@tanstack/react-router-devtools 0.0.1-beta.49 → 0.0.1-beta.56

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.
@@ -11,7 +11,6 @@
11
11
  import * as React from 'react';
12
12
  import React__default from 'react';
13
13
  import { routerContext, invariant, useRouterStore, last } from '@tanstack/react-router';
14
- import { formatDistanceStrict } from 'date-fns';
15
14
 
16
15
  function _extends() {
17
16
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -128,19 +127,8 @@ function useMediaQuery(query) {
128
127
 
129
128
  const isServer$1 = typeof window === 'undefined';
130
129
  function getStatusColor(match, theme) {
131
- return match.store.state.isFetching ? theme.active : match.store.state.status === 'error' ? theme.danger : match.store.state.status === 'success' ? theme.success : theme.gray;
130
+ return match.store.state.status === 'pending' ? theme.active : match.store.state.status === 'error' ? theme.danger : match.store.state.status === 'success' ? theme.success : theme.gray;
132
131
  }
133
-
134
- // export function getQueryStatusLabel(query: Query) {
135
- // return query.state.isFetching
136
- // ? 'fetching'
137
- // : !query.getObserversCount()
138
- // ? 'inactive'
139
- // : query.isStale()
140
- // ? 'stale'
141
- // : 'fresh'
142
- // }
143
-
144
132
  function styled(type, newStyles, queries = {}) {
145
133
  return /*#__PURE__*/React__default.forwardRef(({
146
134
  style,
@@ -214,25 +202,6 @@ function scheduleMicrotask(callback) {
214
202
  throw error;
215
203
  }));
216
204
  }
217
- function multiSortBy(arr, accessors = [d => d]) {
218
- return arr.map((d, i) => [d, i]).sort(([a, ai], [b, bi]) => {
219
- for (const accessor of accessors) {
220
- const ao = accessor(a);
221
- const bo = accessor(b);
222
- if (typeof ao === 'undefined') {
223
- if (typeof bo === 'undefined') {
224
- continue;
225
- }
226
- return 1;
227
- }
228
- if (ao === bo) {
229
- continue;
230
- }
231
- return ao > bo ? 1 : -1;
232
- }
233
- return ai - bi;
234
- }).map(([d]) => d);
235
- }
236
205
 
237
206
  const Panel = styled('div', (_props, theme) => ({
238
207
  fontSize: 'clamp(12px, 1.5vw, 14px)',
@@ -718,11 +687,22 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
718
687
  React__default.useEffect(() => {
719
688
  setActiveMatchId('');
720
689
  }, [activeRouteId]);
721
- const activeMatch = Object.values(router.store.state.matchCache)?.find(d => d.match.id === activeMatchId)?.match ?? router.store.state.currentMatches?.find(d => d.route.id === activeRouteId);
722
- const matchCacheValues = multiSortBy(Object.keys(router.store.state.matchCache).filter(key => {
723
- const cacheEntry = router.store.state.matchCache[key];
724
- return cacheEntry.gc > Date.now();
725
- }).map(key => router.store.state.matchCache[key]), [d => d.match.store.state.isFetching ? -1 : 1, d => -d.match.store.state.updatedAt]);
690
+ const allMatches = React__default.useMemo(() => [...Object.values(router.store.state.currentMatches), ...Object.values(router.store.state.pendingMatches ?? [])], [router.store.state.currentMatches, router.store.state.pendingMatches]);
691
+ const activeMatch = allMatches?.find(d => d.id === activeMatchId) || allMatches?.find(d => d.route.id === activeRouteId);
692
+
693
+ // const matchCacheValues = multiSortBy(
694
+ // Object.keys(router.store.state.matchCache)
695
+ // .filter((key) => {
696
+ // const cacheEntry = router.store.state.matchCache[key]!
697
+ // return cacheEntry.gc > Date.now()
698
+ // })
699
+ // .map((key) => router.store.state.matchCache[key]!),
700
+ // [
701
+ // (d) => (d.match.store.state.isFetching ? -1 : 1),
702
+ // (d) => -d.match.store.state.updatedAt!,
703
+ // ],
704
+ // )
705
+
726
706
  return /*#__PURE__*/React__default.createElement(ThemeProvider, {
727
707
  theme: defaultTheme
728
708
  }, /*#__PURE__*/React__default.createElement(Panel, _extends({
@@ -917,73 +897,6 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
917
897
  padding: '.5em'
918
898
  }
919
899
  }, `${match.id}`));
920
- })) : null, matchCacheValues.length ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
921
- style: {
922
- marginTop: '2rem',
923
- padding: '.5em',
924
- background: defaultTheme.backgroundAlt,
925
- position: 'sticky',
926
- top: 0,
927
- bottom: 0,
928
- zIndex: 1,
929
- display: 'flex',
930
- alignItems: 'center',
931
- justifyContent: 'space-between'
932
- }
933
- }, /*#__PURE__*/React__default.createElement("div", null, "Match Cache"), /*#__PURE__*/React__default.createElement(Button, {
934
- onClick: () => {
935
- router.store.setState(s => s.matchCache = {});
936
- }
937
- }, "Clear")), matchCacheValues.map((d, i) => {
938
- const {
939
- match,
940
- gc
941
- } = d;
942
- return /*#__PURE__*/React__default.createElement("div", {
943
- key: match.id || i,
944
- role: "button",
945
- "aria-label": `Open match details for ${match.id}`,
946
- onClick: () => setActiveMatchId(activeMatchId === match.id ? '' : match.id),
947
- style: {
948
- display: 'flex',
949
- borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
950
- cursor: 'pointer',
951
- background: match === activeMatch ? 'rgba(255,255,255,.1)' : undefined
952
- }
953
- }, /*#__PURE__*/React__default.createElement("div", {
954
- style: {
955
- display: 'flex',
956
- flexDirection: 'column',
957
- padding: '.5rem',
958
- gap: '.3rem'
959
- }
960
- }, /*#__PURE__*/React__default.createElement("div", {
961
- style: {
962
- display: 'flex',
963
- alignItems: 'center',
964
- gap: '.5rem'
965
- }
966
- }, /*#__PURE__*/React__default.createElement("div", {
967
- style: {
968
- flex: '0 0 auto',
969
- width: '1.3rem',
970
- height: '1.3rem',
971
- background: getStatusColor(match, defaultTheme),
972
- alignItems: 'center',
973
- justifyContent: 'center',
974
- fontWeight: 'bold',
975
- borderRadius: '.25rem',
976
- transition: 'all .2s ease-out'
977
- }
978
- }), /*#__PURE__*/React__default.createElement(Code, null, `${match.id}`)), /*#__PURE__*/React__default.createElement("span", {
979
- style: {
980
- fontSize: '.7rem',
981
- opacity: '.5',
982
- lineHeight: 1
983
- }
984
- }, "Expires", ' ', formatDistanceStrict(new Date(gc), new Date(), {
985
- addSuffix: true
986
- }))));
987
900
  })) : null), activeMatch ? /*#__PURE__*/React__default.createElement(ActivePanel, null, /*#__PURE__*/React__default.createElement("div", {
988
901
  style: {
989
902
  padding: '.5em',
@@ -1009,10 +922,6 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
1009
922
  style: {
1010
923
  opacity: '.5'
1011
924
  }
1012
- }, "Invalid"), /*#__PURE__*/React__default.createElement("td", null, activeMatch.getIsInvalid().toString())), /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
1013
- style: {
1014
- opacity: '.5'
1015
- }
1016
925
  }, "Last Updated"), /*#__PURE__*/React__default.createElement("td", null, activeMatch.store.state.updatedAt ? new Date(activeMatch.store.state.updatedAt).toLocaleTimeString() : 'N/A'))))), /*#__PURE__*/React__default.createElement("div", {
1017
926
  style: {
1018
927
  background: defaultTheme.backgroundAlt,
@@ -1027,15 +936,6 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
1027
936
  padding: '0.5em'
1028
937
  }
1029
938
  }, /*#__PURE__*/React__default.createElement(Button, {
1030
- type: "button",
1031
- onClick: () => {
1032
- activeMatch.invalidate();
1033
- },
1034
- style: {
1035
- background: defaultTheme.warning,
1036
- color: defaultTheme.inputTextColor
1037
- }
1038
- }, "Invalidate"), ' ', /*#__PURE__*/React__default.createElement(Button, {
1039
939
  type: "button",
1040
940
  onClick: () => activeMatch.load(),
1041
941
  style: {
@@ -1077,29 +977,6 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
1077
977
  bottom: 0,
1078
978
  zIndex: 1
1079
979
  }
1080
- }, "All Loader Data"), /*#__PURE__*/React__default.createElement("div", {
1081
- style: {
1082
- padding: '.5em'
1083
- }
1084
- }, Object.keys(last(router.store.state.currentMatches)?.store.state.loaderData || {}).length ? /*#__PURE__*/React__default.createElement(Explorer, {
1085
- value: last(router.store.state.currentMatches)?.store.state.loaderData || {},
1086
- defaultExpanded: Object.keys(last(router.store.state.currentMatches)?.store.state.loaderData || {}).reduce((obj, next) => {
1087
- obj[next] = {};
1088
- return obj;
1089
- }, {})
1090
- }) : /*#__PURE__*/React__default.createElement("em", {
1091
- style: {
1092
- opacity: 0.5
1093
- }
1094
- }, '{ }')), /*#__PURE__*/React__default.createElement("div", {
1095
- style: {
1096
- padding: '.5em',
1097
- background: defaultTheme.backgroundAlt,
1098
- position: 'sticky',
1099
- top: 0,
1100
- bottom: 0,
1101
- zIndex: 1
1102
- }
1103
980
  }, "Search Params"), /*#__PURE__*/React__default.createElement("div", {
1104
981
  style: {
1105
982
  padding: '.5em'