@tanstack/react-router-devtools 0.0.1-beta.45 → 0.0.1-beta.55
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 +35 -43
- package/build/cjs/Explorer.js.map +1 -1
- package/build/cjs/devtools.js +49 -147
- package/build/cjs/devtools.js.map +1 -1
- package/build/cjs/styledComponents.js +0 -32
- package/build/cjs/styledComponents.js.map +1 -1
- package/build/cjs/theme.js +4 -5
- package/build/cjs/theme.js.map +1 -1
- package/build/cjs/useMediaQuery.js +3 -6
- package/build/cjs/useMediaQuery.js.map +1 -1
- package/build/cjs/utils.js +7 -51
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +98 -283
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +251 -9572
- package/build/umd/index.development.js +148 -1652
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +15 -5
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -5
- package/src/devtools.tsx +64 -64
- package/src/utils.ts +3 -13
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.55",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router/",
|
|
@@ -42,9 +42,6 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@babel/runtime": "^7.16.7",
|
|
44
44
|
"date-fns": "^2.29.1",
|
|
45
|
-
"@tanstack/react-router": "0.0.1-beta.
|
|
46
|
-
},
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"babel-plugin-transform-async-to-promises": "^0.8.18"
|
|
45
|
+
"@tanstack/react-router": "0.0.1-beta.55"
|
|
49
46
|
}
|
|
50
47
|
}
|
package/src/devtools.tsx
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
last,
|
|
5
5
|
routerContext,
|
|
6
6
|
invariant,
|
|
7
|
-
__useStoreValue,
|
|
8
7
|
useRouterStore,
|
|
9
8
|
} from '@tanstack/react-router'
|
|
10
9
|
import { formatDistanceStrict } from 'date-fns'
|
|
@@ -441,25 +440,31 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
441
440
|
setActiveMatchId('')
|
|
442
441
|
}, [activeRouteId])
|
|
443
442
|
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
(
|
|
447
|
-
|
|
448
|
-
router.store.currentMatches?.find((d) => d.routeId === activeRouteId)
|
|
449
|
-
|
|
450
|
-
const matchCacheValues = multiSortBy(
|
|
451
|
-
Object.keys(router.store.matchCache)
|
|
452
|
-
.filter((key) => {
|
|
453
|
-
const cacheEntry = router.store.matchCache[key]!
|
|
454
|
-
return cacheEntry.gc > Date.now()
|
|
455
|
-
})
|
|
456
|
-
.map((key) => router.store.matchCache[key]!),
|
|
457
|
-
[
|
|
458
|
-
(d) => (d.match.store.isFetching ? -1 : 1),
|
|
459
|
-
(d) => -d.match.store.updatedAt!,
|
|
443
|
+
const allMatches = React.useMemo(
|
|
444
|
+
() => [
|
|
445
|
+
...Object.values(router.store.state.currentMatches),
|
|
446
|
+
...Object.values(router.store.state.pendingMatches ?? []),
|
|
460
447
|
],
|
|
448
|
+
[router.store.state.currentMatches, router.store.state.pendingMatches],
|
|
461
449
|
)
|
|
462
450
|
|
|
451
|
+
const activeMatch =
|
|
452
|
+
allMatches?.find((d) => d.id === activeMatchId) ||
|
|
453
|
+
allMatches?.find((d) => d.route.id === activeRouteId)
|
|
454
|
+
|
|
455
|
+
// const matchCacheValues = multiSortBy(
|
|
456
|
+
// Object.keys(router.store.state.matchCache)
|
|
457
|
+
// .filter((key) => {
|
|
458
|
+
// const cacheEntry = router.store.state.matchCache[key]!
|
|
459
|
+
// return cacheEntry.gc > Date.now()
|
|
460
|
+
// })
|
|
461
|
+
// .map((key) => router.store.state.matchCache[key]!),
|
|
462
|
+
// [
|
|
463
|
+
// (d) => (d.match.store.state.isFetching ? -1 : 1),
|
|
464
|
+
// (d) => -d.match.store.state.updatedAt!,
|
|
465
|
+
// ],
|
|
466
|
+
// )
|
|
467
|
+
|
|
463
468
|
return (
|
|
464
469
|
<ThemeProvider theme={theme}>
|
|
465
470
|
<Panel ref={ref} className="TanStackRouterDevtoolsPanel" {...panelProps}>
|
|
@@ -597,15 +602,15 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
597
602
|
>
|
|
598
603
|
Active Matches
|
|
599
604
|
</div>
|
|
600
|
-
{router.store.currentMatches.map((match, i) => {
|
|
605
|
+
{router.store.state.currentMatches.map((match, i) => {
|
|
601
606
|
return (
|
|
602
607
|
<div
|
|
603
|
-
key={match.
|
|
608
|
+
key={match.route.id || i}
|
|
604
609
|
role="button"
|
|
605
|
-
aria-label={`Open match details for ${match.
|
|
610
|
+
aria-label={`Open match details for ${match.route.id}`}
|
|
606
611
|
onClick={() =>
|
|
607
612
|
setActiveRouteId(
|
|
608
|
-
activeRouteId === match.
|
|
613
|
+
activeRouteId === match.route.id ? '' : match.route.id,
|
|
609
614
|
)
|
|
610
615
|
}
|
|
611
616
|
style={{
|
|
@@ -637,12 +642,12 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
637
642
|
padding: '.5em',
|
|
638
643
|
}}
|
|
639
644
|
>
|
|
640
|
-
{`${match.
|
|
645
|
+
{`${match.id}`}
|
|
641
646
|
</Code>
|
|
642
647
|
</div>
|
|
643
648
|
)
|
|
644
649
|
})}
|
|
645
|
-
{router.store.pendingMatches?.length ? (
|
|
650
|
+
{router.store.state.pendingMatches?.length ? (
|
|
646
651
|
<>
|
|
647
652
|
<div
|
|
648
653
|
style={{
|
|
@@ -656,15 +661,15 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
656
661
|
>
|
|
657
662
|
Pending Matches
|
|
658
663
|
</div>
|
|
659
|
-
{router.store.pendingMatches?.map((match, i) => {
|
|
664
|
+
{router.store.state.pendingMatches?.map((match, i) => {
|
|
660
665
|
return (
|
|
661
666
|
<div
|
|
662
|
-
key={match.
|
|
667
|
+
key={match.route.id || i}
|
|
663
668
|
role="button"
|
|
664
|
-
aria-label={`Open match details for ${match.
|
|
669
|
+
aria-label={`Open match details for ${match.route.id}`}
|
|
665
670
|
onClick={() =>
|
|
666
671
|
setActiveRouteId(
|
|
667
|
-
activeRouteId === match.
|
|
672
|
+
activeRouteId === match.route.id ? '' : match.route.id,
|
|
668
673
|
)
|
|
669
674
|
}
|
|
670
675
|
style={{
|
|
@@ -697,14 +702,14 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
697
702
|
padding: '.5em',
|
|
698
703
|
}}
|
|
699
704
|
>
|
|
700
|
-
{`${match.
|
|
705
|
+
{`${match.id}`}
|
|
701
706
|
</Code>
|
|
702
707
|
</div>
|
|
703
708
|
)
|
|
704
709
|
})}
|
|
705
710
|
</>
|
|
706
711
|
) : null}
|
|
707
|
-
{matchCacheValues.length ? (
|
|
712
|
+
{/* {matchCacheValues.length ? (
|
|
708
713
|
<>
|
|
709
714
|
<div
|
|
710
715
|
style={{
|
|
@@ -723,7 +728,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
723
728
|
<div>Match Cache</div>
|
|
724
729
|
<Button
|
|
725
730
|
onClick={() => {
|
|
726
|
-
router.
|
|
731
|
+
router.store.setState((s) => (s.matchCache = {}))
|
|
727
732
|
}}
|
|
728
733
|
>
|
|
729
734
|
Clear
|
|
@@ -734,12 +739,12 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
734
739
|
|
|
735
740
|
return (
|
|
736
741
|
<div
|
|
737
|
-
key={match.
|
|
742
|
+
key={match.id || i}
|
|
738
743
|
role="button"
|
|
739
|
-
aria-label={`Open match details for ${match.
|
|
744
|
+
aria-label={`Open match details for ${match.id}`}
|
|
740
745
|
onClick={() =>
|
|
741
746
|
setActiveMatchId(
|
|
742
|
-
activeMatchId === match.
|
|
747
|
+
activeMatchId === match.id ? '' : match.id,
|
|
743
748
|
)
|
|
744
749
|
}
|
|
745
750
|
style={{
|
|
@@ -780,7 +785,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
780
785
|
transition: 'all .2s ease-out',
|
|
781
786
|
}}
|
|
782
787
|
/>
|
|
783
|
-
<Code>{`${match.
|
|
788
|
+
<Code>{`${match.id}`}</Code>
|
|
784
789
|
</div>
|
|
785
790
|
<span
|
|
786
791
|
style={{
|
|
@@ -799,7 +804,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
799
804
|
)
|
|
800
805
|
})}
|
|
801
806
|
</>
|
|
802
|
-
) : null}
|
|
807
|
+
) : null} */}
|
|
803
808
|
</div>
|
|
804
809
|
|
|
805
810
|
{activeMatch ? (
|
|
@@ -827,24 +832,24 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
827
832
|
lineHeight: '1.8em',
|
|
828
833
|
}}
|
|
829
834
|
>
|
|
830
|
-
{JSON.stringify(activeMatch.
|
|
835
|
+
{JSON.stringify(activeMatch.id, null, 2)}
|
|
831
836
|
</Code>
|
|
832
837
|
</td>
|
|
833
838
|
</tr>
|
|
834
839
|
<tr>
|
|
835
840
|
<td style={{ opacity: '.5' }}>Status</td>
|
|
836
|
-
<td>{activeMatch.store.status}</td>
|
|
841
|
+
<td>{activeMatch.store.state.status}</td>
|
|
837
842
|
</tr>
|
|
838
|
-
<tr>
|
|
843
|
+
{/* <tr>
|
|
839
844
|
<td style={{ opacity: '.5' }}>Invalid</td>
|
|
840
|
-
<td>{activeMatch.
|
|
841
|
-
</tr>
|
|
845
|
+
<td>{activeMatch.getIsInvalid().toString()}</td>
|
|
846
|
+
</tr> */}
|
|
842
847
|
<tr>
|
|
843
848
|
<td style={{ opacity: '.5' }}>Last Updated</td>
|
|
844
849
|
<td>
|
|
845
|
-
{activeMatch.store.updatedAt
|
|
850
|
+
{activeMatch.store.state.updatedAt
|
|
846
851
|
? new Date(
|
|
847
|
-
activeMatch.store.updatedAt as number,
|
|
852
|
+
activeMatch.store.state.updatedAt as number,
|
|
848
853
|
).toLocaleTimeString()
|
|
849
854
|
: 'N/A'}
|
|
850
855
|
</td>
|
|
@@ -869,18 +874,6 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
869
874
|
padding: '0.5em',
|
|
870
875
|
}}
|
|
871
876
|
>
|
|
872
|
-
<Button
|
|
873
|
-
type="button"
|
|
874
|
-
onClick={() => {
|
|
875
|
-
activeMatch.invalidate()
|
|
876
|
-
}}
|
|
877
|
-
style={{
|
|
878
|
-
background: theme.warning,
|
|
879
|
-
color: theme.inputTextColor,
|
|
880
|
-
}}
|
|
881
|
-
>
|
|
882
|
-
Invalidate
|
|
883
|
-
</Button>{' '}
|
|
884
877
|
<Button
|
|
885
878
|
type="button"
|
|
886
879
|
onClick={() => activeMatch.load()}
|
|
@@ -927,7 +920,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
927
920
|
flexDirection: 'column',
|
|
928
921
|
}}
|
|
929
922
|
>
|
|
930
|
-
<div
|
|
923
|
+
{/* <div
|
|
931
924
|
style={{
|
|
932
925
|
padding: '.5em',
|
|
933
926
|
background: theme.backgroundAlt,
|
|
@@ -945,15 +938,17 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
945
938
|
}}
|
|
946
939
|
>
|
|
947
940
|
{Object.keys(
|
|
948
|
-
last(router.store.currentMatches)?.store.loaderData ||
|
|
941
|
+
last(router.store.state.currentMatches)?.store.state.loaderData ||
|
|
942
|
+
{},
|
|
949
943
|
).length ? (
|
|
950
944
|
<Explorer
|
|
951
945
|
value={
|
|
952
|
-
last(router.store.currentMatches)?.store.
|
|
946
|
+
last(router.store.state.currentMatches)?.store.state
|
|
947
|
+
.loaderData || {}
|
|
953
948
|
}
|
|
954
949
|
defaultExpanded={Object.keys(
|
|
955
|
-
(last(router.store.currentMatches)?.store.
|
|
956
|
-
{},
|
|
950
|
+
(last(router.store.state.currentMatches)?.store.state
|
|
951
|
+
.loaderData as {}) || {},
|
|
957
952
|
).reduce((obj: any, next) => {
|
|
958
953
|
obj[next] = {}
|
|
959
954
|
return obj
|
|
@@ -962,7 +957,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
962
957
|
) : (
|
|
963
958
|
<em style={{ opacity: 0.5 }}>{'{ }'}</em>
|
|
964
959
|
)}
|
|
965
|
-
</div>
|
|
960
|
+
</div> */}
|
|
966
961
|
<div
|
|
967
962
|
style={{
|
|
968
963
|
padding: '.5em',
|
|
@@ -980,12 +975,17 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
980
975
|
padding: '.5em',
|
|
981
976
|
}}
|
|
982
977
|
>
|
|
983
|
-
{Object.keys(
|
|
984
|
-
.
|
|
978
|
+
{Object.keys(
|
|
979
|
+
last(router.store.state.currentMatches)?.store.state.search || {},
|
|
980
|
+
).length ? (
|
|
985
981
|
<Explorer
|
|
986
|
-
value={
|
|
982
|
+
value={
|
|
983
|
+
last(router.store.state.currentMatches)?.store.state.search ||
|
|
984
|
+
{}
|
|
985
|
+
}
|
|
987
986
|
defaultExpanded={Object.keys(
|
|
988
|
-
(last(router.store.currentMatches)?.store.
|
|
987
|
+
(last(router.store.state.currentMatches)?.store.state
|
|
988
|
+
.search as {}) || {},
|
|
989
989
|
).reduce((obj: any, next) => {
|
|
990
990
|
obj[next] = {}
|
|
991
991
|
return obj
|
package/src/utils.ts
CHANGED
|
@@ -26,25 +26,15 @@ type StyledComponent<T> = T extends 'button'
|
|
|
26
26
|
: never
|
|
27
27
|
|
|
28
28
|
export function getStatusColor(match: RouteMatch, theme: Theme) {
|
|
29
|
-
return match.store.
|
|
29
|
+
return match.store.state.status === 'pending'
|
|
30
30
|
? theme.active
|
|
31
|
-
: match.store.status === 'error'
|
|
31
|
+
: match.store.state.status === 'error'
|
|
32
32
|
? theme.danger
|
|
33
|
-
: match.store.status === 'success'
|
|
33
|
+
: match.store.state.status === 'success'
|
|
34
34
|
? theme.success
|
|
35
35
|
: theme.gray
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// export function getQueryStatusLabel(query: Query) {
|
|
39
|
-
// return query.state.isFetching
|
|
40
|
-
// ? 'fetching'
|
|
41
|
-
// : !query.getObserversCount()
|
|
42
|
-
// ? 'inactive'
|
|
43
|
-
// : query.isStale()
|
|
44
|
-
// ? 'stale'
|
|
45
|
-
// : 'fresh'
|
|
46
|
-
// }
|
|
47
|
-
|
|
48
38
|
type Styles =
|
|
49
39
|
| React.CSSProperties
|
|
50
40
|
| ((props: Record<string, any>, theme: Theme) => React.CSSProperties)
|