@tanstack/router-core 0.0.1-beta.167 → 0.0.1-beta.168

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.167",
4
+ "version": "0.0.1-beta.168",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -43,7 +43,7 @@
43
43
  "tiny-invariant": "^1.3.1",
44
44
  "tiny-warning": "^1.0.3",
45
45
  "@gisatcz/cross-package-react-context": "^0.2.0",
46
- "@tanstack/react-store": "0.0.1-beta.167"
46
+ "@tanstack/react-store": "0.0.1-beta.168"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "rollup --config rollup.config.js",
package/src/fileRoute.ts CHANGED
@@ -2,7 +2,6 @@ import { ParsePathParams } from './link'
2
2
  import {
3
3
  AnyRoute,
4
4
  ResolveFullPath,
5
- AnySearchSchema,
6
5
  ResolveFullSearchSchema,
7
6
  MergeParamsFromParent,
8
7
  RouteContext,
package/src/route.ts CHANGED
@@ -11,11 +11,30 @@ export type AnySearchSchema = {}
11
11
  export type AnyContext = {}
12
12
  export interface RouteMeta {}
13
13
  export interface RouteContext {}
14
- export interface RegisterRouteComponent<TProps> {
14
+ export interface RegisterRouteComponent<
15
+ TLoader = unknown,
16
+ TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
17
+ TAllParams extends AnyPathParams = AnyPathParams,
18
+ TRouteContext extends AnyContext = AnyContext,
19
+ TAllContext extends AnyContext = AnyContext,
20
+ > {
15
21
  // RouteComponent: unknown // This is registered by the framework
16
22
  }
17
- export interface RegisterRouteErrorComponent<TProps> {
18
- // RouteErrorComponent: unknown // This is registered by the framework
23
+ export interface RegisterErrorRouteComponent<
24
+ TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
25
+ TAllParams extends AnyPathParams = AnyPathParams,
26
+ TRouteContext extends AnyContext = AnyContext,
27
+ TAllContext extends AnyContext = AnyContext,
28
+ > {
29
+ // ErrorRouteComponent: unknown // This is registered by the framework
30
+ }
31
+ export interface RegisterPendingRouteComponent<
32
+ TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
33
+ TAllParams extends AnyPathParams = AnyPathParams,
34
+ TRouteContext extends AnyContext = AnyContext,
35
+ TAllContext extends AnyContext = AnyContext,
36
+ > {
37
+ // PendingRouteComponent: unknown // This is registered by the framework
19
38
  }
20
39
  export interface RegisterRouteProps<
21
40
  TLoader = unknown,
@@ -44,19 +63,55 @@ export interface RegisterPendingRouteProps<
44
63
  // PendingRouteProps: unknown // This is registered by the framework
45
64
  }
46
65
 
47
- export type RegisteredRouteComponent<TProps> =
48
- RegisterRouteComponent<TProps> extends {
49
- RouteComponent: infer T
50
- }
51
- ? T
52
- : (props: TProps) => unknown
66
+ export type RegisteredRouteComponent<
67
+ TLoader = unknown,
68
+ TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
69
+ TAllParams extends AnyPathParams = AnyPathParams,
70
+ TRouteContext extends AnyContext = AnyContext,
71
+ TAllContext extends AnyContext = AnyContext,
72
+ > = RegisterRouteComponent<
73
+ TLoader,
74
+ TFullSearchSchema,
75
+ TAllParams,
76
+ TRouteContext,
77
+ TAllContext
78
+ > extends {
79
+ RouteComponent: infer T
80
+ }
81
+ ? T
82
+ : () => unknown
53
83
 
54
- export type RegisteredRouteErrorComponent<TProps> =
55
- RegisterRouteErrorComponent<TProps> extends {
56
- RouteErrorComponent: infer T
57
- }
58
- ? T
59
- : (props: TProps) => unknown
84
+ export type RegisteredErrorRouteComponent<
85
+ TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
86
+ TAllParams extends AnyPathParams = AnyPathParams,
87
+ TRouteContext extends AnyContext = AnyContext,
88
+ TAllContext extends AnyContext = AnyContext,
89
+ > = RegisterErrorRouteComponent<
90
+ TFullSearchSchema,
91
+ TAllParams,
92
+ TRouteContext,
93
+ TAllContext
94
+ > extends {
95
+ ErrorRouteComponent: infer T
96
+ }
97
+ ? T
98
+ : () => unknown
99
+
100
+ export type RegisteredPendingRouteComponent<
101
+ TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
102
+ TAllParams extends AnyPathParams = AnyPathParams,
103
+ TRouteContext extends AnyContext = AnyContext,
104
+ TAllContext extends AnyContext = AnyContext,
105
+ > = RegisterPendingRouteComponent<
106
+ TFullSearchSchema,
107
+ TAllParams,
108
+ TRouteContext,
109
+ TAllContext
110
+ > extends {
111
+ PendingRouteComponent: infer T
112
+ }
113
+ ? T
114
+ : () => unknown
60
115
 
61
116
  export type RegisteredRouteProps<
62
117
  TLoader = unknown,
@@ -74,7 +129,7 @@ export type RegisteredRouteProps<
74
129
  RouteProps: infer T
75
130
  }
76
131
  ? T
77
- : (props: {}) => unknown
132
+ : {}
78
133
 
79
134
  export type RegisteredErrorRouteProps<
80
135
  TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
@@ -90,7 +145,7 @@ export type RegisteredErrorRouteProps<
90
145
  ErrorRouteProps: infer T
91
146
  }
