@tanstack/solid-router 1.114.23 → 1.114.25
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/dist/cjs/index.cjs +20 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -1
- package/dist/cjs/route.cjs +42 -92
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +14 -48
- package/dist/cjs/router.cjs +4 -1677
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +32 -139
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/route.d.ts +14 -48
- package/dist/esm/route.js +43 -93
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +32 -139
- package/dist/esm/router.js +6 -1679
- package/dist/esm/router.js.map +1 -1
- package/dist/source/index.d.ts +2 -1
- package/dist/source/index.jsx +2 -1
- package/dist/source/index.jsx.map +1 -1
- package/dist/source/route.d.ts +15 -48
- package/dist/source/route.js +43 -109
- package/dist/source/route.js.map +1 -1
- package/dist/source/router.d.ts +33 -139
- package/dist/source/router.js +5 -1809
- package/dist/source/router.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +3 -3
- package/src/route.ts +110 -359
- package/src/router.ts +39 -2550
package/dist/esm/route.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseRootRoute, BaseRoute, BaseRouteApi, AnyContext, AnyRoute, AnyRouter, ConstrainLiteral, ErrorComponentProps, NotFoundError, NotFoundRouteProps, RegisteredRouter, ResolveFullPath, ResolveId, ResolveParams, RootRouteId, RootRouteOptions, RouteConstraints, RouteIds, RouteMask, RouteOptions, RouteTypesById, RouterCore, ToMaskOptions, UseNavigateResult } from '@tanstack/router-core';
|
|
2
2
|
import { UseLoaderDataRoute } from './useLoaderData.js';
|
|
3
3
|
import { UseMatchRoute } from './useMatch.js';
|
|
4
4
|
import { UseLoaderDepsRoute } from './useLoaderDeps.js';
|
|
@@ -24,8 +24,7 @@ declare module '@tanstack/router-core' {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
export declare function getRouteApi<const TId, TRouter extends AnyRouter = RegisteredRouter>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>): RouteApi<TId, TRouter>;
|
|
27
|
-
export declare class RouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {
|
|
28
|
-
id: TId;
|
|
27
|
+
export declare class RouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> extends BaseRouteApi<TId, TRouter> {
|
|
29
28
|
/**
|
|
30
29
|
* @deprecated Use the `getRouteApi` function instead.
|
|
31
30
|
*/
|
|
@@ -41,43 +40,11 @@ export declare class RouteApi<TId, TRouter extends AnyRouter = RegisteredRouter>
|
|
|
41
40
|
useNavigate: () => UseNavigateResult<RouteTypesById<TRouter, TId>["fullPath"]>;
|
|
42
41
|
notFound: (opts?: NotFoundError) => NotFoundError;
|
|
43
42
|
}
|
|
44
|
-
export declare class Route<in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, in out TPath extends RouteConstraints['TPath'] = '/', in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, in out TCustomId extends RouteConstraints['TCustomId'] = string, in out TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, in out TSearchValidator = undefined, in out TParams = ResolveParams<TPath>, in out TRouterContext = AnyContext, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown>
|
|
45
|
-
isRoot: TParentRoute extends AnyRoute ? true : false;
|
|
46
|
-
options: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>;
|
|
47
|
-
parentRoute: TParentRoute;
|
|
48
|
-
private _id;
|
|
49
|
-
private _path;
|
|
50
|
-
private _fullPath;
|
|
51
|
-
private _to;
|
|
52
|
-
private _ssr;
|
|
53
|
-
get to(): TrimPathRight<TFullPath>;
|
|
54
|
-
get id(): TId;
|
|
55
|
-
get path(): TPath;
|
|
56
|
-
get fullPath(): TFullPath;
|
|
57
|
-
get ssr(): boolean;
|
|
58
|
-
children?: TChildren;
|
|
59
|
-
originalIndex?: number;
|
|
60
|
-
rank: number;
|
|
61
|
-
lazyFn?: () => Promise<CoreLazyRoute>;
|
|
62
|
-
_lazyPromise?: Promise<void>;
|
|
63
|
-
_componentsPromise?: Promise<Array<void>>;
|
|
43
|
+
export declare class Route<in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, in out TPath extends RouteConstraints['TPath'] = '/', in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, in out TCustomId extends RouteConstraints['TCustomId'] = string, in out TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, in out TSearchValidator = undefined, in out TParams = ResolveParams<TPath>, in out TRouterContext = AnyContext, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> extends BaseRoute<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes> {
|
|
64
44
|
/**
|
|
65
45
|
* @deprecated Use the `createRoute` function instead.
|
|
66
46
|
*/
|
|
67
47
|
constructor(options?: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>);
|
|
68
|
-
types: RouteTypes<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>;
|
|
69
|
-
init: (opts: {
|
|
70
|
-
originalIndex: number;
|
|
71
|
-
defaultSsr?: boolean;
|
|
72
|
-
}) => void;
|
|
73
|
-
addChildren: RouteAddChildrenFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TFileRouteTypes>;
|
|
74
|
-
_addFileChildren: RouteAddFileChildrenFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TFileRouteTypes>;
|
|
75
|
-
_addFileTypes: RouteAddFileTypesFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren>;
|
|
76
|
-
updateLoader: <TNewLoaderFn>(options: {
|
|
77
|
-
loader: Constrain<TNewLoaderFn, RouteLoaderFn<TParentRoute, TCustomId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>>;
|
|
78
|
-
}) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TNewLoaderFn, TChildren, TFileRouteTypes>;
|
|
79
|
-
update: (options: UpdatableRouteOptions<TParentRoute, TCustomId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => this;
|
|
80
|
-
lazy: RouteLazyFn<this>;
|
|
81
48
|
useMatch: UseMatchRoute<TId>;
|
|
82
49
|
useRouteContext: UseRouteContextRoute<TId>;
|
|
83
50
|
useSearch: UseSearchRoute<TId>;
|
|
@@ -86,31 +53,29 @@ export declare class Route<in out TParentRoute extends RouteConstraints['TParent
|
|
|
86
53
|
useLoaderData: UseLoaderDataRoute<TId>;
|
|
87
54
|
useNavigate: () => UseNavigateResult<TFullPath>;
|
|
88
55
|
}
|
|
89
|
-
export declare function createRoute<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>, TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown>(options: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn>):
|
|
56
|
+
export declare function createRoute<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>, TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown>(options: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn>): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, unknown>;
|
|
90
57
|
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>;
|
|
91
58
|
export declare function createRootRouteWithContext<TRouterContext extends {}>(): <TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TSearchValidator = undefined, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined>(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>) => RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown>;
|
|
92
59
|
/**
|
|
93
60
|
* @deprecated Use the `createRootRouteWithContext` function instead.
|
|
94
61
|
*/
|
|
95
62
|
export declare const rootRouteWithContext: typeof createRootRouteWithContext;
|
|
96
|
-
export declare class RootRoute<in out TSearchValidator = undefined, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> extends
|
|
97
|
-
'/', // TPath
|
|
98
|
-
'/', // TFullPath
|
|
99
|
-
string, // TCustomId
|
|
100
|
-
RootRouteId, // TId
|
|
101
|
-
TSearchValidator, // TSearchValidator
|
|
102
|
-
{}, // TParams
|
|
103
|
-
TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, // TChildren
|
|
104
|
-
TFileRouteTypes> {
|
|
63
|
+
export declare class RootRoute<in out TSearchValidator = undefined, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> extends BaseRootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes> {
|
|
105
64
|
/**
|
|
106
65
|
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
107
66
|
*/
|
|
108
67
|
constructor(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>);
|
|
68
|
+
useMatch: UseMatchRoute<RootRouteId>;
|
|
69
|
+
useRouteContext: UseRouteContextRoute<RootRouteId>;
|
|
70
|
+
useSearch: UseSearchRoute<RootRouteId>;
|
|
71
|
+
useParams: UseParamsRoute<RootRouteId>;
|
|
72
|
+
useLoaderDeps: UseLoaderDepsRoute<RootRouteId>;
|
|
73
|
+
useLoaderData: UseLoaderDataRoute<RootRouteId>;
|
|
74
|
+
useNavigate: () => UseNavigateResult<"/">;
|
|
109
75
|
}
|
|
110
|
-
export declare function createRootRoute<TSearchValidator = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined>(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown>;
|
|
111
76
|
export declare function createRouteMask<TRouteTree extends AnyRoute, TFrom extends string, TTo extends string>(opts: {
|
|
112
77
|
routeTree: TRouteTree;
|
|
113
|
-
} & ToMaskOptions<
|
|
78
|
+
} & ToMaskOptions<RouterCore<TRouteTree, 'never', false>, TFrom, TTo>): RouteMask<TRouteTree>;
|
|
114
79
|
export type SolidNode = Solid.JSX.Element;
|
|
115
80
|
export type SyncRouteComponent<TProps> = (props: TProps) => Solid.JSX.Element;
|
|
116
81
|
export type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
|
|
@@ -122,3 +87,4 @@ export type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>;
|
|
|
122
87
|
export declare class NotFoundRoute<TParentRoute extends AnyRootRoute, TRouterContext = AnyContext, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TSearchValidator = undefined, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown> extends Route<TParentRoute, '/404', '/404', '404', '404', TSearchValidator, {}, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren> {
|
|
123
88
|
constructor(options: Omit<RouteOptions<TParentRoute, string, string, string, string, TSearchValidator, {}, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>, 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'path' | 'id' | 'params'>);
|
|
124
89
|
}
|
|
90
|
+
export declare function createRootRoute<TSearchValidator = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined>(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown>;
|
package/dist/esm/route.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { notFound, rootRouteId, trimPathLeft, joinPaths } from "@tanstack/router-core";
|
|
1
|
+
import { BaseRouteApi, notFound, BaseRoute, BaseRootRoute } from "@tanstack/router-core";
|
|
3
2
|
import { useLoaderData } from "./useLoaderData.js";
|
|
4
3
|
import { useLoaderDeps } from "./useLoaderDeps.js";
|
|
5
4
|
import { useParams } from "./useParams.js";
|
|
@@ -10,11 +9,12 @@ import { useRouter } from "./useRouter.js";
|
|
|
10
9
|
function getRouteApi(id) {
|
|
11
10
|
return new RouteApi({ id });
|
|
12
11
|
}
|
|
13
|
-
class RouteApi {
|
|
12
|
+
class RouteApi extends BaseRouteApi {
|
|
14
13
|
/**
|
|
15
14
|
* @deprecated Use the `getRouteApi` function instead.
|
|
16
15
|
*/
|
|
17
16
|
constructor({ id }) {
|
|
17
|
+
super({ id });
|
|
18
18
|
this.useMatch = (opts) => {
|
|
19
19
|
return useMatch({
|
|
20
20
|
select: opts == null ? void 0 : opts.select,
|
|
@@ -52,77 +52,14 @@ class RouteApi {
|
|
|
52
52
|
this.notFound = (opts) => {
|
|
53
53
|
return notFound({ routeId: this.id, ...opts });
|
|
54
54
|
};
|
|
55
|
-
this.id = id;
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
|
-
class Route {
|
|
57
|
+
class Route extends BaseRoute {
|
|
59
58
|
/**
|
|
60
59
|
* @deprecated Use the `createRoute` function instead.
|
|
61
60
|
*/
|
|
62
61
|
constructor(options) {
|
|
63
|
-
|
|
64
|
-
var _a, _b;
|
|
65
|
-
this.originalIndex = opts.originalIndex;
|
|
66
|
-
const options2 = this.options;
|
|
67
|
-
const isRoot = !(options2 == null ? void 0 : options2.path) && !(options2 == null ? void 0 : options2.id);
|
|
68
|
-
this.parentRoute = (_b = (_a = this.options).getParentRoute) == null ? void 0 : _b.call(_a);
|
|
69
|
-
if (isRoot) {
|
|
70
|
-
this._path = rootRouteId;
|
|
71
|
-
} else {
|
|
72
|
-
invariant(
|
|
73
|
-
this.parentRoute,
|
|
74
|
-
`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
let path = isRoot ? rootRouteId : options2.path;
|
|
78
|
-
if (path && path !== "/") {
|
|
79
|
-
path = trimPathLeft(path);
|
|
80
|
-
}
|
|
81
|
-
const customId = (options2 == null ? void 0 : options2.id) || path;
|
|
82
|
-
let id = isRoot ? rootRouteId : joinPaths([
|
|
83
|
-
this.parentRoute.id === rootRouteId ? "" : this.parentRoute.id,
|
|
84
|
-
customId
|
|
85
|
-
]);
|
|
86
|
-
if (path === rootRouteId) {
|
|
87
|
-
path = "/";
|
|
88
|
-
}
|
|
89
|
-
if (id !== rootRouteId) {
|
|
90
|
-
id = joinPaths(["/", id]);
|
|
91
|
-
}
|
|
92
|
-
const fullPath = id === rootRouteId ? "/" : joinPaths([this.parentRoute.fullPath, path]);
|
|
93
|
-
this._path = path;
|
|
94
|
-
this._id = id;
|
|
95
|
-
this._fullPath = fullPath;
|
|
96
|
-
this._to = fullPath;
|
|
97
|
-
this._ssr = (options2 == null ? void 0 : options2.ssr) ?? opts.defaultSsr ?? true;
|
|
98
|
-
};
|
|
99
|
-
this.addChildren = (children) => {
|
|
100
|
-
return this._addFileChildren(children);
|
|
101
|
-
};
|
|
102
|
-
this._addFileChildren = (children) => {
|
|
103
|
-
if (Array.isArray(children)) {
|
|
104
|
-
this.children = children;
|
|
105
|
-
}
|
|
106
|
-
if (typeof children === "object" && children !== null) {
|
|
107
|
-
this.children = Object.values(children);
|
|
108
|
-
}
|
|
109
|
-
return this;
|
|
110
|
-
};
|
|
111
|
-
this._addFileTypes = () => {
|
|
112
|
-
return this;
|
|
113
|
-
};
|
|
114
|
-
this.updateLoader = (options2) => {
|
|
115
|
-
Object.assign(this.options, options2);
|
|
116
|
-
return this;
|
|
117
|
-
};
|
|
118
|
-
this.update = (options2) => {
|
|
119
|
-
Object.assign(this.options, options2);
|
|
120
|
-
return this;
|
|
121
|
-
};
|
|
122
|
-
this.lazy = (lazyFn) => {
|
|
123
|
-
this.lazyFn = lazyFn;
|
|
124
|
-
return this;
|
|
125
|
-
};
|
|
62
|
+
super(options);
|
|
126
63
|
this.useMatch = (opts) => {
|
|
127
64
|
return useMatch({
|
|
128
65
|
select: opts == null ? void 0 : opts.select,
|
|
@@ -157,27 +94,6 @@ class Route {
|
|
|
157
94
|
this.useNavigate = () => {
|
|
158
95
|
return useNavigate({ from: this.fullPath });
|
|
159
96
|
};
|
|
160
|
-
this.options = options || {};
|
|
161
|
-
this.isRoot = !(options == null ? void 0 : options.getParentRoute);
|
|
162
|
-
invariant(
|
|
163
|
-
!((options == null ? void 0 : options.id) && (options == null ? void 0 : options.path)),
|
|
164
|
-
`Route cannot have both an 'id' and a 'path' option.`
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
get to() {
|
|
168
|
-
return this._to;
|
|
169
|
-
}
|
|
170
|
-
get id() {
|
|
171
|
-
return this._id;
|
|
172
|
-
}
|
|
173
|
-
get path() {
|
|
174
|
-
return this._path;
|
|
175
|
-
}
|
|
176
|
-
get fullPath() {
|
|
177
|
-
return this._fullPath;
|
|
178
|
-
}
|
|
179
|
-
get ssr() {
|
|
180
|
-
return this._ssr;
|
|
181
97
|
}
|
|
182
98
|
}
|
|
183
99
|
function createRoute(options) {
|
|
@@ -189,17 +105,48 @@ function createRootRouteWithContext() {
|
|
|
189
105
|
};
|
|
190
106
|
}
|
|
191
107
|
const rootRouteWithContext = createRootRouteWithContext;
|
|
192
|
-
class RootRoute extends
|
|
108
|
+
class RootRoute extends BaseRootRoute {
|
|
193
109
|
/**
|
|
194
110
|
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
195
111
|
*/
|
|
196
112
|
constructor(options) {
|
|
197
113
|
super(options);
|
|
114
|
+
this.useMatch = (opts) => {
|
|
115
|
+
return useMatch({
|
|
116
|
+
select: opts == null ? void 0 : opts.select,
|
|
117
|
+
from: this.id
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
this.useRouteContext = (opts) => {
|
|
121
|
+
return useMatch({
|
|
122
|
+
...opts,
|
|
123
|
+
from: this.id,
|
|
124
|
+
select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
this.useSearch = (opts) => {
|
|
128
|
+
return useSearch({
|
|
129
|
+
select: opts == null ? void 0 : opts.select,
|
|
130
|
+
from: this.id
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
this.useParams = (opts) => {
|
|
134
|
+
return useParams({
|
|
135
|
+
select: opts == null ? void 0 : opts.select,
|
|
136
|
+
from: this.id
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
this.useLoaderDeps = (opts) => {
|
|
140
|
+
return useLoaderDeps({ ...opts, from: this.id });
|
|
141
|
+
};
|
|
142
|
+
this.useLoaderData = (opts) => {
|
|
143
|
+
return useLoaderData({ ...opts, from: this.id });
|
|
144
|
+
};
|
|
145
|
+
this.useNavigate = () => {
|
|
146
|
+
return useNavigate({ from: this.fullPath });
|
|
147
|
+
};
|
|
198
148
|
}
|
|
199
149
|
}
|
|
200
|
-
function createRootRoute(options) {
|
|
201
|
-
return new RootRoute(options);
|
|
202
|
-
}
|
|
203
150
|
function createRouteMask(opts) {
|
|
204
151
|
return opts;
|
|
205
152
|
}
|
|
@@ -211,6 +158,9 @@ class NotFoundRoute extends Route {
|
|
|
211
158
|
});
|
|
212
159
|
}
|
|
213
160
|
}
|
|
161
|
+
function createRootRoute(options) {
|
|
162
|
+
return new RootRoute(options);
|
|
163
|
+
}
|
|
214
164
|
export {
|
|
215
165
|
NotFoundRoute,
|
|
216
166
|
RootRoute,
|
package/dist/esm/route.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport {\n joinPaths,\n notFound,\n rootRouteId,\n trimPathLeft,\n} from '@tanstack/router-core'\nimport { useLoaderData } from './useLoaderData'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { useNavigate } from './useNavigate'\nimport { useMatch } from './useMatch'\nimport { useRouter } from './useRouter'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n LazyRoute as CoreLazyRoute,\n Route as CoreRoute,\n ErrorComponentProps,\n NotFoundError,\n NotFoundRouteProps,\n RegisteredRouter,\n ResolveFullPath,\n ResolveId,\n ResolveParams,\n RootRouteId,\n RootRouteOptions,\n RouteAddChildrenFn,\n RouteAddFileChildrenFn,\n RouteAddFileTypesFn,\n RouteConstraints,\n RouteIds,\n RouteLazyFn,\n RouteLoaderFn,\n RouteMask,\n RouteOptions,\n RoutePathOptionsIntersection,\n RouteTypes,\n RouteTypesById,\n Router,\n ToMaskOptions,\n TrimPathRight,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseSearchRoute } from './useSearch'\nimport type * as Solid from 'solid-js'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\ndeclare module '@tanstack/router-core' {\n export interface UpdatableRouteOptionsExtensions {\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n }\n\n export interface RouteExtensions<\n TId extends string,\n TFullPath extends string,\n > {\n useMatch: UseMatchRoute<TId>\n useRouteContext: UseRouteContextRoute<TId>\n useSearch: UseSearchRoute<TId>\n useParams: UseParamsRoute<TId>\n useLoaderDeps: UseLoaderDepsRoute<TId>\n useLoaderData: UseLoaderDataRoute<TId>\n useNavigate: () => UseNavigateResult<TFullPath>\n }\n}\n\nexport function getRouteApi<\n const TId,\n TRouter extends AnyRouter = RegisteredRouter,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return new RouteApi<TId, TRouter>({ id })\n}\n\nexport class RouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {\n id: TId\n\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts) => {\n return useMatch({\n from: this.id as any,\n select: (d) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<\n RouteTypesById<TRouter, TId>['fullPath']\n > => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.id as string].fullPath })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport class Route<\n in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n in out TPath extends RouteConstraints['TPath'] = '/',\n in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n in out TCustomId extends RouteConstraints['TCustomId'] = string,\n in out TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> implements\n CoreRoute<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n{\n isRoot: TParentRoute extends AnyRoute ? true : false\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n\n // The following properties are set up in this.init()\n parentRoute!: TParentRoute\n private _id!: TId\n private _path!: TPath\n private _fullPath!: TFullPath\n private _to!: TrimPathRight<TFullPath>\n private _ssr!: boolean\n\n public get to() {\n /* invariant(\n this._to,\n `trying to access property 'to' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._to\n }\n\n public get id() {\n /* invariant(\n this._id,\n `trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._id\n }\n\n public get path() {\n /* invariant(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.isRoot || this._id || this._path,\n `trying to access property 'path' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._path\n }\n\n public get fullPath() {\n /* invariant(\n this._fullPath,\n `trying to access property 'fullPath' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._fullPath\n }\n\n public get ssr() {\n return this._ssr\n }\n\n // Optional\n children?: TChildren\n originalIndex?: number\n rank!: number\n lazyFn?: () => Promise<CoreLazyRoute>\n _lazyPromise?: Promise<void>\n _componentsPromise?: Promise<Array<void>>\n\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) {\n this.options = (options as any) || {}\n\n this.isRoot = !options?.getParentRoute as any\n invariant(\n !((options as any)?.id && (options as any)?.path),\n `Route cannot have both an 'id' and a 'path' option.`,\n )\n }\n\n types!: RouteTypes<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n\n init = (opts: { originalIndex: number; defaultSsr?: boolean }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\n this.parentRoute = this.options.getParentRoute?.()\n\n if (isRoot) {\n this._path = rootRouteId as TPath\n } else {\n invariant(\n this.parentRoute,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this._path = path as TPath\n this._id = id as TId\n // this.customId = customId as TCustomId\n this._fullPath = fullPath as TFullPath\n this._to = fullPath as TrimPathRight<TFullPath>\n this._ssr = options?.ssr ?? opts.defaultSsr ?? true\n }\n\n addChildren: RouteAddChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n return this._addFileChildren(children) as any\n }\n\n _addFileChildren: RouteAddFileChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n if (Array.isArray(children)) {\n this.children = children as TChildren\n }\n\n if (typeof children === 'object' && children !== null) {\n this.children = Object.values(children) as TChildren\n }\n\n return this as any\n }\n\n _addFileTypes: RouteAddFileTypesFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n > = () => {\n return this as any\n }\n\n updateLoader = <TNewLoaderFn>(options: {\n loader: Constrain<\n TNewLoaderFn,\n RouteLoaderFn<\n TParentRoute,\n TCustomId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n }) => {\n Object.assign(this.options, options)\n return this as unknown as Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TNewLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy: RouteLazyFn<this> = (lazyFn) => {\n this.lazyFn = lazyFn\n return this\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts?) => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.fullPath })\n }\n}\n\nexport function createRoute<\n TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n TPath extends RouteConstraints['TPath'] = '/',\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints['TCustomId'] = string,\n TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n>(\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n): CoreRoute<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown\n> {\n return new Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n >(options)\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>\n\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n >(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) => {\n return createRootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >(options as any)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchValidator, // TSearchValidator\n {}, // TParams\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren, // TChildren\n TFileRouteTypes\n> {\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) {\n super(options as any)\n }\n}\n\nexport function createRootRoute<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n>(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n) {\n return new RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >(options)\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends string,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<Router<TRouteTree, 'never', false>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\nexport type SolidNode = Solid.JSX.Element\n\nexport type SyncRouteComponent<TProps> = (props: TProps) => Solid.JSX.Element\n\nexport type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>\n\nexport type ErrorRouteComponent = RouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>\n\nexport class NotFoundRoute<\n TParentRoute extends AnyRootRoute,\n TRouterContext = AnyContext,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchValidator,\n {},\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n string,\n string,\n TSearchValidator,\n {},\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'path'\n | 'id'\n | 'params'\n >,\n ) {\n super({\n ...(options as any),\n id: '404',\n })\n }\n}\n"],"names":["options"],"mappings":";;;;;;;;;AA+EO,SAAS,YAGd,IAA2D;AAC3D,SAAO,IAAI,SAAuB,EAAE,IAAI;AAC1C;AAEO,MAAM,SAA4D;AAAA;AAAA;AAAA;AAAA,EAMvE,YAAY,EAAE,MAAmB;AAIjC,SAAA,WAA+B,CAAC,SAAS;AACvC,aAAO,SAAS;AAAA,QACd,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SA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KpB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGd,IAAW,MAAM;AACf,WAAO,KAAK;AAAA,EAAA;AA4RhB;AAEO,SAAS,YAqBd,SA6BA;AACO,SAAA,IAAI,MAcT,OAAO;AACX;AAIO,SAAS,6BAAwD;AACtE,SAAO,CAOL,YAQG;AACH,WAAO,gBAOL,OAAc;AAAA,EAClB;AACF;AAKO,MAAM,uBAAuB;AAE7B,MAAM,kBASH,MAeR;AAAA;AAAA;AAAA;AAAA,EAIA,YACE,SAQA;AACA,UAAM,OAAc;AAAA,EAAA;AAExB;AAEO,SAAS,gBAQd,SAQA;AACO,SAAA,IAAI,UAOT,OAAO;AACX;AAEO,SAAS,gBAKd,MAGuB;AAChB,SAAA;AACT;AAgBO,MAAM,sBASH,MAcR;AAAA,EACA,YACE,SAsBA;AACM,UAAA;AAAA,MACJ,GAAI;AAAA,MACJ,IAAI;AAAA,IAAA,CACL;AAAA,EAAA;AAEL;"}
|
|
1
|
+
{"version":3,"file":"route.js","sources":["../../src/route.ts"],"sourcesContent":["import {\n BaseRootRoute,\n BaseRoute,\n BaseRouteApi,\n notFound,\n} from '@tanstack/router-core'\nimport { useLoaderData } from './useLoaderData'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { useNavigate } from './useNavigate'\nimport { useMatch } from './useMatch'\nimport { useRouter } from './useRouter'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n ConstrainLiteral,\n ErrorComponentProps,\n NotFoundError,\n NotFoundRouteProps,\n RegisteredRouter,\n ResolveFullPath,\n ResolveId,\n ResolveParams,\n RootRouteId,\n RootRouteOptions,\n RouteConstraints,\n RouteIds,\n RouteMask,\n RouteOptions,\n RouteTypesById,\n RouterCore,\n ToMaskOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseSearchRoute } from './useSearch'\nimport type * as Solid from 'solid-js'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\ndeclare module '@tanstack/router-core' {\n export interface UpdatableRouteOptionsExtensions {\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n }\n\n export interface RouteExtensions<\n TId extends string,\n TFullPath extends string,\n > {\n useMatch: UseMatchRoute<TId>\n useRouteContext: UseRouteContextRoute<TId>\n useSearch: UseSearchRoute<TId>\n useParams: UseParamsRoute<TId>\n useLoaderDeps: UseLoaderDepsRoute<TId>\n useLoaderData: UseLoaderDataRoute<TId>\n useNavigate: () => UseNavigateResult<TFullPath>\n }\n}\n\nexport function getRouteApi<\n const TId,\n TRouter extends AnyRouter = RegisteredRouter,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return new RouteApi<TId, TRouter>({ id })\n}\n\nexport class RouteApi<\n TId,\n TRouter extends AnyRouter = RegisteredRouter,\n> extends BaseRouteApi<TId, TRouter> {\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n super({ id })\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts) => {\n return useMatch({\n from: this.id as any,\n select: (d) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<\n RouteTypesById<TRouter, TId>['fullPath']\n > => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.id as string].fullPath })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport class Route<\n in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n in out TPath extends RouteConstraints['TPath'] = '/',\n in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n in out TCustomId extends RouteConstraints['TCustomId'] = string,\n in out TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends BaseRoute<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n> {\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) {\n super(options)\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts?) => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.fullPath })\n }\n}\n\nexport function createRoute<\n TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n TPath extends RouteConstraints['TPath'] = '/',\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints['TCustomId'] = string,\n TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n>(\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown\n> {\n return new Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown\n >(options)\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>\n\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n >(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) => {\n return createRootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >(options as any)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends BaseRootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n> {\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) {\n super(options)\n }\n\n useMatch: UseMatchRoute<RootRouteId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<RootRouteId> = (opts) => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<RootRouteId> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<RootRouteId> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<RootRouteId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<RootRouteId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<'/'> => {\n return useNavigate({ from: this.fullPath })\n }\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends string,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<RouterCore<TRouteTree, 'never', false>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\nexport type SolidNode = Solid.JSX.Element\n\nexport type SyncRouteComponent<TProps> = (props: TProps) => Solid.JSX.Element\n\nexport type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>\n\nexport type ErrorRouteComponent = RouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>\n\nexport class NotFoundRoute<\n TParentRoute extends AnyRootRoute,\n TRouterContext = AnyContext,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchValidator,\n {},\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n string,\n string,\n TSearchValidator,\n {},\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'path'\n | 'id'\n | 'params'\n >,\n ) {\n super({\n ...(options as any),\n id: '404',\n })\n }\n}\n\nexport function createRootRoute<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n>(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n): RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n unknown,\n unknown\n> {\n return new RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >(options)\n}\n"],"names":[],"mappings":";;;;;;;;AAkEO,SAAS,YAGd,IAA2D;AAC3D,SAAO,IAAI,SAAuB,EAAE,IAAI;AAC1C;AAEO,MAAM,iBAGH,aAA2B;AAAA;AAAA;AAAA;AAAA,EAInC,YAAY,EAAE,MAAmB;AACzB,UAAA,EAAE,IAAI;AAGd,SAAA,WAA+B,CAAC,SAAS;AACvC,aAAO,SAAS;AAAA,QACd,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SAAA,kBAA6C,CAAC,SAAS;AACrD,aAAO,SAAS;AAAA,QACd,MAAM,KAAK;AAAA,QACX,QAAQ,CAAC,OAAO,6BAAM,UAAS,KAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAC3D;AAAA,IACH;AAEA,SAAA,YAAiC,CAAC,SAAS;AACzC,aAAO,UAAU;AAAA,QACf,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SAAA,YAAiC,CAAC,SAAS;AACzC,aAAO,UAAU;AAAA,QACf,QAAQ,6BAAM;A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M,KAAK,IAAW;AAAA,IACxD;AAEA,SAAA,cAAc,MAA8B;AAC1C,aAAO,YAAY,EAAE,MAAM,KAAK,UAAU;AAAA,IAC5C;AAAA,EAAA;AACF;AAEO,SAAS,gBAKd,MAGuB;AAChB,SAAA;AACT;AAgBO,MAAM,sBASH,MAcR;AAAA,EACA,YACE,SAsBA;AACM,UAAA;AAAA,MACJ,GAAI;AAAA,MACJ,IAAI;AAAA,IAAA,CACL;AAAA,EAAA;AAEL;AAEO,SAAS,gBAQd,SAiBA;AACO,SAAA,IAAI,UAOT,OAAO;AACX;"}
|
package/dist/esm/router.d.ts
CHANGED
|
@@ -1,64 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RouterCore, AnyRoute, CreateRouterFn, RouterConstructorOptions, TrailingSlashOption } from '@tanstack/router-core';
|
|
2
2
|
import { RouterHistory } from '@tanstack/history';
|
|
3
|
-
import { AnyRedirect, AnyRoute, AnyRouteMatch, AnyRouter, BuildLocationFn, BuildNextOptions, ClearCacheFn, CommitLocationFn, CommitLocationOptions, ControlledPromise, Router as CoreRouter, EmitFn, FullSearchSchema, GetMatchFn, GetMatchRoutesFn, InjectedHtmlEntry, InvalidateFn, LoadFn, MakeRouteMatch, Manifest, MatchRouteFn, MatchRoutesFn, NavigateFn, NotFoundError, ParseLocationFn, ParsedLocation, PickAsRequired, PreloadRouteFn, ResolvedRedirect, RouterConstructorOptions, RouterEvent, RouterListener, RouterOptions, RouterState, RoutesById, RoutesByPath, StartSerializer, StartTransitionFn, SubscribeFn, TrailingSlashOption, UpdateFn, UpdateMatchFn, ViewTransitionOptions } from '@tanstack/router-core';
|
|
4
3
|
import { ErrorRouteComponent, NotFoundRouteComponent, RouteComponent } from './route.js';
|
|
5
|
-
import
|
|
4
|
+
import { JSX } from 'solid-js';
|
|
6
5
|
declare module '@tanstack/router-core' {
|
|
7
6
|
interface RouterOptionsExtensions {
|
|
8
|
-
/**
|
|
9
|
-
* A component that will be used to wrap the entire router.
|
|
10
|
-
*
|
|
11
|
-
* This is useful for providing a context to the entire router.
|
|
12
|
-
*
|
|
13
|
-
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
|
|
14
|
-
*
|
|
15
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
|
|
16
|
-
*/
|
|
17
|
-
Wrap?: (props: {
|
|
18
|
-
children: any;
|
|
19
|
-
}) => Solid.JSX.Element;
|
|
20
|
-
/**
|
|
21
|
-
* A component that will be used to wrap the inner contents of the router.
|
|
22
|
-
*
|
|
23
|
-
* This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
|
|
24
|
-
*
|
|
25
|
-
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
|
|
26
|
-
*
|
|
27
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
|
|
28
|
-
*/
|
|
29
|
-
InnerWrap?: (props: {
|
|
30
|
-
children: any;
|
|
31
|
-
}) => Solid.JSX.Element;
|
|
32
7
|
/**
|
|
33
8
|
* The default `component` a route should use if no component is provided.
|
|
34
9
|
*
|
|
35
10
|
* @default Outlet
|
|
36
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/
|
|
11
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultcomponent-property)
|
|
37
12
|
*/
|
|
38
13
|
defaultComponent?: RouteComponent;
|
|
39
14
|
/**
|
|
40
15
|
* The default `errorComponent` a route should use if no error component is provided.
|
|
41
16
|
*
|
|
42
17
|
* @default ErrorComponent
|
|
43
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/
|
|
44
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/
|
|
18
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaulterrorcomponent-property)
|
|
19
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
|
|
45
20
|
*/
|
|
46
21
|
defaultErrorComponent?: ErrorRouteComponent;
|
|
47
22
|
/**
|
|
48
23
|
* The default `pendingComponent` a route should use if no pending component is provided.
|
|
49
24
|
*
|
|
50
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/
|
|
51
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/
|
|
25
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultpendingcomponent-property)
|
|
26
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#showing-a-pending-component)
|
|
52
27
|
*/
|
|
53
28
|
defaultPendingComponent?: RouteComponent;
|
|
54
29
|
/**
|
|
55
30
|
* The default `notFoundComponent` a route should use if no notFound component is provided.
|
|
56
31
|
*
|
|
57
32
|
* @default NotFound
|
|
58
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/
|
|
59
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/
|
|
33
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
|
|
34
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/not-found-errors#default-router-wide-not-found-handling)
|
|
60
35
|
*/
|
|
61
36
|
defaultNotFoundComponent?: NotFoundRouteComponent;
|
|
37
|
+
/**
|
|
38
|
+
* A component that will be used to wrap the entire router.
|
|
39
|
+
*
|
|
40
|
+
* This is useful for providing a context to the entire router.
|
|
41
|
+
*
|
|
42
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#wrap-property)
|
|
43
|
+
*/
|
|
44
|
+
Wrap?: (props: {
|
|
45
|
+
children: any;
|
|
46
|
+
}) => JSX.Element;
|
|
47
|
+
/**
|
|
48
|
+
* A component that will be used to wrap the inner contents of the router.
|
|
49
|
+
*
|
|
50
|
+
* This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
|
|
51
|
+
*
|
|
52
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#innerwrap-property)
|
|
53
|
+
*/
|
|
54
|
+
InnerWrap?: (props: {
|
|
55
|
+
children: any;
|
|
56
|
+
}) => JSX.Element;
|
|
62
57
|
/**
|
|
63
58
|
* The default `onCatch` handler for errors caught by the Router ErrorBoundary
|
|
64
59
|
*
|
|
@@ -68,109 +63,7 @@ declare module '@tanstack/router-core' {
|
|
|
68
63
|
defaultOnCatch?: (error: Error) => void;
|
|
69
64
|
}
|
|
70
65
|
}
|
|
71
|
-
export declare const
|
|
72
|
-
export declare
|
|
73
|
-
|
|
74
|
-
tempLocationKey: string | undefined;
|
|
75
|
-
resetNextScroll: boolean;
|
|
76
|
-
shouldViewTransition?: boolean | ViewTransitionOptions;
|
|
77
|
-
isViewTransitionTypesSupported?: boolean;
|
|
78
|
-
subscribers: Set<RouterListener<RouterEvent>>;
|
|
79
|
-
viewTransitionPromise?: ControlledPromise<true>;
|
|
80
|
-
isScrollRestoring: boolean;
|
|
81
|
-
isScrollRestorationSetup: boolean;
|
|
82
|
-
__store: Store<RouterState<TRouteTree>>;
|
|
83
|
-
options: PickAsRequired<RouterOptions<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated>, 'stringifySearch' | 'parseSearch' | 'context'>;
|
|
84
|
-
history: TRouterHistory;
|
|
85
|
-
latestLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
86
|
-
basepath: string;
|
|
87
|
-
routeTree: TRouteTree;
|
|
88
|
-
routesById: RoutesById<TRouteTree>;
|
|
89
|
-
routesByPath: RoutesByPath<TRouteTree>;
|
|
90
|
-
flatRoutes: Array<AnyRoute>;
|
|
91
|
-
isServer: boolean;
|
|
92
|
-
pathParamsDecodeCharMap?: Map<string, string>;
|
|
93
|
-
/**
|
|
94
|
-
* @deprecated Use the `createRouter` function instead
|
|
95
|
-
*/
|
|
96
|
-
constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated>);
|
|
97
|
-
startTransition: StartTransitionFn;
|
|
98
|
-
update: UpdateFn<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated>;
|
|
99
|
-
get state(): RouterState<TRouteTree, import('@tanstack/router-core').RouteMatch<any, any, any, any, any, any, any>>;
|
|
100
|
-
buildRouteTree: () => void;
|
|
101
|
-
subscribe: SubscribeFn;
|
|
102
|
-
emit: EmitFn;
|
|
103
|
-
parseLocation: ParseLocationFn<TRouteTree>;
|
|
104
|
-
resolvePathWithBase: (from: string, path: string) => string;
|
|
105
|
-
get looseRoutesById(): Record<string, AnyRoute>;
|
|
106
|
-
/**
|
|
107
|
-
@deprecated use the following signature instead
|
|
108
|
-
```ts
|
|
109
|
-
matchRoutes (
|
|
110
|
-
next: ParsedLocation,
|
|
111
|
-
opts?: { preload?: boolean; throwOnError?: boolean },
|
|
112
|
-
): Array<AnyRouteMatch>;
|
|
113
|
-
```
|
|
114
|
-
*/
|
|
115
|
-
matchRoutes: MatchRoutesFn;
|
|
116
|
-
private matchRoutesInternal;
|
|
117
|
-
getMatchedRoutes: GetMatchRoutesFn;
|
|
118
|
-
cancelMatch: (id: string) => void;
|
|
119
|
-
cancelMatches: () => void;
|
|
120
|
-
buildLocation: BuildLocationFn;
|
|
121
|
-
commitLocationPromise: undefined | ControlledPromise<void>;
|
|
122
|
-
commitLocation: CommitLocationFn;
|
|
123
|
-
buildAndCommitLocation: ({ replace, resetScroll, hashScrollIntoView, viewTransition, ignoreBlocker, href, ...rest }?: BuildNextOptions & CommitLocationOptions) => Promise<void>;
|
|
124
|
-
navigate: NavigateFn;
|
|
125
|
-
latestLoadPromise: undefined | Promise<void>;
|
|
126
|
-
load: LoadFn;
|
|
127
|
-
startViewTransition: (fn: () => Promise<void>) => void;
|
|
128
|
-
updateMatch: UpdateMatchFn;
|
|
129
|
-
getMatch: GetMatchFn;
|
|
130
|
-
loadMatches: ({ location, matches, preload: allPreload, onReady, updateMatch, sync, }: {
|
|
131
|
-
location: ParsedLocation;
|
|
132
|
-
matches: Array<AnyRouteMatch>;
|
|
133
|
-
preload?: boolean;
|
|
134
|
-
onReady?: () => Promise<void>;
|
|
135
|
-
updateMatch?: (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => void;
|
|
136
|
-
getMatch?: (matchId: string) => AnyRouteMatch | undefined;
|
|
137
|
-
sync?: boolean;
|
|
138
|
-
}) => Promise<Array<MakeRouteMatch>>;
|
|
139
|
-
invalidate: InvalidateFn<this>;
|
|
140
|
-
resolveRedirect: (err: AnyRedirect) => ResolvedRedirect;
|
|
141
|
-
clearCache: ClearCacheFn<this>;
|
|
142
|
-
clearExpiredCache: () => void;
|
|
143
|
-
loadRouteChunk: (route: AnyRoute) => Promise<void[]>;
|
|
144
|
-
preloadRoute: PreloadRouteFn<TRouteTree, TTrailingSlashOption, false, TRouterHistory>;
|
|
145
|
-
matchRoute: MatchRouteFn<TRouteTree, TTrailingSlashOption, false, TRouterHistory>;
|
|
146
|
-
ssr?: {
|
|
147
|
-
manifest: Manifest | undefined;
|
|
148
|
-
serializer: StartSerializer;
|
|
149
|
-
};
|
|
150
|
-
serverSsr?: {
|
|
151
|
-
injectedHtml: Array<InjectedHtmlEntry>;
|
|
152
|
-
injectHtml: (getHtml: () => string | Promise<string>) => Promise<void>;
|
|
153
|
-
injectScript: (getScript: () => string | Promise<string>, opts?: {
|
|
154
|
-
logScript?: boolean;
|
|
155
|
-
}) => Promise<void>;
|
|
156
|
-
streamValue: (key: string, value: any) => void;
|
|
157
|
-
streamedKeys: Set<string>;
|
|
158
|
-
onMatchSettled: (opts: {
|
|
159
|
-
router: AnyRouter;
|
|
160
|
-
match: AnyRouteMatch;
|
|
161
|
-
}) => any;
|
|
162
|
-
};
|
|
163
|
-
clientSsr?: {
|
|
164
|
-
getStreamedValue: <T>(key: string) => T | undefined;
|
|
165
|
-
};
|
|
166
|
-
_handleNotFound: (matches: Array<AnyRouteMatch>, err: NotFoundError, { updateMatch, }?: {
|
|
167
|
-
updateMatch?: (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => void;
|
|
168
|
-
}) => void;
|
|
169
|
-
hasNotFoundMatch: () => boolean;
|
|
170
|
-
}
|
|
171
|
-
export declare function lazyFn<T extends Record<string, (...args: Array<any>) => any>, TKey extends keyof T = 'default'>(fn: () => Promise<T>, key?: TKey): (...args: Parameters<T[TKey]>) => Promise<Awaited<ReturnType<T[TKey]>>>;
|
|
172
|
-
export declare class SearchParamError extends Error {
|
|
173
|
-
}
|
|
174
|
-
export declare class PathParamError extends Error {
|
|
66
|
+
export declare const createRouter: CreateRouterFn;
|
|
67
|
+
export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption = 'never', in out TDefaultStructuralSharingOption extends boolean = false, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>> extends RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated> {
|
|
68
|
+
constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>);
|
|
175
69
|
}
|
|
176
|
-
export declare function getInitialRouterState(location: ParsedLocation): RouterState<any>;
|