@kylincloud/flamegraph 0.35.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.
Files changed (267) hide show
  1. package/CHANGELOG.md +1211 -0
  2. package/LICENSE +202 -0
  3. package/README.md +251 -0
  4. package/dist/FlameGraph/FlameGraphComponent/CheckIcon.d.ts +2 -0
  5. package/dist/FlameGraph/FlameGraphComponent/CheckIcon.d.ts.map +1 -0
  6. package/dist/FlameGraph/FlameGraphComponent/ContextMenu.d.ts +17 -0
  7. package/dist/FlameGraph/FlameGraphComponent/ContextMenu.d.ts.map +1 -0
  8. package/dist/FlameGraph/FlameGraphComponent/ContextMenuHighlight.d.ts +14 -0
  9. package/dist/FlameGraph/FlameGraphComponent/ContextMenuHighlight.d.ts.map +1 -0
  10. package/dist/FlameGraph/FlameGraphComponent/DiffLegend.d.ts +9 -0
  11. package/dist/FlameGraph/FlameGraphComponent/DiffLegend.d.ts.map +1 -0
  12. package/dist/FlameGraph/FlameGraphComponent/DiffLegendPaletteDropdown.d.ts +8 -0
  13. package/dist/FlameGraph/FlameGraphComponent/DiffLegendPaletteDropdown.d.ts.map +1 -0
  14. package/dist/FlameGraph/FlameGraphComponent/Flamegraph.d.ts +96 -0
  15. package/dist/FlameGraph/FlameGraphComponent/Flamegraph.d.ts.map +1 -0
  16. package/dist/FlameGraph/FlameGraphComponent/Flamegraph_render.d.ts +27 -0
  17. package/dist/FlameGraph/FlameGraphComponent/Flamegraph_render.d.ts.map +1 -0
  18. package/dist/FlameGraph/FlameGraphComponent/GraphVizPane.d.ts +7 -0
  19. package/dist/FlameGraph/FlameGraphComponent/GraphVizPane.d.ts.map +1 -0
  20. package/dist/FlameGraph/FlameGraphComponent/Header.d.ts +12 -0
  21. package/dist/FlameGraph/FlameGraphComponent/Header.d.ts.map +1 -0
  22. package/dist/FlameGraph/FlameGraphComponent/Highlight.d.ts +18 -0
  23. package/dist/FlameGraph/FlameGraphComponent/Highlight.d.ts.map +1 -0
  24. package/dist/FlameGraph/FlameGraphComponent/LogoLink.d.ts +2 -0
  25. package/dist/FlameGraph/FlameGraphComponent/LogoLink.d.ts.map +1 -0
  26. package/dist/FlameGraph/FlameGraphComponent/color.d.ts +20 -0
  27. package/dist/FlameGraph/FlameGraphComponent/color.d.ts.map +1 -0
  28. package/dist/FlameGraph/FlameGraphComponent/colorPalette.d.ts +11 -0
  29. package/dist/FlameGraph/FlameGraphComponent/colorPalette.d.ts.map +1 -0
  30. package/dist/FlameGraph/FlameGraphComponent/constants.d.ts +6 -0
  31. package/dist/FlameGraph/FlameGraphComponent/constants.d.ts.map +1 -0
  32. package/dist/FlameGraph/FlameGraphComponent/index.d.ts +37 -0
  33. package/dist/FlameGraph/FlameGraphComponent/index.d.ts.map +1 -0
  34. package/dist/FlameGraph/FlameGraphComponent/murmur3.d.ts +2 -0
  35. package/dist/FlameGraph/FlameGraphComponent/murmur3.d.ts.map +1 -0
  36. package/dist/FlameGraph/FlameGraphComponent/testData.d.ts +53 -0
  37. package/dist/FlameGraph/FlameGraphComponent/testData.d.ts.map +1 -0
  38. package/dist/FlameGraph/FlameGraphComponent/utils.d.ts +6 -0
  39. package/dist/FlameGraph/FlameGraphComponent/utils.d.ts.map +1 -0
  40. package/dist/FlameGraph/FlameGraphComponent/viewTypes.d.ts +2 -0
  41. package/dist/FlameGraph/FlameGraphComponent/viewTypes.d.ts.map +1 -0
  42. package/dist/FlameGraph/FlameGraphRenderer.d.ts +86 -0
  43. package/dist/FlameGraph/FlameGraphRenderer.d.ts.map +1 -0
  44. package/dist/FlameGraph/decode.d.ts +27 -0
  45. package/dist/FlameGraph/decode.d.ts.map +1 -0
  46. package/dist/FlameGraph/normalize.d.ts +6 -0
  47. package/dist/FlameGraph/normalize.d.ts.map +1 -0
  48. package/dist/FlameGraph/uniqueness.d.ts +3 -0
  49. package/dist/FlameGraph/uniqueness.d.ts.map +1 -0
  50. package/dist/FlamegraphRenderer.d.ts +19 -0
  51. package/dist/FlamegraphRenderer.d.ts.map +1 -0
  52. package/dist/Icons.d.ts +9 -0
  53. package/dist/Icons.d.ts.map +1 -0
  54. package/dist/ProfilerTable.d.ts +21 -0
  55. package/dist/ProfilerTable.d.ts.map +1 -0
  56. package/dist/SharedQueryInput.d.ts +10 -0
  57. package/dist/SharedQueryInput.d.ts.map +1 -0
  58. package/dist/Toolbar.d.ts +31 -0
  59. package/dist/Toolbar.d.ts.map +1 -0
  60. package/dist/Tooltip/FlamegraphTooltip.d.ts +59 -0
  61. package/dist/Tooltip/FlamegraphTooltip.d.ts.map +1 -0
  62. package/dist/Tooltip/LeftClickIcon.d.ts +2 -0
  63. package/dist/Tooltip/LeftClickIcon.d.ts.map +1 -0
  64. package/dist/Tooltip/RightClickIcon.d.ts +2 -0
  65. package/dist/Tooltip/RightClickIcon.d.ts.map +1 -0
  66. package/dist/Tooltip/TableTooltip.d.ts +12 -0
  67. package/dist/Tooltip/TableTooltip.d.ts.map +1 -0
  68. package/dist/Tooltip/Tooltip.d.ts +29 -0
  69. package/dist/Tooltip/Tooltip.d.ts.map +1 -0
  70. package/dist/convert/convertJaegerTraceToProfile.d.ts +3 -0
  71. package/dist/convert/convertJaegerTraceToProfile.d.ts.map +1 -0
  72. package/dist/convert/diffTwoProfiles.d.ts +3 -0
  73. package/dist/convert/diffTwoProfiles.d.ts.map +1 -0
  74. package/dist/convert/flamebearersToTree.d.ts +11 -0
  75. package/dist/convert/flamebearersToTree.d.ts.map +1 -0
  76. package/dist/convert/sandwichViewProfiles.d.ts +14 -0
  77. package/dist/convert/sandwichViewProfiles.d.ts.map +1 -0
  78. package/dist/convert/subtract.d.ts +3 -0
  79. package/dist/convert/subtract.d.ts.map +1 -0
  80. package/dist/convert/testData.d.ts +50 -0
  81. package/dist/convert/testData.d.ts.map +1 -0
  82. package/dist/convert/toGraphviz.d.ts +3 -0
  83. package/dist/convert/toGraphviz.d.ts.map +1 -0
  84. package/dist/fitMode/fitMode.d.ts +42 -0
  85. package/dist/fitMode/fitMode.d.ts.map +1 -0
  86. package/dist/format/format.d.ts +42 -0
  87. package/dist/format/format.d.ts.map +1 -0
  88. package/dist/i18n.d.ts +55 -0
  89. package/dist/i18n.d.ts.map +1 -0
  90. package/dist/index.cjs.css +792 -0
  91. package/dist/index.cjs.js +5087 -0
  92. package/dist/index.d.ts +4 -0
  93. package/dist/index.d.ts.map +1 -0
  94. package/dist/index.esm.css +792 -0
  95. package/dist/index.esm.js +5079 -0
  96. package/dist/index.node.d.ts +9 -0
  97. package/dist/index.node.d.ts.map +1 -0
  98. package/dist/logo-v3-small-T5VXIMRR.svg +32 -0
  99. package/dist/models/decode.d.ts +3 -0
  100. package/dist/models/decode.d.ts.map +1 -0
  101. package/dist/models/flamebearer.d.ts +63 -0
  102. package/dist/models/flamebearer.d.ts.map +1 -0
  103. package/dist/models/groups.d.ts +37 -0
  104. package/dist/models/groups.d.ts.map +1 -0
  105. package/dist/models/index.d.ts +8 -0
  106. package/dist/models/index.d.ts.map +1 -0
  107. package/dist/models/profile.d.ts +152 -0
  108. package/dist/models/profile.d.ts.map +1 -0
  109. package/dist/models/spyName.d.ts +8 -0
  110. package/dist/models/spyName.d.ts.map +1 -0
  111. package/dist/models/trace.d.ts +357 -0
  112. package/dist/models/trace.d.ts.map +1 -0
  113. package/dist/models/units.d.ts +6 -0
  114. package/dist/models/units.d.ts.map +1 -0
  115. package/dist/search.d.ts +2 -0
  116. package/dist/search.d.ts.map +1 -0
  117. package/dist/shims/Box.d.ts +38 -0
  118. package/dist/shims/Box.d.ts.map +1 -0
  119. package/dist/shims/Button.d.ts +26 -0
  120. package/dist/shims/Button.d.ts.map +1 -0
  121. package/dist/shims/Dropdown.d.ts +30 -0
  122. package/dist/shims/Dropdown.d.ts.map +1 -0
  123. package/dist/shims/Input.d.ts +19 -0
  124. package/dist/shims/Input.d.ts.map +1 -0
  125. package/dist/shims/LoadingSpinner.d.ts +7 -0
  126. package/dist/shims/LoadingSpinner.d.ts.map +1 -0
  127. package/dist/shims/Menu.d.ts +4 -0
  128. package/dist/shims/Menu.d.ts.map +1 -0
  129. package/dist/shims/NoData.d.ts +2 -0
  130. package/dist/shims/NoData.d.ts.map +1 -0
  131. package/dist/shims/Table.d.ts +52 -0
  132. package/dist/shims/Table.d.ts.map +1 -0
  133. package/dist/shims/Tooltip.d.ts +9 -0
  134. package/dist/shims/Tooltip.d.ts.map +1 -0
  135. package/package.json +84 -0
  136. package/src/FlameGraph/FlameGraphComponent/CheckIcon.tsx +27 -0
  137. package/src/FlameGraph/FlameGraphComponent/ContextMenu.module.scss +10 -0
  138. package/src/FlameGraph/FlameGraphComponent/ContextMenu.spec.tsx +84 -0
  139. package/src/FlameGraph/FlameGraphComponent/ContextMenu.tsx +86 -0
  140. package/src/FlameGraph/FlameGraphComponent/ContextMenuHighlight.module.css +8 -0
  141. package/src/FlameGraph/FlameGraphComponent/ContextMenuHighlight.tsx +47 -0
  142. package/src/FlameGraph/FlameGraphComponent/DiffLegend.module.css +21 -0
  143. package/src/FlameGraph/FlameGraphComponent/DiffLegend.tsx +52 -0
  144. package/src/FlameGraph/FlameGraphComponent/DiffLegendPaletteDropdown.module.css +40 -0
  145. package/src/FlameGraph/FlameGraphComponent/DiffLegendPaletteDropdown.tsx +129 -0
  146. package/src/FlameGraph/FlameGraphComponent/Flamegraph.spec.ts +552 -0
  147. package/src/FlameGraph/FlameGraphComponent/Flamegraph.ts +446 -0
  148. package/src/FlameGraph/FlameGraphComponent/Flamegraph_render.spec.tsx +233 -0
  149. package/src/FlameGraph/FlameGraphComponent/Flamegraph_render.ts +478 -0
  150. package/src/FlameGraph/FlameGraphComponent/GraphVizPane.tsx +56 -0
  151. package/src/FlameGraph/FlameGraphComponent/GraphVizPanel.module.scss +55 -0
  152. package/src/FlameGraph/FlameGraphComponent/Header.module.css +27 -0
  153. package/src/FlameGraph/FlameGraphComponent/Header.tsx +71 -0
  154. package/src/FlameGraph/FlameGraphComponent/Highlight.module.css +7 -0
  155. package/src/FlameGraph/FlameGraphComponent/Highlight.spec.tsx +53 -0
  156. package/src/FlameGraph/FlameGraphComponent/Highlight.tsx +94 -0
  157. package/src/FlameGraph/FlameGraphComponent/LogoLink.module.scss +10 -0
  158. package/src/FlameGraph/FlameGraphComponent/LogoLink.tsx +101 -0
  159. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/canvas-renderer-spec-tsx-canvas-renderer-group-snapshot-collapses-small-blocks-into-one-1-snap.png +0 -0
  160. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/canvas-renderer-spec-tsx-canvas-renderer-group-snapshot-works-with-diff-mode-1-snap.png +0 -0
  161. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/canvas-renderer-spec-tsx-canvas-renderer-group-snapshot-works-with-highlighted-flamegraph-1-snap.png +0 -0
  162. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/canvas-renderer-spec-tsx-canvas-renderer-group-snapshot-works-with-normal-flamegraph-1-snap.png +0 -0
  163. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/canvas-renderer-spec-tsx-canvas-renderer-group-snapshot-works-with-selected-node-1-snap.png +0 -0
  164. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-focused-also-zooms-1-snap.png +0 -0
  165. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-focused-renders-a-focused-node-in-the-beginning-1-snap.png +0 -0
  166. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-focused-renders-a-focused-node-when-node-is-not-in-the-beginning-1-snap.png +0 -0
  167. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-focused-renders-a-focused-node-zoom-top-level-1-snap.png +0 -0
  168. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-complex-flamegraph-1-snap.png +0 -0
  169. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-double-diff-flamegraph-1-snap.png +0 -0
  170. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-highlighted-double-flamegraph-1-snap.png +0 -0
  171. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-highlighted-flamegraph-1-snap.png +0 -0
  172. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-simple-flamegraph-1-snap.png +0 -0
  173. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-simple-tree-1-snap.png +0 -0
  174. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-zoomed-flamegraph-1-snap.png +0 -0
  175. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-zoomed-with-fit-mode-tail-1-snap.png +0 -0
  176. package/src/FlameGraph/FlameGraphComponent/canvas.module.css +6 -0
  177. package/src/FlameGraph/FlameGraphComponent/color.spec.ts +308 -0
  178. package/src/FlameGraph/FlameGraphComponent/color.ts +167 -0
  179. package/src/FlameGraph/FlameGraphComponent/colorPalette.ts +58 -0
  180. package/src/FlameGraph/FlameGraphComponent/constants.ts +5 -0
  181. package/src/FlameGraph/FlameGraphComponent/index.spec.tsx +291 -0
  182. package/src/FlameGraph/FlameGraphComponent/index.tsx +411 -0
  183. package/src/FlameGraph/FlameGraphComponent/murmur3.ts +97 -0
  184. package/src/FlameGraph/FlameGraphComponent/styles.module.scss +10 -0
  185. package/src/FlameGraph/FlameGraphComponent/testData.ts +427 -0
  186. package/src/FlameGraph/FlameGraphComponent/utils.ts +31 -0
  187. package/src/FlameGraph/FlameGraphComponent/viewTypes.ts +6 -0
  188. package/src/FlameGraph/FlameGraphRenderer.tsx +603 -0
  189. package/src/FlameGraph/FlamegraphRenderer.module.scss +93 -0
  190. package/src/FlameGraph/decode.ts +78 -0
  191. package/src/FlameGraph/normalize.spec.ts +76 -0
  192. package/src/FlameGraph/normalize.ts +60 -0
  193. package/src/FlameGraph/testData.json +423 -0
  194. package/src/FlameGraph/uniqueness.spec.ts +16 -0
  195. package/src/FlameGraph/uniqueness.ts +84 -0
  196. package/src/FlamegraphRenderer.tsx +61 -0
  197. package/src/Icons.tsx +74 -0
  198. package/src/ProfilerTable.tsx +527 -0
  199. package/src/SharedQueryInput.module.scss +82 -0
  200. package/src/SharedQueryInput.tsx +127 -0
  201. package/src/Toolbar.module.scss +117 -0
  202. package/src/Toolbar.spec.tsx +217 -0
  203. package/src/Toolbar.tsx +471 -0
  204. package/src/Tooltip/FlamegraphTooltip.spec.tsx +81 -0
  205. package/src/Tooltip/FlamegraphTooltip.tsx +257 -0
  206. package/src/Tooltip/LeftClickIcon.tsx +18 -0
  207. package/src/Tooltip/RightClickIcon.tsx +18 -0
  208. package/src/Tooltip/TableTooltip.spec.tsx +44 -0
  209. package/src/Tooltip/TableTooltip.tsx +145 -0
  210. package/src/Tooltip/Tooltip.module.scss +71 -0
  211. package/src/Tooltip/Tooltip.spec.tsx +395 -0
  212. package/src/Tooltip/Tooltip.tsx +336 -0
  213. package/src/__snapshots__/Toolbar.spec.tsx.snap +297 -0
  214. package/src/convert/convertJaegerTraceToProfile.ts +97 -0
  215. package/src/convert/diffTwoProfiles.ts +81 -0
  216. package/src/convert/flamebearersToTree.ts +78 -0
  217. package/src/convert/sandwichViewProfiles.spec.ts +65 -0
  218. package/src/convert/sandwichViewProfiles.ts +191 -0
  219. package/src/convert/subtract.ts +87 -0
  220. package/src/convert/testData.ts +145 -0
  221. package/src/convert/toGraphviz.ts +485 -0
  222. package/src/fitMode/fitMode.spec.ts +93 -0
  223. package/src/fitMode/fitMode.ts +122 -0
  224. package/src/format/format.spec.ts +291 -0
  225. package/src/format/format.ts +303 -0
  226. package/src/globals.d.ts +13 -0
  227. package/src/i18n.tsx +293 -0
  228. package/src/index.node.ts +19 -0
  229. package/src/index.spec.tsx +383 -0
  230. package/src/index.tsx +10 -0
  231. package/src/logo-v3-small.svg +32 -0
  232. package/src/models/decode.ts +45 -0
  233. package/src/models/flamebearer.ts +86 -0
  234. package/src/models/groups.ts +14 -0
  235. package/src/models/index.ts +7 -0
  236. package/src/models/profile.spec.ts +32 -0
  237. package/src/models/profile.ts +48 -0
  238. package/src/models/spyName.spec.ts +18 -0
  239. package/src/models/spyName.ts +32 -0
  240. package/src/models/trace.ts +45 -0
  241. package/src/models/units.spec.ts +21 -0
  242. package/src/models/units.ts +24 -0
  243. package/src/sass/_common.scss +206 -0
  244. package/src/sass/_css-variables.scss +201 -0
  245. package/src/sass/_mixins.scss +15 -0
  246. package/src/sass/_sanitize.scss +407 -0
  247. package/src/sass/_variables.scss +53 -0
  248. package/src/sass/flamegraph.scss +18 -0
  249. package/src/search.spec.ts +11 -0
  250. package/src/search.ts +4 -0
  251. package/src/shameful-any.d.ts +2 -0
  252. package/src/shims/Box.module.scss +57 -0
  253. package/src/shims/Box.tsx +105 -0
  254. package/src/shims/Button.module.scss +129 -0
  255. package/src/shims/Button.tsx +128 -0
  256. package/src/shims/Dropdown.module.scss +63 -0
  257. package/src/shims/Dropdown.tsx +96 -0
  258. package/src/shims/Input.module.scss +15 -0
  259. package/src/shims/Input.tsx +55 -0
  260. package/src/shims/LoadingSpinner.tsx +19 -0
  261. package/src/shims/Menu.tsx +9 -0
  262. package/src/shims/NoData.module.scss +6 -0
  263. package/src/shims/NoData.tsx +11 -0
  264. package/src/shims/Table.module.scss +82 -0
  265. package/src/shims/Table.spec.tsx +121 -0
  266. package/src/shims/Table.tsx +252 -0
  267. package/src/shims/Tooltip.tsx +51 -0
