@tanstack/router-devtools 1.112.17 → 1.114.0

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.
Files changed (91) hide show
  1. package/dist/cjs/index.cjs +12 -4
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +2 -2
  4. package/dist/esm/index.d.ts +2 -2
  5. package/dist/esm/index.js +6 -4
  6. package/dist/esm/index.js.map +1 -1
  7. package/package.json +4 -3
  8. package/src/index.tsx +6 -2
  9. package/dist/cjs/AgeTicker.cjs +0 -58
  10. package/dist/cjs/AgeTicker.cjs.map +0 -1
  11. package/dist/cjs/AgeTicker.d.cts +0 -5
  12. package/dist/cjs/BaseTanStackRouterDevtoolsPanel.cjs +0 -421
  13. package/dist/cjs/BaseTanStackRouterDevtoolsPanel.cjs.map +0 -1
  14. package/dist/cjs/BaseTanStackRouterDevtoolsPanel.d.cts +0 -3
  15. package/dist/cjs/Explorer.cjs +0 -310
  16. package/dist/cjs/Explorer.cjs.map +0 -1
  17. package/dist/cjs/Explorer.d.cts +0 -46
  18. package/dist/cjs/TanStackRouterDevtools.cjs +0 -177
  19. package/dist/cjs/TanStackRouterDevtools.cjs.map +0 -1
  20. package/dist/cjs/TanStackRouterDevtools.d.cts +0 -41
  21. package/dist/cjs/TanStackRouterDevtoolsPanel.cjs +0 -21
  22. package/dist/cjs/TanStackRouterDevtoolsPanel.cjs.map +0 -1
  23. package/dist/cjs/TanStackRouterDevtoolsPanel.d.cts +0 -33
  24. package/dist/cjs/context.cjs +0 -18
  25. package/dist/cjs/context.cjs.map +0 -1
  26. package/dist/cjs/context.d.cts +0 -8
  27. package/dist/cjs/logo.cjs +0 -1012
  28. package/dist/cjs/logo.cjs.map +0 -1
  29. package/dist/cjs/logo.d.cts +0 -1
  30. package/dist/cjs/theme.d.cts +0 -34
  31. package/dist/cjs/tokens.cjs +0 -201
  32. package/dist/cjs/tokens.cjs.map +0 -1
  33. package/dist/cjs/tokens.d.cts +0 -298
  34. package/dist/cjs/useLocalStorage.cjs +0 -45
  35. package/dist/cjs/useLocalStorage.cjs.map +0 -1
  36. package/dist/cjs/useLocalStorage.d.cts +0 -1
  37. package/dist/cjs/useMediaQuery.d.cts +0 -1
  38. package/dist/cjs/useStyles.cjs +0 -570
  39. package/dist/cjs/useStyles.cjs.map +0 -1
  40. package/dist/cjs/useStyles.d.cts +0 -52
  41. package/dist/cjs/utils.cjs +0 -84
  42. package/dist/cjs/utils.cjs.map +0 -1
  43. package/dist/cjs/utils.d.cts +0 -23
  44. package/dist/esm/AgeTicker.d.ts +0 -5
  45. package/dist/esm/AgeTicker.js +0 -58
  46. package/dist/esm/AgeTicker.js.map +0 -1
  47. package/dist/esm/BaseTanStackRouterDevtoolsPanel.d.ts +0 -3
  48. package/dist/esm/BaseTanStackRouterDevtoolsPanel.js +0 -421
  49. package/dist/esm/BaseTanStackRouterDevtoolsPanel.js.map +0 -1
  50. package/dist/esm/Explorer.d.ts +0 -46
  51. package/dist/esm/Explorer.js +0 -292
  52. package/dist/esm/Explorer.js.map +0 -1
  53. package/dist/esm/TanStackRouterDevtools.d.ts +0 -41
  54. package/dist/esm/TanStackRouterDevtools.js +0 -177
  55. package/dist/esm/TanStackRouterDevtools.js.map +0 -1
  56. package/dist/esm/TanStackRouterDevtoolsPanel.d.ts +0 -33
  57. package/dist/esm/TanStackRouterDevtoolsPanel.js +0 -21
  58. package/dist/esm/TanStackRouterDevtoolsPanel.js.map +0 -1
  59. package/dist/esm/context.d.ts +0 -8
  60. package/dist/esm/context.js +0 -18
  61. package/dist/esm/context.js.map +0 -1
  62. package/dist/esm/logo.d.ts +0 -1
  63. package/dist/esm/logo.js +0 -1012
  64. package/dist/esm/logo.js.map +0 -1
  65. package/dist/esm/theme.d.ts +0 -34
  66. package/dist/esm/tokens.d.ts +0 -298
  67. package/dist/esm/tokens.js +0 -201
  68. package/dist/esm/tokens.js.map +0 -1
  69. package/dist/esm/useLocalStorage.d.ts +0 -1
  70. package/dist/esm/useLocalStorage.js +0 -46
  71. package/dist/esm/useLocalStorage.js.map +0 -1
  72. package/dist/esm/useMediaQuery.d.ts +0 -1
  73. package/dist/esm/useStyles.d.ts +0 -52
  74. package/dist/esm/useStyles.js +0 -553
  75. package/dist/esm/useStyles.js.map +0 -1
  76. package/dist/esm/utils.d.ts +0 -23
  77. package/dist/esm/utils.js +0 -84
  78. package/dist/esm/utils.js.map +0 -1
  79. package/src/AgeTicker.tsx +0 -73
  80. package/src/BaseTanStackRouterDevtoolsPanel.tsx +0 -488
  81. package/src/Explorer.tsx +0 -362
  82. package/src/TanStackRouterDevtools.tsx +0 -250
  83. package/src/TanStackRouterDevtoolsPanel.tsx +0 -54
  84. package/src/context.ts +0 -22
  85. package/src/logo.tsx +0 -817
  86. package/src/theme.tsx +0 -31
  87. package/src/tokens.ts +0 -305
  88. package/src/useLocalStorage.ts +0 -52
  89. package/src/useMediaQuery.ts +0 -41
  90. package/src/useStyles.tsx +0 -589
  91. package/src/utils.ts +0 -188
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const React = require("react");
4
- const isServer = typeof window === "undefined";
5
- function getStatusColor(match) {
6
- const colorMap = {
7
- pending: "yellow",
8
- success: "green",
9
- error: "red",
10
- notFound: "purple",
11
- redirected: "gray"
12
- };
13
- return match.isFetching && match.status === "success" ? match.isFetching === "beforeLoad" ? "purple" : "blue" : colorMap[match.status];
14
- }
15
- function getRouteStatusColor(matches, route) {
16
- const found = matches.find((d) => d.routeId === route.id);
17
- if (!found) return "gray";
18
- return getStatusColor(found);
19
- }
20
- function useIsMounted() {
21
- const [isMounted, setIsMounted] = React.useState(false);
22
- React[isServer ? "useEffect" : "useLayoutEffect"](() => {
23
- setIsMounted(true);
24
- }, []);
25
- return isMounted;
26
- }
27
- const displayValue = (value) => {
28
- const name = Object.getOwnPropertyNames(Object(value));
29
- const newValue = typeof value === "bigint" ? `${value.toString()}n` : value;
30
- try {
31
- return JSON.stringify(newValue, name);
32
- } catch (e) {
33
- return `unable to stringify`;
34
- }
35
- };
36
- function useSafeState(initialState) {
37
- const isMounted = useIsMounted();
38
- const [state, setState] = React.useState(initialState);
39
- const safeSetState = React.useCallback(
40
- (value) => {
41
- scheduleMicrotask(() => {
42
- if (isMounted) {
43
- setState(value);
44
- }
45
- });
46
- },
47
- [isMounted]
48
- );
49
- return [state, safeSetState];
50
- }
51
- function scheduleMicrotask(callback) {
52
- Promise.resolve().then(callback).catch(
53
- (error) => setTimeout(() => {
54
- throw error;
55
- })
56
- );
57
- }
58
- function multiSortBy(arr, accessors = [(d) => d]) {
59
- return arr.map((d, i) => [d, i]).sort(([a, ai], [b, bi]) => {
60
- for (const accessor of accessors) {
61
- const ao = accessor(a);
62
- const bo = accessor(b);
63
- if (typeof ao === "undefined") {
64
- if (typeof bo === "undefined") {
65
- continue;
66
- }
67
- return 1;
68
- }
69
- if (ao === bo) {
70
- continue;
71
- }
72
- return ao > bo ? 1 : -1;
73
- }
74
- return ai - bi;
75
- }).map(([d]) => d);
76
- }
77
- exports.displayValue = displayValue;
78
- exports.getRouteStatusColor = getRouteStatusColor;
79
- exports.getStatusColor = getStatusColor;
80
- exports.isServer = isServer;
81
- exports.multiSortBy = multiSortBy;
82
- exports.useIsMounted = useIsMounted;
83
- exports.useSafeState = useSafeState;
84
- //# sourceMappingURL=utils.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["import React from 'react'\nimport { useTheme } from './theme'\nimport useMediaQuery from './useMediaQuery'\nimport type {\n AnyRootRoute,\n AnyRoute,\n AnyRouteMatch,\n} from '@tanstack/react-router'\n\nimport type { Theme } from './theme'\n\nexport const isServer = typeof window === 'undefined'\n\ntype StyledComponent<T> = T extends 'button'\n ? React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >\n : T extends 'input'\n ? React.DetailedHTMLProps<\n React.InputHTMLAttributes<HTMLInputElement>,\n HTMLInputElement\n >\n : T extends 'select'\n ? React.DetailedHTMLProps<\n React.SelectHTMLAttributes<HTMLSelectElement>,\n HTMLSelectElement\n >\n : T extends keyof HTMLElementTagNameMap\n ? React.HTMLAttributes<HTMLElementTagNameMap[T]>\n : never\n\nexport function getStatusColor(match: AnyRouteMatch) {\n const colorMap = {\n pending: 'yellow',\n success: 'green',\n error: 'red',\n notFound: 'purple',\n redirected: 'gray',\n } as const\n\n return match.isFetching && match.status === 'success'\n ? match.isFetching === 'beforeLoad'\n ? 'purple'\n : 'blue'\n : colorMap[match.status]\n}\n\nexport function getRouteStatusColor(\n matches: Array<AnyRouteMatch>,\n route: AnyRoute | AnyRootRoute,\n) {\n const found = matches.find((d) => d.routeId === route.id)\n if (!found) return 'gray'\n return getStatusColor(found)\n}\n\ntype Styles =\n | React.CSSProperties\n | ((props: Record<string, any>, theme: Theme) => React.CSSProperties)\n\nexport function styled<T extends keyof HTMLElementTagNameMap>(\n type: T,\n newStyles: Styles,\n queries: Record<string, Styles> = {},\n) {\n return React.forwardRef<HTMLElementTagNameMap[T], StyledComponent<T>>(\n ({ style, ...rest }, ref) => {\n const theme = useTheme()\n\n const mediaStyles = Object.entries(queries).reduce(\n (current, [key, value]) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useMediaQuery(key)\n ? {\n ...current,\n ...(typeof value === 'function' ? value(rest, theme) : value),\n }\n : current\n },\n {},\n )\n\n return React.createElement(type, {\n ...rest,\n style: {\n ...(typeof newStyles === 'function'\n ? newStyles(rest, theme)\n : newStyles),\n ...style,\n ...mediaStyles,\n },\n ref,\n })\n },\n )\n}\n\nexport function useIsMounted() {\n const [isMounted, setIsMounted] = React.useState(false)\n\n React[isServer ? 'useEffect' : 'useLayoutEffect'](() => {\n setIsMounted(true)\n }, [])\n\n return isMounted\n}\n\n/**\n * Displays a string regardless the type of the data\n * @param {unknown} value Value to be stringified\n */\nexport const displayValue = (value: unknown) => {\n const name = Object.getOwnPropertyNames(Object(value))\n const newValue = typeof value === 'bigint' ? `${value.toString()}n` : value\n try {\n return JSON.stringify(newValue, name)\n } catch (e) {\n return `unable to stringify`\n }\n}\n\n/**\n * This hook is a safe useState version which schedules state updates in microtasks\n * to prevent updating a component state while React is rendering different components\n * or when the component is not mounted anymore.\n */\nexport function useSafeState<T>(initialState: T): [T, (value: T) => void] {\n const isMounted = useIsMounted()\n const [state, setState] = React.useState(initialState)\n\n const safeSetState = React.useCallback(\n (value: T) => {\n scheduleMicrotask(() => {\n if (isMounted) {\n setState(value)\n }\n })\n },\n [isMounted],\n )\n\n return [state, safeSetState]\n}\n\n/**\n * Schedules a microtask.\n * This can be useful to schedule state updates after rendering.\n */\nfunction scheduleMicrotask(callback: () => void) {\n Promise.resolve()\n .then(callback)\n .catch((error) =>\n setTimeout(() => {\n throw error\n }),\n )\n}\n\nexport function multiSortBy<T>(\n arr: Array<T>,\n accessors: Array<(item: T) => any> = [(d) => d],\n): Array<T> {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n"],"names":[],"mappings":";;;AAWa,MAAA,WAAW,OAAO,WAAW;AAqBnC,SAAS,eAAe,OAAsB;AACnD,QAAM,WAAW;AAAA,IACf,SAAS;AAAA,IACT,SAAS;AAAA,IACT,OAAO;AAAA,IACP,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AAEA,SAAO,MAAM,cAAc,MAAM,WAAW,YACxC,MAAM,eAAe,eACnB,WACA,SACF,SAAS,MAAM,MAAM;AAC3B;AAEgB,SAAA,oBACd,SACA,OACA;AACM,QAAA,QAAQ,QAAQ,KAAK,CAAC,MAAM,EAAE,YAA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AA,KAAK,SAAS,CAAC;AAEjB,UAAA,OAAO,OAAO,aAAa;AACzB,YAAA,OAAO,OAAO,aAAa;AAC7B;AAAA,QAAA;AAEK,eAAA;AAAA,MAAA;AAGT,UAAI,OAAO,IAAI;AACb;AAAA,MAAA;AAGK,aAAA,KAAK,KAAK,IAAI;AAAA,IAAA;AAGvB,WAAO,KAAK;AAAA,EACb,CAAA,EACA,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AACnB;;;;;;;;"}
@@ -1,23 +0,0 @@
1
- import { default as React } from 'react';
2
- import { AnyRootRoute, AnyRoute, AnyRouteMatch } from '@tanstack/react-router';
3
- import { Theme } from './theme.cjs';
4
- export declare const isServer: boolean;
5
- type StyledComponent<T> = T extends 'button' ? React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> : T extends 'input' ? React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> : T extends 'select' ? React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement> : T extends keyof HTMLElementTagNameMap ? React.HTMLAttributes<HTMLElementTagNameMap[T]> : never;
6
- export declare function getStatusColor(match: AnyRouteMatch): "yellow" | "green" | "red" | "purple" | "gray" | "blue";
7
- export declare function getRouteStatusColor(matches: Array<AnyRouteMatch>, route: AnyRoute | AnyRootRoute): "yellow" | "green" | "red" | "purple" | "gray" | "blue";
8
- type Styles = React.CSSProperties | ((props: Record<string, any>, theme: Theme) => React.CSSProperties);
9
- export declare function styled<T extends keyof HTMLElementTagNameMap>(type: T, newStyles: Styles, queries?: Record<string, Styles>): React.ForwardRefExoticComponent<React.PropsWithoutRef<StyledComponent<T>> & React.RefAttributes<HTMLElementTagNameMap[T]>>;
10
- export declare function useIsMounted(): boolean;
11
- /**
12
- * Displays a string regardless the type of the data
13
- * @param {unknown} value Value to be stringified
14
- */
15
- export declare const displayValue: (value: unknown) => string;
16
- /**
17
- * This hook is a safe useState version which schedules state updates in microtasks
18
- * to prevent updating a component state while React is rendering different components
19
- * or when the component is not mounted anymore.
20
- */
21
- export declare function useSafeState<T>(initialState: T): [T, (value: T) => void];
22
- export declare function multiSortBy<T>(arr: Array<T>, accessors?: Array<(item: T) => any>): Array<T>;
23
- export {};
@@ -1,5 +0,0 @@
1
- import { AnyRouteMatch, AnyRouter } from '@tanstack/react-router';
2
- export declare function AgeTicker({ match, router, }: {
3
- match?: AnyRouteMatch;
4
- router: AnyRouter;
5
- }): import("react/jsx-runtime").JSX.Element | null;
@@ -1,58 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { clsx } from "clsx";
3
- import React__default from "react";
4
- import { useStyles } from "./useStyles.js";
5
- function formatTime(ms) {
6
- const units = ["s", "min", "h", "d"];
7
- const values = [ms / 1e3, ms / 6e4, ms / 36e5, ms / 864e5];
8
- let chosenUnitIndex = 0;
9
- for (let i = 1; i < values.length; i++) {
10
- if (values[i] < 1) break;
11
- chosenUnitIndex = i;
12
- }
13
- const formatter = new Intl.NumberFormat(navigator.language, {
14
- compactDisplay: "short",
15
- notation: "compact",
16
- maximumFractionDigits: 0
17
- });
18
- return formatter.format(values[chosenUnitIndex]) + units[chosenUnitIndex];
19
- }
20
- function AgeTicker({
21
- match,
22
- router
23
- }) {
24
- const styles = useStyles();
25
- const rerender = React__default.useReducer(
26
- () => ({}),
27
- () => ({})
28
- )[1];
29
- React__default.useEffect(() => {
30
- const interval = setInterval(() => {
31
- rerender();
32
- }, 1e3);
33
- return () => {
34
- clearInterval(interval);
35
- };
36
- }, [rerender]);
37
- if (!match) {
38
- return null;
39
- }
40
- const route = router.looseRoutesById[match.routeId];
41
- if (!route.options.loader) {
42
- return null;
43
- }
44
- const age = Date.now() - match.updatedAt;
45
- const staleTime = route.options.staleTime ?? router.options.defaultStaleTime ?? 0;
46
- const gcTime = route.options.gcTime ?? router.options.defaultGcTime ?? 30 * 60 * 1e3;
47
- return /* @__PURE__ */ jsxs("div", { className: clsx(styles.ageTicker(age > staleTime)), children: [
48
- /* @__PURE__ */ jsx("div", { children: formatTime(age) }),
49
- /* @__PURE__ */ jsx("div", { children: "/" }),
50
- /* @__PURE__ */ jsx("div", { children: formatTime(staleTime) }),
51
- /* @__PURE__ */ jsx("div", { children: "/" }),
52
- /* @__PURE__ */ jsx("div", { children: formatTime(gcTime) })
53
- ] });
54
- }
55
- export {
56
- AgeTicker
57
- };
58
- //# sourceMappingURL=AgeTicker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgeTicker.js","sources":["../../src/AgeTicker.tsx"],"sourcesContent":["import { clsx as cx } from 'clsx'\nimport React from 'react'\nimport { useStyles } from './useStyles'\nimport type { AnyRouteMatch, AnyRouter } from '@tanstack/react-router'\n\nfunction formatTime(ms: number) {\n const units = ['s', 'min', 'h', 'd']\n const values = [ms / 1000, ms / 60000, ms / 3600000, ms / 86400000]\n\n let chosenUnitIndex = 0\n for (let i = 1; i < values.length; i++) {\n if (values[i]! < 1) break\n chosenUnitIndex = i\n }\n\n const formatter = new Intl.NumberFormat(navigator.language, {\n compactDisplay: 'short',\n notation: 'compact',\n maximumFractionDigits: 0,\n })\n\n return formatter.format(values[chosenUnitIndex]!) + units[chosenUnitIndex]\n}\n\nexport function AgeTicker({\n match,\n router,\n}: {\n match?: AnyRouteMatch\n router: AnyRouter\n}) {\n const styles = useStyles()\n const rerender = React.useReducer(\n () => ({}),\n () => ({}),\n )[1]\n\n React.useEffect(() => {\n const interval = setInterval(() => {\n rerender()\n }, 1000)\n\n return () => {\n clearInterval(interval)\n }\n }, [rerender])\n\n if (!match) {\n return null\n }\n\n const route = router.looseRoutesById[match.routeId]!\n\n if (!route.options.loader) {\n return null\n }\n\n const age = Date.now() - match.updatedAt\n const staleTime =\n route.options.staleTime ?? router.options.defaultStaleTime ?? 0\n const gcTime =\n route.options.gcTime ?? router.options.defaultGcTime ?? 30 * 60 * 1000\n\n return (\n <div className={cx(styles.ageTicker(age > staleTime))}>\n <div>{formatTime(age)}</div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AK;AAGlE,SAAA,qBAAC,SAAI,WAAWC,KAAG,OAAO,UAAU,MAAM,SAAS,CAAC,GAClD,UAAA;AAAA,IAAC,oBAAA,OAAA,EAAK,UAAW,WAAA,GAAG,EAAE,CAAA;AAAA,IACtB,oBAAC,SAAI,UAAC,IAAA,CAAA;AAAA,IACL,oBAAA,OAAA,EAAK,UAAW,WAAA,SAAS,EAAE,CAAA;AAAA,IAC5B,oBAAC,SAAI,UAAC,IAAA,CAAA;AAAA,IACL,oBAAA,OAAA,EAAK,UAAW,WAAA,MAAM,EAAE,CAAA;AAAA,EAAA,GAC3B;AAEJ;"}
@@ -1,3 +0,0 @@
1
- import { default as React } from 'react';
2
- import { DevtoolsPanelOptions } from './TanStackRouterDevtoolsPanel.js';
3
- export declare const BaseTanStackRouterDevtoolsPanel: React.ForwardRefExoticComponent<DevtoolsPanelOptions & React.RefAttributes<HTMLDivElement>>;
@@ -1,421 +0,0 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import React__default from "react";
3
- import { clsx } from "clsx";
4
- import { useRouter, useRouterState, invariant, rootRouteId, trimPath } from "@tanstack/react-router";
5
- import { useDevtoolsOnClose } from "./context.js";
6
- import { useStyles } from "./useStyles.js";
7
- import useLocalStorage from "./useLocalStorage.js";
8
- import Explorer from "./Explorer.js";
9
- import { multiSortBy, getStatusColor, getRouteStatusColor } from "./utils.js";
10
- import { AgeTicker } from "./AgeTicker.js";
11
- function Logo(props) {
12
- const { className, ...rest } = props;
13
- const styles = useStyles();
14
- return /* @__PURE__ */ jsxs("button", { ...rest, className: clsx(styles.logo, className), children: [
15
- /* @__PURE__ */ jsx("div", { className: styles.tanstackLogo, children: "TANSTACK" }),
16
- /* @__PURE__ */ jsx("div", { className: styles.routerLogo, children: "React Router v1" })
17
- ] });
18
- }
19
- function RouteComp({
20
- router,
21
- route,
22
- isRoot,
23
- activeId,
24
- setActiveId
25
- }) {
26
- var _a;
27
- const routerState = useRouterState({
28
- router
29
- });
30
- const styles = useStyles();
31
- const matches = routerState.pendingMatches || routerState.matches;
32
- const match = routerState.matches.find((d) => d.routeId === route.id);
33
- const param = React__default.useMemo(() => {
34
- try {
35
- if (match == null ? void 0 : match.params) {
36
- const p = match.params;
37
- const r = route.path || trimPath(route.id);
38
- if (r.startsWith("$")) {
39
- const trimmed = r.slice(1);
40
- if (p[trimmed]) {
41
- return `(${p[trimmed]})`;
42
- }
43
- }
44
- }
45
- return "";
46
- } catch (error) {
47
- return "";
48
- }
49
- }, [match, route]);
50
- return /* @__PURE__ */ jsxs("div", { children: [
51
- /* @__PURE__ */ jsxs(
52
- "div",
53
- {
54
- role: "button",
55
- "aria-label": `Open match details for ${route.id}`,
56
- onClick: () => {
57
- if (match) {
58
- setActiveId(activeId === route.id ? "" : route.id);
59
- }
60
- },
61
- className: clsx(
62
- styles.routesRowContainer(route.id === activeId, !!match)
63
- ),
64
- children: [
65
- /* @__PURE__ */ jsx(
66
- "div",
67
- {
68
- className: clsx(
69
- styles.matchIndicator(getRouteStatusColor(matches, route))
70
- )
71
- }
72
- ),
73
- /* @__PURE__ */ jsxs("div", { className: clsx(styles.routesRow(!!match)), children: [
74
- /* @__PURE__ */ jsxs("div", { children: [
75
- /* @__PURE__ */ jsxs("code", { className: styles.code, children: [
76
- isRoot ? rootRouteId : route.path || trimPath(route.id),
77
- " "
78
- ] }),
79
- /* @__PURE__ */ jsx("code", { className: styles.routeParamInfo, children: param })
80
- ] }),
81
- /* @__PURE__ */ jsx(AgeTicker, { match, router })
82
- ] })
83
- ]
84
- }
85
- ),
86
- ((_a = route.children) == null ? void 0 : _a.length) ? /* @__PURE__ */ jsx("div", { className: styles.nestedRouteRow(!!isRoot), children: [...route.children].sort((a, b) => {
87
- return a.rank - b.rank;
88
- }).map((r) => /* @__PURE__ */ jsx(
89
- RouteComp,
90
- {
91
- router,
92
- route: r,
93
- activeId,
94
- setActiveId
95
- },
96
- r.id
97
- )) }) : null
98
- ] });
99
- }
100
- const BaseTanStackRouterDevtoolsPanel = React__default.forwardRef(function BaseTanStackRouterDevtoolsPanel2(props, ref) {
101
- var _a, _b;
102
- const {
103
- isOpen = true,
104
- setIsOpen,
105
- handleDragStart,
106
- router: userRouter,
107
- shadowDOMTarget,
108
- ...panelProps
109
- } = props;
110
- const { onCloseClick } = useDevtoolsOnClose();
111
- const styles = useStyles();
112
- const { className, ...otherPanelProps } = panelProps;
113
- const contextRouter = useRouter({ warn: false });
114
- const router = userRouter ?? contextRouter;
115
- const routerState = useRouterState({
116
- router
117
- });
118
- invariant(
119
- router,
120
- "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."
121
- );
122
- const [showMatches, setShowMatches] = useLocalStorage(
123
- "tanstackRouterDevtoolsShowMatches",
124
- true
125
- );
126
- const [activeId, setActiveId] = useLocalStorage(
127
- "tanstackRouterDevtoolsActiveRouteId",
128
- ""
129
- );
130
- const activeMatch = React__default.useMemo(() => {
131
- const matches = [
132
- ...routerState.pendingMatches ?? [],
133
- ...routerState.matches,
134
- ...routerState.cachedMatches
135
- ];
136
- return matches.find((d) => d.routeId === activeId || d.id === activeId);
137
- }, [
138
- activeId,
139
- routerState.cachedMatches,
140
- routerState.matches,
141
- routerState.pendingMatches
142
- ]);
143
- const hasSearch = Object.keys(routerState.location.search).length;
144
- const explorerState = {
145
- ...router,
146
- state: router.state
147
- };
148
- return /* @__PURE__ */ jsxs(
149
- "div",
150
- {
151
- ref,
152
- className: clsx(
153
- styles.devtoolsPanel,
154
- "TanStackRouterDevtoolsPanel",
155
- className
156
- ),
157
- ...otherPanelProps,
158
- children: [
159
- handleDragStart ? /* @__PURE__ */ jsx("div", { className: styles.dragHandle, onMouseDown: handleDragStart }) : null,
160
- /* @__PURE__ */ jsx(
161
- "button",
162
- {
163
- className: styles.panelCloseBtn,
164
- onClick: (e) => {
165
- setIsOpen(false);
166
- onCloseClick(e);
167
- },
168
- children: /* @__PURE__ */ jsx(
169
- "svg",
170
- {
171
- xmlns: "http://www.w3.org/2000/svg",
172
- width: "10",
173
- height: "6",
174
- fill: "none",
175
- viewBox: "0 0 10 6",
176
- className: styles.panelCloseBtnIcon,
177
- children: /* @__PURE__ */ jsx(
178
- "path",
179
- {
180
- stroke: "currentColor",
181
- strokeLinecap: "round",
182
- strokeLinejoin: "round",
183
- strokeWidth: "1.667",
184
- d: "M1 1l4 4 4-4"
185
- }
186
- )
187
- }
188
- )
189
- }
190
- ),
191
- /* @__PURE__ */ jsxs("div", { className: styles.firstContainer, children: [
192
- /* @__PURE__ */ jsx("div", { className: styles.row, children: /* @__PURE__ */ jsx(
193
- Logo,
194
- {
195
- "aria-hidden": true,
196
- onClick: (e) => {
197
- setIsOpen(false);
198
- onCloseClick(e);
199
- }
200
- }
201
- ) }),
202
- /* @__PURE__ */ jsx("div", { className: styles.routerExplorerContainer, children: /* @__PURE__ */ jsx("div", { className: styles.routerExplorer, children: /* @__PURE__ */ jsx(
203
- Explorer,
204
- {
205
- label: "Router",
206
- value: Object.fromEntries(
207
- multiSortBy(
208
- Object.keys(explorerState),
209
- [
210
- "state",
211
- "routesById",
212
- "routesByPath",
213
- "flatRoutes",
214
- "options",
215
- "manifest"
216
- ].map((d) => (dd) => dd !== d)
217
- ).map((key) => [key, explorerState[key]]).filter(
218
- (d) => typeof d[1] !== "function" && ![
219
- "__store",
220
- "basepath",
221
- "injectedHtml",
222
- "subscribers",
223
- "latestLoadPromise",
224
- "navigateTimeout",
225
- "resetNextScroll",
226
- "tempLocationKey",
227
- "latestLocation",
228
- "routeTree",
229
- "history"
230
- ].includes(d[0])
231
- )
232
- ),
233
- defaultExpanded: {
234
- state: {},
235
- context: {},
236
- options: {}
237
- },
238
- filterSubEntries: (subEntries) => {
239
- return subEntries.filter((d) => typeof d.value !== "function");
240
- }
241
- }
242
- ) }) })
243
- ] }),
244
- /* @__PURE__ */ jsxs("div", { className: styles.secondContainer, children: [
245
- /* @__PURE__ */ jsxs("div", { className: styles.matchesContainer, children: [
246
- /* @__PURE__ */ jsxs("div", { className: styles.detailsHeader, children: [
247
- /* @__PURE__ */ jsx("span", { children: "Pathname" }),
248
- routerState.location.maskedLocation ? /* @__PURE__ */ jsx("div", { className: styles.maskedBadgeContainer, children: /* @__PURE__ */ jsx("span", { className: styles.maskedBadge, children: "masked" }) }) : null
249
- ] }),
250
- /* @__PURE__ */ jsxs("div", { className: styles.detailsContent, children: [
251
- /* @__PURE__ */ jsx("code", { children: routerState.location.pathname }),
252
- routerState.location.maskedLocation ? /* @__PURE__ */ jsx("code", { className: styles.maskedLocation, children: routerState.location.maskedLocation.pathname }) : null
253
- ] }),
254
- /* @__PURE__ */ jsxs("div", { className: styles.detailsHeader, children: [
255
- /* @__PURE__ */ jsxs("div", { className: styles.routeMatchesToggle, children: [
256
- /* @__PURE__ */ jsx(
257
- "button",
258
- {
259
- type: "button",
260
- onClick: () => {
261
- setShowMatches(false);
262
- },
263
- disabled: !showMatches,
264
- className: clsx(styles.routeMatchesToggleBtn(!showMatches, true)),
265
- children: "Routes"
266
- }
267
- ),
268
- /* @__PURE__ */ jsx(
269
- "button",
270
- {
271
- type: "button",
272
- onClick: () => {
273
- setShowMatches(true);
274
- },
275
- disabled: showMatches,
276
- className: clsx(
277
- styles.routeMatchesToggleBtn(!!showMatches, false)
278
- ),
279
- children: "Matches"
280
- }
281
- )
282
- ] }),
283
- /* @__PURE__ */ jsx("div", { className: styles.detailsHeaderInfo, children: /* @__PURE__ */ jsx("div", { children: "age / staleTime / gcTime" }) })
284
- ] }),
285
- /* @__PURE__ */ jsx("div", { className: clsx(styles.routesContainer), children: !showMatches ? /* @__PURE__ */ jsx(
286
- RouteComp,
287
- {
288
- router,
289
- route: router.routeTree,
290
- isRoot: true,
291
- activeId,
292
- setActiveId
293
- }
294
- ) : /* @__PURE__ */ jsx("div", { children: (((_a = routerState.pendingMatches) == null ? void 0 : _a.length) ? routerState.pendingMatches : routerState.matches).map((match, i) => {
295
- return /* @__PURE__ */ jsxs(
296
- "div",
297
- {
298
- role: "button",
299
- "aria-label": `Open match details for ${match.id}`,
300
- onClick: () => setActiveId(activeId === match.id ? "" : match.id),
301
- className: clsx(styles.matchRow(match === activeMatch)),
302
- children: [
303
- /* @__PURE__ */ jsx(
304
- "div",
305
- {
306
- className: clsx(
307
- styles.matchIndicator(getStatusColor(match))
308
- )
309
- }
310
- ),
311
- /* @__PURE__ */ jsx(
312
- "code",
313
- {
314
- className: styles.matchID,
315
- children: `${match.routeId === rootRouteId ? rootRouteId : match.pathname}`
316
- }
317
- ),
318
- /* @__PURE__ */ jsx(AgeTicker, { match, router })
319
- ]
320
- },
321
- match.id || i
322
- );
323
- }) }) })
324
- ] }),
325
- routerState.cachedMatches.length ? /* @__PURE__ */ jsxs("div", { className: styles.cachedMatchesContainer, children: [
326
- /* @__PURE__ */ jsxs("div", { className: styles.detailsHeader, children: [
327
- /* @__PURE__ */ jsx("div", { children: "Cached Matches" }),
328
- /* @__PURE__ */ jsx("div", { className: styles.detailsHeaderInfo, children: "age / staleTime / gcTime" })
329
- ] }),
330
- /* @__PURE__ */ jsx("div", { children: routerState.cachedMatches.map((match) => {
331
- return /* @__PURE__ */ jsxs(
332
- "div",
333
- {
334
- role: "button",
335
- "aria-label": `Open match details for ${match.id}`,
336
- onClick: () => setActiveId(activeId === match.id ? "" : match.id),
337
- className: clsx(styles.matchRow(match === activeMatch)),
338
- children: [
339
- /* @__PURE__ */ jsx(
340
- "div",
341
- {
342
- className: clsx(
343
- styles.matchIndicator(getStatusColor(match))
344
- )
345
- }
346
- ),
347
- /* @__PURE__ */ jsx("code", { className: styles.matchID, children: `${match.id}` }),
348
- /* @__PURE__ */ jsx(AgeTicker, { match, router })
349
- ]
350
- },
351
- match.id
352
- );
353
- }) })
354
- ] }) : null
355
- ] }),
356
- activeMatch ? /* @__PURE__ */ jsxs("div", { className: styles.thirdContainer, children: [
357
- /* @__PURE__ */ jsx("div", { className: styles.detailsHeader, children: "Match Details" }),
358
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: styles.matchDetails, children: [
359
- /* @__PURE__ */ jsx(
360
- "div",
361
- {
362
- className: styles.matchStatus(
363
- activeMatch.status,
364
- activeMatch.isFetching
365
- ),
366
- children: /* @__PURE__ */ jsx("div", { children: activeMatch.status === "success" && activeMatch.isFetching ? "fetching" : activeMatch.status })
367
- }
368
- ),
369
- /* @__PURE__ */ jsxs("div", { className: styles.matchDetailsInfoLabel, children: [
370
- /* @__PURE__ */ jsx("div", { children: "ID:" }),
371
- /* @__PURE__ */ jsx("div", { className: styles.matchDetailsInfo, children: /* @__PURE__ */ jsx("code", { children: activeMatch.id }) })
372
- ] }),
373
- /* @__PURE__ */ jsxs("div", { className: styles.matchDetailsInfoLabel, children: [
374
- /* @__PURE__ */ jsx("div", { children: "State:" }),
375
- /* @__PURE__ */ jsx("div", { className: styles.matchDetailsInfo, children: ((_b = routerState.pendingMatches) == null ? void 0 : _b.find(
376
- (d) => d.id === activeMatch.id
377
- )) ? "Pending" : routerState.matches.find((d) => d.id === activeMatch.id) ? "Active" : "Cached" })
378
- ] }),
379
- /* @__PURE__ */ jsxs("div", { className: styles.matchDetailsInfoLabel, children: [
380
- /* @__PURE__ */ jsx("div", { children: "Last Updated:" }),
381
- /* @__PURE__ */ jsx("div", { className: styles.matchDetailsInfo, children: activeMatch.updatedAt ? new Date(activeMatch.updatedAt).toLocaleTimeString() : "N/A" })
382
- ] })
383
- ] }) }),
384
- activeMatch.loaderData ? /* @__PURE__ */ jsxs(Fragment, { children: [
385
- /* @__PURE__ */ jsx("div", { className: styles.detailsHeader, children: "Loader Data" }),
386
- /* @__PURE__ */ jsx("div", { className: styles.detailsContent, children: /* @__PURE__ */ jsx(
387
- Explorer,
388
- {
389
- label: "loaderData",
390
- value: activeMatch.loaderData,
391
- defaultExpanded: {}
392
- }
393
- ) })
394
- ] }) : null,
395
- /* @__PURE__ */ jsx("div", { className: styles.detailsHeader, children: "Explorer" }),
396
- /* @__PURE__ */ jsx("div", { className: styles.detailsContent, children: /* @__PURE__ */ jsx(Explorer, { label: "Match", value: activeMatch, defaultExpanded: {} }) })
397
- ] }) : null,
398
- hasSearch ? /* @__PURE__ */ jsxs("div", { className: styles.fourthContainer, children: [
399
- /* @__PURE__ */ jsx("div", { className: styles.detailsHeader, children: "Search Params" }),
400
- /* @__PURE__ */ jsx("div", { className: styles.detailsContent, children: /* @__PURE__ */ jsx(
401
- Explorer,
402
- {
403
- value: routerState.location.search,
404
- defaultExpanded: Object.keys(routerState.location.search).reduce(
405
- (obj, next) => {
406
- obj[next] = {};
407
- return obj;
408
- },
409
- {}
410
- )
411
- }
412
- ) })
413
- ] }) : null
414
- ]
415
- }
416
- );
417
- });
418
- export {
419
- BaseTanStackRouterDevtoolsPanel
420
- };
421
- //# sourceMappingURL=BaseTanStackRouterDevtoolsPanel.js.map