@tanstack/solid-router 1.156.0 → 1.157.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 (50) hide show
  1. package/dist/cjs/Asset.cjs +2 -1
  2. package/dist/cjs/Asset.cjs.map +1 -1
  3. package/dist/cjs/Match.cjs +4 -4
  4. package/dist/cjs/Match.cjs.map +1 -1
  5. package/dist/cjs/Matches.cjs +1 -1
  6. package/dist/cjs/Matches.cjs.map +1 -1
  7. package/dist/cjs/ScriptOnce.cjs +2 -1
  8. package/dist/cjs/ScriptOnce.cjs.map +1 -1
  9. package/dist/cjs/Transitioner.cjs +1 -1
  10. package/dist/cjs/Transitioner.cjs.map +1 -1
  11. package/dist/cjs/link.cjs +11 -19
  12. package/dist/cjs/link.cjs.map +1 -1
  13. package/dist/cjs/scroll-restoration.cjs +1 -1
  14. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  15. package/dist/esm/Asset.js +2 -1
  16. package/dist/esm/Asset.js.map +1 -1
  17. package/dist/esm/Match.js +5 -5
  18. package/dist/esm/Match.js.map +1 -1
  19. package/dist/esm/Matches.js +2 -2
  20. package/dist/esm/Matches.js.map +1 -1
  21. package/dist/esm/ScriptOnce.js +2 -1
  22. package/dist/esm/ScriptOnce.js.map +1 -1
  23. package/dist/esm/Transitioner.js +2 -2
  24. package/dist/esm/Transitioner.js.map +1 -1
  25. package/dist/esm/link.js +11 -19
  26. package/dist/esm/link.js.map +1 -1
  27. package/dist/esm/scroll-restoration.js +2 -2
  28. package/dist/esm/scroll-restoration.js.map +1 -1
  29. package/dist/source/Asset.jsx +2 -1
  30. package/dist/source/Asset.jsx.map +1 -1
  31. package/dist/source/Match.jsx +5 -5
  32. package/dist/source/Match.jsx.map +1 -1
  33. package/dist/source/Matches.jsx +3 -2
  34. package/dist/source/Matches.jsx.map +1 -1
  35. package/dist/source/ScriptOnce.jsx +2 -1
  36. package/dist/source/ScriptOnce.jsx.map +1 -1
  37. package/dist/source/Transitioner.jsx +2 -2
  38. package/dist/source/Transitioner.jsx.map +1 -1
  39. package/dist/source/link.jsx +14 -19
  40. package/dist/source/link.jsx.map +1 -1
  41. package/dist/source/scroll-restoration.jsx +2 -2
  42. package/dist/source/scroll-restoration.jsx.map +1 -1
  43. package/package.json +3 -3
  44. package/src/Asset.tsx +2 -1
  45. package/src/Match.tsx +5 -4
  46. package/src/Matches.tsx +3 -2
  47. package/src/ScriptOnce.tsx +2 -1
  48. package/src/Transitioner.tsx +2 -1
  49. package/src/link.tsx +15 -17
  50. package/src/scroll-restoration.tsx +2 -1
package/src/Match.tsx CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  getLocationChangeInfo,
7
7
  isNotFound,
8
8
  isRedirect,
9
+ isServer,
9
10
  rootRouteId,
10
11
  } from '@tanstack/router-core'
11
12
  import { Dynamic } from 'solid-js/web'
