@tanstack/react-router 0.0.1-beta.208 → 0.0.1-beta.209

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.208",
4
+ "version": "0.0.1-beta.209",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -42,7 +42,7 @@
42
42
  "@babel/runtime": "^7.16.7",
43
43
  "tiny-invariant": "^1.3.1",
44
44
  "tiny-warning": "^1.0.3",
45
- "@tanstack/history": "0.0.1-beta.208"
45
+ "@tanstack/history": "0.0.1-beta.209"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "rollup --config rollup.config.js"
package/src/RouteMatch.ts CHANGED
@@ -18,7 +18,7 @@ export interface RouteMatch<
18
18
  updatedAt: number
19
19
  loadPromise?: Promise<void>
20
20
  __resolveLoadPromise?: () => void
21
- meta: RouteById<TRouteTree, TRouteId>['types']['allMeta']
21
+ context: RouteById<TRouteTree, TRouteId>['types']['allContext']
22
22
  routeSearch: RouteById<TRouteTree, TRouteId>['types']['searchSchema']
23
23
  search: FullSearchSchema<TRouteTree> &
24
24
  RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema']
@@ -159,13 +159,13 @@ export function RouterProvider<
159
159
  const options = {
160
160
  ...router.options,
161
161
  ...rest,
162
- meta: {
163
- ...router.options.meta,
164
- ...rest?.meta,
162
+ context: {
163
+ ...router.options.context,
164
+ ...rest?.context,
165
165
  },
166
166
  } as PickAsRequired<
167
167
  RouterOptions<TRouteTree, TDehydrated>,
168
- 'stringifySearch' | 'parseSearch' | 'meta'
168
+ 'stringifySearch' | 'parseSearch' | 'context'
169
169
  >
170
170
 
171
171
  const history = React.useState(
@@ -451,7 +451,7 @@ export function RouterProvider<
451
451
  paramsError: parseErrors[index],
452
452
  searchError: undefined,
453
453
  loadPromise: Promise.resolve(),
454
- meta: undefined!,
454
+ context: undefined!,
455
455
  abortController: new AbortController(),
456
456
  fetchedAt: 0,
457
457
  }
@@ -459,9 +459,9 @@ export function RouterProvider<
459
459
  return routeMatch
460
460
  })
461
461
 
462
- // Take each match and resolve its search params and meta
462
+ // Take each match and resolve its search params and context
463
463
  // This has to happen after the matches are created or found
