@tanstack/vue-router 1.168.12 → 1.168.13

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 (46) hide show
  1. package/dist/esm/Match.js +2 -2
  2. package/dist/esm/Match.js.map +1 -1
  3. package/dist/esm/Transitioner.js +11 -11
  4. package/dist/esm/Transitioner.js.map +1 -1
  5. package/dist/esm/link.js +1 -1
  6. package/dist/esm/link.js.map +1 -1
  7. package/dist/esm/routerStores.js +7 -7
  8. package/dist/esm/routerStores.js.map +1 -1
  9. package/dist/esm/ssr/RouterClient.js +1 -1
  10. package/dist/esm/ssr/RouterClient.js.map +1 -1
  11. package/dist/esm/ssr/renderRouterToStream.js +2 -2
  12. package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
  13. package/dist/esm/ssr/renderRouterToString.js +1 -1
  14. package/dist/esm/ssr/renderRouterToString.js.map +1 -1
  15. package/dist/esm/useMatch.js +1 -1
  16. package/dist/esm/useMatch.js.map +1 -1
  17. package/dist/esm/useRouterState.js +1 -1
  18. package/dist/esm/useRouterState.js.map +1 -1
  19. package/dist/source/Match.jsx +2 -2
  20. package/dist/source/Match.jsx.map +1 -1
  21. package/dist/source/Transitioner.jsx +11 -11
  22. package/dist/source/Transitioner.jsx.map +1 -1
  23. package/dist/source/link.jsx +1 -1
  24. package/dist/source/link.jsx.map +1 -1
  25. package/dist/source/routerStores.js +7 -7
  26. package/dist/source/routerStores.js.map +1 -1
  27. package/dist/source/ssr/RouterClient.jsx +1 -1
  28. package/dist/source/ssr/RouterClient.jsx.map +1 -1
  29. package/dist/source/ssr/renderRouterToStream.jsx +2 -2
  30. package/dist/source/ssr/renderRouterToStream.jsx.map +1 -1
  31. package/dist/source/ssr/renderRouterToString.jsx +1 -1
  32. package/dist/source/ssr/renderRouterToString.jsx.map +1 -1
  33. package/dist/source/useMatch.jsx +1 -1
  34. package/dist/source/useMatch.jsx.map +1 -1
  35. package/dist/source/useRouterState.jsx +1 -1
  36. package/dist/source/useRouterState.jsx.map +1 -1
  37. package/package.json +2 -2
  38. package/src/Match.tsx +3 -3
  39. package/src/Transitioner.tsx +14 -18
  40. package/src/link.tsx +1 -1
  41. package/src/routerStores.ts +7 -7
  42. package/src/ssr/RouterClient.tsx +1 -1
  43. package/src/ssr/renderRouterToStream.tsx +2 -2
  44. package/src/ssr/renderRouterToString.tsx +1 -1
  45. package/src/useMatch.tsx +1 -1
  46. package/src/useRouterState.tsx +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vue-router",
3
- "version": "1.168.12",
3
+ "version": "1.168.13",
4
4
  "description": "Modern and scalable routing for Vue applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -65,7 +65,7 @@
65
65
  "isbot": "^5.1.22",
66
66
  "jsesc": "^3.0.2",
67
67
  "@tanstack/history": "1.161.6",
