@tanstack/solid-router 1.121.0-alpha.22 → 1.121.0-alpha.28
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/Asset.cjs +65 -21
- package/dist/cjs/Asset.cjs.map +1 -1
- package/dist/cjs/Asset.d.cts +2 -1
- package/dist/cjs/CatchBoundary.cjs +14 -15
- package/dist/cjs/CatchBoundary.cjs.map +1 -1
- package/dist/cjs/ClientOnly.cjs +12 -14
- package/dist/cjs/ClientOnly.cjs.map +1 -1
- package/dist/cjs/ClientOnly.d.cts +0 -20
- package/dist/cjs/HeadContent.cjs +28 -23
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/Match.cjs +167 -141
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +26 -24
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +1 -0
- package/dist/cjs/RouterProvider.cjs +5 -5
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/SafeFragment.cjs +2 -2
- package/dist/cjs/SafeFragment.cjs.map +1 -1
- package/dist/cjs/ScriptOnce.cjs +4 -9
- package/dist/cjs/ScriptOnce.cjs.map +1 -1
- package/dist/cjs/ScriptOnce.d.cts +1 -1
- package/dist/cjs/Scripts.cjs +9 -13
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/ScrollRestoration.cjs +3 -4
- package/dist/cjs/ScrollRestoration.cjs.map +1 -1
- package/dist/cjs/Transitioner.cjs +9 -8
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/awaited.cjs +2 -2
- package/dist/cjs/awaited.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs +5 -5
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/index.cjs +0 -12
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +3 -6
- package/dist/cjs/lazyRouteComponent.cjs +6 -26
- package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
- package/dist/cjs/lazyRouteComponent.d.cts +1 -1
- package/dist/cjs/link.cjs +37 -31
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/not-found.cjs +5 -7
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/renderRouteNotFound.cjs +4 -4
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/route.cjs +16 -16
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +14 -5
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/routerContext.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.cjs +12 -6
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/ssr/RouterClient.cjs +45 -0
- package/dist/cjs/ssr/RouterClient.cjs.map +1 -0
- package/dist/cjs/ssr/RouterClient.d.cts +4 -0
- package/dist/cjs/ssr/RouterServer.cjs +56 -0
- package/dist/cjs/ssr/RouterServer.cjs.map +1 -0
- package/dist/cjs/ssr/RouterServer.d.cts +5 -0
- package/dist/cjs/ssr/client.cjs +5 -0
- package/dist/cjs/ssr/client.cjs.map +1 -0
- package/dist/cjs/ssr/client.d.cts +1 -0
- package/dist/cjs/ssr/defaultRenderHandler.cjs +18 -0
- package/dist/cjs/ssr/defaultRenderHandler.cjs.map +1 -0
- package/dist/cjs/ssr/defaultRenderHandler.d.cts +1 -0
- package/dist/cjs/ssr/defaultStreamHandler.cjs +20 -0
- package/dist/cjs/ssr/defaultStreamHandler.cjs.map +1 -0
- package/dist/cjs/ssr/defaultStreamHandler.d.cts +1 -0
- package/dist/cjs/ssr/renderRouterToStream.cjs +45 -0
- package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -0
- package/dist/cjs/ssr/renderRouterToStream.d.cts +8 -0
- package/dist/cjs/ssr/renderRouterToString.cjs +43 -0
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -0
- package/dist/cjs/ssr/renderRouterToString.d.cts +7 -0
- package/dist/cjs/ssr/server.cjs +20 -0
- package/dist/cjs/ssr/server.cjs.map +1 -0
- package/dist/cjs/ssr/server.d.cts +6 -0
- package/dist/cjs/useBlocker.cjs +41 -35
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.cjs.map +1 -1
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLocation.cjs +1 -1
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useNavigate.cjs +9 -3
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useRouter.cjs +1 -1
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouterState.cjs +3 -3
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/utils.cjs +1 -1
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/esm/Asset.d.ts +2 -1
- package/dist/esm/Asset.js +60 -16
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/CatchBoundary.js +1 -2
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ClientOnly.d.ts +0 -20
- package/dist/esm/ClientOnly.js +11 -13
- package/dist/esm/ClientOnly.js.map +1 -1
- package/dist/esm/HeadContent.js +23 -18
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Match.js +148 -122
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.d.ts +1 -0
- package/dist/esm/Matches.js +18 -16
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/SafeFragment.js.map +1 -1
- package/dist/esm/ScriptOnce.d.ts +1 -1
- package/dist/esm/ScriptOnce.js +2 -7
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.js +7 -11
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/ScrollRestoration.js +3 -4
- package/dist/esm/ScrollRestoration.js.map +1 -1
- package/dist/esm/Transitioner.js +9 -8
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.js +5 -5
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +3 -6
- package/dist/esm/index.js +2 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lazyRouteComponent.d.ts +1 -1
- package/dist/esm/lazyRouteComponent.js +2 -22
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.js +34 -28
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/not-found.js +2 -4
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/route.d.ts +14 -5
- package/dist/esm/route.js +12 -12
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.js +10 -4
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.d.ts +4 -0
- package/dist/esm/ssr/RouterClient.js +45 -0
- package/dist/esm/ssr/RouterClient.js.map +1 -0
- package/dist/esm/ssr/RouterServer.d.ts +5 -0
- package/dist/esm/ssr/RouterServer.js +56 -0
- package/dist/esm/ssr/RouterServer.js.map +1 -0
- package/dist/esm/ssr/client.d.ts +1 -0
- package/dist/esm/ssr/client.js +5 -0
- package/dist/esm/ssr/client.js.map +1 -0
- package/dist/esm/ssr/defaultRenderHandler.d.ts +1 -0
- package/dist/esm/ssr/defaultRenderHandler.js +18 -0
- package/dist/esm/ssr/defaultRenderHandler.js.map +1 -0
- package/dist/esm/ssr/defaultStreamHandler.d.ts +1 -0
- package/dist/esm/ssr/defaultStreamHandler.js +20 -0
- package/dist/esm/ssr/defaultStreamHandler.js.map +1 -0
- package/dist/esm/ssr/renderRouterToStream.d.ts +8 -0
- package/dist/esm/ssr/renderRouterToStream.js +28 -0
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -0
- package/dist/esm/ssr/renderRouterToString.d.ts +7 -0
- package/dist/esm/ssr/renderRouterToString.js +26 -0
- package/dist/esm/ssr/renderRouterToString.js.map +1 -0
- package/dist/esm/ssr/server.d.ts +6 -0
- package/dist/esm/ssr/server.js +14 -0
- package/dist/esm/ssr/server.js.map +1 -0
- package/dist/esm/useBlocker.js +41 -35
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.js +1 -1
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.js +9 -3
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouter.js +1 -1
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.js +3 -3
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.js +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/source/Asset.d.ts +2 -1
- package/dist/source/Asset.jsx +45 -7
- package/dist/source/Asset.jsx.map +1 -1
- package/dist/source/ClientOnly.d.ts +0 -20
- package/dist/source/ClientOnly.jsx +3 -29
- package/dist/source/ClientOnly.jsx.map +1 -1
- package/dist/source/HeadContent.jsx +13 -0
- package/dist/source/HeadContent.jsx.map +1 -1
- package/dist/source/Match.jsx +74 -61
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.d.ts +1 -0
- package/dist/source/Matches.jsx +14 -11
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/ScriptOnce.d.ts +1 -1
- package/dist/source/ScriptOnce.jsx +2 -12
- package/dist/source/ScriptOnce.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +8 -8
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/index.d.ts +3 -6
- package/dist/source/index.jsx +1 -4
- package/dist/source/index.jsx.map +1 -1
- package/dist/source/lazyRouteComponent.d.ts +1 -1
- package/dist/source/lazyRouteComponent.jsx +7 -21
- package/dist/source/lazyRouteComponent.jsx.map +1 -1
- package/dist/source/link.jsx +22 -17
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/route.d.ts +14 -5
- package/dist/source/route.jsx.map +1 -1
- package/dist/source/scroll-restoration.jsx +9 -2
- package/dist/source/scroll-restoration.jsx.map +1 -1
- package/dist/source/ssr/RouterClient.d.ts +4 -0
- package/dist/source/ssr/RouterClient.jsx +28 -0
- package/dist/source/ssr/RouterClient.jsx.map +1 -0
- package/dist/source/ssr/RouterServer.d.ts +5 -0
- package/dist/source/ssr/RouterServer.jsx +38 -0
- package/dist/source/ssr/RouterServer.jsx.map +1 -0
- package/dist/source/ssr/client.d.ts +1 -0
- package/dist/source/ssr/client.js +2 -0
- package/dist/source/ssr/client.js.map +1 -0
- package/dist/source/ssr/defaultRenderHandler.d.ts +1 -0
- package/dist/source/ssr/defaultRenderHandler.jsx +9 -0
- package/dist/source/ssr/defaultRenderHandler.jsx.map +1 -0
- package/dist/source/ssr/defaultStreamHandler.d.ts +1 -0
- package/dist/source/ssr/defaultStreamHandler.jsx +10 -0
- package/dist/source/ssr/defaultStreamHandler.jsx.map +1 -0
- package/dist/source/ssr/renderRouterToStream.d.ts +8 -0
- package/dist/source/ssr/renderRouterToStream.jsx +17 -0
- package/dist/source/ssr/renderRouterToStream.jsx.map +1 -0
- package/dist/source/ssr/renderRouterToString.d.ts +7 -0
- package/dist/source/ssr/renderRouterToString.jsx +20 -0
- package/dist/source/ssr/renderRouterToString.jsx.map +1 -0
- package/dist/source/ssr/server.d.ts +6 -0
- package/dist/source/ssr/server.js +7 -0
- package/dist/source/ssr/server.js.map +1 -0
- package/dist/source/useBlocker.jsx +44 -27
- package/dist/source/useBlocker.jsx.map +1 -1
- package/dist/source/useNavigate.jsx +12 -2
- package/dist/source/useNavigate.jsx.map +1 -1
- package/package.json +34 -7
- package/src/Asset.tsx +76 -7
- package/src/ClientOnly.tsx +5 -32
- package/src/HeadContent.tsx +17 -0
- package/src/Match.tsx +103 -81
- package/src/Matches.tsx +28 -19
- package/src/ScriptOnce.tsx +1 -13
- package/src/Transitioner.tsx +7 -7
- package/src/index.tsx +1 -18
- package/src/lazyRouteComponent.tsx +6 -26
- package/src/link.tsx +29 -21
- package/src/not-found.tsx +1 -1
- package/src/route.tsx +16 -5
- package/src/scroll-restoration.tsx +10 -3
- package/src/ssr/RouterClient.tsx +43 -0
- package/src/ssr/RouterServer.tsx +60 -0
- package/src/ssr/client.ts +1 -0
- package/src/ssr/defaultRenderHandler.tsx +12 -0
- package/src/ssr/defaultStreamHandler.tsx +13 -0
- package/src/ssr/renderRouterToStream.tsx +36 -0
- package/src/ssr/renderRouterToString.tsx +31 -0
- package/src/ssr/server.ts +6 -0
- package/src/useBlocker.tsx +48 -32
- package/src/useNavigate.tsx +14 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileRoute.cjs","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderFn,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n >(\n options?: FileBaseRouteOptions<\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown\n > => {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/** \n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderFn<\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n return (loaderFn) => loaderFn as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\n}\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\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 return useSearch({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\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":["route","createRoute","opts","useMatch","useSearch","useParams","useLoaderDeps","useLoaderData","useRouter","useNavigate"],"mappings":";;;;;;;;;;;AAoCO,SAAS,gBAQd,MAC0E;
|
|
1
|
+
{"version":3,"file":"fileRoute.cjs","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderFn,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n >(\n options?: FileBaseRouteOptions<\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown\n > => {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/** \n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderFn<\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n return (loaderFn) => loaderFn as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\n}\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\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 return useSearch({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\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":["route","createRoute","opts","useMatch","useSearch","useParams","useLoaderDeps","useLoaderData","useRouter","useNavigate"],"mappings":";;;;;;;;;;;AAoCO,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,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YAAM,SAASM,UAAAA,UAAA;AACf,aAAOC,YAAAA,YAAY,EAAE,MAAM,OAAO,WAAW,KAAK,QAAQ,EAAE,EAAE,UAAU;AAAA,IAC1E;AA1CE,SAAK,UAAU;AAAA,EACjB;AA0CF;AAEO,SAAS,gBAId,IAA2D;AAC3D,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,EACH;AACF;AACO,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/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const invariant = require("tiny-invariant");
|
|
4
|
-
const warning = require("tiny-warning");
|
|
5
3
|
const routerCore = require("@tanstack/router-core");
|
|
6
4
|
const history = require("@tanstack/history");
|
|
7
5
|
const awaited = require("./awaited.cjs");
|
|
@@ -36,8 +34,6 @@ const ScriptOnce = require("./ScriptOnce.cjs");
|
|
|
36
34
|
const Asset = require("./Asset.cjs");
|
|
37
35
|
const HeadContent = require("./HeadContent.cjs");
|
|
38
36
|
const Scripts = require("./Scripts.cjs");
|
|
39
|
-
exports.invariant = invariant;
|
|
40
|
-
exports.warning = warning;
|
|
41
37
|
Object.defineProperty(exports, "PathParamError", {
|
|
42
38
|
enumerable: true,
|
|
43
39
|
get: () => routerCore.PathParamError
|
|
@@ -90,10 +86,6 @@ Object.defineProperty(exports, "encode", {
|
|
|
90
86
|
enumerable: true,
|
|
91
87
|
get: () => routerCore.encode
|
|
92
88
|
});
|
|
93
|
-
Object.defineProperty(exports, "escapeJSON", {
|
|
94
|
-
enumerable: true,
|
|
95
|
-
get: () => routerCore.escapeJSON
|
|
96
|
-
});
|
|
97
89
|
Object.defineProperty(exports, "functionalUpdate", {
|
|
98
90
|
enumerable: true,
|
|
99
91
|
get: () => routerCore.functionalUpdate
|
|
@@ -182,10 +174,6 @@ Object.defineProperty(exports, "rootRouteId", {
|
|
|
182
174
|
enumerable: true,
|
|
183
175
|
get: () => routerCore.rootRouteId
|
|
184
176
|
});
|
|
185
|
-
Object.defineProperty(exports, "shallow", {
|
|
186
|
-
enumerable: true,
|
|
187
|
-
get: () => routerCore.shallow
|
|
188
|
-
});
|
|
189
177
|
Object.defineProperty(exports, "stringifySearchWith", {
|
|
190
178
|
enumerable: true,
|
|
191
179
|
get: () => routerCore.stringifySearchWith
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { defer, TSR_DEFERRED_PROMISE, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, parsePathname, interpolatePath, matchPathname, removeBasepath, matchByPath, encode, decode, rootRouteId, defaultSerializeError, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, escapeJSON, // SSR
|
|
4
|
-
pick, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, shallow, createControlledPromise, retainSearchParams, stripSearchParams, } from '@tanstack/router-core';
|
|
5
|
-
export type { StartSerializer, Serializable, SerializerParse, SerializerParseBy, SerializerStringify, SerializerStringifyBy, DeferredPromiseState, DeferredPromise, ParsedLocation, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, Segment, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, ResolveOptionalParams, ResolveRequiredParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, TrailingSlashOption, ExtractedEntry, ExtractedStream, ExtractedPromise, StreamState, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, NavigateFn, BuildLocationFn, InferDescendantToPaths, RelativeToPath, RelativeToParentPath, RelativeToCurrentPath, Register, AbsoluteToPath, RelativeToPathAutoComplete, NavigateOptions, ToOptions, ToMaskOptions, ToSubOptions, ResolveRoute, SearchParamOptions, PathParamOptions, ToPathOption, LinkOptions, MakeOptionalPathParams, AnyRouterWithContext, ParseRoute, RoutesById, RouteById, RouteIds, RoutesByPath, RouteByPath, RoutePaths, FullSearchSchema, AllParams, AllLoaderData, FullSearchSchemaInput, AllContext, CommitLocationOptions, MatchLocation, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, ResolveAllParamsFromParent, RouteContextParameter, BeforeLoadContextParameter, ResolveAllContext, FullSearchSchemaOption, MakeRemountDepsOptionsUnion, RemountDepsOptions, FileRouteTypes, FileRoutesByPath, UseNavigateResult, AnyRedirect, Redirect, ResolvedRedirect, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, RouteLoaderFn, LoaderFnContext, MakeRouteMatch, MakeRouteMatchUnion, RouteMatch, AnyRouteMatch, RouteContextFn, RouteContextOptions, BeforeLoadFn, BeforeLoadContextOptions, ContextOptions, RootRouteOptions, AnyRouteWithContext, LazyRouteOptions, AnyRoute, ResolveFullPath, RouteConstraints, RouterState, ListenerFn, BuildNextOptions, AnyRouter, RegisteredRouter, RouterEvents, RouterEvent, RouterListener, MatchRouteOptions, RouteMask, RouterContextOptions, RouterOptions, RouterConstructorOptions, ControllablePromise, InjectedHtmlEntry, RouterErrorSerializer, SerializerExtensions, CreateFileRoute, CreateLazyFileRoute, } from '@tanstack/router-core';
|
|
1
|
+
export { defer, TSR_DEFERRED_PROMISE, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, parsePathname, interpolatePath, matchPathname, removeBasepath, matchByPath, encode, decode, rootRouteId, defaultSerializeError, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, pick, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, } from '@tanstack/router-core';
|
|
2
|
+
export type { DeferredPromiseState, DeferredPromise, ParsedLocation, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, Segment, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, ResolveOptionalParams, ResolveRequiredParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, TrailingSlashOption, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, NavigateFn, BuildLocationFn, InferDescendantToPaths, RelativeToPath, RelativeToParentPath, RelativeToCurrentPath, Register, AbsoluteToPath, RelativeToPathAutoComplete, NavigateOptions, ToOptions, ToMaskOptions, ToSubOptions, ResolveRoute, SearchParamOptions, PathParamOptions, ToPathOption, LinkOptions, MakeOptionalPathParams, AnyRouterWithContext, ParseRoute, RoutesById, RouteById, RouteIds, RoutesByPath, RouteByPath, RoutePaths, FullSearchSchema, AllParams, AllLoaderData, FullSearchSchemaInput, AllContext, CommitLocationOptions, MatchLocation, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, ResolveAllParamsFromParent, RouteContextParameter, BeforeLoadContextParameter, ResolveAllContext, FullSearchSchemaOption, MakeRemountDepsOptionsUnion, RemountDepsOptions, FileRouteTypes, FileRoutesByPath, UseNavigateResult, AnyRedirect, Redirect, RedirectOptions, ResolvedRedirect, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, RouteLoaderFn, LoaderFnContext, MakeRouteMatch, MakeRouteMatchUnion, RouteMatch, AnyRouteMatch, RouteContextFn, RouteContextOptions, BeforeLoadFn, BeforeLoadContextOptions, ContextOptions, RootRouteOptions, AnyRouteWithContext, LazyRouteOptions, AnyRoute, ResolveFullPath, RouteConstraints, RouterState, ListenerFn, BuildNextOptions, AnyRouter, RegisteredRouter, RouterEvents, RouterEvent, RouterListener, MatchRouteOptions, RouteMask, RouterContextOptions, RouterOptions, RouterConstructorOptions, ControllablePromise, InjectedHtmlEntry, CreateFileRoute, CreateLazyFileRoute, } from '@tanstack/router-core';
|
|
6
3
|
export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
|
|
7
4
|
export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryState, } from '@tanstack/history';
|
|
8
5
|
export { useAwaited, Await } from './awaited.cjs';
|
|
@@ -23,7 +20,7 @@ export { useLoaderDeps } from './useLoaderDeps.cjs';
|
|
|
23
20
|
export { useLoaderData } from './useLoaderData.cjs';
|
|
24
21
|
export { redirect, isRedirect } from '@tanstack/router-core';
|
|
25
22
|
export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route.cjs';
|
|
26
|
-
export type { AnyRootRoute, SolidNode,
|
|
23
|
+
export type { AnyRootRoute, SolidNode, AsyncRouteComponent, RouteComponent, ErrorRouteComponent, NotFoundRouteComponent, } from './route.cjs';
|
|
27
24
|
export { createRouter, Router } from './router.cjs';
|
|
28
25
|
export { componentTypes, lazyFn, SearchParamError, PathParamError, getInitialRouterState, } from '@tanstack/router-core';
|
|
29
26
|
export { RouterProvider, RouterContextProvider } from './RouterProvider.cjs';
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const Solid$1 = require("solid-js/web");
|
|
4
4
|
const Solid = require("solid-js");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
function isModuleNotFoundError(error) {
|
|
8
|
-
return typeof (error == null ? void 0 : error.message) === "string" && /Failed to fetch dynamically imported module/.test(error.message);
|
|
9
|
-
}
|
|
10
|
-
function lazyRouteComponent(importer, exportName, ssr) {
|
|
5
|
+
const routerCore = require("@tanstack/router-core");
|
|
6
|
+
function lazyRouteComponent(importer, exportName) {
|
|
11
7
|
let loadPromise;
|
|
12
8
|
let comp;
|
|
13
9
|
let error;
|
|
14
10
|
const load = () => {
|
|
15
|
-
if (typeof document === "undefined" && (ssr == null ? void 0 : ssr()) === false) {
|
|
16
|
-
comp = () => null;
|
|
17
|
-
return Promise.resolve(comp);
|
|
18
|
-
}
|
|
19
11
|
if (!loadPromise) {
|
|
20
12
|
loadPromise = importer().then((res) => {
|
|
21
13
|
loadPromise = void 0;
|
|
@@ -29,7 +21,7 @@ function lazyRouteComponent(importer, exportName, ssr) {
|
|
|
29
21
|
};
|
|
30
22
|
const lazyComp = function Lazy(props) {
|
|
31
23
|
if (error) {
|
|
32
|
-
if (isModuleNotFoundError(error)) {
|
|
24
|
+
if (routerCore.isModuleNotFoundError(error)) {
|
|
33
25
|
if (error instanceof Error && typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
|
|
34
26
|
const storageKey = `tanstack_router_reload:${error.message}`;
|
|
35
27
|
if (!sessionStorage.getItem(storageKey)) {
|
|
@@ -48,21 +40,9 @@ function lazyRouteComponent(importer, exportName, ssr) {
|
|
|
48
40
|
initialValue: comp,
|
|
49
41
|
ssrLoadFrom: "initial"
|
|
50
42
|
});
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
if ((ssr == null ? void 0 : ssr()) === false) {
|
|
54
|
-
return web.createComponent(ClientOnly.ClientOnly, {
|
|
55
|
-
get fallback() {
|
|
56
|
-
return web.createComponent(Match.Outlet, {});
|
|
57
|
-
},
|
|
58
|
-
get children() {
|
|
59
|
-
return web.createComponent(web.Dynamic, web.mergeProps({
|
|
60
|
-
component: comp
|
|
61
|
-
}, props));
|
|
62
|
-
}
|
|
63
|
-
});
|
|
43
|
+
return Solid$1.memo(compResource);
|
|
64
44
|
}
|
|
65
|
-
return
|
|
45
|
+
return Solid$1.createComponent(Solid$1.Dynamic, Solid$1.mergeProps({
|
|
66
46
|
component: comp
|
|
67
47
|
}, props));
|
|
68
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyRouteComponent.cjs","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import { Dynamic } from 'solid-js/web'\nimport { createResource } from 'solid-js'\nimport {
|
|
1
|
+
{"version":3,"file":"lazyRouteComponent.cjs","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import { Dynamic } from 'solid-js/web'\nimport { createResource } from 'solid-js'\nimport { isModuleNotFoundError } from '@tanstack/router-core'\nimport type { AsyncRouteComponent } from './route'\n\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any> | undefined\n let comp: T[TKey] | T['default']\n let error: any\n\n const load = () => {\n if (!loadPromise) {\n loadPromise = importer()\n .then((res) => {\n loadPromise = undefined\n comp = res[exportName ?? 'default']\n return comp\n })\n .catch((err) => {\n error = err\n })\n }\n\n return loadPromise\n }\n\n const lazyComp = function Lazy(props: any) {\n // Now that we're out of preload and into actual render path,\n // throw the error if it was a module not found error during preload\n if (error) {\n // If the load fails due to module not found, it may mean a new version of\n // the build was deployed and the user's browser is still using an old version.\n // If this happens, the old version in the user's browser would have an outdated\n // URL to the lazy module.\n // In that case, we want to attempt one window refresh to get the latest.\n if (isModuleNotFoundError(error)) {\n // We don't want an error thrown from preload in this case, because\n // there's nothing we want to do about module not found during preload.\n // Record the error, recover the promise with a null return,\n // and we will attempt module not found resolution during the render path.\n\n if (\n error instanceof Error &&\n typeof window !== 'undefined' &&\n typeof sessionStorage !== 'undefined'\n ) {\n // Again, we want to reload one time on module not found error and not enter\n // a reload loop if there is some other issue besides an old deploy.\n // That's why we store our reload attempt in sessionStorage.\n // Use error.message as key because it contains the module path that failed.\n const storageKey = `tanstack_router_reload:${error.message}`\n if (!sessionStorage.getItem(storageKey)) {\n sessionStorage.setItem(storageKey, '1')\n window.location.reload()\n\n // Return empty component while we wait for window to reload\n return {\n default: () => null,\n }\n }\n }\n }\n\n // Otherwise, just throw the error\n throw error\n }\n\n if (!comp) {\n const [compResource] = createResource(load, {\n initialValue: comp,\n ssrLoadFrom: 'initial',\n })\n return <>{compResource()}</>\n }\n\n return <Dynamic component={comp} {...props} />\n }\n\n ;(lazyComp as any).preload = load\n\n return lazyComp as any\n}\n"],"names":["lazyRouteComponent","importer","exportName","loadPromise","comp","error","load","then","res","undefined","catch","err","lazyComp","Lazy","props","isModuleNotFoundError","Error","window","sessionStorage","storageKey","message","getItem","setItem","location","reload","default","compResource","createResource","initialValue","ssrLoadFrom","_$memo","_$createComponent","Dynamic","_$mergeProps","component","preload"],"mappings":";;;;;AAKO,SAASA,mBAIdC,UACAC,YAGQ;AACR,MAAIC;AACJ,MAAIC;AACJ,MAAIC;AAEJ,QAAMC,OAAOA,MAAM;AACjB,QAAI,CAACH,aAAa;AAChBA,oBAAcF,SAAAA,EACXM,KAAMC,CAAAA,QAAQ;AACbL,sBAAcM;AACdL,eAAOI,IAAIN,cAAc,SAAS;AAClC,eAAOE;AAAAA,MACT,CAAC,EACAM,MAAOC,CAAAA,QAAQ;AACdN,gBAAQM;AAAAA,MACV,CAAC;AAAA,IACL;AAEA,WAAOR;AAAAA,EACT;AAEA,QAAMS,WAAW,SAASC,KAAKC,OAAY;AAGzC,QAAIT,OAAO;AAMT,UAAIU,WAAAA,sBAAsBV,KAAK,GAAG;AAMhC,YACEA,iBAAiBW,SACjB,OAAOC,WAAW,eAClB,OAAOC,mBAAmB,aAC1B;AAKA,gBAAMC,aAAa,0BAA0Bd,MAAMe,OAAO;AAC1D,cAAI,CAACF,eAAeG,QAAQF,UAAU,GAAG;AACvCD,2BAAeI,QAAQH,YAAY,GAAG;AACtCF,mBAAOM,SAASC,OAAAA;AAGhB,mBAAO;AAAA,cACLC,SAASA,MAAM;AAAA,YAAA;AAAA,UAEnB;AAAA,QACF;AAAA,MACF;AAGA,YAAMpB;AAAAA,IACR;AAEA,QAAI,CAACD,MAAM;AACT,YAAM,CAACsB,YAAY,IAAIC,MAAAA,eAAerB,MAAM;AAAA,QAC1CsB,cAAcxB;AAAAA,QACdyB,aAAa;AAAA,MAAA,CACd;AACD,aAAAC,QAAAA,KAAUJ,YAAY;AAAA,IACxB;AAEA,WAAAK,QAAAA,gBAAQC,QAAAA,SAAOC,mBAAA;AAAA,MAACC,WAAW9B;AAAAA,IAAAA,GAAUU,KAAK,CAAA;AAAA,EAC5C;AAEEF,WAAiBuB,UAAU7B;AAE7B,SAAOM;AACT;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AsyncRouteComponent } from './route.cjs';
|
|
2
|
-
export declare function lazyRouteComponent<T extends Record<string, any>, TKey extends keyof T = 'default'>(importer: () => Promise<T>, exportName?: TKey
|
|
2
|
+
export declare function lazyRouteComponent<T extends Record<string, any>, TKey extends keyof T = 'default'>(importer: () => Promise<T>, exportName?: TKey): T[TKey] extends (props: infer TProps) => any ? AsyncRouteComponent<TProps> : never;
|
package/dist/cjs/link.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const Solid$1 = require("solid-js/web");
|
|
4
4
|
const Solid = require("solid-js");
|
|
5
5
|
const refs = require("@solid-primitives/refs");
|
|
6
6
|
const routerCore = require("@tanstack/router-core");
|
|
7
7
|
const useRouterState = require("./useRouterState.cjs");
|
|
8
8
|
const useRouter = require("./useRouter.cjs");
|
|
9
9
|
const utils = require("./utils.cjs");
|
|
10
|
-
const
|
|
10
|
+
const useMatch = require("./useMatch.cjs");
|
|
11
11
|
function _interopNamespaceDefault(e) {
|
|
12
12
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
13
13
|
if (e) {
|
|
@@ -34,8 +34,8 @@ function useLinkProps(options) {
|
|
|
34
34
|
class: "active"
|
|
35
35
|
}),
|
|
36
36
|
inactiveProps: () => ({})
|
|
37
|
-
}, options), ["activeProps", "inactiveProps", "activeOptions", "to", "preload", "preloadDelay", "hashScrollIntoView", "replace", "startTransition", "resetScroll", "viewTransition", "
|
|
38
|
-
const [_, propsSafeToSpread] = Solid__namespace.splitProps(rest, ["params", "search", "hash", "state", "mask", "reloadDocument"]);
|
|
37
|
+
}, options), ["activeProps", "inactiveProps", "activeOptions", "to", "preload", "preloadDelay", "hashScrollIntoView", "replace", "startTransition", "resetScroll", "viewTransition", "target", "disabled", "style", "class", "onClick", "onFocus", "onMouseEnter", "onMouseLeave", "onMouseOver", "onMouseOut", "onTouchStart", "ignoreBlocker"]);
|
|
38
|
+
const [_, propsSafeToSpread] = Solid__namespace.splitProps(rest, ["params", "search", "hash", "state", "mask", "reloadDocument", "unsafeRelative"]);
|
|
39
39
|
const type = () => {
|
|
40
40
|
try {
|
|
41
41
|
new URL(`${local.to}`);
|
|
@@ -47,11 +47,9 @@ function useLinkProps(options) {
|
|
|
47
47
|
const currentSearch = useRouterState.useRouterState({
|
|
48
48
|
select: (s) => s.location.searchStr
|
|
49
49
|
});
|
|
50
|
-
const from =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return options.from ?? ((_a = matches[matches.length - 1]) == null ? void 0 : _a.fullPath);
|
|
54
|
-
}
|
|
50
|
+
const from = useMatch.useMatch({
|
|
51
|
+
strict: false,
|
|
52
|
+
select: (match) => options.from ?? match.fullPath
|
|
55
53
|
});
|
|
56
54
|
const _options = () => ({
|
|
57
55
|
...options,
|
|
@@ -70,30 +68,29 @@ function useLinkProps(options) {
|
|
|
70
68
|
const preloadDelay = () => local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0;
|
|
71
69
|
const isActive = useRouterState.useRouterState({
|
|
72
70
|
select: (s) => {
|
|
73
|
-
|
|
74
|
-
if ((_a = local.activeOptions) == null ? void 0 : _a.exact) {
|
|
71
|
+
if (local.activeOptions?.exact) {
|
|
75
72
|
const testExact = routerCore.exactPathTest(s.location.pathname, next().pathname, router.basepath);
|
|
76
73
|
if (!testExact) {
|
|
77
74
|
return false;
|
|
78
75
|
}
|
|
79
76
|
} else {
|
|
80
77
|
const currentPathSplit = routerCore.removeTrailingSlash(s.location.pathname, router.basepath).split("/");
|
|
81
|
-
const nextPathSplit =
|
|
82
|
-
const pathIsFuzzyEqual = nextPathSplit
|
|
78
|
+
const nextPathSplit = routerCore.removeTrailingSlash(next()?.pathname, router.basepath)?.split("/");
|
|
79
|
+
const pathIsFuzzyEqual = nextPathSplit?.every((d, i) => d === currentPathSplit[i]);
|
|
83
80
|
if (!pathIsFuzzyEqual) {
|
|
84
81
|
return false;
|
|
85
82
|
}
|
|
86
83
|
}
|
|
87
|
-
if (
|
|
84
|
+
if (local.activeOptions?.includeSearch ?? true) {
|
|
88
85
|
const searchTest = routerCore.deepEqual(s.location.search, next().search, {
|
|
89
|
-
partial: !
|
|
90
|
-
ignoreUndefined: !
|
|
86
|
+
partial: !local.activeOptions?.exact,
|
|
87
|
+
ignoreUndefined: !local.activeOptions?.explicitUndefined
|
|
91
88
|
});
|
|
92
89
|
if (!searchTest) {
|
|
93
90
|
return false;
|
|
94
91
|
}
|
|
95
92
|
}
|
|
96
|
-
if (
|
|
93
|
+
if (local.activeOptions?.includeHash) {
|
|
97
94
|
return s.location.hash === next().hash;
|
|
98
95
|
}
|
|
99
96
|
return true;
|
|
@@ -104,7 +101,7 @@ function useLinkProps(options) {
|
|
|
104
101
|
console.warn(routerCore.preloadWarning);
|
|
105
102
|
});
|
|
106
103
|
const preloadViewportIoCallback = (entry) => {
|
|
107
|
-
if (entry
|
|
104
|
+
if (entry?.isIntersecting) {
|
|
108
105
|
doPreload();
|
|
109
106
|
}
|
|
110
107
|
};
|
|
@@ -132,7 +129,7 @@ function useLinkProps(options) {
|
|
|
132
129
|
get href() {
|
|
133
130
|
return local.to;
|
|
134
131
|
}
|
|
135
|
-
}, Solid__namespace.splitProps(local, ["
|
|
132
|
+
}, Solid__namespace.splitProps(local, ["target", "disabled", "style", "class", "onClick", "onFocus", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver", "onTouchStart"])[0]);
|
|
136
133
|
}
|
|
137
134
|
const handleClick = (e) => {
|
|
138
135
|
if (!local.disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!local.target || local.target === "_self") && e.button === 0) {
|
|
@@ -142,7 +139,7 @@ function useLinkProps(options) {
|
|
|
142
139
|
unsub();
|
|
143
140
|
setIsTransitioning(false);
|
|
144
141
|
});
|
|
145
|
-
|
|
142
|
+
router.navigate({
|
|
146
143
|
..._options(),
|
|
147
144
|
replace: local.replace,
|
|
148
145
|
resetScroll: local.resetScroll,
|
|
@@ -208,8 +205,8 @@ function useLinkProps(options) {
|
|
|
208
205
|
});
|
|
209
206
|
const href = Solid__namespace.createMemo(() => {
|
|
210
207
|
const nextLocation = next();
|
|
211
|
-
const maskedLocation = nextLocation
|
|
212
|
-
return _options().disabled ? void 0 : maskedLocation ? router.history.createHref(maskedLocation.href) : router.history.createHref(nextLocation
|
|
208
|
+
const maskedLocation = nextLocation?.maskedLocation;
|
|
209
|
+
return _options().disabled ? void 0 : maskedLocation ? router.history.createHref(maskedLocation.href) : router.history.createHref(nextLocation?.href);
|
|
213
210
|
});
|
|
214
211
|
return Solid__namespace.mergeProps(propsSafeToSpread, resolvedActiveProps, resolvedInactiveProps, () => {
|
|
215
212
|
return {
|
|
@@ -245,24 +242,33 @@ function useLinkProps(options) {
|
|
|
245
242
|
});
|
|
246
243
|
}
|
|
247
244
|
function createLink(Comp) {
|
|
248
|
-
return (props) =>
|
|
245
|
+
return (props) => Solid$1.createComponent(Link, Solid$1.mergeProps(props, {
|
|
249
246
|
_asChild: Comp
|
|
250
247
|
}));
|
|
251
248
|
}
|
|
252
249
|
const Link = (props) => {
|
|
253
|
-
const [local, rest] = Solid__namespace.splitProps(props, ["_asChild"]);
|
|
254
|
-
const [_, linkProps] = Solid__namespace.splitProps(useLinkProps(rest), ["type"
|
|
255
|
-
const children = () =>
|
|
256
|
-
|
|
257
|
-
|
|
250
|
+
const [local, rest] = Solid__namespace.splitProps(props, ["_asChild", "children"]);
|
|
251
|
+
const [_, linkProps] = Solid__namespace.splitProps(useLinkProps(rest), ["type"]);
|
|
252
|
+
const children = Solid__namespace.createMemo(() => {
|
|
253
|
+
const ch = local.children;
|
|
254
|
+
if (typeof ch === "function") {
|
|
255
|
+
return ch({
|
|
256
|
+
get isActive() {
|
|
257
|
+
return linkProps["data-status"] === "active";
|
|
258
|
+
},
|
|
259
|
+
isTransitioning: false
|
|
260
|
+
});
|
|
258
261
|
}
|
|
259
|
-
|
|
260
|
-
|
|
262
|
+
return ch;
|
|
263
|
+
});
|
|
264
|
+
return Solid$1.createComponent(Solid$1.Dynamic, Solid$1.mergeProps({
|
|
261
265
|
get component() {
|
|
262
266
|
return local._asChild ? local._asChild : "a";
|
|
263
267
|
}
|
|
264
268
|
}, linkProps, {
|
|
265
|
-
children
|
|
269
|
+
get children() {
|
|
270
|
+
return children();
|
|
271
|
+
}
|
|
266
272
|
}));
|
|
267
273
|
};
|
|
268
274
|
function isCtrlEvent(e) {
|
package/dist/cjs/link.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport { mergeRefs } from '@solid-primitives/refs'\n\nimport {\n deepEqual,\n exactPathTest,\n functionalUpdate,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\nimport { Dynamic } from 'solid-js/web'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\n\nimport { useIntersectionObserver } from './utils'\n\nimport { useMatches } from './Matches'\nimport type {\n AnyRouter,\n Constrain,\n LinkCurrentTargetElement,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Solid.ComponentProps<'a'> {\n const router = useRouter()\n const [isTransitioning, setIsTransitioning] = Solid.createSignal(false)\n let hasRenderFetched = false\n\n const [local, rest] = Solid.splitProps(\n Solid.mergeProps(\n {\n activeProps: () => ({ class: 'active' }),\n inactiveProps: () => ({}),\n },\n options,\n ),\n [\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'children',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n ],\n )\n\n // const {\n // // custom props\n // activeProps = () => ({ class: 'active' }),\n // inactiveProps = () => ({}),\n // activeOptions,\n // to,\n // preload: userPreload,\n // preloadDelay: userPreloadDelay,\n // hashScrollIntoView,\n // replace,\n // startTransition,\n // resetScroll,\n // viewTransition,\n // // element props\n // children,\n // target,\n // disabled,\n // style,\n // class,\n // onClick,\n // onFocus,\n // onMouseEnter,\n // onMouseLeave,\n // onTouchStart,\n // ignoreBlocker,\n // ...rest\n // } = options\n\n const [_, propsSafeToSpread] = Solid.splitProps(rest, [\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n ])\n\n // If this link simply reloads the current route,\n // make sure it has a new key so it will trigger a data refresh\n\n // If this `to` is a valid external URL, return\n // null for LinkUtils\n\n const type: Solid.Accessor<'internal' | 'external'> = () => {\n try {\n new URL(`${local.to}`)\n return 'external'\n } catch {}\n return 'internal'\n }\n\n const currentSearch = useRouterState({\n select: (s) => s.location.searchStr,\n })\n\n // when `from` is not supplied, use the leaf route of the current matches as the `from` location\n // so relative routing works as expected\n const from = useMatches({\n select: (matches) => options.from ?? matches[matches.length - 1]?.fullPath,\n })\n\n const _options = () => ({\n ...options,\n from: from(),\n })\n\n const next = Solid.createMemo(() => {\n currentSearch()\n return router.buildLocation(_options() as any)\n })\n\n const preload = Solid.createMemo(() => {\n if (_options().reloadDocument) {\n return false\n }\n return local.preload ?? router.options.defaultPreload\n })\n const preloadDelay = () =>\n local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = useRouterState({\n select: (s) => {\n if (local.activeOptions?.exact) {\n const testExact = exactPathTest(\n s.location.pathname,\n next().pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPathSplit = removeTrailingSlash(\n s.location.pathname,\n router.basepath,\n ).split('/')\n const nextPathSplit = removeTrailingSlash(\n next()?.pathname,\n router.basepath,\n )?.split('/')\n\n const pathIsFuzzyEqual = nextPathSplit?.every(\n (d, i) => d === currentPathSplit[i],\n )\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (local.activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(s.location.search, next().search, {\n partial: !local.activeOptions?.exact,\n ignoreUndefined: !local.activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (local.activeOptions?.includeHash) {\n return s.location.hash === next().hash\n }\n return true\n },\n })\n\n const doPreload = () =>\n router.preloadRoute(_options() as any).catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const preloadViewportIoCallback = (\n entry: IntersectionObserverEntry | undefined,\n ) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n }\n\n const [ref, setRef] = Solid.createSignal<Element | null>(null)\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: !!local.disabled || !(preload() === 'viewport') },\n )\n\n Solid.createEffect(() => {\n if (hasRenderFetched) {\n return\n }\n if (!local.disabled && preload() === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n if (type() === 'external') {\n return Solid.mergeProps(\n propsSafeToSpread,\n {\n ref,\n get type() {\n return type()\n },\n get href() {\n return local.to\n },\n },\n Solid.splitProps(local, [\n 'children',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOut',\n 'onMouseOver',\n 'onTouchStart',\n ])[0],\n ) as any\n }\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n if (\n !local.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!local.target || local.target === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n setIsTransitioning(true)\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n setIsTransitioning(false)\n })\n\n // All is well? Navigate!\n // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n return router.navigate({\n ..._options(),\n replace: local.replace,\n resetScroll: local.resetScroll,\n hashScrollIntoView: local.hashScrollIntoView,\n startTransition: local.startTransition,\n viewTransition: local.viewTransition,\n ignoreBlocker: local.ignoreBlocker,\n } as any)\n }\n }\n\n // The click handler\n const handleFocus = (_: MouseEvent) => {\n if (local.disabled) return\n if (preload()) {\n doPreload()\n }\n }\n\n const handleTouchStart = handleFocus\n\n const handleEnter = (e: MouseEvent) => {\n if (local.disabled) return\n const eventTarget = (e.target || {}) as LinkCurrentTargetElement\n\n if (preload()) {\n if (eventTarget.preloadTimeout) {\n return\n }\n\n eventTarget.preloadTimeout = setTimeout(() => {\n eventTarget.preloadTimeout = null\n doPreload()\n }, preloadDelay())\n }\n }\n\n const handleLeave = (e: MouseEvent) => {\n if (local.disabled) return\n const eventTarget = (e.target || {}) as LinkCurrentTargetElement\n\n if (eventTarget.preloadTimeout) {\n clearTimeout(eventTarget.preloadTimeout)\n eventTarget.preloadTimeout = null\n }\n }\n\n /** Call a JSX.EventHandlerUnion with the event. */\n function callHandler<T, TEvent extends Event>(\n event: TEvent & { currentTarget: T; target: Element },\n handler: Solid.JSX.EventHandlerUnion<T, TEvent> | undefined,\n ) {\n if (handler) {\n if (typeof handler === 'function') {\n handler(event)\n } else {\n handler[0](handler[1], event)\n }\n }\n\n return event.defaultPrevented\n }\n\n function composeEventHandlers<T>(\n handlers: Array<Solid.JSX.EventHandlerUnion<T, any> | undefined>,\n ) {\n return (event: any) => {\n for (const handler of handlers) {\n callHandler(event, handler)\n }\n }\n }\n\n // Get the active props\n const resolvedActiveProps: () => Omit<Solid.ComponentProps<'a'>, 'style'> & {\n style?: Solid.JSX.CSSProperties\n } = () =>\n isActive() ? (functionalUpdate(local.activeProps as any, {}) ?? {}) : {}\n\n // Get the inactive props\n const resolvedInactiveProps: () => Omit<\n Solid.ComponentProps<'a'>,\n 'style'\n > & { style?: Solid.JSX.CSSProperties } = () =>\n isActive() ? {} : functionalUpdate(local.inactiveProps, {})\n\n const resolvedClassName = () =>\n [local.class, resolvedActiveProps().class, resolvedInactiveProps().class]\n .filter(Boolean)\n .join(' ')\n\n const resolvedStyle = () => ({\n ...local.style,\n ...resolvedActiveProps().style,\n ...resolvedInactiveProps().style,\n })\n\n const href = Solid.createMemo(() => {\n const nextLocation = next()\n const maskedLocation = nextLocation?.maskedLocation\n\n return _options().disabled\n ? undefined\n : maskedLocation\n ? router.history.createHref(maskedLocation.href)\n : router.history.createHref(nextLocation?.href)\n })\n\n return Solid.mergeProps(\n propsSafeToSpread,\n resolvedActiveProps,\n resolvedInactiveProps,\n () => {\n return {\n href: href(),\n ref: mergeRefs(setRef, _options().ref),\n onClick: composeEventHandlers([local.onClick, handleClick]),\n onFocus: composeEventHandlers([local.onFocus, handleFocus]),\n onMouseEnter: composeEventHandlers([local.onMouseEnter, handleEnter]),\n onMouseOver: composeEventHandlers([local.onMouseOver, handleEnter]),\n onMouseLeave: composeEventHandlers([local.onMouseLeave, handleLeave]),\n onMouseOut: composeEventHandlers([local.onMouseOut, handleLeave]),\n onTouchStart: composeEventHandlers([\n local.onTouchStart,\n handleTouchStart,\n ]),\n disabled: !!local.disabled,\n target: local.target,\n ...(Object.keys(resolvedStyle).length && { style: resolvedStyle }),\n ...(resolvedClassName() && { class: resolvedClassName() }),\n ...(local.disabled && {\n role: 'link',\n 'aria-disabled': true,\n }),\n ...(isActive() && { 'data-status': 'active', 'aria-current': 'page' }),\n ...(isTransitioning() && { 'data-transitioning': 'transitioning' }),\n }\n },\n ) as any\n}\n\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n Omit<Solid.ComponentProps<'a'>, 'style'> & { style?: Solid.JSX.CSSProperties }\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n LinkComponentSolidProps<TComp> & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | Solid.JSX.Element\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Solid.JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends Solid.ValidComponent\n ? Omit<Solid.ComponentProps<TComp>, keyof CreateLinkProps>\n : never\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentSolidProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Solid.JSX.Element\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): Solid.JSX.Element\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,\n): LinkComponent<TComp> {\n return (props) => <Link {...(props as any)} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props: any) => {\n const [local, rest] = Solid.splitProps(props, ['_asChild'])\n\n const [_, linkProps] = Solid.splitProps(\n useLinkProps(rest as unknown as any),\n ['type', 'children'],\n )\n\n const children = () =>\n typeof rest.children === 'function'\n ? rest.children({\n get isActive() {\n return (linkProps as any)['data-status'] === 'active'\n },\n })\n : rest.children\n\n return (\n <Dynamic component={local._asChild ? local._asChild : 'a'} {...linkProps}>\n {children}\n </Dynamic>\n )\n}\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"names":["useLinkProps","options","router","useRouter","isTransitioning","setIsTransitioning","Solid","createSignal","hasRenderFetched","local","rest","splitProps","mergeProps","activeProps","class","inactiveProps","_","propsSafeToSpread","type","URL","to","currentSearch","useRouterState","select","s","location","searchStr","from","useMatches","matches","length","fullPath","_options","next","createMemo","buildLocation","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","exact","testExact","exactPathTest","pathname","basepath","currentPathSplit","removeTrailingSlash","split","nextPathSplit","pathIsFuzzyEqual","every","d","i","includeSearch","searchTest","deepEqual","search","partial","ignoreUndefined","explicitUndefined","includeHash","hash","doPreload","preloadRoute","catch","err","console","warn","preloadWarning","preloadViewportIoCallback","entry","isIntersecting","ref","setRef","useIntersectionObserver","rootMargin","disabled","createEffect","href","handleClick","e","isCtrlEvent","defaultPrevented","target","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","handleFocus","handleTouchStart","handleEnter","eventTarget","preloadTimeout","setTimeout","handleLeave","clearTimeout","callHandler","event","handler","composeEventHandlers","handlers","resolvedActiveProps","functionalUpdate","resolvedInactiveProps","resolvedClassName","filter","Boolean","join","resolvedStyle","style","nextLocation","maskedLocation","undefined","history","createHref","mergeRefs","onClick","onFocus","onMouseEnter","onMouseOver","onMouseLeave","onMouseOut","onTouchStart","Object","keys","role","createLink","Comp","props","_$createComponent","Link","_$mergeProps","_asChild","linkProps","children","Dynamic","component","metaKey","altKey","ctrlKey","shiftKey","linkOptions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,SAASA,aAOdC,SAC2B;AAC3B,QAAMC,SAASC,UAAAA,UAAU;AACzB,QAAM,CAACC,iBAAiBC,kBAAkB,IAAIC,iBAAMC,aAAa,KAAK;AACtE,MAAIC,mBAAmB;AAEvB,QAAM,CAACC,OAAOC,IAAI,IAAIJ,iBAAMK,WAC1BL,iBAAMM,WACJ;AAAA,IACEC,aAAaA,OAAO;AAAA,MAAEC,OAAO;AAAA,IAAA;AAAA,IAC7BC,eAAeA,OAAO,CAAC;AAAA,EAEzBd,GAAAA,OACF,GACA,CACE,eACA,iBACA,iBACA,MACA,WACA,gBACA,sBACA,WACA,mBACA,eACA,kBACA,YACA,UACA,YACA,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EAAEA,EAAEgE,WAAWhE,EAAEiE,UAAUjE,EAAEkE,WAAWlE,EAAEmE;AACpD;AAkBO,MAAMC,cAAmCtJ,CAAY,YAAA;AACnDA,SAAAA;AACT;;;;;"}
|
|
1
|
+
{"version":3,"file":"link.cjs","sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport { mergeRefs } from '@solid-primitives/refs'\n\nimport {\n deepEqual,\n exactPathTest,\n functionalUpdate,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\nimport { Dynamic } from 'solid-js/web'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\n\nimport { useIntersectionObserver } from './utils'\n\nimport { useMatch } from './useMatch'\nimport type {\n AnyRouter,\n Constrain,\n LinkCurrentTargetElement,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Solid.ComponentProps<'a'> {\n const router = useRouter()\n const [isTransitioning, setIsTransitioning] = Solid.createSignal(false)\n let hasRenderFetched = false\n\n const [local, rest] = Solid.splitProps(\n Solid.mergeProps(\n {\n activeProps: () => ({ class: 'active' }),\n inactiveProps: () => ({}),\n },\n options,\n ),\n [\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n ],\n )\n\n // const {\n // // custom props\n // activeProps = () => ({ class: 'active' }),\n // inactiveProps = () => ({}),\n // activeOptions,\n // to,\n // preload: userPreload,\n // preloadDelay: userPreloadDelay,\n // hashScrollIntoView,\n // replace,\n // startTransition,\n // resetScroll,\n // viewTransition,\n // // element props\n // children,\n // target,\n // disabled,\n // style,\n // class,\n // onClick,\n // onFocus,\n // onMouseEnter,\n // onMouseLeave,\n // onTouchStart,\n // ignoreBlocker,\n // ...rest\n // } = options\n\n const [_, propsSafeToSpread] = Solid.splitProps(rest, [\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'unsafeRelative',\n ])\n\n // If this link simply reloads the current route,\n // make sure it has a new key so it will trigger a data refresh\n\n // If this `to` is a valid external URL, return\n // null for LinkUtils\n\n const type: Solid.Accessor<'internal' | 'external'> = () => {\n try {\n new URL(`${local.to}`)\n return 'external'\n } catch {}\n return 'internal'\n }\n\n const currentSearch = useRouterState({\n select: (s) => s.location.searchStr,\n })\n\n // when `from` is not supplied, use the route of the current match as the `from` location\n // so relative routing works as expected\n const from = useMatch({\n strict: false,\n select: (match) => options.from ?? match.fullPath,\n })\n\n const _options = () => ({\n ...options,\n from: from(),\n })\n\n const next = Solid.createMemo(() => {\n currentSearch()\n return router.buildLocation(_options() as any)\n })\n\n const preload = Solid.createMemo(() => {\n if (_options().reloadDocument) {\n return false\n }\n return local.preload ?? router.options.defaultPreload\n })\n const preloadDelay = () =>\n local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = useRouterState({\n select: (s) => {\n if (local.activeOptions?.exact) {\n const testExact = exactPathTest(\n s.location.pathname,\n next().pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPathSplit = removeTrailingSlash(\n s.location.pathname,\n router.basepath,\n ).split('/')\n const nextPathSplit = removeTrailingSlash(\n next()?.pathname,\n router.basepath,\n )?.split('/')\n\n const pathIsFuzzyEqual = nextPathSplit?.every(\n (d, i) => d === currentPathSplit[i],\n )\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (local.activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(s.location.search, next().search, {\n partial: !local.activeOptions?.exact,\n ignoreUndefined: !local.activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (local.activeOptions?.includeHash) {\n return s.location.hash === next().hash\n }\n return true\n },\n })\n\n const doPreload = () =>\n router.preloadRoute(_options() as any).catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const preloadViewportIoCallback = (\n entry: IntersectionObserverEntry | undefined,\n ) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n }\n\n const [ref, setRef] = Solid.createSignal<Element | null>(null)\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: !!local.disabled || !(preload() === 'viewport') },\n )\n\n Solid.createEffect(() => {\n if (hasRenderFetched) {\n return\n }\n if (!local.disabled && preload() === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n if (type() === 'external') {\n return Solid.mergeProps(\n propsSafeToSpread,\n {\n ref,\n get type() {\n return type()\n },\n get href() {\n return local.to\n },\n },\n Solid.splitProps(local, [\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOut',\n 'onMouseOver',\n 'onTouchStart',\n ])[0],\n ) as any\n }\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n if (\n !local.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!local.target || local.target === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n setIsTransitioning(true)\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n setIsTransitioning(false)\n })\n\n // All is well? Navigate!\n // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n router.navigate({\n ..._options(),\n replace: local.replace,\n resetScroll: local.resetScroll,\n hashScrollIntoView: local.hashScrollIntoView,\n startTransition: local.startTransition,\n viewTransition: local.viewTransition,\n ignoreBlocker: local.ignoreBlocker,\n })\n }\n }\n\n // The click handler\n const handleFocus = (_: MouseEvent) => {\n if (local.disabled) return\n if (preload()) {\n doPreload()\n }\n }\n\n const handleTouchStart = handleFocus\n\n const handleEnter = (e: MouseEvent) => {\n if (local.disabled) return\n const eventTarget = (e.target || {}) as LinkCurrentTargetElement\n\n if (preload()) {\n if (eventTarget.preloadTimeout) {\n return\n }\n\n eventTarget.preloadTimeout = setTimeout(() => {\n eventTarget.preloadTimeout = null\n doPreload()\n }, preloadDelay())\n }\n }\n\n const handleLeave = (e: MouseEvent) => {\n if (local.disabled) return\n const eventTarget = (e.target || {}) as LinkCurrentTargetElement\n\n if (eventTarget.preloadTimeout) {\n clearTimeout(eventTarget.preloadTimeout)\n eventTarget.preloadTimeout = null\n }\n }\n\n /** Call a JSX.EventHandlerUnion with the event. */\n function callHandler<T, TEvent extends Event>(\n event: TEvent & { currentTarget: T; target: Element },\n handler: Solid.JSX.EventHandlerUnion<T, TEvent> | undefined,\n ) {\n if (handler) {\n if (typeof handler === 'function') {\n handler(event)\n } else {\n handler[0](handler[1], event)\n }\n }\n\n return event.defaultPrevented\n }\n\n function composeEventHandlers<T>(\n handlers: Array<Solid.JSX.EventHandlerUnion<T, any> | undefined>,\n ) {\n return (event: any) => {\n for (const handler of handlers) {\n callHandler(event, handler)\n }\n }\n }\n\n // Get the active props\n const resolvedActiveProps: () => Omit<Solid.ComponentProps<'a'>, 'style'> & {\n style?: Solid.JSX.CSSProperties\n } = () =>\n isActive() ? (functionalUpdate(local.activeProps as any, {}) ?? {}) : {}\n\n // Get the inactive props\n const resolvedInactiveProps: () => Omit<\n Solid.ComponentProps<'a'>,\n 'style'\n > & { style?: Solid.JSX.CSSProperties } = () =>\n isActive() ? {} : functionalUpdate(local.inactiveProps, {})\n\n const resolvedClassName = () =>\n [local.class, resolvedActiveProps().class, resolvedInactiveProps().class]\n .filter(Boolean)\n .join(' ')\n\n const resolvedStyle = () => ({\n ...local.style,\n ...resolvedActiveProps().style,\n ...resolvedInactiveProps().style,\n })\n\n const href = Solid.createMemo(() => {\n const nextLocation = next()\n const maskedLocation = nextLocation?.maskedLocation\n\n return _options().disabled\n ? undefined\n : maskedLocation\n ? router.history.createHref(maskedLocation.href)\n : router.history.createHref(nextLocation?.href)\n })\n\n return Solid.mergeProps(\n propsSafeToSpread,\n resolvedActiveProps,\n resolvedInactiveProps,\n () => {\n return {\n href: href(),\n ref: mergeRefs(setRef, _options().ref),\n onClick: composeEventHandlers([local.onClick, handleClick]),\n onFocus: composeEventHandlers([local.onFocus, handleFocus]),\n onMouseEnter: composeEventHandlers([local.onMouseEnter, handleEnter]),\n onMouseOver: composeEventHandlers([local.onMouseOver, handleEnter]),\n onMouseLeave: composeEventHandlers([local.onMouseLeave, handleLeave]),\n onMouseOut: composeEventHandlers([local.onMouseOut, handleLeave]),\n onTouchStart: composeEventHandlers([\n local.onTouchStart,\n handleTouchStart,\n ]),\n disabled: !!local.disabled,\n target: local.target,\n ...(Object.keys(resolvedStyle).length && { style: resolvedStyle }),\n ...(resolvedClassName() && { class: resolvedClassName() }),\n ...(local.disabled && {\n role: 'link',\n 'aria-disabled': true,\n }),\n ...(isActive() && { 'data-status': 'active', 'aria-current': 'page' }),\n ...(isTransitioning() && { 'data-transitioning': 'transitioning' }),\n }\n },\n ) as any\n}\n\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n Omit<Solid.ComponentProps<'a'>, 'style'> & { style?: Solid.JSX.CSSProperties }\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n LinkComponentSolidProps<TComp> & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | Solid.JSX.Element\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Solid.JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends Solid.ValidComponent\n ? Omit<Solid.ComponentProps<TComp>, keyof CreateLinkProps>\n : never\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentSolidProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Solid.JSX.Element\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): Solid.JSX.Element\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,\n): LinkComponent<TComp> {\n return (props) => <Link {...props} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props) => {\n const [local, rest] = Solid.splitProps(\n props as typeof props & { _asChild: any },\n ['_asChild', 'children'],\n )\n\n const [_, linkProps] = Solid.splitProps(\n useLinkProps(rest as unknown as any),\n ['type'],\n )\n\n const children = Solid.createMemo(() => {\n const ch = local.children\n if (typeof ch === 'function') {\n return ch({\n get isActive() {\n return (linkProps as any)['data-status'] === 'active'\n },\n isTransitioning: false,\n })\n }\n\n return ch satisfies Solid.JSX.Element\n })\n\n return (\n <Dynamic component={local._asChild ? local._asChild : 'a'} {...linkProps}>\n {children()}\n </Dynamic>\n )\n}\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"names":["useLinkProps","options","router","useRouter","isTransitioning","setIsTransitioning","Solid","createSignal","hasRenderFetched","local","rest","splitProps","mergeProps","activeProps","class","inactiveProps","_","propsSafeToSpread","type","URL","to","currentSearch","useRouterState","select","s","location","searchStr","from","useMatch","strict","match","fullPath","_options","next","createMemo","buildLocation","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","exact","testExact","exactPathTest","pathname","basepath","currentPathSplit","removeTrailingSlash","split","nextPathSplit","pathIsFuzzyEqual","every","d","i","includeSearch","searchTest","deepEqual","search","partial","ignoreUndefined","explicitUndefined","includeHash","hash","doPreload","preloadRoute","catch","err","console","warn","preloadWarning","preloadViewportIoCallback","entry","isIntersecting","ref","setRef","useIntersectionObserver","rootMargin","disabled","createEffect","href","handleClick","e","isCtrlEvent","defaultPrevented","target","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","handleFocus","handleTouchStart","handleEnter","eventTarget","preloadTimeout","setTimeout","handleLeave","clearTimeout","callHandler","event","handler","composeEventHandlers","handlers","resolvedActiveProps","functionalUpdate","resolvedInactiveProps","resolvedClassName","filter","Boolean","join","resolvedStyle","style","nextLocation","maskedLocation","undefined","history","createHref","mergeRefs","onClick","onFocus","onMouseEnter","onMouseOver","onMouseLeave","onMouseOut","onTouchStart","Object","keys","length","role","createLink","Comp","props","_$createComponent","Link","_$mergeProps","_asChild","linkProps","children","ch","Dynamic","component","metaKey","altKey","ctrlKey","shiftKey","linkOptions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,S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AG;AAAA,QACR,IAAIzG,WAAW;AACb,iBAAQuG,UAAkB,aAAa,MAAM;AAAA,QAC/C;AAAA,QACA5I,iBAAiB;AAAA,MAAA,CAClB;AAAA,IACH;AAEA,WAAO8I;AAAAA,EACT,CAAC;AAED,SAAAN,QAAAA,gBACGO,QAAAA,SAAOL,mBAAA;AAAA,IAAA,IAACM,YAAS;AAAA,aAAE3I,MAAMsI,WAAWtI,MAAMsI,WAAW;AAAA,IAAG;AAAA,EAAA,GAAMC,WAAS;AAAA,IAAA,IAAAC,WAAA;AAAA,aACrEA,SAAAA;AAAAA,IAAU;AAAA,EAAA,CAAA,CAAA;AAGjB;AAEA,SAAS7D,YAAYD,GAAe;AAClC,SAAO,CAAC,EAAEA,EAAEkE,WAAWlE,EAAEmE,UAAUnE,EAAEoE,WAAWpE,EAAEqE;AACpD;AAkBO,MAAMC,cAAmCxJ,CAAAA,YAAY;AAC1D,SAAOA;AACT;;;;;"}
|
package/dist/cjs/not-found.cjs
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const Solid = require("solid-js/web");
|
|
4
4
|
const routerCore = require("@tanstack/router-core");
|
|
5
5
|
const CatchBoundary = require("./CatchBoundary.cjs");
|
|
6
6
|
const useRouterState = require("./useRouterState.cjs");
|
|
7
|
-
var _tmpl$ = /* @__PURE__ */
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ Solid.template(`<p>Not Found`);
|
|
8
8
|
function CatchNotFound(props) {
|
|
9
9
|
const resetKey = useRouterState.useRouterState({
|
|
10
10
|
select: (s) => `not-found-${s.location.pathname}-${s.status}`
|
|
11
11
|
});
|
|
12
|
-
return
|
|
12
|
+
return Solid.createComponent(CatchBoundary.CatchBoundary, {
|
|
13
13
|
getResetKey: () => resetKey(),
|
|
14
14
|
onCatch: (error) => {
|
|
15
|
-
var _a;
|
|
16
15
|
if (routerCore.isNotFound(error)) {
|
|
17
|
-
|
|
16
|
+
props.onCatch?.(error);
|
|
18
17
|
} else {
|
|
19
18
|
throw error;
|
|
20
19
|
}
|
|
@@ -22,9 +21,8 @@ function CatchNotFound(props) {
|
|
|
22
21
|
errorComponent: ({
|
|
23
22
|
error
|
|
24
23
|
}) => {
|
|
25
|
-
var _a;
|
|
26
24
|
if (routerCore.isNotFound(error)) {
|
|
27
|
-
return
|
|
25
|
+
return props.fallback?.(error);
|
|
28
26
|
} else {
|
|
29
27
|
throw error;
|
|
30
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["import { isNotFound } from '@tanstack/router-core'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type * as Solid from 'solid-js'\nimport type { NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => Solid.JSX.Element\n onCatch?: (error: Error) => void\n children: Solid.JSX.Element\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey()}\n onCatch={(error) => {\n if (isNotFound(error)) {\n props.onCatch?.(error)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }
|
|
1
|
+
{"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["import { isNotFound } from '@tanstack/router-core'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type * as Solid from 'solid-js'\nimport type { NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => Solid.JSX.Element\n onCatch?: (error: Error) => void\n children: Solid.JSX.Element\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey()}\n onCatch={(error) => {\n if (isNotFound(error)) {\n props.onCatch?.(error)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }) => {\n if (isNotFound(error)) {\n return props.fallback?.(error)\n } else {\n throw error\n }\n }}\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"names":["CatchNotFound","props","resetKey","useRouterState","select","s","location","pathname","status","_$createComponent","CatchBoundary","getResetKey","onCatch","error","isNotFound","errorComponent","fallback","children","DefaultGlobalNotFound","_tmpl$"],"mappings":";;;;;;;AAMO,SAASA,cAAcC,OAI3B;AAED,QAAMC,WAAWC,eAAAA,eAAe;AAAA,IAC9BC,QAASC,OAAM,aAAaA,EAAEC,SAASC,QAAQ,IAAIF,EAAEG,MAAM;AAAA,EAAA,CAC5D;AAED,SAAAC,MAAAA,gBACGC,cAAAA,eAAa;AAAA,IACZC,aAAaA,MAAMT,SAAAA;AAAAA,IACnBU,SAAUC,CAAAA,UAAU;AAClB,UAAIC,WAAAA,WAAWD,KAAK,GAAG;AACrBZ,cAAMW,UAAUC,KAAK;AAAA,MACvB,OAAO;AACL,cAAMA;AAAAA,MACR;AAAA,IACF;AAAA,IACAE,gBAAgBA,CAAC;AAAA,MAAEF;AAAAA,IAAAA,MAAY;AAC7B,UAAIC,WAAAA,WAAWD,KAAK,GAAG;AACrB,eAAOZ,MAAMe,WAAWH,KAAK;AAAA,MAC/B,OAAO;AACL,cAAMA;AAAAA,MACR;AAAA,IACF;AAAA,IAAC,IAAAI,WAAA;AAAA,aAEAhB,MAAMgB;AAAAA,IAAQ;AAAA,EAAA,CAAA;AAGrB;AAEO,SAASC,wBAAwB;AACtC,SAAAC,OAAAA;AACF;;;"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const Solid = require("solid-js/web");
|
|
4
4
|
const warning = require("tiny-warning");
|
|
5
5
|
const notFound = require("./not-found.cjs");
|
|
6
6
|
function renderRouteNotFound(router, route, data) {
|
|
7
7
|
if (!route.options.notFoundComponent) {
|
|
8
8
|
if (router.options.defaultNotFoundComponent) {
|
|
9
|
-
return
|
|
9
|
+
return Solid.createComponent(router.options.defaultNotFoundComponent, {
|
|
10
10
|
data
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
if (process.env.NODE_ENV === "development") {
|
|
14
14
|
warning(route.options.notFoundComponent, `A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`);
|
|
15
15
|
}
|
|
16
|
-
return
|
|
16
|
+
return Solid.createComponent(notFound.DefaultGlobalNotFound, {});
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return Solid.createComponent(route.options.notFoundComponent, {
|
|
19
19
|
data
|
|
20
20
|
});
|
|
21
21
|
}
|