@tanstack/react-router-devtools 0.0.1-alpha.6 → 0.0.1-alpha.8
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/packages/react-router-devtools/src/devtools.js +43 -42
- package/build/cjs/packages/react-router-devtools/src/devtools.js.map +1 -1
- package/build/cjs/packages/react-router-devtools/src/utils.js +36 -0
- package/build/cjs/packages/react-router-devtools/src/utils.js.map +1 -1
- package/build/esm/index.js +78 -42
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +2677 -2677
- package/build/umd/index.development.js +78 -42
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/devtools.tsx +172 -180
- package/src/utils.ts +30 -0
|
@@ -1101,6 +1101,41 @@
|
|
|
1101
1101
|
}));
|
|
1102
1102
|
}
|
|
1103
1103
|
|
|
1104
|
+
function multiSortBy(arr, accessors) {
|
|
1105
|
+
if (accessors === void 0) {
|
|
1106
|
+
accessors = [d => d];
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
return arr.map((d, i) => [d, i]).sort((_ref3, _ref4) => {
|
|
1110
|
+
let [a, ai] = _ref3;
|
|
1111
|
+
let [b, bi] = _ref4;
|
|
1112
|
+
|
|
1113
|
+
for (const accessor of accessors) {
|
|
1114
|
+
const ao = accessor(a);
|
|
1115
|
+
const bo = accessor(b);
|
|
1116
|
+
|
|
1117
|
+
if (typeof ao === 'undefined') {
|
|
1118
|
+
if (typeof bo === 'undefined') {
|
|
1119
|
+
continue;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
return 1;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
if (ao === bo) {
|
|
1126
|
+
continue;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
return ao > bo ? 1 : -1;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
return ai - bi;
|
|
1133
|
+
}).map(_ref5 => {
|
|
1134
|
+
let [d] = _ref5;
|
|
1135
|
+
return d;
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1104
1139
|
const Panel = styled('div', (_props, theme) => ({
|
|
1105
1140
|
fontSize: 'clamp(12px, 1.5vw, 14px)',
|
|
1106
1141
|
fontFamily: "sans-serif",
|
|
@@ -1407,9 +1442,7 @@
|
|
|
1407
1442
|
const _excluded = ["style"],
|
|
1408
1443
|
_excluded2 = ["style", "onClick"],
|
|
1409
1444
|
_excluded3 = ["style", "onClick"],
|
|
1410
|
-
_excluded4 = ["isOpen", "setIsOpen", "handleDragStart", "router"]
|
|
1411
|
-
_excluded5 = ["listeners", "buildLocation", "mount", "update", "buildNext", "navigate", "cancelMatches", "loadLocation", "cleanPreloadCache", "loadRoute", "matchRoutes", "loadMatches", "invalidateRoute", "resolvePath", "matchRoute", "buildLink", "__experimental__createSnapshot", "destroy"],
|
|
1412
|
-
_excluded6 = ["cancel", "load", "router", "Link", "MatchRoute", "buildLink", "linkProps", "matchRoute", "navigate"];
|
|
1445
|
+
_excluded4 = ["isOpen", "setIsOpen", "handleDragStart", "router"];
|
|
1413
1446
|
const isServer = typeof window === 'undefined';
|
|
1414
1447
|
function TanStackRouterDevtools(_ref) {
|
|
1415
1448
|
let {
|
|
@@ -1645,7 +1678,7 @@
|
|
|
1645
1678
|
})) : null);
|
|
1646
1679
|
}
|
|
1647
1680
|
const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default["default"].forwardRef(function TanStackRouterDevtoolsPanel(props, ref) {
|
|
1648
|
-
var _router$state$matches, _router$state$pending, _last, _last2, _last3, _last4, _last5, _last6;
|
|
1681
|
+
var _Object$values$find$m, _Object$values, _Object$values$find, _router$state$matches, _router$state$pending, _router$state$pending2, _last, _last2, _last3, _last4, _last5, _last6;
|
|
1649
1682
|
|
|
1650
1683
|
const {
|
|
1651
1684
|
isOpen = true,
|
|
@@ -1654,15 +1687,10 @@
|
|
|
1654
1687
|
} = props,
|
|
1655
1688
|
panelProps = _objectWithoutPropertiesLoose(props, _excluded4);
|
|
1656
1689
|
|
|
1657
|
-
const routerExplorerValue = React__default["default"].useMemo(() => {
|
|
1658
|
-
const rest = _objectWithoutPropertiesLoose(router, _excluded5);
|
|
1659
|
-
|
|
1660
|
-
return rest;
|
|
1661
|
-
}, [router.state]);
|
|
1662
1690
|
const rerender = React__default["default"].useReducer(() => ({}), {})[1];
|
|
1663
1691
|
React__default["default"].useEffect(() => {
|
|
1664
1692
|
let interval = setInterval(() => {
|
|
1665
|
-
router.
|
|
1693
|
+
router.cleanMatchCache(); // router.notify()
|
|
1666
1694
|
|
|
1667
1695
|
rerender();
|
|
1668
1696
|
}, 250);
|
|
@@ -1671,16 +1699,15 @@
|
|
|
1671
1699
|
};
|
|
1672
1700
|
}, []);
|
|
1673
1701
|
const [activeRouteId, setActiveRouteId] = useLocalStorage('tanstackRouterDevtoolsActiveRouteId', '');
|
|
1674
|
-
const
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
const
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
}, [activeMatch]);
|
|
1702
|
+
const [activeMatchId, setActiveMatchId] = useLocalStorage('tanstackRouterDevtoolsActiveMatchId', '');
|
|
1703
|
+
React__default["default"].useEffect(() => {
|
|
1704
|
+
setActiveMatchId('');
|
|
1705
|
+
}, [activeRouteId]);
|
|
1706
|
+
const activeMatch = (_Object$values$find$m = (_Object$values = Object.values(router.matchCache)) == null ? void 0 : (_Object$values$find = _Object$values.find(d => d.match.matchId === activeMatchId)) == null ? void 0 : _Object$values$find.match) != null ? _Object$values$find$m : (_router$state$matches = router.state.matches) == null ? void 0 : _router$state$matches.find(d => d.routeId === activeRouteId);
|
|
1707
|
+
const matchCacheValues = multiSortBy(Object.keys(router.matchCache).filter(key => {
|
|
1708
|
+
const cacheEntry = router.matchCache[key];
|
|
1709
|
+
return cacheEntry.gc > Date.now();
|
|
1710
|
+
}).map(key => router.matchCache[key]), [d => d.match.isFetching ? -1 : 1, d => -d.match.updatedAt]);
|
|
1684
1711
|
return /*#__PURE__*/React__default["default"].createElement(ThemeProvider, {
|
|
1685
1712
|
theme: defaultTheme
|
|
1686
1713
|
}, /*#__PURE__*/React__default["default"].createElement(Panel, _extends({
|
|
@@ -1746,7 +1773,7 @@
|
|
|
1746
1773
|
}
|
|
1747
1774
|
}, /*#__PURE__*/React__default["default"].createElement(Explorer, {
|
|
1748
1775
|
label: "Router",
|
|
1749
|
-
value:
|
|
1776
|
+
value: router,
|
|
1750
1777
|
defaultExpanded: {}
|
|
1751
1778
|
})))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1752
1779
|
style: {
|
|
@@ -1766,7 +1793,7 @@
|
|
|
1766
1793
|
top: 0,
|
|
1767
1794
|
zIndex: 1
|
|
1768
1795
|
}
|
|
1769
|
-
}, "
|
|
1796
|
+
}, "Active Matches"), router.state.matches.map((match, i) => {
|
|
1770
1797
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1771
1798
|
key: match.routeId || i,
|
|
1772
1799
|
role: "button",
|
|
@@ -1797,7 +1824,7 @@
|
|
|
1797
1824
|
padding: '.5em'
|
|
1798
1825
|
}
|
|
1799
1826
|
}, "" + match.matchId));
|
|
1800
|
-
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1827
|
+
}), (_router$state$pending = router.state.pending) != null && _router$state$pending.matches.length ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1801
1828
|
style: {
|
|
1802
1829
|
marginTop: '2rem',
|
|
1803
1830
|
padding: '.5em',
|
|
@@ -1806,7 +1833,7 @@
|
|
|
1806
1833
|
top: 0,
|
|
1807
1834
|
zIndex: 1
|
|
1808
1835
|
}
|
|
1809
|
-
}, "Pending Matches"), (_router$state$
|
|
1836
|
+
}, "Pending Matches"), (_router$state$pending2 = router.state.pending) == null ? void 0 : _router$state$pending2.matches.map((match, i) => {
|
|
1810
1837
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1811
1838
|
key: match.routeId || i,
|
|
1812
1839
|
role: "button",
|
|
@@ -1836,32 +1863,34 @@
|
|
|
1836
1863
|
padding: '.5em'
|
|
1837
1864
|
}
|
|
1838
1865
|
}, "" + match.matchId));
|
|
1839
|
-
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1866
|
+
})) : null, matchCacheValues.length ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1840
1867
|
style: {
|
|
1841
1868
|
marginTop: '2rem',
|
|
1842
1869
|
padding: '.5em',
|
|
1843
1870
|
background: defaultTheme.backgroundAlt,
|
|
1844
1871
|
position: 'sticky',
|
|
1845
1872
|
top: 0,
|
|
1846
|
-
|
|
1873
|
+
bottom: 0,
|
|
1874
|
+
zIndex: 1,
|
|
1875
|
+
display: 'flex',
|
|
1876
|
+
alignItems: 'center',
|
|
1877
|
+
justifyContent: 'space-between'
|
|
1847
1878
|
}
|
|
1848
|
-
}, "
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
}).map((
|
|
1854
|
-
var _match$updatedAt;
|
|
1855
|
-
|
|
1879
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", null, "Match Cache"), /*#__PURE__*/React__default["default"].createElement(Button, {
|
|
1880
|
+
onClick: () => {
|
|
1881
|
+
router.matchCache = {};
|
|
1882
|
+
router.notify();
|
|
1883
|
+
}
|
|
1884
|
+
}, "Clear")), matchCacheValues.map((d, i) => {
|
|
1856
1885
|
const {
|
|
1857
1886
|
match,
|
|
1858
|
-
|
|
1859
|
-
} =
|
|
1887
|
+
gc
|
|
1888
|
+
} = d;
|
|
1860
1889
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1861
1890
|
key: match.matchId || i,
|
|
1862
1891
|
role: "button",
|
|
1863
1892
|
"aria-label": "Open match details for " + match.matchId,
|
|
1864
|
-
onClick: () =>
|
|
1893
|
+
onClick: () => setActiveMatchId(activeMatchId === match.matchId ? '' : match.matchId),
|
|
1865
1894
|
style: {
|
|
1866
1895
|
display: 'flex',
|
|
1867
1896
|
borderBottom: "solid 1px " + defaultTheme.grayAlt,
|
|
@@ -1895,17 +1924,20 @@
|
|
|
1895
1924
|
}
|
|
1896
1925
|
}), /*#__PURE__*/React__default["default"].createElement(Code, null, "" + match.matchId)), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1897
1926
|
style: {
|
|
1898
|
-
|
|
1927
|
+
fontSize: '.7rem',
|
|
1928
|
+
opacity: '.5',
|
|
1929
|
+
lineHeight: 1
|
|
1899
1930
|
}
|
|
1900
|
-
}, "Expires", ' ', formatDistanceStrict(new Date(), new Date(
|
|
1931
|
+
}, "Expires", ' ', formatDistanceStrict(new Date(gc), new Date(), {
|
|
1901
1932
|
addSuffix: true
|
|
1902
1933
|
}))));
|
|
1903
|
-
})), activeMatch ? /*#__PURE__*/React__default["default"].createElement(ActivePanel, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1934
|
+
})) : null), activeMatch ? /*#__PURE__*/React__default["default"].createElement(ActivePanel, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1904
1935
|
style: {
|
|
1905
1936
|
padding: '.5em',
|
|
1906
1937
|
background: defaultTheme.backgroundAlt,
|
|
1907
1938
|
position: 'sticky',
|
|
1908
1939
|
top: 0,
|
|
1940
|
+
bottom: 0,
|
|
1909
1941
|
zIndex: 1
|
|
1910
1942
|
}
|
|
1911
1943
|
}, "Match Details"), /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("table", null, /*#__PURE__*/React__default["default"].createElement("tbody", null, /*#__PURE__*/React__default["default"].createElement("tr", null, /*#__PURE__*/React__default["default"].createElement("td", {
|
|
@@ -1938,6 +1970,7 @@
|
|
|
1938
1970
|
padding: '.5em',
|
|
1939
1971
|
position: 'sticky',
|
|
1940
1972
|
top: 0,
|
|
1973
|
+
bottom: 0,
|
|
1941
1974
|
zIndex: 1
|
|
1942
1975
|
}
|
|
1943
1976
|
}, "Actions"), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -1966,6 +1999,7 @@
|
|
|
1966
1999
|
padding: '.5em',
|
|
1967
2000
|
position: 'sticky',
|
|
1968
2001
|
top: 0,
|
|
2002
|
+
bottom: 0,
|
|
1969
2003
|
zIndex: 1
|
|
1970
2004
|
}
|
|
1971
2005
|
}, "Explorer"), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -1974,7 +2008,7 @@
|
|
|
1974
2008
|
}
|
|
1975
2009
|
}, /*#__PURE__*/React__default["default"].createElement(Explorer, {
|
|
1976
2010
|
label: "Match",
|
|
1977
|
-
value:
|
|
2011
|
+
value: activeMatch,
|
|
1978
2012
|
defaultExpanded: {}
|
|
1979
2013
|
}))) : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1980
2014
|
style: {
|
|
@@ -1992,9 +2026,10 @@
|
|
|
1992
2026
|
background: defaultTheme.backgroundAlt,
|
|
1993
2027
|
position: 'sticky',
|
|
1994
2028
|
top: 0,
|
|
2029
|
+
bottom: 0,
|
|
1995
2030
|
zIndex: 1
|
|
1996
2031
|
}
|
|
1997
|
-
}, "Loader Data"), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2032
|
+
}, "All Loader Data"), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1998
2033
|
style: {
|
|
1999
2034
|
padding: '.5em'
|
|
2000
2035
|
}
|
|
@@ -2014,6 +2049,7 @@
|
|
|
2014
2049
|
background: defaultTheme.backgroundAlt,
|
|
2015
2050
|
position: 'sticky',
|
|
2016
2051
|
top: 0,
|
|
2052
|
+
bottom: 0,
|
|
2017
2053
|
zIndex: 1
|
|
2018
2054
|
}
|
|
2019
2055
|
}, "Search Params"), /*#__PURE__*/React__default["default"].createElement("div", {
|