@tanstack/react-router
Version:
Modern and scalable routing for React applications
1 lines • 4.74 kB
Source Map (JSON)
{"version":3,"file":"router.cjs","sources":["../../src/router.ts"],"sourcesContent":["import { RouterCore } from '@tanstack/router-core'\nimport type { RouterHistory } from '@tanstack/history'\nimport type {\n AnyRoute,\n CreateRouterFn,\n RouterConstructorOptions,\n TrailingSlashOption,\n} from '@tanstack/router-core'\n\nimport type {\n ErrorRouteComponent,\n NotFoundRouteComponent,\n RouteComponent,\n} from './route'\n\ndeclare module '@tanstack/router-core' {\n export interface RouterOptionsExtensions {\n /**\n * The default `component` a route should use if no component is provided.\n *\n * @default Outlet\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)\n */\n defaultComponent?: RouteComponent\n /**\n * The default `errorComponent` a route should use if no error component is provided.\n *\n * @default ErrorComponent\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)\n */\n defaultErrorComponent?: ErrorRouteComponent\n /**\n * The default `pendingComponent` a route should use if no pending component is provided.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)\n */\n defaultPendingComponent?: RouteComponent\n /**\n * The default `notFoundComponent` a route should use if no notFound component is provided.\n *\n * @default NotFound\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)\n */\n defaultNotFoundComponent?: NotFoundRouteComponent\n /**\n * A component that will be used to wrap the entire router.\n *\n * This is useful for providing a context to the entire router.\n *\n * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)\n */\n Wrap?: (props: { children: any }) => React.JSX.Element\n /**\n * A component that will be used to wrap the inner contents of the router.\n *\n * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.\n *\n * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)\n */\n InnerWrap?: (props: { children: any }) => React.JSX.Element\n\n /**\n * The default `onCatch` handler for errors caught by the Router ErrorBoundary\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)\n */\n defaultOnCatch?: (error: Error, errorInfo: React.ErrorInfo) => void\n }\n}\n\nexport const createRouter: CreateRouterFn = (options) => {\n return new Router(options)\n}\n\nexport class Router<\n in out TRouteTree extends AnyRoute,\n in out TTrailingSlashOption extends TrailingSlashOption = 'never',\n in out TDefaultStructuralSharingOption extends boolean = false,\n in out TRouterHistory extends RouterHistory = RouterHistory,\n in out TDehydrated extends Record<string, any> = Record<string, any>,\n> extends RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n> {\n constructor(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n ) {\n super(options)\n }\n}\n"],"names":["RouterCore"],"mappings":";;;AA8Ea,MAAA,eAA+B,CAAC,YAAY;AAChD,SAAA,IAAI,OAAO,OAAO;AAC3B;AAEO,MAAM,eAMHA,WAAAA,WAMR;AAAA,EACA,YACE,SAOA;AACA,UAAM,OAAO;AAAA,EAAA;AAEjB;;;"}