@@ -0,0 +1,336 @@
1
+ // src/Tooltip/Tooltip.tsx
2
+ import React, {
3
+ CSSProperties,
4
+ RefObject,
5
+ ReactNode,
6
+ useEffect,
7
+ useState,
8
+ useRef,
9
+ useCallback,
10
+ Dispatch,
11
+ SetStateAction,
12
+ } from 'react';
13
+ import clsx from 'clsx';
14
+ import type { Units } from '../models';
15
+
16
+ import RightClickIcon from './RightClickIcon';
17
+ import LeftClickIcon from './LeftClickIcon';
18
+
19
+ import styles from './Tooltip.module.scss';
20
+ import { useFlamegraphI18n } from '../i18n';
21
+
22
+ export type TooltipData = {
23
+ units: Units;
24
+ percent?: string | number;
25
+ samples?: string;
26
+ formattedValue?: string;
27
+ self?: string;
28
+ total?: string;
29
+ tooltipType: 'table' | 'flamegraph';
30
+ };
31
+
32
+ export interface TooltipProps {
33
+ // canvas or table body ref
34
+ dataSourceRef: RefObject<HTMLCanvasElement | HTMLTableSectionElement>;
35
+
36
+ shouldShowFooter?: boolean;
37
+ shouldShowTitle?: boolean;
38
+ clickInfoSide?: 'left' | 'right';
39
+
40
+ setTooltipContent: (
41
+ setContent: Dispatch<
42
+ SetStateAction<{
43
+ title: {
44
+ text: string;
45
+ diff: {
46
+ text: string;
47
+ color: string;
48
+ };
49
+ };
50
+ tooltipData: TooltipData[];
51
+ }>
52
+ >,
53
+ onMouseOut: () => void,
54
+ e: MouseEvent
55
+ ) => void;
56
+ }
57
+
58
+ export function Tooltip({
59
+ shouldShowFooter = true,
60
+ shouldShowTitle = true,
61
+ dataSourceRef,
62
+ clickInfoSide,
63
+ setTooltipContent,
64
+ }: TooltipProps) {
65
+ const tooltipRef = useRef<HTMLDivElement>(null);
66
+ const [content, setContent] = React.useState({
67
+ title: {
68
+ text: '',
69
+ diff: {
70
+ text: '',
71
+ color: '',
72
+ },
73
+ },
74
+ tooltipData: [] as TooltipData[],
75
+ });
76
+ const [style, setStyle] = useState<CSSProperties>();
77
+
78
+ const onMouseOut = () => {
79
+ setStyle({
80
+ visibility: 'hidden',
81
+ });
82
+ setContent({
83
+ title: {
84
+ text: '',
85
+ diff: {
86
+ text: '',
87
+ color: '',
88
+ },
89
+ },
90
+ tooltipData: [],
91
+ });
92
+ };
93
+
94
+ const memoizedOnMouseMove = useCallback(
95
+ (e: MouseEvent) => {
96
+ if (!tooltipRef || !tooltipRef.current) {
97
+ throw new Error('Missing tooltipElement');
98
+ }
99
+
100
+ const left = Math.min(
101
+ e.clientX + 12,
102
+ window.innerWidth - tooltipRef.current.clientWidth - 20
103
+ );
104
+ const top = e.clientY + 20;
105
+
106
+ const style: React.CSSProperties = {
107
+ top,
108
+ left,
109
+ visibility: 'visible',
110
+ };
111
+
112
+ setTooltipContent(setContent, onMouseOut, e);
113
+ setStyle(style);
114
+ },
115
+
116
+ // these are the dependencies from props
117
+ // that are going to be used in onMouseMove
118
+ [tooltipRef, setTooltipContent]
119
+ );
120
+
121
+ useEffect(() => {
122
+ const dataSourceEl = dataSourceRef.current;
123
+ if (!dataSourceEl) {
124
+ return () => {};
125
+ }
126
+
127
+ dataSourceEl.addEventListener(
128
+ 'mousemove',
129
+ memoizedOnMouseMove as EventListener
130
+ );
131
+ dataSourceEl.addEventListener('mouseout', onMouseOut);
132
+
133
+ return () => {
134
+ dataSourceEl.removeEventListener(
135
+ 'mousemove',
136
+ memoizedOnMouseMove as EventListener
137
+ );
138
+ dataSourceEl.removeEventListener('mouseout', onMouseOut);
139
+ };
140
+ }, [dataSourceRef.current, memoizedOnMouseMove]);
141
+
142
+ return (
143
+ <div
144
+ data-testid="tooltip"
145
+ className={clsx(styles.tooltip, {
146
+ [styles.flamegraphDiffTooltip]: content.tooltipData.length > 1,
147
+ })}
148
+ style={style}
149
+ ref={tooltipRef}
150
+ >
151
+ {content.tooltipData.length > 0 && (
152
+ <>
153
+ {shouldShowTitle && (
154
+ <div className={styles.tooltipName} data-testid="tooltip-title">
155
+ {content.title.text}
156
+ </div>
157
+ )}
158
+ <div
159
+ className={styles.functionName}
160
+ data-testid="tooltip-function-name"
161
+ >
162
+ {content.title.text}
163
+ </div>
164
+ {content.title.diff.text.length > 0 ? (
165
+ <TooltipTable
166
+ data={content.tooltipData}
167
+ diff={content.title.diff}
168
+ />
169
+ ) : (
170
+ <TooltipTable data={content.tooltipData} />
171
+ )}
172
+ {shouldShowFooter && <TooltipFooter clickInfoSide={clickInfoSide} />}
173
+ </>
174
+ )}
175
+ </div>
176
+ );
177
+ }
178
+
179
+ function TooltipTable({
180
+ data,
181
+ diff,
182
+ }: {
183
+ data: TooltipData[];
184
+ diff?: { text: string; color: string };
185
+ }) {
186
+ const i18n = useFlamegraphI18n();
187
+ const [baselineData, comparisonData] = data;
188
+
189
+ if (!baselineData) {
190
+ return null;
191
+ }
192
+
193
+ let renderTable: () => ReactNode;
194
+
195
+ switch (baselineData.tooltipType) {
196
+ case 'flamegraph':
197
+ renderTable = () => (
198
+ <>
199
+ {comparisonData && (
200
+ <thead>
201
+ <tr>
202
+ <th />
203
+ <th>{i18n.baseline}</th>
204
+ <th>{i18n.comparison}</th>
205
+ <th>{i18n.diff}</th>
206
+ </tr>
207
+ </thead>
208
+ )}
209
+ <tbody>
210
+ <tr>
211
+ <td>
212
+ {i18n.tooltipUnitTitles[baselineData.units].percent}:
213
+ </td>
214
+ <td>{baselineData.percent}</td>
215
+ {comparisonData && (
216
+ <>
217
+ <td>{comparisonData.percent}</td>
218
+ <td>
219
+ {diff && (
220
+ <span
221
+ data-testid="tooltip-diff"
222
+ style={{ color: diff.color }}
223
+ >
224
+ {diff.text}
225
+ </span>
226
+ )}
227
+ </td>
228
+ </>
229
+ )}
230
+ </tr>
231
+ <tr>
232
+ <td>
233
+ {i18n.tooltipUnitTitles[baselineData.units].formattedValue}:
234
+ </td>
235
+ <td>{baselineData.formattedValue}</td>
236
+ {comparisonData && (
237
+ <>
238
+ <td>{comparisonData.formattedValue}</td>
239
+ <td />
240
+ </>
241
+ )}
242
+ </tr>
243
+ <tr>
244
+ <td>{i18n.tooltipSamples}</td>
245
+ <td>{baselineData.samples}</td>
246
+ {comparisonData && (
247
+ <>
248
+ <td>{comparisonData.samples}</td>
249
+ <td />
250
+ </>
251
+ )}
252
+ </tr>
253
+ </tbody>
254
+ </>
255
+ );
256
+ break;
257
+ case 'table':
258
+ renderTable = () => (
259
+ <>
260
+ <thead>
261
+ <tr>
262
+ <td />
263
+ <td>
264
+ {i18n.self} (
265
+ {i18n.tooltipUnitTitles[baselineData.units].total})
266
+ </td>
267
+ <td>
268
+ {i18n.total} (
269
+ {i18n.tooltipUnitTitles[baselineData.units].total})
270
+ </td>
271
+ </tr>
272
+ </thead>
273
+ <tbody>
274
+ <tr>
275
+ <td>
276
+ {i18n.tooltipUnitTitles[baselineData.units].formattedValue}:
277
+ </td>
278
+ <td>{baselineData.self}</td>
279
+ <td>{baselineData.total}</td>
280
+ </tr>
281
+ </tbody>
282
+ </>
283
+ );
284
+ break;
285
+ default:
286
+ renderTable = () => null;
287
+ }
288
+
289
+ return (
290
+ <table
291
+ data-testid="tooltip-table"
292
+ className={clsx(styles.tooltipTable, {
293
+ [styles[`${baselineData.tooltipType}${comparisonData ? 'Diff' : ''}`]]:
294
+ baselineData.tooltipType,
295
+ })}
296
+ >
297
+ {renderTable()}
298
+ </table>
299
+ );
300
+ }
301
+
302
+ function TooltipFooter({
303
+ clickInfoSide,
304
+ }: {
305
+ clickInfoSide?: 'left' | 'right';
306
+ }) {
307
+ const i18n = useFlamegraphI18n();
308
+ let clickInfo: ReactNode;
309
+
310
+ switch (clickInfoSide) {
311
+ case 'right':
312
+ clickInfo = (
313
+ <>
314
+ <RightClickIcon />
315
+ <span>{i18n.rightClickForMoreNodeOptions}</span>
316
+ </>
317
+ );
318
+ break;
319
+ case 'left':
320
+ clickInfo = (
321
+ <>
322
+ <LeftClickIcon />
323
+ <span>{i18n.clickToHighlightNode}</span>
324
+ </>
325
+ );
326
+ break;
327
+ default:
328
+ clickInfo = <></>;
329
+ }
330
+
331
+ return (
332
+ <div data-testid="tooltip-footer" className={styles.clickInfo}>
333
+ {clickInfo}
334
+ </div>
335
+ );
336
+ }
@@ -0,0 +1,297 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ProfileHeader should render toolbar correctly 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ role="toolbar"
7
+ >
8
+ <div
9
+ class="navbar"
10
+ >
11
+ <div>
12
+ <div
13
+ class="wrapper"
14
+ style="width: 175px;"
15
+ >
16
+ <input
17
+ class="input search "
18
+ data-testid="flamegraph-search"
19
+ name="flamegraph-search"
20
+ placeholder="Search…"
21
+ type="search"
22
+ value=""
23
+ />
24
+ </div>
25
+ </div>
26
+ <div>
27
+ <div
28
+ class="itemsContainer"
29
+ >
30
+ <div
31
+ class="item"
32
+ style="width: 93px;"
33
+ >
34
+ <button
35
+ aria-label="Head first"
36
+ class="button default fitModeButton selected noIcon"
37
+ data-mui-internal-clone-element="true"
38
+ type="button"
39
+ >
40
+ <svg
41
+ viewBox="0 0 64 64"
42
+ xmlns="http://www.w3.org/2000/svg"
43
+ >
44
+ <g
45
+ id="ab_shape"
46
+ >
47
+ <g>
48
+ <path
49
+ d="M16.71,41l-.42-2.45h-.16c-1.63,1.95-4.06,2.95-6.91,2.95-4.8,0-7.86-3.45-7.86-7.45,0-6.4,6.01-9.3,14.13-9.3v-.4c0-1.5-.84-3.2-4.38-3.2-2.48,0-4.9,.75-6.54,1.7l-1.42-4.75c1.69-.9,5.01-2.1,9.44-2.1,8.33,0,10.65,4.95,10.65,10.45v8.7c0,2.25,.11,4.4,.37,5.85h-6.91Zm-.95-11.7c-3.64,0-6.91,.9-6.91,4,0,2.1,1.37,3,3,3s3.22-1.05,3.74-2.6c.11-.35,.16-.8,.16-1.2v-3.2Z"
50
+ />
51
+ <path
52
+ d="M29.36,41c.11-1.79,.21-4.62,.21-7.25V6h7.7v13.46h.11c1.42-1.99,3.8-3.28,7.06-3.28,5.85,0,9.7,5.01,9.65,12.16,0,8.69-5.22,13.16-10.81,13.16-2.74,0-5.22-.99-6.91-3.72h-.11l-.37,3.23h-6.54Zm7.91-9.83c0,.55,.05,.99,.16,1.39,.58,1.94,2.16,3.18,4.01,3.18,3.11,0,4.9-2.53,4.9-7,0-3.92-1.58-6.8-4.9-6.8-1.85,0-3.53,1.39-3.95,3.28-.16,.4-.21,.94-.21,1.44v4.52Z"
53
+ />
54
+ </g>
55
+ </g>
56
+ <g
57
+ id="arrows"
58
+ >
59
+ <polygon
60
+ points="62 54 52 45 52 51 35 51 35 57 52 57 52 63 62 54"
61
+ />
62
+ </g>
63
+ </svg>
64
+ </button>
65
+ <button
66
+ aria-label="Tail first"
67
+ class="button default fitModeButton noIcon"
68
+ data-mui-internal-clone-element="true"
69
+ type="button"
70
+ >
71
+ <svg
72
+ viewBox="0 0 64 64"
73
+ xmlns="http://www.w3.org/2000/svg"
74
+ >
75
+ <g
76
+ id="yz_shape"
77
+ >
78
+ <g>
79
+ <path
80
+ d="M22.75,13l3.43,12.39c.42,1.47,.84,3.2,1.16,4.52h.11c.32-1.32,.69-3.05,1-4.47l2.9-12.44h8.01l-5.8,17.16c-2.95,8.33-5.17,12.54-8.07,15.23-2.58,2.39-5.43,3.3-7.17,3.55l-1.85-6.3c1.11-.25,2.32-.76,3.48-1.52,1.16-.71,2.32-1.88,2.95-3.05,.26-.41,.42-.76,.42-1.12,0-.31-.05-.66-.26-1.17L14.32,13h8.43Z"
81
+ />
82
+ <path
83
+ d="M41.62,33.46l7.59-10.16c1.27-1.57,2.37-2.95,3.58-4.27v-.15h-10.33v-5.89h19.45l-.05,4.57-7.28,9.8c-1.21,1.57-2.48,3.15-3.69,4.42v.1h11.33v5.94h-20.61v-4.37Z"
84
+ />
85
+ </g>
86
+ </g>
87
+ <g
88
+ id="arrows"
89
+ >
90
+ <polygon
91
+ points="12 51 12 45 2 54 12 63 12 57 29 57 29 51 12 51"
92
+ />
93
+ </g>
94
+ </svg>
95
+ </button>
96
+ <div
97
+ class="divider"
98
+ />
99
+ </div>
100
+ <div
101
+ class="item"
102
+ style="width: 44px;"
103
+ >
104
+ <span
105
+ aria-label="Reset View"
106
+ class=""
107
+ data-mui-internal-clone-element="true"
108
+ >
109
+ <button
110
+ aria-label="Reset View"
111
+ class="button default resetViewButton noIcon"
112
+ disabled=""
113
+ id="reset"
114
+ type="button"
115
+ >
116
+ <svg
117
+ aria-hidden="true"
118
+ class="svg-inline--fa fa-undo fa-w-16 "
119
+ data-icon="undo"
120
+ data-prefix="fas"
121
+ focusable="false"
122
+ role="img"
123
+ viewBox="0 0 512 512"
124
+ xmlns="http://www.w3.org/2000/svg"
125
+ >
126
+ <path
127
+ d="M212.333 224.333H12c-6.627 0-12-5.373-12-12V12C0 5.373 5.373 0 12 0h48c6.627 0 12 5.373 12 12v78.112C117.773 39.279 184.26 7.47 258.175 8.007c136.906.994 246.448 111.623 246.157 248.532C504.041 393.258 393.12 504 256.333 504c-64.089 0-122.496-24.313-166.51-64.215-5.099-4.622-5.334-12.554-.467-17.42l33.967-33.967c4.474-4.474 11.662-4.717 16.401-.525C170.76 415.336 211.58 432 256.333 432c97.268 0 176-78.716 176-176 0-97.267-78.716-176-176-176-58.496 0-110.28 28.476-142.274 72.333h98.274c6.627 0 12 5.373 12 12v48c0 6.627-5.373 12-12 12z"
128
+ fill="currentColor"
129
+ />
130
+ </svg>
131
+ </button>
132
+ </span>
133
+ </div>
134
+ <div
135
+ class="item"
136
+ style="width: 49px;"
137
+ >
138
+ <div
139
+ aria-label="Collapse nodes above"
140
+ class=""
141
+ data-mui-internal-clone-element="true"
142
+ >
143
+ <button
144
+ aria-label="Collapse nodes above"
145
+ class="button default collapseNodeButton noIcon"
146
+ disabled=""
147
+ type="button"
148
+ >
149
+ <svg
150
+ aria-hidden="true"
151
+ class="svg-inline--fa fa-compress-alt fa-w-14 "
152
+ data-icon="compress-alt"
153
+ data-prefix="fas"
154
+ focusable="false"
155
+ role="img"
156
+ viewBox="0 0 448 512"
157
+ xmlns="http://www.w3.org/2000/svg"
158
+ >
159
+ <path
160
+ d="M4.686 427.314L104 328l-32.922-31.029C55.958 281.851 66.666 256 88.048 256h112C213.303 256 224 266.745 224 280v112c0 21.382-25.803 32.09-40.922 16.971L152 376l-99.314 99.314c-6.248 6.248-16.379 6.248-22.627 0L4.686 449.941c-6.248-6.248-6.248-16.379 0-22.627zM443.314 84.686L344 184l32.922 31.029c15.12 15.12 4.412 40.971-16.97 40.971h-112C234.697 256 224 245.255 224 232V120c0-21.382 25.803-32.09 40.922-16.971L296 136l99.314-99.314c6.248-6.248 16.379-6.248 22.627 0l25.373 25.373c6.248 6.248 6.248 16.379 0 22.627z"
161
+ fill="currentColor"
162
+ />
163
+ </svg>
164
+ </button>
165
+ </div>
166
+ <div
167
+ class="divider"
168
+ />
169
+ </div>
170
+ <div
171
+ class="item"
172
+ style="width: 220px;"
173
+ >
174
+ <div
175
+ class="viewType"
176
+ >
177
+ <button
178
+ aria-label="Table"
179
+ class="button default toggleViewButton noIcon"
180
+ data-mui-internal-clone-element="true"
181
+ data-testid="table"
182
+ type="button"
183
+ >
184
+ <svg
185
+ viewBox="0 0 64 64"
186
+ xmlns="http://www.w3.org/2000/svg"
187
+ >
188
+ <g
189
+ id="z9nPJj.tif"
190
+ >
191
+ <path
192
+ d="M62,13.33V49.68c-.02,.05-.04,.11-.05,.16-.3,2.66-2.66,5.16-6.08,5.15-15.92,0-31.83,0-47.75-.01-.54,0-1.1-.06-1.62-.19-2.73-.69-4.52-3.09-4.52-5.88,0-12,.01-23.56,.01-34.9,0-.29,.01-.57,.05-.86,.35-2.3,1.62-3.91,3.84-4.75,.6-.23,1.27-.28,1.9-.41,16.13,0,32.27,0,48.4,0,.09,.01,.17,.04,.26,.04,2.66,.21,4.8,2.01,5.4,4.57,.06,.24,.1,.48,.14,.72ZM28.99,31.81c0-3.92-.01-7.91-.01-11.81H8c0,3.91,.01,7.9,.01,11.81H28.99Zm27,0c0-3.92-.01-7.92-.01-11.81h-20.97c0,3.92,.01,7.91,.01,11.81h20.97Zm-47.98,5.19c0,3.7,0,8,0,11.69v.31H29v-12m6.01,.04c0,3.93-.01,8.05-.01,11.96h20.99c0-.12,0-.22,0-.31,0-3.7,0-7.99,0-11.69"
193
+ />
194
+ </g>
195
+ </svg>
196
+ </button>
197
+ <button
198
+ aria-label="Table and Flamegraph"
199
+ class="button default toggleViewButton selected noIcon"
200
+ data-mui-internal-clone-element="true"
201
+ data-testid="both"
202
+ type="button"
203
+ >
204
+ <svg
205
+ viewBox="0 0 64 64"
206
+ xmlns="http://www.w3.org/2000/svg"
207
+ >
208
+ <path
209
+ d="M31,8.04H7.62c-.61,.13-1.26,.18-1.84,.41-2.14,.84-3.37,2.45-3.71,4.75-.04,.28-.05,.57-.05,.86,0,11.32-.02,22.88-.01,34.87,0,2.79,1.73,5.18,4.37,5.88,.51,.13,1.04,.19,1.57,.19,7.69,0,15.38,0,23.07,0V8.04Zm-2.92,11.99c0,3.9,.01,7.89,.01,11.8H7.82c0-3.9-.01-7.89-.01-11.8H28.08ZM7.82,49.01v-.31c0-3.69,0-7.99,0-11.68H28.1v11.99H7.82Z"
210
+ />
211
+ <path
212
+ d="M58.67,7.9h-25.67V55h2.9c1.84,0,2.9-1.55,2.9-3.45V27.14h11.6v6.37c0,1.91,1.49,3.45,3.33,3.45h4.94c1.84,0,3.33-1.55,3.33-3.45V11.35c0-1.91-1.49-3.45-3.33-3.45Z"
213
+ />
214
+ </svg>
215
+ </button>
216
+ <button
217
+ aria-label="Flamegraph"
218
+ class="button default toggleViewButton noIcon"
219
+ data-mui-internal-clone-element="true"
220
+ data-testid="flamegraph"
221
+ type="button"
222
+ >
223
+ <svg
224
+ viewBox="0 0 64 64"
225
+ xmlns="http://www.w3.org/2000/svg"
226
+ >
227
+ <path
228
+ d="M5.44,8H58.56c1.9,0,3.44,1.54,3.44,3.44v6.16s0,9.6,0,9.6v6.36c0,1.9-1.54,3.44-3.44,3.44h-5.11c-1.9,0-3.44-1.54-3.44-3.44v-6.36h-12s0,9.8,0,9.8v9s0,5.56,0,5.56c0,1.9-1.1,3.44-3,3.44h-6c-1.9,0-3-1.54-3-3.44v-5.56h-9c-1.99,0-3-1.52-3-3.4v-5.6H5.44c-1.9,0-3.44-1.74-3.44-3.64v-6.16s0-9.6,0-9.6v-6.16c0-1.9,1.54-3.44,3.44-3.44Z"
229
+ />
230
+ </svg>
231
+ </button>
232
+ <button
233
+ aria-label="Sandwich"
234
+ class="button default toggleViewButton noIcon"
235
+ data-mui-internal-clone-element="true"
236
+ data-testid="sandwich"
237
+ type="button"
238
+ >
239
+ <svg
240
+ viewBox="0 0 64 64"
241
+ xmlns="http://www.w3.org/2000/svg"
242
+ >
243
+ <g
244
+ id="shape_squiggle"
245
+ >
246
+ <path
247
+ d="M60,38.42c-4.62,0-6.97-2.64-8.86-4.75-1.81-2.03-2.86-3.08-5.13-3.08s-3.32,1.06-5.13,3.08c-1.89,2.12-4.24,4.75-8.86,4.75s-6.97-2.64-8.87-4.75c-1.81-2.03-2.86-3.08-5.14-3.08s-3.33,1.06-5.14,3.08c-1.89,2.12-4.25,4.75-8.87,4.75-1.38,0-2.5-1.12-2.5-2.5s1.12-2.5,2.5-2.5c2.28,0,3.33-1.06,5.14-3.09,1.89-2.12,4.25-4.75,8.87-4.75s6.97,2.64,8.87,4.75c1.81,2.03,2.86,3.09,5.14,3.09s3.32-1.06,5.13-3.08c1.89-2.12,4.24-4.75,8.86-4.75s6.97,2.64,8.86,4.75c1.81,2.03,2.86,3.08,5.13,3.08,1.38,0,2.5,1.12,2.5,2.5s-1.12,2.5-2.5,2.5Z"
248
+ />
249
+ </g>
250
+ <g
251
+ id="Layer_4"
252
+ >
253
+ <rect
254
+ height="14"
255
+ rx="3.94"
256
+ ry="3.94"
257
+ width="60"
258
+ x="2"
259
+ y="8"
260
+ />
261
+ <path
262
+ d="M58.06,41h-18.64c-1.58,0-3.14,.42-4.5,1.22l-6.88,4.02c-1.87,1.09-4.19,1.09-6.06,0l-6.88-4.02c-1.37-.8-2.92-1.22-4.5-1.22H5.94c-2.18,0-3.94,1.76-3.94,3.94v7.12c0,2.18,1.76,3.94,3.94,3.94H58.06c2.18,0,3.94-1.76,3.94-3.94v-7.12c0-2.18-1.76-3.94-3.94-3.94Z"
263
+ />
264
+ </g>
265
+ </svg>
266
+ </button>
267
+ <button
268
+ aria-label="GraphViz"
269
+ class="button default toggleViewButton noIcon"
270
+ data-mui-internal-clone-element="true"
271
+ data-testid="graphviz"
272
+ type="button"
273
+ >
274
+ <svg
275
+ aria-hidden="true"
276
+ class="svg-inline--fa fa-project-diagram fa-w-20 "
277
+ data-icon="project-diagram"
278
+ data-prefix="fas"
279
+ focusable="false"
280
+ role="img"
281
+ viewBox="0 0 640 512"
282
+ xmlns="http://www.w3.org/2000/svg"
283
+ >
284
+ <path
285
+ d="M384 320H256c-17.67 0-32 14.33-32 32v128c0 17.67 14.33 32 32 32h128c17.67 0 32-14.33 32-32V352c0-17.67-14.33-32-32-32zM192 32c0-17.67-14.33-32-32-32H32C14.33 0 0 14.33 0 32v128c0 17.67 14.33 32 32 32h95.72l73.16 128.04C211.98 300.98 232.4 288 256 288h.28L192 175.51V128h224V64H192V32zM608 0H480c-17.67 0-32 14.33-32 32v128c0 17.67 14.33 32 32 32h128c17.67 0 32-14.33 32-32V32c0-17.67-14.33-32-32-32z"
286
+ fill="currentColor"
287
+ />
288
+ </svg>
289
+ </button>
290
+ </div>
291
+ </div>
292
+ </div>
293
+ </div>
294
+ </div>
295
+ </div>
296
+ </DocumentFragment>
297
+ `;