@tanstack/react-router-devtools 0.0.1-alpha.4 → 0.0.1-alpha.6

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.
@@ -9,6 +9,7 @@
9
9
  * @license MIT
10
10
  */
11
11
  import React from 'react';
12
+ import { Router } from '@tanstack/react-router';
12
13
 
13
14
  declare type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
14
15
  interface DevtoolsOptions {
@@ -42,7 +43,7 @@ interface DevtoolsOptions {
42
43
  /**
43
44
  * A boolean variable indicating if the "lite" version of the library is being used
44
45
  */
45
- useRouter?: () => unknown;
46
+ router: Router<any, any>;
46
47
  }
47
48
  interface DevtoolsPanelOptions {
48
49
  /**
@@ -68,9 +69,9 @@ interface DevtoolsPanelOptions {
68
69
  /**
69
70
  * A boolean variable indicating if the "lite" version of the library is being used
70
71
  */
71
- useRouter: () => unknown;
72
+ router: Router<any, any>;
72
73
  }
73
- declare function TanStackRouterDevtools({ initialIsOpen, panelProps, closeButtonProps, toggleButtonProps, position, containerElement: Container, useRouter: useRouterImpl, }: DevtoolsOptions): React.ReactElement | null;
74
+ declare function TanStackRouterDevtools({ initialIsOpen, panelProps, closeButtonProps, toggleButtonProps, position, containerElement: Container, router, }: DevtoolsOptions): React.ReactElement | null;
74
75
  declare const TanStackRouterDevtoolsPanel: React.ForwardRefExoticComponent<DevtoolsPanelOptions & React.RefAttributes<HTMLDivElement>>;
75
76
 
76
77
  export { PartialKeys, TanStackRouterDevtools, TanStackRouterDevtoolsPanel };
@@ -1260,7 +1260,7 @@
1260
1260
  }