@@ -93,7 +94,7 @@ export const Match = (props: { matchId: string }) => {
93
94
  component={ResolvedSuspenseBoundary()}
94
95
  fallback={
95
96
  // Don't show fallback on server when using no-ssr mode to avoid hydration mismatch
96
- router.isServer || resolvedNoSsr ? undefined : (
97
+ (isServer ?? router.isServer) || resolvedNoSsr ? undefined : (
97
98
  <Dynamic component={resolvePendingComponent()} />
98
99
  )
99
100
  }
@@ -129,7 +130,7 @@ export const Match = (props: { matchId: string }) => {
129
130
  <Solid.Switch>
130
131
  <Solid.Match when={resolvedNoSsr}>
131
132
  <Solid.Show
132
- when={!router.isServer}
133
+ when={!(isServer ?? router.isServer)}
133
134
  fallback={<Dynamic component={resolvePendingComponent()} />}
134
135
  >
135
136
  <MatchInner matchId={props.matchId} />
@@ -271,7 +272,7 @@ export const MatchInner = (props: { matchId: string }): any => {
271
272
  const routerMatch = router.getMatch(match().id)
272
273
  if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {
273
274
  // Create a promise that will resolve after the minPendingMs
274
- if (!router.isServer) {
275
+ if (!(isServer ?? router.isServer)) {
275
276
  const minPendingPromise = createControlledPromise<void>()
276
277
 
277
278
  routerMatch._nonReactive.minPendingPromise = minPendingPromise
@@ -332,7 +333,7 @@ export const MatchInner = (props: { matchId: string }): any => {
332
333
  </Solid.Match>
333
334
  <Solid.Match when={match().status === 'error'}>
334
335
  {(_) => {
335
- if (router.isServer) {
336
+ if (isServer ?? router.isServer) {
336
337
  const RouteErrorComponent =
337
338
  (route().options.errorComponent ??
338
339
  router.options.defaultErrorComponent) ||
package/src/Matches.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as Solid from 'solid-js'
2
2
  import warning from 'tiny-warning'
3
- import { rootRouteId } from '@tanstack/router-core'
3
+ import { isServer, rootRouteId } from '@tanstack/router-core'
4
4
  import { CatchBoundary, ErrorComponent } from './CatchBoundary'
5
5
  import { useRouterState } from './useRouterState'
6
6
  import { useRouter } from './useRouter'
@@ -41,7 +41,8 @@ export function Matches() {
41
41
  const router = useRouter()
42
42
 
43
43
  const ResolvedSuspense =
44
- router.isServer || (typeof document !== 'undefined' && router.ssr)
44
+ (isServer ?? router.isServer) ||
45
+ (typeof document !== 'undefined' && router.ssr)
45
46
  ? SafeFragment
46
47
  : Solid.Suspense
47
48
 
@@ -1,3 +1,4 @@
1
+ import { isServer } from '@tanstack/router-core'
1
2
  import { useRouter } from './useRouter'
2
3
 
3
4
  export function ScriptOnce({
@@ -8,7 +9,7 @@ export function ScriptOnce({
8
9
  sync?: boolean
9
10
  }) {
10
11
  const router = useRouter()
11
- if (!router.isServer) {
12
+ if (!(isServer ?? router.isServer)) {
12
13
  return null
13
14
  }
14
15
  return (
@@ -2,6 +2,7 @@ import * as Solid from 'solid-js'
2
2
  import {
3
3
  getLocationChangeInfo,
4
4
  handleHashScroll,
5
+ isServer,
5
6
  trimPathRight,
6
7
  } from '@tanstack/router-core'
7
8
  import { useRouter } from './useRouter'
@@ -15,7 +16,7 @@ export function Transitioner() {
15
16
  select: ({ isLoading }) => isLoading,
16
17
  })
17
18
 
18
- if (router.isServer) {
19
+ if (isServer ?? router.isServer) {
19
20
  return null
20
21
  }
21
22
 
package/src/link.tsx CHANGED
@@ -134,25 +134,23 @@ export function useLinkProps<
134
134
  })
135
135
 
136
136
  const hrefOption = Solid.createMemo(() => {
137
- if (_options().disabled) {
138
- return undefined
137
+ if (_options().disabled) return undefined
138
+ // Use publicHref - it contains the correct href for display
139
+ // When a rewrite changes the origin, publicHref is the full URL
140
+ // Otherwise it's the origin-stripped path
141
+ // This avoids constructing URL objects in the hot path
142
+ const location = next().maskedLocation ?? next()
143
+ const publicHref = location.publicHref
144
+ const external = location.external
145
+
146
+ if (external) {
147
+ return { href: publicHref, external: true }
139
148
  }
140
- let href
141
- const maskedLocation = next().maskedLocation
142
- if (maskedLocation) {
143
- href = maskedLocation.url.href
144
- } else {
145
- href = next().url.href
146
- }
147
- let external = false
148
- if (router.origin) {
149
- if (href.startsWith(router.origin)) {
150
- href = router.history.createHref(href.replace(router.origin, ''))
151
- } else {
152
- external = true
153
- }
149
+
150
+ return {
151
+ href: router.history.createHref(publicHref) || '/',
152
+ external: false,
154
153
  }
155
- return { href, external }
156
154
  })
157
155
 
158
156
  const externalLink = Solid.createMemo(() => {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  defaultGetScrollRestorationKey,
3
3
  escapeHtml,
4
+ isServer,
4
5
  restoreScroll,
5
6
  storageKey,
6
7
  } from '@tanstack/router-core'
@@ -9,7 +10,7 @@ import { ScriptOnce } from './ScriptOnce'
9
10
 
10
11
  export function ScrollRestoration() {
11
12
  const router = useRouter()
12
- if (!router.isScrollRestoring || !router.isServer) {
13
+ if (!router.isScrollRestoring || !(isServer ?? router.isServer)) {
13
14
  return null
14
15
  }
15
16
  if (typeof router.options.scrollRestoration === 'function') {