92
147
  ? T
93
- : (props: {}) => unknown
148
+ : {}
94
149
 
95
150
  export type RegisteredPendingRouteProps<
96
151
  TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
@@ -106,7 +161,7 @@ export type RegisteredPendingRouteProps<
106
161
  PendingRouteProps: infer T
107
162
  }
108
163
  ? T
109
- : (props: {}) => unknown
164
+ : {}
110
165
 
111
166
  export type PreloadableObj = { preload?: () => Promise<void> }
112
167
 
@@ -325,31 +380,25 @@ export type UpdatableRouteOptions<
325
380
  wrapInSuspense?: boolean
326
381
  // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
327
382
  component?: RegisteredRouteComponent<
328
- RegisteredRouteProps<
329
- TLoader,
330
- TFullSearchSchema,
331
- TAllParams,
332
- TRouteContext,
333
- TAllContext
334
- >
383
+ TLoader,
384
+ TFullSearchSchema,
385
+ TAllParams,
386
+ TRouteContext,
387
+ TAllContext
335
388
  >
336
389
  // The content to be rendered when the route encounters an error
337
- errorComponent?: RegisteredRouteErrorComponent<
338
- RegisteredErrorRouteProps<
339
- TFullSearchSchema,
340
- TAllParams,
341
- TRouteContext,
342
- TAllContext
343
- >
390
+ errorComponent?: RegisteredErrorRouteComponent<
391
+ TFullSearchSchema,
392
+ TAllParams,
393
+ TRouteContext,
394
+ TAllContext
344
395
  > //
345
396
  // If supported by your framework, the content to be rendered as the fallback content until the route is ready to render
346
- pendingComponent?: RegisteredRouteComponent<
347
- RegisteredPendingRouteProps<
348
- TFullSearchSchema,
349
- TAllParams,
350
- TRouteContext,
351
- TAllContext
352
- >
397
+ pendingComponent?: RegisteredPendingRouteComponent<
398
+ TFullSearchSchema,
399
+ TAllParams,
400
+ TRouteContext,
401
+ TAllContext
353
402
  >
354
403
  // Filter functions that can manipulate search params *before* they are passed to links and navigate
355
404
  // calls that match this route.
package/src/router.ts CHANGED
@@ -27,9 +27,8 @@ import {
27
27
  AnyContext,
28
28
  AnyPathParams,
29
29
  RegisteredRouteComponent,
30
- RegisteredRouteErrorComponent,
31
- RegisteredRouteProps,
32
- RegisteredErrorRouteProps,
30
+ RegisteredErrorRouteComponent,
31
+ RegisteredPendingRouteComponent,
33
32
  } from './route'
