@tanstack/router-core 0.0.1-beta.161 → 0.0.1-beta.162
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.map +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +114 -114
- package/build/types/index.d.ts +22 -22
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/fileRoute.ts +5 -5
- package/src/link.ts +8 -8
- package/src/route.ts +13 -13
- package/src/routeInfo.ts +2 -2
- package/src/router.ts +11 -11
package/build/types/index.d.ts
CHANGED
|
@@ -114,8 +114,8 @@ type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<ParseRoute<TRoute
|
|
|
114
114
|
fullPath: TPath;
|
|
115
115
|
}>;
|
|
116
116
|
type RoutePaths<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['fullPath'] | '/';
|
|
117
|
-
type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['
|
|
118
|
-
type AllParams<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['
|
|
117
|
+
type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['fullSearchSchema']> & {};
|
|
118
|
+
type AllParams<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['allParams']>;
|
|
119
119
|
|
|
120
120
|
declare global {
|
|
121
121
|
interface Window {
|
|
@@ -156,7 +156,7 @@ interface RouteMatch<TRouteTree extends AnyRoute = AnyRoute, TRoute extends AnyR
|
|
|
156
156
|
key?: string;
|
|
157
157
|
routeId: string;
|
|
158
158
|
pathname: string;
|
|
159
|
-
params: TRoute['
|
|
159
|
+
params: TRoute['types']['allParams'];
|
|
160
160
|
status: 'pending' | 'success' | 'error';
|
|
161
161
|
isFetching: boolean;
|
|
162
162
|
invalid: boolean;
|
|
@@ -166,21 +166,21 @@ interface RouteMatch<TRouteTree extends AnyRoute = AnyRoute, TRoute extends AnyR
|
|
|
166
166
|
updatedAt: number;
|
|
167
167
|
invalidAt: number;
|
|
168
168
|
preloadInvalidAt: number;
|
|
169
|
-
loaderData: TRoute['
|
|
169
|
+
loaderData: TRoute['types']['loader'];
|
|
170
170
|
loadPromise?: Promise<void>;
|
|
171
171
|
__resolveLoadPromise?: () => void;
|
|
172
|
-
routeContext: TRoute['
|
|
173
|
-
context: TRoute['
|
|
174
|
-
routeSearch: TRoute['
|
|
175
|
-
search: FullSearchSchema<TRouteTree> & TRoute['
|
|
172
|
+
routeContext: TRoute['types']['routeContext'];
|
|
173
|
+
context: TRoute['types']['context'];
|
|
174
|
+
routeSearch: TRoute['types']['searchSchema'];
|
|
175
|
+
search: FullSearchSchema<TRouteTree> & TRoute['types']['fullSearchSchema'];
|
|
176
176
|
fetchedAt: number;
|
|
177
177
|
abortController: AbortController;
|
|
178
178
|
}
|
|
179
179
|
type AnyRouteMatch = RouteMatch<AnyRoute, AnyRoute>;
|
|
180
|
-
type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends TRouteTree['
|
|
181
|
-
context?: TRouteTree['
|
|
180
|
+
type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends TRouteTree['types']['routerContext'] ? {
|
|
181
|
+
context?: TRouteTree['types']['routerContext'];
|
|
182
182
|
} : {
|
|
183
|
-
context: TRouteTree['
|
|
183
|
+
context: TRouteTree['types']['routerContext'];
|
|
184
184
|
};
|
|
185
185
|
interface RouterOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<string, any>> {
|
|
186
186
|
history?: RouterHistory;
|
|
@@ -202,7 +202,7 @@ interface RouterOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<
|
|
|
202
202
|
router: AnyRouter;
|
|
203
203
|
}) => void;
|
|
204
204
|
onRouteChange?: () => void;
|
|
205
|
-
context?: TRouteTree['
|
|
205
|
+
context?: TRouteTree['types']['routerContext'];
|
|
206
206
|
Wrap?: React.ComponentType<{
|
|
207
207
|
children: React.ReactNode;
|
|
208
208
|
dehydratedState?: TDehydrated;
|
|
@@ -303,7 +303,7 @@ declare class Router<TRouteTree extends AnyRoute = AnyRoute, TDehydrated extends
|
|
|
303
303
|
reload: () => Promise<void>;
|
|
304
304
|
resolvePath: (from: string, path: string) => string;
|
|
305
305
|
navigate: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">({ from, to, search, hash, replace, params, }: NavigateOptions<TRouteTree, TFrom, TTo>) => Promise<void>;
|
|
306
|
-
matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRouteTree, TFrom, TTo, ResolveRelativePath<TFrom, NoInfer<TTo>>>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["
|
|
306
|
+
matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRouteTree, TFrom, TTo, ResolveRelativePath<TFrom, NoInfer<TTo>>>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
|
|
307
307
|
buildLink: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">({ from, to, search, params, hash, target, replace, activeOptions, preload, preloadDelay: userPreloadDelay, disabled, state, }: LinkOptions<TRouteTree, TFrom, TTo>) => LinkInfo;
|
|
308
308
|
dehydrate: () => DehydratedRouter;
|
|
309
309
|
hydrate: (__do_not_use_server_ctx?: HydrationCtx) => Promise<void>;
|
|
@@ -374,7 +374,7 @@ type MetaOptions = keyof PickRequired<RouteMeta> extends never ? {
|
|
|
374
374
|
type AnyRouteProps = RouteProps<any, any, any, any, any>;
|
|
375
375
|
type ComponentPropsFromRoute<TRoute> = TRoute extends Route<infer TParentRoute, infer TPath, infer TFullPath, infer TCustomId, infer TId, infer TLoader, infer TSearchSchema, infer TFullSearchSchema, infer TParams, infer TAllParams, infer TParentContext, infer TAllParentContext, infer TRouteContext, infer TContext, infer TRouterContext, infer TChildren, infer TRouteTree> ? RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext> : never;
|
|
376
376
|
type ComponentFromRoute<TRoute> = RegisteredRouteComponent<ComponentPropsFromRoute<TRoute>>;
|
|
377
|
-
type RouteLoaderFromRoute<TRoute extends AnyRoute> = LoaderFn<TRoute['
|
|
377
|
+
type RouteLoaderFromRoute<TRoute extends AnyRoute> = LoaderFn<TRoute['types']['loader'], TRoute['types']['searchSchema'], TRoute['types']['fullSearchSchema'], TRoute['types']['allParams'], TRoute['types']['routeContext'], TRoute['types']['context']>;
|
|
378
378
|
type RouteProps<TLoader extends any = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TContext extends AnyContext = AnyContext> = {
|
|
379
379
|
useMatch: () => RouteMatch<any, any>;
|
|
380
380
|
useLoader: () => UseLoaderResult<TLoader>;
|
|
@@ -491,11 +491,11 @@ type ResolveId<TParentRoute, TCustomId extends string, TPath extends string> = T
|
|
|
491
491
|
} ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId> : RootRouteId;
|
|
492
492
|
type InferFullSearchSchema<TRoute> = TRoute extends {
|
|
493
493
|
isRoot: true;
|
|
494
|
-
|
|
494
|
+
types: {
|
|
495
495
|
searchSchema: infer TSearchSchema;
|
|
496
496
|
};
|
|
497
497
|
} ? TSearchSchema : TRoute extends {
|
|
498
|
-
|
|
498
|
+
types: {
|
|
499
499
|
fullSearchSchema: infer TFullSearchSchema;
|
|
500
500
|
};
|
|
501
501
|
} ? TFullSearchSchema : {};
|
|
@@ -531,8 +531,8 @@ type RouteConstraints = {
|
|
|
531
531
|
TChildren: unknown;
|
|
532
532
|
TRouteTree: AnyRoute;
|
|
533
533
|
};
|
|
534
|
-
declare class Route<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends RouteConstraints['TParams'] = Record<ParsePathParams<TPath>, string>, TAllParams extends RouteConstraints['TAllParams'] = MergeParamsFromParent<TParentRoute['
|
|
535
|
-
|
|
534
|
+
declare class Route<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends RouteConstraints['TParams'] = Record<ParsePathParams<TPath>, string>, TAllParams extends RouteConstraints['TAllParams'] = MergeParamsFromParent<TParentRoute['types']['allParams'], TParams>, TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['types']['routeContext'], TAllParentContext extends RouteConstraints['TAllParentContext'] = TParentRoute['types']['context'], TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TAllContext extends RouteConstraints['TAllContext'] = MergeParamsFromParent<TParentRoute['types']['context'], TRouteContext>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute> {
|
|
535
|
+
types: {
|
|
536
536
|
parentRoute: TParentRoute;
|
|
537
537
|
path: TPath;
|
|
538
538
|
to: TrimPathRight<TFullPath>;
|
|
@@ -593,12 +593,12 @@ type TrimLeft<T extends string, S extends string> = T extends `${S}${infer U}` ?
|
|
|
593
593
|
type TrimRight<T extends string, S extends string> = T extends `${infer U}${S}` ? U : T;
|
|
594
594
|
type Trim<T extends string, S extends string> = TrimLeft<TrimRight<T, S>, S>;
|
|
595
595
|
type RemoveUnderScores<T extends string> = Replace<Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>, '/_', '/'>;
|
|
596
|
-
type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : Replace<TrimPathLeft<TFilePath>, TrimPathLeft<TParentRoute['
|
|
596
|
+
type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : Replace<TrimPathLeft<TFilePath>, TrimPathLeft<TParentRoute['types']['customId']>, ''>;
|
|
597
597
|
type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends string> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}` ? string : ResolveFilePath<TParentRoute, TFilePath>;
|
|
598
598
|
declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = TFilePath, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, RemoveUnderScores<TPath>>> {
|
|
599
599
|
path: TFilePath;
|
|
600
600
|
constructor(path: TFilePath);
|
|
601
|
-
createRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = (TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never) extends never ? AnyPathParams : Record<TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never, string>, TAllParams extends Record<string, any> = IsAny<TParentRoute["
|
|
601
|
+
createRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = (TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never) extends never ? AnyPathParams : Record<TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never, string>, TAllParams extends Record<string, any> = IsAny<TParentRoute["types"]["allParams"], TParams, TParentRoute["types"]["allParams"] & TParams>, TParentContext extends AnyContext = TParentRoute["types"]["routeContext"], TAllParentContext extends string = TParentRoute["types"]["context"], TRouteContext extends RouteContext = RouteContext, TContext extends AnyContext = IsAny<TParentRoute["types"]["context"], TRouteContext, TParentRoute["types"]["context"] & TRouteContext>, TRouterContext extends AnyContext = AnyContext, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options: Omit<RouteOptions<TParentRoute, string, string, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext>, "id" | "path" | "getParentRoute"> & {
|
|
602
602
|
meta?: RouteMeta | undefined;
|
|
603
603
|
} & {
|
|
604
604
|
key?: false | GetKeyFn<TFullSearchSchema, TAllParams> | null | undefined;
|
|
@@ -677,7 +677,7 @@ type ToOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<
|
|
|
677
677
|
state?: LocationState;
|
|
678
678
|
from?: TFrom;
|
|
679
679
|
} & CheckPath<TRouteTree, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TRouteTree, TFrom, TResolvedTo> & PathParamOptions<TRouteTree, TFrom, TResolvedTo>;
|
|
680
|
-
type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['
|
|
680
|
+
type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']>, TToSchema = Partial<RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']> & Omit<RouteByPath<TRouteTree, TTo>['types']['fullSearchSchema'], keyof PickRequired<RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']>>, TFromFullSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & TFromSchema>, TToFullSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & TToSchema>> = keyof PickRequired<TToSchema> extends never ? {
|
|
681
681
|
search?: true | SearchReducer<TFromFullSchema, TToFullSchema>;
|
|
682
682
|
} : {
|
|
683
683
|
search: SearchReducer<TFromFullSchema, TToFullSchema>;
|
|
@@ -685,7 +685,7 @@ type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = U
|
|
|
685
685
|
type SearchReducer<TFrom, TTo> = {
|
|
686
686
|
[TKey in keyof TTo]: TTo[TKey];
|
|
687
687
|
} | ((current: TFrom) => TTo);
|
|
688
|
-
type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['
|
|
688
|
+
type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['types']['allParams']>, TToSchema = Partial<RouteByPath<TRouteTree, TFrom>['types']['allParams']> & Omit<RouteByPath<TRouteTree, TTo>['types']['allParams'], keyof PickRequired<RouteByPath<TRouteTree, TFrom>['types']['allParams']>>, TFromFullParams = UnionToIntersection<AllParams<TRouteTree> & TFromSchema>, TToFullParams = UnionToIntersection<AllParams<TRouteTree> & TToSchema>> = keyof PickRequired<TToSchema> extends never ? {
|
|
689
689
|
params?: ParamsReducer<TFromFullParams, TToFullParams>;
|
|
690
690
|
} : {
|
|
691
691
|
params: ParamsReducer<TFromFullParams, TToFullParams>;
|