@tanstack/router-core 0.0.1-beta.193 → 0.0.1-beta.194

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/router-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.193",
4
+ "version": "0.0.1-beta.194",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
package/src/fileRoute.ts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  TrimPathLeft,
16
16
  RouteConstraints,
17
17
  } from './route'
18
+ import { DeepMergeAll, Expand, IsAny } from './utils'
18
19
 
19
20
  export interface FileRoutesByPath {
20
21
  // '/': {
@@ -99,12 +100,15 @@ export class FileRoute<
99
100
  TParentRoute['types']['allParams'],
100
101
  TParams
101
102
  >,
102
- TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['types']['routeContext'],
103
- TAllParentContext extends RouteConstraints['TAllParentContext'] = TParentRoute['types']['context'],
104
103
  TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
105
- TContext extends RouteConstraints['TAllContext'] = MergeFromFromParent<
106
- TParentRoute['types']['context'],
107
- TRouteContext
104
+ TContext extends RouteConstraints['TAllContext'] = Expand<
105
+ DeepMergeAll<
106
+ [
107
+ IsAny<TParentRoute['types']['context'], {}>,
108
+ TLoaderContext,
109
+ TRouteContext,
110
+ ]
111
+ >
108
112
  >,
109
113
  TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
110
114
  TChildren extends RouteConstraints['TChildren'] = unknown,
@@ -121,8 +125,6 @@ export class FileRoute<
121
125
  TFullSearchSchema,
122
126
  TParams,
123
127
  TAllParams,
124
- TParentContext,
125
- TAllParentContext,
126
128
  TRouteContext,
127
129
  TContext
128
130
  >,
@@ -148,8 +150,6 @@ export class FileRoute<
148
150
  TFullSearchSchema,
149
151
  TParams,
150
152
  TAllParams,
151
- TParentContext,
152
- TAllParentContext,
153
153
  TRouteContext,
154
154
  TContext,
155
155
  TRouterContext,
package/src/route.ts CHANGED
@@ -206,8 +206,6 @@ export type RouteOptions<
206
206
  TFullSearchSchema extends Record<string, any> = TSearchSchema,
207
207
  TParams extends AnyPathParams = AnyPathParams,
208
208
  TAllParams extends AnyPathParams = TParams,
209
- TParentContext extends Record<string, any> = AnyContext,
210
- TAllParentContext extends Record<string, any> = AnyContext,
211
209
  TRouteContext extends RouteContext = RouteContext,
212
210
  TAllContext extends Record<string, any> = AnyContext,
213
211
  > = BaseRouteOptions<
@@ -220,8 +218,6 @@ export type RouteOptions<
220
218
  TFullSearchSchema,
221
219
  TParams,
222
220
  TAllParams,
223
- TParentContext,
224
- TAllParentContext,
225
221
  TRouteContext,
226
222
  TAllContext
227
223
  > &
@@ -253,8 +249,6 @@ export type BaseRouteOptions<
253
249
  TFullSearchSchema extends Record<string, any> = TSearchSchema,
254
250
  TParams extends AnyPathParams = {},
255
251
  TAllParams = ParamsFallback<TPath, TParams>,
256
- TParentContext extends Record<string, any> = AnyContext,
257
- TAllParentContext extends Record<string, any> = AnyContext,
258
252
  TRouteContext extends RouteContext = RouteContext,
259
253
  TAllContext extends Record<string, any> = AnyContext,
260
254
  > = RoutePathOptions<TCustomId, TPath> & {
@@ -270,7 +264,6 @@ export type BaseRouteOptions<
270
264
  beforeLoad?: BeforeLoadFn<
271
265
  TParentRoute,
272
266
  TAllParams,
273
- TAllParentContext,
274
267
  NoInfer<TLoaderContext>,
275
268
  TRouteContext
276
269
  >
@@ -279,7 +272,6 @@ export type BaseRouteOptions<
279
272
  beforeLoad: BeforeLoadFn<
280
273
  TParentRoute,
281
274
  TAllParams,
282
- TAllParentContext,
283
275
  NoInfer<TLoaderContext>,
284
276
  TRouteContext
285
277
  >
@@ -315,16 +307,15 @@ export type BaseRouteOptions<
315
307
  )
316
308
 
317
309
  type BeforeLoadFn<
318
- TParentRoute,
310
+ TParentRoute extends AnyRoute,
319
311
  TAllParams,
320
- TParentContext,
321
312
  TLoaderContext,
322
313
  TRouteContext,
323
314
  > = (opts: {
324
315
  abortController: AbortController
325
316
  preload: boolean
326
317
  params: TAllParams
327
- context: Expand<TParentContext & TLoaderContext>
318
+ context: Expand<TParentRoute['types']['context'] & TLoaderContext>
328
319
  }) => Promise<TRouteContext> | TRouteContext | void
329
320
 
330
321
  export type UpdatableRouteOptions<
@@ -489,8 +480,6 @@ export interface AnyRoute
489
480
  any,
490
481
  any,
491
482
  any,
492
- any,
493
- any,
494
483
  any
495
484
  > {}
496
485
 
@@ -535,7 +524,6 @@ export type RouteConstraints = {
535
524
  TParams: Record<string, any>
536
525
  TAllParams: Record<string, any>
537
526
  TParentContext: AnyContext
538
- TAllParentContext: AnyContext
539
527
  TRouteContext: RouteContext
540
528
  TAllContext: AnyContext
541
529
  TRouterContext: AnyContext
@@ -556,7 +544,7 @@ export class Route<
556
544
  TCustomId,
557
545
  TPath
558
546
  >,
559
- TLoaderContext extends RouteConstraints['TLoaderContext'] = AnyContext,
547
+ TLoaderContext extends RouteConstraints['TLoaderContext'] = {},
560
548
  TLoader = unknown,
561
549
  TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
562
550
  TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
@@ -570,12 +558,15 @@ export class Route<
570
558
  TParentRoute,
571
559
  TParams
572
560
  >,
573
- TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['types']['routeContext'],
574
- TAllParentContext extends RouteConstraints['TAllParentContext'] = TParentRoute['types']['context'],
575
561
  TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
576
- TAllContext extends RouteConstraints['TAllContext'] = MergeFromFromParent<
577
- TParentRoute['types']['context'],
578
- TRouteContext
562
+ TAllContext extends RouteConstraints['TAllContext'] = Expand<
563
+ DeepMergeAll<
564
+ [
565
+ IsAny<TParentRoute['types']['context'], {}>,
566
+ TLoaderContext,
567
+ TRouteContext,
568
+ ]
569
+ >
579
570
  >,
580
571
  TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
581
572
  TChildren extends RouteConstraints['TChildren'] = unknown,
@@ -593,8 +584,6 @@ export class Route<
593
584
  fullSearchSchema: TFullSearchSchema
594
585
  params: TParams
595
586
  allParams: TAllParams
596
- parentContext: TParentContext
597
- allParentContext: TAllParentContext
598
587
  routeContext: TRouteContext
599
588
  context: TAllContext
600
589
  children: TChildren
@@ -612,8 +601,6 @@ export class Route<
612
601
  TFullSearchSchema,
613
602
  TParams,
614
603
  TAllParams,
615
- TParentContext,
616
- TAllParentContext,
617
604
  TRouteContext,
618
605
  TAllContext
619
606
  >
@@ -643,8 +630,6 @@ export class Route<
643
630
  TFullSearchSchema,
644
631
  TParams,
645
632
  TAllParams,
646
- TParentContext,
647
- TAllParentContext,
648
633
  TRouteContext,
649
634
  TAllContext
650
635
  > &
@@ -676,8 +661,6 @@ export class Route<
676
661
  TFullSearchSchema,
677
662
  TParams,
678
663
  TAllParams,
679
- TParentContext,
680
- TAllParentContext,
681
664
  TRouteContext,
682
665
  TAllContext
683
666
  > &
@@ -747,8 +730,6 @@ export class Route<
747
730
  TFullSearchSchema,
748
731
  TParams,
749
732
  TAllParams,
750
- TParentContext,
751
- TAllParentContext,
752
733
  TRouteContext,
753
734
  TAllContext,
754
735
  TRouterContext,
@@ -792,19 +773,17 @@ export class RouterContext<TRouterContext extends {}> {
792
773
  >(
793
774
  options?: Omit<
794
775
  RouteOptions<
795
- AnyRoute,
796
- RootRouteId,
797
- '',
798
- TLoaderContext,
799
- TLoader,
800
- TSearchSchema,
801
- TSearchSchema,
802
- {},
803
- {},
804
- TRouterContext,
805
- TRouterContext,
806
- TRouteContext,
807
- MergeFromFromParent<TRouterContext, TRouteContext>
776
+ AnyRoute, // TParentRoute
777
+ RootRouteId, // TCustomId
778
+ '', // TPath
779
+ TLoaderContext, // TLoaderContext
780
+ TLoader, // TLoader
781
+ TSearchSchema, // TSearchSchema
782
+ TSearchSchema, // TFullSearchSchema
783
+ {}, // TParams
784
+ {}, // TAllParams
785
+ TRouteContext, // TRouteContext
786
+ DeepMergeAll<[TRouterContext, TLoaderContext, TRouteContext]> // TAllContext
808
787
  >,
809
788
  | 'path'
810
789
  | 'id'
@@ -831,41 +810,37 @@ export class RootRoute<
831
810
  TRouteContext extends RouteContext = RouteContext,
832
811
  TRouterContext extends {} = {},
833
812
  > extends Route<
834
- any,
835
- '/',
836
- '/',
837
- string,
838
- RootRouteId,
839
- TLoaderContext,
840
- TLoader,
841
- TSearchSchema,
842
- TSearchSchema,
843
- {},
844
- {},
845
- TRouterContext,
846
- TRouterContext,
847
- TRouteContext,
848
- MergeFromFromParent<TRouterContext, TRouteContext>,
849
- TRouterContext,
850
- any,
851
- any
813
+ any, // TParentRoute
814
+ '/', // TPath
815
+ '/', // TFullPath
816
+ string, // TCustomId
817
+ RootRouteId, // TId
818
+ TLoaderContext, // TLoaderContext
819
+ TLoader, // TLoader
820
+ TSearchSchema, // TSearchSchema
821
+ TSearchSchema, // TFullSearchSchema
822
+ {}, // TParams
823
+ {}, // TAllParams
824
+ TRouteContext, // TRouteContext
825
+ DeepMergeAll<[TRouterContext, TLoaderContext, TRouteContext]>, // TAllContext
826
+ TRouterContext, // TRouterContext
827
+ any, // TChildren
828
+ any // TRouteTree
852
829
  > {
853
830
  constructor(
854
831
  options?: Omit<
855
832
  RouteOptions<
856
- AnyRoute,
857
- RootRouteId,
858
- '',
859
- TLoaderContext,
860
- TLoader,
861
- TSearchSchema,
862
- TSearchSchema,
863
- {},
864
- {},
865
- TRouterContext,
866
- TRouterContext,
867
- TRouteContext,
868
- MergeFromFromParent<TRouterContext, TRouteContext>
833
+ AnyRoute, // TParentRoute
834
+ RootRouteId, // TCustomId
835
+ '', // TPath
836
+ TLoaderContext, // TLoaderContext
837
+ TLoader, // TLoader
838
+ TSearchSchema, // TSearchSchema
839
+ TSearchSchema, // TFullSearchSchema
840
+ {}, // TParams
841
+ {}, // TAllParams
842
+ TRouteContext, // TRouteContext
843
+ DeepMergeAll<[TRouterContext, TLoaderContext, TRouteContext]> // TAllContext
869
844
  >,
870
845
  | 'path'
871
846
  | 'id'
package/src/routeInfo.ts CHANGED
@@ -21,8 +21,6 @@ export type ParseRouteChildren<TRouteTree extends AnyRoute> =
21
21
  any,
22
22
  any,
23
23
  any,
24
- any,
25
- any,
26
24
  infer TChildren,
27
25
  any
28
26
  >
package/src/router.ts CHANGED
@@ -1050,7 +1050,7 @@ export class Router<
1050
1050
 
1051
1051
  this.setRouteMatch(match.id, (s) => ({
1052
1052
  ...s,
1053
- context,
1053
+ context: replaceEqualDeep(s.context, context),
1054
1054
  }))
1055
1055
  } catch (err) {
1056
1056
  handleError(err, 'BEFORE_LOAD')
package/src/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type NoInfer<T> = [T][T extends any ? 0 : never]
2
- export type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N
2
+ export type IsAny<T, Y, N = T> = 1 extends 0 & T ? Y : N
3
3
  export type IsAnyBoolean<T> = 1 extends 0 & T ? true : false
4
4
  export type IsKnown<T, Y, N> = unknown extends T ? N : Y
5
5
  export type PickAsRequired<T, K extends keyof T> = Omit<T, K> &