@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/build/cjs/fileRoute.js.map +1 -1
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/router.js +7 -6
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +7 -6
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +130 -130
- package/build/types/index.d.ts +25 -20
- package/build/umd/index.development.js +7 -6
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/fileRoute.ts +0 -1
- package/src/route.ts +88 -39
- package/src/router.ts +25 -33
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.
|
|
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.
|
|
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
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<
|
|
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
|
|
18
|
-
|
|
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<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
:
|
|
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
|
-
:
|
|
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
|
-
:
|
|
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
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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?:
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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?:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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
|
-
|
|
31
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
AnyContext
|
|
166
|
-
>
|
|
159
|
+
unknown,
|
|
160
|
+
AnySearchSchema,
|
|
161
|
+
AnyPathParams,
|
|
162
|
+
AnyContext,
|
|
163
|
+
AnyContext
|
|
167
164
|
>
|
|
168
|
-
defaultErrorComponent?:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
AnyContext
|
|
174
|
-
>
|
|
165
|
+
defaultErrorComponent?: RegisteredErrorRouteComponent<
|
|
166
|
+
AnySearchSchema,
|
|
167
|
+
AnyPathParams,
|
|
168
|
+
AnyContext,
|
|
169
|
+
AnyContext
|
|
175
170
|
>
|
|
176
|
-
defaultPendingComponent?:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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:
|
|
807
|
-
preloadInvalidAt:
|
|
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
|
-
|
|
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?: {
|