1261
1261
  const DefaultRenderer = _ref2 => {
1262
1262
  let {
1263
- HandleEntry,
1263
+ handleEntry,
1264
1264
  label,
1265
1265
  value,
1266
1266
  subEntries = [],
@@ -1282,19 +1282,13 @@
1282
1282
  onClick: () => toggleExpanded()
1283
1283
  }, /*#__PURE__*/React__namespace.createElement(Expander, {
1284
1284
  expanded: expanded
1285
- }), " ", label, ' ', /*#__PURE__*/React__namespace.createElement(Info, null, String(type).toLowerCase() === 'iterable' ? '(Iterable) ' : '', subEntries.length, " ", subEntries.length > 1 ? "items" : "item")), expanded ? subEntryPages.length === 1 ? /*#__PURE__*/React__namespace.createElement(SubEntries, null, subEntries.map(entry => /*#__PURE__*/React__namespace.createElement(HandleEntry, {
1286
- key: entry.label,
1287
- entry: entry
1288
- }))) : /*#__PURE__*/React__namespace.createElement(SubEntries, null, subEntryPages.map((entries, index) => /*#__PURE__*/React__namespace.createElement("div", {
1285
+ }), " ", label, ' ', /*#__PURE__*/React__namespace.createElement(Info, null, String(type).toLowerCase() === 'iterable' ? '(Iterable) ' : '', subEntries.length, " ", subEntries.length > 1 ? "items" : "item")), expanded ? subEntryPages.length === 1 ? /*#__PURE__*/React__namespace.createElement(SubEntries, null, subEntries.map((entry, index) => handleEntry(entry))) : /*#__PURE__*/React__namespace.createElement(SubEntries, null, subEntryPages.map((entries, index) => /*#__PURE__*/React__namespace.createElement("div", {
1289
1286
  key: index
1290
1287
  }, /*#__PURE__*/React__namespace.createElement(Entry, null, /*#__PURE__*/React__namespace.createElement(LabelButton, {
1291
1288
  onClick: () => setExpandedPages(old => old.includes(index) ? old.filter(d => d !== index) : [...old, index])
1292
1289
  }, /*#__PURE__*/React__namespace.createElement(Expander, {
1293
1290
  expanded: expanded
1294
- }), " [", index * pageSize, " ...", ' ', index * pageSize + pageSize - 1, "]"), expandedPages.includes(index) ? /*#__PURE__*/React__namespace.createElement(SubEntries, null, entries.map(entry => /*#__PURE__*/React__namespace.createElement(HandleEntry, {
1295
- key: entry.label,
1296
- entry: entry
1297
- }))) : null)))) : null) : type === 'function' ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Explorer, {
1291
+ }), " [", index * pageSize, " ...", ' ', index * pageSize + pageSize - 1, "]"), expandedPages.includes(index) ? /*#__PURE__*/React__namespace.createElement(SubEntries, null, entries.map(entry => handleEntry(entry))) : null)))) : null) : type === 'function' ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Explorer, {
1298
1292
  renderer: renderer,
1299
1293
  label: /*#__PURE__*/React__namespace.createElement("button", {
1300
1294
  onClick: refreshValueSnapshot,
@@ -1361,15 +1355,11 @@
1361
1355
 
1362
1356
  const subEntryPages = chunkArray(subEntries, pageSize);
1363
1357
  return renderer(_extends({
1364
- HandleEntry: React__namespace.useCallback(_ref5 => {
1365
- let {
1366
- entry
1367
- } = _ref5;
1368
- return /*#__PURE__*/React__namespace.createElement(Explorer, _extends({
1369
- value: value,
1370
- renderer: renderer
1371
- }, rest, entry));
1372
- }, [value, renderer]),
1358
+ handleEntry: entry => /*#__PURE__*/React__namespace.createElement(Explorer, _extends({
1359
+ key: entry.label,
1360
+ value: value,
1361
+ renderer: renderer
1362
+ }, rest, entry)),
1373
1363
  type,
1374
1364
  subEntries,
1375
1365
  subEntryPages,
@@ -1417,7 +1407,7 @@
1417
1407
  const _excluded = ["style"],
1418
1408
  _excluded2 = ["style", "onClick"],
1419
1409
  _excluded3 = ["style", "onClick"],
1420
- _excluded4 = ["isOpen", "setIsOpen", "handleDragStart", "useRouter"],
1410
+ _excluded4 = ["isOpen", "setIsOpen", "handleDragStart", "router"],
1421
1411
  _excluded5 = ["listeners", "buildLocation", "mount", "update", "buildNext", "navigate", "cancelMatches", "loadLocation", "cleanPreloadCache", "loadRoute", "matchRoutes", "loadMatches", "invalidateRoute", "resolvePath", "matchRoute", "buildLink", "__experimental__createSnapshot", "destroy"],
1422
1412
  _excluded6 = ["cancel", "load", "router", "Link", "MatchRoute", "buildLink", "linkProps", "matchRoute", "navigate"];
1423
1413
  const isServer = typeof window === 'undefined';
@@ -1429,7 +1419,7 @@
1429
1419
  toggleButtonProps = {},
1430
1420
  position = 'bottom-left',
1431
1421
  containerElement: Container = 'footer',
1432
- useRouter: useRouterImpl = reactRouter.useRouter
1422
+ router
1433
1423
  } = _ref;
1434
1424
  const rootRef = React__default["default"].useRef(null);
1435
1425
  const panelRef = React__default["default"].useRef(null);
@@ -1565,7 +1555,7 @@
1565
1555
  }, /*#__PURE__*/React__default["default"].createElement(TanStackRouterDevtoolsPanel, _extends({
1566
1556
  ref: panelRef
1567
1557
  }, otherPanelProps, {
1568
- useRouter: useRouterImpl,
1558
+ router: router,
1569
1559
  style: _extends({
1570
1560
  position: 'fixed',
1571
1561
  bottom: '0',
@@ -1660,22 +1650,37 @@
1660
1650
  const {
1661
1651
  isOpen = true,
1662
1652
  handleDragStart,
1663
- useRouter
1653
+ router
1664
1654
  } = props,
1665
1655
  panelProps = _objectWithoutPropertiesLoose(props, _excluded4);
1666
1656
 
1667
- const router = useRouter();
1657
+ const routerExplorerValue = React__default["default"].useMemo(() => {
1658
+ const rest = _objectWithoutPropertiesLoose(router, _excluded5);
1659
+
1660
+ return rest;
1661
+ }, [router.state]);
1662
+ const rerender = React__default["default"].useReducer(() => ({}), {})[1];
1668
1663
  React__default["default"].useEffect(() => {
1669
1664
  let interval = setInterval(() => {
1670
- router.cleanPreloadCache();
1671
- router.notify();
1672
- }, 1000);
1665
+ router.cleanPreloadCache(); // router.notify()
1666
+
1667
+ rerender();
1668
+ }, 250);
1673
1669
  return () => {
1674
1670
  clearInterval(interval);
1675
1671
  };
1676
1672
  }, []);
1677
1673
  const [activeRouteId, setActiveRouteId] = useLocalStorage('tanstackRouterDevtoolsActiveRouteId', '');
1678
1674
  const activeMatch = (_router$state$matches = router.state.matches) == null ? void 0 : _router$state$matches.find(d => d.routeId === activeRouteId);
1675
+ const activeMatchExplorerValue = React__default["default"].useMemo(() => {
1676
+ if (!activeMatch) {
1677
+ return {};
1678
+ }
1679
+
1680
+ const rest = _objectWithoutPropertiesLoose(activeMatch, _excluded6);
1681
+
1682
+ return rest;
1683
+ }, [activeMatch]);
1679
1684
  return /*#__PURE__*/React__default["default"].createElement(ThemeProvider, {
1680
1685
  theme: defaultTheme
1681
1686
  }, /*#__PURE__*/React__default["default"].createElement(Panel, _extends({
@@ -1741,11 +1746,7 @@
1741
1746
  }
1742
1747
  }, /*#__PURE__*/React__default["default"].createElement(Explorer, {
1743
1748
  label: "Router",
1744
- value: (() => {
1745
- const rest = _objectWithoutPropertiesLoose(router, _excluded5);
1746
-
1747
- return rest;
1748
- })(),
1749
+ value: routerExplorerValue,
1749
1750
  defaultExpanded: {}
1750
1751
  })))), /*#__PURE__*/React__default["default"].createElement("div", {
1751
1752
  style: {
@@ -1946,7 +1947,7 @@
1946
1947
  }, /*#__PURE__*/React__default["default"].createElement(Button, {
1947
1948
  type: "button",
1948
1949
  onClick: () => {
1949
- router.invalidateRoute(activeMatch);
1950
+ activeMatch.invalidate();
1950
1951
  router.notify();
1951
1952
  },
1952
1953
  style: {
@@ -1955,7 +1956,7 @@
1955
1956
  }
1956
1957
  }, "Invalidate"), ' ', /*#__PURE__*/React__default["default"].createElement(Button, {
1957
1958
  type: "button",
1958
- onClick: () => router.reload(),
1959
+ onClick: () => activeMatch.load(),
1959
1960
  style: {
1960
1961
  background: defaultTheme.gray
1961
1962
  }
@@ -1973,11 +1974,7 @@
1973
1974
  }
1974
1975
  }, /*#__PURE__*/React__default["default"].createElement(Explorer, {
1975
1976
  label: "Match",
1976
- value: (() => {
1977
- const rest = _objectWithoutPropertiesLoose(activeMatch, _excluded6);
1978
-
1979
- return rest;
1980
- })(),
1977
+ value: activeMatchExplorerValue,
1981
1978
  defaultExpanded: {}
1982
1979
  }))) : null, /*#__PURE__*/React__default["default"].createElement("div", {
1983
1980
  style: {