@tanstack/solid-router 1.120.2 → 1.120.4-alpha.1

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.
Files changed (52) hide show
  1. package/dist/cjs/HeadContent.cjs +18 -6
  2. package/dist/cjs/HeadContent.cjs.map +1 -1
  3. package/dist/cjs/fileRoute.cjs +8 -0
  4. package/dist/cjs/fileRoute.cjs.map +1 -1
  5. package/dist/cjs/fileRoute.d.cts +16 -5
  6. package/dist/cjs/index.d.cts +1 -1
  7. package/dist/cjs/link.cjs.map +1 -1
  8. package/dist/cjs/link.d.cts +4 -1
  9. package/dist/cjs/route.cjs.map +1 -1
  10. package/dist/cjs/route.d.cts +1 -1
  11. package/dist/cjs/router.cjs +8 -0
  12. package/dist/cjs/router.cjs.map +1 -1
  13. package/dist/cjs/useBlocker.cjs +1 -1
  14. package/dist/cjs/useBlocker.cjs.map +1 -1
  15. package/dist/esm/HeadContent.js +18 -6
  16. package/dist/esm/HeadContent.js.map +1 -1
  17. package/dist/esm/fileRoute.d.ts +16 -5
  18. package/dist/esm/fileRoute.js +8 -0
  19. package/dist/esm/fileRoute.js.map +1 -1
  20. package/dist/esm/index.d.ts +1 -1
  21. package/dist/esm/link.d.ts +4 -1
  22. package/dist/esm/link.js.map +1 -1
  23. package/dist/esm/route.d.ts +1 -1
  24. package/dist/esm/route.js.map +1 -1
  25. package/dist/esm/router.js +8 -0
  26. package/dist/esm/router.js.map +1 -1
  27. package/dist/esm/useBlocker.js +1 -1
  28. package/dist/esm/useBlocker.js.map +1 -1
  29. package/dist/source/HeadContent.jsx +25 -10
  30. package/dist/source/HeadContent.jsx.map +1 -1
  31. package/dist/source/fileRoute.d.ts +16 -5
  32. package/dist/source/fileRoute.js +8 -0
  33. package/dist/source/fileRoute.js.map +1 -1
  34. package/dist/source/index.d.ts +1 -1
  35. package/dist/source/index.jsx.map +1 -1
  36. package/dist/source/link.d.ts +4 -1
  37. package/dist/source/link.jsx.map +1 -1
  38. package/dist/source/route.d.ts +1 -1
  39. package/dist/source/route.jsx +6 -6
  40. package/dist/source/route.jsx.map +1 -1
  41. package/dist/source/router.js +11 -0
  42. package/dist/source/router.js.map +1 -1
  43. package/dist/source/useBlocker.jsx +1 -1
  44. package/dist/source/useBlocker.jsx.map +1 -1
  45. package/package.json +3 -3
  46. package/src/HeadContent.tsx +23 -3
  47. package/src/fileRoute.ts +26 -4
  48. package/src/index.tsx +2 -0
  49. package/src/link.tsx +19 -14
  50. package/src/route.tsx +8 -8
  51. package/src/router.ts +9 -0
  52. package/src/useBlocker.tsx +4 -1
package/src/link.tsx CHANGED
@@ -522,20 +522,25 @@ export type LinkComponent<
522
522
  props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
523
523
  ) => Solid.JSX.Element
524
524
 
525
- export type LinkComponentRoute<in out TDefaultFrom extends string = string> = <
526
- TRouter extends AnyRouter = RegisteredRouter,
527
- const TTo extends string | undefined = undefined,
528
- const TMaskTo extends string = '',
529
- >(
530
- props: LinkComponentProps<
531
- 'a',
532
- TRouter,
533
- TDefaultFrom,
534
- TTo,
535
- TDefaultFrom,
536
- TMaskTo
537
- >,
538
- ) => Solid.JSX.Element
525
+ export interface LinkComponentRoute<
526
+ in out TDefaultFrom extends string = string,
527
+ > {
528
+ defaultFrom: TDefaultFrom
529
+ <
530
+ TRouter extends AnyRouter = RegisteredRouter,
531
+ const TTo extends string | undefined = undefined,
532
+ const TMaskTo extends string = '',
533
+ >(
534
+ props: LinkComponentProps<
535
+ 'a',
536
+ TRouter,
537
+ this['defaultFrom'],
538
+ TTo,
539
+ this['defaultFrom'],
540
+ TMaskTo
541
+ >,
542
+ ): Solid.JSX.Element
543
+ }
539
544
 