68
- "@tanstack/router-core": "1.168.9"
68
+ "@tanstack/router-core": "1.168.10"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@tanstack/intent": "^0.0.14",
package/src/Match.tsx CHANGED
@@ -268,8 +268,8 @@ const OnRendered = Vue.defineComponent({
268
268
  router.emit({
269
269
  type: 'onRendered',
270
270
  ...getLocationChangeInfo(
271
- router.stores.location.state,
272
- router.stores.resolvedLocation.state,
271
+ router.stores.location.get(),
272
+ router.stores.resolvedLocation.get(),
273
273
  ),
274
274
  })
275
275
  prevHref = currentHref
@@ -525,7 +525,7 @@ export const Outlet = Vue.defineComponent({
525
525
  const childMatchData = Vue.computed(() => {
526
526
  const childId = childMatchIdMap.value[parentRouteId]
527
527
  if (!childId) return null
528
- const child = router.stores.activeMatchStoresById.get(childId)?.state
528
+ const child = router.stores.activeMatchStoresById.get(childId)?.get()
529
529
  if (!child) return null
530
530
 
531
531
  return {
@@ -60,7 +60,7 @@ export function useTransitionerSetup() {
60
60
  isTransitioning.value = true
61
61
  // Also update the router state so useMatch knows we're transitioning
62
62
  try {
63
- router.stores.isTransitioning.setState(() => true)
63
+ router.stores.isTransitioning.set(true)
64
64
  } catch {
65
65
  // Ignore errors if component is unmounted
66
66
  }
@@ -71,7 +71,7 @@ export function useTransitionerSetup() {
71
71
  Vue.nextTick(() => {
72
72
  try {
73
73
  isTransitioning.value = false
74
- router.stores.isTransitioning.setState(() => false)
74
+ router.stores.isTransitioning.set(false)
75
75
  } catch {
76
76
  // Ignore errors if component is unmounted
77
77
  }
@@ -140,12 +140,10 @@ export function useTransitionerSetup() {
140
140
  Vue.onMounted(() => {
141
141
  isMounted.value = true
142
142
  if (!isAnyPending.value) {
143
- if (router.stores.status.state === 'pending') {
143
+ if (router.stores.status.get() === 'pending') {
144
144
  batch(() => {
145
- router.stores.status.setState(() => 'idle')
146
- router.stores.resolvedLocation.setState(
147
- () => router.stores.location.state,
148
- )
145
+ router.stores.status.set('idle')
146
+ router.stores.resolvedLocation.set(router.stores.location.get())
149
147
  })
150
148
  }
151
149
  }
@@ -188,8 +186,8 @@ export function useTransitionerSetup() {
188
186
  router.emit({
189
187
  type: 'onLoad',
190
188
  ...getLocationChangeInfo(
191
- router.stores.location.state,
192
- router.stores.resolvedLocation.state,
189
+ router.stores.location.get(),
190
+ router.stores.resolvedLocation.get(),
193
191
  ),
194
192
  })
195
193
  }
@@ -207,8 +205,8 @@ export function useTransitionerSetup() {
207
205
  router.emit({
208
206
  type: 'onBeforeRouteMount',
209
207
  ...getLocationChangeInfo(
210
- router.stores.location.state,
211
- router.stores.resolvedLocation.state,
208
+ router.stores.location.get(),
209
+ router.stores.resolvedLocation.get(),
212
210
  ),
213
211
  })
214
212
  }
@@ -220,20 +218,18 @@ export function useTransitionerSetup() {
220
218
  Vue.watch(isAnyPending, (newValue) => {
221
219
  if (!isMounted.value) return
222
220
  try {
223
- if (!newValue && router.stores.status.state === 'pending') {
221
+ if (!newValue && router.stores.status.get() === 'pending') {
224
222
  batch(() => {
225
- router.stores.status.setState(() => 'idle')
226
- router.stores.resolvedLocation.setState(
227
- () => router.stores.location.state,
228
- )
223
+ router.stores.status.set('idle')
224
+ router.stores.resolvedLocation.set(router.stores.location.get())
229
225
  })
230
226
  }
231
227
 
232
228
  // The router was pending and now it's not
233
229
  if (previousIsAnyPending.value.previous && !newValue) {
234
230
  const changeInfo = getLocationChangeInfo(
235
- router.stores.location.state,
236
- router.stores.resolvedLocation.state,
231
+ router.stores.location.get(),
232
+ router.stores.resolvedLocation.get(),
237
233
  )
238
234
  router.emit({
239
235
  type: 'onResolved',
package/src/link.tsx CHANGED
@@ -186,7 +186,7 @@ export function useLinkProps<
186
186
  })
187
187
 
188
188
  const isActive = getIsActive({
189
- loc: router.stores.location.state,
189
+ loc: router.stores.location.get(),
190
190
  nextLoc: next,
191
191
  activeOptions: options.activeOptions,
192
192
  router,
@@ -1,4 +1,4 @@
1
- import { batch, createStore } from '@tanstack/vue-store'
1
+ import { batch, createAtom } from '@tanstack/vue-store'
2
2
  import type {
3
3
  AnyRoute,
4
4
  GetStoreConfig,
@@ -18,16 +18,16 @@ declare module '@tanstack/router-core' {
18
18
 
19
19
  export const getStoreFactory: GetStoreConfig = (_opts) => {
20
20
  return {
21
- createMutableStore: createStore,
22
- createReadonlyStore: createStore,
21
+ createMutableStore: createAtom,
22
+ createReadonlyStore: createAtom,
23
23
  batch,
24
24
  init: (stores: RouterStores<AnyRoute>) => {
25
25
  // Single derived store: one reactive node that maps every active
26
26
  // routeId to its child's matchId. Depends only on matchesId +
27
27
  // the pool's routeId tags (which are set during reconciliation).
28
28
  // Outlet reads the map and then does a direct pool lookup.
29
- stores.childMatchIdByRouteId = createStore(() => {
30
- const ids = stores.matchesId.state
29
+ stores.childMatchIdByRouteId = createAtom(() => {
30
+ const ids = stores.matchesId.get()
31
31
  const obj: Record<string, string> = {}
32
32
  for (let i = 0; i < ids.length - 1; i++) {
33
33
  const parentStore = stores.activeMatchStoresById.get(ids[i]!)
@@ -38,8 +38,8 @@ export const getStoreFactory: GetStoreConfig = (_opts) => {
38
38
  return obj
39
39
  })
40
40
 
41
- stores.pendingRouteIds = createStore(() => {
42
- const ids = stores.pendingMatchesId.state
41
+ stores.pendingRouteIds = createAtom(() => {
42
+ const ids = stores.pendingMatchesId.get()
43
43
  const obj: Record<string, boolean> = {}
44
44
  for (const id of ids) {
45
45
  const store = stores.pendingMatchStoresById.get(id)
@@ -18,7 +18,7 @@ export const RouterClient = Vue.defineComponent({
18
18
  const isHydrated = Vue.ref(false)
19
19
 
20
20
  if (!hydrationPromise) {
21
- if (!props.router.stores.matchesId.state.length) {
21
+ if (!props.router.stores.matchesId.get().length) {
22
22
  hydrationPromise = hydrate(props.router)
23
23
  } else {
24
24
  hydrationPromise = Promise.resolve()
@@ -62,7 +62,7 @@ export const renderRouterToStream = async ({
62
62
  }
63
63
 
64
64
  return new Response(`<!DOCTYPE html>${fullHtml}`, {
65
- status: router.stores.statusCode.state,
65
+ status: router.stores.statusCode.get(),
66
66
  headers: responseHeaders,
67
67
  })
68
68
  }
@@ -78,7 +78,7 @@ export const renderRouterToStream = async ({
78
78
  )
79
79
 
80
80
  return new Response(responseStream as any, {
81
- status: router.stores.statusCode.state,
81
+ status: router.stores.statusCode.get(),
82
82
  headers: responseHeaders,
83
83
  })
84
84
  }
@@ -24,7 +24,7 @@ export const renderRouterToString = async ({
24
24
  }
25
25
 
26
26
  return new Response(`<!DOCTYPE html>${html}`, {
27
- status: router.stores.statusCode.state,
27
+ status: router.stores.statusCode.get(),
28
28
  headers: responseHeaders,
29
29
  })
30
30
  } catch (error) {
package/src/useMatch.tsx CHANGED
@@ -85,7 +85,7 @@ export function useMatch<
85
85
  (opts.from ?? nearestRouteId)
86
86
  ? router.stores.getMatchStoreByRouteId(opts.from ?? nearestRouteId!)
87
87
  : undefined
88
- const match = matchStore?.state
88
+ const match = matchStore?.get()
89
89
 
90
90
  if ((opts.shouldThrow ?? true) && !match) {
91
91
  if (process.env.NODE_ENV !== 'production') {
@@ -42,7 +42,7 @@ export function useRouterState<
42
42
  const _isServer = isServer ?? router.isServer
43
43
 
44
44
  if (_isServer) {
45
- const state = router.stores.__store.state as RouterState<
45
+ const state = router.stores.__store.get() as RouterState<
46
46
  TRouter['routeTree']
47
47
  >
48
48
  return Vue.ref(opts?.select ? opts.select(state) : state) as Vue.Ref<