@tanstack/router-core 0.0.1-beta.3 → 0.0.1-beta.30

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 (56) hide show
  1. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -2
  2. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  3. package/build/cjs/{packages/router-core/src/index.js → index.js} +23 -7
  4. package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
  5. package/build/cjs/{packages/router-core/src/path.js → path.js} +7 -34
  6. package/build/cjs/path.js.map +1 -0
  7. package/build/cjs/{packages/router-core/src/qss.js → qss.js} +9 -13
  8. package/build/cjs/qss.js.map +1 -0
  9. package/build/cjs/{packages/router-core/src/route.js → route.js} +15 -37
  10. package/build/cjs/route.js.map +1 -0
  11. package/build/cjs/{packages/router-core/src/routeConfig.js → routeConfig.js} +13 -12
  12. package/build/cjs/routeConfig.js.map +1 -0
  13. package/build/cjs/routeMatch.js +200 -0
  14. package/build/cjs/routeMatch.js.map +1 -0
  15. package/build/cjs/{packages/router-core/src/router.js → router.js} +246 -208
  16. package/build/cjs/router.js.map +1 -0
  17. package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +7 -10
  18. package/build/cjs/searchParams.js.map +1 -0
  19. package/build/cjs/{packages/router-core/src/utils.js → utils.js} +17 -30
  20. package/build/cjs/utils.js.map +1 -0
  21. package/build/esm/index.js +382 -1307
  22. package/build/esm/index.js.map +1 -1
  23. package/build/stats-html.html +59 -49
  24. package/build/stats-react.json +161 -168
  25. package/build/types/index.d.ts +228 -206
  26. package/build/umd/index.development.js +373 -481
  27. package/build/umd/index.development.js.map +1 -1
  28. package/build/umd/index.production.js +1 -1
  29. package/build/umd/index.production.js.map +1 -1
  30. package/package.json +3 -2
  31. package/src/frameworks.ts +2 -2
  32. package/src/index.ts +0 -1
  33. package/src/link.ts +8 -5
  34. package/src/path.ts +2 -6
  35. package/src/qss.ts +1 -0
  36. package/src/route.ts +24 -32
  37. package/src/routeConfig.ts +100 -77
  38. package/src/routeInfo.ts +22 -7
  39. package/src/routeMatch.ts +95 -157
  40. package/src/router.ts +346 -122
  41. package/src/utils.ts +14 -7
  42. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  43. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  44. package/build/cjs/node_modules/history/index.js +0 -815
  45. package/build/cjs/node_modules/history/index.js.map +0 -1
  46. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  47. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  48. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  49. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  50. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  51. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  52. package/build/cjs/packages/router-core/src/routeMatch.js +0 -266
  53. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  54. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  55. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  56. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.3",
4
+ "version": "0.0.1-beta.30",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -23,7 +23,7 @@
23
23
  "url": "https://github.com/sponsors/tannerlinsley"
24
24
  },
25
25
  "module": "build/esm/index.js",
26
- "main": "build/cjs/packages/router-core/src/index.js",
26
+ "main": "build/cjs/index.js",
27
27
  "browser": "build/umd/index.production.js",
28
28
  "types": "build/types/index.d.ts",
29
29
  "engines": {
@@ -33,6 +33,7 @@
33
33
  "build/**",
34
34
  "src"
35
35
  ],
