@tanstack/react-router 1.31.29 → 1.32.2
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/Matches.d.cts +6 -9
- package/dist/cjs/RouterProvider.d.cts +6 -6
- package/dist/cjs/awaited.d.cts +1 -1
- package/dist/cjs/defer.d.cts +1 -0
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +38 -79
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +4 -3
- package/dist/cjs/lazyRouteComponent.d.cts +2 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +56 -50
- package/dist/cjs/location.d.cts +3 -2
- package/dist/cjs/not-found.d.cts +2 -2
- package/dist/cjs/path.d.cts +3 -2
- package/dist/cjs/redirects.d.cts +5 -4
- package/dist/cjs/route.cjs +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +59 -52
- package/dist/cjs/routeInfo.d.cts +12 -11
- package/dist/cjs/router.cjs +2 -2
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +19 -20
- package/dist/cjs/routerContext.d.cts +1 -1
- package/dist/cjs/scroll-restoration.d.cts +2 -1
- package/dist/cjs/searchParams.d.cts +2 -1
- package/dist/cjs/useBlocker.d.cts +3 -2
- package/dist/cjs/useLocation.cjs +10 -0
- package/dist/cjs/useLocation.cjs.map +1 -0
- package/dist/cjs/useLocation.d.cts +5 -0
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +5 -4
- package/dist/cjs/useParams.d.cts +5 -5
- package/dist/cjs/useRouteContext.d.cts +5 -4
- package/dist/cjs/useRouter.d.cts +2 -1
- package/dist/cjs/useRouterState.d.cts +2 -1
- package/dist/cjs/useSearch.d.cts +5 -4
- package/dist/esm/Matches.d.ts +6 -9
- package/dist/esm/RouterProvider.d.ts +6 -6
- package/dist/esm/awaited.d.ts +1 -1
- package/dist/esm/defer.d.ts +1 -0
- package/dist/esm/fileRoute.d.ts +38 -79
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lazyRouteComponent.d.ts +2 -1
- package/dist/esm/link.d.ts +56 -50
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/location.d.ts +3 -2
- package/dist/esm/not-found.d.ts +2 -2
- package/dist/esm/path.d.ts +3 -2
- package/dist/esm/redirects.d.ts +5 -4
- package/dist/esm/route.d.ts +59 -52
- package/dist/esm/route.js +1 -1
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/routeInfo.d.ts +12 -11
- package/dist/esm/router.d.ts +19 -20
- package/dist/esm/router.js +2 -2
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +1 -1
- package/dist/esm/scroll-restoration.d.ts +2 -1
- package/dist/esm/searchParams.d.ts +2 -1
- package/dist/esm/useBlocker.d.ts +3 -2
- package/dist/esm/useLocation.d.ts +5 -0
- package/dist/esm/useLocation.js +10 -0
- package/dist/esm/useLocation.js.map +1 -0
- package/dist/esm/useNavigate.d.ts +5 -4
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.d.ts +5 -5
- package/dist/esm/useRouteContext.d.ts +5 -4
- package/dist/esm/useRouter.d.ts +2 -1
- package/dist/esm/useRouterState.d.ts +2 -1
- package/dist/esm/useSearch.d.ts +5 -4
- package/package.json +2 -10
- package/src/fileRoute.ts +26 -104
- package/src/index.tsx +1 -8
- package/src/link.tsx +205 -156
- package/src/route.ts +121 -106
- package/src/routeInfo.ts +24 -22
- package/src/useLocation.tsx +15 -0
- package/src/useNavigate.tsx +2 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AnyRouter, RegisteredRouter, RouterState } from './router.cjs';
|
|
2
|
+
|
|
3
|
+
export declare function useLocation<TRouter extends AnyRouter = RegisteredRouter, TLocationState = RouterState<TRouter['routeTree']>['location'], TSelected = TLocationState>(opts?: {
|
|
4
|
+
select?: (state: TLocationState) => TSelected;
|
|
5
|
+
}): TSelected;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigate.cjs","sources":["../../src/useNavigate.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useMatch } from './Matches'\nimport { useRouter } from './useRouter'\n\nimport type { NavigateOptions } from './link'\nimport type { RoutePaths, RoutePathsAutoComplete } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\n\nexport type UseNavigateResult<TDefaultFrom extends string> = <\n TTo extends string,\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = TDefaultFrom,\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>({\n from,\n ...rest\n}: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void>\n\nexport function useNavigate<\n TDefaultFrom extends string = string,\n>(_defaultOpts?: {\n from?: RoutePathsAutoComplete<RegisteredRouter
|
|
1
|
+
{"version":3,"file":"useNavigate.cjs","sources":["../../src/useNavigate.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useMatch } from './Matches'\nimport { useRouter } from './useRouter'\n\nimport type { NavigateOptions } from './link'\nimport type { RoutePaths, RoutePathsAutoComplete } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\n\nexport type UseNavigateResult<TDefaultFrom extends string> = <\n TTo extends string,\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = TDefaultFrom,\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>({\n from,\n ...rest\n}: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void>\n\nexport function useNavigate<\n TDefaultFrom extends string = string,\n>(_defaultOpts?: {\n from?: RoutePathsAutoComplete<RegisteredRouter, TDefaultFrom>\n}): UseNavigateResult<TDefaultFrom> {\n const router = useRouter()\n\n return React.useCallback(\n (options: NavigateOptions) => {\n return router.navigate({\n ...options,\n from: options.to ? router.state.resolvedLocation.pathname : undefined,\n })\n },\n [router],\n ) as UseNavigateResult<TDefaultFrom>\n}\n\n// NOTE: I don't know of anyone using this. It's undocumented, so let's wait until someone needs it\n// export function typedNavigate<\n// TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n// TDefaultFrom extends RoutePaths<TRouteTree> = '/',\n// >(navigate: (opts: NavigateOptions<any>) => Promise<void>) {\n// return navigate as <\n// TFrom extends RoutePaths<TRouteTree> = TDefaultFrom,\n// TTo extends string = '',\n// TMaskFrom extends RoutePaths<TRouteTree> = '/',\n// TMaskTo extends string = '',\n// >(\n// opts?: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n// ) => Promise<void>\n// } //\n\nexport function Navigate<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(props: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): null {\n const { navigate } = useRouter()\n const match = useMatch({ strict: false })\n\n React.useEffect(() => {\n navigate({\n from: props.to ? match.pathname : undefined,\n ...props,\n } as any)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n return null\n}\n"],"names":["useRouter","React","useMatch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,YAEd,cAEkC;AAClC,QAAM,SAASA,UAAAA;AAEf,SAAOC,iBAAM;AAAA,IACX,CAAC,YAA6B;AAC5B,aAAO,OAAO,SAAS;AAAA,QACrB,GAAG;AAAA,QACH,MAAM,QAAQ,KAAK,OAAO,MAAM,iBAAiB,WAAW;AAAA,MAAA,CAC7D;AAAA,IACH;AAAA,IACA,CAAC,MAAM;AAAA,EAAA;AAEX;AAiBO,SAAS,SAMd,OAAuE;AACjE,QAAA,EAAE,aAAaD,UAAAA;AACrB,QAAM,QAAQE,QAAA,SAAS,EAAE,QAAQ,MAAO,CAAA;AAExCD,mBAAM,UAAU,MAAM;AACX,aAAA;AAAA,MACP,MAAM,MAAM,KAAK,MAAM,WAAW;AAAA,MAClC,GAAG;AAAA,IAAA,CACG;AAAA,EAEV,GAAG,CAAE,CAAA;AAEE,SAAA;AACT;;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { NavigateOptions } from './link.cjs';
|
|
2
|
+
import { RoutePaths, RoutePathsAutoComplete } from './routeInfo.cjs';
|
|
3
|
+
import { AnyRouter, RegisteredRouter } from './router.cjs';
|
|
4
|
+
|
|
4
5
|
export type UseNavigateResult<TDefaultFrom extends string> = <TTo extends string, TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = TDefaultFrom, TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = ''>({ from, ...rest }: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void>;
|
|
5
6
|
export declare function useNavigate<TDefaultFrom extends string = string>(_defaultOpts?: {
|
|
6
|
-
from?: RoutePathsAutoComplete<RegisteredRouter
|
|
7
|
+
from?: RoutePathsAutoComplete<RegisteredRouter, TDefaultFrom>;
|
|
7
8
|
}): UseNavigateResult<TDefaultFrom>;
|
|
8
9
|
export declare function Navigate<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = ''>(props: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): null;
|
package/dist/cjs/useParams.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { AnyRoute } from './route.cjs';
|
|
2
|
+
import { AllParams, RouteById, RouteIds } from './routeInfo.cjs';
|
|
3
|
+
import { RegisteredRouter } from './router.cjs';
|
|
4
|
+
import { Expand, StrictOrFrom } from './utils.cjs';
|
|
5
|
+
|
|
6
6
|
export declare function useParams<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>, TReturnIntersection extends boolean = false, TParams = TReturnIntersection extends false ? RouteById<TRouteTree, TFrom>['types']['allParams'] : Expand<Partial<AllParams<TRouteTree>>>, TSelected = TParams>(opts: StrictOrFrom<TFrom, TReturnIntersection> & {
|
|
7
7
|
select?: (params: TParams) => TSelected;
|
|
8
8
|
}): TSelected;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { AnyRoute } from './route.cjs';
|
|
2
|
+
import { RouteById, RouteIds } from './routeInfo.cjs';
|
|
3
|
+
import { RegisteredRouter } from './router.cjs';
|
|
4
|
+
import { StrictOrFrom } from './utils.cjs';
|
|
5
|
+
|
|
5
6
|
export declare function useRouteContext<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>, TRouteContext = RouteById<TRouteTree, TFrom>['types']['allContext'], TSelected = TRouteContext>(opts: StrictOrFrom<TFrom> & {
|
|
6
7
|
select?: (search: TRouteContext) => TSelected;
|
|
7
8
|
}): TSelected;
|
package/dist/cjs/useRouter.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AnyRouter, RegisteredRouter, RouterState } from './router.cjs';
|
|
2
|
+
|
|
2
3
|
export declare function useRouterState<TRouter extends AnyRouter = RegisteredRouter, TSelected = RouterState<TRouter['routeTree']>>(opts?: {
|
|
3
4
|
router?: TRouter;
|
|
4
5
|
select: (state: RouterState<RegisteredRouter['routeTree']>) => TSelected;
|
package/dist/cjs/useSearch.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { AnyRoute, RootSearchSchema } from './route.cjs';
|
|
2
|
+
import { FullSearchSchema, RouteById, RouteIds } from './routeInfo.cjs';
|
|
3
|
+
import { RegisteredRouter } from './router.cjs';
|
|
4
|
+
import { StrictOrFrom } from './utils.cjs';
|
|
5
|
+
|
|
5
6
|
export declare function useSearch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>, TReturnIntersection extends boolean = false, TSearch = TReturnIntersection extends false ? Exclude<RouteById<TRouteTree, TFrom>['types']['fullSearchSchema'], RootSearchSchema> : Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>, TSelected = TSearch>(opts: StrictOrFrom<TFrom, TReturnIntersection> & {
|
|
6
7
|
select?: (search: TSearch) => TSelected;
|
|
7
8
|
}): TSelected;
|
package/dist/esm/Matches.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { AnyRouter, RegisteredRouter } from './router.js';
|
|
2
|
+
import { ResolveRelativePath, ToOptions } from './link.js';
|
|
3
|
+
import { AnyRoute, ReactNode, StaticDataRouteOption } from './route.js';
|
|
4
|
+
import { AllParams, FullSearchSchema, ParseRoute, RouteById, RouteByPath, RouteIds, RoutePaths } from './routeInfo.js';
|
|
5
|
+
import { ControlledPromise, DeepPartial, NoInfer, StrictOrFrom } from './utils.js';
|
|
1
6
|
import * as React from 'react';
|
|
2
|
-
import { type AnyRouter, type RegisteredRouter } from './router.js';
|
|
3
|
-
import type { ResolveRelativePath, ToOptions } from './link.js';
|
|
4
|
-
import type { AnyRoute, ReactNode, StaticDataRouteOption } from './route.js';
|
|
5
|
-
import type { AllParams, FullSearchSchema, ParseRoute, RouteById, RouteByPath, RouteIds, RoutePaths } from './routeInfo.js';
|
|
6
|
-
import type { ControlledPromise, DeepPartial, NoInfer, StrictOrFrom } from './utils.js';
|
|
7
7
|
export declare const matchContext: React.Context<string | undefined>;
|
|
8
8
|
export interface RouteMatch<TRouteId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps> {
|
|
9
9
|
id: string;
|
|
@@ -50,10 +50,7 @@ export interface MatchRouteOptions {
|
|
|
50
50
|
fuzzy?: boolean;
|
|
51
51
|
}
|
|
52
52
|
export type UseMatchRouteOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> = RoutePaths<TRouter['routeTree']>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom, TMaskTo extends string = '', TOptions extends ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>, TRelaxedOptions = Omit<TOptions, 'search' | 'params'> & DeepPartial<Pick<TOptions, 'search' | 'params'>>> = TRelaxedOptions & MatchRouteOptions;
|
|
53
|
-
export declare function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>(): <TFrom extends string | ParseRoute<TRouter["routeTree"], TRouter["routeTree"]>["fullPath"] = string, TTo extends string = "", TMaskFrom extends string | ParseRoute<TRouter["routeTree"], TRouter["routeTree"]>["fullPath"] = TFrom, TMaskTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo
|
|
54
|
-
search?: DeepPartial<ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>["search"]> | undefined;
|
|
55
|
-
params?: DeepPartial<ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>["params"]> | undefined;
|
|
56
|
-
}>) => false | RouteById<TRouter["routeTree"], TResolved>["types"]["allParams"];
|
|
53
|
+
export declare function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>(): <TFrom extends string | ParseRoute<TRouter["routeTree"], TRouter["routeTree"]>["fullPath"] = string, TTo extends string = "", TMaskFrom extends string | ParseRoute<TRouter["routeTree"], TRouter["routeTree"]>["fullPath"] = TFrom, TMaskTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => false | RouteById<TRouter['routeTree'], TResolved>['types']['allParams'];
|
|
57
54
|
export type MakeMatchRouteOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> = RoutePaths<TRouter['routeTree']>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom, TMaskTo extends string = ''> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
58
55
|
children?: ((params?: RouteByPath<TRouter['routeTree'], ResolveRelativePath<TFrom, NoInfer<TTo>>>['types']['allParams']) => ReactNode) | React.ReactNode;
|
|
59
56
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { NavigateOptions, ToOptions } from './link.js';
|
|
2
|
+
import { ParsedLocation } from './location.js';
|
|
3
|
+
import { AnyRoute } from './route.js';
|
|
4
|
+
import { RoutePaths } from './routeInfo.js';
|
|
5
|
+
import { AnyRouter, RegisteredRouter, Router, RouterOptions, RouterState } from './router.js';
|
|
6
|
+
import { MakeRouteMatch } from './Matches.js';
|
|
1
7
|
import * as React from 'react';
|
|
2
|
-
import type { NavigateOptions, ToOptions } from './link.js';
|
|
3
|
-
import type { ParsedLocation } from './location.js';
|
|
4
|
-
import type { AnyRoute } from './route.js';
|
|
5
|
-
import type { RoutePaths } from './routeInfo.js';
|
|
6
|
-
import type { AnyRouter, RegisteredRouter, Router, RouterOptions, RouterState } from './router.js';
|
|
7
|
-
import type { MakeRouteMatch } from './Matches.js';
|
|
8
8
|
export interface CommitLocationOptions {
|
|
9
9
|
replace?: boolean;
|
|
10
10
|
resetScroll?: boolean;
|
package/dist/esm/awaited.d.ts
CHANGED
package/dist/esm/defer.d.ts
CHANGED
package/dist/esm/fileRoute.d.ts
CHANGED
|
@@ -1,96 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
1
|
+
import { ParsePathParams } from './link.js';
|
|
2
|
+
import { AnyContext, AnyPathParams, AnyRoute, AnySearchSchema, FileBaseRouteOptions, ResolveAllContext, ResolveAllParamsFromParent, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, ResolveLoaderData, ResolveRouteContext, ResolveSearchSchemaUsed, Route, RouteConstraints, RouteContext, RouteLoaderFn, UpdatableRouteOptions } from './route.js';
|
|
3
|
+
import { Assign, IsAny } from './utils.js';
|
|
4
|
+
import { MakeRouteMatch } from './Matches.js';
|
|
5
|
+
import { NoInfer } from '@tanstack/react-store';
|
|
6
|
+
import { RegisteredRouter } from './router.js';
|
|
7
|
+
import { RouteById, RouteIds } from './routeInfo.js';
|
|
8
|
+
|
|
9
9
|
export interface FileRoutesByPath {
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
export type TrimLeft<TValue extends string, TStartsWith extends string> = TValue extends `${TStartsWith}${infer U}` ? U : TValue;
|
|
13
|
-
export type TrimRight<TValue extends string, TEndsWith extends string> = TValue extends `${infer U}${TEndsWith}` ? U : TValue;
|
|
14
|
-
export type Trim<TValue extends string, TFind extends string> = TrimLeft<TrimRight<TValue, TFind>, TFind>;
|
|
15
|
-
export type RemoveUnderScores<T extends string> = Replace<Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>, '/_', '/'>;
|
|
16
|
-
type RemoveRouteGroups<T extends string> = T extends `${infer Before}(${string})${infer After}` ? RemoveRouteGroups<`${Before}${After}`> : T;
|
|
17
|
-
type NormalizeSlashes<T extends string> = T extends `${infer Before}//${infer After}` ? NormalizeSlashes<`${Before}/${After}`> : T;
|
|
18
|
-
export type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : TFilePath extends `${TParentRoute['types']['customId']}${infer TRest}` ? TRest : TFilePath;
|
|
19
|
-
export type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends string, TResolvedFilePath = ResolveFilePath<TParentRoute, TFilePath>> = TResolvedFilePath extends `_${string}` ? '' : TResolvedFilePath extends `/_${string}` ? '' : TResolvedFilePath;
|
|
20
|
-
export declare function createFileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = NormalizeSlashes<RemoveRouteGroups<TFilePath>>, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, NormalizeSlashes<RemoveRouteGroups<RemoveUnderScores<TPath>>>>>(path: TFilePath): <TSearchSchemaInput extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TSearchSchemaUsed = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, "__TSearchSchemaInput__"> : TSearchSchema, TFullSearchSchemaInput = Assign<TParentRoute["id"] extends "__root__" ? Omit<TParentRoute["types"]["searchSchemaInput"], "__TRootSearchSchema__"> : TParentRoute["types"]["fullSearchSchemaInput"], TSearchSchemaUsed>, TFullSearchSchema = Assign<TParentRoute["id"] extends "__root__" ? Omit<TParentRoute["types"]["searchSchema"], "__TRootSearchSchema__"> : TParentRoute["types"]["fullSearchSchema"], TSearchSchema>, TParams = Record<TrimLeft<TrimRight<import("./link").Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<import("./link").Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L extends "" ? "_splat" : L : never : never : never, string>, TAllParams = IsAny<TParentRoute["types"]["allParams"], TParams, TParentRoute["types"]["allParams"] & TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TAllContext = Assign<IsAny<TParentRoute["types"]["allContext"], {}, TParentRoute["types"]["allContext"]>, TRouteContext>, TRouterContext extends AnyContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn, TChildren extends unknown = unknown>(options?: (FileBaseRouteOptions<TParentRoute, TPath, TSearchSchemaInput, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn> & {
|
|
11
|
+
export declare function createFileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'], TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'], TFullPath extends RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath']>(path: TFilePath): <TSearchSchemaInput = {}, TSearchSchema = {}, TSearchSchemaUsed = ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema>, TFullSearchSchemaInput = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams = Record<ParsePathParams<TPath, never>, string>, TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>, TRouteContextReturn = RouteContext, TRouteContext = ResolveRouteContext<TRouteContextReturn>, TAllContext = Assign<IsAny<TParentRoute["types"]["allContext"], {}, TParentRoute["types"]["allContext"]>, TRouteContext>, TRouterContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = ResolveLoaderData<TLoaderDataReturn>, TChildren = unknown>(options?: (FileBaseRouteOptions<TParentRoute, TPath, TSearchSchemaInput, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn> & {
|
|
21
12
|
caseSensitive?: boolean | undefined;
|
|
22
13
|
wrapInSuspense?: boolean | undefined;
|
|
23
|
-
component?: import(
|
|
24
|
-
errorComponent?: false | import(
|
|
25
|
-
notFoundComponent?: import(
|
|
26
|
-
pendingComponent?: import(
|
|
14
|
+
component?: import('./route').RouteComponent<any> | undefined;
|
|
15
|
+
errorComponent?: false | import('./route').ErrorRouteComponent | null | undefined;
|
|
16
|
+
notFoundComponent?: import('./route').NotFoundRouteComponent | undefined;
|
|
17
|
+
pendingComponent?: import('./route').RouteComponent<any> | undefined;
|
|
27
18
|
pendingMs?: number | undefined;
|
|
28
19
|
pendingMinMs?: number | undefined;
|
|
29
20
|
staleTime?: number | undefined;
|
|
30
21
|
gcTime?: number | undefined;
|
|
31
22
|
preloadStaleTime?: number | undefined;
|
|
32
23
|
preloadGcTime?: number | undefined;
|
|
33
|
-
preSearchFilters?: import(
|
|
34
|
-
postSearchFilters?: import(
|
|
24
|
+
preSearchFilters?: import('./route').SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
|
|
25
|
+
postSearchFilters?: import('./route').SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
|
|
35
26
|
onError?: ((err: any) => void) | undefined;
|
|
36
|
-
onEnter?: ((match: import(
|
|
37
|
-
onStay?: ((match: import(
|
|
38
|
-
onLeave?: ((match: import(
|
|
27
|
+
onEnter?: ((match: import('./Matches').RouteMatch<TId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps>) => void) | undefined;
|
|
28
|
+
onStay?: ((match: import('./Matches').RouteMatch<TId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps>) => void) | undefined;
|
|
29
|
+
onLeave?: ((match: import('./Matches').RouteMatch<TId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps>) => void) | undefined;
|
|
39
30
|
meta?: ((ctx: {
|
|
40
|
-
matches: import(
|
|
31
|
+
matches: import('./Matches').RouteMatch<TId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps>[];
|
|
41
32
|
params: TAllParams;
|
|
42
33
|
loaderData: TLoaderData;
|
|
43
|
-
}) => import(
|
|
44
|
-
links?: (() => import(
|
|
45
|
-
scripts?: (() => import(
|
|
34
|
+
}) => import('react').DetailedHTMLProps<import('react').MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>[]) | undefined;
|
|
35
|
+
links?: (() => import('react').DetailedHTMLProps<import('react').LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>[]) | undefined;
|
|
36
|
+
scripts?: (() => import('react').DetailedHTMLProps<import('react').ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>[]) | undefined;
|
|
46
37
|
headers?: ((ctx: {
|
|
47
38
|
loaderData: TLoaderData;
|
|
48
39
|
}) => Record<string, string>) | undefined;
|
|
49
40
|
} & {
|
|
50
|
-
staticData?: import(
|
|
41
|
+
staticData?: import('./route').StaticDataRouteOption | undefined;
|
|
51
42
|
}) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren>;
|
|
52
43
|
/**
|
|
53
44
|
@deprecated It's no longer recommended to use the `FileRoute` class directly.
|
|
54
45
|
Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
|
|
55
46
|
*/
|
|
56
|
-
export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = TFilePath, TPath extends RouteConstraints['TPath'] =
|
|
47
|
+
export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'], TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'], TFullPath extends RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath']> {
|
|
57
48
|
path: TFilePath;
|
|
58
49
|
silent?: boolean;
|
|
59
50
|
constructor(path: TFilePath, _opts?: {
|
|
60
51
|
silent: boolean;
|
|
61
52
|
});
|
|
62
|
-
createRoute: <TSearchSchemaInput
|
|
63
|
-
caseSensitive?: boolean | undefined;
|
|
64
|
-
wrapInSuspense?: boolean | undefined;
|
|
65
|
-
component?: import("./route").RouteComponent<any> | undefined;
|
|
66
|
-
errorComponent?: false | import("./route").ErrorRouteComponent | null | undefined;
|
|
67
|
-
notFoundComponent?: import("./route").NotFoundRouteComponent | undefined;
|
|
68
|
-
pendingComponent?: import("./route").RouteComponent<any> | undefined;
|
|
69
|
-
pendingMs?: number | undefined;
|
|
70
|
-
pendingMinMs?: number | undefined;
|
|
71
|
-
staleTime?: number | undefined;
|
|
72
|
-
gcTime?: number | undefined;
|
|
73
|
-
preloadStaleTime?: number | undefined;
|
|
74
|
-
preloadGcTime?: number | undefined;
|
|
75
|
-
preSearchFilters?: import("./route").SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
|
|
76
|
-
postSearchFilters?: import("./route").SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
|
|
77
|
-
onError?: ((err: any) => void) | undefined;
|
|
78
|
-
onEnter?: ((match: import("./Matches").RouteMatch<TId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps>) => void) | undefined;
|
|
79
|
-
onStay?: ((match: import("./Matches").RouteMatch<TId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps>) => void) | undefined;
|
|
80
|
-
onLeave?: ((match: import("./Matches").RouteMatch<TId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps>) => void) | undefined;
|
|
81
|
-
meta?: ((ctx: {
|
|
82
|
-
matches: import("./Matches").RouteMatch<TId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps>[];
|
|
83
|
-
params: TAllParams;
|
|
84
|
-
loaderData: TLoaderData;
|
|
85
|
-
}) => import("react").DetailedHTMLProps<import("react").MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>[]) | undefined;
|
|
86
|
-
links?: (() => import("react").DetailedHTMLProps<import("react").LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>[]) | undefined;
|
|
87
|
-
scripts?: (() => import("react").DetailedHTMLProps<import("react").ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>[]) | undefined;
|
|
88
|
-
headers?: ((ctx: {
|
|
89
|
-
loaderData: TLoaderData;
|
|
90
|
-
}) => Record<string, string>) | undefined;
|
|
91
|
-
} & {
|
|
92
|
-
staticData?: import("./route").StaticDataRouteOption | undefined;
|
|
93
|
-
}) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren>;
|
|
53
|
+
createRoute: <TSearchSchemaInput = {}, TSearchSchema = {}, TSearchSchemaUsed = ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema>, TFullSearchSchemaInput = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams = Record<ParsePathParams<TPath>, string>, TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>, TRouteContextReturn = RouteContext, TRouteContext = ResolveRouteContext<TRouteContextReturn>, TAllContext = ResolveAllContext<TParentRoute, TRouteContext>, TRouterContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = ResolveLoaderData<TLoaderDataReturn>, TChildren = unknown>(options?: FileBaseRouteOptions<TParentRoute, TPath, TSearchSchemaInput, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn> & UpdatableRouteOptions<TId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps>) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren>;
|
|
94
54
|
}
|
|
95
55
|
/**
|
|
96
56
|
@deprecated It's recommended not to split loaders into separate files.
|
|
@@ -107,25 +67,24 @@ export declare class LazyRoute<TRoute extends AnyRoute> {
|
|
|
107
67
|
id: string;
|
|
108
68
|
} & LazyRouteOptions);
|
|
109
69
|
useMatch: <TRouteMatch = MakeRouteMatch<any, TRoute["types"]["id"]>, TSelected = TRouteMatch>(opts?: {
|
|
110
|
-
select?: (
|
|
111
|
-
}
|
|
70
|
+
select?: (match: TRouteMatch) => TSelected;
|
|
71
|
+
}) => TSelected;
|
|
112
72
|
useRouteContext: <TSelected = TRoute["types"]["allContext"]>(opts?: {
|
|
113
|
-
select?: (
|
|
114
|
-
}
|
|
73
|
+
select?: (s: TRoute['types']['allContext']) => TSelected;
|
|
74
|
+
}) => TSelected;
|
|
115
75
|
useSearch: <TSelected = TRoute["types"]["fullSearchSchema"]>(opts?: {
|
|
116
|
-
select?: (
|
|
117
|
-
}
|
|
76
|
+
select?: (s: TRoute['types']['fullSearchSchema']) => TSelected;
|
|
77
|
+
}) => TSelected;
|
|
118
78
|
useParams: <TSelected = TRoute["types"]["allParams"]>(opts?: {
|
|
119
|
-
select?: (
|
|
120
|
-
}
|
|
79
|
+
select?: (s: TRoute['types']['allParams']) => TSelected;
|
|
80
|
+
}) => TSelected;
|
|
121
81
|
useLoaderDeps: <TSelected = TRoute["types"]["loaderDeps"]>(opts?: {
|
|
122
|
-
select?: (
|
|
123
|
-
}
|
|
82
|
+
select?: (s: TRoute['types']['loaderDeps']) => TSelected;
|
|
83
|
+
}) => TSelected;
|
|
124
84
|
useLoaderData: <TSelected = TRoute["types"]["loaderData"]>(opts?: {
|
|
125
|
-
select?: (
|
|
126
|
-
}
|
|
127
|
-
useNavigate: () => import(
|
|
85
|
+
select?: (s: TRoute['types']['loaderData']) => TSelected;
|
|
86
|
+
}) => TSelected;
|
|
87
|
+
useNavigate: () => import('./useNavigate').UseNavigateResult<string>;
|
|
128
88
|
}
|
|
129
89
|
export declare function createLazyRoute<TId extends RouteIds<RegisteredRouter['routeTree']>, TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>>(id: TId): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
|
|
130
90
|
export declare function createLazyFileRoute<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(path: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
|
|
131
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\nimport { useLoaderData, useLoaderDeps, useMatch } from './Matches'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport type { ParsePathParams } from './link'\nimport type {\n AnyContext,\n AnyPathParams,\n AnyRoute,\n AnySearchSchema,\n FileBaseRouteOptions,\n MergeFromFromParent,\n ResolveFullPath,\n ResolveFullSearchSchema,\n ResolveFullSearchSchemaInput,\n RootRouteId,\n Route,\n RouteConstraints,\n RouteContext,\n RouteLoaderFn,\n SearchSchemaInput,\n TrimPathLeft,\n UpdatableRouteOptions,\n} from './route'\nimport type { Assign, IsAny } from './utils'\nimport type { MakeRouteMatch } from './Matches'\nimport type { NoInfer } from '@tanstack/react-store'\nimport type { RegisteredRouter } from './router'\nimport type { RouteById, RouteIds } from './routeInfo'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\ntype Replace<\n TValue extends string,\n TFrom extends string,\n TTo extends string,\n TAcc extends string = '',\n> = TValue extends `${infer Start}${TFrom}${infer Rest}`\n ? Replace<Rest, TFrom, TTo, `${TAcc}${Start}${TTo}`>\n : `${TAcc}${TValue}`\n\nexport type TrimLeft<\n TValue extends string,\n TStartsWith extends string,\n> = TValue extends `${TStartsWith}${infer U}` ? U : TValue\n\nexport type TrimRight<\n TValue extends string,\n TEndsWith extends string,\n> = TValue extends `${infer U}${TEndsWith}` ? U : TValue\n\nexport type Trim<TValue extends string, TFind extends string> = TrimLeft<\n TrimRight<TValue, TFind>,\n TFind\n>\n\nexport type RemoveUnderScores<T extends string> = Replace<\n Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>,\n '/_',\n '/'\n>\n\ntype RemoveRouteGroups<T extends string> =\n T extends `${infer Before}(${string})${infer After}`\n ? RemoveRouteGroups<`${Before}${After}`>\n : T\n\ntype NormalizeSlashes<T extends string> =\n T extends `${infer Before}//${infer After}`\n ? NormalizeSlashes<`${Before}/${After}`>\n : T\n\nexport type ResolveFilePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = TParentRoute['id'] extends RootRouteId\n ? TrimPathLeft<TFilePath>\n : TFilePath extends `${TParentRoute['types']['customId']}${infer TRest}`\n ? TRest\n : TFilePath\n\nexport type FileRoutePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n TResolvedFilePath = ResolveFilePath<TParentRoute, TFilePath>,\n> = TResolvedFilePath extends `_${string}`\n ? ''\n : TResolvedFilePath extends `/_${string}`\n ? ''\n : TResolvedFilePath\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = NormalizeSlashes<\n RemoveRouteGroups<TFilePath>\n >,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n NormalizeSlashes<RemoveRouteGroups<RemoveUnderScores<TPath>>>\n >,\n>(path: TFilePath) {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = TFilePath,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n RemoveUnderScores<TPath>\n >,\n> {\n silent?: boolean\n\n constructor(\n public path: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TSearchSchemaInput extends RouteConstraints['TSearchSchema'] = {},\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TSearchSchemaUsed = TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : TSearchSchema,\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TParams = Record<ParsePathParams<TPath>, string>,\n TAllParams = MergeFromFromParent<\n TParentRoute['types']['allParams'],\n TParams\n >,\n TRouteContextReturn extends\n RouteConstraints['TRouteContext'] = RouteContext,\n TRouteContext = [TRouteContextReturn] extends [never]\n ? RouteContext\n : TRouteContextReturn,\n TAllContext = Assign<\n IsAny<TParentRoute['types']['allContext'], {}>,\n TRouteContext\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = unknown,\n TLoaderData = [TLoaderDataReturn] extends [never]\n ? undefined\n : TLoaderDataReturn,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n >(\n options?: FileBaseRouteOptions<\n TParentRoute,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n > &\n UpdatableRouteOptions<\n TId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\n > => {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/** \n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderData>(\n loaderFn: RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TRoute['types']['routeContext'],\n TLoaderData\n >,\n) => RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TRoute['types']['routeContext'],\n NoInfer<TLoaderData>\n> {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n return (loaderFn) => loaderFn\n}\n\nexport type LazyRouteOptions = Pick<\n UpdatableRouteOptions<\n string,\n AnyPathParams,\n AnySearchSchema,\n {},\n AnyContext,\n AnyContext,\n {}\n >,\n 'component' | 'errorComponent' | 'pendingComponent' | 'notFoundComponent'\n>\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n useMatch = <\n TRouteMatch = MakeRouteMatch<\n RegisteredRouter['routeTree'],\n TRoute['types']['id']\n >,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ select: opts?.select, from: this.options.id })\n }\n\n useRouteContext = <TSelected = TRoute['types']['allContext']>(opts?: {\n select?: (s: TRoute['types']['allContext']) => TSelected\n }): TSelected => {\n return useMatch({\n from: this.options.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = TRoute['types']['fullSearchSchema']>(opts?: {\n select?: (s: TRoute['types']['fullSearchSchema']) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.options.id })\n }\n\n useParams = <TSelected = TRoute['types']['allParams']>(opts?: {\n select?: (s: TRoute['types']['allParams']) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.options.id })\n }\n\n useLoaderDeps = <TSelected = TRoute['types']['loaderDeps']>(opts?: {\n select?: (s: TRoute['types']['loaderDeps']) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData = <TSelected = TRoute['types']['loaderData']>(opts?: {\n select?: (s: TRoute['types']['loaderData']) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = () => {\n return useNavigate({ from: this.options.id })\n }\n}\n\nexport function createLazyRoute<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,\n>(id: TId) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({ id: id as any, ...opts })\n }\n}\n\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(path: TFilePath) {\n const id = removeGroups(path)\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n\nconst routeGroupPatternRegex = /\\(.+\\)/g\n\nfunction removeGroups(s: string) {\n return s.replaceAll(routeGroupPatternRegex, '').replaceAll('//', '/')\n}\n"],"names":["opts"],"mappings":";;;;;;AAiGO,SAAS,gBAcd,MAAiB;AACV,SAAA,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EACT,CAAA,EAAE;AACL;AAMO,MAAM,UAYX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CAiCZ,YA6CG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MAAA;AAEI,YAAA,QAAQ,YAAY,OAAc;AACtC,YAAc,SAAS;AAClB,aAAA;AAAA,IAAA;AAxFP,SAAK,SAAS,+BAAO;AAAA,EACvB;AAyFF;AAOO,SAAS,gBAId,OAeA;AACA;AAAA,IACE;AAAA,IACA;AAAA,EAAA;AAEF,SAAO,CAAC,aAAa;AACvB;AAeO,MAAM,UAAmC;AAAA,EAK9C,YACE,MAGA;AAKF,SAAA,WAAW,CAMTA,UAEe;AACR,aAAA,SAAS,EAAE,QAAQA,SAAA,gBAAAA,MAAM,QAAQ,MAAM,KAAK,QAAQ,GAAA,CAAI;AAAA,IAAA;AAGjE,SAAA,kBAAkB,CAA4CA,UAE7C;AACf,aAAO,SAAS;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,QAAQ,CAAC,OAAYA,SAAA,gBAAAA,MAAM,UAASA,MAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAChE;AAAA,IAAA;AAGH,SAAA,YAAY,CAAkDA,UAE7C;AACR,aAAA,UAAU,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAI;AAAA,IAAA;AAGrD,SAAA,YAAY,CAA2CA,UAEtC;AACR,aAAA,UAAU,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAI;AAAA,IAAA;AAGrD,SAAA,gBAAgB,CAA4CA,UAE3C;AACR,aAAA,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAAA;AAGhE,SAAA,gBAAgB,CAA4CA,UAE3C;AACR,aAAA,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAAA;AAGhE,SAAA,cAAc,MAAM;AAClB,aAAO,YAAY,EAAE,MAAM,KAAK,QAAQ,IAAI;AAAA,IAAA;AAlD5C,SAAK,UAAU;AACb,SAAa,WAAW,OAAO,IAAI,YAAY;AAAA,EACnD;AAkDF;AAEO,SAAS,gBAGd,IAAS;AACT,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB,EAAE,IAAe,GAAG,KAAM,CAAA;AAAA,EAAA;AAE3D;AAEO,SAAS,oBAGd,MAAiB;AACX,QAAA,KAAK,aAAa,IAAI;AACrB,SAAA,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;AAEA,MAAM,yBAAyB;AAE/B,SAAS,aAAa,GAAW;AAC/B,SAAO,EAAE,WAAW,wBAAwB,EAAE,EAAE,WAAW,MAAM,GAAG;AACtE;"}
|
|
1
|
+
{"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\nimport { useLoaderData, useLoaderDeps, useMatch } from './Matches'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport type { ParsePathParams } from './link'\nimport type {\n AnyContext,\n AnyPathParams,\n AnyRoute,\n AnySearchSchema,\n FileBaseRouteOptions,\n ResolveAllContext,\n ResolveAllParamsFromParent,\n ResolveFullSearchSchema,\n ResolveFullSearchSchemaInput,\n ResolveLoaderData,\n ResolveRouteContext,\n ResolveSearchSchemaUsed,\n RootRouteId,\n Route,\n RouteConstraints,\n RouteContext,\n RouteLoaderFn,\n SearchSchemaInput,\n TrimPathLeft,\n UpdatableRouteOptions,\n} from './route'\nimport type { Assign, IsAny } from './utils'\nimport type { MakeRouteMatch } from './Matches'\nimport type { NoInfer } from '@tanstack/react-store'\nimport type { RegisteredRouter } from './router'\nimport type { RouteById, RouteIds } from './routeInfo'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n>(path: TFilePath) {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TParams = Record<ParsePathParams<TPath>, string>,\n TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TRouterContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = unknown,\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n >(\n options?: FileBaseRouteOptions<\n TParentRoute,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n > &\n UpdatableRouteOptions<\n TId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\n > => {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/** \n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderData>(\n loaderFn: RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TRoute['types']['routeContext'],\n TLoaderData\n >,\n) => RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TRoute['types']['routeContext'],\n NoInfer<TLoaderData>\n> {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n return (loaderFn) => loaderFn\n}\n\nexport type LazyRouteOptions = Pick<\n UpdatableRouteOptions<\n string,\n AnyPathParams,\n AnySearchSchema,\n {},\n AnyContext,\n AnyContext,\n {}\n >,\n 'component' | 'errorComponent' | 'pendingComponent' | 'notFoundComponent'\n>\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n useMatch = <\n TRouteMatch = MakeRouteMatch<\n RegisteredRouter['routeTree'],\n TRoute['types']['id']\n >,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ select: opts?.select, from: this.options.id })\n }\n\n useRouteContext = <TSelected = TRoute['types']['allContext']>(opts?: {\n select?: (s: TRoute['types']['allContext']) => TSelected\n }): TSelected => {\n return useMatch({\n from: this.options.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = TRoute['types']['fullSearchSchema']>(opts?: {\n select?: (s: TRoute['types']['fullSearchSchema']) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.options.id })\n }\n\n useParams = <TSelected = TRoute['types']['allParams']>(opts?: {\n select?: (s: TRoute['types']['allParams']) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.options.id })\n }\n\n useLoaderDeps = <TSelected = TRoute['types']['loaderDeps']>(opts?: {\n select?: (s: TRoute['types']['loaderDeps']) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData = <TSelected = TRoute['types']['loaderData']>(opts?: {\n select?: (s: TRoute['types']['loaderData']) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = () => {\n return useNavigate({ from: this.options.id })\n }\n}\n\nexport function createLazyRoute<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,\n>(id: TId) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({ id: id as any, ...opts })\n }\n}\n\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(path: TFilePath) {\n const id = removeGroups(path)\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n\nconst routeGroupPatternRegex = /\\(.+\\)/g\n\nfunction removeGroups(s: string) {\n return s.replaceAll(routeGroupPatternRegex, '').replaceAll('//', '/')\n}\n"],"names":["opts"],"mappings":";;;;;;AAyCO,SAAS,gBAOd,MAAiB;AACV,SAAA,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EACT,CAAA,EAAE;AACL;AAMO,MAAM,UAOX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CAuBZ,YA6CG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MAAA;AAEI,YAAA,QAAQ,YAAY,OAAc;AACtC,YAAc,SAAS;AAClB,aAAA;AAAA,IAAA;AA9EP,SAAK,SAAS,+BAAO;AAAA,EACvB;AA+EF;AAOO,SAAS,gBAId,OAeA;AACA;AAAA,IACE;AAAA,IACA;AAAA,EAAA;AAEF,SAAO,CAAC,aAAa;AACvB;AAeO,MAAM,UAAmC;AAAA,EAK9C,YACE,MAGA;AAKF,SAAA,WAAW,CAMTA,UAEe;AACR,aAAA,SAAS,EAAE,QAAQA,SAAA,gBAAAA,MAAM,QAAQ,MAAM,KAAK,QAAQ,GAAA,CAAI;AAAA,IAAA;AAGjE,SAAA,kBAAkB,CAA4CA,UAE7C;AACf,aAAO,SAAS;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,QAAQ,CAAC,OAAYA,SAAA,gBAAAA,MAAM,UAASA,MAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAChE;AAAA,IAAA;AAGH,SAAA,YAAY,CAAkDA,UAE7C;AACR,aAAA,UAAU,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAI;AAAA,IAAA;AAGrD,SAAA,YAAY,CAA2CA,UAEtC;AACR,aAAA,UAAU,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAI;AAAA,IAAA;AAGrD,SAAA,gBAAgB,CAA4CA,UAE3C;AACR,aAAA,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAAA;AAGhE,SAAA,gBAAgB,CAA4CA,UAE3C;AACR,aAAA,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAAA;AAGhE,SAAA,cAAc,MAAM;AAClB,aAAO,YAAY,EAAE,MAAM,KAAK,QAAQ,IAAI;AAAA,IAAA;AAlD5C,SAAK,UAAU;AACb,SAAa,WAAW,OAAO,IAAI,YAAY;AAAA,EACnD;AAkDF;AAEO,SAAS,gBAGd,IAAS;AACT,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB,EAAE,IAAe,GAAG,KAAM,CAAA;AAAA,EAAA;AAE3D;AAEO,SAAS,oBAGd,MAAiB;AACX,QAAA,KAAK,aAAa,IAAI;AACrB,SAAA,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;AAEA,MAAM,yBAAyB;AAE/B,SAAS,aAAa,GAAW;AAC/B,SAAO,EAAE,WAAW,wBAAwB,EAAE,EAAE,WAAW,MAAM,GAAG;AACtE;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,16 +4,16 @@ export { default as warning } from 'tiny-warning';
|
|
|
4
4
|
export { useAwaited, Await, type AwaitOptions } from './awaited.js';
|
|
5
5
|
export { defer, isDehydratedDeferred, type DeferredPromiseState, type DeferredPromise, } from './defer.js';
|
|
6
6
|
export { CatchBoundary, ErrorComponent } from './CatchBoundary.js';
|
|
7
|
-
export { FileRoute, createFileRoute, FileRouteLoader, LazyRoute, createLazyRoute, createLazyFileRoute, type FileRoutesByPath, type
|
|
7
|
+
export { FileRoute, createFileRoute, FileRouteLoader, LazyRoute, createLazyRoute, createLazyFileRoute, type FileRoutesByPath, type LazyRouteOptions, } from './fileRoute.js';
|
|
8
8
|
export * from './history.js';
|
|
9
9
|
export { lazyRouteComponent } from './lazyRouteComponent.js';
|
|
10
|
-
export { useLinkProps, createLink, Link, type CleanPath, type Split, type ParsePathParams, type Join, type Last, type RemoveTrailingSlashes, type RemoveLeadingSlashes, type SearchPaths, type SearchRelativePathAutoComplete, type RelativeToParentPathAutoComplete, type RelativeToCurrentPathAutoComplete, type AbsolutePathAutoComplete, type RelativeToPathAutoComplete, type NavigateOptions, type ToOptions, type ToMaskOptions, type ToSubOptions, type ResolveRoute, type
|
|
10
|
+
export { useLinkProps, createLink, Link, type CleanPath, type Split, type ParsePathParams, type Join, type Last, type RemoveTrailingSlashes, type RemoveLeadingSlashes, type SearchPaths, type SearchRelativePathAutoComplete, type RelativeToParentPathAutoComplete, type RelativeToCurrentPathAutoComplete, type AbsolutePathAutoComplete, type RelativeToPathAutoComplete, type NavigateOptions, type ToOptions, type ToMaskOptions, type ToSubOptions, type ResolveRoute, type SearchParamOptions, type PathParamOptions, type ToPathOption, type ActiveOptions, type LinkOptions, type CheckPath, type ResolveRelativePath, type UseLinkPropsOptions, type ActiveLinkOptions, type LinkProps, type LinkComponent, } from './link.js';
|
|
11
11
|
export { type ParsedLocation } from './location.js';
|
|
12
12
|
export { matchContext, Matches, Match, Outlet, useMatchRoute, MatchRoute, useMatch, useMatches, useParentMatches, useChildMatches, useLoaderDeps, useLoaderData, isServerSideError, defaultDeserializeError, type RouteMatch, type AnyRouteMatch, type MatchRouteOptions, type UseMatchRouteOptions, type MakeMatchRouteOptions, } from './Matches.js';
|
|
13
13
|
export { joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, parsePathname, interpolatePath, matchPathname, removeBasepath, matchByPath, type Segment, } from './path.js';
|
|
14
14
|
export { encode, decode } from './qss.js';
|
|
15
15
|
export { redirect, isRedirect, type AnyRedirect, type Redirect, type ResolvedRedirect, } from './redirects.js';
|
|
16
|
-
export { rootRouteId, RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, type RootRouteId, type AnyPathParams, type SearchSchemaInput, type AnySearchSchema, type AnyContext, type RouteContext, type PreloadableObj, type RoutePathOptions, type StaticDataRouteOption, type RoutePathOptionsIntersection, type RouteOptions, type ParamsFallback, type FileBaseRouteOptions, type BaseRouteOptions, type UpdatableRouteOptions, type UpdatableStaticRouteOption, type MetaDescriptor, type RouteLinkEntry, type ParseParamsOption, type ParseParamsFn, type ParseParamsObj, type SearchSchemaValidator, type SearchSchemaValidatorObj, type SearchSchemaValidatorFn, type RouteLoaderFn, type LoaderFnContext, type SearchFilter, type ResolveId, type InferFullSearchSchema, type InferFullSearchSchemaInput, type ResolveFullSearchSchema, type ResolveFullSearchSchemaInput, type AnyRoute, type
|
|
16
|
+
export { rootRouteId, RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, type RootRouteId, type AnyPathParams, type SearchSchemaInput, type AnySearchSchema, type AnyContext, type RouteContext, type PreloadableObj, type RoutePathOptions, type StaticDataRouteOption, type RoutePathOptionsIntersection, type RouteOptions, type ParamsFallback, type FileBaseRouteOptions, type BaseRouteOptions, type UpdatableRouteOptions, type UpdatableStaticRouteOption, type MetaDescriptor, type RouteLinkEntry, type ParseParamsOption, type ParseParamsFn, type ParseParamsObj, type SearchSchemaValidator, type SearchSchemaValidatorObj, type SearchSchemaValidatorFn, type RouteLoaderFn, type LoaderFnContext, type SearchFilter, type ResolveId, type InferFullSearchSchema, type InferFullSearchSchemaInput, type ResolveFullSearchSchema, type ResolveFullSearchSchemaInput, type AnyRoute, type ResolveAllParams, type RouteConstraints, type AnyRootRoute, type RootSearchSchema, type ResolveFullPath, type RouteMask, type ErrorRouteProps, type ErrorComponentProps, type NotFoundRouteProps, type ReactNode, type SyncRouteComponent, type AsyncRouteComponent, type RouteComponent, type ErrorRouteComponent, type NotFoundRouteComponent, type TrimPath, type TrimPathLeft, type TrimPathRight, type RootRouteOptions, } from './route.js';
|
|
17
17
|
export { type ParseRoute, type RoutesById, type RouteById, type RouteIds, type RoutesByPath, type RouteByPath, type RoutePaths, type RoutePathsAutoComplete, type FullSearchSchema, type AllParams, } from './routeInfo.js';
|
|
18
18
|
export { componentTypes, createRouter, Router, lazyFn, SearchParamError, PathParamError, getInitialRouterState, defaultSerializeError, type Register, type AnyRouter, type RegisteredRouter, type HydrationCtx, type RouterContextOptions, type RouterOptions, type RouterTransformer, type RouterErrorSerializer, type RouterState, type ListenerFn, type BuildNextOptions, type DehydratedRouterState, type DehydratedRouteMatch, type DehydratedRouter, type RouterConstructorOptions, type RouterEvents, type RouterEvent, type RouterListener, } from './router.js';
|
|
19
19
|
export { RouterProvider, RouterContextProvider, getRouteMatch, type RouterProps, type CommitLocationOptions, type MatchLocation, type NavigateFn, type BuildLocationFn, type InjectedHtmlEntry, } from './RouterProvider.js';
|
|
@@ -27,6 +27,7 @@ export { getRouterContext, } from './routerContext.js';
|
|
|
27
27
|
export { useRouteContext } from './useRouteContext.js';
|
|
28
28
|
export { useRouter } from './useRouter.js';
|
|
29
29
|
export { useRouterState } from './useRouterState.js';
|
|
30
|
+
export { useLocation } from './useLocation.js';
|
|
30
31
|
export { escapeJSON, // SSR
|
|
31
32
|
useLayoutEffect, // SSR
|
|
32
33
|
pick, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, useStableCallback, shallow, } from './utils';
|
package/dist/esm/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { getRouterContext } from "./routerContext.js";
|
|
|
24
24
|
import { useRouteContext } from "./useRouteContext.js";
|
|
25
25
|
import { useRouter } from "./useRouter.js";
|
|
26
26
|
import { useRouterState } from "./useRouterState.js";
|
|
27
|
+
import { useLocation } from "./useLocation.js";
|
|
27
28
|
import { deepEqual, escapeJSON, functionalUpdate, isPlainArray, isPlainObject, pick, replaceEqualDeep, shallow, useLayoutEffect, useStableCallback } from "./utils.js";
|
|
28
29
|
import { CatchNotFound, DefaultGlobalNotFound, isNotFound, notFound } from "./not-found.js";
|
|
29
30
|
export {
|
|
@@ -118,6 +119,7 @@ export {
|
|
|
118
119
|
useLinkProps,
|
|
119
120
|
useLoaderData,
|
|
120
121
|
useLoaderDeps,
|
|
122
|
+
useLocation,
|
|
121
123
|
useMatch,
|
|
122
124
|
useMatchRoute,
|
|
123
125
|
useMatches,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AsyncRouteComponent } from './route.js';
|
|
2
|
+
|
|
2
3
|
export declare function lazyRouteComponent<T extends Record<string, any>, TKey extends keyof T = 'default'>(importer: () => Promise<T>, exportName?: TKey): T[TKey] extends (props: infer TProps) => any ? AsyncRouteComponent<TProps> : never;
|