@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.
- package/dist/esm/Match.js +2 -2
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Transitioner.js +11 -11
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/link.js +1 -1
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/routerStores.js +7 -7
- package/dist/esm/routerStores.js.map +1 -1
- package/dist/esm/ssr/RouterClient.js +1 -1
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +2 -2
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +1 -1
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/useMatch.js +1 -1
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useRouterState.js +1 -1
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/source/Match.jsx +2 -2
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +11 -11
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/link.jsx +1 -1
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/routerStores.js +7 -7
- package/dist/source/routerStores.js.map +1 -1
- package/dist/source/ssr/RouterClient.jsx +1 -1
- package/dist/source/ssr/RouterClient.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToStream.jsx +2 -2
- package/dist/source/ssr/renderRouterToStream.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToString.jsx +1 -1
- package/dist/source/ssr/renderRouterToString.jsx.map +1 -1
- package/dist/source/useMatch.jsx +1 -1
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useRouterState.jsx +1 -1
- package/dist/source/useRouterState.jsx.map +1 -1
- package/package.json +2 -2
- package/src/Match.tsx +3 -3
- package/src/Transitioner.tsx +14 -18
- package/src/link.tsx +1 -1
- package/src/routerStores.ts +7 -7
- package/src/ssr/RouterClient.tsx +1 -1
- package/src/ssr/renderRouterToStream.tsx +2 -2
- package/src/ssr/renderRouterToString.tsx +1 -1
- package/src/useMatch.tsx +1 -1
- 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.
|
|
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.
|
|
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.
|
|
272
|
-
router.stores.resolvedLocation.
|
|
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)?.
|
|
528
|
+
const child = router.stores.activeMatchStoresById.get(childId)?.get()
|
|
529
529
|
if (!child) return null
|
|
530
530
|
|
|
531
531
|
return {
|
package/src/Transitioner.tsx
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
143
|
+
if (router.stores.status.get() === 'pending') {
|
|
144
144
|
batch(() => {
|
|
145
|
-
router.stores.status.
|
|
146
|
-
router.stores.resolvedLocation.
|
|
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.
|
|
192
|
-
router.stores.resolvedLocation.
|
|
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.
|
|
211
|
-
router.stores.resolvedLocation.
|
|
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.
|
|
221
|
+
if (!newValue && router.stores.status.get() === 'pending') {
|
|
224
222
|
batch(() => {
|
|
225
|
-
router.stores.status.
|
|
226
|
-
router.stores.resolvedLocation.
|
|
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.
|
|
236
|
-
router.stores.resolvedLocation.
|
|
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
package/src/routerStores.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { batch,
|
|
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:
|
|
22
|
-
createReadonlyStore:
|
|
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 =
|
|
30
|
-
const ids = stores.matchesId.
|
|
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 =
|
|
42
|
-
const ids = stores.pendingMatchesId.
|
|
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)
|
package/src/ssr/RouterClient.tsx
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
81
|
+
status: router.stores.statusCode.get(),
|
|
82
82
|
headers: responseHeaders,
|
|
83
83
|
})
|
|
84
84
|
}
|
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?.
|
|
88
|
+
const match = matchStore?.get()
|
|
89
89
|
|
|
90
90
|
if ((opts.shouldThrow ?? true) && !match) {
|
|
91
91
|
if (process.env.NODE_ENV !== 'production') {
|
package/src/useRouterState.tsx
CHANGED
|
@@ -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.
|
|
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<
|