@tanstack/solid-router 1.112.10 → 1.112.12
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/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +1 -8
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +4 -4
- package/dist/cjs/Transitioner.cjs +1 -1
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +4 -7
- package/dist/cjs/index.d.cts +3 -5
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +1 -2
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +1 -2
- package/dist/cjs/redirects.cjs.map +1 -1
- package/dist/cjs/redirects.d.cts +1 -2
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/renderRouteNotFound.d.cts +1 -2
- package/dist/cjs/route.cjs +15 -23
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +19 -50
- package/dist/cjs/router.cjs +25 -25
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +84 -454
- package/dist/cjs/routerContext.cjs.map +1 -1
- package/dist/cjs/routerContext.d.cts +2 -2
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.d.cts +1 -2
- package/dist/cjs/typePrimitives.d.cts +1 -2
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useBlocker.d.cts +2 -3
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderData.d.cts +1 -3
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.d.cts +1 -3
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useLocation.d.cts +1 -1
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useMatch.d.cts +1 -3
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +1 -2
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +1 -3
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouteContext.d.cts +1 -2
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouter.d.cts +1 -1
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useRouterState.d.cts +1 -1
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +1 -3
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +0 -9
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.d.ts +1 -8
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +4 -4
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/Transitioner.js +1 -1
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +4 -7
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +3 -5
- package/dist/esm/link.d.ts +1 -2
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/not-found.d.ts +1 -2
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/redirects.d.ts +1 -2
- package/dist/esm/redirects.js.map +1 -1
- package/dist/esm/renderRouteNotFound.d.ts +1 -2
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/route.d.ts +19 -50
- package/dist/esm/route.js +15 -23
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +84 -454
- package/dist/esm/router.js +25 -25
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +2 -2
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.d.ts +1 -2
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/typePrimitives.d.ts +1 -2
- package/dist/esm/useBlocker.d.ts +2 -3
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useLoaderData.d.ts +1 -3
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.d.ts +1 -3
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.d.ts +1 -1
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.d.ts +1 -3
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.d.ts +1 -2
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.d.ts +1 -3
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.d.ts +1 -2
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouter.d.ts +1 -1
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.d.ts +1 -1
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.d.ts +1 -3
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +0 -9
- package/dist/esm/utils.js.map +1 -1
- package/dist/source/Matches.d.ts +1 -8
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/RouterProvider.d.ts +4 -4
- package/dist/source/RouterProvider.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +1 -1
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/fileRoute.d.ts +4 -7
- package/dist/source/fileRoute.js.map +1 -1
- package/dist/source/index.d.ts +3 -5
- package/dist/source/index.jsx.map +1 -1
- package/dist/source/link.d.ts +1 -2
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/not-found.d.ts +1 -2
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/redirects.d.ts +1 -2
- package/dist/source/renderRouteNotFound.d.ts +1 -2
- package/dist/source/renderRouteNotFound.jsx.map +1 -1
- package/dist/source/route.d.ts +19 -50
- package/dist/source/route.js +15 -23
- package/dist/source/route.js.map +1 -1
- package/dist/source/router.d.ts +83 -454
- package/dist/source/router.js +33 -22
- package/dist/source/router.js.map +1 -1
- package/dist/source/routerContext.d.ts +2 -2
- package/dist/source/routerContext.jsx.map +1 -1
- package/dist/source/scroll-restoration.d.ts +1 -2
- package/dist/source/scroll-restoration.jsx.map +1 -1
- package/dist/source/typePrimitives.d.ts +1 -2
- package/dist/source/useBlocker.d.ts +2 -3
- package/dist/source/useBlocker.jsx.map +1 -1
- package/dist/source/useLoaderData.d.ts +1 -3
- package/dist/source/useLoaderData.jsx.map +1 -1
- package/dist/source/useLoaderDeps.d.ts +1 -3
- package/dist/source/useLoaderDeps.jsx.map +1 -1
- package/dist/source/useLocation.d.ts +1 -1
- package/dist/source/useLocation.jsx.map +1 -1
- package/dist/source/useMatch.d.ts +1 -3
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useNavigate.d.ts +1 -2
- package/dist/source/useNavigate.jsx.map +1 -1
- package/dist/source/useParams.d.ts +1 -3
- package/dist/source/useParams.jsx.map +1 -1
- package/dist/source/useRouteContext.d.ts +1 -2
- package/dist/source/useRouter.d.ts +1 -1
- package/dist/source/useRouterState.d.ts +1 -1
- package/dist/source/useRouterState.jsx.map +1 -1
- package/dist/source/useSearch.d.ts +1 -3
- package/dist/source/useSearch.jsx.map +1 -1
- package/dist/source/utils.d.ts +1 -10
- package/dist/source/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/Match.tsx +1 -1
- package/src/Matches.tsx +4 -8
- package/src/RouterProvider.tsx +4 -7
- package/src/Transitioner.tsx +1 -1
- package/src/fileRoute.ts +9 -25
- package/src/index.tsx +22 -28
- package/src/link.tsx +2 -1
- package/src/not-found.tsx +1 -2
- package/src/redirects.ts +1 -1
- package/src/renderRouteNotFound.tsx +1 -2
- package/src/route.ts +93 -222
- package/src/router.ts +154 -596
- package/src/routerContext.tsx +3 -3
- package/src/scroll-restoration.tsx +6 -2
- package/src/typePrimitives.ts +2 -1
- package/src/useBlocker.tsx +7 -3
- package/src/useLoaderData.tsx +3 -2
- package/src/useLoaderDeps.tsx +3 -2
- package/src/useLocation.tsx +5 -1
- package/src/useMatch.tsx +3 -2
- package/src/useNavigate.tsx +2 -1
- package/src/useParams.tsx +3 -2
- package/src/useRouteContext.ts +2 -2
- package/src/useRouter.tsx +1 -1
- package/src/useRouterState.tsx +5 -1
- package/src/useSearch.tsx +3 -2
- package/src/utils.ts +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["import { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type * as Solid from 'solid-js'\nimport type { RegisteredRouter
|
|
1
|
+
{"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["import { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type * as Solid from 'solid-js'\nimport type { RegisteredRouter, RouteIds } from '@tanstack/router-core'\n\nexport type NotFoundError = {\n /**\n @deprecated\n Use `routeId: rootRouteId` instead\n */\n global?: boolean\n /**\n @private\n Do not use this. It's used internally to indicate a path matching error\n */\n _global?: boolean\n data?: any\n throw?: boolean\n routeId?: RouteIds<RegisteredRouter['routeTree']>\n headers?: HeadersInit\n}\n\nexport function notFound(options: NotFoundError = {}) {\n ;(options as any).isNotFound = true\n if (options.throw) throw options\n return options\n}\n\nexport function isNotFound(obj: any): obj is NotFoundError {\n return !!obj?.isNotFound\n}\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => Solid.JSX.Element\n onCatch?: (error: Error) => void\n children: Solid.JSX.Element\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey()}\n onCatch={(error) => {\n if (isNotFound(error)) {\n props.onCatch?.(error)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }: { error: Error }) => {\n if (isNotFound(error)) {\n return props.fallback?.(error)\n } else {\n throw error\n }\n }}\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"names":["notFound","options","isNotFound","throw","obj","CatchNotFound","props","resetKey","useRouterState","select","s","location","pathname","status","_$createComponent","CatchBoundary","getResetKey","onCatch","error","errorComponent","fallback","children","DefaultGlobalNotFound","_tmpl$"],"mappings":";;;;;;AAsBgBA,SAAAA,SAASC,UAAyB,IAAI;AAClDA,UAAgBC,aAAa;AAC3BD,MAAAA,QAAQE,MAAaF,OAAAA;AAClBA,SAAAA;AACT;AAEO,SAASC,WAAWE,KAAgC;AAClD,SAAA,CAAC,EAACA,2BAAKF;AAChB;AAEO,SAASG,cAAcC,OAI3B;AAED,QAAMC,WAAWC,eAAAA,eAAe;AAAA,IAC9BC,QAASC,OAAM,aAAaA,EAAEC,SAASC,QAAQ,IAAIF,EAAEG,MAAM;AAAA,EAAA,CAC5D;AAED,SAAAC,IAAAA,gBACGC,cAAAA,eAAa;AAAA,IACZC,aAAaA,MAAMT,SAAS;AAAA,IAC5BU,SAAUC,CAAU,UAAA;;AACdhB,UAAAA,WAAWgB,KAAK,GAAG;AACrBZ,oBAAMW,YAANX,+BAAgBY;AAAAA,MAAK,OAChB;AACCA,cAAAA;AAAAA,MAAAA;AAAAA,IAEV;AAAA,IACAC,gBAAgBA,CAAC;AAAA,MAAED;AAAAA,IAAAA,MAA8B;;AAC3ChB,UAAAA,WAAWgB,KAAK,GAAG;AACdZ,gBAAAA,WAAMc,aAANd,+BAAiBY;AAAAA,MAAK,OACxB;AACCA,cAAAA;AAAAA,MAAAA;AAAAA,IAEV;AAAA,IAAC,IAAAG,WAAA;AAAA,aAEAf,MAAMe;AAAAA,IAAAA;AAAAA,EAAQ,CAAA;AAGrB;AAEO,SAASC,wBAAwB;AACtC,SAAAC,OAAA;AACF;;;;;"}
|
package/dist/cjs/not-found.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirects.cjs","sources":["../../src/redirects.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"redirects.cjs","sources":["../../src/redirects.ts"],"sourcesContent":["import type {\n AnyRedirect,\n Redirect,\n RegisteredRouter,\n ResolvedRedirect,\n} from '@tanstack/router-core'\n\nexport function redirect<\n TRouter extends RegisteredRouter,\n const TTo extends string | undefined,\n const TFrom extends string = string,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> {\n ;(opts as any).isRedirect = true\n opts.statusCode = opts.statusCode || opts.code || 307\n opts.headers = opts.headers || {}\n if (!opts.reloadDocument) {\n opts.reloadDocument = false\n try {\n new URL(`${opts.href}`)\n opts.reloadDocument = true\n } catch {}\n }\n\n if (opts.throw) {\n throw opts\n }\n\n return opts\n}\n\nexport function isRedirect(obj: any): obj is AnyRedirect {\n return !!obj?.isRedirect\n}\n\nexport function isResolvedRedirect(obj: any): obj is ResolvedRedirect {\n return !!obj?.isRedirect && obj.href\n}\n"],"names":[],"mappings":";;AAOO,SAAS,SAOd,MACmD;AACjD,OAAa,aAAa;AAC5B,OAAK,aAAa,KAAK,cAAc,KAAK,QAAQ;AAC7C,OAAA,UAAU,KAAK,WAAW,CAAC;AAC5B,MAAA,CAAC,KAAK,gBAAgB;AACxB,SAAK,iBAAiB;AAClB,QAAA;AACF,UAAI,IAAI,GAAG,KAAK,IAAI,EAAE;AACtB,WAAK,iBAAiB;AAAA,IAAA,QAChB;AAAA,IAAA;AAAA,EAAC;AAGX,MAAI,KAAK,OAAO;AACR,UAAA;AAAA,EAAA;AAGD,SAAA;AACT;AAEO,SAAS,WAAW,KAA8B;AAChD,SAAA,CAAC,EAAC,2BAAK;AAChB;AAEO,SAAS,mBAAmB,KAAmC;AACpE,SAAO,CAAC,EAAC,2BAAK,eAAc,IAAI;AAClC;;;;"}
|
package/dist/cjs/redirects.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { RegisteredRouter } from '
|
|
2
|
-
import { AnyRedirect, Redirect, ResolvedRedirect } from '@tanstack/router-core';
|
|
1
|
+
import { AnyRedirect, Redirect, RegisteredRouter, ResolvedRedirect } from '@tanstack/router-core';
|
|
3
2
|
export declare function redirect<TRouter extends RegisteredRouter, const TTo extends string | undefined, const TFrom extends string = string, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
|
|
4
3
|
export declare function isRedirect(obj: any): obj is AnyRedirect;
|
|
5
4
|
export declare function isResolvedRedirect(obj: any): obj is ResolvedRedirect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRouteNotFound.cjs","sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import warning from 'tiny-warning'\nimport { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRouter } from '
|
|
1
|
+
{"version":3,"file":"renderRouteNotFound.cjs","sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import warning from 'tiny-warning'\nimport { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRoute, AnyRouter } from '@tanstack/router-core'\n\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n) {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return <router.options.defaultNotFoundComponent data={data} />\n }\n\n if (process.env.NODE_ENV === 'development') {\n warning(\n route.options.notFoundComponent,\n `A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`,\n )\n }\n\n return <DefaultGlobalNotFound />\n }\n\n return <route.options.notFoundComponent data={data} />\n}\n"],"names":["renderRouteNotFound","router","route","data","options","notFoundComponent","defaultNotFoundComponent","_$createComponent","process","env","NODE_ENV","warning","id","DefaultGlobalNotFound"],"mappings":";;;;;AAIgBA,SAAAA,oBACdC,QACAC,OACAC,MACA;AACI,MAAA,CAACD,MAAME,QAAQC,mBAAmB;AAChCJ,QAAAA,OAAOG,QAAQE,0BAA0B;AAC3CC,aAAAA,oBAAQN,OAAOG,QAAQE,0BAAwB;AAAA,QAACH;AAAAA,MAAAA,CAAU;AAAA,IAAA;AAGxDK,QAAAA,QAAQC,IAAIC,aAAa,eAAe;AAC1CC,cACET,MAAME,QAAQC,mBACd,yDAAyDH,MAAMU,EAAE,uPACnE;AAAA,IAAA;AAGFL,WAAAA,IAAAA,gBAAQM,SAAqB,uBAAA,EAAA;AAAA,EAAA;AAG/BN,SAAAA,oBAAQL,MAAME,QAAQC,mBAAiB;AAAA,IAACF;AAAAA,EAAAA,CAAU;AACpD;;"}
|
package/dist/cjs/route.cjs
CHANGED
|
@@ -97,6 +97,21 @@ class Route {
|
|
|
97
97
|
this._to = fullPath;
|
|
98
98
|
this._ssr = (options2 == null ? void 0 : options2.ssr) ?? opts.defaultSsr ?? true;
|
|
99
99
|
};
|
|
100
|
+
this.addChildren = (children) => {
|
|
101
|
+
return this._addFileChildren(children);
|
|
102
|
+
};
|
|
103
|
+
this._addFileChildren = (children) => {
|
|
104
|
+
if (Array.isArray(children)) {
|
|
105
|
+
this.children = children;
|
|
106
|
+
}
|
|
107
|
+
if (typeof children === "object" && children !== null) {
|
|
108
|
+
this.children = Object.values(children);
|
|
109
|
+
}
|
|
110
|
+
return this;
|
|
111
|
+
};
|
|
112
|
+
this._addFileTypes = () => {
|
|
113
|
+
return this;
|
|
114
|
+
};
|
|
100
115
|
this.updateLoader = (options2) => {
|
|
101
116
|
Object.assign(this.options, options2);
|
|
102
117
|
return this;
|
|
@@ -165,18 +180,6 @@ class Route {
|
|
|
165
180
|
get ssr() {
|
|
166
181
|
return this._ssr;
|
|
167
182
|
}
|
|
168
|
-
addChildren(children) {
|
|
169
|
-
return this._addFileChildren(children);
|
|
170
|
-
}
|
|
171
|
-
_addFileChildren(children) {
|
|
172
|
-
if (Array.isArray(children)) {
|
|
173
|
-
this.children = children;
|
|
174
|
-
}
|
|
175
|
-
if (typeof children === "object" && children !== null) {
|
|
176
|
-
this.children = Object.values(children);
|
|
177
|
-
}
|
|
178
|
-
return this;
|
|
179
|
-
}
|
|
180
183
|
}
|
|
181
184
|
function createRoute(options) {
|
|
182
185
|
return new Route(options);
|
|
@@ -194,17 +197,6 @@ class RootRoute extends Route {
|
|
|
194
197
|
constructor(options) {
|
|
195
198
|
super(options);
|
|
196
199
|
}
|
|
197
|
-
addChildren(children) {
|
|
198
|
-
super.addChildren(children);
|
|
199
|
-
return this;
|
|
200
|
-
}
|
|
201
|
-
_addFileChildren(children) {
|
|
202
|
-
super._addFileChildren(children);
|
|
203
|
-
return this;
|
|
204
|
-
}
|
|
205
|
-
_addFileTypes() {
|
|
206
|
-
return this;
|
|
207
|
-
}
|
|
208
200
|
}
|
|
209
201
|
function createRootRoute(options) {
|
|
210
202
|
return new RootRoute(options);
|
package/dist/cjs/route.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.cjs","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport { joinPaths, rootRouteId, trimPathLeft } from '@tanstack/router-core'\nimport { useLoaderData } from './useLoaderData'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { notFound } from './not-found'\nimport { useNavigate } from './useNavigate'\nimport { useMatch } from './useMatch'\nimport type {\n AnyContext,\n AnySchema,\n Constrain,\n ConstrainLiteral,\n RootRoute as CoreRootRoute,\n Route as CoreRoute,\n ErrorComponentProps,\n NotFoundRouteProps,\n ResolveId,\n ResolveParams,\n RootRouteId,\n RootRouteOptions,\n RouteById,\n RouteContext,\n RouteIds,\n RouteLoaderFn,\n RouteOptions,\n RoutePathOptionsIntersection,\n RoutePaths,\n RoutePrefix,\n RouteTypes,\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 { AnyRouter, RegisteredRouter, Router } from './router'\nimport type { NotFoundError } from './not-found'\nimport type { LazyRoute } from './fileRoute'\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\nexport interface AnyRoute\n extends Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport type AnyRouteWithContext<TContext> = AnyRoute & {\n types: { allContext: TContext }\n}\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySchema\n TFullSearchSchema: AnySchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport type RouteTypesById<TRouter extends AnyRouter, TId> = RouteById<\n TRouter['routeTree'],\n TId\n>['types']\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 return useNavigate({ from: this.id as string })\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 Route<any> ? 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<LazyRoute<any>>\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<const TNewChildren>(\n children: Constrain<\n TNewChildren,\n ReadonlyArray<AnyRoute> | Record<string, AnyRoute>\n >,\n ): Route<\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 TNewChildren,\n TFileRouteTypes\n > {\n return this._addFileChildren(children) 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 TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n >\n }\n\n _addFileChildren<const TNewChildren>(\n children: TNewChildren,\n ): Route<\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 TNewChildren,\n TFileRouteTypes\n > {\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 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 TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n >\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 = (lazyFn: () => Promise<LazyRoute<any>>): this => {\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.id })\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) {\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 >\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 implements\n CoreRootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\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 addChildren<const TNewChildren>(\n children: Constrain<\n TNewChildren,\n ReadonlyArray<AnyRoute> | Record<string, AnyRoute>\n >,\n ): RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n > {\n super.addChildren(children)\n return this as unknown as RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n >\n }\n\n _addFileChildren<const TNewChildren>(\n children: TNewChildren,\n ): RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n > {\n super._addFileChildren(children)\n return this as unknown as RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n >\n }\n\n _addFileTypes<TFileRouteTypes>(): RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n > {\n return this 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 type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\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'>, 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":["useMatch","useSearch","useParams","useLoaderDeps","useLoaderData","useNavigate","notFound","options","rootRouteId","trimPathLeft","joinPaths"],"mappings":";;;;;;;;;;;AAqGO,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,aAAOA,kBAAS;AAAA,QACd,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SAAA,kBAA6C,CAAC,SAAS;AACrD,aAAOA,kBAAS;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,aAAOC,oBAAU;AAAA,QACf,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SAAA,YAAiC,CAAC,SAAS;AACzC,aAAOC,oBAAU;AAAA,QACf,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SAAA,gBAAyC,CAAC,SAAS;AAC1C,aAAAC,cAAA,cAAc,EAAE,GAAG,MAAM,MAAM,KAAK,IAAI,QAAQ,OAAc;AAAA,IACvE;AAEA,SAAA,gBAAyC,CAAC,SAAS;AAC1C,aAAAC,cAAA,cAAc,EAAE,GAAG,MAAM,MAAM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O;AACX;AAmBO,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.cjs","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport { joinPaths, rootRouteId, trimPathLeft } from '@tanstack/router-core'\nimport { useLoaderData } from './useLoaderData'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { notFound } from './not-found'\nimport { useNavigate } from './useNavigate'\nimport { useMatch } from './useMatch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n LazyRoute as CoreLazyRoute,\n Route as CoreRoute,\n ErrorComponentProps,\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 { NotFoundError } from './not-found'\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 return useNavigate({ from: this.id as string })\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.id })\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":["useMatch","useSearch","useParams","useLoaderDeps","useLoaderData","useNavigate","notFound","options","rootRouteId","trimPathLeft","joinPaths"],"mappings":";;;;;;;;;;;AA0EO,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,aAAOA,kBAAS;AAAA,QACd,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SAAA,kBAA6C,CAAC,SAAS;AACrD,aAAOA,kBAAS;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,aAAOC,oBAAU;AAAA,QACf,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA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QG;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;;;;;;;;;;;"}
|
package/dist/cjs/route.d.cts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { AnyContext,
|
|
1
|
+
import { AnyContext, AnyRoute, AnyRouter, Constrain, ConstrainLiteral, LazyRoute as CoreLazyRoute, Route as CoreRoute, ErrorComponentProps, NotFoundRouteProps, RegisteredRouter, ResolveFullPath, ResolveId, ResolveParams, RootRouteId, RootRouteOptions, RouteAddChildrenFn, RouteAddFileChildrenFn, RouteAddFileTypesFn, RouteConstraints, RouteIds, RouteLazyFn, RouteLoaderFn, RouteMask, RouteOptions, RouteTypes, RouteTypesById, Router, ToMaskOptions, TrimPathRight, UpdatableRouteOptions, UseNavigateResult } from '@tanstack/router-core';
|
|
2
2
|
import { UseLoaderDataRoute } from './useLoaderData.cjs';
|
|
3
3
|
import { UseMatchRoute } from './useMatch.cjs';
|
|
4
4
|
import { UseLoaderDepsRoute } from './useLoaderDeps.cjs';
|
|
5
5
|
import { UseParamsRoute } from './useParams.cjs';
|
|
6
6
|
import { UseSearchRoute } from './useSearch.cjs';
|
|
7
|
-
import { AnyRouter, RegisteredRouter, Router } from './router.cjs';
|
|
8
7
|
import { NotFoundError } from './not-found.cjs';
|
|
9
|
-
import { LazyRoute } from './fileRoute.cjs';
|
|
10
8
|
import { UseRouteContextRoute } from './useRouteContext.cjs';
|
|
11
9
|
import type * as Solid from 'solid-js';
|
|
12
10
|
declare module '@tanstack/router-core' {
|
|
@@ -16,32 +14,16 @@ declare module '@tanstack/router-core' {
|
|
|
16
14
|
notFoundComponent?: NotFoundRouteComponent;
|
|
17
15
|
pendingComponent?: RouteComponent;
|
|
18
16
|
}
|
|
17
|
+
interface RouteExtensions<TId extends string, TFullPath extends string> {
|
|
18
|
+
useMatch: UseMatchRoute<TId>;
|
|
19
|
+
useRouteContext: UseRouteContextRoute<TId>;
|
|
20
|
+
useSearch: UseSearchRoute<TId>;
|
|
21
|
+
useParams: UseParamsRoute<TId>;
|
|
22
|
+
useLoaderDeps: UseLoaderDepsRoute<TId>;
|
|
23
|
+
useLoaderData: UseLoaderDataRoute<TId>;
|
|
24
|
+
useNavigate: () => UseNavigateResult<TFullPath>;
|
|
25
|
+
}
|
|
19
26
|
}
|
|
20
|
-
export interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
21
|
-
}
|
|
22
|
-
export type AnyRouteWithContext<TContext> = AnyRoute & {
|
|
23
|
-
types: {
|
|
24
|
-
allContext: TContext;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export type RouteConstraints = {
|
|
28
|
-
TParentRoute: AnyRoute;
|
|
29
|
-
TPath: string;
|
|
30
|
-
TFullPath: string;
|
|
31
|
-
TCustomId: string;
|
|
32
|
-
TId: string;
|
|
33
|
-
TSearchSchema: AnySchema;
|
|
34
|
-
TFullSearchSchema: AnySchema;
|
|
35
|
-
TParams: Record<string, any>;
|
|
36
|
-
TAllParams: Record<string, any>;
|
|
37
|
-
TParentContext: AnyContext;
|
|
38
|
-
TRouteContext: RouteContext;
|
|
39
|
-
TAllContext: AnyContext;
|
|
40
|
-
TRouterContext: AnyContext;
|
|
41
|
-
TChildren: unknown;
|
|
42
|
-
TRouteTree: AnyRoute;
|
|
43
|
-
};
|
|
44
|
-
export type RouteTypesById<TRouter extends AnyRouter, TId> = RouteById<TRouter['routeTree'], TId>['types'];
|
|
45
27
|
export declare function getRouteApi<const TId, TRouter extends AnyRouter = RegisteredRouter>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>): RouteApi<TId, TRouter>;
|
|
46
28
|
export declare class RouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {
|
|
47
29
|
id: TId;
|
|
@@ -61,7 +43,7 @@ export declare class RouteApi<TId, TRouter extends AnyRouter = RegisteredRouter>
|
|
|
61
43
|
notFound: (opts?: NotFoundError) => NotFoundError;
|
|
62
44
|
}
|
|
63
45
|
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> implements CoreRoute<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes> {
|
|
64
|
-
isRoot: TParentRoute extends
|
|
46
|
+
isRoot: TParentRoute extends AnyRoute ? true : false;
|
|
65
47
|
options: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>;
|
|
66
48
|
parentRoute: TParentRoute;
|
|
67
49
|
private _id;
|
|
@@ -77,7 +59,7 @@ export declare class Route<in out TParentRoute extends RouteConstraints['TParent
|
|
|
77
59
|
children?: TChildren;
|
|
78
60
|
originalIndex?: number;
|
|
79
61
|
rank: number;
|
|
80
|
-
lazyFn?: () => Promise<
|
|
62
|
+
lazyFn?: () => Promise<CoreLazyRoute>;
|
|
81
63
|
_lazyPromise?: Promise<void>;
|
|
82
64
|
_componentsPromise?: Promise<Array<void>>;
|
|
83
65
|
/**
|
|
@@ -89,13 +71,14 @@ export declare class Route<in out TParentRoute extends RouteConstraints['TParent
|
|
|
89
71
|
originalIndex: number;
|
|
90
72
|
defaultSsr?: boolean;
|
|
91
73
|
}) => void;
|
|
92
|
-
addChildren
|
|
93
|
-
_addFileChildren
|
|
74
|
+
addChildren: RouteAddChildrenFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TFileRouteTypes>;
|
|
75
|
+
_addFileChildren: RouteAddFileChildrenFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TFileRouteTypes>;
|
|
76
|
+
_addFileTypes: RouteAddFileTypesFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren>;
|
|
94
77
|
updateLoader: <TNewLoaderFn>(options: {
|
|
95
78
|
loader: Constrain<TNewLoaderFn, RouteLoaderFn<TParentRoute, TCustomId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>>;
|
|
96
79
|
}) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TNewLoaderFn, TChildren, TFileRouteTypes>;
|
|
97
80
|
update: (options: UpdatableRouteOptions<TParentRoute, TCustomId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => this;
|
|
98
|
-
lazy:
|
|
81
|
+
lazy: RouteLazyFn<this>;
|
|
99
82
|
useMatch: UseMatchRoute<TId>;
|
|
100
83
|
useRouteContext: UseRouteContextRoute<TId>;
|
|
101
84
|
useSearch: UseSearchRoute<TId>;
|
|
@@ -104,7 +87,7 @@ export declare class Route<in out TParentRoute extends RouteConstraints['TParent
|
|
|
104
87
|
useLoaderData: UseLoaderDataRoute<TId>;
|
|
105
88
|
useNavigate: () => UseNavigateResult<TFullPath>;
|
|
106
89
|
}
|
|
107
|
-
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>):
|
|
90
|
+
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>): CoreRoute<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, unknown>;
|
|
108
91
|
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>;
|
|
109
92
|
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>;
|
|
110
93
|
/**
|
|
@@ -119,30 +102,16 @@ RootRouteId, // TId
|
|
|
119
102
|
TSearchValidator, // TSearchValidator
|
|
120
103
|
{}, // TParams
|
|
121
104
|
TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, // TChildren
|
|
122
|
-
TFileRouteTypes>
|
|
105
|
+
TFileRouteTypes> {
|
|
123
106
|
/**
|
|
124
107
|
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
125
108
|
*/
|
|
126
109
|
constructor(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>);
|
|
127
|
-
addChildren<const TNewChildren>(children: Constrain<TNewChildren, ReadonlyArray<AnyRoute> | Record<string, AnyRoute>>): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
|
|
128
|
-
_addFileChildren<const TNewChildren>(children: TNewChildren): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
|
|
129
|
-
_addFileTypes<TFileRouteTypes>(): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>;
|
|
130
110
|
}
|
|
131
111
|
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>;
|
|
132
|
-
export type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
|
|
133
|
-
export type RouteMask<TRouteTree extends AnyRoute> = {
|
|
134
|
-
routeTree: TRouteTree;
|
|
135
|
-
from: RoutePaths<TRouteTree>;
|
|
136
|
-
to?: any;
|
|
137
|
-
params?: any;
|
|
138
|
-
search?: any;
|
|
139
|
-
hash?: any;
|
|
140
|
-
state?: any;
|
|
141
|
-
unmaskOnReload?: boolean;
|
|
142
|
-
};
|
|
143
112
|
export declare function createRouteMask<TRouteTree extends AnyRoute, TFrom extends string, TTo extends string>(opts: {
|
|
144
113
|
routeTree: TRouteTree;
|
|
145
|
-
} & ToMaskOptions<Router<TRouteTree, 'never'>, TFrom, TTo>): RouteMask<TRouteTree>;
|
|
114
|
+
} & ToMaskOptions<Router<TRouteTree, 'never', false>, TFrom, TTo>): RouteMask<TRouteTree>;
|
|
146
115
|
export type SolidNode = Solid.JSX.Element;
|
|
147
116
|
export type SyncRouteComponent<TProps> = (props: TProps) => Solid.JSX.Element;
|
|
148
117
|
export type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
|
package/dist/cjs/router.cjs
CHANGED
|
@@ -59,7 +59,7 @@ class Router {
|
|
|
59
59
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
60
60
|
this.isScrollRestoring = false;
|
|
61
61
|
this.isScrollRestorationSetup = false;
|
|
62
|
-
this.
|
|
62
|
+
this.startTransition = (fn) => fn();
|
|
63
63
|
this.update = (newOptions) => {
|
|
64
64
|
var _a;
|
|
65
65
|
if (newOptions.notFoundRoute) {
|
|
@@ -256,6 +256,19 @@ class Router {
|
|
|
256
256
|
});
|
|
257
257
|
return resolvedPath;
|
|
258
258
|
};
|
|
259
|
+
this.matchRoutes = (pathnameOrNext, locationSearchOrOpts, opts) => {
|
|
260
|
+
if (typeof pathnameOrNext === "string") {
|
|
261
|
+
return this.matchRoutesInternal(
|
|
262
|
+
{
|
|
263
|
+
pathname: pathnameOrNext,
|
|
264
|
+
search: locationSearchOrOpts
|
|
265
|
+
},
|
|
266
|
+
opts
|
|
267
|
+
);
|
|
268
|
+
} else {
|
|
269
|
+
return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
259
272
|
this.getMatchedRoutes = (next, dest) => {
|
|
260
273
|
let routeParams = {};
|
|
261
274
|
const trimmedPath = routerCore.trimPathRight(next.pathname);
|
|
@@ -637,7 +650,7 @@ class Router {
|
|
|
637
650
|
let notFound$1;
|
|
638
651
|
let loadPromise;
|
|
639
652
|
loadPromise = new Promise((resolve) => {
|
|
640
|
-
this.
|
|
653
|
+
this.startTransition(async () => {
|
|
641
654
|
var _a;
|
|
642
655
|
try {
|
|
643
656
|
const next = this.latestLocation;
|
|
@@ -930,16 +943,16 @@ class Router {
|
|
|
930
943
|
}
|
|
931
944
|
if (executeBeforeLoad) {
|
|
932
945
|
try {
|
|
933
|
-
updateMatch(matchId, (prev) =>
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
})
|
|
946
|
+
updateMatch(matchId, (prev) => {
|
|
947
|
+
const prevLoadPromise = prev.loadPromise;
|
|
948
|
+
return {
|
|
949
|
+
...prev,
|
|
950
|
+
loadPromise: routerCore.createControlledPromise(() => {
|
|
951
|
+
prevLoadPromise == null ? void 0 : prevLoadPromise.resolve();
|
|
952
|
+
}),
|
|
953
|
+
beforeLoadPromise: routerCore.createControlledPromise()
|
|
954
|
+
};
|
|
955
|
+
});
|
|
943
956
|
const abortController = new AbortController();
|
|
944
957
|
let pendingTimeout;
|
|
945
958
|
if (shouldPending) {
|
|
@@ -1432,19 +1445,6 @@ class Router {
|
|
|
1432
1445
|
get looseRoutesById() {
|
|
1433
1446
|
return this.routesById;
|
|
1434
1447
|
}
|
|
1435
|
-
matchRoutes(pathnameOrNext, locationSearchOrOpts, opts) {
|
|
1436
|
-
if (typeof pathnameOrNext === "string") {
|
|
1437
|
-
return this.matchRoutesInternal(
|
|
1438
|
-
{
|
|
1439
|
-
pathname: pathnameOrNext,
|
|
1440
|
-
search: locationSearchOrOpts
|
|
1441
|
-
},
|
|
1442
|
-
opts
|
|
1443
|
-
);
|
|
1444
|
-
} else {
|
|
1445
|
-
return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
1448
|
matchRoutesInternal(next, opts) {
|
|
1449
1449
|
const { foundRoute, matchedRoutes, routeParams } = this.getMatchedRoutes(
|
|
1450
1450
|
next,
|