@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
package/build/esm/index.js
CHANGED
|
@@ -1076,6 +1076,41 @@ function scheduleMicrotask(callback) {
|
|
|
1076
1076
|
}));
|
|
1077
1077
|
}
|
|
1078
1078
|
|
|
1079
|
+
function multiSortBy(arr, accessors) {
|
|
1080
|
+
if (accessors === void 0) {
|
|
1081
|
+
accessors = [d => d];
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
return arr.map((d, i) => [d, i]).sort((_ref3, _ref4) => {
|
|
1085
|
+
let [a, ai] = _ref3;
|
|
1086
|
+
let [b, bi] = _ref4;
|
|
1087
|
+
|
|
1088
|
+
for (const accessor of accessors) {
|
|
1089
|
+
const ao = accessor(a);
|
|
1090
|
+
const bo = accessor(b);
|
|
1091
|
+
|
|
1092
|
+
if (typeof ao === 'undefined') {
|
|
1093
|
+
if (typeof bo === 'undefined') {
|
|
1094
|
+
continue;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
return 1;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
if (ao === bo) {
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
return ao > bo ? 1 : -1;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
return ai - bi;
|
|
1108
|
+
}).map(_ref5 => {
|
|
1109
|
+
let [d] = _ref5;
|
|
1110
|
+
return d;
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1079
1114
|
const Panel = styled('div', (_props, theme) => ({
|
|
1080
1115
|
fontSize: 'clamp(12px, 1.5vw, 14px)',
|
|
1081
1116
|
fontFamily: "sans-serif",
|
|
@@ -1382,9 +1417,7 @@ function Logo(props) {
|
|
|
1382
1417
|
const _excluded = ["style"],
|
|
1383
1418
|
_excluded2 = ["style", "onClick"],
|
|
1384
1419
|
_excluded3 = ["style", "onClick"],
|
|
1385
|
-
_excluded4 = ["isOpen", "setIsOpen", "handleDragStart", "router"]
|
|
1386
|
-
_excluded5 = ["listeners", "buildLocation", "mount", "update", "buildNext", "navigate", "cancelMatches", "loadLocation", "cleanPreloadCache", "loadRoute", "matchRoutes", "loadMatches", "invalidateRoute", "resolvePath", "matchRoute", "buildLink", "__experimental__createSnapshot", "destroy"],
|
|
1387
|
-
_excluded6 = ["cancel", "load", "router", "Link", "MatchRoute", "buildLink", "linkProps", "matchRoute", "navigate"];
|
|
1420
|
+
_excluded4 = ["isOpen", "setIsOpen", "handleDragStart", "router"];
|
|
1388
1421
|
const isServer = typeof window === 'undefined';
|
|
1389
1422
|
function TanStackRouterDevtools(_ref) {
|
|
1390
1423
|
let {
|
|
@@ -1620,7 +1653,7 @@ function TanStackRouterDevtools(_ref) {
|
|
|
1620
1653
|
})) : null);
|
|
1621
1654
|
}
|
|
1622
1655
|
const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(function TanStackRouterDevtoolsPanel(props, ref) {
|
|
1623
|
-
var _router$state$matches, _router$state$pending, _last, _last2, _last3, _last4, _last5, _last6;
|
|
1656
|
+
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;
|
|
1624
1657
|
|
|
1625
1658
|
const {
|
|
1626
1659
|
isOpen = true,
|
|
@@ -1629,15 +1662,10 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1629
1662
|
} = props,
|
|
1630
1663
|
panelProps = _objectWithoutPropertiesLoose(props, _excluded4);
|
|
1631
1664
|
|
|
1632
|
-
const routerExplorerValue = React__default.useMemo(() => {
|
|
1633
|
-
const rest = _objectWithoutPropertiesLoose(router, _excluded5);
|
|
1634
|
-
|
|
1635
|
-
return rest;
|
|
1636
|
-
}, [router.state]);
|
|
1637
1665
|
const rerender = React__default.useReducer(() => ({}), {})[1];
|
|
1638
1666
|
React__default.useEffect(() => {
|
|
1639
1667
|
let interval = setInterval(() => {
|
|
1640
|
-
router.
|
|
1668
|
+
router.cleanMatchCache(); // router.notify()
|
|
1641
1669
|
|
|
1642
1670
|
rerender();
|
|
1643
1671
|
}, 250);
|
|
@@ -1646,16 +1674,15 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1646
1674
|
};
|
|
1647
1675
|
}, []);
|
|
1648
1676
|
const [activeRouteId, setActiveRouteId] = useLocalStorage('tanstackRouterDevtoolsActiveRouteId', '');
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
const
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
}, [activeMatch]);
|
|
1677
|
+
const [activeMatchId, setActiveMatchId] = useLocalStorage('tanstackRouterDevtoolsActiveMatchId', '');
|
|
1678
|
+
React__default.useEffect(() => {
|
|
1679
|
+
setActiveMatchId('');
|
|
1680
|
+
}, [activeRouteId]);
|
|
1681
|
+
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);
|
|
1682
|
+
const matchCacheValues = multiSortBy(Object.keys(router.matchCache).filter(key => {
|
|
1683
|
+
const cacheEntry = router.matchCache[key];
|
|
1684
|
+
return cacheEntry.gc > Date.now();
|
|
1685
|
+
}).map(key => router.matchCache[key]), [d => d.match.isFetching ? -1 : 1, d => -d.match.updatedAt]);
|
|
1659
1686
|
return /*#__PURE__*/React__default.createElement(ThemeProvider, {
|
|
1660
1687
|
theme: defaultTheme
|
|
1661
1688
|
}, /*#__PURE__*/React__default.createElement(Panel, _extends({
|
|
@@ -1721,7 +1748,7 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1721
1748
|
}
|
|
1722
1749
|
}, /*#__PURE__*/React__default.createElement(Explorer, {
|
|
1723
1750
|
label: "Router",
|
|
1724
|
-
value:
|
|
1751
|
+
value: router,
|
|
1725
1752
|
defaultExpanded: {}
|
|
1726
1753
|
})))), /*#__PURE__*/React__default.createElement("div", {
|
|
1727
1754
|
style: {
|
|
@@ -1741,7 +1768,7 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1741
1768
|
top: 0,
|
|
1742
1769
|
zIndex: 1
|
|
1743
1770
|
}
|
|
1744
|
-
}, "
|
|
1771
|
+
}, "Active Matches"), router.state.matches.map((match, i) => {
|
|
1745
1772
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
1746
1773
|
key: match.routeId || i,
|
|
1747
1774
|
role: "button",
|
|
@@ -1772,7 +1799,7 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1772
1799
|
padding: '.5em'
|
|
1773
1800
|
}
|
|
1774
1801
|
}, "" + match.matchId));
|
|
1775
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
1802
|
+
}), (_router$state$pending = router.state.pending) != null && _router$state$pending.matches.length ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
1776
1803
|
style: {
|
|
1777
1804
|
marginTop: '2rem',
|
|
1778
1805
|
padding: '.5em',
|
|
@@ -1781,7 +1808,7 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1781
1808
|
top: 0,
|
|
1782
1809
|
zIndex: 1
|
|
1783
1810
|
}
|
|
1784
|
-
}, "Pending Matches"), (_router$state$
|
|
1811
|
+
}, "Pending Matches"), (_router$state$pending2 = router.state.pending) == null ? void 0 : _router$state$pending2.matches.map((match, i) => {
|
|
1785
1812
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
1786
1813
|
key: match.routeId || i,
|
|
1787
1814
|
role: "button",
|
|
@@ -1811,32 +1838,34 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1811
1838
|
padding: '.5em'
|
|
1812
1839
|
}
|
|
1813
1840
|
}, "" + match.matchId));
|
|
1814
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
1841
|
+
})) : null, matchCacheValues.length ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
1815
1842
|
style: {
|
|
1816
1843
|
marginTop: '2rem',
|
|
1817
1844
|
padding: '.5em',
|
|
1818
1845
|
background: defaultTheme.backgroundAlt,
|
|
1819
1846
|
position: 'sticky',
|
|
1820
1847
|
top: 0,
|
|
1821
|
-
|
|
1848
|
+
bottom: 0,
|
|
1849
|
+
zIndex: 1,
|
|
1850
|
+
display: 'flex',
|
|
1851
|
+
alignItems: 'center',
|
|
1852
|
+
justifyContent: 'space-between'
|
|
1822
1853
|
}
|
|
1823
|
-
}, "
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
}).map((
|
|
1829
|
-
var _match$updatedAt;
|
|
1830
|
-
|
|
1854
|
+
}, /*#__PURE__*/React__default.createElement("div", null, "Match Cache"), /*#__PURE__*/React__default.createElement(Button, {
|
|
1855
|
+
onClick: () => {
|
|
1856
|
+
router.matchCache = {};
|
|
1857
|
+
router.notify();
|
|
1858
|
+
}
|
|
1859
|
+
}, "Clear")), matchCacheValues.map((d, i) => {
|
|
1831
1860
|
const {
|
|
1832
1861
|
match,
|
|
1833
|
-
|
|
1834
|
-
} =
|
|
1862
|
+
gc
|
|
1863
|
+
} = d;
|
|
1835
1864
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
1836
1865
|
key: match.matchId || i,
|
|
1837
1866
|
role: "button",
|
|
1838
1867
|
"aria-label": "Open match details for " + match.matchId,
|
|
1839
|
-
onClick: () =>
|
|
1868
|
+
onClick: () => setActiveMatchId(activeMatchId === match.matchId ? '' : match.matchId),
|
|
1840
1869
|
style: {
|
|
1841
1870
|
display: 'flex',
|
|
1842
1871
|
borderBottom: "solid 1px " + defaultTheme.grayAlt,
|
|
@@ -1870,17 +1899,20 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1870
1899
|
}
|
|
1871
1900
|
}), /*#__PURE__*/React__default.createElement(Code, null, "" + match.matchId)), /*#__PURE__*/React__default.createElement("span", {
|
|
1872
1901
|
style: {
|
|
1873
|
-
|
|
1902
|
+
fontSize: '.7rem',
|
|
1903
|
+
opacity: '.5',
|
|
1904
|
+
lineHeight: 1
|
|
1874
1905
|
}
|
|
1875
|
-
}, "Expires", ' ', formatDistanceStrict(new Date(), new Date(
|
|
1906
|
+
}, "Expires", ' ', formatDistanceStrict(new Date(gc), new Date(), {
|
|
1876
1907
|
addSuffix: true
|
|
1877
1908
|
}))));
|
|
1878
|
-
})), activeMatch ? /*#__PURE__*/React__default.createElement(ActivePanel, null, /*#__PURE__*/React__default.createElement("div", {
|
|
1909
|
+
})) : null), activeMatch ? /*#__PURE__*/React__default.createElement(ActivePanel, null, /*#__PURE__*/React__default.createElement("div", {
|
|
1879
1910
|
style: {
|
|
1880
1911
|
padding: '.5em',
|
|
1881
1912
|
background: defaultTheme.backgroundAlt,
|
|
1882
1913
|
position: 'sticky',
|
|
1883
1914
|
top: 0,
|
|
1915
|
+
bottom: 0,
|
|
1884
1916
|
zIndex: 1
|
|
1885
1917
|
}
|
|
1886
1918
|
}, "Match Details"), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("table", null, /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
|
|
@@ -1913,6 +1945,7 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1913
1945
|
padding: '.5em',
|
|
1914
1946
|
position: 'sticky',
|
|
1915
1947
|
top: 0,
|
|
1948
|
+
bottom: 0,
|
|
1916
1949
|
zIndex: 1
|
|
1917
1950
|
}
|
|
1918
1951
|
}, "Actions"), /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -1941,6 +1974,7 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1941
1974
|
padding: '.5em',
|
|
1942
1975
|
position: 'sticky',
|
|
1943
1976
|
top: 0,
|
|
1977
|
+
bottom: 0,
|
|
1944
1978
|
zIndex: 1
|
|
1945
1979
|
}
|
|
1946
1980
|
}, "Explorer"), /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -1949,7 +1983,7 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1949
1983
|
}
|
|
1950
1984
|
}, /*#__PURE__*/React__default.createElement(Explorer, {
|
|
1951
1985
|
label: "Match",
|
|
1952
|
-
value:
|
|
1986
|
+
value: activeMatch,
|
|
1953
1987
|
defaultExpanded: {}
|
|
1954
1988
|
}))) : null, /*#__PURE__*/React__default.createElement("div", {
|
|
1955
1989
|
style: {
|
|
@@ -1967,9 +2001,10 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1967
2001
|
background: defaultTheme.backgroundAlt,
|
|
1968
2002
|
position: 'sticky',
|
|
1969
2003
|
top: 0,
|
|
2004
|
+
bottom: 0,
|
|
1970
2005
|
zIndex: 1
|
|
1971
2006
|
}
|
|
1972
|
-
}, "Loader Data"), /*#__PURE__*/React__default.createElement("div", {
|
|
2007
|
+
}, "All Loader Data"), /*#__PURE__*/React__default.createElement("div", {
|
|
1973
2008
|
style: {
|
|
1974
2009
|
padding: '.5em'
|
|
1975
2010
|
}
|
|
@@ -1989,6 +2024,7 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
|
|
|
1989
2024
|
background: defaultTheme.backgroundAlt,
|
|
1990
2025
|
position: 'sticky',
|
|
1991
2026
|
top: 0,
|
|
2027
|
+
bottom: 0,
|
|
1992
2028
|
zIndex: 1
|
|
1993
2029
|
}
|
|
1994
2030
|
}, "Search Params"), /*#__PURE__*/React__default.createElement("div", {
|