Skip to content
26 changes: 11 additions & 15 deletions packages/react-router/src/Matches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,26 @@ import type {
} from './structuralSharing'
import type { AnyRoute, ReactNode } from './route'
import type {
AllContext,
AllLoaderData,
AllParams,
ControlledPromise,
DeepPartial,
NoInfer,
ResolveRelativePath,
StaticDataRouteOption,
} from '@tanstack/router-core'
import type { AnyRouter, RegisteredRouter, RouterState } from './router'
import type {
FullSearchSchema,
MakeOptionalPathParams,
MakeOptionalSearchParams,
MaskOptions,
ResolveRoute,
ToSubOptionsProps,
} from './link'
import type {
AllContext,
AllLoaderData,
AllParams,
FullSearchSchema,
NoInfer,
ParseRoute,
ResolveRelativePath,
ResolveRoute,
RouteById,
RouteByPath,
RouteIds,
} from './routeInfo'
StaticDataRouteOption,
ToSubOptionsProps,
} from '@tanstack/router-core'
import type { AnyRouter, RegisteredRouter, RouterState } from './router'

export type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<
TRoute['types']['id'],
Expand Down
48 changes: 0 additions & 48 deletions packages/react-router/src/RouterProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,13 @@
import * as React from 'react'
import { Matches } from './Matches'
import { getRouterContext } from './routerContext'
import type { NavigateOptions, ToOptions } from './link'
import type {
ParsedLocation,
ViewTransitionOptions,
} from '@tanstack/router-core'
import type { RoutePaths } from './routeInfo'
import type {
AnyRouter,
RegisteredRouter,
Router,
RouterOptions,
} from './router'

export interface CommitLocationOptions {
replace?: boolean
resetScroll?: boolean
hashScrollIntoView?: boolean | ScrollIntoViewOptions
viewTransition?: boolean | ViewTransitionOptions
/**
* @deprecated All navigations use React transitions under the hood now
**/
startTransition?: boolean
ignoreBlocker?: boolean
}

export interface MatchLocation {
to?: string | number | null
fuzzy?: boolean
caseSensitive?: boolean
from?: string
}

export type NavigateFn = <
TRouter extends RegisteredRouter,
TTo extends string | undefined,
TFrom extends RoutePaths<TRouter['routeTree']> | string = string,
TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,
TMaskTo extends string = '',
>(
opts: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
) => Promise<void> | void

export type BuildLocationFn = <
TRouter extends RegisteredRouter,
TTo extends string | undefined,
TFrom extends RoutePaths<TRouter['routeTree']> | string = string,
TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,
TMaskTo extends string = '',
>(
opts: ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {
leaveParams?: boolean
_includeValidateSearch?: boolean
},
) => ParsedLocation

export function RouterContextProvider<
TRouter extends AnyRouter = RegisteredRouter,
TDehydrated extends Record<string, any> = Record<string, any>,
Expand Down
48 changes: 10 additions & 38 deletions packages/react-router/src/fileRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,30 @@ import { useNavigate } from './useNavigate'
import type { UseParamsRoute } from './useParams'
import type { UseMatchRoute } from './useMatch'
import type { UseSearchRoute } from './useSearch'
import type {
AnyContext,
AnyPathParams,
AnyValidator,
Constrain,
ResolveParams,
} from '@tanstack/router-core'

import type {
AnyRoute,
FileBaseRouteOptions,
RootRoute,
Route,
RouteConstraints,
RouteLoaderFn,
UpdatableRouteOptions,
} from './route'
import type { RegisteredRouter } from './router'
import type { RouteById, RouteIds } from './routeInfo'
import type {
AnyContext,
AnyPathParams,
AnyValidator,
Constrain,
FileRoutesByPath,
ResolveParams,
RouteById,
RouteIds,
} from '@tanstack/router-core'
import type { UseLoaderDepsRoute } from './useLoaderDeps'
import type { UseLoaderDataRoute } from './useLoaderData'
import type { UseRouteContextRoute } from './useRouteContext'

export interface FileRoutesByPath {
// '/': {
// parentRoute: typeof rootRoute
// }
}

