@tanstack/solid-router 2.0.0-beta.16 → 2.0.0-beta.17
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.map +1 -1
- package/dist/cjs/Asset.d.cts +1 -1
- package/dist/cjs/CatchBoundary.cjs.map +1 -1
- package/dist/cjs/CatchBoundary.d.cts +4 -3
- package/dist/cjs/ClientOnly.cjs.map +1 -1
- package/dist/cjs/ClientOnly.d.cts +4 -3
- package/dist/cjs/HeadContent.d.cts +1 -1
- package/dist/cjs/HeadContent.dev.d.cts +1 -1
- package/dist/cjs/Match.d.cts +2 -3
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +8 -7
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +4 -4
- package/dist/cjs/SafeFragment.d.cts +1 -1
- package/dist/cjs/ScriptOnce.d.cts +1 -1
- package/dist/cjs/Scripts.d.cts +1 -2
- package/dist/cjs/awaited.d.cts +1 -2
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +10 -10
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +5 -5
- package/dist/cjs/renderRouteNotFound.d.cts +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +5 -5
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -1
- package/dist/cjs/scroll-restoration.d.cts +1 -1
- package/dist/cjs/ssr/RouterClient.d.cts +1 -1
- package/dist/cjs/ssr/RouterServer.d.cts +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToStream.d.cts +2 -2
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToString.d.cts +2 -2
- package/dist/esm/Asset.d.ts +1 -1
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/CatchBoundary.d.ts +4 -3
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ClientOnly.d.ts +4 -3
- package/dist/esm/ClientOnly.js.map +1 -1
- package/dist/esm/HeadContent.d.ts +1 -1
- package/dist/esm/HeadContent.dev.d.ts +1 -1
- package/dist/esm/Match.d.ts +2 -3
- package/dist/esm/Matches.d.ts +8 -7
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +4 -4
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/SafeFragment.d.ts +1 -1
- package/dist/esm/ScriptOnce.d.ts +1 -1
- package/dist/esm/Scripts.d.ts +1 -2
- package/dist/esm/awaited.d.ts +1 -2
- package/dist/esm/link.d.ts +10 -10
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/not-found.d.ts +5 -5
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.d.ts +1 -1
- package/dist/esm/route.d.ts +5 -5
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +1 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/scroll-restoration.d.ts +1 -1
- package/dist/esm/ssr/RouterClient.d.ts +1 -1
- package/dist/esm/ssr/RouterServer.d.ts +1 -1
- package/dist/esm/ssr/renderRouterToStream.d.ts +2 -2
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.d.ts +2 -2
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/source/Asset.d.ts +1 -1
- package/dist/source/CatchBoundary.d.ts +4 -3
- package/dist/source/CatchBoundary.jsx.map +1 -1
- package/dist/source/ClientOnly.d.ts +4 -3
- package/dist/source/ClientOnly.jsx.map +1 -1
- package/dist/source/HeadContent.d.ts +1 -1
- package/dist/source/HeadContent.dev.d.ts +1 -1
- package/dist/source/Match.d.ts +2 -3
- package/dist/source/Matches.d.ts +8 -7
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/RouterProvider.d.ts +4 -4
- package/dist/source/RouterProvider.jsx.map +1 -1
- package/dist/source/SafeFragment.d.ts +1 -1
- package/dist/source/ScriptOnce.d.ts +1 -1
- package/dist/source/Scripts.d.ts +1 -2
- package/dist/source/awaited.d.ts +1 -2
- package/dist/source/link.d.ts +10 -10
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/not-found.d.ts +5 -5
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/renderRouteNotFound.d.ts +1 -1
- package/dist/source/route.d.ts +5 -5
- package/dist/source/route.jsx.map +1 -1
- package/dist/source/router.d.ts +1 -1
- package/dist/source/scroll-restoration.d.ts +1 -1
- package/dist/source/ssr/RouterClient.d.ts +1 -1
- package/dist/source/ssr/RouterServer.d.ts +1 -1
- package/dist/source/ssr/renderRouterToStream.d.ts +2 -2
- package/dist/source/ssr/renderRouterToString.d.ts +2 -2
- package/package.json +8 -8
- package/src/Asset.tsx +1 -1
- package/src/CatchBoundary.tsx +2 -1
- package/src/ClientOnly.tsx +3 -2
- package/src/Matches.tsx +8 -7
- package/src/RouterProvider.tsx +2 -1
- package/src/link.tsx +16 -20
- package/src/not-found.tsx +3 -2
- package/src/route.tsx +3 -7
- package/src/router.ts +1 -1
- package/src/ssr/renderRouterToStream.tsx +2 -2
- package/src/ssr/renderRouterToString.tsx +2 -2
package/src/Matches.tsx
CHANGED
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
RouteByPath,
|
|
25
25
|
ToSubOptionsProps,
|
|
26
26
|
} from '@tanstack/router-core'
|
|
27
|
+
import type { JSX } from '@solidjs/web'
|
|
27
28
|
|
|
28
29
|
const NearestMatchContext = nearestMatchContext as unknown as Solid.Component<{
|
|
29
30
|
value: any
|
|
@@ -32,11 +33,11 @@ const NearestMatchContext = nearestMatchContext as unknown as Solid.Component<{
|
|
|
32
33
|
|
|
33
34
|
declare module '@tanstack/router-core' {
|
|
34
35
|
export interface RouteMatchExtensions {
|
|
35
|
-
meta?: Array<
|
|
36
|
-
links?: Array<
|
|
37
|
-
scripts?: Array<
|
|
38
|
-
styles?: Array<
|
|
39
|
-
headScripts?: Array<
|
|
36
|
+
meta?: Array<JSX.IntrinsicElements['meta'] | undefined>
|
|
37
|
+
links?: Array<JSX.IntrinsicElements['link'] | undefined>
|
|
38
|
+
scripts?: Array<JSX.IntrinsicElements['script'] | undefined>
|
|
39
|
+
styles?: Array<JSX.IntrinsicElements['style'] | undefined>
|
|
40
|
+
headScripts?: Array<JSX.IntrinsicElements['script'] | undefined>
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -183,8 +184,8 @@ export type MakeMatchRouteOptions<
|
|
|
183
184
|
TRouter['routeTree'],
|
|
184
185
|
ResolveRelativePath<TFrom, NoInfer<TTo>>
|
|
185
186
|
>['types']['allParams'],
|
|
186
|
-
) =>
|
|
187
|
-
|
|
|
187
|
+
) => JSX.Element)
|
|
188
|
+
| JSX.Element
|
|
188
189
|
}
|
|
189
190
|
|
|
190
191
|
export function MatchRoute<
|
package/src/RouterProvider.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
RegisteredRouter,
|
|
8
8
|
RouterOptions,
|
|
9
9
|
} from '@tanstack/router-core'
|
|
10
|
+
import type { JSX } from '@solidjs/web'
|
|
10
11
|
|
|
11
12
|
const RouterContext = routerContext as unknown as Solid.Component<{
|
|
12
13
|
value: any
|
|
@@ -21,7 +22,7 @@ export function RouterContextProvider<
|
|
|
21
22
|
children,
|
|
22
23
|
...rest
|
|
23
24
|
}: RouterProps<TRouter, TDehydrated> & {
|
|
24
|
-
children: () =>
|
|
25
|
+
children: () => JSX.Element
|
|
25
26
|
}) {
|
|
26
27
|
if (Object.keys(rest).length > 0) {
|
|
27
28
|
Solid.runWithOwner(null, () => {
|
package/src/link.tsx
CHANGED
|
@@ -27,6 +27,7 @@ import type {
|
|
|
27
27
|
ValidateLinkOptions,
|
|
28
28
|
ValidateLinkOptionsArray,
|
|
29
29
|
} from './typePrimitives'
|
|
30
|
+
import type { ComponentProps, JSX, ValidComponent } from '@solidjs/web'
|
|
30
31
|
|
|
31
32
|
function mergeRefs<T>(
|
|
32
33
|
...refs: Array<((el: T) => void) | undefined>
|
|
@@ -63,7 +64,7 @@ export function useLinkProps<
|
|
|
63
64
|
TMaskTo extends string = '',
|
|
64
65
|
>(
|
|
65
66
|
options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
|
|
66
|
-
):
|
|
67
|
+
): ComponentProps<'a'> {
|
|
67
68
|
const router = useRouter()
|
|
68
69
|
const [isTransitioning, setIsTransitioning] = Solid.createSignal(false)
|
|
69
70
|
const shouldHydrateHash = !isServer && !!router.options.ssr
|
|
@@ -417,8 +418,8 @@ export function useLinkProps<
|
|
|
417
418
|
handleTouchStart,
|
|
418
419
|
)
|
|
419
420
|
|
|
420
|
-
type ResolvedLinkStateProps = Omit<
|
|
421
|
-
style?:
|
|
421
|
+
type ResolvedLinkStateProps = Omit<ComponentProps<'a'>, 'style'> & {
|
|
422
|
+
style?: JSX.CSSProperties
|
|
422
423
|
}
|
|
423
424
|
|
|
424
425
|
const resolvedProps = Solid.createMemo(() => {
|
|
@@ -500,7 +501,7 @@ const STATIC_TRANSITIONING_ATTRIBUTES = {
|
|
|
500
501
|
/** Call a JSX.EventHandlerUnion with the event. */
|
|
501
502
|
function callHandler<T, TEvent extends Event>(
|
|
502
503
|
event: TEvent & { currentTarget: T; target: Element },
|
|
503
|
-
handler:
|
|
504
|
+
handler: JSX.EventHandlerUnion<T, TEvent>,
|
|
504
505
|
) {
|
|
505
506
|
if (typeof handler === 'function') {
|
|
506
507
|
handler(event)
|
|
@@ -511,7 +512,7 @@ function callHandler<T, TEvent extends Event>(
|
|
|
511
512
|
}
|
|
512
513
|
|
|
513
514
|
function createComposedHandler<T, TEvent extends Event>(
|
|
514
|
-
getHandler: () =>
|
|
515
|
+
getHandler: () => JSX.EventHandlerUnion<T, TEvent> | undefined,
|
|
515
516
|
fallback: (event: TEvent) => void,
|
|
516
517
|
) {
|
|
517
518
|
return (event: TEvent & { currentTarget: T; target: Element }) => {
|
|
@@ -527,7 +528,7 @@ export type UseLinkPropsOptions<
|
|
|
527
528
|
TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,
|
|
528
529
|
TMaskTo extends string = '.',
|
|
529
530
|
> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &
|
|
530
|
-
Omit<
|
|
531
|
+
Omit<ComponentProps<'a'>, 'style'> & { style?: JSX.CSSProperties }
|
|
531
532
|
|
|
532
533
|
export type ActiveLinkOptions<
|
|
533
534
|
TComp = 'a',
|
|
@@ -571,15 +572,12 @@ export type LinkProps<
|
|
|
571
572
|
export interface LinkPropsChildren {
|
|
572
573
|
// 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
|
|
573
574
|
children?:
|
|
574
|
-
|
|
|
575
|
-
| ((state: {
|
|
576
|
-
isActive: boolean
|
|
577
|
-
isTransitioning: boolean
|
|
578
|
-
}) => Solid.JSX.Element)
|
|
575
|
+
| JSX.Element
|
|
576
|
+
| ((state: { isActive: boolean; isTransitioning: boolean }) => JSX.Element)
|
|
579
577
|
}
|
|
580
578
|
|
|
581
|
-
type LinkComponentSolidProps<TComp> = TComp extends
|
|
582
|
-
? Omit<
|
|
579
|
+
type LinkComponentSolidProps<TComp> = TComp extends ValidComponent
|
|
580
|
+
? Omit<ComponentProps<TComp>, keyof CreateLinkProps>
|
|
583
581
|
: never
|
|
584
582
|
|
|
585
583
|
export type LinkComponentProps<
|
|
@@ -612,7 +610,7 @@ export type LinkComponent<
|
|
|
612
610
|
const TMaskTo extends string = '',
|
|
613
611
|
>(
|
|
614
612
|
props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
|
|
615
|
-
) =>
|
|
613
|
+
) => JSX.Element
|
|
616
614
|
|
|
617
615
|
export interface LinkComponentRoute<
|
|
618
616
|
in out TDefaultFrom extends string = string,
|
|
@@ -631,11 +629,11 @@ export interface LinkComponentRoute<
|
|
|
631
629
|
this['defaultFrom'],
|
|
632
630
|
TMaskTo
|
|
633
631
|
>,
|
|
634
|
-
):
|
|
632
|
+
): JSX.Element
|
|
635
633
|
}
|
|
636
634
|
|
|
637
635
|
export function createLink<const TComp>(
|
|
638
|
-
Comp: Constrain<TComp, any, (props: CreateLinkProps) =>
|
|
636
|
+
Comp: Constrain<TComp, any, (props: CreateLinkProps) => JSX.Element>,
|
|
639
637
|
): LinkComponent<TComp> {
|
|
640
638
|
return (props) => <Link {...props} _asChild={Comp} />
|
|
641
639
|
}
|
|
@@ -653,9 +651,7 @@ export const Link: LinkComponent<'a'> = (props) => {
|
|
|
653
651
|
// Resolve children once using Solid.children to avoid
|
|
654
652
|
// re-accessing the children getter (which in Solid 2.0 would
|
|
655
653
|
// re-invoke createComponent each time for JSX children).
|
|
656
|
-
const resolvedChildren = Solid.children(
|
|
657
|
-
() => local.children as Solid.JSX.Element,
|
|
658
|
-
)
|
|
654
|
+
const resolvedChildren = Solid.children(() => local.children as JSX.Element)
|
|
659
655
|
|
|
660
656
|
const children = () => {
|
|
661
657
|
const ch = resolvedChildren()
|
|
@@ -687,7 +683,7 @@ export const Link: LinkComponent<'a'> = (props) => {
|
|
|
687
683
|
}
|
|
688
684
|
|
|
689
685
|
return (
|
|
690
|
-
<Dynamic component={local._asChild as
|
|
686
|
+
<Dynamic component={local._asChild as ValidComponent} {...linkProps}>
|
|
691
687
|
{children()}
|
|
692
688
|
</Dynamic>
|
|
693
689
|
)
|
package/src/not-found.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import * as Solid from 'solid-js'
|
|
|
3
3
|
import { CatchBoundary } from './CatchBoundary'
|
|
4
4
|
import { useRouter } from './useRouter'
|
|
5
5
|
import type { NotFoundError } from '@tanstack/router-core'
|
|
6
|
+
import type { JSX } from '@solidjs/web'
|
|
6
7
|
|
|
7
8
|
// Solid wraps non-Error throws in an Error and stores the original thrown value
|
|
8
9
|
// on `cause`, so component-thrown `notFound()` needs one extra unwrapping step.
|
|
@@ -21,9 +22,9 @@ export function getNotFound(
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export function CatchNotFound(props: {
|
|
24
|
-
fallback?: (error: NotFoundError) =>
|
|
25
|
+
fallback?: (error: NotFoundError) => JSX.Element
|
|
25
26
|
onCatch?: (error: NotFoundError) => void
|
|
26
|
-
children:
|
|
27
|
+
children: JSX.Element
|
|
27
28
|
}) {
|
|
28
29
|
const router = useRouter()
|
|
29
30
|
// TODO: Some way for the user to programmatically reset the not-found boundary?
|
package/src/route.tsx
CHANGED
|
@@ -44,9 +44,9 @@ import type { UseMatchRoute } from './useMatch'
|
|
|
44
44
|
import type { UseLoaderDepsRoute } from './useLoaderDeps'
|
|
45
45
|
import type { UseParamsRoute } from './useParams'
|
|
46
46
|
import type { UseSearchRoute } from './useSearch'
|
|
47
|
-
import type * as Solid from 'solid-js'
|
|
48
47
|
import type { UseRouteContextRoute } from './useRouteContext'
|
|
49
48
|
import type { LinkComponentRoute } from './link'
|
|
49
|
+
import type { JSX } from '@solidjs/web'
|
|
50
50
|
|
|
51
51
|
declare module '@tanstack/router-core' {
|
|
52
52
|
export interface UpdatableRouteOptionsExtensions {
|
|
@@ -57,11 +57,7 @@ declare module '@tanstack/router-core' {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export interface RootRouteOptionsExtensions {
|
|
60
|
-
shellComponent?: ({
|
|
61
|
-
children,
|
|
62
|
-
}: {
|
|
63
|
-
children: Solid.JSX.Element
|
|
64
|
-
}) => Solid.JSX.Element
|
|
60
|
+
shellComponent?: ({ children }: { children: JSX.Element }) => JSX.Element
|
|
65
61
|
}
|
|
66
62
|
|
|
67
63
|
export interface RouteExtensions<
|
|
@@ -537,7 +533,7 @@ export function createRouteMask<
|
|
|
537
533
|
return opts as any
|
|
538
534
|
}
|
|
539
535
|
|
|
540
|
-
export type SolidNode =
|
|
536
|
+
export type SolidNode = JSX.Element
|
|
541
537
|
|
|
542
538
|
export interface DefaultRouteTypes<TProps> {
|
|
543
539
|
component: (props: TProps) => any
|
package/src/router.ts
CHANGED
|
@@ -2,9 +2,9 @@ import * as Solid from '@solidjs/web'
|
|
|
2
2
|
import { isbot } from 'isbot'
|
|
3
3
|
import { transformReadableStreamWithRouter } from '@tanstack/router-core/ssr/server'
|
|
4
4
|
import { makeSsrSerovalPlugin } from '@tanstack/router-core'
|
|
5
|
-
import type { JSXElement } from 'solid-js'
|
|
6
5
|
import type { ReadableStream } from 'node:stream/web'
|
|
7
6
|
import type { AnyRouter } from '@tanstack/router-core'
|
|
7
|
+
import type { JSX } from '@solidjs/web'
|
|
8
8
|
|
|
9
9
|
export const renderRouterToStream = async ({
|
|
10
10
|
request,
|
|
@@ -15,7 +15,7 @@ export const renderRouterToStream = async ({
|
|
|
15
15
|
request: Request
|
|
16
16
|
router: AnyRouter
|
|
17
17
|
responseHeaders: Headers
|
|
18
|
-
children: () =>
|
|
18
|
+
children: () => JSX.Element
|
|
19
19
|
}) => {
|
|
20
20
|
const { writable, readable } = new TransformStream()
|
|
21
21
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Solid from '@solidjs/web'
|
|
2
2
|
import { makeSsrSerovalPlugin } from '@tanstack/router-core'
|
|
3
3
|
import type { AnyRouter } from '@tanstack/router-core'
|
|
4
|
-
import type {
|
|
4
|
+
import type { JSX } from '@solidjs/web'
|
|
5
5
|
|
|
6
6
|
export const renderRouterToString = ({
|
|
7
7
|
router,
|
|
@@ -10,7 +10,7 @@ export const renderRouterToString = ({
|
|
|
10
10
|
}: {
|
|
11
11
|
router: AnyRouter
|
|
12
12
|
responseHeaders: Headers
|
|
13
|
-
children: () =>
|
|
13
|
+
children: () => JSX.Element
|
|
14
14
|
}) => {
|
|
15
15
|
try {
|
|
16
16
|
const serializationAdapters =
|