36
+ "sideEffects": false,
36
37
  "peerDependencies": {
37
38
  "react": ">=16",
38
39
  "react-dom": ">=16"
package/src/frameworks.ts CHANGED
@@ -3,8 +3,8 @@ export interface FrameworkGenerics {
3
3
  // and are extended by framework adapters, but cannot be
4
4
  // pre-defined as constraints:
5
5
  //
6
- // Element: any
7
- // SyncOrAsyncElement?: any
6
+ // Component: any
7
+ // ErrorComponent: any
8
8
  }
9
9
 
10
10
  export type GetFrameworkGeneric<U> = U extends keyof FrameworkGenerics
package/src/index.ts CHANGED
@@ -7,7 +7,6 @@ export {
7
7
  export { default as invariant } from 'tiny-invariant'
8
8
 
9
9
  export * from './frameworks'
10
- export * from './index'
11
10
  export * from './link'
12
11
  export * from './path'
13
12
  export * from './qss'
package/src/link.ts CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  DefaultAllRouteInfo,
5
5
  RouteInfoByPath,
6
6
  } from './routeInfo'
7
- import { Location } from './router'
8
- import { Expand, NoInfer, PickAsRequired, PickRequired, Updater } from './utils'
7
+ import { Location, LocationState } from './router'
8
+ import { Expand, NoInfer, PickRequired, Updater } from './utils'
9
9
 
10
10
  export type LinkInfo =
11
11
  | {
@@ -58,7 +58,7 @@ export type Split<S, TIncludeTrailingSlash = true> = S extends unknown
58
58
  : never
59
59
 
60
60
  export type ParsePathParams<T extends string> = Split<T>[number] extends infer U
61
- ? U extends `:${infer V}`
61
+ ? U extends `$${infer V}`
62
62
  ? V
63
63
  : never
64
64
  : never
@@ -126,6 +126,8 @@ export type ToOptions<
126
126
  to?: ToPathOption<TAllRouteInfo, TFrom, TTo>
127
127
  // The new has string or a function to update it
128
128
  hash?: Updater<string>
129
+ // State to pass to the history stack
130
+ state?: LocationState
129
131
  // 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
132
  from?: TFrom
131
133
  // // When using relative route paths, this option forces resolution from the current path, instead of the route API's path or `from` path
@@ -140,8 +142,9 @@ type SearchParamOptions<
140
142
  TTo,
141
143
  TFromSchema = RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema'],
142
144
  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
+ > = StartsWith<TFrom, TTo> extends true
146
+ ? // If the next route search extend or cover the from route, params will be optional
147
+ {
145
148
  search?: SearchReducer<TFromSchema, TToSchema>
146
149
  }
147
150
  : // Optional search params? Allow it
package/src/path.ts CHANGED
@@ -97,7 +97,7 @@ export function parsePathname(pathname?: string): Segment[] {
97
97
  }
98
98
  }
99
99
 
100
- if (part.charAt(0) === ':') {
100
+ if (part.charAt(0) === '$') {
101
101
  return {
102
102
  type: 'param',
103
103
  value: part,
@@ -155,10 +155,6 @@ export function matchPathname(
155
155
  return
156
156
  }
157
157
 
158
- // if (matchLocation.search && !searchMatched) {
159
- // return
160
- // }
161
-
162
158
  return pathParams ?? {}
163
159
  }
164
160
 
@@ -219,7 +215,7 @@ export function matchByPath(
219
215
  if (baseSegment?.value === '/') {
220
216
  return false
221
217
  }
222
- if (!baseSegment.value.startsWith(':')) {
218
+ if (baseSegment.value.charAt(0) !== '$') {
223
219
  params[routeSegment.value.substring(1)] = baseSegment.value
224
220
  }
225
221
  }
package/src/qss.ts CHANGED
@@ -30,6 +30,7 @@ function toValue(mix) {
30
30
  var str = decodeURIComponent(mix)
31
31
  if (str === 'false') return false
32
32
  if (str === 'true') return true
33
+ if (str.charAt(0) === '0') return str
33
34
  return +str * 0 === 0 ? +str : str
34
35
  }
35
36
 
package/src/route.ts CHANGED
@@ -13,7 +13,6 @@ import {
13
13
  RouteInfo,
14
14
  RouteInfoByPath,
15
15
  } from './routeInfo'
16
- import { RouteMatch } from './routeMatch'
17
16
  import {
18
17
  Action,
19
18
  ActionState,
@@ -22,14 +21,16 @@ import {
22
21
  MatchRouteOptions,
23
22
  Router,
24
23
  } from './router'
25
- import { NoInfer, replaceEqualDeep } from './utils'
24
+ import { NoInfer } from './utils'
26
25
 
27
- export interface AnyRoute extends Route<any, any> {}
26
+ export interface AnyRoute extends Route<any, any, any> {}
28
27
 
29
28
  export interface Route<
30
29
  TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
31
30
  TRouteInfo extends AnyRouteInfo = RouteInfo,
31
+ TRouterContext = unknown,
32
32
  > {
33
+ routeInfo: TRouteInfo
33
34
  routeId: TRouteInfo['id']
34
35
  routeRouteId: TRouteInfo['routeId']
35
36
  routePath: TRouteInfo['path']
@@ -37,7 +38,7 @@ export interface Route<
37
38
  parentRoute?: AnyRoute
38
39
  childRoutes?: AnyRoute[]
39
40
  options: RouteOptions
40
- router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>
41
+ router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>
41
42
  buildLink: <TTo extends string = '.'>(
42
43
  options: Omit<
43
44
  LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>,
@@ -57,7 +58,10 @@ export interface Route<
57
58
  opts?: MatchRouteOptions,
58
59
  ) => RouteInfoByPath<TAllRouteInfo, TResolved>['allParams']
59
60
  navigate: <TTo extends string = '.'>(
60
- options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['id'], TTo>, 'from'>,
61
+ options: Omit<
62
+ LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>,
63
+ 'from'
64
+ >,
61
65
  ) => Promise<void>
62
66
  action: unknown extends TRouteInfo['actionResponse']
63
67
  ?
@@ -84,22 +88,23 @@ export interface Route<
84
88
  export function createRoute<
85
89
  TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
86
90
  TRouteInfo extends AnyRouteInfo = RouteInfo,
91
+ TRouterContext = unknown,
87
92
  >(
88
93
  routeConfig: RouteConfig,
89
94
  options: TRouteInfo['options'],
90
95
  parent: undefined | Route<TAllRouteInfo, any>,
91
- router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>,
92
- ): Route<TAllRouteInfo, TRouteInfo> {
96
+ router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>,
97
+ ): Route<TAllRouteInfo, TRouteInfo, TRouterContext> {
93
98
  const { id, routeId, path: routePath, fullPath } = routeConfig
94
99
 
95
100
  const action =
96
101
  router.state.actions[id] ||
97
102
  (() => {
98
103
  router.state.actions[id] = {
99
- pending: [],
104
+ submissions: [],
100
105
  submit: async <T, U>(
101
106
  submission: T,
102
- actionOpts?: { invalidate?: boolean },
107
+ actionOpts?: { invalidate?: boolean; multi?: boolean },
103
108
  ) => {
104
109
  if (!route) {
105
110
  return
@@ -107,27 +112,27 @@ export function createRoute<
107
112
 
108
113
  const invalidate = actionOpts?.invalidate ?? true
109
114
 
115
+ if (!actionOpts?.multi) {
116
+ action.submissions = action.submissions.filter((d) => d.isMulti)
117
+ }
118
+
110
119
  const actionState: ActionState<T, U> = {
111
120
  submittedAt: Date.now(),
112
121
  status: 'pending',
113
122
  submission,
123
+ isMulti: !!actionOpts?.multi,
114
124
  }
115
125
 
116
126
  action.current = actionState
117
127
  action.latest = actionState
118
- action.pending.push(actionState)
119
-
120
- router.state = {
121
- ...router.state,
122
- currentAction: actionState,
123
- latestAction: actionState,
124
- }
128
+ action.submissions.push(actionState)
125
129
 
126
130
  router.notify()
127
131
 
128
132
  try {
129
133
  const res = await route.options.action?.(submission)
130
134
  actionState.data = res as U
135
+
131
136
  if (invalidate) {
132
137
  router.invalidateRoute({ to: '.', fromCurrent: true })
133
138
  await router.reload()
@@ -135,12 +140,11 @@ export function createRoute<
135
140
  actionState.status = 'success'
136
141
  return res
137
142
  } catch (err) {
143
+ console.log('tanner')
138
144
  console.error(err)
139
145
  actionState.error = err
140
146
  actionState.status = 'error'
141
147
  } finally {
142
- action.pending = action.pending.filter((d) => d !== actionState)
143
- router.removeActionQueue.push({ action, actionState })
144
148
  router.notify()
145
149
  }
146
150
  },
@@ -187,7 +191,8 @@ export function createRoute<
187
191
  return router.state.loaders[id]!
188
192
  })()
189
193
 
190
- let route: Route<TAllRouteInfo, TRouteInfo> = {
194
+ let route: Route<TAllRouteInfo, TRouteInfo, TRouterContext> = {
195
+ routeInfo: undefined!,
191
196
  routeId: id,
192
197
  routeRouteId: routeId,
193
198
  routePath,
@@ -228,16 +233,3 @@ export function createRoute<
228
233
 
229
234
  return route
230
235
  }
231
-
232
- export function cascadeLoaderData(matches: RouteMatch<any, any>[]) {
233
- matches.forEach((match, index) => {
234
- const parent = matches[index - 1]
235
-
236
- if (parent) {
237
- match.loaderData = replaceEqualDeep(match.loaderData, {
238
- ...parent.loaderData,
239
- ...match.routeLoaderData,
240
- })
241
- }
242
- })
243
- }
@@ -1,16 +1,11 @@
1
+ import invariant from 'tiny-invariant'
1
2
  import { GetFrameworkGeneric } from './frameworks'
2
3
  import { ParsePathParams } from './link'
3
4
  import { joinPaths, trimPath, trimPathRight } from './path'
4
5
  import { RouteInfo } from './routeInfo'
5
6
  import { RouteMatch } from './routeMatch'
6
- import {
7
- DeepAwaited,
8
- Expand,
9
- IsAny,
10
- NoInfer,
11
- PickUnsafe,
12
- Values,
13
- } from './utils'
7
+ import { RegisteredRouter, Router } from './router'
8
+ import { Expand, IsAny, NoInfer, PickUnsafe } from './utils'
14
9
 
15
10
  export const rootRouteId = '__root__' as const
16
11
  export type RootRouteId = typeof rootRouteId
@@ -50,12 +45,12 @@ export type ParentParams<TParentParams> = AnyPathParams extends TParentParams
50
45
  }
51
46
 
52
47
  export type LoaderFn<
53
- TRouteLoaderData extends AnyLoaderData,
48
+ TRouteLoaderData extends AnyLoaderData = {},
54
49
  TFullSearchSchema extends AnySearchSchema = {},
55
50
  TAllParams extends AnyPathParams = {},
56
51
  > = (
57
52
  loaderContext: LoaderContext<TFullSearchSchema, TAllParams>,
58
- ) => Promise<TRouteLoaderData>
53
+ ) => TRouteLoaderData | Promise<TRouteLoaderData>
59
54
 
60
55
  export interface LoaderContext<
61
56
  TFullSearchSchema extends AnySearchSchema = {},
@@ -64,6 +59,7 @@ export interface LoaderContext<
64
59
  params: TAllParams
65
60
  search: TFullSearchSchema
66
61
  signal?: AbortSignal
62
+ // parentLoaderPromise?: Promise<TParentRouteLoaderData>
67
63
  }
68
64
 
69
65
  export type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (
@@ -77,7 +73,9 @@ export type UnloaderFn<TPath extends string> = (
77
73
  export type RouteOptions<
78
74
  TRouteId extends string = string,
79
75
  TPath extends string = string,
76
+ TParentRouteLoaderData extends AnyLoaderData = {},
80
77
  TRouteLoaderData extends AnyLoaderData = {},
78
+ TParentLoaderData extends AnyLoaderData = {},
81
79
  TLoaderData extends AnyLoaderData = {},
82
80
  TActionPayload = unknown,
83
81
  TActionResponse = unknown,
@@ -108,18 +106,12 @@ export type RouteOptions<
108
106
  // Filter functions that can manipulate search params *after* they are passed to links and navigate
109
107
  // calls that match this route.
110
108
  postSearchFilters?: SearchFilter<TFullSearchSchema>[]
111
- // The duration to wait during `loader` execution before showing the `pendingElement`
112
- pendingMs?: number
113
- // _If the `pendingElement` is shown_, the minimum duration for which it will be visible.
114
- pendingMinMs?: number
115
- // The content to be rendered when the route is matched. If no element is provided, defaults to `<Outlet />`
116
- element?: GetFrameworkGeneric<'SyncOrAsyncElement'> // , NoInfer<TLoaderData>>
117
- // The content to be rendered when `loader` encounters an error
118
- errorElement?: GetFrameworkGeneric<'SyncOrAsyncElement'> // , NoInfer<TLoaderData>>
119
- // The content to be rendered when rendering encounters an error
120
- catchElement?: GetFrameworkGeneric<'SyncOrAsyncElement'> // , NoInfer<TLoaderData>>
121
- // The content to be rendered when the duration of `loader` execution surpasses the `pendingMs` duration
122
- pendingElement?: GetFrameworkGeneric<'SyncOrAsyncElement'> //, NoInfer<TLoaderData>>
109
+ // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
110
+ component?: GetFrameworkGeneric<'Component'> // , NoInfer<TParentLoaderData>>
111
+ // The content to be rendered when the route encounters an error
112
+ errorComponent?: GetFrameworkGeneric<'ErrorComponent'> // , NoInfer<TParentLoaderData>>
113
+ // If supported by your framework, the content to be rendered as the fallback content until the route is ready to render
114
+ pendingComponent?: GetFrameworkGeneric<'Component'> //, NoInfer<TParentLoaderData>>
123
115
  // An asynchronous function responsible for preparing or fetching data for the route before it is rendered
124
116
  loader?: LoaderFn<TRouteLoaderData, TFullSearchSchema, TAllParams>
125
117
  // The max age to consider loader data fresh (not-stale) for this route in milliseconds from the time of fetch
@@ -131,13 +123,16 @@ export type RouteOptions<
131
123
  // An asynchronous function made available to the route for performing asynchronous or mutative actions that
132
124
  // might invalidate the route's data.
133
125
  action?: ActionFn<TActionPayload, TActionResponse>
134
- // Set this to true to rethrow errors up the component tree to either the nearest error boundary or
135
- // route with error element, whichever comes first.
136
- useErrorBoundary?: boolean
126
+ // This async function is called before a route is loaded. If an error is thrown, the navigation is cancelled.
127
+ // If you want to redirect instead, throw a call to the `router.navigate()` function
128
+ beforeLoad?: (opts: {
129
+ router: Router<any, any, unknown>
130
+ match: RouteMatch
131
+ }) => Promise<void> | void
137
132
  // This function is called
138
133
  // when moving from an inactive state to an active one. Likewise, when moving from
139
134
  // an active to an inactive state, the return function (if provided) is called.
140
- onMatch?: (matchContext: {
135
+ onLoaded?: (matchContext: {
141
136
  params: TAllParams
142
137
  search: TFullSearchSchema
143
138
  }) =>
@@ -177,7 +172,9 @@ export interface RouteConfig<
177
172
  TRouteId extends string = string,
178
173
  TPath extends string = string,
179
174
  TFullPath extends string = string,
175
+ TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData,
180
176
  TRouteLoaderData extends AnyLoaderData = AnyLoaderData,
177
+ TParentLoaderData extends AnyLoaderData = {},
181
178
  TLoaderData extends AnyLoaderData = AnyLoaderData,
182
179
  TActionPayload = unknown,
183
180
  TActionResponse = unknown,
@@ -185,10 +182,7 @@ export interface RouteConfig<
185
182
  TSearchSchema extends AnySearchSchema = {},
186
183
  TFullSearchSchema extends AnySearchSchema = {},
187
184
  TParentParams extends AnyPathParams = {},
188
- TParams extends Record<ParsePathParams<TPath>, unknown> = Record<
189
- ParsePathParams<TPath>,
190
- string
191
- >,
185
+ TParams extends AnyPathParams = {},
192
186
  TAllParams extends AnyPathParams = {},
193
187
  TKnownChildren = unknown,
194
188
  > {
@@ -199,7 +193,9 @@ export interface RouteConfig<
199
193
  options: RouteOptions<
200
194
  TRouteId,
201
195
  TPath,
196
+ TParentRouteLoaderData,
202
197
  TRouteLoaderData,
198
+ TParentLoaderData,
203
199
  TLoaderData,
204
200
  TActionPayload,
205
201
  TActionResponse,
@@ -223,7 +219,9 @@ export interface RouteConfig<
223
219
  TRouteId,
224
220
  TPath,
225
221
  TFullPath,
222
+ TParentRouteLoaderData,
226
223
  TRouteLoaderData,
224
+ TParentLoaderData,
227
225
  TLoaderData,
228
226
  TActionPayload,
229
227
  TActionResponse,
@@ -236,55 +234,74 @@ export interface RouteConfig<
236
234
  TNewChildren
237
235
  >
238
236
  >
239
- createChildren: IsAny<
237
+ createRoute: CreateRouteConfigFn<
238
+ false,
240
239
  TId,
241
- any,
242
- <TNewChildren extends any>(
243
- cb: (
244
- createChildRoute: CreateRouteConfigFn<
245
- false,
246
- TId,
247
- TFullPath,
248
- TLoaderData,
249
- TFullSearchSchema,
250
- TAllParams
251
- >,
252
- ) => TNewChildren extends AnyRouteConfig[]
253
- ? TNewChildren
254
- : { error: 'Invalid route detected'; route: TNewChildren },
255
- ) => RouteConfig<
256
- TId,
240
+ TFullPath,
241
+ TRouteLoaderData,
242
+ TLoaderData,
243
+ TFullSearchSchema,
244
+ TAllParams
245
+ >
246
+ generate: GenerateFn<
247
+ TRouteId,
248
+ TPath,
249
+ TParentRouteLoaderData,
250
+ TParentLoaderData,
251
+ TParentSearchSchema,
252
+ TParentParams
253
+ >
254
+ }
255
+
256
+ type GenerateFn<
257
+ TRouteId extends string = string,
258
+ TPath extends string = string,
259
+ TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData,
260
+ TParentLoaderData extends AnyLoaderData = {},
261
+ TParentSearchSchema extends {} = {},
262
+ TParentParams extends AnyPathParams = {},
263
+ > = <
264
+ TRouteLoaderData extends AnyLoaderData = AnyLoaderData,
265
+ TActionPayload = unknown,
266
+ TActionResponse = unknown,
267
+ TSearchSchema extends AnySearchSchema = {},
268
+ TParams extends Record<ParsePathParams<TPath>, unknown> = Record<
269
+ ParsePathParams<TPath>,
270
+ string
271
+ >,
272
+ TAllParams extends AnyPathParams extends TParams
273
+ ? Record<ParsePathParams<TPath>, string>
274
+ : NoInfer<TParams> = AnyPathParams extends TParams
275
+ ? Record<ParsePathParams<TPath>, string>
276
+ : NoInfer<TParams>,
277
+ >(
278
+ options: Omit<
279
+ RouteOptions<
257
280
  TRouteId,
258
281
  TPath,
259
- TFullPath,
282
+ TParentRouteLoaderData,
260
283
  TRouteLoaderData,
261
- TLoaderData,
284
+ TParentLoaderData,
285
+ Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>,
262
286
  TActionPayload,
263
287
  TActionResponse,
264
288
  TParentSearchSchema,
265
289
  TSearchSchema,
266
- TFullSearchSchema,
290
+ Expand<TParentSearchSchema & TSearchSchema>,
267
291
  TParentParams,
268
292
  TParams,
269
- TAllParams,
270
- TNewChildren
271
- >
272
- >
273
- createRoute: CreateRouteConfigFn<
274
- false,
275
- TId,
276
- TFullPath,
277
- TLoaderData,
278
- TFullSearchSchema,
279
- TAllParams
280
- >
281
- }
293
+ Expand<TParentParams & TAllParams>
294
+ >,
295
+ 'path'
296
+ >,
297
+ ) => void
282
298
 
283
299
  type CreateRouteConfigFn<
284
300
  TIsRoot extends boolean = false,
285
301
  TParentId extends string = string,
286
302
  TParentPath extends string = string,
287
- TParentAllLoaderData extends AnyLoaderData = {},
303
+ TParentRouteLoaderData extends AnyLoaderData = {},
304
+ TParentLoaderData extends AnyLoaderData = {},
288
305
  TParentSearchSchema extends AnySearchSchema = {},
289
306
  TParentParams extends AnyPathParams = {},
290
307
  > = <
@@ -315,8 +332,10 @@ type CreateRouteConfigFn<
315
332
  RouteOptions<
316
333
  TRouteId,
317
334
  TPath,
335
+ TParentRouteLoaderData,
318
336
  TRouteLoaderData,
319
- Expand<TParentAllLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>,
337
+ TParentLoaderData,
338
+ Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>,
320
339
  TActionPayload,
321
340
  TActionResponse,
322
341
  TParentSearchSchema,
@@ -331,8 +350,10 @@ type CreateRouteConfigFn<
331
350
  : RouteOptions<
332
351
  TRouteId,
333
352
  TPath,
353
+ TParentRouteLoaderData,
334
354
  TRouteLoaderData,
335
- Expand<TParentAllLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>,
355
+ TParentLoaderData,
356
+ Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>,
336
357
  TActionPayload,
337
358
  TActionResponse,
338
359
  TParentSearchSchema,
@@ -351,8 +372,10 @@ type CreateRouteConfigFn<
351
372
  TResolvedId,
352
373
  TPath,
353
374
  string extends TPath ? '' : RoutePath<RoutePrefix<TParentPath, TPath>>,
375
+ TParentRouteLoaderData,
354
376
  TRouteLoaderData,
355
- Expand<TParentAllLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>,
377
+ TParentLoaderData,
378
+ Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>,
356
379
  TActionPayload,
357
380
  TActionResponse,
358
381
  TParentSearchSchema,
@@ -395,6 +418,8 @@ export interface AnyRouteConfig
395
418
  any,
396
419
  any,
397
420
  any,
421
+ any,
422
+ any,
398
423
  any
399
424
  > {}
400
425
 
@@ -414,6 +439,8 @@ export interface AnyRouteConfigWithChildren<TChildren>
414
439
  any,
415
440
  any,
416
441
  any,
442
+ any,
443
+ any,
417
444
  TChildren
418
445
  > {}
419
446
 
@@ -477,19 +504,15 @@ export const createRouteConfig: CreateRouteConfigFn<true> = (
477
504
  fullPath: fullPath as any,
478
505
  options: options as any,
479
506
  children,
480
- createChildren: (cb: any) =>
481
- createRouteConfig(
482
- options,
483
- cb((childOptions: any) =>
484
- createRouteConfig(childOptions, undefined, false, id, fullPath),
485
- ),
486
- false,
487
- parentId,
488
- parentPath,
489
- ),
490
507
  addChildren: (children: any) =>
491
508
  createRouteConfig(options, children, false, parentId, parentPath),
492
509
  createRoute: (childOptions: any) =>
493
510
  createRouteConfig(childOptions, undefined, false, id, fullPath) as any,
511
+ generate: () => {
512
+ invariant(
513
+ false,
514
+ `routeConfig.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. `,
515
+ )
516
+ },
494
517
  }
495
518
  }