@tanstack/solid-router 1.168.12 → 1.168.14
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/Match.cjs +7 -7
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +6 -6
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Scripts.cjs +1 -1
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/Transitioner.cjs +9 -9
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/headContentUtils.cjs +1 -1
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/link.cjs +1 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/not-found.cjs +2 -2
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/routerStores.cjs +8 -13
- package/dist/cjs/routerStores.cjs.map +1 -1
- package/dist/cjs/ssr/RouterClient.cjs +1 -1
- package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToString.cjs +1 -1
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.cjs +1 -1
- package/dist/cjs/useCanGoBack.cjs.map +1 -1
- package/dist/cjs/useLocation.cjs +2 -2
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs +2 -2
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useRouterState.cjs +3 -3
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/esm/Match.js +7 -7
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +6 -6
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/Scripts.js +1 -1
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/Transitioner.js +9 -9
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/headContentUtils.js +1 -1
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/link.js +1 -1
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/not-found.js +2 -2
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/routerStores.js +8 -13
- 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 +1 -1
- 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/useCanGoBack.js +1 -1
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLocation.js +2 -2
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +2 -2
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useRouterState.js +3 -3
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/source/Match.jsx +7 -7
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +6 -8
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/Scripts.jsx +1 -1
- package/dist/source/Scripts.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +9 -9
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/headContentUtils.jsx +1 -1
- package/dist/source/headContentUtils.jsx.map +1 -1
- package/dist/source/link.jsx +1 -1
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/not-found.jsx +2 -2
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/routerStores.js +6 -15
- 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 +1 -1
- 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/useCanGoBack.js +1 -1
- package/dist/source/useCanGoBack.js.map +1 -1
- package/dist/source/useLocation.jsx +2 -2
- package/dist/source/useLocation.jsx.map +1 -1
- package/dist/source/useMatch.jsx +3 -3
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useRouterState.jsx +3 -3
- package/dist/source/useRouterState.jsx.map +1 -1
- package/package.json +2 -2
- package/src/Match.tsx +8 -8
- package/src/Matches.tsx +6 -8
- package/src/Scripts.tsx +1 -3
- package/src/Transitioner.tsx +12 -18
- package/src/headContentUtils.tsx +1 -3
- package/src/link.tsx +1 -1
- package/src/not-found.tsx +2 -2
- package/src/routerStores.ts +6 -15
- package/src/ssr/RouterClient.tsx +1 -1
- package/src/ssr/renderRouterToStream.tsx +1 -1
- package/src/ssr/renderRouterToString.tsx +1 -1
- package/src/useCanGoBack.ts +1 -1
- package/src/useLocation.tsx +2 -2
- package/src/useMatch.tsx +3 -3
- package/src/useRouterState.tsx +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouterState.jsx","sourceRoot":"","sources":["../../src/useRouterState.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AACzD,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAkBvC,MAAM,UAAU,cAAc,CAI5B,IAAgD;IAEhD,MAAM,aAAa,GAAG,SAAS,CAAU;QACvC,IAAI,EAAE,IAAI,EAAE,MAAM,KAAK,SAAS;KACjC,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,aAAa,CAAA;IAE5C,gEAAgE;IAChE,sEAAsE;IACtE,yDAAyD;IACzD,MAAM,SAAS,GAAG,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAA;IAC7C,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"useRouterState.jsx","sourceRoot":"","sources":["../../src/useRouterState.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AACzD,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAkBvC,MAAM,UAAU,cAAc,CAI5B,IAAgD;IAEhD,MAAM,aAAa,GAAG,SAAS,CAAU;QACvC,IAAI,EAAE,IAAI,EAAE,MAAM,KAAK,SAAS;KACjC,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,aAAa,CAAA;IAE5C,gEAAgE;IAChE,sEAAsE;IACtE,yDAAyD;IACzD,MAAM,SAAS,GAAG,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAA;IAC7C,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAEtC,CAAA;QACD,MAAM,QAAQ,GAAG,CACf,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CACE,CAAA;QAC7C,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,CAErB,CAAA;IACH,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAExC,CAAA;IACH,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IAE1B,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,IAA2B,EAAE,EAAE;QACtD,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QAC/C,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,GAAG,CAAA;QAClC,OAAO,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACpC,CAAC,CAAuD,CAAA;AAC1D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-router",
|
|
3
|
-
"version": "1.168.
|
|
3
|
+
"version": "1.168.14",
|
|
4
4
|
"description": "Modern and scalable routing for Solid applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@solidjs/meta": "^0.29.4",
|
|
93
93
|
"isbot": "^5.1.22",
|
|
94
94
|
"@tanstack/history": "1.161.6",
|
|
95
|
-
"@tanstack/router-core": "1.168.
|
|
95
|
+
"@tanstack/router-core": "1.168.11"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@solidjs/testing-library": "^0.8.10",
|
package/src/Match.tsx
CHANGED
|
@@ -24,7 +24,7 @@ export const Match = (props: { matchId: string }) => {
|
|
|
24
24
|
const match = Solid.createMemo(() => {
|
|
25
25
|
const id = props.matchId
|
|
26
26
|
if (!id) return undefined
|
|
27
|
-
return router.stores.
|
|
27
|
+
return router.stores.matchStores.get(id)?.get()
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
const rawMatchState = Solid.createMemo(() => {
|
|
@@ -49,7 +49,7 @@ export const Match = (props: { matchId: string }) => {
|
|
|
49
49
|
const hasPendingMatch = Solid.createMemo(() => {
|
|
50
50
|
const currentRouteId = rawMatchState()?.routeId
|
|
51
51
|
return currentRouteId
|
|
52
|
-
? Boolean(router.stores.pendingRouteIds.
|
|
52
|
+
? Boolean(router.stores.pendingRouteIds.get()[currentRouteId])
|
|
53
53
|
: false
|
|
54
54
|
})
|
|
55
55
|
const nearestMatch = {
|
|
@@ -113,7 +113,7 @@ export const Match = (props: { matchId: string }) => {
|
|
|
113
113
|
>
|
|
114
114
|
<Dynamic
|
|
115
115
|
component={ResolvedCatchBoundary()}
|
|
116
|
-
getResetKey={() => router.stores.loadedAt.
|
|
116
|
+
getResetKey={() => router.stores.loadedAt.get()}
|
|
117
117
|
errorComponent={routeErrorComponent() || ErrorComponent}
|
|
118
118
|
onCatch={(error: Error) => {
|
|
119
119
|
// Forward not found errors (we don't want to show the error component for these)
|
|
@@ -202,15 +202,15 @@ function OnRendered() {
|
|
|
202
202
|
const router = useRouter()
|
|
203
203
|
|
|
204
204
|
const location = Solid.createMemo(
|
|
205
|
-
() => router.stores.resolvedLocation.
|
|
205
|
+
() => router.stores.resolvedLocation.get()?.state.__TSR_key,
|
|
206
206
|
)
|
|
207
207
|
Solid.createEffect(
|
|
208
208
|
Solid.on([location], () => {
|
|
209
209
|
router.emit({
|
|
210
210
|
type: 'onRendered',
|
|
211
211
|
...getLocationChangeInfo(
|
|
212
|
-
router.stores.location.
|
|
213
|
-
router.stores.resolvedLocation.
|
|
212
|
+
router.stores.location.get(),
|
|
213
|
+
router.stores.resolvedLocation.get(),
|
|
214
214
|
),
|
|
215
215
|
})
|
|
216
216
|
}),
|
|
@@ -459,14 +459,14 @@ export const Outlet = () => {
|
|
|
459
459
|
const childMatchId = Solid.createMemo(() => {
|
|
460
460
|
const currentRouteId = routeId()
|
|
461
461
|
return currentRouteId
|
|
462
|
-
? router.stores.childMatchIdByRouteId.
|
|
462
|
+
? router.stores.childMatchIdByRouteId.get()[currentRouteId]
|
|
463
463
|
: undefined
|
|
464
464
|
})
|
|
465
465
|
|
|
466
466
|
const childMatchStatus = Solid.createMemo(() => {
|
|
467
467
|
const id = childMatchId()
|
|
468
468
|
if (!id) return undefined
|
|
469
|
-
return router.stores.
|
|
469
|
+
return router.stores.matchStores.get(id)?.get().status
|
|
470
470
|
})
|
|
471
471
|
|
|
472
472
|
// Only show not-found if we're not in a redirected state
|
package/src/Matches.tsx
CHANGED
|
@@ -62,17 +62,15 @@ export function Matches() {
|
|
|
62
62
|
|
|
63
63
|
function MatchesInner() {
|
|
64
64
|
const router = useRouter()
|
|
65
|
-
const matchId = () => router.stores.
|
|
65
|
+
const matchId = () => router.stores.firstId.get()
|
|
66
66
|
const routeId = () => (matchId() ? rootRouteId : undefined)
|
|
67
67
|
const match = () =>
|
|
68
|
-
routeId()
|
|
69
|
-
? router.stores.getMatchStoreByRouteId(rootRouteId).state
|
|
70
|
-
: undefined
|
|
68
|
+
routeId() ? router.stores.getRouteMatchStore(rootRouteId).get() : undefined
|
|
71
69
|
const hasPendingMatch = () =>
|
|
72
70
|
routeId()
|
|
73
|
-
? Boolean(router.stores.pendingRouteIds.
|
|
71
|
+
? Boolean(router.stores.pendingRouteIds.get()[rootRouteId])
|
|
74
72
|
: false
|
|
75
|
-
const resetKey = () => router.stores.loadedAt.
|
|
73
|
+
const resetKey = () => router.stores.loadedAt.get()
|
|
76
74
|
const nearestMatch = {
|
|
77
75
|
matchId,
|
|
78
76
|
routeId,
|
|
@@ -142,7 +140,7 @@ export function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {
|
|
|
142
140
|
return Solid.createMemo(() => {
|
|
143
141
|
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts
|
|
144
142
|
|
|
145
|
-
router.stores.
|
|
143
|
+
router.stores.matchRouteDeps.get()
|
|
146
144
|
return router.matchRoute(rest as any, {
|
|
147
145
|
pending,
|
|
148
146
|
caseSensitive,
|
|
@@ -211,7 +209,7 @@ export function useMatches<
|
|
|
211
209
|
): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {
|
|
212
210
|
const router = useRouter<TRouter>()
|
|
213
211
|
return Solid.createMemo((prev: TSelected | undefined) => {
|
|
214
|
-
const matches = router.stores.
|
|
212
|
+
const matches = router.stores.matches.get() as Array<
|
|
215
213
|
MakeRouteMatchUnion<TRouter>
|
|
216
214
|
>
|
|
217
215
|
const res = opts?.select ? opts.select(matches) : matches
|
package/src/Scripts.tsx
CHANGED
|
@@ -6,9 +6,7 @@ import type { RouterManagedTag } from '@tanstack/router-core'
|
|
|
6
6
|
export const Scripts = () => {
|
|
7
7
|
const router = useRouter()
|
|
8
8
|
const nonce = router.options.ssr?.nonce
|
|
9
|
-
const activeMatches = Solid.createMemo(
|
|
10
|
-
() => router.stores.activeMatchesSnapshot.state,
|
|
11
|
-
)
|
|
9
|
+
const activeMatches = Solid.createMemo(() => router.stores.matches.get())
|
|
12
10
|
const assetScripts = Solid.createMemo(() => {
|
|
13
11
|
const assetScripts: Array<RouterManagedTag> = []
|
|
14
12
|
const manifest = router.ssr?.manifest
|
package/src/Transitioner.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import { useRouter } from './useRouter'
|
|
|
10
10
|
export function Transitioner() {
|
|
11
11
|
const router = useRouter()
|
|
12
12
|
let mountLoadForRouter = { router, mounted: false }
|
|
13
|
-
const isLoading = Solid.createMemo(() => router.stores.isLoading.
|
|
13
|
+
const isLoading = Solid.createMemo(() => router.stores.isLoading.get())
|
|
14
14
|
|
|
15
15
|
if (isServer ?? router.isServer) {
|
|
16
16
|
return null
|
|
@@ -19,17 +19,13 @@ export function Transitioner() {
|
|
|
19
19
|
const [isSolidTransitioning, startSolidTransition] = Solid.useTransition()
|
|
20
20
|
|
|
21
21
|
// Track pending state changes
|
|
22
|
-
const
|
|
23
|
-
() => router.stores.hasPendingMatches.state,
|
|
24
|
-
)
|
|
22
|
+
const hasPending = Solid.createMemo(() => router.stores.hasPending.get())
|
|
25
23
|
|
|
26
24
|
const isAnyPending = Solid.createMemo(
|
|
27
|
-
() => isLoading() || isSolidTransitioning() ||
|
|
25
|
+
() => isLoading() || isSolidTransitioning() || hasPending(),
|
|
28
26
|
)
|
|
29
27
|
|
|
30
|
-
const isPagePending = Solid.createMemo(
|
|
31
|
-
() => isLoading() || hasPendingMatches(),
|
|
32
|
-
)
|
|
28
|
+
const isPagePending = Solid.createMemo(() => isLoading() || hasPending())
|
|
33
29
|
|
|
34
30
|
router.startTransition = (fn: () => void | Promise<void>) => {
|
|
35
31
|
Solid.startTransition(() => {
|
|
@@ -95,8 +91,8 @@ export function Transitioner() {
|
|
|
95
91
|
router.emit({
|
|
96
92
|
type: 'onLoad',
|
|
97
93
|
...getLocationChangeInfo(
|
|
98
|
-
router.stores.location.
|
|
99
|
-
router.stores.resolvedLocation.
|
|
94
|
+
router.stores.location.get(),
|
|
95
|
+
router.stores.resolvedLocation.get(),
|
|
100
96
|
),
|
|
101
97
|
})
|
|
102
98
|
}
|
|
@@ -111,8 +107,8 @@ export function Transitioner() {
|
|
|
111
107
|
router.emit({
|
|
112
108
|
type: 'onBeforeRouteMount',
|
|
113
109
|
...getLocationChangeInfo(
|
|
114
|
-
router.stores.location.
|
|
115
|
-
router.stores.resolvedLocation.
|
|
110
|
+
router.stores.location.get(),
|
|
111
|
+
router.stores.resolvedLocation.get(),
|
|
116
112
|
),
|
|
117
113
|
})
|
|
118
114
|
}
|
|
@@ -125,8 +121,8 @@ export function Transitioner() {
|
|
|
125
121
|
|
|
126
122
|
if (previousIsAnyPending && !currentIsAnyPending) {
|
|
127
123
|
const changeInfo = getLocationChangeInfo(
|
|
128
|
-
router.stores.location.
|
|
129
|
-
router.stores.resolvedLocation.
|
|
124
|
+
router.stores.location.get(),
|
|
125
|
+
router.stores.resolvedLocation.get(),
|
|
130
126
|
)
|
|
131
127
|
router.emit({
|
|
132
128
|
type: 'onResolved',
|
|
@@ -134,10 +130,8 @@ export function Transitioner() {
|
|
|
134
130
|
})
|
|
135
131
|
|
|
136
132
|
Solid.batch(() => {
|
|
137
|
-
router.stores.status.
|
|
138
|
-
router.stores.resolvedLocation.
|
|
139
|
-
() => router.stores.location.state,
|
|
140
|
-
)
|
|
133
|
+
router.stores.status.set('idle')
|
|
134
|
+
router.stores.resolvedLocation.set(router.stores.location.get())
|
|
141
135
|
})
|
|
142
136
|
|
|
143
137
|
if (changeInfo.hrefChanged) {
|
package/src/headContentUtils.tsx
CHANGED
|
@@ -18,9 +18,7 @@ import type {
|
|
|
18
18
|
export const useTags = (assetCrossOrigin?: AssetCrossOriginConfig) => {
|
|
19
19
|
const router = useRouter()
|
|
20
20
|
const nonce = router.options.ssr?.nonce
|
|
21
|
-
const activeMatches = Solid.createMemo(
|
|
22
|
-
() => router.stores.activeMatchesSnapshot.state,
|
|
23
|
-
)
|
|
21
|
+
const activeMatches = Solid.createMemo(() => router.stores.matches.get())
|
|
24
22
|
const routeMeta = Solid.createMemo(() =>
|
|
25
23
|
activeMatches()
|
|
26
24
|
.map((match) => match.meta!)
|
package/src/link.tsx
CHANGED
package/src/not-found.tsx
CHANGED
|
@@ -27,8 +27,8 @@ export function CatchNotFound(props: {
|
|
|
27
27
|
}) {
|
|
28
28
|
const router = useRouter()
|
|
29
29
|
// TODO: Some way for the user to programmatically reset the not-found boundary?
|
|
30
|
-
const pathname = Solid.createMemo(() => router.stores.location.
|
|
31
|
-
const status = Solid.createMemo(() => router.stores.status.
|
|
30
|
+
const pathname = Solid.createMemo(() => router.stores.location.get().pathname)
|
|
31
|
+
const status = Solid.createMemo(() => router.stores.status.get())
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<CatchBoundary
|
package/src/routerStores.ts
CHANGED
|
@@ -28,10 +28,10 @@ function initRouterStores(
|
|
|
28
28
|
) => RouterReadableStore<TValue>,
|
|
29
29
|
) {
|
|
30
30
|
stores.childMatchIdByRouteId = createReadonlyStore(() => {
|
|
31
|
-
const ids = stores.matchesId.
|
|
31
|
+
const ids = stores.matchesId.get()
|
|
32
32
|
const obj: Record<string, string> = {}
|
|
33
33
|
for (let i = 0; i < ids.length - 1; i++) {
|
|
34
|
-
const parentStore = stores.
|
|
34
|
+
const parentStore = stores.matchStores.get(ids[i]!)
|
|
35
35
|
if (parentStore?.routeId) {
|
|
36
36
|
obj[parentStore.routeId] = ids[i + 1]!
|
|
37
37
|
}
|
|
@@ -40,10 +40,10 @@ function initRouterStores(
|
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
stores.pendingRouteIds = createReadonlyStore(() => {
|
|
43
|
-
const ids = stores.
|
|
43
|
+
const ids = stores.pendingIds.get()
|
|
44
44
|
const obj: Record<string, boolean> = {}
|
|
45
45
|
for (const id of ids) {
|
|
46
|
-
const store = stores.
|
|
46
|
+
const store = stores.pendingMatchStores.get(id)
|
|
47
47
|
if (store?.routeId) {
|
|
48
48
|
obj[store.routeId] = true
|
|
49
49
|
}
|
|
@@ -57,12 +57,7 @@ function createSolidMutableStore<TValue>(
|
|
|
57
57
|
): RouterWritableStore<TValue> {
|
|
58
58
|
const [signal, setSignal] = Solid.createSignal(initialValue)
|
|
59
59
|
|
|
60
|
-
return {
|
|
61
|
-
get state() {
|
|
62
|
-
return signal()
|
|
63
|
-
},
|
|
64
|
-
setState: setSignal,
|
|
65
|
-
}
|
|
60
|
+
return { get: signal, set: setSignal }
|
|
66
61
|
}
|
|
67
62
|
|
|
68
63
|
let finalizationRegistry: FinalizationRegistry<() => void> | null = null
|
|
@@ -78,11 +73,7 @@ function createSolidReadonlyStore<TValue>(
|
|
|
78
73
|
dispose = d
|
|
79
74
|
return Solid.createMemo(read)
|
|
80
75
|
})
|
|
81
|
-
const store = {
|
|
82
|
-
get state() {
|
|
83
|
-
return memo()
|
|
84
|
-
},
|
|
85
|
-
}
|
|
76
|
+
const store = { get: memo }
|
|
86
77
|
finalizationRegistry?.register(store, dispose)
|
|
87
78
|
return store
|
|
88
79
|
}
|
package/src/ssr/RouterClient.tsx
CHANGED
|
@@ -11,7 +11,7 @@ const Dummy = (props: { children?: JSXElement }) => <>{props.children}</>
|
|
|
11
11
|
|
|
12
12
|
export function RouterClient(props: { router: AnyRouter }) {
|
|
13
13
|
if (!hydrationPromise) {
|
|
14
|
-
if (!props.router.stores.matchesId.
|
|
14
|
+
if (!props.router.stores.matchesId.get().length) {
|
|
15
15
|
hydrationPromise = hydrate(props.router)
|
|
16
16
|
} else {
|
|
17
17
|
hydrationPromise = Promise.resolve()
|
|
@@ -52,7 +52,7 @@ export const renderRouterToStream = async ({
|
|
|
52
52
|
readable as unknown as ReadableStream,
|
|
53
53
|
)
|
|
54
54
|
return new Response(responseStream as any, {
|
|
55
|
-
status: router.stores.statusCode.
|
|
55
|
+
status: router.stores.statusCode.get(),
|
|
56
56
|
headers: responseHeaders,
|
|
57
57
|
})
|
|
58
58
|
}
|
|
@@ -32,7 +32,7 @@ export const renderRouterToString = ({
|
|
|
32
32
|
html = html.replace(`</body>`, () => `${injectedHtml}</body>`)
|
|
33
33
|
}
|
|
34
34
|
return new Response(`<!DOCTYPE html>${html}`, {
|
|
35
|
-
status: router.stores.statusCode.
|
|
35
|
+
status: router.stores.statusCode.get(),
|
|
36
36
|
headers: responseHeaders,
|
|
37
37
|
})
|
|
38
38
|
} catch (error) {
|
package/src/useCanGoBack.ts
CHANGED
package/src/useLocation.tsx
CHANGED
|
@@ -28,7 +28,7 @@ export function useLocation<
|
|
|
28
28
|
const router = useRouter<TRouter>()
|
|
29
29
|
|
|
30
30
|
if (!opts?.select) {
|
|
31
|
-
return (() => router.stores.location.
|
|
31
|
+
return (() => router.stores.location.get()) as Accessor<
|
|
32
32
|
UseLocationResult<TRouter, TSelected>
|
|
33
33
|
>
|
|
34
34
|
}
|
|
@@ -36,7 +36,7 @@ export function useLocation<
|
|
|
36
36
|
const select = opts.select
|
|
37
37
|
|
|
38
38
|
return Solid.createMemo((prev: TSelected | undefined) => {
|
|
39
|
-
const res = select(router.stores.location.
|
|
39
|
+
const res = select(router.stores.location.get())
|
|
40
40
|
if (prev === undefined) return res
|
|
41
41
|
return replaceEqualDeep(prev, res)
|
|
42
42
|
}) as Accessor<UseLocationResult<TRouter, TSelected>>
|
package/src/useMatch.tsx
CHANGED
|
@@ -76,7 +76,7 @@ export function useMatch<
|
|
|
76
76
|
|
|
77
77
|
const match = () => {
|
|
78
78
|
if (opts.from) {
|
|
79
|
-
return router.stores.
|
|
79
|
+
return router.stores.getRouteMatchStore(opts.from).get()
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
return nearestMatch?.match()
|
|
@@ -88,12 +88,12 @@ export function useMatch<
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
const hasPendingMatch = opts.from
|
|
91
|
-
? Boolean(router.stores.pendingRouteIds.
|
|
91
|
+
? Boolean(router.stores.pendingRouteIds.get()[opts.from!])
|
|
92
92
|
: (nearestMatch?.hasPending() ?? false)
|
|
93
93
|
|
|
94
94
|
if (
|
|
95
95
|
!hasPendingMatch &&
|
|
96
|
-
!router.stores.isTransitioning.
|
|
96
|
+
!router.stores.isTransitioning.get() &&
|
|
97
97
|
(opts.shouldThrow ?? true)
|
|
98
98
|
) {
|
|
99
99
|
if (process.env.NODE_ENV !== 'production') {
|
package/src/useRouterState.tsx
CHANGED
|
@@ -35,7 +35,7 @@ export function useRouterState<
|
|
|
35
35
|
// implementation does not provide subscribe() semantics.
|
|
36
36
|
const _isServer = isServer ?? router.isServer
|
|
37
37
|
if (_isServer) {
|
|
38
|
-
const state = router.stores.__store.
|
|
38
|
+
const state = router.stores.__store.get() as RouterState<
|
|
39
39
|
TRouter['routeTree']
|
|
40
40
|
>
|
|
41
41
|
const selected = (
|
|
@@ -47,7 +47,7 @@ export function useRouterState<
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (!opts?.select) {
|
|
50
|
-
return (() => router.stores.__store.
|
|
50
|
+
return (() => router.stores.__store.get()) as Accessor<
|
|
51
51
|
UseRouterStateResult<TRouter, TSelected>
|
|
52
52
|
>
|
|
53
53
|
}
|
|
@@ -55,7 +55,7 @@ export function useRouterState<
|
|
|
55
55
|
const select = opts.select
|
|
56
56
|
|
|
57
57
|
return Solid.createMemo((prev: TSelected | undefined) => {
|
|
58
|
-
const res = select(router.stores.__store.
|
|
58
|
+
const res = select(router.stores.__store.get())
|
|
59
59
|
if (prev === undefined) return res
|
|
60
60
|
return replaceEqualDeep(prev, res)
|
|
61
61
|
}) as Accessor<UseRouterStateResult<TRouter, TSelected>>
|