export interface FileRouteTypes {
fileRoutesByFullPath: any
fullPaths: any
to: any
fileRoutesByTo: any
id: any
fileRoutesById: any
}

export type InferFileRouteTypes<TRouteTree extends AnyRoute> =
TRouteTree extends RootRoute<
any,
any,
any,
any,
any,
any,
any,
infer TFileRouteTypes extends FileRouteTypes
>
? TFileRouteTypes
: never

export function createFileRoute<
TFilePath extends keyof FileRoutesByPath,
TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],
Expand Down
67 changes: 26 additions & 41 deletions packages/react-router/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export type {
IntersectAssign,
ResolveValidatorInput,
ResolveValidatorOutput,
Register,
AnyValidator,
DefaultValidator,
ValidatorFn,
Expand All @@ -120,6 +121,8 @@ export type {
Validator,
ValidatorAdapter,
ValidatorObj,
FileRoutesByPath,
RouteById,
} from '@tanstack/router-core'

export {
Expand Down Expand Up @@ -150,11 +153,7 @@ export {
createLazyRoute,
createLazyFileRoute,
} from './fileRoute'
export type {
FileRoutesByPath,
FileRouteTypes,
LazyRouteOptions,
} from './fileRoute'
export type { LazyRouteOptions } from './fileRoute'

export * from './history'

Expand All @@ -177,13 +176,33 @@ export type {
PathParamOptions,
ToPathOption,
LinkOptions,
MakeOptionalPathParams,
FileRouteTypes,
RouteContextParameter,
BeforeLoadContextParameter,
ResolveAllContext,
ResolveAllParamsFromParent,
ResolveFullSearchSchema,
ResolveFullSearchSchemaInput,
RouteIds,
NavigateFn,
BuildLocationFn,
FullSearchSchemaOption,
MakeRemountDepsOptionsUnion,
RemountDepsOptions,
ResolveFullPath,
AnyRouteWithContext,
AnyRouterWithContext,
CommitLocationOptions,
MatchLocation,
} from '@tanstack/router-core'
export type {
UseLinkPropsOptions,
ActiveLinkOptions,
LinkProps,
LinkComponent,
LinkComponentProps,
CreateLinkProps,
MakeOptionalPathParams,
} from './link'

export {
Expand Down Expand Up @@ -234,12 +253,9 @@ export type {
UpdatableRouteOptions,
RouteLoaderFn,
LoaderFnContext,
ResolveFullSearchSchema,
ResolveFullSearchSchemaInput,
AnyRoute,
RouteConstraints,
AnyRootRoute,
ResolveFullPath,
RouteMask,
ReactNode,
SyncRouteComponent,
Expand All @@ -248,36 +264,13 @@ export type {
ErrorRouteComponent,
NotFoundRouteComponent,
RootRouteOptions,
AnyRouteWithContext,
FullSearchSchemaOption,
RouteContextFn,
RouteContextOptions,
BeforeLoadFn,
BeforeLoadContextOptions,
ContextOptions,
RouteContextParameter,
BeforeLoadContextParameter,
ResolveAllContext,
ResolveAllParamsFromParent,
MakeRemountDepsOptionsUnion,
RemountDepsOptions,
} from './route'

export type {
ParseRoute,
RoutesById,
RouteById,
RouteIds,
RoutesByPath,
RouteByPath,
RoutePaths,
FullSearchSchema,
AllParams,
AllLoaderData,
FullSearchSchemaInput,
AllContext,
} from './routeInfo'

export {
componentTypes,
createRouter,
Expand All @@ -289,7 +282,6 @@ export {
} from './router'

export type {
Register,
AnyRouter,
RegisteredRouter,
RouterContextOptions,
Expand All @@ -302,19 +294,12 @@ export type {
RouterEvents,
RouterEvent,
RouterListener,
AnyRouterWithContext,
ControllablePromise,
InjectedHtmlEntry,
} from './router'

export { RouterProvider, RouterContextProvider } from './RouterProvider'
export type {
RouterProps,
CommitLocationOptions,
MatchLocation,
NavigateFn,
BuildLocationFn,
} from './RouterProvider'
export type { RouterProps } from './RouterProvider'

export {
useElementScrollRestoration,
Expand Down
Loading