@tanstack/router-core 0.0.1-beta.3 → 0.0.1-beta.31
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/_virtual/_rollupPluginBabelHelpers.js +0 -2
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/{packages/router-core/src/index.js → index.js} +23 -7
- package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
- package/build/cjs/{packages/router-core/src/path.js → path.js} +7 -34
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/{packages/router-core/src/qss.js → qss.js} +9 -13
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/{packages/router-core/src/route.js → route.js} +15 -37
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/{packages/router-core/src/routeConfig.js → routeConfig.js} +13 -12
- package/build/cjs/routeConfig.js.map +1 -0
- package/build/cjs/routeMatch.js +200 -0
- package/build/cjs/routeMatch.js.map +1 -0
- package/build/cjs/{packages/router-core/src/router.js → router.js} +257 -221
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +7 -10
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/{packages/router-core/src/utils.js → utils.js} +17 -30
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +395 -1322
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +161 -168
- package/build/types/index.d.ts +247 -227
- package/build/umd/index.development.js +385 -495
- 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 +3 -2
- package/src/frameworks.ts +2 -2
- package/src/index.ts +0 -1
- package/src/link.ts +66 -31
- package/src/path.ts +2 -6
- package/src/qss.ts +1 -0
- package/src/route.ts +25 -33
- package/src/routeConfig.ts +100 -77
- package/src/routeInfo.ts +26 -8
- package/src/routeMatch.ts +100 -160
- package/src/router.ts +363 -141
- package/src/utils.ts +14 -7
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
- package/build/cjs/node_modules/history/index.js +0 -815
- package/build/cjs/node_modules/history/index.js.map +0 -1
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
- package/build/cjs/packages/router-core/src/path.js.map +0 -1
- package/build/cjs/packages/router-core/src/qss.js.map +0 -1
- package/build/cjs/packages/router-core/src/route.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeMatch.js +0 -266
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- package/build/cjs/packages/router-core/src/router.js.map +0 -1
- package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
- package/build/cjs/packages/router-core/src/utils.js.map +0 -1
package/build/types/index.d.ts
CHANGED
|
@@ -14,36 +14,37 @@ export { default as invariant } from 'tiny-invariant';
|
|
|
14
14
|
|
|
15
15
|
interface FrameworkGenerics {
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
type GetFrameworkGeneric<U> = U extends keyof FrameworkGenerics ? FrameworkGenerics[U] : any;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
20
|
+
type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N;
|
|
21
|
+
type IsAnyBoolean<T> = 1 extends 0 & T ? true : false;
|
|
22
|
+
type IsKnown<T, Y, N> = unknown extends T ? N : Y;
|
|
23
|
+
type PickAsRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
24
|
+
type PickAsPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
25
|
+
type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never;
|
|
26
|
+
type PickExtra<T, K> = Expand<{
|
|
27
27
|
[TKey in keyof K as string extends TKey ? never : TKey extends keyof T ? never : TKey]: K[TKey];
|
|
28
28
|
}>;
|
|
29
|
-
|
|
29
|
+
type PickRequired<T> = {
|
|
30
30
|
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
type Expand<T> = T extends object ? T extends infer O ? {
|
|
33
33
|
[K in keyof O]: O[K];
|
|
34
34
|
} : never : T;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => any ? I : never;
|
|
36
|
+
type Values<O> = O[ValueKeys<O>];
|
|
37
|
+
type ValueKeys<O> = Extract<keyof O, PropertyKey>;
|
|
38
|
+
type DeepAwaited<T> = T extends Promise<infer A> ? DeepAwaited<A> : T extends Record<infer A, Promise<infer B>> ? {
|
|
38
39
|
[K in A]: DeepAwaited<B>;
|
|
39
40
|
} : T;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
type PathParamMask<TRoutePath extends string> = TRoutePath extends `${infer L}/$${infer C}/${infer R}` ? PathParamMask<`${L}/${string}/${R}`> : TRoutePath extends `${infer L}/$${infer C}` ? PathParamMask<`${L}/${string}`> : TRoutePath;
|
|
42
|
+
type Timeout = ReturnType<typeof setTimeout>;
|
|
43
|
+
type Updater<TPrevious, TResult = TPrevious> = TResult | ((prev?: TPrevious) => TResult);
|
|
44
|
+
type PickExtract<T, U> = {
|
|
44
45
|
[K in keyof T as T[K] extends U ? K : never]: T[K];
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
+
type PickExclude<T, U> = {
|
|
47
48
|
[K in keyof T as T[K] extends U ? never : K]: T[K];
|
|
48
49
|
};
|
|
49
50
|
/**
|
|
@@ -55,7 +56,16 @@ declare function replaceEqualDeep(prev: any, next: any): any;
|
|
|
55
56
|
declare function last<T>(arr: T[]): T | undefined;
|
|
56
57
|
declare function warning(cond: any, message: string): cond is true;
|
|
57
58
|
declare function functionalUpdate<TResult>(updater: Updater<TResult>, previous: TResult): TResult;
|
|
59
|
+
declare function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K>;
|
|
58
60
|
|
|
61
|
+
interface RegisterRouter {
|
|
62
|
+
}
|
|
63
|
+
type RegisteredRouter = RegisterRouter extends {
|
|
64
|
+
router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>;
|
|
65
|
+
} ? Router<TRouteConfig, TAllRouteInfo, TRouterContext> : Router;
|
|
66
|
+
type RegisteredAllRouteInfo = RegisterRouter extends {
|
|
67
|
+
router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>;
|
|
68
|
+
} ? TAllRouteInfo : AnyAllRouteInfo;
|
|
59
69
|
interface LocationState {
|
|
60
70
|
}
|
|
61
71
|
interface Location<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
|
|
@@ -73,10 +83,10 @@ interface FromLocation {
|
|
|
73
83
|
key?: string;
|
|
74
84
|
hash?: string;
|
|
75
85
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
|
|
86
|
+
type SearchSerializer = (searchObj: Record<string, any>) => string;
|
|
87
|
+
type SearchParser = (searchStr: string) => Record<string, any>;
|
|
88
|
+
type FilterRoutesFn = <TRoute extends Route<any, RouteInfo>>(routeConfigs: TRoute[]) => TRoute[];
|
|
89
|
+
interface RouterOptions<TRouteConfig extends AnyRouteConfig, TRouterContext> {
|
|
80
90
|
history?: BrowserHistory | MemoryHistory | HashHistory;
|
|
81
91
|
stringifySearch?: SearchSerializer;
|
|
82
92
|
parseSearch?: SearchParser;
|
|
@@ -85,35 +95,37 @@ interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
|
|
|
85
95
|
defaultPreloadMaxAge?: number;
|
|
86
96
|
defaultPreloadGcMaxAge?: number;
|
|
87
97
|
defaultPreloadDelay?: number;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
defaultCatchElement?: GetFrameworkGeneric<'Element'>;
|
|
92
|
-
defaultPendingElement?: GetFrameworkGeneric<'Element'>;
|
|
93
|
-
defaultPendingMs?: number;
|
|
94
|
-
defaultPendingMinMs?: number;
|
|
98
|
+
defaultComponent?: GetFrameworkGeneric<'Component'>;
|
|
99
|
+
defaultErrorComponent?: GetFrameworkGeneric<'ErrorComponent'>;
|
|
100
|
+
defaultPendingComponent?: GetFrameworkGeneric<'Component'>;
|
|
95
101
|
defaultLoaderMaxAge?: number;
|
|
96
102
|
defaultLoaderGcMaxAge?: number;
|
|
97
103
|
caseSensitive?: boolean;
|
|
98
104
|
routeConfig?: TRouteConfig;
|
|
99
105
|
basepath?: string;
|
|
100
|
-
|
|
106
|
+
useServerData?: boolean;
|
|
107
|
+
createRouter?: (router: Router<any, any, any>) => void;
|
|
101
108
|
createRoute?: (opts: {
|
|
102
109
|
route: AnyRoute;
|
|
103
|
-
router: Router<any, any>;
|
|
110
|
+
router: Router<any, any, any>;
|
|
104
111
|
}) => void;
|
|
105
|
-
|
|
112
|
+
context?: TRouterContext;
|
|
113
|
+
loadComponent?: (component: GetFrameworkGeneric<'Component'>) => Promise<GetFrameworkGeneric<'Component'>>;
|
|
106
114
|
}
|
|
107
115
|
interface Action<TPayload = unknown, TResponse = unknown> {
|
|
108
|
-
submit: (submission?: TPayload
|
|
116
|
+
submit: (submission?: TPayload, actionOpts?: {
|
|
117
|
+
invalidate?: boolean;
|
|
118
|
+
multi?: boolean;
|
|
119
|
+
}) => Promise<TResponse>;
|
|
109
120
|
current?: ActionState<TPayload, TResponse>;
|
|
110
121
|
latest?: ActionState<TPayload, TResponse>;
|
|
111
|
-
|
|
122
|
+
submissions: ActionState<TPayload, TResponse>[];
|
|
112
123
|
}
|
|
113
124
|
interface ActionState<TPayload = unknown, TResponse = unknown> {
|
|
114
125
|
submittedAt: number;
|
|
115
126
|
status: 'idle' | 'pending' | 'success' | 'error';
|
|
116
127
|
submission: TPayload;
|
|
128
|
+
isMulti: boolean;
|
|
117
129
|
data?: TResponse;
|
|
118
130
|
error?: unknown;
|
|
119
131
|
}
|
|
@@ -136,18 +148,15 @@ interface Loader<TFullSearchSchema extends AnySearchSchema = {}, TAllParams exte
|
|
|
136
148
|
latest?: LoaderState<TFullSearchSchema, TAllParams>;
|
|
137
149
|
pending: LoaderState<TFullSearchSchema, TAllParams>[];
|
|
138
150
|
}
|
|
139
|
-
interface LoaderState<TFullSearchSchema =
|
|
151
|
+
interface LoaderState<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
|
|
140
152
|
loadedAt: number;
|
|
141
153
|
loaderContext: LoaderContext<TFullSearchSchema, TAllParams>;
|
|
142
154
|
}
|
|
143
|
-
interface RouterState {
|
|
155
|
+
interface RouterState<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
|
|
144
156
|
status: 'idle' | 'loading';
|
|
145
|
-
location: Location
|
|
157
|
+
location: Location<TSearchObj, TState>;
|
|
146
158
|
matches: RouteMatch[];
|
|
147
159
|
lastUpdated: number;
|
|
148
|
-
loaderData: unknown;
|
|
149
|
-
currentAction?: ActionState;
|
|
150
|
-
latestAction?: ActionState;
|
|
151
160
|
actions: Record<string, Action>;
|
|
152
161
|
loaders: Record<string, Loader>;
|
|
153
162
|
pending?: PendingState;
|
|
@@ -158,20 +167,21 @@ interface PendingState {
|
|
|
158
167
|
location: Location;
|
|
159
168
|
matches: RouteMatch[];
|
|
160
169
|
}
|
|
161
|
-
|
|
162
|
-
|
|
170
|
+
type Listener = (router: Router<any, any, any>) => void;
|
|
171
|
+
type ListenerFn = () => void;
|
|
163
172
|
interface BuildNextOptions {
|
|
164
173
|
to?: string | number | null;
|
|
165
|
-
params?: true | Updater<
|
|
174
|
+
params?: true | Updater<unknown>;
|
|
166
175
|
search?: true | Updater<unknown>;
|
|
167
176
|
hash?: true | Updater<string>;
|
|
177
|
+
state?: LocationState;
|
|
168
178
|
key?: string;
|
|
169
179
|
from?: string;
|
|
170
180
|
fromCurrent?: boolean;
|
|
171
181
|
__preSearchFilters?: SearchFilter<any>[];
|
|
172
182
|
__postSearchFilters?: SearchFilter<any>[];
|
|
173
183
|
}
|
|
174
|
-
|
|
184
|
+
type MatchCacheEntry = {
|
|
175
185
|
gc: number;
|
|
176
186
|
match: RouteMatch;
|
|
177
187
|
};
|
|
@@ -186,33 +196,45 @@ interface MatchRouteOptions {
|
|
|
186
196
|
pending: boolean;
|
|
187
197
|
caseSensitive?: boolean;
|
|
188
198
|
}
|
|
189
|
-
interface
|
|
199
|
+
interface DehydratedRouterState extends Pick<RouterState, 'status' | 'location' | 'lastUpdated' | 'location'> {
|
|
200
|
+
matches: DehydratedRouteMatch[];
|
|
201
|
+
}
|
|
202
|
+
interface DehydratedRouter<TRouterContext = unknown> {
|
|
203
|
+
location: Router['__location'];
|
|
204
|
+
state: DehydratedRouterState;
|
|
205
|
+
context: TRouterContext;
|
|
206
|
+
}
|
|
207
|
+
interface DehydratedRouteMatch extends Pick<RouteMatch<any, any>, 'matchId' | 'status' | 'routeLoaderData' | 'loaderData' | 'isInvalid' | 'invalidAt'> {
|
|
208
|
+
}
|
|
209
|
+
interface RouterContext {
|
|
210
|
+
}
|
|
211
|
+
interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown> {
|
|
212
|
+
types: {
|
|
213
|
+
RouteConfig: TRouteConfig;
|
|
214
|
+
AllRouteInfo: TAllRouteInfo;
|
|
215
|
+
};
|
|
190
216
|
history: BrowserHistory | MemoryHistory | HashHistory;
|
|
191
|
-
options: PickAsRequired<RouterOptions<TRouteConfig>, 'stringifySearch' | 'parseSearch'>;
|
|
217
|
+
options: PickAsRequired<RouterOptions<TRouteConfig, TRouterContext>, 'stringifySearch' | 'parseSearch' | 'context'>;
|
|
192
218
|
basepath: string;
|
|
193
|
-
allRouteInfo: TAllRouteInfo;
|
|
194
219
|
listeners: Listener[];
|
|
195
|
-
|
|
220
|
+
__location: Location<TAllRouteInfo['fullSearchSchema']>;
|
|
196
221
|
navigateTimeout?: Timeout;
|
|
197
222
|
nextAction?: 'push' | 'replace';
|
|
198
|
-
state: RouterState
|
|
223
|
+
state: RouterState<TAllRouteInfo['fullSearchSchema']>;
|
|
199
224
|
routeTree: Route<TAllRouteInfo, RouteInfo>;
|
|
200
225
|
routesById: RoutesById<TAllRouteInfo>;
|
|
201
|
-
navigationPromise
|
|
202
|
-
removeActionQueue: {
|
|
203
|
-
action: Action;
|
|
204
|
-
actionState: ActionState;
|
|
205
|
-
}[];
|
|
226
|
+
navigationPromise?: Promise<void>;
|
|
206
227
|
startedLoadingAt: number;
|
|
207
228
|
resolveNavigation: () => void;
|
|
208
229
|
subscribe: (listener: Listener) => () => void;
|
|
230
|
+
reset: () => void;
|
|
209
231
|
notify: () => void;
|
|
210
232
|
mount: () => () => void;
|
|
211
233
|
onFocus: () => void;
|
|
212
|
-
update: <TRouteConfig extends RouteConfig = RouteConfig>(opts?: RouterOptions<TRouteConfig>) => Router<TRouteConfig>;
|
|
234
|
+
update: <TRouteConfig extends RouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(opts?: RouterOptions<TRouteConfig, TRouterContext>) => Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
|
|
213
235
|
buildNext: (opts: BuildNextOptions) => Location;
|
|
214
236
|
cancelMatches: () => void;
|
|
215
|
-
|
|
237
|
+
load: (next?: Location) => Promise<void>;
|
|
216
238
|
matchCache: Record<string, MatchCacheEntry>;
|
|
217
239
|
cleanMatchCache: () => void;
|
|
218
240
|
getRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(id: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
|
|
@@ -225,8 +247,6 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
|
|
|
225
247
|
strictParseParams?: boolean;
|
|
226
248
|
}) => RouteMatch[];
|
|
227
249
|
loadMatches: (resolvedMatches: RouteMatch[], loaderOpts?: {
|
|
228
|
-
withPending?: boolean;
|
|
229
|
-
} & ({
|
|
230
250
|
preload: true;
|
|
231
251
|
maxAge: number;
|
|
232
252
|
gcMaxAge: number;
|
|
@@ -234,13 +254,16 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
|
|
|
234
254
|
preload?: false;
|
|
235
255
|
maxAge?: never;
|
|
236
256
|
gcMaxAge?: never;
|
|
237
|
-
})
|
|
257
|
+
}) => Promise<void>;
|
|
258
|
+
loadMatchData: (routeMatch: RouteMatch<any, any>) => Promise<Record<string, unknown>>;
|
|
238
259
|
invalidateRoute: (opts: MatchLocation) => void;
|
|
239
260
|
reload: () => Promise<void>;
|
|
240
261
|
resolvePath: (from: string, path: string) => string;
|
|
241
262
|
navigate: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo>) => Promise<void>;
|
|
242
263
|
matchRoute: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(matchLocation: ToOptions<TAllRouteInfo, TFrom, TTo>, opts?: MatchRouteOptions) => boolean;
|
|
243
264
|
buildLink: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: LinkOptions<TAllRouteInfo, TFrom, TTo>) => LinkInfo;
|
|
265
|
+
dehydrate: () => DehydratedRouter<TRouterContext>;
|
|
266
|
+
hydrate: (dehydratedRouter: DehydratedRouter<TRouterContext>) => void;
|
|
244
267
|
__: {
|
|
245
268
|
buildRouteTree: (routeConfig: RouteConfig) => Route<TAllRouteInfo, AnyRouteInfo>;
|
|
246
269
|
parseLocation: (location: History['location'], previousLocation?: Location) => Location;
|
|
@@ -251,16 +274,16 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
|
|
|
251
274
|
}) => Promise<void>;
|
|
252
275
|
};
|
|
253
276
|
}
|
|
254
|
-
declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig
|
|
277
|
+
declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(userOptions?: RouterOptions<TRouteConfig, TRouterContext>): Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
|
|
255
278
|
|
|
256
279
|
interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> extends Route<TAllRouteInfo, TRouteInfo> {
|
|
257
280
|
matchId: string;
|
|
258
281
|
pathname: string;
|
|
259
|
-
params: TRouteInfo['
|
|
282
|
+
params: TRouteInfo['allParams'];
|
|
260
283
|
parentMatch?: RouteMatch;
|
|
261
284
|
childMatches: RouteMatch[];
|
|
262
285
|
routeSearch: TRouteInfo['searchSchema'];
|
|
263
|
-
search: TRouteInfo['fullSearchSchema']
|
|
286
|
+
search: Expand<TAllRouteInfo['fullSearchSchema'] & TRouteInfo['fullSearchSchema']>;
|
|
264
287
|
status: 'idle' | 'loading' | 'success' | 'error';
|
|
265
288
|
updatedAt?: number;
|
|
266
289
|
error?: unknown;
|
|
@@ -269,20 +292,14 @@ interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo
|
|
|
269
292
|
loaderData: TRouteInfo['loaderData'];
|
|
270
293
|
routeLoaderData: TRouteInfo['routeLoaderData'];
|
|
271
294
|
isFetching: boolean;
|
|
272
|
-
isPending: boolean;
|
|
273
295
|
invalidAt: number;
|
|
274
296
|
__: {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
pendingElement?: GetFrameworkGeneric<'Element'>;
|
|
297
|
+
component?: GetFrameworkGeneric<'Component'>;
|
|
298
|
+
errorComponent?: GetFrameworkGeneric<'ErrorComponent'>;
|
|
299
|
+
pendingComponent?: GetFrameworkGeneric<'Component'>;
|
|
279
300
|
loadPromise?: Promise<void>;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
dataPromise?: Promise<void>;
|
|
283
|
-
pendingTimeout?: Timeout;
|
|
284
|
-
pendingMinTimeout?: Timeout;
|
|
285
|
-
pendingMinPromise?: Promise<void>;
|
|
301
|
+
componentsPromise?: Promise<void>;
|
|
302
|
+
dataPromise?: Promise<TRouteInfo['routeLoaderData']>;
|
|
286
303
|
onExit?: void | ((matchContext: {
|
|
287
304
|
params: TRouteInfo['allParams'];
|
|
288
305
|
search: TRouteInfo['fullSearchSchema'];
|
|
@@ -290,15 +307,11 @@ interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo
|
|
|
290
307
|
abortController: AbortController;
|
|
291
308
|
latestId: string;
|
|
292
309
|
validate: () => void;
|
|
293
|
-
startPending: () => void;
|
|
294
|
-
cancelPending: () => void;
|
|
295
310
|
notify: () => void;
|
|
296
311
|
resolve: () => void;
|
|
297
312
|
};
|
|
298
313
|
cancel: () => void;
|
|
299
314
|
load: (loaderOpts?: {
|
|
300
|
-
withPending?: boolean;
|
|
301
|
-
} & ({
|
|
302
315
|
preload: true;
|
|
303
316
|
maxAge: number;
|
|
304
317
|
gcMaxAge: number;
|
|
@@ -306,22 +319,120 @@ interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo
|
|
|
306
319
|
preload?: false;
|
|
307
320
|
maxAge?: never;
|
|
308
321
|
gcMaxAge?: never;
|
|
309
|
-
})
|
|
322
|
+
}) => Promise<TRouteInfo['routeLoaderData']>;
|
|
310
323
|
fetch: (opts?: {
|
|
311
324
|
maxAge?: number;
|
|
312
325
|
}) => Promise<TRouteInfo['routeLoaderData']>;
|
|
313
326
|
invalidate: () => void;
|
|
314
327
|
hasLoaders: () => boolean;
|
|
315
328
|
}
|
|
316
|
-
declare function createRouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(router: Router<any, any>, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
|
|
329
|
+
declare function createRouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(router: Router<any, any, any>, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
|
|
330
|
+
parentMatch?: RouteMatch<any, any>;
|
|
317
331
|
matchId: string;
|
|
318
332
|
params: TRouteInfo['allParams'];
|
|
319
333
|
pathname: string;
|
|
320
334
|
}): RouteMatch<TAllRouteInfo, TRouteInfo>;
|
|
321
335
|
|
|
322
|
-
|
|
336
|
+
declare const rootRouteId: "__root__";
|
|
337
|
+
type RootRouteId = typeof rootRouteId;
|
|
338
|
+
type AnyLoaderData = {};
|
|
339
|
+
type AnyPathParams = {};
|
|
340
|
+
type AnySearchSchema = {};
|
|
341
|
+
interface RouteMeta {
|
|
342
|
+
}
|
|
343
|
+
type SearchSchemaValidator<TReturn, TParentSchema> = SearchSchemaValidatorObj<TReturn, TParentSchema> | SearchSchemaValidatorFn<TReturn, TParentSchema>;
|
|
344
|
+
type SearchSchemaValidatorObj<TReturn, TParentSchema> = {
|
|
345
|
+
parse?: SearchSchemaValidatorFn<TReturn, TParentSchema>;
|
|
346
|
+
};
|
|
347
|
+
type SearchSchemaValidatorFn<TReturn, TParentSchema> = (searchObj: Record<string, unknown>) => {} extends TParentSchema ? TReturn : keyof TReturn extends keyof TParentSchema ? {
|
|
348
|
+
error: 'Top level search params cannot be redefined by child routes!';
|
|
349
|
+
keys: keyof TReturn & keyof TParentSchema;
|
|
350
|
+
} : TReturn;
|
|
351
|
+
type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!';
|
|
352
|
+
type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
|
|
353
|
+
[Key in keyof TParentParams]?: DefinedPathParamWarning;
|
|
354
|
+
};
|
|
355
|
+
type LoaderFn<TRouteLoaderData extends AnyLoaderData = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> = (loaderContext: LoaderContext<TFullSearchSchema, TAllParams>) => TRouteLoaderData | Promise<TRouteLoaderData>;
|
|
356
|
+
interface LoaderContext<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
|
|
357
|
+
params: TAllParams;
|
|
358
|
+
search: TFullSearchSchema;
|
|
359
|
+
signal?: AbortSignal;
|
|
360
|
+
}
|
|
361
|
+
type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (submission: TActionPayload) => TActionResponse | Promise<TActionResponse>;
|
|
362
|
+
type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, RouteInfo<string, TPath>>) => void;
|
|
363
|
+
type RouteOptions<TRouteId extends string = string, TPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = {}> = ({
|
|
364
|
+
path: TPath;
|
|
365
|
+
} | {
|
|
366
|
+
id: TRouteId;
|
|
367
|
+
}) & {
|
|
368
|
+
caseSensitive?: boolean;
|
|
369
|
+
validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;
|
|
370
|
+
preSearchFilters?: SearchFilter<TFullSearchSchema>[];
|
|
371
|
+
postSearchFilters?: SearchFilter<TFullSearchSchema>[];
|
|
372
|
+
component?: GetFrameworkGeneric<'Component'>;
|
|
373
|
+
errorComponent?: GetFrameworkGeneric<'ErrorComponent'>;
|
|
374
|
+
pendingComponent?: GetFrameworkGeneric<'Component'>;
|
|
375
|
+
loader?: LoaderFn<TRouteLoaderData, TFullSearchSchema, TAllParams>;
|
|
376
|
+
loaderMaxAge?: number;
|
|
377
|
+
loaderGcMaxAge?: number;
|
|
378
|
+
action?: ActionFn<TActionPayload, TActionResponse>;
|
|
379
|
+
beforeLoad?: (opts: {
|
|
380
|
+
router: Router<any, any, unknown>;
|
|
381
|
+
match: RouteMatch;
|
|
382
|
+
}) => Promise<void> | void;
|
|
383
|
+
onLoaded?: (matchContext: {
|
|
384
|
+
params: TAllParams;
|
|
385
|
+
search: TFullSearchSchema;
|
|
386
|
+
}) => void | undefined | ((match: {
|
|
387
|
+
params: TAllParams;
|
|
388
|
+
search: TFullSearchSchema;
|
|
389
|
+
}) => void);
|
|
390
|
+
onTransition?: (match: {
|
|
391
|
+
params: TAllParams;
|
|
392
|
+
search: TFullSearchSchema;
|
|
393
|
+
}) => void;
|
|
394
|
+
meta?: RouteMeta;
|
|
395
|
+
} & ({
|
|
396
|
+
parseParams?: never;
|
|
397
|
+
stringifyParams?: never;
|
|
398
|
+
} | {
|
|
399
|
+
parseParams: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams;
|
|
400
|
+
stringifyParams: (params: TParams) => Record<ParsePathParams<TPath>, string>;
|
|
401
|
+
}) & (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never ? {} : 'Cannot redefined path params in child routes!');
|
|
402
|
+
type SearchFilter<T, U = T> = (prev: T) => U;
|
|
403
|
+
interface RouteConfig<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData, TRouteLoaderData extends AnyLoaderData = AnyLoaderData, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = AnyLoaderData, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}, TKnownChildren = unknown> {
|
|
404
|
+
id: TId;
|
|
405
|
+
routeId: TRouteId;
|
|
406
|
+
path: NoInfer<TPath>;
|
|
407
|
+
fullPath: TFullPath;
|
|
408
|
+
options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
|
|
409
|
+
children?: TKnownChildren;
|
|
410
|
+
addChildren: IsAny<TId, any, <TNewChildren extends any>(children: TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
|
|
411
|
+
error: 'Invalid route detected';
|
|
412
|
+
route: TNewChildren;
|
|
413
|
+
}) => RouteConfig<TId, TRouteId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
|
|
414
|
+
createRoute: CreateRouteConfigFn<false, TId, TFullPath, TRouteLoaderData, TLoaderData, TFullSearchSchema, TAllParams>;
|
|
415
|
+
generate: GenerateFn<TRouteId, TPath, TParentRouteLoaderData, TParentLoaderData, TParentSearchSchema, TParentParams>;
|
|
416
|
+
}
|
|
417
|
+
type GenerateFn<TRouteId extends string = string, TPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData, TParentLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends {} = {}, TParentParams extends AnyPathParams = {}> = <TRouteLoaderData extends AnyLoaderData = AnyLoaderData, TActionPayload = unknown, TActionResponse = unknown, TSearchSchema extends AnySearchSchema = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams> = AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams>>(options: Omit<RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'>) => void;
|
|
418
|
+
type CreateRouteConfigFn<TIsRoot extends boolean = false, TParentId extends string = string, TParentPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}> = <TRouteId extends string, TPath extends string, TRouteLoaderData extends AnyLoaderData, TActionPayload, TActionResponse, TSearchSchema extends AnySearchSchema = AnySearchSchema, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams> = AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams>, TKnownChildren extends RouteConfig[] = RouteConfig[], TResolvedId extends string = string extends TRouteId ? string extends TPath ? string : TPath : TRouteId>(options?: TIsRoot extends true ? Omit<RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'> & {
|
|
419
|
+
path?: never;
|
|
420
|
+
} : RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, children?: TKnownChildren, isRoot?: boolean, parentId?: string, parentPath?: string) => RouteConfig<RoutePrefix<TParentId, TResolvedId>, TResolvedId, TPath, string extends TPath ? '' : RoutePath<RoutePrefix<TParentPath, TPath>>, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>, TKnownChildren>;
|
|
421
|
+
type RoutePath<T extends string> = T extends RootRouteId ? '/' : TrimPathRight<`${T}`>;
|
|
422
|
+
type RoutePrefix<TPrefix extends string, TId extends string> = string extends TId ? RootRouteId : TId extends string ? `${TPrefix}/${TId}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}` : never;
|
|
423
|
+
interface AnyRouteConfig extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
424
|
+
}
|
|
425
|
+
interface AnyRouteConfigWithChildren<TChildren> extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, TChildren> {
|
|
323
426
|
}
|
|
324
|
-
|
|
427
|
+
type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
|
|
428
|
+
type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
|
|
429
|
+
type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
|
|
430
|
+
declare const createRouteConfig: CreateRouteConfigFn<true>;
|
|
431
|
+
|
|
432
|
+
interface AnyRoute extends Route<any, any, any> {
|
|
433
|
+
}
|
|
434
|
+
interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown> {
|
|
435
|
+
routeInfo: TRouteInfo;
|
|
325
436
|
routeId: TRouteInfo['id'];
|
|
326
437
|
routeRouteId: TRouteInfo['routeId'];
|
|
327
438
|
routePath: TRouteInfo['path'];
|
|
@@ -329,15 +440,14 @@ interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRo
|
|
|
329
440
|
parentRoute?: AnyRoute;
|
|
330
441
|
childRoutes?: AnyRoute[];
|
|
331
442
|
options: RouteOptions;
|
|
332
|
-
router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>;
|
|
443
|
+
router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>;
|
|
333
444
|
buildLink: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>) => LinkInfo;
|
|
334
445
|
matchRoute: <TTo extends string = '.', TResolved extends string = ResolveRelativePath<TRouteInfo['id'], TTo>>(matchLocation: CheckRelativePath<TAllRouteInfo, TRouteInfo['fullPath'], NoInfer<TTo>> & Omit<ToOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>, opts?: MatchRouteOptions) => RouteInfoByPath<TAllRouteInfo, TResolved>['allParams'];
|
|
335
|
-
navigate: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['
|
|
446
|
+
navigate: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>) => Promise<void>;
|
|
336
447
|
action: unknown extends TRouteInfo['actionResponse'] ? Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']> | undefined : Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>;
|
|
337
448
|
loader: unknown extends TRouteInfo['routeLoaderData'] ? Action<LoaderContext<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams']>, TRouteInfo['routeLoaderData']> | undefined : Loader<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams'], TRouteInfo['routeLoaderData']>;
|
|
338
449
|
}
|
|
339
|
-
declare function createRoute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(routeConfig: RouteConfig, options: TRouteInfo['options'], parent: undefined | Route<TAllRouteInfo, any>, router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>): Route<TAllRouteInfo, TRouteInfo>;
|
|
340
|
-
declare function cascadeLoaderData(matches: RouteMatch<any, any>[]): void;
|
|
450
|
+
declare function createRoute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown>(routeConfig: RouteConfig, options: TRouteInfo['options'], parent: undefined | Route<TAllRouteInfo, any>, router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>): Route<TAllRouteInfo, TRouteInfo, TRouterContext>;
|
|
341
451
|
|
|
342
452
|
interface AnyAllRouteInfo {
|
|
343
453
|
routeConfig: AnyRouteConfig;
|
|
@@ -346,6 +456,8 @@ interface AnyAllRouteInfo {
|
|
|
346
456
|
routeInfoByFullPath: Record<string, AnyRouteInfo>;
|
|
347
457
|
routeIds: any;
|
|
348
458
|
routePaths: any;
|
|
459
|
+
fullSearchSchema: Record<string, any>;
|
|
460
|
+
allParams: Record<string, any>;
|
|
349
461
|
}
|
|
350
462
|
interface DefaultAllRouteInfo {
|
|
351
463
|
routeConfig: RouteConfig;
|
|
@@ -354,20 +466,26 @@ interface DefaultAllRouteInfo {
|
|
|
354
466
|
routeInfoByFullPath: Record<string, RouteInfo>;
|
|
355
467
|
routeIds: string;
|
|
356
468
|
routePaths: string;
|
|
469
|
+
fullSearchSchema: AnySearchSchema;
|
|
470
|
+
allParams: AnyPathParams;
|
|
357
471
|
}
|
|
358
472
|
interface AllRouteInfo<TRouteConfig extends AnyRouteConfig = RouteConfig> extends RoutesInfoInner<TRouteConfig, ParseRouteConfig<TRouteConfig>> {
|
|
359
473
|
}
|
|
360
|
-
|
|
361
|
-
|
|
474
|
+
type ParseRouteConfig<TRouteConfig = AnyRouteConfig> = TRouteConfig extends AnyRouteConfig ? RouteConfigRoute<TRouteConfig> | ParseRouteChildren<TRouteConfig> : never;
|
|
475
|
+
type ParseRouteChildren<TRouteConfig> = TRouteConfig extends AnyRouteConfigWithChildren<infer TChildren> ? unknown extends TChildren ? never : TChildren extends AnyRouteConfig[] ? Values<{
|
|
362
476
|
[TId in TChildren[number]['id']]: ParseRouteChild<TChildren[number], TId>;
|
|
363
477
|
}> : never : never;
|
|
364
|
-
|
|
478
|
+
type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
|
|
365
479
|
id: TId;
|
|
366
480
|
} extends AnyRouteConfig ? ParseRouteConfig<TRouteConfig> : never;
|
|
367
|
-
|
|
368
|
-
interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extends RouteInfo<string, string, any, any, any, any, any, any, any, any, any, any, any, any> = RouteInfo, TRouteInfoById = {
|
|
481
|
+
type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<infer TId, infer TRouteId, infer TPath, infer TFullPath, infer TParentRouteLoaderData, infer TRouteLoaderData, infer TParentLoaderData, infer TLoaderData, infer TActionPayload, infer TActionResponse, infer TParentSearchSchema, infer TSearchSchema, infer TFullSearchSchema, infer TParentParams, infer TParams, infer TAllParams, any> ? string extends TRouteId ? never : RouteInfo<TId, TRouteId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams> : never;
|
|
482
|
+
interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extends RouteInfo<string, string, any, any, any, any, any, any, any, any, any, any, any, any, any, any> = RouteInfo, TRouteInfoById = {
|
|
483
|
+
'/': TRouteInfo;
|
|
484
|
+
} & {
|
|
369
485
|
[TInfo in TRouteInfo as TInfo['id']]: TInfo;
|
|
370
486
|
}, TRouteInfoByFullPath = {
|
|
487
|
+
'/': TRouteInfo;
|
|
488
|
+
} & {
|
|
371
489
|
[TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId ? never : string extends TInfo['fullPath'] ? never : TInfo['fullPath']]: TInfo;
|
|
372
490
|
}> {
|
|
373
491
|
routeConfig: TRouteConfig;
|
|
@@ -376,15 +494,19 @@ interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extend
|
|
|
376
494
|
routeInfoByFullPath: TRouteInfoByFullPath;
|
|
377
495
|
routeIds: keyof TRouteInfoById;
|
|
378
496
|
routePaths: keyof TRouteInfoByFullPath;
|
|
497
|
+
fullSearchSchema: Partial<UnionToIntersection<TRouteInfo['fullSearchSchema']>>;
|
|
498
|
+
allParams: Partial<UnionToIntersection<TRouteInfo['allParams']>>;
|
|
379
499
|
}
|
|
380
|
-
interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
500
|
+
interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
381
501
|
}
|
|
382
|
-
interface RouteInfo<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string =
|
|
502
|
+
interface RouteInfo<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = '/', TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}> {
|
|
383
503
|
id: TId;
|
|
384
504
|
routeId: TRouteId;
|
|
385
505
|
path: TPath;
|
|
386
506
|
fullPath: TFullPath;
|
|
507
|
+
parentRouteLoaderData: TParentRouteLoaderData;
|
|
387
508
|
routeLoaderData: TRouteLoaderData;
|
|
509
|
+
parentLoaderData: TParentLoaderData;
|
|
388
510
|
loaderData: TLoaderData;
|
|
389
511
|
actionPayload: TActionPayload;
|
|
390
512
|
actionResponse: TActionResponse;
|
|
@@ -393,113 +515,15 @@ interface RouteInfo<TId extends string = string, TRouteId extends string = strin
|
|
|
393
515
|
parentParams: TParentParams;
|
|
394
516
|
params: TParams;
|
|
395
517
|
allParams: TAllParams;
|
|
396
|
-
options: RouteOptions<TRouteId, TPath, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
|
|
518
|
+
options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
|
|
397
519
|
}
|
|
398
|
-
|
|
520
|
+
type RoutesById<TAllRouteInfo extends AnyAllRouteInfo> = {
|
|
399
521
|
[K in keyof TAllRouteInfo['routeInfoById']]: Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][K]>;
|
|
400
522
|
};
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
declare const rootRouteId: "__root__";
|
|
405
|
-
declare type RootRouteId = typeof rootRouteId;
|
|
406
|
-
declare type AnyLoaderData = {};
|
|
407
|
-
declare type AnyPathParams = {};
|
|
408
|
-
declare type AnySearchSchema = {};
|
|
409
|
-
interface RouteMeta {
|
|
410
|
-
}
|
|
411
|
-
declare type SearchSchemaValidator<TReturn, TParentSchema> = SearchSchemaValidatorObj<TReturn, TParentSchema> | SearchSchemaValidatorFn<TReturn, TParentSchema>;
|
|
412
|
-
declare type SearchSchemaValidatorObj<TReturn, TParentSchema> = {
|
|
413
|
-
parse?: SearchSchemaValidatorFn<TReturn, TParentSchema>;
|
|
414
|
-
};
|
|
415
|
-
declare type SearchSchemaValidatorFn<TReturn, TParentSchema> = (searchObj: Record<string, unknown>) => {} extends TParentSchema ? TReturn : keyof TReturn extends keyof TParentSchema ? {
|
|
416
|
-
error: 'Top level search params cannot be redefined by child routes!';
|
|
417
|
-
keys: keyof TReturn & keyof TParentSchema;
|
|
418
|
-
} : TReturn;
|
|
419
|
-
declare type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!';
|
|
420
|
-
declare type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
|
|
421
|
-
[Key in keyof TParentParams]?: DefinedPathParamWarning;
|
|
422
|
-
};
|
|
423
|
-
declare type LoaderFn<TRouteLoaderData extends AnyLoaderData, TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> = (loaderContext: LoaderContext<TFullSearchSchema, TAllParams>) => Promise<TRouteLoaderData>;
|
|
424
|
-
interface LoaderContext<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
|
|
425
|
-
params: TAllParams;
|
|
426
|
-
search: TFullSearchSchema;
|
|
427
|
-
signal?: AbortSignal;
|
|
428
|
-
}
|
|
429
|
-
declare type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (submission: TActionPayload) => TActionResponse | Promise<TActionResponse>;
|
|
430
|
-
declare type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, RouteInfo<string, TPath>>) => void;
|
|
431
|
-
declare type RouteOptions<TRouteId extends string = string, TPath extends string = string, TRouteLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = {}> = ({
|
|
432
|
-
path: TPath;
|
|
433
|
-
} | {
|
|
434
|
-
id: TRouteId;
|
|
435
|
-
}) & {
|
|
436
|
-
caseSensitive?: boolean;
|
|
437
|
-
validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;
|
|
438
|
-
preSearchFilters?: SearchFilter<TFullSearchSchema>[];
|
|
439
|
-
postSearchFilters?: SearchFilter<TFullSearchSchema>[];
|
|
440
|
-
pendingMs?: number;
|
|
441
|
-
pendingMinMs?: number;
|
|
442
|
-
element?: GetFrameworkGeneric<'SyncOrAsyncElement'>;
|
|
443
|
-
errorElement?: GetFrameworkGeneric<'SyncOrAsyncElement'>;
|
|
444
|
-
catchElement?: GetFrameworkGeneric<'SyncOrAsyncElement'>;
|
|
445
|
-
pendingElement?: GetFrameworkGeneric<'SyncOrAsyncElement'>;
|
|
446
|
-
loader?: LoaderFn<TRouteLoaderData, TFullSearchSchema, TAllParams>;
|
|
447
|
-
loaderMaxAge?: number;
|
|
448
|
-
loaderGcMaxAge?: number;
|
|
449
|
-
action?: ActionFn<TActionPayload, TActionResponse>;
|
|
450
|
-
useErrorBoundary?: boolean;
|
|
451
|
-
onMatch?: (matchContext: {
|
|
452
|
-
params: TAllParams;
|
|
453
|
-
search: TFullSearchSchema;
|
|
454
|
-
}) => void | undefined | ((match: {
|
|
455
|
-
params: TAllParams;
|
|
456
|
-
search: TFullSearchSchema;
|
|
457
|
-
}) => void);
|
|
458
|
-
onTransition?: (match: {
|
|
459
|
-
params: TAllParams;
|
|
460
|
-
search: TFullSearchSchema;
|
|
461
|
-
}) => void;
|
|
462
|
-
meta?: RouteMeta;
|
|
463
|
-
} & ({
|
|
464
|
-
parseParams?: never;
|
|
465
|
-
stringifyParams?: never;
|
|
466
|
-
} | {
|
|
467
|
-
parseParams: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams;
|
|
468
|
-
stringifyParams: (params: TParams) => Record<ParsePathParams<TPath>, string>;
|
|
469
|
-
}) & (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never ? {} : 'Cannot redefined path params in child routes!');
|
|
470
|
-
declare type SearchFilter<T, U = T> = (prev: T) => U;
|
|
471
|
-
interface RouteConfig<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, TRouteLoaderData extends AnyLoaderData = AnyLoaderData, TLoaderData extends AnyLoaderData = AnyLoaderData, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = {}, TKnownChildren = unknown> {
|
|
472
|
-
id: TId;
|
|
473
|
-
routeId: TRouteId;
|
|
474
|
-
path: NoInfer<TPath>;
|
|
475
|
-
fullPath: TFullPath;
|
|
476
|
-
options: RouteOptions<TRouteId, TPath, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
|
|
477
|
-
children?: TKnownChildren;
|
|
478
|
-
addChildren: IsAny<TId, any, <TNewChildren extends any>(children: TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
|
|
479
|
-
error: 'Invalid route detected';
|
|
480
|
-
route: TNewChildren;
|
|
481
|
-
}) => RouteConfig<TId, TRouteId, TPath, TFullPath, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
|
|
482
|
-
createChildren: IsAny<TId, any, <TNewChildren extends any>(cb: (createChildRoute: CreateRouteConfigFn<false, TId, TFullPath, TLoaderData, TFullSearchSchema, TAllParams>) => TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
|
|
483
|
-
error: 'Invalid route detected';
|
|
484
|
-
route: TNewChildren;
|
|
485
|
-
}) => RouteConfig<TId, TRouteId, TPath, TFullPath, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
|
|
486
|
-
createRoute: CreateRouteConfigFn<false, TId, TFullPath, TLoaderData, TFullSearchSchema, TAllParams>;
|
|
487
|
-
}
|
|
488
|
-
declare type CreateRouteConfigFn<TIsRoot extends boolean = false, TParentId extends string = string, TParentPath extends string = string, TParentAllLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}> = <TRouteId extends string, TPath extends string, TRouteLoaderData extends AnyLoaderData, TActionPayload, TActionResponse, TSearchSchema extends AnySearchSchema = AnySearchSchema, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams> = AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams>, TKnownChildren extends RouteConfig[] = RouteConfig[], TResolvedId extends string = string extends TRouteId ? string extends TPath ? string : TPath : TRouteId>(options?: TIsRoot extends true ? Omit<RouteOptions<TRouteId, TPath, TRouteLoaderData, Expand<TParentAllLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'> & {
|
|
489
|
-
path?: never;
|
|
490
|
-
} : RouteOptions<TRouteId, TPath, TRouteLoaderData, Expand<TParentAllLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, children?: TKnownChildren, isRoot?: boolean, parentId?: string, parentPath?: string) => RouteConfig<RoutePrefix<TParentId, TResolvedId>, TResolvedId, TPath, string extends TPath ? '' : RoutePath<RoutePrefix<TParentPath, TPath>>, TRouteLoaderData, Expand<TParentAllLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>, TKnownChildren>;
|
|
491
|
-
declare type RoutePath<T extends string> = T extends RootRouteId ? '/' : TrimPathRight<`${T}`>;
|
|
492
|
-
declare type RoutePrefix<TPrefix extends string, TId extends string> = string extends TId ? RootRouteId : TId extends string ? `${TPrefix}/${TId}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}` : never;
|
|
493
|
-
interface AnyRouteConfig extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
494
|
-
}
|
|
495
|
-
interface AnyRouteConfigWithChildren<TChildren> extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, TChildren> {
|
|
496
|
-
}
|
|
497
|
-
declare type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
|
|
498
|
-
declare type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
|
|
499
|
-
declare type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
|
|
500
|
-
declare const createRouteConfig: CreateRouteConfigFn<true>;
|
|
523
|
+
type RouteInfoById<TAllRouteInfo extends AnyAllRouteInfo, TId> = TId extends keyof TAllRouteInfo['routeInfoById'] ? IsAny<TAllRouteInfo['routeInfoById'][TId]['id'], RouteInfo, TAllRouteInfo['routeInfoById'][TId]> : never;
|
|
524
|
+
type RouteInfoByPath<TAllRouteInfo extends AnyAllRouteInfo, TPath> = TPath extends keyof TAllRouteInfo['routeInfoByFullPath'] ? IsAny<TAllRouteInfo['routeInfoByFullPath'][TPath]['id'], RouteInfo, TAllRouteInfo['routeInfoByFullPath'][TPath]> : never;
|
|
501
525
|
|
|
502
|
-
|
|
526
|
+
type LinkInfo = {
|
|
503
527
|
type: 'external';
|
|
504
528
|
href: string;
|
|
505
529
|
} | {
|
|
@@ -512,12 +536,11 @@ declare type LinkInfo = {
|
|
|
512
536
|
isActive: boolean;
|
|
513
537
|
disabled?: boolean;
|
|
514
538
|
};
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
declare type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
|
|
539
|
+
type CleanPath<T extends string> = T extends `${infer L}//${infer R}` ? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`> : T extends `${infer L}//` ? `${CleanPath<L>}/` : T extends `//${infer L}` ? `/${CleanPath<L>}` : T;
|
|
540
|
+
type Split<S, TIncludeTrailingSlash = true> = S extends unknown ? string extends S ? string[] : S extends string ? CleanPath<S> extends '' ? [] : TIncludeTrailingSlash extends true ? CleanPath<S> extends `${infer T}/` ? [...Split<T>, '/'] : CleanPath<S> extends `/${infer U}` ? Split<U> : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : [S] : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : S extends string ? [S] : never : never : never;
|
|
541
|
+
type ParsePathParams<T extends string> = Split<T>[number] extends infer U ? U extends `$${infer V}` ? V : never : never;
|
|
542
|
+
type Join<T> = T extends [] ? '' : T extends [infer L extends string] ? L : T extends [infer L extends string, ...infer Tail extends [...string[]]] ? CleanPath<`${L}/${Join<Tail>}`> : never;
|
|
543
|
+
type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
|
|
521
544
|
...Split<ResolveRelativePath<TFrom, TTo>, false>,
|
|
522
545
|
...infer TToRest
|
|
523
546
|
] ? `${CleanPath<Join<[
|
|
@@ -528,39 +551,36 @@ declare type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends s
|
|
|
528
551
|
...Split<RestTTo, false>,
|
|
529
552
|
...infer RestPath
|
|
530
553
|
] ? `${TTo}${Join<RestPath>}` : never : './' | '../' | AllPaths;
|
|
531
|
-
|
|
554
|
+
type NavigateOptionsAbsolute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = ToOptions<TAllRouteInfo, TFrom, TTo> & {
|
|
532
555
|
replace?: boolean;
|
|
533
556
|
};
|
|
534
|
-
|
|
557
|
+
type ToOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
|
|
535
558
|
to?: ToPathOption<TAllRouteInfo, TFrom, TTo>;
|
|
536
559
|
hash?: Updater<string>;
|
|
560
|
+
state?: LocationState;
|
|
537
561
|
from?: TFrom;
|
|
538
562
|
} & CheckPath<TAllRouteInfo, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TAllRouteInfo, TFrom, TResolvedTo> & PathParamOptions<TAllRouteInfo, TFrom, TResolvedTo>;
|
|
539
|
-
|
|
540
|
-
search?: SearchReducer<
|
|
541
|
-
} : keyof PickRequired<TToSchema> extends never ? {
|
|
542
|
-
search?: SearchReducer<TFromSchema, TToSchema>;
|
|
563
|
+
type SearchParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = Expand<UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & RouteInfoByPath<TAllRouteInfo, TFrom> extends never ? {} : RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']>>, TToSchema = Partial<RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']> & Omit<RouteInfoByPath<TAllRouteInfo, TTo>['fullSearchSchema'], keyof PickRequired<RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']>>, TFromFullSchema = Expand<UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & TFromSchema>>, TToFullSchema = Expand<UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & TToSchema>>> = keyof PickRequired<TToSchema> extends never ? {
|
|
564
|
+
search?: true | SearchReducer<TFromFullSchema, TToFullSchema>;
|
|
543
565
|
} : {
|
|
544
|
-
search: SearchReducer<
|
|
566
|
+
search: SearchReducer<TFromFullSchema, TToFullSchema>;
|
|
545
567
|
};
|
|
546
|
-
|
|
568
|
+
type SearchReducer<TFrom, TTo> = {
|
|
547
569
|
[TKey in keyof TTo]: TTo[TKey];
|
|
548
570
|
} | ((current: TFrom) => TTo);
|
|
549
|
-
|
|
550
|
-
params?: ParamsReducer<
|
|
551
|
-
} : AnyPathParams extends TToParams ? {
|
|
552
|
-
params?: ParamsReducer<TFromParams, Record<string, never>>;
|
|
571
|
+
type PathParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = Expand<UnionToIntersection<RouteInfoByPath<TAllRouteInfo, TFrom> extends never ? {} : RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']>>, TToSchema = Partial<RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']> & Omit<RouteInfoByPath<TAllRouteInfo, TTo>['allParams'], keyof PickRequired<RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']>>, TFromFullParams = Expand<UnionToIntersection<TAllRouteInfo['allParams'] & TFromSchema>>, TToFullParams = Expand<UnionToIntersection<TAllRouteInfo['allParams'] & TToSchema>>> = keyof PickRequired<TToSchema> extends never ? {
|
|
572
|
+
params?: ParamsReducer<TFromFullParams, TToFullParams>;
|
|
553
573
|
} : {
|
|
554
|
-
params: ParamsReducer<
|
|
574
|
+
params: ParamsReducer<TFromFullParams, TToFullParams>;
|
|
555
575
|
};
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
576
|
+
type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
|
|
577
|
+
type ToPathOption<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = TTo | RelativeToPathAutoComplete<TAllRouteInfo['routePaths'], NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
|
|
578
|
+
type ToIdOption<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = TTo | RelativeToPathAutoComplete<TAllRouteInfo['routeIds'], NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
|
|
559
579
|
interface ActiveOptions {
|
|
560
580
|
exact?: boolean;
|
|
561
581
|
includeHash?: boolean;
|
|
562
582
|
}
|
|
563
|
-
|
|
583
|
+
type LinkOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo> & {
|
|
564
584
|
target?: HTMLAnchorElement['target'];
|
|
565
585
|
activeOptions?: ActiveOptions;
|
|
566
586
|
preload?: false | 'intent';
|
|
@@ -569,22 +589,22 @@ declare type LinkOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRoute
|
|
|
569
589
|
preloadDelay?: number;
|
|
570
590
|
disabled?: boolean;
|
|
571
591
|
};
|
|
572
|
-
|
|
592
|
+
type CheckRelativePath<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends TAllRouteInfo['routePaths'] ? {} : {
|
|
573
593
|
Error: `${TFrom} + ${TTo} resolves to ${ResolveRelativePath<TFrom, TTo>}, which is not a valid route path.`;
|
|
574
594
|
'Valid Route Paths': TAllRouteInfo['routePaths'];
|
|
575
595
|
} : {} : {};
|
|
576
|
-
|
|
577
|
-
|
|
596
|
+
type CheckPath<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routePaths']> extends never ? TPass : CheckPathError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routePaths']>>;
|
|
597
|
+
type CheckPathError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
|
|
578
598
|
Error: `${TInvalids extends string ? TInvalids : never} is not a valid route path.`;
|
|
579
599
|
'Valid Route Paths': TAllRouteInfo['routePaths'];
|
|
580
600
|
}>;
|
|
581
|
-
|
|
582
|
-
|
|
601
|
+
type CheckId<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routeIds']> extends never ? TPass : CheckIdError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routeIds']>>;
|
|
602
|
+
type CheckIdError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
|
|
583
603
|
Error: `${TInvalids extends string ? TInvalids : never} is not a valid route ID.`;
|
|
584
604
|
'Valid Route IDs': TAllRouteInfo['routeIds'];
|
|
585
605
|
}>;
|
|
586
|
-
|
|
587
|
-
|
|
606
|
+
type ResolveRelativePath<TFrom, TTo = '.'> = TFrom extends string ? TTo extends string ? TTo extends '.' ? TFrom : TTo extends `./` ? Join<[TFrom, '/']> : TTo extends `./${infer TRest}` ? ResolveRelativePath<TFrom, TRest> : TTo extends `/${infer TRest}` ? TTo : Split<TTo> extends ['..', ...infer ToRest] ? Split<TFrom> extends [...infer FromRest, infer FromTail] ? ToRest extends ['/'] ? Join<[...FromRest, '/']> : ResolveRelativePath<Join<FromRest>, Join<ToRest>> : never : Split<TTo> extends ['.', ...infer ToRest] ? ToRest extends ['/'] ? Join<[TFrom, '/']> : ResolveRelativePath<TFrom, Join<ToRest>> : CleanPath<Join<['/', ...Split<TFrom>, ...Split<TTo>]>> : never : never;
|
|
607
|
+
type ValidFromPath<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo> = undefined | (string extends TAllRouteInfo['routePaths'] ? string : TAllRouteInfo['routePaths']);
|
|
588
608
|
|
|
589
609
|
interface Segment {
|
|
590
610
|
type: 'pathname' | 'param' | 'wildcard';
|
|
@@ -609,4 +629,4 @@ declare const defaultStringifySearch: (search: Record<string, any>) => string;
|
|
|
609
629
|
declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySearchSchema;
|
|
610
630
|
declare function stringifySearchWith(stringify: (search: any) => string): (search: Record<string, any>) => string;
|
|
611
631
|
|
|
612
|
-
export { Action, ActionFn, ActionState, AllRouteInfo, AnyAllRouteInfo, AnyLoaderData, AnyPathParams, AnyRoute, AnyRouteConfig, AnyRouteConfigWithChildren, AnyRouteInfo, AnySearchSchema, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, DeepAwaited, DefaultAllRouteInfo, DefinedPathParamWarning, Expand, FilterRoutesFn, FrameworkGenerics, FromLocation, GetFrameworkGeneric, IsAny, IsAnyBoolean, IsKnown, LinkInfo, LinkOptions, ListenerFn, Loader, LoaderContext, LoaderFn, LoaderState, Location, LocationState, MatchCacheEntry, MatchLocation, MatchRouteOptions, NavigateOptionsAbsolute, NoInfer, ParentParams, ParsePathParams, ParseRouteConfig, PathParamMask, PendingState, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, RelativeToPathAutoComplete, ResolveRelativePath, RootRouteId, Route, RouteConfig, RouteConfigRoute, RouteInfo, RouteInfoById, RouteInfoByPath, RouteMatch, RouteMeta, RouteOptions, Router, RouterOptions, RouterState, RoutesById, RoutesInfoInner, SearchFilter, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, Timeout, ToIdOption, ToOptions, ToPathOption, UnloaderFn, Updater, ValidFromPath, ValueKeys, Values,
|
|
632
|
+
export { Action, ActionFn, ActionState, AllRouteInfo, AnyAllRouteInfo, AnyLoaderData, AnyPathParams, AnyRoute, AnyRouteConfig, AnyRouteConfigWithChildren, AnyRouteInfo, AnySearchSchema, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, DeepAwaited, DefaultAllRouteInfo, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, Expand, FilterRoutesFn, FrameworkGenerics, FromLocation, GetFrameworkGeneric, IsAny, IsAnyBoolean, IsKnown, LinkInfo, LinkOptions, ListenerFn, Loader, LoaderContext, LoaderFn, LoaderState, Location, LocationState, MatchCacheEntry, MatchLocation, MatchRouteOptions, NavigateOptionsAbsolute, NoInfer, ParentParams, ParsePathParams, ParseRouteConfig, PathParamMask, PendingState, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, RegisterRouter, RegisteredAllRouteInfo, RegisteredRouter, RelativeToPathAutoComplete, ResolveRelativePath, RootRouteId, Route, RouteConfig, RouteConfigRoute, RouteInfo, RouteInfoById, RouteInfoByPath, RouteMatch, RouteMeta, RouteOptions, Router, RouterContext, RouterOptions, RouterState, RoutesById, RoutesInfoInner, SearchFilter, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, Timeout, ToIdOption, ToOptions, ToPathOption, UnionToIntersection, UnloaderFn, Updater, ValidFromPath, ValueKeys, Values, cleanPath, createRoute, createRouteConfig, createRouteMatch, createRouter, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
|