@tanstack/react-router 1.141.2 → 1.141.6
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/ClientOnly.cjs.map +1 -1
- package/dist/cjs/ClientOnly.d.cts +0 -8
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/HeadContent.d.cts +0 -4
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +0 -12
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +0 -9
- package/dist/cjs/ScriptOnce.cjs +1 -2
- package/dist/cjs/ScriptOnce.cjs.map +1 -1
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/Scripts.d.cts +0 -4
- package/dist/cjs/awaited.cjs.map +1 -1
- package/dist/cjs/awaited.d.cts +0 -5
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +0 -59
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +0 -5
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderData.d.cts +0 -4
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.d.cts +0 -4
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useLocation.d.cts +0 -5
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +0 -4
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouter.d.cts +0 -5
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useRouterState.d.cts +0 -5
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +0 -4
- package/dist/esm/ClientOnly.d.ts +0 -8
- package/dist/esm/ClientOnly.js.map +1 -1
- package/dist/esm/HeadContent.d.ts +0 -4
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Matches.d.ts +0 -12
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +0 -9
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/ScriptOnce.js +1 -2
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.d.ts +0 -4
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/awaited.d.ts +0 -5
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +0 -59
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/router.d.ts +0 -5
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useLoaderData.d.ts +0 -4
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.d.ts +0 -4
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.d.ts +0 -5
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useParams.d.ts +0 -4
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouter.d.ts +0 -5
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.d.ts +0 -5
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.d.ts +0 -4
- package/dist/esm/useSearch.js.map +1 -1
- package/package.json +2 -2
- package/src/ClientOnly.tsx +0 -8
- package/src/HeadContent.tsx +0 -4
- package/src/Matches.tsx +0 -12
- package/src/RouterProvider.tsx +0 -9
- package/src/ScriptOnce.tsx +1 -2
- package/src/Scripts.tsx +0 -4
- package/src/awaited.tsx +0 -5
- package/src/fileRoute.ts +0 -59
- package/src/router.ts +0 -5
- package/src/useLoaderData.tsx +0 -4
- package/src/useLoaderDeps.tsx +0 -4
- package/src/useLocation.tsx +0 -5
- package/src/useParams.tsx +0 -4
- package/src/useRouter.tsx +0 -5
- package/src/useRouterState.tsx +0 -5
- package/src/useSearch.tsx +0 -4
|
@@ -1 +1 @@
|
|
|
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 Register,\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\n/**\n * Creates a file-based Route factory for a given path.\n *\n * Used by TanStack Router's file-based routing to associate a file with a\n * route. The returned function accepts standard route options. In normal usage\n * the `path` string is inserted and maintained by the `tsr` generator.\n *\n * @param path File path literal for the route (usually auto-generated).\n * @returns A function that accepts Route options and returns a Route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction\n */\n/**\n * Creates a file-based Route factory for a given path.\n *\n * Used by TanStack Router's file-based routing to associate a file with a\n * route. The returned function accepts standard route options. In normal usage\n * the `path` string is inserted and maintained by the `tsr` generator.\n *\n * @param path File path literal for the route (usually auto-generated).\n * @returns A function that accepts Route options and returns a Route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction\n */\n/**\n * Creates a file-based Route factory for a given path.\n * Used by file-based routing to associate a file with a route. The returned\n * function accepts standard route options; the path is typically auto-managed\n * by the generator.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction\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 TRegister = Register,\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 TSSR = unknown,\n const TMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: FileBaseRouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n AnyContext,\n TSSR,\n TMiddlewares,\n THandlers\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 TRegister,\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 TSSR,\n TMiddlewares,\n THandlers\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*/\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*/\n/**\n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the main route file via `createFileRoute`.\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 Register,\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\n/**\n * Creates a lazily-configurable code-based route stub by ID.\n *\n * Use this for code-splitting with code-based routes. The returned function\n * accepts only non-critical route options like `component`, `pendingComponent`,\n * `errorComponent`, and `notFoundComponent` which are applied when the route\n * is matched.\n *\n * @param id Route ID string literal to associate with the lazy route.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction\n */\n/**\n * Creates a lazily-configurable code-based route stub by ID.\n *\n * Use this for code-splitting with code-based routes. The returned function\n * accepts only non-critical route options like `component`, `pendingComponent`,\n * `errorComponent`, and `notFoundComponent` which are applied when the route\n * is matched.\n *\n * @param id Route ID string literal to associate with the lazy route.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction\n */\n/**\n * Create a lazily-configurable code-based route stub by ID.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction\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\n/**\n * Creates a lazily-configurable file-based route stub by file path.\n *\n * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).\n * The returned function accepts only non-critical route options like\n * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.\n *\n * @param id File path literal for the route file.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction\n */\n/**\n * Creates a lazily-configurable file-based route stub by file path.\n *\n * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).\n * The returned function accepts only non-critical route options like\n * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.\n *\n * @param id File path literal for the route file.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction\n */\n/**\n * Create a lazily-configurable file-based route stub by file path.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction\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":";;;;;;;;;AAkEO,SAAS,gBAQd,MAC0E;AAC1E,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO,IAAI,UAA0D,MAAM;AAAA,MACzE,QAAQ;AAAA,IAAA,CACT,EAAE,YAAY,IAAI;AAAA,EACrB;AACA,SAAO,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EAAA,CACT,EAAE;AACL;AAMO,MAAM,UAOX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CAaZ,YAgDG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MAAA;AAEF,YAAM,QAAQ,YAAY,OAAc;AACtC,YAAc,SAAS;AACzB,aAAO;AAAA,IACT;AAxEE,SAAK,SAAS,OAAO;AAAA,EACvB;AAwEF;AAgBO,SAAS,gBAId,OAea;AACb;AAAA,IACE;AAAA,IACA;AAAA,EAAA;AAEF,SAAO,CAAC,aAAa;AACvB;AAcO,MAAM,UAAmC;AAAA,EAK9C,YACE,MAGA;AAKF,SAAA,WAAwC,CAACA,UAAS;AAChD,aAAO,SAAS;AAAA,QACd,QAAQA,OAAM;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,mBAAmBA,OAAM;AAAA,MAAA,CACnB;AAAA,IACV;AAEA,SAAA,kBAAsD,CAACA,UAAS;AAC9D,aAAO,SAAS;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,QAAQ,CAAC,MAAYA,OAAM,SAASA,MAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAChE;AAAA,IACH;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAO,UAAU;AAAA,QACf,QAAQA,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAO,UAAU;AAAA,QACf,QAAQA,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAO,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAO,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,cAAc,MAA6C;AACzD,YAAM,SAAS,UAAA;AACf,aAAO,YAAY,EAAE,MAAM,OAAO,WAAW,KAAK,QAAQ,EAAE,EAAE,UAAU;AAAA,IAC1E;AAhDE,SAAK,UAAU;AACb,SAAa,WAAW,OAAO,IAAI,YAAY;AAAA,EACnD;AA+CF;AA8BO,SAAS,gBAId,IAA2D;AAC3D,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,EACH;AACF;AA4BO,SAAS,oBAGd,IAA8D;AAC9D,MAAI,OAAO,OAAO,UAAU;AAC1B,WAAO,IAAI,UAAkB,EAAE;AAAA,EACjC;AAEA,SAAO,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;"}
|
|
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 Register,\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\n/**\n * Creates a file-based Route factory for a given path.\n *\n * Used by TanStack Router's file-based routing to associate a file with a\n * route. The returned function accepts standard route options. In normal usage\n * the `path` string is inserted and maintained by the `tsr` generator.\n *\n * @param path File path literal for the route (usually auto-generated).\n * @returns A function that accepts Route options and returns a Route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction\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 TRegister = Register,\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 TSSR = unknown,\n const TMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: FileBaseRouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n AnyContext,\n TSSR,\n TMiddlewares,\n THandlers\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 TRegister,\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 TSSR,\n TMiddlewares,\n THandlers\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 main route file via `createFileRoute`.\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 Register,\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\n/**\n * Creates a lazily-configurable code-based route stub by ID.\n *\n * Use this for code-splitting with code-based routes. The returned function\n * accepts only non-critical route options like `component`, `pendingComponent`,\n * `errorComponent`, and `notFoundComponent` which are applied when the route\n * is matched.\n *\n * @param id Route ID string literal to associate with the lazy route.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction\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\n/**\n * Creates a lazily-configurable file-based route stub by file path.\n *\n * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).\n * The returned function accepts only non-critical route options like\n * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.\n *\n * @param id File path literal for the route file.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction\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":";;;;;;;;;AAgDO,SAAS,gBAQd,MAC0E;AAC1E,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO,IAAI,UAA0D,MAAM;AAAA,MACzE,QAAQ;AAAA,IAAA,CACT,EAAE,YAAY,IAAI;AAAA,EACrB;AACA,SAAO,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EAAA,CACT,EAAE;AACL;AAMO,MAAM,UAOX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CAaZ,YAgDG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MAAA;AAEF,YAAM,QAAQ,YAAY,OAAc;AACtC,YAAc,SAAS;AACzB,aAAO;AAAA,IACT;AAxEE,SAAK,SAAS,OAAO;AAAA,EACvB;AAwEF;AAMO,SAAS,gBAId,OAea;AACb;AAAA,IACE;AAAA,IACA;AAAA,EAAA;AAEF,SAAO,CAAC,aAAa;AACvB;AAcO,MAAM,UAAmC;AAAA,EAK9C,YACE,MAGA;AAKF,SAAA,WAAwC,CAACA,UAAS;AAChD,aAAO,SAAS;AAAA,QACd,QAAQA,OAAM;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,mBAAmBA,OAAM;AAAA,MAAA,CACnB;AAAA,IACV;AAEA,SAAA,kBAAsD,CAACA,UAAS;AAC9D,aAAO,SAAS;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,QAAQ,CAAC,MAAYA,OAAM,SAASA,MAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAChE;AAAA,IACH;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAO,UAAU;AAAA,QACf,QAAQA,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAO,UAAU;AAAA,QACf,QAAQA,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAO,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAO,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,cAAc,MAA6C;AACzD,YAAM,SAAS,UAAA;AACf,aAAO,YAAY,EAAE,MAAM,OAAO,WAAW,KAAK,QAAQ,EAAE,EAAE,UAAU;AAAA,IAC1E;AAhDE,SAAK,UAAU;AACb,SAAa,WAAW,OAAO,IAAI,YAAY;AAAA,EACnD;AA+CF;AAcO,SAAS,gBAId,IAA2D;AAC3D,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,EACH;AACF;AAaO,SAAS,oBAGd,IAA8D;AAC9D,MAAI,OAAO,OAAO,UAAU;AAC1B,WAAO,IAAI,UAAkB,EAAE;AAAA,EACjC;AAEA,SAAO,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;"}
|
package/dist/esm/router.d.ts
CHANGED
|
@@ -77,11 +77,6 @@ declare module '@tanstack/router-core' {
|
|
|
77
77
|
* @returns A Router instance to be provided to `RouterProvider`.
|
|
78
78
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
|
|
79
79
|
*/
|
|
80
|
-
/**
|
|
81
|
-
* Create a new React router instance from `RouterOptions`.
|
|
82
|
-
* Pass the resulting router to `RouterProvider`.
|
|
83
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
|
|
84
|
-
*/
|
|
85
80
|
export declare const createRouter: CreateRouterFn;
|
|
86
81
|
export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption = 'never', in out TDefaultStructuralSharingOption extends boolean = false, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>> extends RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated> {
|
|
87
82
|
constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>);
|
package/dist/esm/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import { RouterCore } from '@tanstack/router-core'\nimport { createFileRoute, createLazyFileRoute } from './fileRoute'\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\n/**\n * Creates a new Router instance for React.\n *\n * Pass the returned router to `RouterProvider` to enable routing.\n * Notable options: `routeTree` (your route definitions) and `context`\n * (required if the root route was created with `createRootRouteWithContext`).\n *\n * @param options Router options used to configure the router.\n * @returns A Router instance to be provided to `RouterProvider`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction\n */\
|
|
1
|
+
{"version":3,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import { RouterCore } from '@tanstack/router-core'\nimport { createFileRoute, createLazyFileRoute } from './fileRoute'\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\n/**\n * Creates a new Router instance for React.\n *\n * Pass the returned router to `RouterProvider` to enable routing.\n * Notable options: `routeTree` (your route definitions) and `context`\n * (required if the root route was created with `createRootRouteWithContext`).\n *\n * @param options Router options used to configure the router.\n * @returns A Router instance to be provided to `RouterProvider`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction\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\nif (typeof globalThis !== 'undefined') {\n ;(globalThis as any).createFileRoute = createFileRoute\n ;(globalThis as any).createLazyFileRoute = createLazyFileRoute\n} else if (typeof window !== 'undefined') {\n ;(window as any).createFileRoute = createFileRoute\n ;(window as any).createLazyFileRoute = createLazyFileRoute\n}\n"],"names":[],"mappings":";;AA0FO,MAAM,eAA+B,CAAC,YAAY;AACvD,SAAO,IAAI,OAAO,OAAO;AAC3B;AAEO,MAAM,eAMH,WAMR;AAAA,EACA,YACE,SAOA;AACA,UAAM,OAAO;AAAA,EACf;AACF;AAEA,IAAI,OAAO,eAAe,aAAa;AACnC,aAAmB,kBAAkB;AACrC,aAAmB,sBAAsB;AAC7C,WAAW,OAAO,WAAW,aAAa;AACtC,SAAe,kBAAkB;AACjC,SAAe,sBAAsB;AACzC;"}
|
|
@@ -16,8 +16,4 @@ export type UseLoaderDataRoute<out TId> = <TRouter extends AnyRouter = Registere
|
|
|
16
16
|
* @returns The loader data (or selected value) for the matched route.
|
|
17
17
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDataHook
|
|
18
18
|
*/
|
|
19
|
-
/**
|
|
20
|
-
* Read and select the current route's loader data with type‑safety.
|
|
21
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDataHook
|
|
22
|
-
*/
|
|
23
19
|
export declare function useLoaderData<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string | undefined = undefined, TStrict extends boolean = true, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts: UseLoaderDataOptions<TRouter, TFrom, TStrict, TSelected, TStructuralSharing>): UseLoaderDataResult<TRouter, TFrom, TStrict, TSelected>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoaderData.js","sources":["../../src/useLoaderData.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseLoaderData,\n StrictOrFrom,\n UseLoaderDataResult,\n} from '@tanstack/router-core'\n\nexport interface UseLoaderDataBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n match: ResolveUseLoaderData<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseLoaderDataOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseLoaderDataBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseLoaderDataRoute<out TId> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseLoaderDataBaseOptions<\n TRouter,\n TId,\n true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseLoaderDataResult<TRouter, TId, true, TSelected>\n\n/**\n * Read and select the current route's loader data with type‑safety.\n *\n * Options:\n * - `from`/`strict`: Choose which route's data to read and strictness\n * - `select`: Map the loader data to a derived value\n * - `structuralSharing`: Enable structural sharing for stable references\n *\n * @returns The loader data (or selected value) for the matched route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDataHook\n */\
|
|
1
|
+
{"version":3,"file":"useLoaderData.js","sources":["../../src/useLoaderData.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseLoaderData,\n StrictOrFrom,\n UseLoaderDataResult,\n} from '@tanstack/router-core'\n\nexport interface UseLoaderDataBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n match: ResolveUseLoaderData<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseLoaderDataOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseLoaderDataBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseLoaderDataRoute<out TId> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseLoaderDataBaseOptions<\n TRouter,\n TId,\n true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseLoaderDataResult<TRouter, TId, true, TSelected>\n\n/**\n * Read and select the current route's loader data with type‑safety.\n *\n * Options:\n * - `from`/`strict`: Choose which route's data to read and strictness\n * - `select`: Map the loader data to a derived value\n * - `structuralSharing`: Enable structural sharing for stable references\n *\n * @returns The loader data (or selected value) for the matched route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDataHook\n */\nexport function useLoaderData<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseLoaderDataOptions<\n TRouter,\n TFrom,\n TStrict,\n TSelected,\n TStructuralSharing\n >,\n): UseLoaderDataResult<TRouter, TFrom, TStrict, TSelected> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n structuralSharing: opts.structuralSharing,\n select: (s: any) => {\n return opts.select ? opts.select(s.loaderData) : s.loaderData\n },\n } as any) as UseLoaderDataResult<TRouter, TFrom, TStrict, TSelected>\n}\n"],"names":[],"mappings":";AAmEO,SAAS,cAOd,MAOyD;AACzD,SAAO,SAAS;AAAA,IACd,MAAM,KAAK;AAAA,IACX,QAAQ,KAAK;AAAA,IACb,mBAAmB,KAAK;AAAA,IACxB,QAAQ,CAAC,MAAW;AAClB,aAAO,KAAK,SAAS,KAAK,OAAO,EAAE,UAAU,IAAI,EAAE;AAAA,IACrD;AAAA,EAAA,CACM;AACV;"}
|
|
@@ -16,8 +16,4 @@ export type UseLoaderDepsRoute<out TId> = <TRouter extends AnyRouter = Registere
|
|
|
16
16
|
* @returns The loader deps (or selected value) for the matched route.
|
|
17
17
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDepsHook
|
|
18
18
|
*/
|
|
19
|
-
/**
|
|
20
|
-
* Read and select the current route's loader dependencies object.
|
|
21
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDepsHook
|
|
22
|
-
*/
|
|
23
19
|
export declare function useLoaderDeps<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string | undefined = undefined, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts: UseLoaderDepsOptions<TRouter, TFrom, TSelected, TStructuralSharing>): UseLoaderDepsResult<TRouter, TFrom, TSelected>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoaderDeps.js","sources":["../../src/useLoaderDeps.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseLoaderDeps,\n StrictOrFrom,\n UseLoaderDepsResult,\n} from '@tanstack/router-core'\n\nexport interface UseLoaderDepsBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n deps: ResolveUseLoaderDeps<TRouter, TFrom>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseLoaderDepsOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom> &\n UseLoaderDepsBaseOptions<TRouter, TFrom, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseLoaderDepsRoute<out TId> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseLoaderDepsBaseOptions<TRouter, TId, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, false>,\n) => UseLoaderDepsResult<TRouter, TId, TSelected>\n\n/**\n * Read and select the current route's loader dependencies object.\n *\n * Options:\n * - `from`: Choose which route's loader deps to read\n * - `select`: Map the deps to a derived value\n * - `structuralSharing`: Enable structural sharing for stable references\n *\n * @returns The loader deps (or selected value) for the matched route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDepsHook\n */\
|
|
1
|
+
{"version":3,"file":"useLoaderDeps.js","sources":["../../src/useLoaderDeps.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseLoaderDeps,\n StrictOrFrom,\n UseLoaderDepsResult,\n} from '@tanstack/router-core'\n\nexport interface UseLoaderDepsBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n deps: ResolveUseLoaderDeps<TRouter, TFrom>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseLoaderDepsOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom> &\n UseLoaderDepsBaseOptions<TRouter, TFrom, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseLoaderDepsRoute<out TId> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseLoaderDepsBaseOptions<TRouter, TId, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, false>,\n) => UseLoaderDepsResult<TRouter, TId, TSelected>\n\n/**\n * Read and select the current route's loader dependencies object.\n *\n * Options:\n * - `from`: Choose which route's loader deps to read\n * - `select`: Map the deps to a derived value\n * - `structuralSharing`: Enable structural sharing for stable references\n *\n * @returns The loader deps (or selected value) for the matched route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDepsHook\n */\nexport function useLoaderDeps<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseLoaderDepsOptions<TRouter, TFrom, TSelected, TStructuralSharing>,\n): UseLoaderDepsResult<TRouter, TFrom, TSelected> {\n const { select, ...rest } = opts\n return useMatch({\n ...rest,\n select: (s) => {\n return select ? select(s.loaderDeps) : s.loaderDeps\n },\n }) as UseLoaderDepsResult<TRouter, TFrom, TSelected>\n}\n"],"names":[],"mappings":";AAqDO,SAAS,cAMd,MACgD;AAChD,QAAM,EAAE,QAAQ,GAAG,KAAA,IAAS;AAC5B,SAAO,SAAS;AAAA,IACd,GAAG;AAAA,IACH,QAAQ,CAAC,MAAM;AACb,aAAO,SAAS,OAAO,EAAE,UAAU,IAAI,EAAE;AAAA,IAC3C;AAAA,EAAA,CACD;AACH;"}
|
|
@@ -15,9 +15,4 @@ export type UseLocationResult<TRouter extends AnyRouter, TSelected> = unknown ex
|
|
|
15
15
|
* @returns The current location (or selected value).
|
|
16
16
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLocationHook
|
|
17
17
|
*/
|
|
18
|
-
/**
|
|
19
|
-
* Read the current location from the router state with optional selection.
|
|
20
|
-
* Useful for subscribing to just the pieces of location you care about.
|
|
21
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLocationHook
|
|
22
|
-
*/
|
|
23
18
|
export declare function useLocation<TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseLocationBaseOptions<TRouter, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>): UseLocationResult<TRouter, TSelected>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocation.js","sources":["../../src/useLocation.tsx"],"sourcesContent":["import { useRouterState } from './useRouterState'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterState,\n} from '@tanstack/router-core'\n\nexport interface UseLocationBaseOptions<\n TRouter extends AnyRouter,\n TSelected,\n TStructuralSharing extends boolean = boolean,\n> {\n select?: (\n state: RouterState<TRouter['routeTree']>['location'],\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseLocationResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected\n ? RouterState<TRouter['routeTree']>['location']\n : TSelected\n\n/**\n * Read the current location from the router state with optional selection.\n * Useful for subscribing to just the pieces of location you care about.\n *\n * Options:\n * - `select`: Project the `location` object to a derived value\n * - `structuralSharing`: Enable structural sharing for stable references\n *\n * @returns The current location (or selected value).\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLocationHook\n */\
|
|
1
|
+
{"version":3,"file":"useLocation.js","sources":["../../src/useLocation.tsx"],"sourcesContent":["import { useRouterState } from './useRouterState'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterState,\n} from '@tanstack/router-core'\n\nexport interface UseLocationBaseOptions<\n TRouter extends AnyRouter,\n TSelected,\n TStructuralSharing extends boolean = boolean,\n> {\n select?: (\n state: RouterState<TRouter['routeTree']>['location'],\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseLocationResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected\n ? RouterState<TRouter['routeTree']>['location']\n : TSelected\n\n/**\n * Read the current location from the router state with optional selection.\n * Useful for subscribing to just the pieces of location you care about.\n *\n * Options:\n * - `select`: Project the `location` object to a derived value\n * - `structuralSharing`: Enable structural sharing for stable references\n *\n * @returns The current location (or selected value).\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLocationHook\n */\nexport function useLocation<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseLocationBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseLocationResult<TRouter, TSelected> {\n return useRouterState({\n select: (state: any) =>\n opts?.select ? opts.select(state.location) : state.location,\n } as any) as UseLocationResult<TRouter, TSelected>\n}\n"],"names":[],"mappings":";AAuCO,SAAS,YAKd,MAEuC;AACvC,SAAO,eAAe;AAAA,IACpB,QAAQ,CAAC,UACP,MAAM,SAAS,KAAK,OAAO,MAAM,QAAQ,IAAI,MAAM;AAAA,EAAA,CAC/C;AACV;"}
|
package/dist/esm/useParams.d.ts
CHANGED
|
@@ -18,8 +18,4 @@ export type UseParamsRoute<out TFrom> = <TRouter extends AnyRouter = RegisteredR
|
|
|
18
18
|
* @returns The params object (or selected value) for the matched route.
|
|
19
19
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useParamsHook
|
|
20
20
|
*/
|
|
21
|
-
/**
|
|
22
|
-
* Access the current route's path parameters with type-safety.
|
|
23
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useParamsHook
|
|
24
|
-
*/
|
|
25
21
|
export declare function useParams<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string | undefined = undefined, TStrict extends boolean = true, TThrow extends boolean = true, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts: UseParamsOptions<TRouter, TFrom, TStrict, ThrowConstraint<TStrict, TThrow>, TSelected, TStructuralSharing>): ThrowOrOptional<UseParamsResult<TRouter, TFrom, TStrict, TSelected>, TThrow>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useParams.js","sources":["../../src/useParams.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseParams,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseParamsResult,\n} from '@tanstack/router-core'\n\nexport interface UseParamsBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n params: ResolveUseParams<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseParamsOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseParamsBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseParamsRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseParamsBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseParamsResult<TRouter, TFrom, true, TSelected>\n\n/**\n * Access the current route's path parameters with type-safety.\n *\n * Options:\n * - `from`/`strict`: Specify the matched route and whether to enforce strict typing\n * - `select`: Project the params object to a derived value for memoized renders\n * - `structuralSharing`: Enable structural sharing for stable references\n * - `shouldThrow`: Throw if the route is not found in strict contexts\n *\n * @returns The params object (or selected value) for the matched route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useParamsHook\n */\
|
|
1
|
+
{"version":3,"file":"useParams.js","sources":["../../src/useParams.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseParams,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseParamsResult,\n} from '@tanstack/router-core'\n\nexport interface UseParamsBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n params: ResolveUseParams<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseParamsOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseParamsBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseParamsRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseParamsBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseParamsResult<TRouter, TFrom, true, TSelected>\n\n/**\n * Access the current route's path parameters with type-safety.\n *\n * Options:\n * - `from`/`strict`: Specify the matched route and whether to enforce strict typing\n * - `select`: Project the params object to a derived value for memoized renders\n * - `structuralSharing`: Enable structural sharing for stable references\n * - `shouldThrow`: Throw if the route is not found in strict contexts\n *\n * @returns The params object (or selected value) for the matched route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useParamsHook\n */\nexport function useParams<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseParamsOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<\n UseParamsResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatch({\n from: opts.from!,\n shouldThrow: opts.shouldThrow,\n structuralSharing: opts.structuralSharing,\n strict: opts.strict,\n select: (match) => {\n const params = opts.strict === false ? match.params : match._strictParams\n\n return opts.select ? opts.select(params) : params\n },\n }) as any\n}\n"],"names":[],"mappings":";AA2EO,SAAS,UAQd,MAWA;AACA,SAAO,SAAS;AAAA,IACd,MAAM,KAAK;AAAA,IACX,aAAa,KAAK;AAAA,IAClB,mBAAmB,KAAK;AAAA,IACxB,QAAQ,KAAK;AAAA,IACb,QAAQ,CAAC,UAAU;AACjB,YAAM,SAAS,KAAK,WAAW,QAAQ,MAAM,SAAS,MAAM;AAE5D,aAAO,KAAK,SAAS,KAAK,OAAO,MAAM,IAAI;AAAA,IAC7C;AAAA,EAAA,CACD;AACH;"}
|
package/dist/esm/useRouter.d.ts
CHANGED
|
@@ -9,11 +9,6 @@ import { AnyRouter, RegisteredRouter } from '@tanstack/router-core';
|
|
|
9
9
|
* @returns The registered router instance.
|
|
10
10
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook
|
|
11
11
|
*/
|
|
12
|
-
/**
|
|
13
|
-
* Access the current TanStack Router instance from React context.
|
|
14
|
-
* Must be used within a `RouterProvider`.
|
|
15
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook
|
|
16
|
-
*/
|
|
17
12
|
export declare function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {
|
|
18
13
|
warn?: boolean;
|
|
19
14
|
}): TRouter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouter.js","sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { getRouterContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\n/**\n * Access the current TanStack Router instance from React context.\n * Must be used within a `RouterProvider`.\n *\n * Options:\n * - `warn`: Log a warning if no router context is found (default: true).\n *\n * @returns The registered router instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook\n */\
|
|
1
|
+
{"version":3,"file":"useRouter.js","sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { getRouterContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\n/**\n * Access the current TanStack Router instance from React context.\n * Must be used within a `RouterProvider`.\n *\n * Options:\n * - `warn`: Log a warning if no router context is found (default: true).\n *\n * @returns The registered router instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook\n */\nexport function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {\n warn?: boolean\n}): TRouter {\n const value = React.useContext(getRouterContext())\n warning(\n !((opts?.warn ?? true) && !value),\n 'useRouter must be used inside a <RouterProvider> component!',\n )\n return value as any\n}\n"],"names":[],"mappings":";;;AAeO,SAAS,UAAwD,MAE5D;AACV,QAAM,QAAQ,MAAM,WAAW,iBAAA,CAAkB;AACjD;AAAA,IACE,GAAG,MAAM,QAAQ,SAAS,CAAC;AAAA,IAC3B;AAAA,EAAA;AAEF,SAAO;AACT;"}
|
|
@@ -17,9 +17,4 @@ export type UseRouterStateResult<TRouter extends AnyRouter, TSelected> = unknown
|
|
|
17
17
|
* @returns The selected router state (or the full state by default).
|
|
18
18
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterStateHook
|
|
19
19
|
*/
|
|
20
|
-
/**
|
|
21
|
-
* Subscribe to the router's state store with optional selection and
|
|
22
|
-
* structural sharing for render optimization.
|
|
23
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterStateHook
|
|
24
|
-
*/
|
|
25
20
|
export declare function useRouterState<TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseRouterStateOptions<TRouter, TSelected, TStructuralSharing>): UseRouterStateResult<TRouter, TSelected>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouterState.js","sources":["../../src/useRouterState.tsx"],"sourcesContent":["import { useStore } from '@tanstack/react-store'\nimport { useRef } from 'react'\nimport { replaceEqualDeep } from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterState,\n} from '@tanstack/router-core'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\n\nexport type UseRouterStateOptions<\n TRouter extends AnyRouter,\n TSelected,\n TStructuralSharing,\n> = {\n router?: TRouter\n select?: (\n state: RouterState<TRouter['routeTree']>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n} & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseRouterStateResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? RouterState<TRouter['routeTree']> : TSelected\n\n/**\n * Subscribe to the router's state store with optional selection and\n * structural sharing for render optimization.\n *\n * Options:\n * - `select`: Project the full router state to a derived slice\n * - `structuralSharing`: Replace-equal semantics for stable references\n * - `router`: Read state from a specific router instance instead of context\n *\n * @returns The selected router state (or the full state by default).\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterStateHook\n */\
|
|
1
|
+
{"version":3,"file":"useRouterState.js","sources":["../../src/useRouterState.tsx"],"sourcesContent":["import { useStore } from '@tanstack/react-store'\nimport { useRef } from 'react'\nimport { replaceEqualDeep } from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterState,\n} from '@tanstack/router-core'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\n\nexport type UseRouterStateOptions<\n TRouter extends AnyRouter,\n TSelected,\n TStructuralSharing,\n> = {\n router?: TRouter\n select?: (\n state: RouterState<TRouter['routeTree']>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n} & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseRouterStateResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? RouterState<TRouter['routeTree']> : TSelected\n\n/**\n * Subscribe to the router's state store with optional selection and\n * structural sharing for render optimization.\n *\n * Options:\n * - `select`: Project the full router state to a derived slice\n * - `structuralSharing`: Replace-equal semantics for stable references\n * - `router`: Read state from a specific router instance instead of context\n *\n * @returns The selected router state (or the full state by default).\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterStateHook\n */\nexport function useRouterState<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseRouterStateOptions<TRouter, TSelected, TStructuralSharing>,\n): UseRouterStateResult<TRouter, TSelected> {\n const contextRouter = useRouter<TRouter>({\n warn: opts?.router === undefined,\n })\n const router = opts?.router || contextRouter\n const previousResult =\n useRef<ValidateSelected<TRouter, TSelected, TStructuralSharing>>(undefined)\n\n return useStore(router.__store, (state) => {\n if (opts?.select) {\n if (opts.structuralSharing ?? router.options.defaultStructuralSharing) {\n const newSlice = replaceEqualDeep(\n previousResult.current,\n opts.select(state),\n )\n previousResult.current = newSlice\n return newSlice\n }\n return opts.select(state)\n }\n return state\n }) as UseRouterStateResult<TRouter, TSelected>\n}\n"],"names":[],"mappings":";;;;AA0CO,SAAS,eAKd,MAC0C;AAC1C,QAAM,gBAAgB,UAAmB;AAAA,IACvC,MAAM,MAAM,WAAW;AAAA,EAAA,CACxB;AACD,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,iBACJ,OAAiE,MAAS;AAE5E,SAAO,SAAS,OAAO,SAAS,CAAC,UAAU;AACzC,QAAI,MAAM,QAAQ;AAChB,UAAI,KAAK,qBAAqB,OAAO,QAAQ,0BAA0B;AACrE,cAAM,WAAW;AAAA,UACf,eAAe;AAAA,UACf,KAAK,OAAO,KAAK;AAAA,QAAA;AAEnB,uBAAe,UAAU;AACzB,eAAO;AAAA,MACT;AACA,aAAO,KAAK,OAAO,KAAK;AAAA,IAC1B;AACA,WAAO;AAAA,EACT,CAAC;AACH;"}
|
package/dist/esm/useSearch.d.ts
CHANGED
|
@@ -18,8 +18,4 @@ export type UseSearchRoute<out TFrom> = <TRouter extends AnyRouter = RegisteredR
|
|
|
18
18
|
* @returns The search object (or selected value) for the matched route.
|
|
19
19
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useSearchHook
|
|
20
20
|
*/
|
|
21
|
-
/**
|
|
22
|
-
* Read and select the current route's search parameters with type-safety.
|
|
23
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useSearchHook
|
|
24
|
-
*/
|
|
25
21
|
export declare function useSearch<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string | undefined = undefined, TStrict extends boolean = true, TThrow extends boolean = true, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts: UseSearchOptions<TRouter, TFrom, TStrict, ThrowConstraint<TStrict, TThrow>, TSelected, TStructuralSharing>): ThrowOrOptional<UseSearchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearch.js","sources":["../../src/useSearch.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseSearch,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseSearchResult,\n} from '@tanstack/router-core'\n\nexport interface UseSearchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n state: ResolveUseSearch<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseSearchOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseSearchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseSearchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseSearchBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseSearchResult<TRouter, TFrom, true, TSelected>\n\n/**\n * Read and select the current route's search parameters with type-safety.\n *\n * Options:\n * - `from`/`strict`: Control which route's search is read and how strictly it's typed\n * - `select`: Map the search object to a derived value for render optimization\n * - `structuralSharing`: Enable structural sharing for stable references\n * - `shouldThrow`: Throw when the route is not found (strict contexts)\n *\n * @returns The search object (or selected value) for the matched route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useSearchHook\n */\
|
|
1
|
+
{"version":3,"file":"useSearch.js","sources":["../../src/useSearch.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseSearch,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseSearchResult,\n} from '@tanstack/router-core'\n\nexport interface UseSearchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n state: ResolveUseSearch<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseSearchOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseSearchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseSearchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseSearchBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseSearchResult<TRouter, TFrom, true, TSelected>\n\n/**\n * Read and select the current route's search parameters with type-safety.\n *\n * Options:\n * - `from`/`strict`: Control which route's search is read and how strictly it's typed\n * - `select`: Map the search object to a derived value for render optimization\n * - `structuralSharing`: Enable structural sharing for stable references\n * - `shouldThrow`: Throw when the route is not found (strict contexts)\n *\n * @returns The search object (or selected value) for the matched route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useSearchHook\n */\nexport function useSearch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseSearchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<\n UseSearchResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n structuralSharing: opts.structuralSharing,\n select: (match: any) => {\n return opts.select ? opts.select(match.search) : match.search\n },\n }) as any\n}\n"],"names":[],"mappings":";AA2EO,SAAS,UAQd,MAWA;AACA,SAAO,SAAS;AAAA,IACd,MAAM,KAAK;AAAA,IACX,QAAQ,KAAK;AAAA,IACb,aAAa,KAAK;AAAA,IAClB,mBAAmB,KAAK;AAAA,IACxB,QAAQ,CAAC,UAAe;AACtB,aAAO,KAAK,SAAS,KAAK,OAAO,MAAM,MAAM,IAAI,MAAM;AAAA,IACzD;AAAA,EAAA,CACD;AACH;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
|
-
"version": "1.141.
|
|
3
|
+
"version": "1.141.6",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"tiny-invariant": "^1.3.3",
|
|
81
81
|
"tiny-warning": "^1.0.3",
|
|
82
82
|
"@tanstack/history": "1.141.0",
|
|
83
|
-
"@tanstack/router-core": "1.141.
|
|
83
|
+
"@tanstack/router-core": "1.141.6"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@testing-library/jest-dom": "^6.6.3",
|
package/src/ClientOnly.tsx
CHANGED
|
@@ -28,11 +28,6 @@ export interface ClientOnlyProps {
|
|
|
28
28
|
* )
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
/**
|
|
32
|
-
* Render children only after client hydration; otherwise render `fallback`.
|
|
33
|
-
* Useful for components that require browser-only APIs.
|
|
34
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/clientOnlyComponent
|
|
35
|
-
*/
|
|
36
31
|
export function ClientOnly({ children, fallback = null }: ClientOnlyProps) {
|
|
37
32
|
return useHydrated() ? (
|
|
38
33
|
<React.Fragment>{children}</React.Fragment>
|
|
@@ -60,9 +55,6 @@ export function ClientOnly({ children, fallback = null }: ClientOnlyProps) {
|
|
|
60
55
|
* ```
|
|
61
56
|
* @returns True if the JS has been hydrated already, false otherwise.
|
|
62
57
|
*/
|
|
63
|
-
/**
|
|
64
|
-
* Return a boolean indicating whether client hydration has occurred.
|
|
65
|
-
*/
|
|
66
58
|
export function useHydrated(): boolean {
|
|
67
59
|
return React.useSyncExternalStore(
|
|
68
60
|
subscribe,
|
package/src/HeadContent.tsx
CHANGED
|
@@ -187,10 +187,6 @@ export const useTags = () => {
|
|
|
187
187
|
)
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
/**
|
|
191
|
-
* @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.
|
|
192
|
-
* It should be rendered in the `<head>` of your document.
|
|
193
|
-
*/
|
|
194
190
|
/**
|
|
195
191
|
* Render route-managed head tags (title, meta, links, styles, head scripts).
|
|
196
192
|
* Place inside the document head of your app shell.
|
package/src/Matches.tsx
CHANGED
|
@@ -41,10 +41,6 @@ declare module '@tanstack/router-core' {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
* Internal component that renders the router's active match tree with
|
|
46
|
-
* suspense, error, and not-found boundaries. Rendered by `RouterProvider`.
|
|
47
|
-
*/
|
|
48
44
|
/**
|
|
49
45
|
* Internal component that renders the router's active match tree with
|
|
50
46
|
* suspense, error, and not-found boundaries. Rendered by `RouterProvider`.
|
|
@@ -263,10 +259,6 @@ export function useMatches<
|
|
|
263
259
|
*
|
|
264
260
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook
|
|
265
261
|
*/
|
|
266
|
-
/**
|
|
267
|
-
* Read the full array of active route matches or select a derived subset
|
|
268
|
-
* from the parent boundary up to (but not including) the current match.
|
|
269
|
-
*/
|
|
270
262
|
export function useParentMatches<
|
|
271
263
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
272
264
|
TSelected = unknown,
|
|
@@ -289,10 +281,6 @@ export function useParentMatches<
|
|
|
289
281
|
} as any)
|
|
290
282
|
}
|
|
291
283
|
|
|
292
|
-
/**
|
|
293
|
-
* Read the array of active route matches that are children of the current
|
|
294
|
-
* match (or selected parent) in the match tree.
|
|
295
|
-
*/
|
|
296
284
|
/**
|
|
297
285
|
* Read the array of active route matches that are children of the current
|
|
298
286
|
* match (or selected parent) in the match tree.
|
package/src/RouterProvider.tsx
CHANGED
|
@@ -7,10 +7,6 @@ import type {
|
|
|
7
7
|
RouterOptions,
|
|
8
8
|
} from '@tanstack/router-core'
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* Low-level provider that places the router into React context and optionally
|
|
12
|
-
* updates router options from props. Most apps should use `RouterProvider`.
|
|
13
|
-
*/
|
|
14
10
|
/**
|
|
15
11
|
* Low-level provider that places the router into React context and optionally
|
|
16
12
|
* updates router options from props. Most apps should use `RouterProvider`.
|
|
@@ -61,11 +57,6 @@ export function RouterContextProvider<
|
|
|
61
57
|
*
|
|
62
58
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
|
|
63
59
|
*/
|
|
64
|
-
/**
|
|
65
|
-
* Top-level component that renders the active route matches and provides the
|
|
66
|
-
* router to the React tree via context. Accepts the same options as
|
|
67
|
-
* `createRouter` via props to update the router instance.
|
|
68
|
-
*/
|
|
69
60
|
export function RouterProvider<
|
|
70
61
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
71
62
|
TDehydrated extends Record<string, any> = Record<string, any>,
|
package/src/ScriptOnce.tsx
CHANGED
|
@@ -12,9 +12,8 @@ export function ScriptOnce({ children }: { children: string }) {
|
|
|
12
12
|
return (
|
|
13
13
|
<script
|
|
14
14
|
nonce={router.options.ssr?.nonce}
|
|
15
|
-
className="$tsr"
|
|
16
15
|
dangerouslySetInnerHTML={{
|
|
17
|
-
__html: children + ';
|
|
16
|
+
__html: children + ';document.currentScript.remove()',
|
|
18
17
|
}}
|
|
19
18
|
/>
|
|
20
19
|
)
|
package/src/Scripts.tsx
CHANGED
|
@@ -3,10 +3,6 @@ import { useRouterState } from './useRouterState'
|
|
|
3
3
|
import { useRouter } from './useRouter'
|
|
4
4
|
import type { RouterManagedTag } from '@tanstack/router-core'
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Render body script tags collected from route matches and SSR manifests.
|
|
8
|
-
* Should be placed near the end of the document body.
|
|
9
|
-
*/
|
|
10
6
|
/**
|
|
11
7
|
* Render body script tags collected from route matches and SSR manifests.
|
|
12
8
|
* Should be placed near the end of the document body.
|
package/src/awaited.tsx
CHANGED
|
@@ -7,7 +7,6 @@ export type AwaitOptions<T> = {
|
|
|
7
7
|
promise: Promise<T>
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
/** Suspend until a deferred promise resolves/rejects and return its data. */
|
|
11
10
|
/** Suspend until a deferred promise resolves or rejects and return its data. */
|
|
12
11
|
export function useAwaited<T>({
|
|
13
12
|
promise: _promise,
|
|
@@ -25,10 +24,6 @@ export function useAwaited<T>({
|
|
|
25
24
|
return [promise[TSR_DEFERRED_PROMISE].data, promise]
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
/**
|
|
29
|
-
* Component that suspends on a deferred promise and renders its child with
|
|
30
|
-
* the resolved value. Optionally provides a Suspense fallback.
|
|
31
|
-
*/
|
|
32
27
|
/**
|
|
33
28
|
* Component that suspends on a deferred promise and renders its child with
|
|
34
29
|
* the resolved value. Optionally provides a Suspense fallback.
|
package/src/fileRoute.ts
CHANGED
|
@@ -46,24 +46,6 @@ import type { UseRouteContextRoute } from './useRouteContext'
|
|
|
46
46
|
* @returns A function that accepts Route options and returns a Route instance.
|
|
47
47
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
|
|
48
48
|
*/
|
|
49
|
-
/**
|
|
50
|
-
* Creates a file-based Route factory for a given path.
|
|
51
|
-
*
|
|
52
|
-
* Used by TanStack Router's file-based routing to associate a file with a
|
|
53
|
-
* route. The returned function accepts standard route options. In normal usage
|
|
54
|
-
* the `path` string is inserted and maintained by the `tsr` generator.
|
|
55
|
-
*
|
|
56
|
-
* @param path File path literal for the route (usually auto-generated).
|
|
57
|
-
* @returns A function that accepts Route options and returns a Route instance.
|
|
58
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
|
|
59
|
-
*/
|
|
60
|
-
/**
|
|
61
|
-
* Creates a file-based Route factory for a given path.
|
|
62
|
-
* Used by file-based routing to associate a file with a route. The returned
|
|
63
|
-
* function accepts standard route options; the path is typically auto-managed
|
|
64
|
-
* by the generator.
|
|
65
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
|
|
66
|
-
*/
|
|
67
49
|
export function createFileRoute<
|
|
68
50
|
TFilePath extends keyof FileRoutesByPath,
|
|
69
51
|
TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],
|
|
@@ -177,16 +159,6 @@ export class FileRoute<
|
|
|
177
159
|
}
|
|
178
160
|
}
|
|
179
161
|
|
|
180
|
-
/**
|
|
181
|
-
@deprecated It's recommended not to split loaders into separate files.
|
|
182
|
-
Instead, place the loader function in the the main route file, inside the
|
|
183
|
-
`createFileRoute('/path/to/file)(options)` options.
|
|
184
|
-
*/
|
|
185
|
-
/**
|
|
186
|
-
@deprecated It's recommended not to split loaders into separate files.
|
|
187
|
-
Instead, place the loader function in the the main route file, inside the
|
|
188
|
-
`createFileRoute('/path/to/file)(options)` options.
|
|
189
|
-
*/
|
|
190
162
|
/**
|
|
191
163
|
@deprecated It's recommended not to split loaders into separate files.
|
|
192
164
|
Instead, place the loader function in the main route file via `createFileRoute`.
|
|
@@ -303,22 +275,6 @@ export class LazyRoute<TRoute extends AnyRoute> {
|
|
|
303
275
|
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
|
|
304
276
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
|
|
305
277
|
*/
|
|
306
|
-
/**
|
|
307
|
-
* Creates a lazily-configurable code-based route stub by ID.
|
|
308
|
-
*
|
|
309
|
-
* Use this for code-splitting with code-based routes. The returned function
|
|
310
|
-
* accepts only non-critical route options like `component`, `pendingComponent`,
|
|
311
|
-
* `errorComponent`, and `notFoundComponent` which are applied when the route
|
|
312
|
-
* is matched.
|
|
313
|
-
*
|
|
314
|
-
* @param id Route ID string literal to associate with the lazy route.
|
|
315
|
-
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
|
|
316
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
|
|
317
|
-
*/
|
|
318
|
-
/**
|
|
319
|
-
* Create a lazily-configurable code-based route stub by ID.
|
|
320
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
|
|
321
|
-
*/
|
|
322
278
|
export function createLazyRoute<
|
|
323
279
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
324
280
|
TId extends string = string,
|
|
@@ -343,21 +299,6 @@ export function createLazyRoute<
|
|
|
343
299
|
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
|
|
344
300
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
|
|
345
301
|
*/
|
|
346
|
-
/**
|
|
347
|
-
* Creates a lazily-configurable file-based route stub by file path.
|
|
348
|
-
*
|
|
349
|
-
* Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).
|
|
350
|
-
* The returned function accepts only non-critical route options like
|
|
351
|
-
* `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.
|
|
352
|
-
*
|
|
353
|
-
* @param id File path literal for the route file.
|
|
354
|
-
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
|
|
355
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
|
|
356
|
-
*/
|
|
357
|
-
/**
|
|
358
|
-
* Create a lazily-configurable file-based route stub by file path.
|
|
359
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
|
|
360
|
-
*/
|
|
361
302
|
export function createLazyFileRoute<
|
|
362
303
|
TFilePath extends keyof FileRoutesByPath,
|
|
363
304
|
TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],
|
package/src/router.ts
CHANGED
|
@@ -88,11 +88,6 @@ declare module '@tanstack/router-core' {
|
|
|
88
88
|
* @returns A Router instance to be provided to `RouterProvider`.
|
|
89
89
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
|
|
90
90
|
*/
|
|
91
|
-
/**
|
|
92
|
-
* Create a new React router instance from `RouterOptions`.
|
|
93
|
-
* Pass the resulting router to `RouterProvider`.
|
|
94
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
|
|
95
|
-
*/
|
|
96
91
|
export const createRouter: CreateRouterFn = (options) => {
|
|
97
92
|
return new Router(options)
|
|
98
93
|
}
|
package/src/useLoaderData.tsx
CHANGED
|
@@ -65,10 +65,6 @@ export type UseLoaderDataRoute<out TId> = <
|
|
|
65
65
|
* @returns The loader data (or selected value) for the matched route.
|
|
66
66
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDataHook
|
|
67
67
|
*/
|
|
68
|
-
/**
|
|
69
|
-
* Read and select the current route's loader data with type‑safety.
|
|
70
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDataHook
|
|
71
|
-
*/
|
|
72
68
|
export function useLoaderData<
|
|
73
69
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
74
70
|
const TFrom extends string | undefined = undefined,
|
package/src/useLoaderDeps.tsx
CHANGED
|
@@ -51,10 +51,6 @@ export type UseLoaderDepsRoute<out TId> = <
|
|
|
51
51
|
* @returns The loader deps (or selected value) for the matched route.
|
|
52
52
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDepsHook
|
|
53
53
|
*/
|
|
54
|
-
/**
|
|
55
|
-
* Read and select the current route's loader dependencies object.
|
|
56
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDepsHook
|
|
57
|
-
*/
|
|
58
54
|
export function useLoaderDeps<
|
|
59
55
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
60
56
|
const TFrom extends string | undefined = undefined,
|
package/src/useLocation.tsx
CHANGED
|
@@ -37,11 +37,6 @@ export type UseLocationResult<
|
|
|
37
37
|
* @returns The current location (or selected value).
|
|
38
38
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLocationHook
|
|
39
39
|
*/
|
|
40
|
-
/**
|
|
41
|
-
* Read the current location from the router state with optional selection.
|
|
42
|
-
* Useful for subscribing to just the pieces of location you care about.
|
|
43
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLocationHook
|
|
44
|
-
*/
|
|
45
40
|
export function useLocation<
|
|
46
41
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
47
42
|
TSelected = unknown,
|