@tanstack/vue-router 0.0.1 → 1.140.0
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/LICENSE +21 -0
- package/README.md +66 -45
- package/dist/esm/Asset.d.ts +2 -0
- package/dist/esm/Asset.js +33 -0
- package/dist/esm/Asset.js.map +1 -0
- package/dist/esm/CatchBoundary.d.ts +19 -0
- package/dist/esm/CatchBoundary.js +135 -0
- package/dist/esm/CatchBoundary.js.map +1 -0
- package/dist/esm/ClientOnly.d.ts +67 -0
- package/dist/esm/HeadContent.d.ts +10 -0
- package/dist/esm/HeadContent.js +116 -0
- package/dist/esm/HeadContent.js.map +1 -0
- package/dist/esm/Match.d.ts +25 -0
- package/dist/esm/Match.js +262 -0
- package/dist/esm/Match.js.map +1 -0
- package/dist/esm/Matches.d.ts +39 -0
- package/dist/esm/Matches.js +186 -0
- package/dist/esm/Matches.js.map +1 -0
- package/dist/esm/RouterProvider.d.ts +33 -0
- package/dist/esm/RouterProvider.js +65 -0
- package/dist/esm/RouterProvider.js.map +1 -0
- package/dist/esm/SafeFragment.d.ts +4 -0
- package/dist/esm/ScriptOnce.d.ts +5 -0
- package/dist/esm/ScriptOnce.js +21 -0
- package/dist/esm/ScriptOnce.js.map +1 -0
- package/dist/esm/Scripts.d.ts +1 -0
- package/dist/esm/Scripts.js +46 -0
- package/dist/esm/Scripts.js.map +1 -0
- package/dist/esm/ScrollRestoration.d.ts +14 -0
- package/dist/esm/ScrollRestoration.js +36 -0
- package/dist/esm/ScrollRestoration.js.map +1 -0
- package/dist/esm/Transitioner.d.ts +2 -0
- package/dist/esm/Transitioner.js +154 -0
- package/dist/esm/Transitioner.js.map +1 -0
- package/dist/esm/awaited.d.ts +12 -0
- package/dist/esm/awaited.js +40 -0
- package/dist/esm/awaited.js.map +1 -0
- package/dist/esm/fileRoute.d.ts +54 -0
- package/dist/esm/fileRoute.js +103 -0
- package/dist/esm/fileRoute.js.map +1 -0
- package/dist/esm/history.d.ts +8 -0
- package/dist/esm/index.d.ts +51 -0
- package/dist/esm/index.js +138 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lazyRouteComponent.d.ts +8 -0
- package/dist/esm/lazyRouteComponent.js +106 -0
- package/dist/esm/lazyRouteComponent.js.map +1 -0
- package/dist/esm/link.d.ts +61 -0
- package/dist/esm/link.js +376 -0
- package/dist/esm/link.js.map +1 -0
- package/dist/esm/matchContext.d.ts +20 -0
- package/dist/esm/matchContext.js +16 -0
- package/dist/esm/matchContext.js.map +1 -0
- package/dist/esm/not-found.d.ts +12 -0
- package/dist/esm/not-found.js +45 -0
- package/dist/esm/not-found.js.map +1 -0
- package/dist/esm/renderRouteNotFound.d.ts +11 -0
- package/dist/esm/renderRouteNotFound.js +19 -0
- package/dist/esm/renderRouteNotFound.js.map +1 -0
- package/dist/esm/route.d.ts +96 -0
- package/dist/esm/route.js +176 -0
- package/dist/esm/route.js.map +1 -0
- package/dist/esm/router.d.ts +69 -0
- package/dist/esm/router.js +14 -0
- package/dist/esm/router.js.map +1 -0
- package/dist/esm/routerContext.d.ts +21 -0
- package/dist/esm/routerContext.js +21 -0
- package/dist/esm/routerContext.js.map +1 -0
- package/dist/esm/scroll-restoration.d.ts +1 -0
- package/dist/esm/scroll-restoration.js +21 -0
- package/dist/esm/scroll-restoration.js.map +1 -0
- package/dist/esm/typePrimitives.d.ts +10 -0
- package/dist/esm/useBlocker.d.ts +66 -0
- package/dist/esm/useBlocker.js +295 -0
- package/dist/esm/useBlocker.js.map +1 -0
- package/dist/esm/useCanGoBack.d.ts +1 -0
- package/dist/esm/useCanGoBack.js +8 -0
- package/dist/esm/useCanGoBack.js.map +1 -0
- package/dist/esm/useLoaderData.d.ts +8 -0
- package/dist/esm/useLoaderData.js +14 -0
- package/dist/esm/useLoaderData.js.map +1 -0
- package/dist/esm/useLoaderDeps.d.ts +7 -0
- package/dist/esm/useLoaderDeps.js +17 -0
- package/dist/esm/useLoaderDeps.js.map +1 -0
- package/dist/esm/useLocation.d.ts +7 -0
- package/dist/esm/useLocation.js +10 -0
- package/dist/esm/useLocation.js.map +1 -0
- package/dist/esm/useMatch.d.ts +10 -0
- package/dist/esm/useMatch.js +39 -0
- package/dist/esm/useMatch.js.map +1 -0
- package/dist/esm/useNavigate.d.ts +5 -0
- package/dist/esm/useNavigate.js +29 -0
- package/dist/esm/useNavigate.js.map +1 -0
- package/dist/esm/useParams.d.ts +9 -0
- package/dist/esm/useParams.js +15 -0
- package/dist/esm/useParams.js.map +1 -0
- package/dist/esm/useRouteContext.d.ts +4 -0
- package/dist/esm/useRouteContext.js +11 -0
- package/dist/esm/useRouteContext.js.map +1 -0
- package/dist/esm/useRouter.d.ts +4 -0
- package/dist/esm/useRouter.js +12 -0
- package/dist/esm/useRouter.js.map +1 -0
- package/dist/esm/useRouterState.d.ts +8 -0
- package/dist/esm/useRouterState.js +20 -0
- package/dist/esm/useRouterState.js.map +1 -0
- package/dist/esm/useSearch.d.ts +9 -0
- package/dist/esm/useSearch.js +15 -0
- package/dist/esm/useSearch.js.map +1 -0
- package/dist/esm/utils.d.ts +40 -0
- package/dist/esm/utils.js +44 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/source/Asset.d.ts +2 -0
- package/dist/source/Asset.jsx +22 -0
- package/dist/source/Asset.jsx.map +1 -0
- package/dist/source/CatchBoundary.d.ts +19 -0
- package/dist/source/CatchBoundary.jsx +134 -0
- package/dist/source/CatchBoundary.jsx.map +1 -0
- package/dist/source/ClientOnly.d.ts +67 -0
- package/dist/source/ClientOnly.jsx +63 -0
- package/dist/source/ClientOnly.jsx.map +1 -0
- package/dist/source/HeadContent.d.ts +10 -0
- package/dist/source/HeadContent.jsx +133 -0
- package/dist/source/HeadContent.jsx.map +1 -0
- package/dist/source/Match.d.ts +25 -0
- package/dist/source/Match.jsx +316 -0
- package/dist/source/Match.jsx.map +1 -0
- package/dist/source/Matches.d.ts +39 -0
- package/dist/source/Matches.jsx +191 -0
- package/dist/source/Matches.jsx.map +1 -0
- package/dist/source/RouterProvider.d.ts +33 -0
- package/dist/source/RouterProvider.jsx +63 -0
- package/dist/source/RouterProvider.jsx.map +1 -0
- package/dist/source/SafeFragment.d.ts +4 -0
- package/dist/source/SafeFragment.jsx +10 -0
- package/dist/source/SafeFragment.jsx.map +1 -0
- package/dist/source/ScriptOnce.d.ts +5 -0
- package/dist/source/ScriptOnce.jsx +17 -0
- package/dist/source/ScriptOnce.jsx.map +1 -0
- package/dist/source/Scripts.d.ts +1 -0
- package/dist/source/Scripts.jsx +49 -0
- package/dist/source/Scripts.jsx.map +1 -0
- package/dist/source/ScrollRestoration.d.ts +14 -0
- package/dist/source/ScrollRestoration.jsx +37 -0
- package/dist/source/ScrollRestoration.jsx.map +1 -0
- package/dist/source/Transitioner.d.ts +2 -0
- package/dist/source/Transitioner.jsx +181 -0
- package/dist/source/Transitioner.jsx.map +1 -0
- package/dist/source/awaited.d.ts +12 -0
- package/dist/source/awaited.jsx +38 -0
- package/dist/source/awaited.jsx.map +1 -0
- package/dist/source/fileRoute.d.ts +54 -0
- package/dist/source/fileRoute.js +98 -0
- package/dist/source/fileRoute.js.map +1 -0
- package/dist/source/history.d.ts +8 -0
- package/dist/source/history.js +2 -0
- package/dist/source/history.js.map +1 -0
- package/dist/source/index.d.ts +51 -0
- package/dist/source/index.jsx +40 -0
- package/dist/source/index.jsx.map +1 -0
- package/dist/source/lazyRouteComponent.d.ts +8 -0
- package/dist/source/lazyRouteComponent.jsx +135 -0
- package/dist/source/lazyRouteComponent.jsx.map +1 -0
- package/dist/source/link.d.ts +61 -0
- package/dist/source/link.jsx +495 -0
- package/dist/source/link.jsx.map +1 -0
- package/dist/source/matchContext.d.ts +20 -0
- package/dist/source/matchContext.jsx +32 -0
- package/dist/source/matchContext.jsx.map +1 -0
- package/dist/source/not-found.d.ts +12 -0
- package/dist/source/not-found.jsx +48 -0
- package/dist/source/not-found.jsx.map +1 -0
- package/dist/source/renderRouteNotFound.d.ts +11 -0
- package/dist/source/renderRouteNotFound.jsx +24 -0
- package/dist/source/renderRouteNotFound.jsx.map +1 -0
- package/dist/source/route.d.ts +97 -0
- package/dist/source/route.js +167 -0
- package/dist/source/route.js.map +1 -0
- package/dist/source/router.d.ts +70 -0
- package/dist/source/router.js +10 -0
- package/dist/source/router.js.map +1 -0
- package/dist/source/routerContext.d.ts +21 -0
- package/dist/source/routerContext.jsx +37 -0
- package/dist/source/routerContext.jsx.map +1 -0
- package/dist/source/scroll-restoration.d.ts +1 -0
- package/dist/source/scroll-restoration.jsx +16 -0
- package/dist/source/scroll-restoration.jsx.map +1 -0
- package/dist/source/typePrimitives.d.ts +10 -0
- package/dist/source/typePrimitives.js +2 -0
- package/dist/source/typePrimitives.js.map +1 -0
- package/dist/source/useBlocker.d.ts +66 -0
- package/dist/source/useBlocker.jsx +308 -0
- package/dist/source/useBlocker.jsx.map +1 -0
- package/dist/source/useCanGoBack.d.ts +1 -0
- package/dist/source/useCanGoBack.js +5 -0
- package/dist/source/useCanGoBack.js.map +1 -0
- package/dist/source/useLoaderData.d.ts +8 -0
- package/dist/source/useLoaderData.jsx +11 -0
- package/dist/source/useLoaderData.jsx.map +1 -0
- package/dist/source/useLoaderDeps.d.ts +7 -0
- package/dist/source/useLoaderDeps.jsx +11 -0
- package/dist/source/useLoaderDeps.jsx.map +1 -0
- package/dist/source/useLocation.d.ts +7 -0
- package/dist/source/useLocation.jsx +7 -0
- package/dist/source/useLocation.jsx.map +1 -0
- package/dist/source/useMatch.d.ts +10 -0
- package/dist/source/useMatch.jsx +46 -0
- package/dist/source/useMatch.jsx.map +1 -0
- package/dist/source/useNavigate.d.ts +5 -0
- package/dist/source/useNavigate.jsx +18 -0
- package/dist/source/useNavigate.jsx.map +1 -0
- package/dist/source/useParams.d.ts +9 -0
- package/dist/source/useParams.jsx +12 -0
- package/dist/source/useParams.jsx.map +1 -0
- package/dist/source/useRouteContext.d.ts +4 -0
- package/dist/source/useRouteContext.js +8 -0
- package/dist/source/useRouteContext.js.map +1 -0
- package/dist/source/useRouter.d.ts +4 -0
- package/dist/source/useRouter.jsx +9 -0
- package/dist/source/useRouter.jsx.map +1 -0
- package/dist/source/useRouterState.d.ts +8 -0
- package/dist/source/useRouterState.jsx +19 -0
- package/dist/source/useRouterState.jsx.map +1 -0
- package/dist/source/useSearch.d.ts +9 -0
- package/dist/source/useSearch.jsx +12 -0
- package/dist/source/useSearch.jsx.map +1 -0
- package/dist/source/utils.d.ts +40 -0
- package/dist/source/utils.js +78 -0
- package/dist/source/utils.js.map +1 -0
- package/package.json +77 -7
- package/src/Asset.tsx +23 -0
- package/src/CatchBoundary.tsx +186 -0
- package/src/ClientOnly.tsx +75 -0
- package/src/HeadContent.tsx +159 -0
- package/src/Match.tsx +415 -0
- package/src/Matches.tsx +349 -0
- package/src/RouterProvider.tsx +117 -0
- package/src/SafeFragment.tsx +10 -0
- package/src/ScriptOnce.tsx +30 -0
- package/src/Scripts.tsx +65 -0
- package/src/ScrollRestoration.tsx +69 -0
- package/src/Transitioner.tsx +213 -0
- package/src/awaited.tsx +54 -0
- package/src/fileRoute.ts +271 -0
- package/src/history.ts +9 -0
- package/src/index.tsx +346 -0
- package/src/lazyRouteComponent.tsx +173 -0
- package/src/link.tsx +765 -0
- package/src/matchContext.tsx +41 -0
- package/src/not-found.tsx +55 -0
- package/src/renderRouteNotFound.tsx +35 -0
- package/src/route.ts +658 -0
- package/src/router.ts +103 -0
- package/src/routerContext.tsx +53 -0
- package/src/scroll-restoration.tsx +29 -0
- package/src/typePrimitives.ts +74 -0
- package/src/useBlocker.tsx +501 -0
- package/src/useCanGoBack.ts +5 -0
- package/src/useLoaderData.tsx +50 -0
- package/src/useLoaderDeps.tsx +46 -0
- package/src/useLocation.tsx +30 -0
- package/src/useMatch.tsx +127 -0
- package/src/useNavigate.tsx +40 -0
- package/src/useParams.tsx +71 -0
- package/src/useRouteContext.ts +31 -0
- package/src/useRouter.tsx +15 -0
- package/src/useRouterState.tsx +43 -0
- package/src/useSearch.tsx +71 -0
- package/src/utils.ts +111 -0
package/src/router.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { RouterCore } from '@tanstack/router-core'
|
|
2
|
+
import type { RouterHistory } from '@tanstack/history'
|
|
3
|
+
import type {
|
|
4
|
+
AnyRoute,
|
|
5
|
+
CreateRouterFn,
|
|
6
|
+
RouterConstructorOptions,
|
|
7
|
+
TrailingSlashOption,
|
|
8
|
+
} from '@tanstack/router-core'
|
|
9
|
+
import type {
|
|
10
|
+
ErrorRouteComponent,
|
|
11
|
+
NotFoundRouteComponent,
|
|
12
|
+
RouteComponent,
|
|
13
|
+
} from './route'
|
|
14
|
+
import type { VNode } from 'vue'
|
|
15
|
+
|
|
16
|
+
declare module '@tanstack/router-core' {
|
|
17
|
+
export interface RouterOptionsExtensions {
|
|
18
|
+
/**
|
|
19
|
+
* The default `component` a route should use if no component is provided.
|
|
20
|
+
*
|
|
21
|
+
* @default Outlet
|
|
22
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultcomponent-property)
|
|
23
|
+
*/
|
|
24
|
+
defaultComponent?: RouteComponent
|
|
25
|
+
/**
|
|
26
|
+
* The default `errorComponent` a route should use if no error component is provided.
|
|
27
|
+
*
|
|
28
|
+
* @default ErrorComponent
|
|
29
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaulterrorcomponent-property)
|
|
30
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
|
|
31
|
+
*/
|
|
32
|
+
defaultErrorComponent?: ErrorRouteComponent
|
|
33
|
+
/**
|
|
34
|
+
* The default `pendingComponent` a route should use if no pending component is provided.
|
|
35
|
+
*
|
|
36
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultpendingcomponent-property)
|
|
37
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#showing-a-pending-component)
|
|
38
|
+
*/
|
|
39
|
+
defaultPendingComponent?: RouteComponent
|
|
40
|
+
/**
|
|
41
|
+
* The default `notFoundComponent` a route should use if no notFound component is provided.
|
|
42
|
+
*
|
|
43
|
+
* @default NotFound
|
|
44
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
|
|
45
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/not-found-errors#default-router-wide-not-found-handling)
|
|
46
|
+
*/
|
|
47
|
+
defaultNotFoundComponent?: NotFoundRouteComponent
|
|
48
|
+
/**
|
|
49
|
+
* A component that will be used to wrap the entire router.
|
|
50
|
+
*
|
|
51
|
+
* This is useful for providing a context to the entire router.
|
|
52
|
+
*
|
|
53
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#wrap-property)
|
|
54
|
+
*/
|
|
55
|
+
Wrap?: (props: { children: any }) => VNode
|
|
56
|
+
/**
|
|
57
|
+
* A component that will be used to wrap the inner contents of the router.
|
|
58
|
+
*
|
|
59
|
+
* This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
|
|
60
|
+
*
|
|
61
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#innerwrap-property)
|
|
62
|
+
*/
|
|
63
|
+
InnerWrap?: (props: { children: any }) => VNode
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The default `onCatch` handler for errors caught by the Router ErrorBoundary
|
|
67
|
+
*
|
|
68
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
|
|
69
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
|
|
70
|
+
*/
|
|
71
|
+
defaultOnCatch?: (error: Error) => void
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const createRouter: CreateRouterFn = (options) => {
|
|
76
|
+
return new Router(options)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class Router<
|
|
80
|
+
in out TRouteTree extends AnyRoute,
|
|
81
|
+
in out TTrailingSlashOption extends TrailingSlashOption = 'never',
|
|
82
|
+
in out TDefaultStructuralSharingOption extends boolean = false,
|
|
83
|
+
in out TRouterHistory extends RouterHistory = RouterHistory,
|
|
84
|
+
in out TDehydrated extends Record<string, any> = Record<string, any>,
|
|
85
|
+
> extends RouterCore<
|
|
86
|
+
TRouteTree,
|
|
87
|
+
TTrailingSlashOption,
|
|
88
|
+
TDefaultStructuralSharingOption,
|
|
89
|
+
TRouterHistory,
|
|
90
|
+
TDehydrated
|
|
91
|
+
> {
|
|
92
|
+
constructor(
|
|
93
|
+
options: RouterConstructorOptions<
|
|
94
|
+
TRouteTree,
|
|
95
|
+
TTrailingSlashOption,
|
|
96
|
+
TDefaultStructuralSharingOption,
|
|
97
|
+
TRouterHistory,
|
|
98
|
+
TDehydrated
|
|
99
|
+
>,
|
|
100
|
+
) {
|
|
101
|
+
super(options)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as Vue from 'vue'
|
|
2
|
+
import type { AnyRouter } from '@tanstack/router-core'
|
|
3
|
+
|
|
4
|
+
// Create a router context symbol
|
|
5
|
+
export const RouterSymbol = Symbol(
|
|
6
|
+
'TanStackRouter',
|
|
7
|
+
) as Vue.InjectionKey<AnyRouter>
|
|
8
|
+
|
|
9
|
+
declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
__TSR_ROUTER_CONTEXT__?: Vue.InjectionKey<AnyRouter>
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Gets the router context, handling server-side rendering
|
|
17
|
+
* and ensuring a single instance across the application
|
|
18
|
+
*/
|
|
19
|
+
export function getRouterContext(): Vue.InjectionKey<AnyRouter> {
|
|
20
|
+
if (typeof document === 'undefined') {
|
|
21
|
+
// For SSR, return the symbol directly
|
|
22
|
+
return RouterSymbol
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// In the browser, check if we have a cached context
|
|
26
|
+
if (window.__TSR_ROUTER_CONTEXT__) {
|
|
27
|
+
return window.__TSR_ROUTER_CONTEXT__
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Create and cache the context
|
|
31
|
+
window.__TSR_ROUTER_CONTEXT__ = RouterSymbol
|
|
32
|
+
return RouterSymbol
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Provides the router to all child components
|
|
37
|
+
*/
|
|
38
|
+
export function provideRouter(router: AnyRouter): void {
|
|
39
|
+
Vue.provide(getRouterContext(), router)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Injects the router from the component tree
|
|
44
|
+
*/
|
|
45
|
+
export function injectRouter(): AnyRouter {
|
|
46
|
+
const router = Vue.inject<AnyRouter | null>(getRouterContext(), null)
|
|
47
|
+
if (!router) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
'No TanStack Router found in component tree. Did you forget to add a RouterProvider component?',
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
return router
|
|
53
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultGetScrollRestorationKey,
|
|
3
|
+
restoreScroll,
|
|
4
|
+
storageKey,
|
|
5
|
+
} from '@tanstack/router-core'
|
|
6
|
+
import { useRouter } from './useRouter'
|
|
7
|
+
import { ScriptOnce } from './ScriptOnce'
|
|
8
|
+
|
|
9
|
+
export function ScrollRestoration() {
|
|
10
|
+
const router = useRouter()
|
|
11
|
+
const getKey =
|
|
12
|
+
router.options.getScrollRestorationKey || defaultGetScrollRestorationKey
|
|
13
|
+
const userKey = getKey(router.latestLocation)
|
|
14
|
+
const resolvedKey =
|
|
15
|
+
userKey !== defaultGetScrollRestorationKey(router.latestLocation)
|
|
16
|
+
? userKey
|
|
17
|
+
: null
|
|
18
|
+
|
|
19
|
+
if (!router.isScrollRestoring || !router.isServer) {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ScriptOnce
|
|
25
|
+
children={`(${restoreScroll.toString()})(${JSON.stringify(storageKey)},${JSON.stringify(resolvedKey)}, undefined, true)`}
|
|
26
|
+
log={false}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { LinkComponentProps } from './link'
|
|
2
|
+
import type { UseParamsOptions } from './useParams'
|
|
3
|
+
import type { UseSearchOptions } from './useSearch'
|
|
4
|
+
import type {
|
|
5
|
+
AnyRouter,
|
|
6
|
+
Constrain,
|
|
7
|
+
InferFrom,
|
|
8
|
+
InferMaskFrom,
|
|
9
|
+
InferMaskTo,
|
|
10
|
+
InferSelected,
|
|
11
|
+
InferShouldThrow,
|
|
12
|
+
InferStrict,
|
|
13
|
+
InferTo,
|
|
14
|
+
RegisteredRouter,
|
|
15
|
+
} from '@tanstack/router-core'
|
|
16
|
+
|
|
17
|
+
export type ValidateLinkOptions<
|
|
18
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
19
|
+
TOptions = unknown,
|
|
20
|
+
TDefaultFrom extends string = string,
|
|
21
|
+
TComp = 'a',
|
|
22
|
+
> = Constrain<
|
|
23
|
+
TOptions,
|
|
24
|
+
LinkComponentProps<
|
|
25
|
+
TComp,
|
|
26
|
+
TRouter,
|
|
27
|
+
InferFrom<TOptions, TDefaultFrom>,
|
|
28
|
+
InferTo<TOptions>,
|
|
29
|
+
InferMaskFrom<TOptions>,
|
|
30
|
+
InferMaskTo<TOptions>
|
|
31
|
+
>
|
|
32
|
+
>
|
|
33
|
+
|
|
34
|
+
export type ValidateLinkOptionsArray<
|
|
35
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
36
|
+
TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>,
|
|
37
|
+
TDefaultFrom extends string = string,
|
|
38
|
+
TComp = 'a',
|
|
39
|
+
> = {
|
|
40
|
+
[K in keyof TOptions]: ValidateLinkOptions<
|
|
41
|
+
TRouter,
|
|
42
|
+
TOptions[K],
|
|
43
|
+
TDefaultFrom,
|
|
44
|
+
TComp
|
|
45
|
+
>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type ValidateUseSearchOptions<
|
|
49
|
+
TOptions,
|
|
50
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
51
|
+
> = Constrain<
|
|
52
|
+
TOptions,
|
|
53
|
+
UseSearchOptions<
|
|
54
|
+
TRouter,
|
|
55
|
+
InferFrom<TOptions>,
|
|
56
|
+
InferStrict<TOptions>,
|
|
57
|
+
InferShouldThrow<TOptions>,
|
|
58
|
+
InferSelected<TOptions>
|
|
59
|
+
>
|
|
60
|
+
>
|
|
61
|
+
|
|
62
|
+
export type ValidateUseParamsOptions<
|
|
63
|
+
TOptions,
|
|
64
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
65
|
+
> = Constrain<
|
|
66
|
+
TOptions,
|
|
67
|
+
UseParamsOptions<
|
|
68
|
+
TRouter,
|
|
69
|
+
InferFrom<TOptions>,
|
|
70
|
+
InferStrict<TOptions>,
|
|
71
|
+
InferShouldThrow<TOptions>,
|
|
72
|
+
InferSelected<TOptions>
|
|
73
|
+
>
|
|
74
|
+
>
|