464
- // so that we can use the parent match's search params and meta
464
+ // so that we can use the parent match's search params and context
465
465
  matches.forEach((match, i): any => {
466
466
  const parentMatch = matches[i - 1]
467
467
  const route = looseRoutesById[match.routeId]!
@@ -848,27 +848,27 @@ export function RouterProvider<
848
848
  handleError(match.searchError, 'VALIDATE_SEARCH')
849
849
  }
850
850
 
851
- const parentMeta = parentMatch?.meta ?? options.meta ?? {}
851
+ const parentContext = parentMatch?.context ?? options.context ?? {}
852
852
 
853
- const beforeLoadMeta =
853
+ const beforeLoadContext =
854
854
  (await route.options.beforeLoad?.({
855
855
  search: match.search,
856
856
  abortController: match.abortController,
857
857
  params: match.params,
858
858
  preload: !!preload,
859
- meta: parentMeta,
859
+ context: parentContext,
860
860
  location: state.location, // TODO: This might need to be latestLocationRef.current...?
861
861
  navigate: (opts) => navigate({ ...opts, from: match.pathname }),
862
862
  })) ?? ({} as any)
863
863
 
864
- const meta = {
865
- ...parentMeta,
866
- ...beforeLoadMeta,
864
+ const context = {
865
+ ...parentContext,
866
+ ...beforeLoadContext,
867
867
  }
868
868
 
869
869
  matches[index] = match = {
870
870
  ...match,
871
- meta: replaceEqualDeep(match.meta, meta),
871
+ context: replaceEqualDeep(match.context, context),
872
872
  }
873
873
  } catch (err) {
874
874
  handleError(err, 'BEFORE_LOAD')
@@ -925,7 +925,7 @@ export function RouterProvider<
925
925
  preload: !!preload,
926
926
  parentMatchPromise,
927
927
  abortController: match.abortController,
928
- meta: match.meta,
928
+ context: match.context,
929
929
  location: state.location,
930
930
  navigate: (opts) =>
931
931
  navigate({ ...opts, from: match.pathname }),
package/src/fileRoute.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  ResolveFullPath,
5
5
  ResolveFullSearchSchema,
6
6
  MergeFromFromParent,
7
- RouteMeta,
7
+ RouteContext,
8
8
  AnyContext,
9
9
  RouteOptions,
10
10
  UpdatableRouteOptions,
@@ -97,11 +97,13 @@ export class FileRoute<
97
97
  TParentRoute['types']['allParams'],
98
98
  TParams
99
99
  >,
100
- TRouteMeta extends RouteConstraints['TRouteMeta'] = RouteMeta,
100
+ TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
101
101
  TContext extends Expand<
102
- Assign<IsAny<TParentRoute['types']['allMeta'], {}>, TRouteMeta>
103
- > = Expand<Assign<IsAny<TParentRoute['types']['allMeta'], {}>, TRouteMeta>>,
104
- TRouterMeta extends RouteConstraints['TRouterMeta'] = AnyContext,
102
+ Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
103
+ > = Expand<
104
+ Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
105
+ >,
106
+ TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
105
107
  TChildren extends RouteConstraints['TChildren'] = unknown,
106
108
  TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,
107
109
  >(
@@ -114,7 +116,7 @@ export class FileRoute<
114
116
  TFullSearchSchema,
115
117
  TParams,
116
118
  TAllParams,
117
- TRouteMeta,
119
+ TRouteContext,
118
120
  TContext
119
121
  >,
120
122
  'getParentRoute' | 'path' | 'id'
@@ -130,9 +132,9 @@ export class FileRoute<
130
132
  TFullSearchSchema,
131
133
  TParams,
132
134
  TAllParams,
133
- TRouteMeta,
135
+ TRouteContext,
134
136
  TContext,
135
- TRouterMeta,
137
+ TRouterContext,
136
138
  TChildren,
137
139
  TRouteTree
138
140
  > => {
package/src/react.tsx CHANGED
@@ -40,7 +40,7 @@ export type RouteProps<
40
40
  useMatch: <TSelected = TAllContext>(opts?: {
41
41
  select?: (search: TAllContext) => TSelected
42
42
  }) => TSelected
43
- useRouteMeta: <TSelected = TAllContext>(opts?: {
43
+ useRouteContext: <TSelected = TAllContext>(opts?: {
44
44
  select?: (search: TAllContext) => TSelected
45
45
  }) => TSelected
46
46
  useSearch: <TSelected = TFullSearchSchema>(opts?: {
@@ -398,7 +398,7 @@ export type RouterProps<
398
398
  TDehydrated extends Record<string, any> = Record<string, any>,
399
399
  > = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & {
400
400
  router: Router<TRouteTree>
401
- context?: Partial<RouterOptions<TRouteTree, TDehydrated>['meta']>
401
+ context?: Partial<RouterOptions<TRouteTree, TDehydrated>['context']>
402
402
  }
403
403
 
404
404
  export function useRouter<
@@ -515,21 +515,23 @@ export type RouteFromIdOrRoute<
515
515
  ? RouteIds<TRouteTree>
516
516
  : never
517
517
 
518
- export function useRouteMeta<
518
+ export function useRouteContext<
519
519
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
520
520
  TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
521
521
  TStrict extends boolean = true,
522
- TRouteMeta = RouteById<TRouteTree, TFrom>['types']['allMeta'],
523
- TSelected = TRouteMeta,
522
+ TRouteContext = RouteById<TRouteTree, TFrom>['types']['allContext'],
523
+ TSelected = TRouteContext,
524
524
  >(
525
525
  opts: StrictOrFrom<TFrom> & {
526
- select?: (search: TRouteMeta) => TSelected
526
+ select?: (search: TRouteContext) => TSelected
527
527
  },
528
528
  ): TStrict extends true ? TSelected : TSelected | undefined {
529
529
  return useMatch({
530
530
  ...(opts as any),
531
531
  select: (match: RouteMatch) =>
532
- opts?.select ? opts.select(match.meta as TRouteMeta) : match.meta,
532
+ opts?.select
533
+ ? opts.select(match.context as TRouteContext)
534
+ : match.context,
533
535
  })
534
536
  }
535
537
 
@@ -666,7 +668,7 @@ export function Matches() {
666
668
  return React.createElement(ErrorComponent, {
667
669
  ...props,
668
670
  useMatch: route.useMatch,
669
- useRouteMeta: route.useRouteMeta,
671
+ useRouteContext: route.useRouteContext,
670
672
  useSearch: route.useSearch,
671
673
  useParams: route.useParams,
672
674
  })
@@ -755,7 +757,7 @@ function Match({ matches }: { matches: RouteMatch[] }) {
755
757
  return React.createElement(routeErrorComponent, {
756
758
  ...props,
757
759
  useMatch: route.useMatch,
758
- useRouteMeta: route.useRouteMeta,
760
+ useRouteContext: route.useRouteContext,
759
761
  useSearch: route.useSearch,
760
762
  useParams: route.useParams,
761
763
  })
@@ -768,7 +770,7 @@ function Match({ matches }: { matches: RouteMatch[] }) {
768
770
  <ResolvedSuspenseBoundary
769
771
  fallback={React.createElement(PendingComponent, {
770
772
  useMatch: route.useMatch,
771
- useRouteMeta: route.useRouteMeta,
773
+ useRouteContext: route.useRouteContext,
772
774
  useSearch: route.useSearch,
773
775
  useParams: route.useParams,
774
776
  })}
@@ -805,7 +807,7 @@ function MatchInner({ match }: { match: RouteMatch }): any {
805
807
  if (comp) {
806
808
  return React.createElement(comp, {
807
809
  useMatch: route.useMatch,
808
- useRouteMeta: route.useRouteMeta as any,
810
+ useRouteContext: route.useRouteContext as any,
809
811
  useSearch: route.useSearch,
810
812
  useParams: route.useParams as any,
811
813
  } as any)
package/src/route.ts CHANGED
@@ -29,6 +29,7 @@ export type RootRouteId = typeof rootRouteId
29
29
  export type AnyPathParams = {}
30
30
  export type AnySearchSchema = {}
31
31
  export type AnyContext = {}
32
+ export interface RouteContext {}
32
33
  export interface RouteMeta {}
33
34
 
34
35
  export type PreloadableObj = { preload?: () => Promise<void> }
@@ -44,13 +45,13 @@ export type RoutePathOptions<TCustomId, TPath> =
44
45
  export type RoutePathOptionsIntersection<TCustomId, TPath> =
45
46
  UnionToIntersection<RoutePathOptions<TCustomId, TPath>>
46
47
 
47
- // export type MetaOptions = keyof PickRequired<RouteMeta> extends never
48
- // ? {
49
- // meta?: RouteMeta
50
- // }
51
- // : {
52
- // meta: RouteMeta
53
- // }
48
+ export type MetaOptions = keyof PickRequired<RouteMeta> extends never
49
+ ? {
50
+ meta?: RouteMeta
51
+ }
52
+ : {
53
+ meta: RouteMeta
54
+ }
54
55
 
55
56
  export type RouteOptions<
56
57
  TParentRoute extends AnyRoute = AnyRoute,
@@ -60,8 +61,8 @@ export type RouteOptions<
60
61
  TFullSearchSchema extends Record<string, any> = TSearchSchema,
61
62
  TParams extends AnyPathParams = AnyPathParams,
62
63
  TAllParams extends AnyPathParams = TParams,
63
- TRouteMeta extends RouteMeta = RouteMeta,
64
- TAllMeta extends Record<string, any> = AnyContext,
64
+ TRouteContext extends RouteContext = RouteContext,
65
+ TAllContext extends Record<string, any> = AnyContext,
65
66
  > = BaseRouteOptions<
66
67
  TParentRoute,
67
68
  TCustomId,
@@ -70,10 +71,10 @@ export type RouteOptions<
70
71
  TFullSearchSchema,
71
72
  TParams,
72
73
  TAllParams,
73
- TRouteMeta,
74
- TAllMeta
74
+ TRouteContext,
75
+ TAllContext
75
76
  > &
76
- NoInfer<UpdatableRouteOptions<TFullSearchSchema, TAllParams, TAllMeta>>
77
+ NoInfer<UpdatableRouteOptions<TFullSearchSchema, TAllParams, TAllContext>>
77
78
 
78
79
  export type ParamsFallback<
79
80
  TPath extends string,
@@ -92,12 +93,12 @@ export type BaseRouteOptions<
92
93
  TFullSearchSchema extends Record<string, any> = TSearchSchema,
93
94
  TParams extends AnyPathParams = {},
94
95
  TAllParams = ParamsFallback<TPath, TParams>,
95
- TRouteMeta extends RouteMeta = RouteMeta,
96
+ TRouteContext extends RouteContext = RouteContext,
96
97
  TAllContext extends Record<string, any> = AnyContext,
97
98
  > = RoutePathOptions<TCustomId, TPath> & {
98
99
  getParentRoute: () => TParentRoute
99
100
  validateSearch?: SearchSchemaValidator<TSearchSchema>
100
- } & (keyof PickRequired<RouteMeta> extends never
101
+ } & (keyof PickRequired<RouteContext> extends never
101
102
  ? // This async function is called before a route is loaded.
102
103
  // If an error is thrown here, the route's loader will not be called.
103
104
  // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.
@@ -107,7 +108,7 @@ export type BaseRouteOptions<
107
108
  TFullSearchSchema,
108
109
  TParentRoute,
109
110
  TAllParams,
110
- TRouteMeta
111
+ TRouteContext
111
112
  >
112
113
  }
113
114
  : {
@@ -115,14 +116,14 @@ export type BaseRouteOptions<
115
116
  TFullSearchSchema,
116
117
  TParentRoute,
117
118
  TAllParams,
118
- TRouteMeta
119
+ TRouteContext
119
120
  >
120
121
  }) & {
121
122
  load?: RouteLoadFn<
122
123
  TAllParams,
123
124
  TFullSearchSchema,
124
125
  NoInfer<TAllContext>,
125
- NoInfer<TRouteMeta>
126
+ NoInfer<TRouteContext>
126
127
  >
127
128
  } & (
128
129
  | {
@@ -146,61 +147,59 @@ type BeforeLoadFn<
146
147
  TFullSearchSchema extends Record<string, any>,
147
148
  TParentRoute extends AnyRoute,
148
149
  TAllParams,
149
- TRouteMeta,
150
+ TRouteContext,
150
151
  > = (opts: {
151
152
  search: TFullSearchSchema
152
153
  abortController: AbortController
153
154
  preload: boolean
154
155
  params: TAllParams
155
- meta: TParentRoute['types']['allMeta']
156
+ context: TParentRoute['types']['allContext']
156
157
  location: ParsedLocation
157
158
  navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>
158
- }) => Promise<TRouteMeta> | TRouteMeta | void
159
+ }) => Promise<TRouteContext> | TRouteContext | void
159
160
 
160
161
  export type UpdatableRouteOptions<
161
162
  TFullSearchSchema extends Record<string, any>,
162
163
  TAllParams extends AnyPathParams,
163
164
  TAllContext extends AnyContext,
164
- > =
165
- // MetaOptions &
166
- {
167
- // test?: (args: TAllContext) => void
168
- // If true, this route will be matched as case-sensitive
169
- caseSensitive?: boolean
170
- // If true, this route will be forcefully wrapped in a suspense boundary
171
- wrapInSuspense?: boolean
172
- // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
173
- component?: RouteComponent<TFullSearchSchema, TAllParams, TAllContext>
174
- // The content to be rendered when the route encounters an error
175
- errorComponent?: ErrorRouteComponent<
176
- TFullSearchSchema,
177
- TAllParams,
178
- {}
179
- // TAllContext // TODO: I have no idea why this breaks the universe,
180
- // so we'll come back to it later.
181
- > //
182
- // If supported by your framework, the content to be rendered as the fallback content until the route is ready to render
183
- pendingComponent?: PendingRouteComponent<
184
- TFullSearchSchema,
185
- TAllParams,
186
- TAllContext
187
- >
188
- // Filter functions that can manipulate search params *before* they are passed to links and navigate
189
- // calls that match this route.
190
- preSearchFilters?: SearchFilter<TFullSearchSchema>[]
191
- // Filter functions that can manipulate search params *after* they are passed to links and navigate
192
- // calls that match this route.
193
- postSearchFilters?: SearchFilter<TFullSearchSchema>[]
194
- onError?: (err: any) => void
195
- // These functions are called as route matches are loaded, stick around and leave the active
196
- // matches
197
- onEnter?: (match: AnyRouteMatch) => void
198
- onTransition?: (match: AnyRouteMatch) => void
199
- onLeave?: (match: AnyRouteMatch) => void
200
- // Set this to true or false to specifically set whether or not this route should be preloaded. If unset, will
201
- // default to router.options.reloadOnWindowFocus
202
- reloadOnWindowFocus?: boolean
203
- }
165
+ > = MetaOptions & {
166
+ // test?: (args: TAllContext) => void
167
+ // If true, this route will be matched as case-sensitive
168
+ caseSensitive?: boolean
169
+ // If true, this route will be forcefully wrapped in a suspense boundary
170
+ wrapInSuspense?: boolean
171
+ // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
172
+ component?: RouteComponent<TFullSearchSchema, TAllParams, TAllContext>
173
+ // The content to be rendered when the route encounters an error
174
+ errorComponent?: ErrorRouteComponent<
175
+ TFullSearchSchema,
176
+ TAllParams,
177
+ {}
178
+ // TAllContext // TODO: I have no idea why this breaks the universe,
179
+ // so we'll come back to it later.
180
+ > //
181
+ // If supported by your framework, the content to be rendered as the fallback content until the route is ready to render
182
+ pendingComponent?: PendingRouteComponent<
183
+ TFullSearchSchema,
184
+ TAllParams,
185
+ TAllContext
186
+ >
187
+ // Filter functions that can manipulate search params *before* they are passed to links and navigate
188
+ // calls that match this route.
189
+ preSearchFilters?: SearchFilter<TFullSearchSchema>[]
190
+ // Filter functions that can manipulate search params *after* they are passed to links and navigate
191
+ // calls that match this route.
192
+ postSearchFilters?: SearchFilter<TFullSearchSchema>[]
193
+ onError?: (err: any) => void
194
+ // These functions are called as route matches are loaded, stick around and leave the active
195
+ // matches
196
+ onEnter?: (match: AnyRouteMatch) => void
197
+ onTransition?: (match: AnyRouteMatch) => void
198
+ onLeave?: (match: AnyRouteMatch) => void
199
+ // Set this to true or false to specifically set whether or not this route should be preloaded. If unset, will
200
+ // default to router.options.reloadOnWindowFocus
201
+ reloadOnWindowFocus?: boolean
202
+ }
204
203
 
205
204
  export type ParseParamsOption<TPath extends string, TParams> = ParseParamsFn<
206
205
  TPath,
@@ -243,13 +242,13 @@ export type RouteLoadFn<
243
242
  TAllParams = {},
244
243
  TFullSearchSchema extends Record<string, any> = {},
245
244
  TAllContext extends Record<string, any> = AnyContext,
246
- TRouteMeta extends Record<string, any> = AnyContext,
245
+ TRouteContext extends Record<string, any> = AnyContext,
247
246
  > = (
248
247
  match: LoadFnContext<
249
248
  TAllParams,
250
249
  TFullSearchSchema,
251
250
  TAllContext,
252
- TRouteMeta
251
+ TRouteContext
253
252
  > & {
254
253
  parentMatchPromise?: Promise<void>
255
254
  },
@@ -259,13 +258,13 @@ export interface LoadFnContext<
259
258
  TAllParams = {},
260
259
  TFullSearchSchema extends Record<string, any> = {},
261
260
  TAllContext extends Record<string, any> = AnyContext,
262
- TRouteMeta extends Record<string, any> = AnyContext,
261
+ TRouteContext extends Record<string, any> = AnyContext,
263
262
  > {
264
263
  abortController: AbortController
265
264
  preload: boolean
266
265
  params: TAllParams
267
266
  search: TFullSearchSchema
268
- meta: Expand<Assign<TAllContext, TRouteMeta>>
267
+ context: Expand<Assign<TAllContext, TRouteContext>>
269
268
  location: ParsedLocation<TFullSearchSchema>
270
269
  navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>
271
270
  }
@@ -339,9 +338,9 @@ export type RouteConstraints = {
339
338
  TParams: Record<string, any>
340
339
  TAllParams: Record<string, any>
341
340
  TParentContext: AnyContext
342
- TRouteMeta: RouteMeta
341
+ TRouteContext: RouteContext
343
342
  TAllContext: AnyContext
344
- TRouterMeta: AnyContext
343
+ TRouterContext: AnyContext
345
344
  TChildren: unknown
346
345
  TRouteTree: AnyRoute
347
346
  }
@@ -371,11 +370,13 @@ export class Route<
371
370
  TParentRoute,
372
371
  TParams
373
372
  >,
374
- TRouteMeta extends RouteConstraints['TRouteMeta'] = RouteMeta,
375
- TAllMeta extends Expand<
376
- Assign<IsAny<TParentRoute['types']['allMeta'], {}>, TRouteMeta>
377
- > = Expand<Assign<IsAny<TParentRoute['types']['allMeta'], {}>, TRouteMeta>>,
378
- TRouterMeta extends RouteConstraints['TRouterMeta'] = AnyContext,
373
+ TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
374
+ TAllContext extends Expand<
375
+ Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
376
+ > = Expand<
377
+ Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
378
+ >,
379
+ TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
379
380
  TChildren extends RouteConstraints['TChildren'] = unknown,
380
381
  TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,
381
382
  > {
@@ -388,11 +389,13 @@ export class Route<
388
389
  TFullSearchSchema,
389
390
  TParams,
390
391
  TAllParams,
391
- TRouteMeta,
392
- TAllMeta
392
+ TRouteContext,
393
+ TAllContext
393
394
  >
394
395
 
395
- test!: Expand<Assign<IsAny<TParentRoute['types']['allMeta'], {}>, TRouteMeta>>
396
+ test!: Expand<
397
+ Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
398
+ >
396
399
 
397
400
  // Set up in this.init()
398
401
  parentRoute!: TParentRoute
@@ -417,8 +420,8 @@ export class Route<
417
420
  TFullSearchSchema,
418
421
  TParams,
419
422
  TAllParams,
420
- TRouteMeta,
421
- TAllMeta
423
+ TRouteContext,
424
+ TAllContext
422
425
  >,
423
426
  ) {
424
427
  this.options = (options as any) || {}
@@ -437,11 +440,11 @@ export class Route<
437
440
  fullSearchSchema: TFullSearchSchema
438
441
  params: TParams
439
442
  allParams: TAllParams
440
- routeMeta: TRouteMeta
441
- allMeta: TAllMeta
443
+ routeContext: TRouteContext
444
+ allContext: TAllContext
442
445
  children: TChildren
443
446
  routeTree: TRouteTree
444
- routerMeta: TRouterMeta
447
+ routerContext: TRouterContext
445
448
  }
446
449
 
447
450
  init = (opts: { originalIndex: number }) => {
@@ -455,8 +458,8 @@ export class Route<
455
458
  TFullSearchSchema,
456
459
  TParams,
457
460
  TAllParams,
458
- TRouteMeta,
459
- TAllMeta
461
+ TRouteContext,
462
+ TAllContext
460
463
  > &
461
464
  RoutePathOptionsIntersection<TCustomId, TPath>
462
465
 
@@ -522,9 +525,9 @@ export class Route<
522
525
  TFullSearchSchema,
523
526
  TParams,
524
527
  TAllParams,
525
- TRouteMeta,
526
- TAllMeta,
527
- TRouterMeta,
528
+ TRouteContext,
529
+ TAllContext,
530
+ TRouterContext,
528
531
  TNewChildren,
529
532
  TRouteTree
530
533
  > => {
@@ -536,7 +539,9 @@ export class Route<
536
539
  options: UpdatableRouteOptions<
537
540
  TFullSearchSchema,
538
541
  TAllParams,
539
- Expand<Assign<IsAny<TParentRoute['types']['allMeta'], {}>, TRouteMeta>>
542
+ Expand<
543
+ Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
544
+ >
540
545
  >,
541
546
  ) => {
542
547
  Object.assign(this.options, options)
@@ -548,18 +553,18 @@ export class Route<
548
553
  // replaced by a framework specific implementation if necessary
549
554
  }
550
555
 
551
- useMatch = <TSelected = TAllMeta>(opts?: {
552
- select?: (search: TAllMeta) => TSelected
556
+ useMatch = <TSelected = TAllContext>(opts?: {
557
+ select?: (search: TAllContext) => TSelected
553
558
  }): TSelected => {
554
559
  return useMatch({ ...opts, from: this.id }) as any
555
560
  }
556
- useRouteMeta = <TSelected = TAllMeta>(opts?: {
557
- select?: (search: TAllMeta) => TSelected
561
+ useRouteContext = <TSelected = TAllContext>(opts?: {
562
+ select?: (search: TAllContext) => TSelected
558
563
  }): TSelected => {
559
564
  return useMatch({
560
565
  ...opts,
561
566
  from: this.id,
562
- select: (d: any) => (opts?.select ? opts.select(d.meta) : d.meta),
567
+ select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),
563
568
  } as any)
564
569
  }
565
570
  useSearch = <TSelected = TFullSearchSchema>(opts?: {
@@ -576,12 +581,10 @@ export class Route<
576
581
 
577
582
  export type AnyRootRoute = RootRoute<any, any, any>
578
583
 
579
- export class RouterMeta<TRouterMeta extends {}> {
580
- constructor() {}
581
-
582
- createRootRoute = <
584
+ export function rootRouteWithContext<TRouterContext extends {}>() {
585
+ return <
583
586
  TSearchSchema extends Record<string, any> = {},
584
- TRouteMeta extends RouteMeta = RouteMeta,
587
+ TRouteContext extends RouteContext = RouteContext,
585
588
  >(
586
589
  options?: Omit<
587
590
  RouteOptions<
@@ -592,8 +595,8 @@ export class RouterMeta<TRouterMeta extends {}> {
592
595
  TSearchSchema, // TFullSearchSchema
593
596
  {}, // TParams
594
597
  {}, // TAllParams
595
- TRouteMeta, // TRouteMeta
596
- Assign<TRouterMeta, TRouteMeta> // TAllContext
598
+ TRouteContext, // TRouteContext
599
+ Assign<TRouterContext, TRouteContext> // TAllContext
597
600
  >,
598
601
  | 'path'
599
602
  | 'id'
@@ -602,15 +605,15 @@ export class RouterMeta<TRouterMeta extends {}> {
602
605
  | 'parseParams'
603
606
  | 'stringifyParams'
604
607
  >,
605
- ): RootRoute<TSearchSchema, TRouteMeta, TRouterMeta> => {
608
+ ): RootRoute<TSearchSchema, TRouteContext, TRouterContext> => {
606
609
  return new RootRoute(options) as any
607
610
  }
608
611
  }
609
612
 
610
613
  export class RootRoute<
611
614
  TSearchSchema extends Record<string, any> = {},
612
- TRouteMeta extends RouteMeta = RouteMeta,
613
- TRouterMeta extends {} = {},
615
+ TRouteContext extends RouteContext = RouteContext,
616
+ TRouterContext extends {} = {},
614
617
  > extends Route<
615
618
  any, // TParentRoute
616
619
  '/', // TPath
@@ -621,9 +624,9 @@ export class RootRoute<
621
624
  TSearchSchema, // TFullSearchSchema
622
625
  {}, // TParams
623
626
  {}, // TAllParams
624
- TRouteMeta, // TRouteMeta
625
- Expand<Assign<TRouterMeta, TRouteMeta>>, // TAllContext
626
- TRouterMeta, // TRouterMeta
627
+ TRouteContext, // TRouteContext
628
+ Expand<Assign<TRouterContext, TRouteContext>>, // TAllContext
629
+ TRouterContext, // TRouterContext
627
630
  any, // TChildren
628
631
  any // TRouteTree
629
632
  > {
@@ -637,8 +640,8 @@ export class RootRoute<
637
640
  TSearchSchema, // TFullSearchSchema
638
641
  {}, // TParams
639
642
  {}, // TAllParams
640
- TRouteMeta, // TRouteMeta
641
- Assign<TRouterMeta, TRouteMeta> // TAllContext
643
+ TRouteContext, // TRouteContext
644
+ Assign<TRouterContext, TRouteContext> // TAllContext
642
645
  >,
643
646
  | 'path'
644
647
  | 'id'