@tanstack/react-router-devtools 0.0.1-beta.61 → 0.0.1-beta.63
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/devtools.js +15 -15
- package/build/cjs/devtools.js.map +1 -1
- package/build/cjs/utils.js +1 -1
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +17 -17
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +126 -126
- package/build/types/index.d.ts +3 -3
- package/build/umd/index.development.js +22 -20
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +3 -3
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/devtools.tsx +26 -30
- package/src/utils.ts +5 -5
|
@@ -154,14 +154,16 @@
|
|
|
154
154
|
* @license MIT
|
|
155
155
|
*/
|
|
156
156
|
const routerContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
157
|
-
function
|
|
157
|
+
function useRouterContext() {
|
|
158
158
|
const value = React__namespace.useContext(routerContext);
|
|
159
159
|
warning(!value, 'useRouter must be used inside a <Router> component!');
|
|
160
|
+
useStore(value.router.store);
|
|
160
161
|
return value.router;
|
|
161
162
|
}
|
|
162
|
-
function
|
|
163
|
-
const router =
|
|
164
|
-
|
|
163
|
+
function useRouter(track, shallow) {
|
|
164
|
+
const router = useRouterContext();
|
|
165
|
+
useStore(router.store, track, shallow);
|
|
166
|
+
return router;
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
const getItem = key => {
|
|
@@ -264,7 +266,7 @@
|
|
|
264
266
|
|
|
265
267
|
const isServer$1 = typeof window === 'undefined';
|
|
266
268
|
function getStatusColor(match, theme) {
|
|
267
|
-
return match.
|
|
269
|
+
return match.state.status === 'pending' ? theme.active : match.state.status === 'error' ? theme.danger : match.state.status === 'success' ? theme.success : theme.gray;
|
|
268
270
|
}
|
|
269
271
|
function styled(type, newStyles, queries = {}) {
|
|
270
272
|
return /*#__PURE__*/React__default["default"].forwardRef(({
|
|
@@ -818,25 +820,25 @@
|
|
|
818
820
|
const routerContextValue = React__default["default"].useContext(routerContext);
|
|
819
821
|
const router = userRouter ?? routerContextValue?.router;
|
|
820
822
|
invariant(router, '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.');
|
|
821
|
-
|
|
823
|
+
useRouter();
|
|
822
824
|
const [activeRouteId, setActiveRouteId] = useLocalStorage('tanstackRouterDevtoolsActiveRouteId', '');
|
|
823
825
|
const [activeMatchId, setActiveMatchId] = useLocalStorage('tanstackRouterDevtoolsActiveMatchId', '');
|
|
824
826
|
React__default["default"].useEffect(() => {
|
|
825
827
|
setActiveMatchId('');
|
|
826
828
|
}, [activeRouteId]);
|
|
827
|
-
const allMatches = React__default["default"].useMemo(() => [...Object.values(router.
|
|
829
|
+
const allMatches = React__default["default"].useMemo(() => [...Object.values(router.state.currentMatches), ...Object.values(router.state.pendingMatches ?? [])], [router.state.currentMatches, router.state.pendingMatches]);
|
|
828
830
|
const activeMatch = allMatches?.find(d => d.id === activeMatchId) || allMatches?.find(d => d.route.id === activeRouteId);
|
|
829
831
|
|
|
830
832
|
// const matchCacheValues = multiSortBy(
|
|
831
|
-
// Object.keys(router.
|
|
833
|
+
// Object.keys(router.state.matchCache)
|
|
832
834
|
// .filter((key) => {
|
|
833
|
-
// const cacheEntry = router.
|
|
835
|
+
// const cacheEntry = router.state.matchCache[key]!
|
|
834
836
|
// return cacheEntry.gc > Date.now()
|
|
835
837
|
// })
|
|
836
|
-
// .map((key) => router.
|
|
838
|
+
// .map((key) => router.state.matchCache[key]!),
|
|
837
839
|
// [
|
|
838
|
-
// (d) => (d.match.
|
|
839
|
-
// (d) => -d.match.
|
|
840
|
+
// (d) => (d.match.state.isFetching ? -1 : 1),
|
|
841
|
+
// (d) => -d.match.state.updatedAt!,
|
|
840
842
|
// ],
|
|
841
843
|
// )
|
|
842
844
|
|
|
@@ -964,7 +966,7 @@
|
|
|
964
966
|
top: 0,
|
|
965
967
|
zIndex: 1
|
|
966
968
|
}
|
|
967
|
-
}, "Active Matches"), router.
|
|
969
|
+
}, "Active Matches"), router.state.currentMatches.map((match, i) => {
|
|
968
970
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
969
971
|
key: match.route.id || i,
|
|
970
972
|
role: "button",
|
|
@@ -995,7 +997,7 @@
|
|
|
995
997
|
padding: '.5em'
|
|
996
998
|
}
|
|
997
999
|
}, `${match.id}`));
|
|
998
|
-
}), router.
|
|
1000
|
+
}), router.state.pendingMatches?.length ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
999
1001
|
style: {
|
|
1000
1002
|
marginTop: '2rem',
|
|
1001
1003
|
padding: '.5em',
|
|
@@ -1004,7 +1006,7 @@
|
|
|
1004
1006
|
top: 0,
|
|
1005
1007
|
zIndex: 1
|
|
1006
1008
|
}
|
|
1007
|
-
}, "Pending Matches"), router.
|
|
1009
|
+
}, "Pending Matches"), router.state.pendingMatches?.map((match, i) => {
|
|
1008
1010
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1009
1011
|
key: match.route.id || i,
|
|
1010
1012
|
role: "button",
|
|
@@ -1055,11 +1057,11 @@
|
|
|
1055
1057
|
style: {
|
|
1056
1058
|
opacity: '.5'
|
|
1057
1059
|
}
|
|
1058
|
-
}, "Status"), /*#__PURE__*/React__default["default"].createElement("td", null, activeMatch.
|
|
1060
|
+
}, "Status"), /*#__PURE__*/React__default["default"].createElement("td", null, activeMatch.state.status)), /*#__PURE__*/React__default["default"].createElement("tr", null, /*#__PURE__*/React__default["default"].createElement("td", {
|
|
1059
1061
|
style: {
|
|
1060
1062
|
opacity: '.5'
|
|
1061
1063
|
}
|
|
1062
|
-
}, "Last Updated"), /*#__PURE__*/React__default["default"].createElement("td", null, activeMatch.
|
|
1064
|
+
}, "Last Updated"), /*#__PURE__*/React__default["default"].createElement("td", null, activeMatch.state.updatedAt ? new Date(activeMatch.state.updatedAt).toLocaleTimeString() : 'N/A'))))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1063
1065
|
style: {
|
|
1064
1066
|
background: defaultTheme.backgroundAlt,
|
|
1065
1067
|
padding: '.5em',
|
|
@@ -1118,9 +1120,9 @@
|
|
|
1118
1120
|
style: {
|
|
1119
1121
|
padding: '.5em'
|
|
1120
1122
|
}
|
|
1121
|
-
}, Object.keys(last(router.
|
|
1122
|
-
value: last(router.
|
|
1123
|
-
defaultExpanded: Object.keys(last(router.
|
|
1123
|
+
}, Object.keys(last(router.state.currentMatches)?.state.search || {}).length ? /*#__PURE__*/React__default["default"].createElement(Explorer, {
|
|
1124
|
+
value: last(router.state.currentMatches)?.state.search || {},
|
|
1125
|
+
defaultExpanded: Object.keys(last(router.state.currentMatches)?.state.search || {}).reduce((obj, next) => {
|
|
1124
1126
|
obj[next] = {};
|
|
1125
1127
|
return obj;
|
|
1126
1128
|
}, {})
|