34
33
  import {
35
34
  RoutesById,
@@ -157,30 +156,23 @@ export interface RouterOptions<
157
156
  defaultPreload?: false | 'intent'
158
157
  defaultPreloadDelay?: number
159
158
  defaultComponent?: RegisteredRouteComponent<
160
- RegisteredRouteProps<
161
- unknown,
162
- AnySearchSchema,
163
- AnyPathParams,
164
- AnyContext,
165
- AnyContext
166
- >
159
+ unknown,
160
+ AnySearchSchema,
161
+ AnyPathParams,
162
+ AnyContext,
163
+ AnyContext
167
164
  >
168
- defaultErrorComponent?: RegisteredRouteErrorComponent<
169
- RegisteredErrorRouteProps<
170
- AnySearchSchema,
171
- AnyPathParams,
172
- AnyContext,
173
- AnyContext
174
- >
165
+ defaultErrorComponent?: RegisteredErrorRouteComponent<
166
+ AnySearchSchema,
167
+ AnyPathParams,
168
+ AnyContext,
169
+ AnyContext
175
170
  >
176
- defaultPendingComponent?: RegisteredRouteComponent<
177
- RegisteredRouteProps<
178
- unknown,
179
- AnySearchSchema,
180
- AnyPathParams,
181
- AnyContext,
182
- AnyContext
183
- >
171
+ defaultPendingComponent?: RegisteredPendingRouteComponent<
172
+ AnySearchSchema,
173
+ AnyPathParams,
174
+ AnyContext,
175
+ AnyContext
184
176
  >
185
177
  defaultMaxAge?: number
186
178
  defaultGcMaxAge?: number
@@ -803,8 +795,8 @@ export class Router<
803
795
  params: routeParams,
804
796
  pathname: joinPaths([this.basepath, interpolatedPath]),
805
797
  updatedAt: Date.now(),
806
- invalidAt: 9999999999999,
807
- preloadInvalidAt: 9999999999999,
798
+ invalidAt: Infinity,
799
+ preloadInvalidAt: Infinity,
808
800
  routeSearch: {},
809
801
  search: {} as any,
810
802
  status: hasLoaders ? 'pending' : 'success',
@@ -912,8 +904,6 @@ export class Router<
912
904
  maxAge?: number
913
905
  },
914
906
  ) => {
915
- this.cleanMatches()
916
-
917
907
  if (!opts?.preload) {
918
908
  resolvedMatches.forEach((match) => {
919
909
  // Update each match with its latest route data
@@ -927,10 +917,13 @@ export class Router<
927
917
  paramsError: match.paramsError,
928
918
  searchError: match.searchError,
929
919
  params: match.params,
920
+ preloadInvalidAt: 0,
930
921
  }))
931
922
  })
932
923
  }
933
924
 
925
+ this.cleanMatches()
926
+
934
927
  let firstBadMatchIndex: number | undefined
935
928
 
936
929
  // Check each match middleware to see if the route can be accessed
@@ -1105,6 +1098,8 @@ export class Router<
1105
1098
  })
1106
1099
 
1107
1100
  await Promise.all(matchPromises)
1101
+
1102
+ this.cleanMatches()
1108
1103
  }
1109
1104
 
1110
1105
  reload = () => {
@@ -1766,7 +1761,7 @@ export class Router<
1766
1761
  (opts?.maxAge ??
1767
1762
  route.options.maxAge ??
1768
1763
  this.options.defaultMaxAge ??
1769
- 9999999999999)
1764
+ Infinity)
1770
1765
 
1771
1766
  this.setRouteMatch(id, (s) => ({
1772
1767
  ...s,
@@ -1778,9 +1773,6 @@ export class Router<
1778
1773
  preloadInvalidAt,
1779
1774
  invalidAt,
1780
1775
  }))
1781
-
1782
- if (this.state.matches.find((d) => d.id === id)) {
1783
- }
1784
1776
  }
1785
1777
 
1786
1778
  invalidate = async (opts?: {