@tanstack/react-router-devtools 0.0.1-beta.30 → 0.0.1-beta.39
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/build/cjs/Explorer.js +18 -16
- package/build/cjs/Explorer.js.map +1 -1
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -13
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/devtools.js +150 -117
- package/build/cjs/devtools.js.map +1 -1
- package/build/cjs/styledComponents.js +14 -14
- package/build/cjs/styledComponents.js.map +1 -1
- package/build/cjs/theme.js +3 -4
- package/build/cjs/theme.js.map +1 -1
- package/build/cjs/useLocalStorage.js +2 -2
- package/build/cjs/useLocalStorage.js.map +1 -1
- package/build/cjs/utils.js +17 -11
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +205 -176
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +2901 -2756
- package/build/umd/index.development.js +806 -180
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +23 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +3 -3
- package/src/devtools.tsx +39 -37
- package/src/utils.ts +3 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router-devtools",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.39",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router/",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
],
|
|
37
37
|
"sideEffects": false,
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@tanstack/react-router": "0.0.1-beta.30",
|
|
40
39
|
"react": ">=16",
|
|
41
40
|
"react-dom": ">=16"
|
|
42
41
|
},
|
|
43
42
|
"dependencies": {
|
|
44
43
|
"@babel/runtime": "^7.16.7",
|
|
45
|
-
"date-fns": "^2.29.1"
|
|
44
|
+
"date-fns": "^2.29.1",
|
|
45
|
+
"@tanstack/react-router": "workspace:^"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"babel-plugin-transform-async-to-promises": "^0.8.18"
|
package/src/devtools.tsx
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Router,
|
|
4
|
+
last,
|
|
5
|
+
routerContext,
|
|
6
|
+
invariant,
|
|
7
|
+
__useStoreValue,
|
|
8
|
+
useRouterStore,
|
|
9
|
+
} from '@tanstack/react-router'
|
|
3
10
|
import { formatDistanceStrict } from 'date-fns'
|
|
4
11
|
|
|
5
12
|
import useLocalStorage from './useLocalStorage'
|
|
@@ -418,19 +425,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
418
425
|
'No router was found for the TanStack Router Devtools. Please place the devtools in the <RouterProvider> component tree or pass the router instance to the devtools manually.',
|
|
419
426
|
)
|
|
420
427
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
React.useEffect(() => {
|
|
424
|
-
let interval = setInterval(() => {
|
|
425
|
-
router.cleanMatchCache()
|
|
426
|
-
// router.notify()
|
|
427
|
-
rerender()
|
|
428
|
-
}, 250)
|
|
429
|
-
|
|
430
|
-
return () => {
|
|
431
|
-
clearInterval(interval)
|
|
432
|
-
}
|
|
433
|
-
}, [])
|
|
428
|
+
useRouterStore()
|
|
434
429
|
|
|
435
430
|
const [activeRouteId, setActiveRouteId] = useLocalStorage(
|
|
436
431
|
'tanstackRouterDevtoolsActiveRouteId',
|
|
@@ -447,18 +442,22 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
447
442
|
}, [activeRouteId])
|
|
448
443
|
|
|
449
444
|
const activeMatch =
|
|
450
|
-
Object.values(router.matchCache)?.find(
|
|
445
|
+
Object.values(router.store.matchCache)?.find(
|
|
451
446
|
(d) => d.match.matchId === activeMatchId,
|
|
452
|
-
)?.match ??
|
|
447
|
+
)?.match ??
|
|
448
|
+
router.store.currentMatches?.find((d) => d.routeId === activeRouteId)
|
|
453
449
|
|
|
454
450
|
const matchCacheValues = multiSortBy(
|
|
455
|
-
Object.keys(router.matchCache)
|
|
451
|
+
Object.keys(router.store.matchCache)
|
|
456
452
|
.filter((key) => {
|
|
457
|
-
const cacheEntry = router.matchCache[key]!
|
|
453
|
+
const cacheEntry = router.store.matchCache[key]!
|
|
458
454
|
return cacheEntry.gc > Date.now()
|
|
459
455
|
})
|
|
460
|
-
.map((key) => router.matchCache[key]!),
|
|
461
|
-
[
|
|
456
|
+
.map((key) => router.store.matchCache[key]!),
|
|
457
|
+
[
|
|
458
|
+
(d) => (d.match.store.isFetching ? -1 : 1),
|
|
459
|
+
(d) => -d.match.store.updatedAt!,
|
|
460
|
+
],
|
|
462
461
|
)
|
|
463
462
|
|
|
464
463
|
return (
|
|
@@ -598,7 +597,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
598
597
|
>
|
|
599
598
|
Active Matches
|
|
600
599
|
</div>
|
|
601
|
-
{router.
|
|
600
|
+
{router.store.currentMatches.map((match, i) => {
|
|
602
601
|
return (
|
|
603
602
|
<div
|
|
604
603
|
key={match.routeId || i}
|
|
@@ -643,7 +642,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
643
642
|
</div>
|
|
644
643
|
)
|
|
645
644
|
})}
|
|
646
|
-
{router.
|
|
645
|
+
{router.store.pendingMatches?.length ? (
|
|
647
646
|
<>
|
|
648
647
|
<div
|
|
649
648
|
style={{
|
|
@@ -657,7 +656,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
657
656
|
>
|
|
658
657
|
Pending Matches
|
|
659
658
|
</div>
|
|
660
|
-
{router.
|
|
659
|
+
{router.store.pendingMatches?.map((match, i) => {
|
|
661
660
|
return (
|
|
662
661
|
<div
|
|
663
662
|
key={match.routeId || i}
|
|
@@ -724,8 +723,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
724
723
|
<div>Match Cache</div>
|
|
725
724
|
<Button
|
|
726
725
|
onClick={() => {
|
|
727
|
-
router.matchCache = {}
|
|
728
|
-
router.notify()
|
|
726
|
+
router.setStore((s) => (s.matchCache = {}))
|
|
729
727
|
}}
|
|
730
728
|
>
|
|
731
729
|
Clear
|
|
@@ -835,18 +833,18 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
835
833
|
</tr>
|
|
836
834
|
<tr>
|
|
837
835
|
<td style={{ opacity: '.5' }}>Status</td>
|
|
838
|
-
<td>{activeMatch.status}</td>
|
|
836
|
+
<td>{activeMatch.store.status}</td>
|
|
839
837
|
</tr>
|
|
840
838
|
<tr>
|
|
841
839
|
<td style={{ opacity: '.5' }}>Invalid</td>
|
|
842
|
-
<td>{activeMatch.isInvalid.toString()}</td>
|
|
840
|
+
<td>{activeMatch.store.isInvalid.toString()}</td>
|
|
843
841
|
</tr>
|
|
844
842
|
<tr>
|
|
845
843
|
<td style={{ opacity: '.5' }}>Last Updated</td>
|
|
846
844
|
<td>
|
|
847
|
-
{activeMatch.updatedAt
|
|
845
|
+
{activeMatch.store.updatedAt
|
|
848
846
|
? new Date(
|
|
849
|
-
activeMatch.updatedAt as number,
|
|
847
|
+
activeMatch.store.updatedAt as number,
|
|
850
848
|
).toLocaleTimeString()
|
|
851
849
|
: 'N/A'}
|
|
852
850
|
</td>
|
|
@@ -875,7 +873,6 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
875
873
|
type="button"
|
|
876
874
|
onClick={() => {
|
|
877
875
|
activeMatch.invalidate()
|
|
878
|
-
router.notify()
|
|
879
876
|
}}
|
|
880
877
|
style={{
|
|
881
878
|
background: theme.warning,
|
|
@@ -947,12 +944,16 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
947
944
|
padding: '.5em',
|
|
948
945
|
}}
|
|
949
946
|
>
|
|
950
|
-
{Object.keys(
|
|
951
|
-
.
|
|
947
|
+
{Object.keys(
|
|
948
|
+
last(router.store.currentMatches)?.store.loaderData || {},
|
|
949
|
+
).length ? (
|
|
952
950
|
<Explorer
|
|
953
|
-
value={
|
|
951
|
+
value={
|
|
952
|
+
last(router.store.currentMatches)?.store.loaderData || {}
|
|
953
|
+
}
|
|
954
954
|
defaultExpanded={Object.keys(
|
|
955
|
-
(last(router.
|
|
955
|
+
(last(router.store.currentMatches)?.store.loaderData as {}) ||
|
|
956
|
+
{},
|
|
956
957
|
).reduce((obj: any, next) => {
|
|
957
958
|
obj[next] = {}
|
|
958
959
|
return obj
|
|
@@ -979,11 +980,12 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
979
980
|
padding: '.5em',
|
|
980
981
|
}}
|
|
981
982
|
>
|
|
982
|
-
{Object.keys(last(router.
|
|
983
|
+
{Object.keys(last(router.store.currentMatches)?.store.search || {})
|
|
984
|
+
.length ? (
|
|
983
985
|
<Explorer
|
|
984
|
-
value={last(router.
|
|
986
|
+
value={last(router.store.currentMatches)?.store.search || {}}
|
|
985
987
|
defaultExpanded={Object.keys(
|
|
986
|
-
(last(router.
|
|
988
|
+
(last(router.store.currentMatches)?.store.search as {}) || {},
|
|
987
989
|
).reduce((obj: any, next) => {
|
|
988
990
|
obj[next] = {}
|
|
989
991
|
return obj
|
package/src/utils.ts
CHANGED
|
@@ -26,11 +26,11 @@ type StyledComponent<T> = T extends 'button'
|
|
|
26
26
|
: never
|
|
27
27
|
|
|
28
28
|
export function getStatusColor(match: RouteMatch, theme: Theme) {
|
|
29
|
-
return match.isFetching
|
|
29
|
+
return match.store.isFetching
|
|
30
30
|
? theme.active
|
|
31
|
-
: match.status === 'error'
|
|
31
|
+
: match.store.status === 'error'
|
|
32
32
|
? theme.danger
|
|
33
|
-
: match.status === 'success'
|
|
33
|
+
: match.store.status === 'success'
|
|
34
34
|
? theme.success
|
|
35
35
|
: theme.gray
|
|
36
36
|
}
|