540
545
  export function createLink<const TComp>(
541
546
  Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,
package/src/route.tsx CHANGED
@@ -53,8 +53,8 @@ declare module '@tanstack/router-core' {
53
53
  }
54
54
 
55
55
  export interface RouteExtensions<
56
- TId extends string,
57
- TFullPath extends string,
56
+ in out TId extends string,
57
+ in out TFullPath extends string,
58
58
  > {
59
59
  useMatch: UseMatchRoute<TId>
60
60
  useRouteContext: UseRouteContextRoute<TId>
@@ -132,13 +132,13 @@ export class RouteApi<
132
132
  return notFound({ routeId: this.id as string, ...opts })
133
133
  }
134
134
 
135
- Link: LinkComponentRoute<RouteTypesById<TRouter, TId>['fullPath']> = (
135
+ Link: LinkComponentRoute<RouteTypesById<TRouter, TId>['fullPath']> = ((
136
136
  props,
137
137
  ) => {
138
138
  const router = useRouter()
139
139
  const fullPath = router.routesById[this.id as string].fullPath
140
140
  return <Link from={fullPath as never} {...props} />
141
- }
141
+ }) as LinkComponentRoute<RouteTypesById<TRouter, TId>['fullPath']>
142
142
  }
143
143
 
144
144
  export class Route<
@@ -242,9 +242,9 @@ export class Route<
242
242
  return useNavigate({ from: this.fullPath })
243
243
  }
244
244
 
245
- Link: LinkComponentRoute<TFullPath> = (props) => {
245
+ Link: LinkComponentRoute<TFullPath> = ((props) => {
246
246
  return <Link from={this.fullPath} {...props} />
247
- }
247
+ }) as LinkComponentRoute<TFullPath>
248
248
  }
249
249
 
250
250
  export function createRoute<
@@ -427,9 +427,9 @@ export class RootRoute<
427
427
  return useNavigate({ from: this.fullPath })
428
428
  }
429
429
 
430
- Link: LinkComponentRoute<'/'> = (props) => {
430
+ Link: LinkComponentRoute<'/'> = ((props) => {
431
431
  return <Link from={this.fullPath} {...(props as any)} />
432
- }
432
+ }) as LinkComponentRoute<'/'>
433
433
  }
434
434
 
435
435
  export function createRouteMask<
package/src/router.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { RouterCore } from '@tanstack/router-core'
2
+ import { createFileRoute, createLazyFileRoute } from './fileRoute'
2
3
  import type { RouterHistory } from '@tanstack/history'
3
4
  import type {
4
5
  AnyRoute,
@@ -101,3 +102,11 @@ export class Router<
101
102
  super(options)
102
103
  }
103
104
  }
105
+
106
+ if (typeof globalThis !== 'undefined') {
107
+ ;(globalThis as any).createFileRoute = createFileRoute
108
+ ;(globalThis as any).createLazyFileRoute = createLazyFileRoute
109
+ } else if (typeof window !== 'undefined') {
110
+ ;(window as any).createFileRoute = createFileRoute
111
+ ;(window as any).createFileRoute = createLazyFileRoute
112
+ }
@@ -180,7 +180,10 @@ export function useBlocker(
180
180
  location: HistoryLocation,
181
181
  ): AnyShouldBlockFnLocation {
182
182
  const parsedLocation = router.parseLocation(undefined, location)
183
- const matchedRoutes = router.getMatchedRoutes(parsedLocation)
183
+ const matchedRoutes = router.getMatchedRoutes(
184
+ parsedLocation.pathname,
185
+ undefined,
186
+ )
184
187
  if (matchedRoutes.foundRoute === undefined) {
185
188
  throw new Error(`No route found for location ${location.href}`)
186
189
  }