@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.
@@ -1,5 +1,4 @@
1
- import invariant from 'tiny-invariant';
2
- import { joinPaths, notFound, rootRouteId, trimPathLeft, } from '@tanstack/router-core';
1
+ import { BaseRootRoute, BaseRoute, BaseRouteApi, notFound, } from '@tanstack/router-core';
3
2
  import { useLoaderData } from './useLoaderData';
4
3
  import { useLoaderDeps } from './useLoaderDeps';
5
4
  import { useParams } from './useParams';
@@ -10,11 +9,12 @@ import { useRouter } from './useRouter';
10
9
  export function getRouteApi(id) {
11
10
  return new RouteApi({ id });
12
11
  }
13
- export class RouteApi {
12
+ export 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?.select,
@@ -52,111 +52,14 @@ export 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
- export class Route {
59
- get to() {
60
- /* invariant(
61
- this._to,
62
- `trying to access property 'to' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,
63
- )*/
64
- return this._to;
65
- }
66
- get id() {
67
- /* invariant(
68
- this._id,
69
- `trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,
70
- )*/
71
- return this._id;
72
- }
73
- get path() {
74
- /* invariant(
75
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
76
- this.isRoot || this._id || this._path,
77
- `trying to access property 'path' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,
78
- )*/
79
- return this._path;
80
- }
81
- get fullPath() {
82
- /* invariant(
83
- this._fullPath,
84
- `trying to access property 'fullPath' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,
85
- )*/
86
- return this._fullPath;
87
- }
88
- get ssr() {
89
- return this._ssr;
90
- }
57
+ export class Route extends BaseRoute {
91
58
  /**
92
59
  * @deprecated Use the `createRoute` function instead.
93
60
  */
94
61
  constructor(options) {
95
- this.init = (opts) => {
96
- this.originalIndex = opts.originalIndex;
97
- const options = this.options;
98
- const isRoot = !options?.path && !options?.id;
99
- this.parentRoute = this.options.getParentRoute?.();
100
- if (isRoot) {
101
- this._path = rootRouteId;
102
- }
103
- else {
104
- invariant(this.parentRoute, `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);
105
- }
106
- let path = isRoot ? rootRouteId : options.path;
107
- // If the path is anything other than an index path, trim it up
108
- if (path && path !== '/') {
109
- path = trimPathLeft(path);
110
- }
111
- const customId = options?.id || path;
112
- // Strip the parentId prefix from the first level of children
113
- let id = isRoot
114
- ? rootRouteId
115
- : joinPaths([
116
- this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,
117
- customId,
118
- ]);
119
- if (path === rootRouteId) {
120
- path = '/';
121
- }
122
- if (id !== rootRouteId) {
123
- id = joinPaths(['/', id]);
124
- }
125
- const fullPath = id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path]);
126
- this._path = path;
127
- this._id = id;
128
- // this.customId = customId as TCustomId
129
- this._fullPath = fullPath;
130
- this._to = fullPath;
131
- this._ssr = options?.ssr ?? opts.defaultSsr ?? true;
132
- };
133
- this.addChildren = (children) => {
134
- return this._addFileChildren(children);
135
- };
136
- this._addFileChildren = (children) => {
137
- if (Array.isArray(children)) {
138
- this.children = children;
139
- }
140
- if (typeof children === 'object' && children !== null) {
141
- this.children = Object.values(children);
142
- }
143
- return this;
144
- };
145
- this._addFileTypes = () => {
146
- return this;
147
- };
148
- this.updateLoader = (options) => {
149
- Object.assign(this.options, options);
150
- return this;
151
- };
152
- this.update = (options) => {
153
- Object.assign(this.options, options);
154
- return this;
155
- };
156
- this.lazy = (lazyFn) => {
157
- this.lazyFn = lazyFn;
158
- return this;
159
- };
62
+ super(options);
160
63
  this.useMatch = (opts) => {
161
64
  return useMatch({
162
65
  select: opts?.select,
@@ -191,9 +94,6 @@ export class Route {
191
94
  this.useNavigate = () => {
192
95
  return useNavigate({ from: this.fullPath });
193
96
  };
194
- this.options = options || {};
195
- this.isRoot = !options?.getParentRoute;
196
- invariant(!(options?.id && options?.path), `Route cannot have both an 'id' and a 'path' option.`);
197
97
  }
198
98
  }
199
99
  export function createRoute(options) {
@@ -208,17 +108,48 @@ export function createRootRouteWithContext() {
208
108
  * @deprecated Use the `createRootRouteWithContext` function instead.
209
109
  */
210
110
  export const rootRouteWithContext = createRootRouteWithContext;
211
- export class RootRoute extends Route {
111
+ export class RootRoute extends BaseRootRoute {
212
112
  /**
213
113
  * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
214
114
  */
215
115
  constructor(options) {
216
116
  super(options);
117
+ this.useMatch = (opts) => {
118
+ return useMatch({
119
+ select: opts?.select,
120
+ from: this.id,
121
+ });
122
+ };
123
+ this.useRouteContext = (opts) => {
124
+ return useMatch({
125
+ ...opts,
126
+ from: this.id,
127
+ select: (d) => (opts?.select ? opts.select(d.context) : d.context),
128
+ });
129
+ };
130
+ this.useSearch = (opts) => {
131
+ return useSearch({
132
+ select: opts?.select,
133
+ from: this.id,
134
+ });
135
+ };
136
+ this.useParams = (opts) => {
137
+ return useParams({
138
+ select: opts?.select,
139
+ from: this.id,
140
+ });
141
+ };
142
+ this.useLoaderDeps = (opts) => {
143
+ return useLoaderDeps({ ...opts, from: this.id });
144
+ };
145
+ this.useLoaderData = (opts) => {
146
+ return useLoaderData({ ...opts, from: this.id });
147
+ };
148
+ this.useNavigate = () => {
149
+ return useNavigate({ from: this.fullPath });
150
+ };
217
151
  }
218
152
  }
219
- export function createRootRoute(options) {
220
- return new RootRoute(options);
221
- }
222
153
  export function createRouteMask(opts) {
223
154
  return opts;
224
155
  }
@@ -230,4 +161,7 @@ export class NotFoundRoute extends Route {
230
161
  });
231
162
  }
232
163
  }
164
+ export function createRootRoute(options) {
165
+ return new RootRoute(options);
166
+ }
233
167
  //# sourceMappingURL=route.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/route.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,GACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAkEvC,MAAM,UAAU,WAAW,CAGzB,EAAyD;IACzD,OAAO,IAAI,QAAQ,CAAe,EAAE,EAAE,EAAE,CAAC,CAAA;AAC3C,CAAC;AAED,MAAM,OAAO,QAAQ;IAGnB;;OAEG;IACH,YAAY,EAAE,EAAE,EAAe;QAI/B,aAAQ,GAAuB,CAAC,IAAI,EAAE,EAAE;YACtC,OAAO,QAAQ,CAAC;gBACd,MAAM,EAAE,IAAI,EAAE,MAAM;gBACpB,IAAI,EAAE,IAAI,CAAC,EAAE;aACP,CAAQ,CAAA;QAClB,CAAC,CAAA;QAED,oBAAe,GAA8B,CAAC,IAAI,EAAE,EAAE;YACpD,OAAO,QAAQ,CAAC;gBACd,IAAI,EAAE,IAAI,CAAC,EAAS;gBACpB,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAA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,GAAI,OAAe;YACnB,EAAE,EAAE,KAAK;SACV,CAAC,CAAA;IACJ,CAAC;CACF;AAED,MAAM,UAAU,eAAe,CAQ7B,OAOC;IAWD,OAAO,IAAI,SAAS,CAOlB,OAAO,CAAC,CAAA;AACZ,CAAC"}
@@ -1,64 +1,60 @@
1
- import { Store } from '@tanstack/solid-store';
2
- import type * as Solid from 'solid-js';
1
+ import { RouterCore } from '@tanstack/router-core';
3
2
  import type { RouterHistory } from '@tanstack/history';
4
- import type { 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';
3
+ import type { AnyRoute, CreateRouterFn, RouterConstructorOptions, TrailingSlashOption } from '@tanstack/router-core';
5
4
  import type { ErrorRouteComponent, NotFoundRouteComponent, RouteComponent } from './route';
5
+ import type { JSX } from 'solid-js';
6
6
  declare module '@tanstack/router-core' {
7
7
  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
8
  /**
33
9
  * The default `component` a route should use if no component is provided.
34
10
  *
35
11
  * @default Outlet
36
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
12
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultcomponent-property)
37
13
  */
38
14
  defaultComponent?: RouteComponent;
39
15
  /**
40
16
  * The default `errorComponent` a route should use if no error component is provided.
41
17
  *
42
18
  * @default ErrorComponent
43
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
44
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
19
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaulterrorcomponent-property)
20
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
45
21
  */
46
22
  defaultErrorComponent?: ErrorRouteComponent;
47
23
  /**
48
24
  * The default `pendingComponent` a route should use if no pending component is provided.
49
25
  *
50
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
51
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
26
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultpendingcomponent-property)
27
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#showing-a-pending-component)
52
28
  */
53
29
  defaultPendingComponent?: RouteComponent;
54
30
  /**
55
31
  * The default `notFoundComponent` a route should use if no notFound component is provided.
56
32
  *
57
33
  * @default NotFound
58
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
59
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
34
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
35
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/not-found-errors#default-router-wide-not-found-handling)
60
36
  */
61
37
  defaultNotFoundComponent?: NotFoundRouteComponent;
38
+ /**
39
+ * A component that will be used to wrap the entire router.
40
+ *
41
+ * This is useful for providing a context to the entire router.
42
+ *
43
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#wrap-property)
44
+ */
45
+ Wrap?: (props: {
46
+ children: any;
47
+ }) => JSX.Element;
48
+ /**
49
+ * A component that will be used to wrap the inner contents of the router.
50
+ *
51
+ * 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.
52
+ *
53
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#innerwrap-property)
54
+ */
55
+ InnerWrap?: (props: {
56
+ children: any;
57
+ }) => JSX.Element;
62
58
  /**
63
59
  * The default `onCatch` handler for errors caught by the Router ErrorBoundary
64
60
  *
@@ -68,109 +64,7 @@ declare module '@tanstack/router-core' {
68
64
  defaultOnCatch?: (error: Error) => void;
69
65
  }
70
66
  }
71
- export declare const componentTypes: readonly ["component", "errorComponent", "pendingComponent", "notFoundComponent"];
72
- export declare function createRouter<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>>(options: undefined extends number ? 'strictNullChecks must be enabled in tsconfig.json' : RouterConstructorOptions<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated>): CoreRouter<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated>;
73
- export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>> implements CoreRouter<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated> {
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 {
67
+ export declare const createRouter: CreateRouterFn;
68
+ 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> {
69
+ constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>);
175
70
  }
176
- export declare function getInitialRouterState(location: ParsedLocation): RouterState<any>;