@tanstack/react-router 1.20.1 → 1.20.3-alpha.1
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/README.md +31 -0
- package/dist/cjs/Asset.cjs +41 -0
- package/dist/cjs/Asset.cjs.map +1 -0
- package/dist/cjs/Asset.d.cts +2 -0
- package/dist/cjs/CatchBoundary.cjs +16 -12
- package/dist/cjs/CatchBoundary.cjs.map +1 -1
- package/dist/cjs/CatchBoundary.d.cts +8 -32
- package/dist/cjs/ClientOnly.cjs +20 -0
- package/dist/cjs/ClientOnly.cjs.map +1 -0
- package/dist/cjs/ClientOnly.d.cts +29 -0
- package/dist/cjs/HeadContent.cjs +155 -0
- package/dist/cjs/HeadContent.cjs.map +1 -0
- package/dist/cjs/HeadContent.d.cts +7 -0
- package/dist/cjs/Match.cjs +252 -0
- package/dist/cjs/Match.cjs.map +1 -0
- package/dist/cjs/Match.d.cts +8 -0
- package/dist/cjs/Matches.cjs +39 -287
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +23 -83
- package/dist/cjs/RouterProvider.cjs +17 -140
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +8 -27
- package/dist/cjs/SafeFragment.cjs +8 -0
- package/dist/cjs/SafeFragment.cjs.map +1 -0
- package/dist/cjs/SafeFragment.d.cts +1 -0
- package/dist/cjs/ScriptOnce.cjs +28 -0
- package/dist/cjs/ScriptOnce.cjs.map +1 -0
- package/dist/cjs/ScriptOnce.d.cts +5 -0
- package/dist/cjs/Scripts.cjs +51 -0
- package/dist/cjs/Scripts.cjs.map +1 -0
- package/dist/cjs/Scripts.d.cts +1 -0
- package/dist/cjs/ScrollRestoration.cjs +39 -0
- package/dist/cjs/ScrollRestoration.cjs.map +1 -0
- package/dist/cjs/ScrollRestoration.d.cts +14 -0
- package/dist/cjs/Transitioner.cjs +115 -0
- package/dist/cjs/Transitioner.cjs.map +1 -0
- package/dist/cjs/Transitioner.d.cts +1 -0
- package/dist/cjs/awaited.cjs +12 -65
- package/dist/cjs/awaited.cjs.map +1 -1
- package/dist/cjs/awaited.d.cts +4 -4
- package/dist/cjs/fileRoute.cjs +41 -15
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +33 -108
- package/dist/cjs/history.d.cts +1 -0
- package/dist/cjs/index.cjs +216 -73
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +52 -29
- package/dist/cjs/lazyRouteComponent.cjs +40 -29
- package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
- package/dist/cjs/lazyRouteComponent.d.cts +1 -1
- package/dist/cjs/link.cjs +212 -106
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +41 -86
- package/dist/cjs/matchContext.cjs +27 -0
- package/dist/cjs/matchContext.cjs.map +1 -0
- package/dist/cjs/matchContext.d.cts +3 -0
- package/dist/cjs/not-found.cjs +9 -15
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +5 -22
- package/dist/cjs/renderRouteNotFound.cjs +22 -0
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -0
- package/dist/cjs/renderRouteNotFound.d.cts +2 -0
- package/dist/cjs/route.cjs +110 -79
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +64 -361
- package/dist/cjs/router.cjs +12 -1237
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +69 -237
- package/dist/cjs/routerContext.cjs +1 -1
- package/dist/cjs/routerContext.cjs.map +1 -1
- package/dist/cjs/routerContext.d.cts +7 -2
- package/dist/cjs/scroll-restoration.cjs +16 -177
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.d.cts +1 -18
- package/dist/cjs/serializer.d.cts +6 -0
- package/dist/cjs/structuralSharing.d.cts +8 -0
- package/dist/cjs/typePrimitives.d.cts +16 -0
- package/dist/cjs/useBlocker.cjs +138 -9
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useBlocker.d.cts +64 -7
- package/dist/cjs/useCanGoBack.cjs +8 -0
- package/dist/cjs/useCanGoBack.cjs.map +1 -0
- package/dist/cjs/useCanGoBack.d.cts +1 -0
- package/dist/cjs/useLoaderData.cjs +15 -0
- package/dist/cjs/useLoaderData.cjs.map +1 -0
- package/dist/cjs/useLoaderData.d.cts +8 -0
- package/dist/cjs/useLoaderDeps.cjs +14 -0
- package/dist/cjs/useLoaderDeps.cjs.map +1 -0
- package/dist/cjs/useLoaderDeps.d.cts +8 -0
- package/dist/cjs/useLocation.cjs +10 -0
- package/dist/cjs/useLocation.cjs.map +1 -0
- package/dist/cjs/useLocation.d.cts +7 -0
- package/dist/cjs/useMatch.cjs +47 -0
- package/dist/cjs/useMatch.cjs.map +1 -0
- package/dist/cjs/useMatch.d.cts +10 -0
- package/dist/cjs/useNavigate.cjs +18 -19
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +4 -8
- package/dist/cjs/useParams.cjs +8 -8
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +9 -8
- package/dist/cjs/useRouteContext.cjs +3 -3
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouteContext.d.cts +3 -7
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouter.d.cts +3 -4
- package/dist/cjs/useRouterState.cjs +18 -1
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useRouterState.d.cts +8 -6
- package/dist/cjs/useSearch.cjs +7 -4
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +9 -7
- package/dist/cjs/utils.cjs +40 -122
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +46 -50
- package/dist/esm/Asset.d.ts +2 -0
- package/dist/esm/Asset.js +41 -0
- package/dist/esm/Asset.js.map +1 -0
- package/dist/esm/CatchBoundary.d.ts +8 -32
- package/dist/esm/CatchBoundary.js +16 -12
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ClientOnly.d.ts +29 -0
- package/dist/esm/ClientOnly.js +20 -0
- package/dist/esm/ClientOnly.js.map +1 -0
- package/dist/esm/HeadContent.d.ts +7 -0
- package/dist/esm/HeadContent.js +139 -0
- package/dist/esm/HeadContent.js.map +1 -0
- package/dist/esm/Match.d.ts +8 -0
- package/dist/esm/Match.js +235 -0
- package/dist/esm/Match.js.map +1 -0
- package/dist/esm/Matches.d.ts +23 -83
- package/dist/esm/Matches.js +36 -284
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +8 -27
- package/dist/esm/RouterProvider.js +20 -126
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/SafeFragment.d.ts +1 -0
- package/dist/esm/SafeFragment.js +8 -0
- package/dist/esm/SafeFragment.js.map +1 -0
- package/dist/esm/ScriptOnce.d.ts +5 -0
- package/dist/esm/ScriptOnce.js +28 -0
- package/dist/esm/ScriptOnce.js.map +1 -0
- package/dist/esm/Scripts.d.ts +1 -0
- package/dist/esm/Scripts.js +51 -0
- package/dist/esm/Scripts.js.map +1 -0
- package/dist/esm/ScrollRestoration.d.ts +14 -0
- package/dist/esm/ScrollRestoration.js +39 -0
- package/dist/esm/ScrollRestoration.js.map +1 -0
- package/dist/esm/Transitioner.d.ts +1 -0
- package/dist/esm/Transitioner.js +98 -0
- package/dist/esm/Transitioner.js.map +1 -0
- package/dist/esm/awaited.d.ts +4 -4
- package/dist/esm/awaited.js +12 -65
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +33 -108
- package/dist/esm/fileRoute.js +38 -12
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/history.d.ts +1 -0
- package/dist/esm/index.d.ts +52 -29
- package/dist/esm/index.js +41 -29
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lazyRouteComponent.d.ts +1 -1
- package/dist/esm/lazyRouteComponent.js +40 -29
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.d.ts +41 -86
- package/dist/esm/link.js +212 -106
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.d.ts +3 -0
- package/dist/esm/matchContext.js +10 -0
- package/dist/esm/matchContext.js.map +1 -0
- package/dist/esm/not-found.d.ts +5 -22
- package/dist/esm/not-found.js +9 -15
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.d.ts +2 -0
- package/dist/esm/renderRouteNotFound.js +22 -0
- package/dist/esm/renderRouteNotFound.js.map +1 -0
- package/dist/esm/route.d.ts +64 -361
- package/dist/esm/route.js +103 -72
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +69 -237
- package/dist/esm/router.js +13 -1238
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +7 -2
- package/dist/esm/routerContext.js +1 -1
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.d.ts +1 -18
- package/dist/esm/scroll-restoration.js +17 -161
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/serializer.d.ts +6 -0
- package/dist/esm/structuralSharing.d.ts +8 -0
- package/dist/esm/typePrimitives.d.ts +16 -0
- package/dist/esm/useBlocker.d.ts +64 -7
- package/dist/esm/useBlocker.js +138 -9
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useCanGoBack.d.ts +1 -0
- package/dist/esm/useCanGoBack.js +8 -0
- package/dist/esm/useCanGoBack.js.map +1 -0
- package/dist/esm/useLoaderData.d.ts +8 -0
- package/dist/esm/useLoaderData.js +15 -0
- package/dist/esm/useLoaderData.js.map +1 -0
- package/dist/esm/useLoaderDeps.d.ts +8 -0
- package/dist/esm/useLoaderDeps.js +14 -0
- package/dist/esm/useLoaderDeps.js.map +1 -0
- package/dist/esm/useLocation.d.ts +7 -0
- package/dist/esm/useLocation.js +10 -0
- package/dist/esm/useLocation.js.map +1 -0
- package/dist/esm/useMatch.d.ts +10 -0
- package/dist/esm/useMatch.js +30 -0
- package/dist/esm/useMatch.js.map +1 -0
- package/dist/esm/useNavigate.d.ts +4 -8
- package/dist/esm/useNavigate.js +18 -19
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.d.ts +9 -8
- package/dist/esm/useParams.js +8 -8
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.d.ts +3 -7
- package/dist/esm/useRouteContext.js +2 -2
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouter.d.ts +3 -4
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.d.ts +8 -6
- package/dist/esm/useRouterState.js +18 -1
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.d.ts +9 -7
- package/dist/esm/useSearch.js +6 -3
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +46 -50
- package/dist/esm/utils.js +41 -123
- package/dist/esm/utils.js.map +1 -1
- package/package.json +30 -31
- package/src/Asset.tsx +40 -0
- package/src/CatchBoundary.tsx +35 -19
- package/src/ClientOnly.tsx +68 -0
- package/src/HeadContent.tsx +174 -0
- package/src/Match.tsx +330 -0
- package/src/Matches.tsx +149 -558
- package/src/RouterProvider.tsx +58 -212
- package/src/SafeFragment.tsx +5 -0
- package/src/ScriptOnce.tsx +32 -0
- package/src/Scripts.tsx +65 -0
- package/src/ScrollRestoration.tsx +69 -0
- package/src/Transitioner.tsx +130 -0
- package/src/awaited.tsx +16 -87
- package/src/fileRoute.ts +145 -248
- package/src/history.ts +2 -1
- package/src/index.tsx +368 -30
- package/src/lazyRouteComponent.tsx +68 -54
- package/src/link.tsx +397 -522
- package/src/matchContext.tsx +8 -0
- package/src/not-found.tsx +13 -34
- package/src/renderRouteNotFound.tsx +27 -0
- package/src/route.tsx +572 -0
- package/src/router.ts +99 -2067
- package/src/routerContext.tsx +8 -2
- package/src/scroll-restoration.tsx +23 -224
- package/src/serializer.ts +7 -0
- package/src/structuralSharing.ts +47 -0
- package/src/typePrimitives.ts +84 -0
- package/src/useBlocker.tsx +297 -15
- package/src/useCanGoBack.ts +5 -0
- package/src/useLoaderData.tsx +80 -0
- package/src/useLoaderDeps.tsx +58 -0
- package/src/useLocation.tsx +41 -0
- package/src/useMatch.tsx +119 -0
- package/src/useNavigate.tsx +41 -61
- package/src/useParams.tsx +88 -23
- package/src/useRouteContext.ts +24 -18
- package/src/useRouter.tsx +4 -5
- package/src/useRouterState.tsx +52 -10
- package/src/useSearch.tsx +87 -24
- package/src/utils.ts +97 -312
- package/dist/cjs/createServerFn.cjs +0 -40
- package/dist/cjs/createServerFn.cjs.map +0 -1
- package/dist/cjs/createServerFn.d.cts +0 -44
- package/dist/cjs/defer.cjs +0 -30
- package/dist/cjs/defer.cjs.map +0 -1
- package/dist/cjs/defer.d.cts +0 -25
- package/dist/cjs/location.d.cts +0 -12
- package/dist/cjs/path.cjs +0 -213
- package/dist/cjs/path.cjs.map +0 -1
- package/dist/cjs/path.d.cts +0 -24
- package/dist/cjs/qss.cjs +0 -45
- package/dist/cjs/qss.cjs.map +0 -1
- package/dist/cjs/qss.d.cts +0 -2
- package/dist/cjs/redirects.cjs +0 -16
- package/dist/cjs/redirects.cjs.map +0 -1
- package/dist/cjs/redirects.d.cts +0 -18
- package/dist/cjs/routeInfo.d.cts +0 -31
- package/dist/cjs/searchParams.cjs +0 -63
- package/dist/cjs/searchParams.cjs.map +0 -1
- package/dist/cjs/searchParams.d.cts +0 -7
- package/dist/esm/createServerFn.d.ts +0 -44
- package/dist/esm/createServerFn.js +0 -40
- package/dist/esm/createServerFn.js.map +0 -1
- package/dist/esm/defer.d.ts +0 -25
- package/dist/esm/defer.js +0 -30
- package/dist/esm/defer.js.map +0 -1
- package/dist/esm/location.d.ts +0 -12
- package/dist/esm/path.d.ts +0 -24
- package/dist/esm/path.js +0 -213
- package/dist/esm/path.js.map +0 -1
- package/dist/esm/qss.d.ts +0 -2
- package/dist/esm/qss.js +0 -45
- package/dist/esm/qss.js.map +0 -1
- package/dist/esm/redirects.d.ts +0 -18
- package/dist/esm/redirects.js +0 -16
- package/dist/esm/redirects.js.map +0 -1
- package/dist/esm/routeInfo.d.ts +0 -31
- package/dist/esm/searchParams.d.ts +0 -7
- package/dist/esm/searchParams.js +0 -63
- package/dist/esm/searchParams.js.map +0 -1
- package/src/createServerFn.ts +0 -107
- package/src/defer.ts +0 -70
- package/src/location.ts +0 -13
- package/src/path.ts +0 -280
- package/src/qss.ts +0 -53
- package/src/redirects.ts +0 -56
- package/src/route.ts +0 -1356
- package/src/routeInfo.ts +0 -63
- package/src/searchParams.ts +0 -79
package/dist/esm/fileRoute.d.ts
CHANGED
|
@@ -1,103 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AnyRoute,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
export interface FileRoutesByPath {
|
|
10
|
-
}
|
|
11
|
-
type Replace<S extends string, From extends string, To extends string> = S extends `${infer Start}${From}${infer Rest}` ? `${Start}${To}${Replace<Rest, From, To>}` : S;
|
|
12
|
-
export type TrimLeft<T extends string, S extends string> = T extends `${S}${infer U}` ? U : T;
|
|
13
|
-
export type TrimRight<T extends string, S extends string> = T extends `${infer U}${S}` ? U : T;
|
|
14
|
-
export type Trim<T extends string, S extends string> = TrimLeft<TrimRight<T, S>, S>;
|
|
15
|
-
export type RemoveUnderScores<T extends string> = Replace<Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>, '/_', '/'>;
|
|
16
|
-
type RemoveRouteGroups<S extends string> = S extends `${infer Before}(${infer RouteGroup})${infer After}` ? RemoveRouteGroups<`${Before}${After}`> : S;
|
|
17
|
-
type NormalizeSlashes<S extends string> = S extends `${infer Before}//${infer After}` ? NormalizeSlashes<`${Before}/${After}`> : S;
|
|
18
|
-
type ReplaceFirstOccurrence<T extends string, Search extends string, Replacement extends string> = T extends `${infer Prefix}${Search}${infer Suffix}` ? `${Prefix}${Replacement}${Suffix}` : T;
|
|
19
|
-
export type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : ReplaceFirstOccurrence<TrimPathLeft<TFilePath>, TrimPathLeft<TParentRoute['types']['customId']>, ''>;
|
|
20
|
-
export type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends string> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}` ? '' : ResolveFilePath<TParentRoute, TFilePath> extends `/_${infer _}` ? '' : ResolveFilePath<TParentRoute, TFilePath>;
|
|
21
|
-
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 extends Record<string, any> = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, "__TSearchSchemaInput__"> : TSearchSchema, TFullSearchSchemaInput extends AnySearchSchema = Expand<Assign<Omit<import("./route").InferFullSearchSchemaInput<TParentRoute>, "__TRootSearchSchema__">, TSearchSchemaUsed>>, TFullSearchSchema extends AnySearchSchema = Expand<Assign<Omit<import("./route").InferFullSearchSchema<TParentRoute>, "__TRootSearchSchema__">, TSearchSchema>>, TParams extends Record<string, any> = Expand<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 extends Record<string, any> = IsAny<TParentRoute["types"]["allParams"], TParams, TParentRoute["types"]["allParams"] & TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TAllContext extends Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}, TParentRoute["types"]["allContext"]>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}, TParentRoute["types"]["allContext"]>, TRouteContext>>, TRouterContext extends AnyContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn extends unknown = unknown, TLoaderData extends unknown = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options?: (FileBaseRouteOptions<TParentRoute, TPath, TSearchSchemaInput, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn> & {
|
|
22
|
-
caseSensitive?: boolean | undefined;
|
|
23
|
-
wrapInSuspense?: boolean | undefined;
|
|
24
|
-
component?: import("./route").RouteComponent<any> | undefined;
|
|
25
|
-
errorComponent?: false | import("./route").ErrorRouteComponent | null | undefined;
|
|
26
|
-
notFoundComponent?: import("./route").NotFoundRouteComponent | undefined;
|
|
27
|
-
pendingComponent?: import("./route").RouteComponent<any> | undefined;
|
|
28
|
-
pendingMs?: number | undefined;
|
|
29
|
-
pendingMinMs?: number | undefined;
|
|
30
|
-
staleTime?: number | undefined;
|
|
31
|
-
gcTime?: number | undefined;
|
|
32
|
-
preloadStaleTime?: number | undefined;
|
|
33
|
-
preloadGcTime?: number | undefined;
|
|
34
|
-
preSearchFilters?: import("./route").SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
|
|
35
|
-
postSearchFilters?: import("./route").SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
|
|
36
|
-
onError?: ((err: any) => void) | undefined;
|
|
37
|
-
onEnter?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
|
|
38
|
-
onStay?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
|
|
39
|
-
onLeave?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
|
|
40
|
-
meta?: ((ctx: {
|
|
41
|
-
params: TAllParams;
|
|
42
|
-
loaderData: TLoaderData;
|
|
43
|
-
}) => import("react").DetailedHTMLProps<import("react").MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>[] | Promise<import("react").DetailedHTMLProps<import("react").MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>[]>) | undefined;
|
|
44
|
-
links?: (() => import("react").DetailedHTMLProps<import("react").LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>[]) | undefined;
|
|
45
|
-
scripts?: (() => import("react").DetailedHTMLProps<import("react").ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>[]) | undefined;
|
|
46
|
-
headers?: ((ctx: {
|
|
47
|
-
loaderData: TLoaderData;
|
|
48
|
-
}) => Record<string, string> | Promise<Record<string, string>>) | undefined;
|
|
49
|
-
} & {
|
|
50
|
-
staticData?: import("./route").StaticDataRouteOption | undefined;
|
|
51
|
-
}) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren, TRouteTree>;
|
|
1
|
+
import { UseParamsRoute } from './useParams.js';
|
|
2
|
+
import { UseMatchRoute } from './useMatch.js';
|
|
3
|
+
import { UseSearchRoute } from './useSearch.js';
|
|
4
|
+
import { AnyContext, AnyRoute, AnyRouter, Constrain, ConstrainLiteral, FileBaseRouteOptions, FileRoutesByPath, LazyRouteOptions, RegisteredRouter, ResolveParams, Route, RouteById, RouteConstraints, RouteIds, RouteLoaderFn, UpdatableRouteOptions, UseNavigateResult } from '@tanstack/router-core';
|
|
5
|
+
import { UseLoaderDepsRoute } from './useLoaderDeps.js';
|
|
6
|
+
import { UseLoaderDataRoute } from './useLoaderData.js';
|
|
7
|
+
import { UseRouteContextRoute } from './useRouteContext.js';
|
|
8
|
+
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): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'];
|
|
52
9
|
/**
|
|
53
10
|
@deprecated It's no longer recommended to use the `FileRoute` class directly.
|
|
54
11
|
Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
|
|
55
12
|
*/
|
|
56
|
-
export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = TFilePath, TPath extends RouteConstraints['TPath'] =
|
|
57
|
-
path
|
|
13
|
+
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']> {
|
|
14
|
+
path?: TFilePath | undefined;
|
|
58
15
|
silent?: boolean;
|
|
59
|
-
constructor(path
|
|
16
|
+
constructor(path?: TFilePath | undefined, _opts?: {
|
|
60
17
|
silent: boolean;
|
|
61
18
|
});
|
|
62
|
-
createRoute: <
|
|
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").AnyRouteMatch) => void) | undefined;
|
|
79
|
-
onStay?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
|
|
80
|
-
onLeave?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
|
|
81
|
-
meta?: ((ctx: {
|
|
82
|
-
params: TAllParams;
|
|
83
|
-
loaderData: TLoaderData;
|
|
84
|
-
}) => import("react").DetailedHTMLProps<import("react").MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>[] | Promise<import("react").DetailedHTMLProps<import("react").MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>[]>) | undefined;
|
|
85
|
-
links?: (() => import("react").DetailedHTMLProps<import("react").LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>[]) | undefined;
|
|
86
|
-
scripts?: (() => import("react").DetailedHTMLProps<import("react").ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>[]) | undefined;
|
|
87
|
-
headers?: ((ctx: {
|
|
88
|
-
loaderData: TLoaderData;
|
|
89
|
-
}) => Record<string, string> | Promise<Record<string, string>>) | undefined;
|
|
90
|
-
} & {
|
|
91
|
-
staticData?: import("./route").StaticDataRouteOption | undefined;
|
|
92
|
-
}) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren, TRouteTree>;
|
|
19
|
+
createRoute: <TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown>(options?: FileBaseRouteOptions<TParentRoute, TId, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn> & UpdatableRouteOptions<TParentRoute, TId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, AnyContext, TRouteContextFn, TBeforeLoadFn>) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, unknown>;
|
|
93
20
|
}
|
|
94
21
|
/**
|
|
95
22
|
@deprecated It's recommended not to split loaders into separate files.
|
|
96
23
|
Instead, place the loader function in the the main route file, inside the
|
|
97
24
|
`createFileRoute('/path/to/file)(options)` options.
|
|
98
25
|
*/
|
|
99
|
-
export declare function FileRouteLoader<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(_path: TFilePath): <
|
|
100
|
-
|
|
26
|
+
export declare function FileRouteLoader<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(_path: TFilePath): <TLoaderFn>(loaderFn: Constrain<TLoaderFn, RouteLoaderFn<TRoute['parentRoute'], TRoute['types']['id'], TRoute['types']['params'], TRoute['types']['loaderDeps'], TRoute['types']['routerContext'], TRoute['types']['routeContextFn'], TRoute['types']['beforeLoadFn']>>) => TLoaderFn;
|
|
27
|
+
declare module '@tanstack/router-core' {
|
|
28
|
+
interface LazyRoute<in out TRoute extends AnyRoute> {
|
|
29
|
+
useMatch: UseMatchRoute<TRoute['id']>;
|
|
30
|
+
useRouteContext: UseRouteContextRoute<TRoute['id']>;
|
|
31
|
+
useSearch: UseSearchRoute<TRoute['id']>;
|
|
32
|
+
useParams: UseParamsRoute<TRoute['id']>;
|
|
33
|
+
useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>;
|
|
34
|
+
useLoaderData: UseLoaderDataRoute<TRoute['id']>;
|
|
35
|
+
useNavigate: () => UseNavigateResult<TRoute['fullPath']>;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
101
38
|
export declare class LazyRoute<TRoute extends AnyRoute> {
|
|
102
39
|
options: {
|
|
103
40
|
id: string;
|
|
@@ -105,25 +42,13 @@ export declare class LazyRoute<TRoute extends AnyRoute> {
|
|
|
105
42
|
constructor(opts: {
|
|
106
43
|
id: string;
|
|
107
44
|
} & LazyRouteOptions);
|
|
108
|
-
useMatch: <
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
select?: ((s: TRoute['types']['fullSearchSchema']) => TSelected) | undefined;
|
|
116
|
-
} | undefined) => TSelected;
|
|
117
|
-
useParams: <TSelected = TRoute["types"]["allParams"]>(opts?: {
|
|
118
|
-
select?: ((s: TRoute['types']['allParams']) => TSelected) | undefined;
|
|
119
|
-
} | undefined) => TSelected;
|
|
120
|
-
useLoaderDeps: <TSelected = TRoute["types"]["loaderDeps"]>(opts?: {
|
|
121
|
-
select?: ((s: TRoute['types']['loaderDeps']) => TSelected) | undefined;
|
|
122
|
-
} | undefined) => TSelected;
|
|
123
|
-
useLoaderData: <TSelected = TRoute["types"]["loaderData"]>(opts?: {
|
|
124
|
-
select?: ((s: TRoute['types']['loaderData']) => TSelected) | undefined;
|
|
125
|
-
} | undefined) => TSelected;
|
|
45
|
+
useMatch: UseMatchRoute<TRoute['id']>;
|
|
46
|
+
useRouteContext: UseRouteContextRoute<TRoute['id']>;
|
|
47
|
+
useSearch: UseSearchRoute<TRoute['id']>;
|
|
48
|
+
useParams: UseParamsRoute<TRoute['id']>;
|
|
49
|
+
useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>;
|
|
50
|
+
useLoaderData: UseLoaderDataRoute<TRoute['id']>;
|
|
51
|
+
useNavigate: () => UseNavigateResult<TRoute["fullPath"]>;
|
|
126
52
|
}
|
|
127
|
-
export declare function createLazyRoute<
|
|
128
|
-
export declare function createLazyFileRoute<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(
|
|
129
|
-
export {};
|
|
53
|
+
export declare function createLazyRoute<TRouter extends AnyRouter = RegisteredRouter, TId extends string = string, TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
|
|
54
|
+
export declare function createLazyFileRoute<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
|
package/dist/esm/fileRoute.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import warning from "tiny-warning";
|
|
1
2
|
import { createRoute } from "./route.js";
|
|
2
|
-
import { useMatch
|
|
3
|
+
import { useMatch } from "./useMatch.js";
|
|
4
|
+
import { useLoaderDeps } from "./useLoaderDeps.js";
|
|
5
|
+
import { useLoaderData } from "./useLoaderData.js";
|
|
3
6
|
import { useSearch } from "./useSearch.js";
|
|
4
7
|
import { useParams } from "./useParams.js";
|
|
5
|
-
import
|
|
8
|
+
import { useNavigate } from "./useNavigate.js";
|
|
9
|
+
import { useRouter } from "./useRouter.js";
|
|
6
10
|
function createFileRoute(path) {
|
|
11
|
+
if (typeof path === "object") {
|
|
12
|
+
return new FileRoute(path, {
|
|
13
|
+
silent: true
|
|
14
|
+
}).createRoute(path);
|
|
15
|
+
}
|
|
7
16
|
return new FileRoute(path, {
|
|
8
17
|
silent: true
|
|
9
18
|
}).createRoute;
|
|
@@ -33,7 +42,11 @@ function FileRouteLoader(_path) {
|
|
|
33
42
|
class LazyRoute {
|
|
34
43
|
constructor(opts) {
|
|
35
44
|
this.useMatch = (opts2) => {
|
|
36
|
-
return useMatch({
|
|
45
|
+
return useMatch({
|
|
46
|
+
select: opts2 == null ? void 0 : opts2.select,
|
|
47
|
+
from: this.options.id,
|
|
48
|
+
structuralSharing: opts2 == null ? void 0 : opts2.structuralSharing
|
|
49
|
+
});
|
|
37
50
|
};
|
|
38
51
|
this.useRouteContext = (opts2) => {
|
|
39
52
|
return useMatch({
|
|
@@ -42,10 +55,18 @@ class LazyRoute {
|
|
|
42
55
|
});
|
|
43
56
|
};
|
|
44
57
|
this.useSearch = (opts2) => {
|
|
45
|
-
return useSearch({
|
|
58
|
+
return useSearch({
|
|
59
|
+
select: opts2 == null ? void 0 : opts2.select,
|
|
60
|
+
structuralSharing: opts2 == null ? void 0 : opts2.structuralSharing,
|
|
61
|
+
from: this.options.id
|
|
62
|
+
});
|
|
46
63
|
};
|
|
47
64
|
this.useParams = (opts2) => {
|
|
48
|
-
return useParams({
|
|
65
|
+
return useParams({
|
|
66
|
+
select: opts2 == null ? void 0 : opts2.select,
|
|
67
|
+
structuralSharing: opts2 == null ? void 0 : opts2.structuralSharing,
|
|
68
|
+
from: this.options.id
|
|
69
|
+
});
|
|
49
70
|
};
|
|
50
71
|
this.useLoaderDeps = (opts2) => {
|
|
51
72
|
return useLoaderDeps({ ...opts2, from: this.options.id });
|
|
@@ -53,23 +74,28 @@ class LazyRoute {
|
|
|
53
74
|
this.useLoaderData = (opts2) => {
|
|
54
75
|
return useLoaderData({ ...opts2, from: this.options.id });
|
|
55
76
|
};
|
|
77
|
+
this.useNavigate = () => {
|
|
78
|
+
const router = useRouter();
|
|
79
|
+
return useNavigate({ from: router.routesById[this.options.id].fullPath });
|
|
80
|
+
};
|
|
56
81
|
this.options = opts;
|
|
57
82
|
this.$$typeof = Symbol.for("react.memo");
|
|
58
83
|
}
|
|
59
84
|
}
|
|
60
85
|
function createLazyRoute(id) {
|
|
61
86
|
return (opts) => {
|
|
62
|
-
return new LazyRoute({
|
|
87
|
+
return new LazyRoute({
|
|
88
|
+
id,
|
|
89
|
+
...opts
|
|
90
|
+
});
|
|
63
91
|
};
|
|
64
92
|
}
|
|
65
|
-
function createLazyFileRoute(
|
|
66
|
-
|
|
93
|
+
function createLazyFileRoute(id) {
|
|
94
|
+
if (typeof id === "object") {
|
|
95
|
+
return new LazyRoute(id);
|
|
96
|
+
}
|
|
67
97
|
return (opts) => new LazyRoute({ id, ...opts });
|
|
68
98
|
}
|
|
69
|
-
const routeGroupPatternRegex = /\(.+\)/g;
|
|
70
|
-
function removeGroups(s) {
|
|
71
|
-
return s.replaceAll(routeGroupPatternRegex, "").replaceAll("//", "/");
|
|
72
|
-
}
|
|
73
99
|
export {
|
|
74
100
|
FileRoute,
|
|
75
101
|
FileRouteLoader,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import { NoInfer } from '@tanstack/react-store'\nimport { ParsePathParams } from './link'\nimport {\n AnyRoute,\n ResolveFullPath,\n ResolveFullSearchSchema,\n MergeFromFromParent,\n RouteContext,\n AnyContext,\n RouteOptions,\n UpdatableRouteOptions,\n Route,\n createRoute,\n RootRouteId,\n TrimPathLeft,\n RouteConstraints,\n ResolveFullSearchSchemaInput,\n SearchSchemaInput,\n RouteLoaderFn,\n AnyPathParams,\n AnySearchSchema,\n FileBaseRouteOptions,\n} from './route'\nimport { Assign, Expand, IsAny } from './utils'\nimport { useMatch, useLoaderDeps, useLoaderData, RouteMatch } from './Matches'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport warning from 'tiny-warning'\nimport { RegisteredRouter } from './router'\nimport { RouteById, RouteIds } from './routeInfo'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\ntype Replace<\n S extends string,\n From extends string,\n To extends string,\n> = S extends `${infer Start}${From}${infer Rest}`\n ? `${Start}${To}${Replace<Rest, From, To>}`\n : S\n\nexport type TrimLeft<\n T extends string,\n S extends string,\n> = T extends `${S}${infer U}` ? U : T\n\nexport type TrimRight<\n T extends string,\n S extends string,\n> = T extends `${infer U}${S}` ? U : T\n\nexport type Trim<T extends string, S extends string> = TrimLeft<\n TrimRight<T, S>,\n S\n>\n\nexport type RemoveUnderScores<T extends string> = Replace<\n Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>,\n '/_',\n '/'\n>\n\ntype RemoveRouteGroups<S extends string> =\n S extends `${infer Before}(${infer RouteGroup})${infer After}`\n ? RemoveRouteGroups<`${Before}${After}`>\n : S\n\ntype NormalizeSlashes<S extends string> =\n S extends `${infer Before}//${infer After}`\n ? NormalizeSlashes<`${Before}/${After}`>\n : S\n\ntype ReplaceFirstOccurrence<\n T extends string,\n Search extends string,\n Replacement extends string,\n> = T extends `${infer Prefix}${Search}${infer Suffix}`\n ? `${Prefix}${Replacement}${Suffix}`\n : T\n\nexport type ResolveFilePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = TParentRoute['id'] extends RootRouteId\n ? TrimPathLeft<TFilePath>\n : ReplaceFirstOccurrence<\n TrimPathLeft<TFilePath>,\n TrimPathLeft<TParentRoute['types']['customId']>,\n ''\n >\n\nexport type FileRoutePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> =\n ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}`\n ? ''\n : ResolveFilePath<TParentRoute, TFilePath> extends `/_${infer _}`\n ? ''\n : ResolveFilePath<TParentRoute, TFilePath>\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 extends Record<\n string,\n any\n > = TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : TSearchSchema,\n TFullSearchSchemaInput extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TParams extends RouteConstraints['TParams'] = Expand<\n Record<ParsePathParams<TPath>, string>\n >,\n TAllParams extends RouteConstraints['TAllParams'] = MergeFromFromParent<\n TParentRoute['types']['allParams'],\n TParams\n >,\n TRouteContextReturn extends\n RouteConstraints['TRouteContext'] = RouteContext,\n TRouteContext extends RouteConstraints['TRouteContext'] = [\n TRouteContextReturn,\n ] extends [never]\n ? RouteContext\n : TRouteContextReturn,\n TAllContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn extends any = unknown,\n TLoaderData extends any = [TLoaderDataReturn] extends [never]\n ? undefined\n : TLoaderDataReturn,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\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<TAllParams, TFullSearchSchema, TLoaderData>,\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 TRouteTree\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 extends any>(\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<AnyPathParams, AnySearchSchema, any>,\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 TRouteMatchState = RouteMatch<\n TRoute['types']['routeTree'],\n TRoute['types']['id']\n >,\n TSelected = TRouteMatchState,\n >(opts?: {\n select?: (match: TRouteMatchState) => 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\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":";;;;;AAyGO,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,CA+CZ,YAsCG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MAAA;AAEI,YAAA,QAAQ,YAAY,OAAc;AACtC,YAAc,SAAS;AAClB,aAAA;AAAA,IAAA;AA/FP,SAAK,SAAS,+BAAO;AAAA,EACvB;AAgGF;AAOO,SAAS,gBAId,OAeA;AACA;AAAA,IACE;AAAA,IACA;AAAA,EAAA;AAEF,SAAO,CAAC,aAAa;AACvB;AAOO,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;AA9C9D,SAAK,UAAU;AACb,SAAa,WAAW,OAAO,IAAI,YAAY;AAAA,EACnD;AA8CF;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'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderFn,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\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>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\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 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?: FileBaseRouteOptions<\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown\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): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderFn<\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\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 as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\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: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {\n return useMatch({\n from: this.options.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\n\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute> {\n if (typeof id === 'object') {\n return new LazyRoute<TRoute>(id) as any\n }\n\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n"],"names":["opts"],"mappings":";;;;;;;;;AAoCO,SAAS,gBAQd,MAC0E;AACtE,MAAA,OAAO,SAAS,UAAU;AACrB,WAAA,IAAI,UAA0D,MAAM;AAAA,MACzE,QAAQ;AAAA,IAAA,CACT,EAAE,YAAY,IAAI;AAAA,EAAA;AAEd,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,CASZ,YAuCG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MACF;AACM,YAAA,QAAQ,YAAY,OAAc;AACtC,YAAc,SAAS;AAClB,aAAA;AAAA,IACT;AA3DE,SAAK,SAAS,+BAAO;AAAA,EAAA;AA4DzB;AAOO,SAAS,gBAId,OAca;AACb;AAAA,IACE;AAAA,IACA;AAAA,EACF;AACA,SAAO,CAAC,aAAa;AACvB;AAcO,MAAM,UAAmC;AAAA,EAK9C,YACE,MAGA;AAKF,SAAA,WAAwC,CAACA,UAAS;AAChD,aAAO,SAAS;AAAA,QACd,QAAQA,SAAA,gBAAAA,MAAM;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,mBAAmBA,SAAA,gBAAAA,MAAM;AAAA,MAAA,CACnB;AAAA,IACV;AAEA,SAAA,kBAAsD,CAACA,UAAS;AAC9D,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,IACH;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAO,UAAU;AAAA,QACf,QAAQA,SAAA,gBAAAA,MAAM;AAAA,QACd,mBAAmBA,SAAA,gBAAAA,MAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAO,UAAU;AAAA,QACf,QAAQA,SAAA,gBAAAA,MAAM;AAAA,QACd,mBAAmBA,SAAA,gBAAAA,MAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,gBAAkD,CAACA,UAAS;AACnD,aAAA,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,gBAAkD,CAACA,UAAS;AACnD,aAAA,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,cAAc,MAA6C;AACzD,YAAM,SAAS,UAAU;AAClB,aAAA,YAAY,EAAE,MAAM,OAAO,WAAW,KAAK,QAAQ,EAAE,EAAE,UAAU;AAAA,IAC1E;AAhDE,SAAK,UAAU;AACb,SAAa,WAAW,OAAO,IAAI,YAAY;AAAA,EAAA;AAgDrD;AAEO,SAAS,gBAId,IAA2D;AAC3D,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,EACH;AACF;AAEO,SAAS,oBAGd,IAA8D;AAC1D,MAAA,OAAO,OAAO,UAAU;AACnB,WAAA,IAAI,UAAkB,EAAE;AAAA,EAAA;AAG1B,SAAA,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;"}
|
package/dist/esm/history.d.ts
CHANGED
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,32 +1,55 @@
|
|
|
1
|
-
export * from '@tanstack/history';
|
|
2
1
|
export { default as invariant } from 'tiny-invariant';
|
|
3
2
|
export { default as warning } from 'tiny-warning';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export * from './
|
|
3
|
+
export { defer, TSR_DEFERRED_PROMISE, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, parsePathname, interpolatePath, matchPathname, removeBasepath, matchByPath, encode, decode, rootRouteId, defaultSerializeError, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, escapeJSON, // SSR
|
|
4
|
+
pick, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, shallow, createControlledPromise, retainSearchParams, stripSearchParams, } from '@tanstack/router-core';
|
|
5
|
+
export type { AnyRoute, StartSerializer, Serializable, SerializerParse, SerializerParseBy, SerializerStringify, SerializerStringifyBy, DeferredPromiseState, DeferredPromise, ParsedLocation, ParsePathParams, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, Segment, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, ParseSplatParams, SplatParams, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, TrailingSlashOption, ExtractedEntry, ExtractedStream, ExtractedPromise, StreamState, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, Register, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, FileRoutesByPath, RouteById, RootRouteOptions, SerializerExtensions, CreateFileRoute, } from '@tanstack/router-core';
|
|
6
|
+
export type * from './serializer.js';
|
|
7
|
+
export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
|
|
8
|
+
export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryState, } from '@tanstack/history';
|
|
9
|
+
export { useAwaited, Await } from './awaited.js';
|
|
10
|
+
export type { AwaitOptions } from './awaited.js';
|
|
11
|
+
export { CatchBoundary, ErrorComponent } from './CatchBoundary.js';
|
|
12
|
+
export { ClientOnly } from './ClientOnly.js';
|
|
13
|
+
export { FileRoute, createFileRoute, FileRouteLoader, LazyRoute, createLazyRoute, createLazyFileRoute, } from './fileRoute.js';
|
|
8
14
|
export * from './history.js';
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
15
|
+
export { lazyRouteComponent } from './lazyRouteComponent.js';
|
|
16
|
+
export { useLinkProps, createLink, Link, linkOptions } from './link.js';
|
|
17
|
+
export type { InferDescendantToPaths, RelativeToPath, RelativeToParentPath, RelativeToCurrentPath, AbsoluteToPath, RelativeToPathAutoComplete, NavigateOptions, ToOptions, ToMaskOptions, ToSubOptions, ResolveRoute, SearchParamOptions, PathParamOptions, ToPathOption, LinkOptions, MakeOptionalPathParams, FileRouteTypes, RouteContextParameter, BeforeLoadContextParameter, ResolveAllContext, ResolveAllParamsFromParent, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, RouteIds, NavigateFn, BuildLocationFn, FullSearchSchemaOption, MakeRemountDepsOptionsUnion, RemountDepsOptions, ResolveFullPath, AnyRouteWithContext, AnyRouterWithContext, CommitLocationOptions, MatchLocation, UseNavigateResult, AnyRedirect, Redirect, ResolvedRedirect, MakeRouteMatch, MakeRouteMatchUnion, RouteMatch, AnyRouteMatch, RouteContextFn, RouteContextOptions, BeforeLoadFn, BeforeLoadContextOptions, ContextOptions, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, RouteLoaderFn, LoaderFnContext, LazyRouteOptions, AnyRouter, RegisteredRouter, RouterContextOptions, ControllablePromise, InjectedHtmlEntry, RouterOptions, RouterErrorSerializer, RouterState, ListenerFn, BuildNextOptions, RouterConstructorOptions, RouterEvents, RouterEvent, RouterListener, RouteConstraints, RouteMask, MatchRouteOptions, CreateLazyFileRoute, } from '@tanstack/router-core';
|
|
18
|
+
export type { UseLinkPropsOptions, ActiveLinkOptions, LinkProps, LinkComponent, LinkComponentProps, CreateLinkProps, } from './link.js';
|
|
19
|
+
export { Matches, useMatchRoute, MatchRoute, useMatches, useParentMatches, useChildMatches, } from './Matches.js';
|
|
20
|
+
export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches.js';
|
|
21
|
+
export { matchContext } from './matchContext.js';
|
|
22
|
+
export { Match, Outlet } from './Match.js';
|
|
23
|
+
export { useMatch } from './useMatch.js';
|
|
24
|
+
export { useLoaderDeps } from './useLoaderDeps.js';
|
|
25
|
+
export { useLoaderData } from './useLoaderData.js';
|
|
26
|
+
export { redirect, isRedirect } from '@tanstack/router-core';
|
|
27
|
+
export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route.js';
|
|
28
|
+
export type { AnyRootRoute, ReactNode, SyncRouteComponent, AsyncRouteComponent, RouteComponent, ErrorRouteComponent, NotFoundRouteComponent, } from './route.js';
|
|
29
|
+
export { createRouter, Router } from './router.js';
|
|
30
|
+
export { componentTypes, lazyFn, SearchParamError, PathParamError, getInitialRouterState, } from '@tanstack/router-core';
|
|
31
|
+
export { RouterProvider, RouterContextProvider } from './RouterProvider.js';
|
|
32
|
+
export type { RouterProps } from './RouterProvider.js';
|
|
33
|
+
export { useElementScrollRestoration, ScrollRestoration, } from './ScrollRestoration.js';
|
|
34
|
+
export type { UseBlockerOpts, ShouldBlockFn } from './useBlocker.js';
|
|
35
|
+
export { useBlocker, Block } from './useBlocker.js';
|
|
36
|
+
export { useNavigate, Navigate } from './useNavigate.js';
|
|
37
|
+
export { useParams } from './useParams.js';
|
|
38
|
+
export { useSearch } from './useSearch.js';
|
|
39
|
+
export { getRouterContext, } from './routerContext.js';
|
|
40
|
+
export { useRouteContext } from './useRouteContext.js';
|
|
41
|
+
export { useRouter } from './useRouter.js';
|
|
42
|
+
export { useRouterState } from './useRouterState.js';
|
|
43
|
+
export { useLocation } from './useLocation.js';
|
|
44
|
+
export { useCanGoBack } from './useCanGoBack.js';
|
|
45
|
+
export { useLayoutEffect, // SSR
|
|
46
|
+
useStableCallback, } from './utils.js';
|
|
47
|
+
export { CatchNotFound, DefaultGlobalNotFound } from './not-found.js';
|
|
48
|
+
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
49
|
+
export type { NotFoundError } from '@tanstack/router-core';
|
|
50
|
+
export type { ValidateLinkOptions, InferStructuralSharing, ValidateUseSearchOptions, ValidateUseParamsOptions, ValidateLinkOptionsArray, } from './typePrimitives.js';
|
|
51
|
+
export type { ValidateFromPath, ValidateToPath, ValidateSearch, ValidateParams, InferFrom, InferTo, InferMaskTo, InferMaskFrom, ValidateNavigateOptions, ValidateNavigateOptionsArray, ValidateRedirectOptions, ValidateRedirectOptionsArray, ValidateId, InferStrict, InferShouldThrow, InferSelected, ValidateUseSearchResult, ValidateUseParamsResult, } from '@tanstack/router-core';
|
|
52
|
+
export { ScriptOnce } from './ScriptOnce.js';
|
|
53
|
+
export { Asset } from './Asset.js';
|
|
54
|
+
export { HeadContent } from './HeadContent.js';
|
|
55
|
+
export { Scripts } from './Scripts.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
export * from "@tanstack/history";
|
|
2
1
|
import { default as default2 } from "tiny-invariant";
|
|
3
2
|
import { default as default3 } from "tiny-warning";
|
|
3
|
+
import { PathParamError, SearchParamError, TSR_DEFERRED_PROMISE, cleanPath, componentTypes, createControlledPromise, decode, deepEqual, defaultParseSearch, defaultSerializeError, defaultStringifySearch, defer, encode, escapeJSON, functionalUpdate, getInitialRouterState, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, matchByPath, matchPathname, notFound, parsePathname, parseSearchWith, pick, redirect, removeBasepath, replaceEqualDeep, resolvePath, retainSearchParams, rootRouteId, shallow, stringifySearchWith, stripSearchParams, trimPath, trimPathLeft, trimPathRight } from "@tanstack/router-core";
|
|
4
|
+
import { createBrowserHistory, createHashHistory, createHistory, createMemoryHistory } from "@tanstack/history";
|
|
4
5
|
import { Await, useAwaited } from "./awaited.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
7
|
+
import { ClientOnly } from "./ClientOnly.js";
|
|
7
8
|
import { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileRoute, createLazyRoute } from "./fileRoute.js";
|
|
8
9
|
import { lazyRouteComponent } from "./lazyRouteComponent.js";
|
|
9
|
-
import { Link, createLink, useLinkProps } from "./link.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
10
|
+
import { Link, createLink, linkOptions, useLinkProps } from "./link.js";
|
|
11
|
+
import { MatchRoute, Matches, useChildMatches, useMatchRoute, useMatches, useParentMatches } from "./Matches.js";
|
|
12
|
+
import { matchContext } from "./matchContext.js";
|
|
13
|
+
import { Match, Outlet } from "./Match.js";
|
|
14
|
+
import { useMatch } from "./useMatch.js";
|
|
15
|
+
import { useLoaderDeps } from "./useLoaderDeps.js";
|
|
16
|
+
import { useLoaderData } from "./useLoaderData.js";
|
|
17
|
+
import { NotFoundRoute, RootRoute, Route, RouteApi, createRootRoute, createRootRouteWithContext, createRoute, createRouteMask, getRouteApi, rootRouteWithContext } from "./route.js";
|
|
18
|
+
import { Router, createRouter } from "./router.js";
|
|
19
|
+
import { RouterContextProvider, RouterProvider } from "./RouterProvider.js";
|
|
20
|
+
import { ScrollRestoration, useElementScrollRestoration } from "./ScrollRestoration.js";
|
|
19
21
|
import { Block, useBlocker } from "./useBlocker.js";
|
|
20
22
|
import { Navigate, useNavigate } from "./useNavigate.js";
|
|
21
23
|
import { useParams } from "./useParams.js";
|
|
@@ -24,19 +26,26 @@ import { getRouterContext } from "./routerContext.js";
|
|
|
24
26
|
import { useRouteContext } from "./useRouteContext.js";
|
|
25
27
|
import { useRouter } from "./useRouter.js";
|
|
26
28
|
import { useRouterState } from "./useRouterState.js";
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
29
|
+
import { useLocation } from "./useLocation.js";
|
|
30
|
+
import { useCanGoBack } from "./useCanGoBack.js";
|
|
31
|
+
import { useLayoutEffect, useStableCallback } from "./utils.js";
|
|
32
|
+
import { CatchNotFound, DefaultGlobalNotFound } from "./not-found.js";
|
|
33
|
+
import { ScriptOnce } from "./ScriptOnce.js";
|
|
34
|
+
import { Asset } from "./Asset.js";
|
|
35
|
+
import { HeadContent } from "./HeadContent.js";
|
|
36
|
+
import { Scripts } from "./Scripts.js";
|
|
30
37
|
export {
|
|
38
|
+
Asset,
|
|
31
39
|
Await,
|
|
32
40
|
Block,
|
|
33
41
|
CatchBoundary,
|
|
34
|
-
CatchBoundaryImpl,
|
|
35
42
|
CatchNotFound,
|
|
43
|
+
ClientOnly,
|
|
36
44
|
DefaultGlobalNotFound,
|
|
37
45
|
ErrorComponent,
|
|
38
46
|
FileRoute,
|
|
39
47
|
FileRouteLoader,
|
|
48
|
+
HeadContent,
|
|
40
49
|
LazyRoute,
|
|
41
50
|
Link,
|
|
42
51
|
Match,
|
|
@@ -50,24 +59,31 @@ export {
|
|
|
50
59
|
Route,
|
|
51
60
|
RouteApi,
|
|
52
61
|
Router,
|
|
62
|
+
RouterContextProvider,
|
|
53
63
|
RouterProvider,
|
|
64
|
+
ScriptOnce,
|
|
65
|
+
Scripts,
|
|
54
66
|
ScrollRestoration,
|
|
55
67
|
SearchParamError,
|
|
68
|
+
TSR_DEFERRED_PROMISE,
|
|
56
69
|
cleanPath,
|
|
57
70
|
componentTypes,
|
|
71
|
+
createBrowserHistory,
|
|
72
|
+
createControlledPromise,
|
|
58
73
|
createFileRoute,
|
|
74
|
+
createHashHistory,
|
|
75
|
+
createHistory,
|
|
59
76
|
createLazyFileRoute,
|
|
60
77
|
createLazyRoute,
|
|
61
78
|
createLink,
|
|
79
|
+
createMemoryHistory,
|
|
62
80
|
createRootRoute,
|
|
63
81
|
createRootRouteWithContext,
|
|
64
82
|
createRoute,
|
|
65
83
|
createRouteMask,
|
|
66
84
|
createRouter,
|
|
67
|
-
createServerFn,
|
|
68
85
|
decode,
|
|
69
86
|
deepEqual,
|
|
70
|
-
defaultDeserializeError,
|
|
71
87
|
defaultParseSearch,
|
|
72
88
|
defaultSerializeError,
|
|
73
89
|
defaultStringifySearch,
|
|
@@ -76,24 +92,19 @@ export {
|
|
|
76
92
|
escapeJSON,
|
|
77
93
|
functionalUpdate,
|
|
78
94
|
getInitialRouterState,
|
|
79
|
-
getRenderedMatches,
|
|
80
95
|
getRouteApi,
|
|
81
|
-
getRouteMatch,
|
|
82
96
|
getRouterContext,
|
|
83
97
|
interpolatePath,
|
|
84
98
|
default2 as invariant,
|
|
85
|
-
|
|
99
|
+
isMatch,
|
|
86
100
|
isNotFound,
|
|
87
101
|
isPlainArray,
|
|
88
102
|
isPlainObject,
|
|
89
103
|
isRedirect,
|
|
90
|
-
isServer,
|
|
91
|
-
isServerSideError,
|
|
92
104
|
joinPaths,
|
|
93
|
-
json,
|
|
94
|
-
last,
|
|
95
105
|
lazyFn,
|
|
96
106
|
lazyRouteComponent,
|
|
107
|
+
linkOptions,
|
|
97
108
|
matchByPath,
|
|
98
109
|
matchContext,
|
|
99
110
|
matchPathname,
|
|
@@ -105,23 +116,25 @@ export {
|
|
|
105
116
|
removeBasepath,
|
|
106
117
|
replaceEqualDeep,
|
|
107
118
|
resolvePath,
|
|
119
|
+
retainSearchParams,
|
|
108
120
|
rootRouteId,
|
|
109
121
|
rootRouteWithContext,
|
|
110
|
-
serverFnPayloadTypeHeader,
|
|
111
|
-
serverFnReturnTypeHeader,
|
|
112
122
|
shallow,
|
|
113
123
|
stringifySearchWith,
|
|
124
|
+
stripSearchParams,
|
|
114
125
|
trimPath,
|
|
115
126
|
trimPathLeft,
|
|
116
127
|
trimPathRight,
|
|
117
128
|
useAwaited,
|
|
118
129
|
useBlocker,
|
|
130
|
+
useCanGoBack,
|
|
119
131
|
useChildMatches,
|
|
120
132
|
useElementScrollRestoration,
|
|
121
133
|
useLayoutEffect,
|
|
122
134
|
useLinkProps,
|
|
123
135
|
useLoaderData,
|
|
124
136
|
useLoaderDeps,
|
|
137
|
+
useLocation,
|
|
125
138
|
useMatch,
|
|
126
139
|
useMatchRoute,
|
|
127
140
|
useMatches,
|
|
@@ -131,7 +144,6 @@ export {
|
|
|
131
144
|
useRouteContext,
|
|
132
145
|
useRouter,
|
|
133
146
|
useRouterState,
|
|
134
|
-
useScrollRestoration,
|
|
135
147
|
useSearch,
|
|
136
148
|
useStableCallback,
|
|
137
149
|
default3 as warning
|
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,2 @@
|
|
|
1
1
|
import { AsyncRouteComponent } from './route.js';
|
|
2
|
-
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;
|
|
2
|
+
export declare function lazyRouteComponent<T extends Record<string, any>, TKey extends keyof T = 'default'>(importer: () => Promise<T>, exportName?: TKey, ssr?: () => boolean): T[TKey] extends (props: infer TProps) => any ? AsyncRouteComponent<TProps> : never;
|