@parca/profile 0.19.140 → 0.19.142

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 (253) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/GraphTooltipArrow/Content.js +224 -30
  3. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
  4. package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
  5. package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
  6. package/dist/GraphTooltipArrow/index.js +86 -56
  7. package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
  8. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.d.ts.map +1 -1
  9. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +104 -72
  10. package/dist/MatchersInput/SuggestionItem.js +91 -12
  11. package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
  12. package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
  13. package/dist/MatchersInput/SuggestionsList.js +371 -157
  14. package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
  15. package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
  16. package/dist/MatchersInput/index.js +308 -115
  17. package/dist/MetricsCircle/index.js +39 -3
  18. package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
  19. package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
  20. package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
  21. package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
  22. package/dist/MetricsGraph/index.js +552 -203
  23. package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
  24. package/dist/MetricsGraph/utils/colorMapping.js +24 -17
  25. package/dist/MetricsSeries/index.js +70 -7
  26. package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
  27. package/dist/PreSelectedMatchers/index.js +249 -102
  28. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
  29. package/dist/ProfileExplorer/ProfileExplorerCompare.js +241 -45
  30. package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
  31. package/dist/ProfileExplorer/index.js +183 -32
  32. package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
  33. package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
  34. package/dist/ProfileFlameChart/SamplesStrips/index.d.ts +2 -2
  35. package/dist/ProfileFlameChart/SamplesStrips/index.d.ts.map +1 -1
  36. package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
  37. package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
  38. package/dist/ProfileFlameChart/index.d.ts.map +1 -1
  39. package/dist/ProfileFlameChart/index.js +267 -129
  40. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
  41. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +288 -89
  42. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
  43. package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
  44. package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
  45. package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
  46. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  47. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +72 -47
  48. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
  49. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
  50. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
  51. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
  52. package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
  53. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
  54. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
  55. package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
  56. package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
  57. package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
  58. package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
  59. package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
  60. package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
  61. package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
  62. package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
  63. package/dist/ProfileFlameGraph/index.js +324 -150
  64. package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
  65. package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
  66. package/dist/ProfileMetricsGraph/index.js +519 -258
  67. package/dist/ProfileSelector/CompareButton.js +132 -12
  68. package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
  69. package/dist/ProfileSelector/MetricsGraphSection.js +236 -64
  70. package/dist/ProfileSelector/index.d.ts.map +1 -1
  71. package/dist/ProfileSelector/index.js +727 -141
  72. package/dist/ProfileSelector/useAutoQuerySelector.js +249 -130
  73. package/dist/ProfileSource.js +230 -163
  74. package/dist/ProfileTypeSelector/index.js +214 -125
  75. package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
  76. package/dist/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
  77. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +141 -35
  78. package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
  79. package/dist/ProfileView/components/ColorStackLegend.js +185 -55
  80. package/dist/ProfileView/components/DashboardItems/index.js +87 -28
  81. package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
  82. package/dist/ProfileView/components/DiffLegend.js +172 -29
  83. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
  84. package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
  85. package/dist/ProfileView/components/InvertCallStack/index.js +100 -12
  86. package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
  87. package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
  88. package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
  89. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +2 -1
  90. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
  91. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +188 -118
  92. package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
  93. package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
  94. package/dist/ProfileView/components/ShareButton/index.js +352 -62
  95. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  96. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +678 -194
  97. package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
  98. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
  99. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +199 -157
  100. package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
  101. package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
  102. package/dist/ProfileView/components/Toolbars/index.js +441 -21
  103. package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
  104. package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
  105. package/dist/ProfileView/components/ViewSelector/index.js +212 -86
  106. package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
  107. package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
  108. package/dist/ProfileView/components/VisualizationPanel.js +185 -8
  109. package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
  110. package/dist/ProfileView/context/DashboardContext.js +85 -29
  111. package/dist/ProfileView/context/ProfileViewContext.js +56 -15
  112. package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
  113. package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
  114. package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
  115. package/dist/ProfileView/hooks/useResetFlameGraphState.js +32 -12
  116. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
  117. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
  118. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
  119. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +40 -19
  120. package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
  121. package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
  122. package/dist/ProfileView/hooks/useVisualizationState.js +258 -67
  123. package/dist/ProfileView/index.js +383 -45
  124. package/dist/ProfileView/types/visualization.js +1 -13
  125. package/dist/ProfileView/utils/colorUtils.js +8 -7
  126. package/dist/ProfileViewWithData.d.ts.map +1 -1
  127. package/dist/ProfileViewWithData.js +332 -228
  128. package/dist/QueryControls/index.js +418 -47
  129. package/dist/Sandwich/components/CalleesSection.js +54 -4
  130. package/dist/Sandwich/components/CallersSection.js +97 -27
  131. package/dist/Sandwich/components/TableSection.js +77 -4
  132. package/dist/Sandwich/index.d.ts.map +1 -1
  133. package/dist/Sandwich/index.js +126 -14
  134. package/dist/Sandwich/utils/processRowData.js +48 -39
  135. package/dist/SelectWithRefresh/index.js +102 -28
  136. package/dist/SimpleMatchers/Select.js +520 -187
  137. package/dist/SimpleMatchers/index.js +590 -288
  138. package/dist/SourceView/Highlighter.js +230 -70
  139. package/dist/SourceView/LineNo.js +72 -17
  140. package/dist/SourceView/index.d.ts.map +1 -1
  141. package/dist/SourceView/index.js +178 -104
  142. package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
  143. package/dist/SourceView/lang-detector/index.js +28 -14
  144. package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
  145. package/dist/SourceView/useSelectedLineRange.js +99 -23
  146. package/dist/Table/ColorCell.js +42 -1
  147. package/dist/Table/ColumnsVisibility.js +114 -6
  148. package/dist/Table/MoreDropdown.d.ts.map +1 -1
  149. package/dist/Table/MoreDropdown.js +122 -25
  150. package/dist/Table/TableContextMenu.d.ts.map +1 -1
  151. package/dist/Table/TableContextMenu.js +151 -137
  152. package/dist/Table/TableContextMenuWrapper.js +59 -14
  153. package/dist/Table/hooks/useColorManagement.js +58 -16
  154. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  155. package/dist/Table/hooks/useTableConfiguration.js +333 -169
  156. package/dist/Table/index.d.ts.map +1 -1
  157. package/dist/Table/index.js +222 -128
  158. package/dist/Table/utils/functions.js +169 -144
  159. package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
  160. package/dist/TimelineGuide/index.js +209 -16
  161. package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
  162. package/dist/TopTable/index.d.ts.map +1 -1
  163. package/dist/TopTable/index.js +342 -123
  164. package/dist/contexts/LabelsQueryProvider.js +94 -32
  165. package/dist/contexts/UnifiedLabelsContext.js +114 -49
  166. package/dist/contexts/utils.js +37 -15
  167. package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
  168. package/dist/hooks/useCompareModeMeta.js +158 -64
  169. package/dist/hooks/useLabels.js +295 -52
  170. package/dist/hooks/useQueryState.d.ts +3 -3
  171. package/dist/hooks/useQueryState.d.ts.map +1 -1
  172. package/dist/hooks/useQueryState.js +373 -332
  173. package/dist/index.d.ts +2 -3
  174. package/dist/index.d.ts.map +1 -1
  175. package/dist/index.js +22 -8
  176. package/dist/testdata/fg-diff.json +3750 -0
  177. package/dist/testdata/fg-simple.json +1879 -0
  178. package/dist/testdata/link_data.json +56 -0
  179. package/dist/testdata/tabular.json +30 -0
  180. package/dist/testdata/test_flamegraph.json +26846 -0
  181. package/dist/testdata/test_graph.json +53 -0
  182. package/dist/useDelayedLoader.js +32 -18
  183. package/dist/useGrpcQuery/index.js +71 -11
  184. package/dist/useHasProfileData.js +90 -12
  185. package/dist/useQuery.js +205 -64
  186. package/dist/useSumBy.d.ts +1 -1
  187. package/dist/useSumBy.d.ts.map +1 -1
  188. package/dist/useSumBy.js +294 -138
  189. package/dist/utils.js +62 -30
  190. package/package.json +9 -10
  191. package/src/GraphTooltipArrow/index.tsx +3 -0
  192. package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +13 -11
  193. package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
  194. package/src/MatchersInput/SuggestionsList.tsx +11 -10
  195. package/src/MatchersInput/index.tsx +1 -1
  196. package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
  197. package/src/PreSelectedMatchers/index.tsx +3 -0
  198. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -4
  199. package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
  200. package/src/ProfileFlameChart/index.tsx +28 -21
  201. package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +9 -10
  202. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +6 -5
  203. package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
  204. package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
  205. package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
  206. package/src/ProfileFlameGraph/index.tsx +9 -6
  207. package/src/ProfileMetricsGraph/index.tsx +8 -6
  208. package/src/ProfileSelector/MetricsGraphSection.tsx +10 -5
  209. package/src/ProfileSelector/index.tsx +61 -39
  210. package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +6 -10
  211. package/src/ProfileView/components/ColorStackLegend.tsx +4 -2
  212. package/src/ProfileView/components/InvertCallStack/index.tsx +4 -5
  213. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +192 -94
  214. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
  215. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +28 -24
  216. package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +5 -4
  217. package/src/ProfileView/components/Toolbars/index.tsx +3 -3
  218. package/src/ProfileView/components/ViewSelector/index.tsx +16 -9
  219. package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
  220. package/src/ProfileView/context/DashboardContext.tsx +6 -6
  221. package/src/ProfileView/hooks/useResetFlameGraphState.ts +4 -6
  222. package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +26 -24
  223. package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +8 -16
  224. package/src/ProfileView/hooks/useVisualizationState.ts +69 -61
  225. package/src/ProfileViewWithData.tsx +35 -29
  226. package/src/Sandwich/index.tsx +3 -4
  227. package/src/SourceView/index.tsx +2 -4
  228. package/src/SourceView/useSelectedLineRange.ts +19 -34
  229. package/src/Table/MoreDropdown.tsx +11 -9
  230. package/src/Table/TableContextMenu.tsx +13 -10
  231. package/src/Table/hooks/useTableConfiguration.tsx +11 -16
  232. package/src/Table/index.tsx +21 -12
  233. package/src/TopTable/index.tsx +4 -3
  234. package/src/hooks/useCompareModeMeta.ts +91 -61
  235. package/src/hooks/useQueryState.test.tsx +345 -275
  236. package/src/hooks/useQueryState.ts +118 -136
  237. package/src/index.tsx +15 -16
  238. package/src/useDelayedLoader.ts +10 -10
  239. package/src/useSumBy.ts +15 -21
  240. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
  241. package/dist/hooks/urlParsers.d.ts +0 -18
  242. package/dist/hooks/urlParsers.d.ts.map +0 -1
  243. package/dist/hooks/urlParsers.js +0 -32
  244. package/dist/hooks/useColorBy.d.ts +0 -5
  245. package/dist/hooks/useColorBy.d.ts.map +0 -1
  246. package/dist/hooks/useColorBy.js +0 -26
  247. package/dist/hooks/useDashboardItems.d.ts +0 -5
  248. package/dist/hooks/useDashboardItems.d.ts.map +0 -1
  249. package/dist/hooks/useDashboardItems.js +0 -27
  250. package/dist/hooks/useQueryState.test.js +0 -868
  251. package/src/hooks/urlParsers.ts +0 -38
  252. package/src/hooks/useColorBy.ts +0 -42
  253. package/src/hooks/useDashboardItems.ts +0 -46
@@ -1,4 +1,16 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
+ import { c as _c } from "react-compiler-runtime";
2
14
  // Copyright 2022 The Parca Authors
3
15
  // Licensed under the Apache License, Version 2.0 (the "License");
4
16
  // you may not use this file except in compliance with the License.
@@ -11,167 +23,329 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
11
23
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
24
  // See the License for the specific language governing permissions and
13
25
  // limitations under the License.
14
- import { useCallback, useEffect, useMemo, useState } from 'react';
26
+
27
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
15
28
  import cx from 'classnames';
16
29
  import { AnimatePresence, motion } from 'framer-motion';
17
- import { useQueryState } from 'nuqs';
18
30
  import { useMeasure } from 'react-use';
19
- import { FlameGraphSkeleton, SandwichFlameGraphSkeleton, useParcaContext } from '@parca/components';
31
+ import { FlameGraphSkeleton, SandwichFlameGraphSkeleton, useParcaContext, useURLState } from '@parca/components';
20
32
  import { TEST_IDS, testId } from '@parca/test-utils';
21
33
  import { capitalizeOnlyFirstLetter, divide } from '@parca/utilities';
22
34
  import DiffLegend from '../ProfileView/components/DiffLegend';
23
35
  import { useProfileViewContext } from '../ProfileView/context/ProfileViewContext';
24
36
  import { useProfileMetadata } from '../ProfileView/hooks/useProfileMetadata';
25
37
  import { useVisualizationState } from '../ProfileView/hooks/useVisualizationState';
26
- import { boolParam } from '../hooks/urlParsers';
27
38
  import { FlameGraphArrow } from './FlameGraphArrow';
28
- const numberFormatter = new Intl.NumberFormat('en-US');
29
- const ErrorContent = ({ errorMessage }) => {
30
- return (_jsx("div", { className: "flex flex-col justify-center p-10 text-center gap-6 text-sm", children: errorMessage }));
39
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
40
+ var numberFormatter = new Intl.NumberFormat('en-US');
41
+ var ErrorContent = function ErrorContent(t0) {
42
+ var $ = _c(2);
43
+ var errorMessage = t0.errorMessage;
44
+ var t1;
45
+ if ($[0] !== errorMessage) {
46
+ t1 = /*#__PURE__*/_jsx("div", {
47
+ className: "flex flex-col justify-center p-10 text-center gap-6 text-sm",
48
+ children: errorMessage
49
+ });
50
+ $[0] = errorMessage;
51
+ $[1] = t1;
52
+ } else {
53
+ t1 = $[1];
54
+ }
55
+ return t1;
31
56
  };
32
- export const validateFlameChartQuery = (profileSource) => {
33
- const isNonDelta = !profileSource.ProfileType().delta;
34
- const duration = profileSource.mergeTo - profileSource.mergeFrom;
35
- const isDurationTooLong = duration > 900000000000n; // 15 minutes in nanoseconds
36
- return { isValid: !isNonDelta && !isDurationTooLong, isNonDelta, isDurationTooLong };
57
+ export var validateFlameChartQuery = function validateFlameChartQuery(profileSource) {
58
+ var isNonDelta = !profileSource.ProfileType().delta;
59
+ var duration = profileSource.mergeTo - profileSource.mergeFrom;
60
+ var isDurationTooLong = duration > 900000000000n; // 15 minutes in nanoseconds
61
+ return {
62
+ isValid: !isNonDelta && !isDurationTooLong,
63
+ isNonDelta: isNonDelta,
64
+ isDurationTooLong: isDurationTooLong
65
+ };
37
66
  };
38
- const ProfileFlameGraph = function ProfileFlameGraphNonMemo({ arrow, total, filtered, curPathArrow, setNewCurPathArrow, profileType, loading, error, width, isHalfScreen, metadataMappingFiles, isFlameChart = false, profileSource, isInSandwichView = false, isRenderedAsFlamegraph = false, tooltipId, maxFrameCount, isExpanded = false, metadataLoading = false, zoomControlsRef, }) {
39
- const { onError, authenticationErrorMessage, isDarkMode, flamechartHelpText } = useParcaContext();
40
- const { compareMode } = useProfileViewContext();
41
- const [isLoading, setIsLoading] = useState(true);
42
- const [flameChartRef] = useMeasure();
43
- const { colorBy, setColorBy } = useVisualizationState();
44
- // Create local state for paths when in sandwich view to avoid URL updates
45
- const [localCurPathArrow, setLocalCurPathArrow] = useState([]);
46
- const setCurPathArrowWrapper = useCallback((path) => {
47
- if (isInSandwichView) {
48
- setLocalCurPathArrow(path);
49
- }
50
- else {
51
- setNewCurPathArrow(path);
52
- }
53
- }, [isInSandwichView, setNewCurPathArrow]);
54
- // Determine which paths to use based on isInSandwichView flag
55
- const effectiveCurPathArrow = isInSandwichView ? localCurPathArrow : curPathArrow;
56
- const { mappingsList, filenamesList } = useProfileMetadata({
57
- flamegraphArrow: arrow,
58
- metadataMappingFiles,
59
- metadataLoading,
60
- colorBy,
67
+ var ProfileFlameGraph = function ProfileFlameGraphNonMemo(_ref) {
68
+ var arrow = _ref.arrow,
69
+ total = _ref.total,
70
+ filtered = _ref.filtered,
71
+ curPathArrow = _ref.curPathArrow,
72
+ setNewCurPathArrow = _ref.setNewCurPathArrow,
73
+ profileType = _ref.profileType,
74
+ loading = _ref.loading,
75
+ error = _ref.error,
76
+ width = _ref.width,
77
+ isHalfScreen = _ref.isHalfScreen,
78
+ metadataMappingFiles = _ref.metadataMappingFiles,
79
+ _ref$isFlameChart = _ref.isFlameChart,
80
+ isFlameChart = _ref$isFlameChart === void 0 ? false : _ref$isFlameChart,
81
+ profileSource = _ref.profileSource,
82
+ _ref$isInSandwichView = _ref.isInSandwichView,
83
+ isInSandwichView = _ref$isInSandwichView === void 0 ? false : _ref$isInSandwichView,
84
+ _ref$isRenderedAsFlam = _ref.isRenderedAsFlamegraph,
85
+ isRenderedAsFlamegraph = _ref$isRenderedAsFlam === void 0 ? false : _ref$isRenderedAsFlam,
86
+ tooltipId = _ref.tooltipId,
87
+ maxFrameCount = _ref.maxFrameCount,
88
+ _ref$isExpanded = _ref.isExpanded,
89
+ isExpanded = _ref$isExpanded === void 0 ? false : _ref$isExpanded,
90
+ _ref$metadataLoading = _ref.metadataLoading,
91
+ metadataLoading = _ref$metadataLoading === void 0 ? false : _ref$metadataLoading,
92
+ zoomControlsRef = _ref.zoomControlsRef;
93
+ var _useParcaContext = useParcaContext(),
94
+ onError = _useParcaContext.onError,
95
+ authenticationErrorMessage = _useParcaContext.authenticationErrorMessage,
96
+ isDarkMode = _useParcaContext.isDarkMode,
97
+ flamechartHelpText = _useParcaContext.flamechartHelpText;
98
+ var _useProfileViewContex = useProfileViewContext(),
99
+ compareMode = _useProfileViewContex.compareMode;
100
+ var _useState = useState(true),
101
+ _useState2 = _slicedToArray(_useState, 2),
102
+ isLoading = _useState2[0],
103
+ setIsLoading = _useState2[1];
104
+ var _useMeasure = useMeasure(),
105
+ _useMeasure2 = _slicedToArray(_useMeasure, 1),
106
+ flameChartRef = _useMeasure2[0];
107
+ var _useVisualizationStat = useVisualizationState(),
108
+ colorBy = _useVisualizationStat.colorBy,
109
+ setColorBy = _useVisualizationStat.setColorBy;
110
+
111
+ // Create local state for paths when in sandwich view to avoid URL updates
112
+ var _useState3 = useState([]),
113
+ _useState4 = _slicedToArray(_useState3, 2),
114
+ localCurPathArrow = _useState4[0],
115
+ setLocalCurPathArrow = _useState4[1];
116
+ var setCurPathArrowWrapper = useCallback(function (path) {
117
+ if (isInSandwichView) {
118
+ setLocalCurPathArrow(path);
119
+ } else {
120
+ setNewCurPathArrow(path);
121
+ }
122
+ }, [isInSandwichView, setNewCurPathArrow]);
123
+
124
+ // Determine which paths to use based on isInSandwichView flag
125
+ var effectiveCurPathArrow = isInSandwichView ? localCurPathArrow : curPathArrow;
126
+ var _useProfileMetadata = useProfileMetadata({
127
+ flamegraphArrow: arrow,
128
+ metadataMappingFiles: metadataMappingFiles,
129
+ metadataLoading: metadataLoading,
130
+ colorBy: colorBy
131
+ }),
132
+ mappingsList = _useProfileMetadata.mappingsList,
133
+ filenamesList = _useProfileMetadata.filenamesList;
134
+
135
+ // By default, we want delta profiles (CPU) to be relatively compared.
136
+ // For non-delta profiles, like goroutines or memory, we want the profiles to be compared absolutely.
137
+ var compareAbsoluteDefault = (profileType === null || profileType === void 0 ? void 0 : profileType.delta) === false ? 'true' : 'false';
138
+ var _useURLState = useURLState('compare_absolute'),
139
+ _useURLState2 = _slicedToArray(_useURLState, 1),
140
+ _useURLState2$ = _useURLState2[0],
141
+ compareAbsolute = _useURLState2$ === void 0 ? compareAbsoluteDefault : _useURLState2$;
142
+ var isCompareAbsolute = compareAbsolute === 'true';
143
+ var mappingsListCount = useMemo(function () {
144
+ return mappingsList.filter(function (m) {
145
+ return m !== '';
146
+ }).length;
147
+ }, [mappingsList]);
148
+ var _useMemo = useMemo(function () {
149
+ var _arrow$trimmed;
150
+ if (arrow === undefined) {
151
+ return ['0', '0', false, '0', '0', false, '0', '0'];
152
+ }
153
+ var trimmed = (_arrow$trimmed = arrow === null || arrow === void 0 ? void 0 : arrow.trimmed) !== null && _arrow$trimmed !== void 0 ? _arrow$trimmed : 0n;
154
+ var totalUnfiltered = total + filtered;
155
+ // safeguard against division by zero
156
+ var totalUnfilteredDivisor = totalUnfiltered > 0 ? totalUnfiltered : 1n;
157
+ return [numberFormatter.format(total), numberFormatter.format(totalUnfiltered), trimmed > 0, numberFormatter.format(trimmed), numberFormatter.format(divide(trimmed * 100n, totalUnfilteredDivisor)), filtered > 0, numberFormatter.format(divide(total * 100n, totalUnfilteredDivisor))];
158
+ }, [arrow, filtered, total]),
159
+ _useMemo2 = _slicedToArray(_useMemo, 7),
160
+ totalFormatted = _useMemo2[0],
161
+ totalUnfilteredFormatted = _useMemo2[1],
162
+ isTrimmed = _useMemo2[2],
163
+ trimmedFormatted = _useMemo2[3],
164
+ trimmedPercentage = _useMemo2[4],
165
+ isFiltered = _useMemo2[5],
166
+ filteredPercentage = _useMemo2[6];
167
+ var loadingState = !loading && arrow !== undefined && metadataMappingFiles !== undefined;
168
+
169
+ // If there is only one mapping file, we want to color by filename by default.
170
+ useEffect(function () {
171
+ if (mappingsListCount === 1 && colorBy !== 'filename') {
172
+ setColorBy('filename');
173
+ }
174
+ // eslint-disable-next-line react-hooks/exhaustive-deps
175
+ }, [mappingsListCount]);
176
+ useEffect(function () {
177
+ if (loadingState) {
178
+ setIsLoading(false);
179
+ } else {
180
+ setIsLoading(true);
181
+ }
182
+ }, [loadingState]);
183
+ var flameGraph = useMemo(function () {
184
+ var _ref2 = isFlameChart ? validateFlameChartQuery(profileSource) : {
185
+ isValid: true,
186
+ isNonDelta: false,
187
+ isDurationTooLong: false
188
+ },
189
+ isFlameChartValid = _ref2.isValid,
190
+ isNonDelta = _ref2.isNonDelta,
191
+ isDurationTooLong = _ref2.isDurationTooLong;
192
+ var isInvalidFlameChartQuery = isFlameChart && !isFlameChartValid;
193
+ if (isLoading && !isInvalidFlameChartQuery) {
194
+ return /*#__PURE__*/_jsx("div", {
195
+ className: "h-auto overflow-clip",
196
+ "data-testid": TEST_IDS.FLAMEGRAPH_SKELETON,
197
+ children: isRenderedAsFlamegraph ? /*#__PURE__*/_jsx(SandwichFlameGraphSkeleton, {
198
+ isHalfScreen: isHalfScreen,
199
+ isDarkMode: isDarkMode
200
+ }) : /*#__PURE__*/_jsx(FlameGraphSkeleton, {
201
+ isHalfScreen: isHalfScreen,
202
+ isDarkMode: isDarkMode
203
+ })
204
+ });
205
+ }
206
+
207
+ // Do necessary checks to ensure that flame chart can be rendered for this query.
208
+ if (isInvalidFlameChartQuery) {
209
+ if (isNonDelta) {
210
+ return /*#__PURE__*/_jsx(ErrorContent, {
211
+ errorMessage: /*#__PURE__*/_jsxs(_Fragment, {
212
+ children: [/*#__PURE__*/_jsx("span", {
213
+ children: "To use the Flame chart, please switch to a Delta profile."
214
+ }), flamechartHelpText !== null && flamechartHelpText !== void 0 ? flamechartHelpText : null]
215
+ })
216
+ });
217
+ } else if (isDurationTooLong) {
218
+ return /*#__PURE__*/_jsx(ErrorContent, {
219
+ errorMessage: /*#__PURE__*/_jsxs(_Fragment, {
220
+ children: [/*#__PURE__*/_jsx("span", {
221
+ children: "Flame chart is unavailable for queries longer than 15 minutes. Please select a point in the metrics graph to continue."
222
+ }), flamechartHelpText !== null && flamechartHelpText !== void 0 ? flamechartHelpText : null]
223
+ })
224
+ });
225
+ } else {
226
+ return /*#__PURE__*/_jsx(ErrorContent, {
227
+ errorMessage: /*#__PURE__*/_jsxs(_Fragment, {
228
+ children: [/*#__PURE__*/_jsx("span", {
229
+ children: "The Flame chart is not available for this query."
230
+ }), flamechartHelpText !== null && flamechartHelpText !== void 0 ? flamechartHelpText : null]
231
+ })
232
+ });
233
+ }
234
+ }
235
+ if (arrow === undefined) return /*#__PURE__*/_jsx("div", {
236
+ className: "mx-auto text-center",
237
+ children: "No data..."
238
+ });
239
+ if (total === 0n && !loading) return /*#__PURE__*/_jsx("div", {
240
+ className: "mx-auto text-center",
241
+ children: "Profile has no samples"
61
242
  });
62
- // By default, we want delta profiles (CPU) to be relatively compared.
63
- // For non-delta profiles, like goroutines or memory, we want the profiles to be compared absolutely.
64
- const compareAbsoluteDefault = profileType?.delta === false ? 'true' : 'false';
65
- const [compareAbsolute] = useQueryState('compare_absolute', boolParam);
66
- const isCompareAbsolute = compareAbsolute ?? compareAbsoluteDefault === 'true';
67
- const mappingsListCount = useMemo(() => mappingsList.filter(m => m !== '').length, [mappingsList]);
68
- const [totalFormatted, totalUnfilteredFormatted, isTrimmed, trimmedFormatted, trimmedPercentage, isFiltered, filteredPercentage,] = useMemo(() => {
69
- if (arrow === undefined) {
70
- return ['0', '0', false, '0', '0', false, '0', '0'];
71
- }
72
- const trimmed = arrow?.trimmed ?? 0n;
73
- const totalUnfiltered = total + filtered;
74
- // safeguard against division by zero
75
- const totalUnfilteredDivisor = totalUnfiltered > 0 ? totalUnfiltered : 1n;
76
- return [
77
- numberFormatter.format(total),
78
- numberFormatter.format(totalUnfiltered),
79
- trimmed > 0,
80
- numberFormatter.format(trimmed),
81
- numberFormatter.format(divide(trimmed * 100n, totalUnfilteredDivisor)),
82
- filtered > 0,
83
- numberFormatter.format(divide(total * 100n, totalUnfilteredDivisor)),
84
- ];
85
- }, [arrow, filtered, total]);
86
- const loadingState = !loading && arrow !== undefined && metadataMappingFiles !== undefined;
87
- // If there is only one mapping file, we want to color by filename by default.
88
- useEffect(() => {
89
- if (mappingsListCount === 1 && colorBy !== 'filename') {
90
- void setColorBy('filename');
91
- }
92
- // eslint-disable-next-line react-hooks/exhaustive-deps
93
- }, [mappingsListCount]);
94
- useEffect(() => {
95
- if (loadingState) {
96
- setIsLoading(false);
97
- }
98
- else {
99
- setIsLoading(true);
100
- }
101
- }, [loadingState]);
102
- const flameGraph = useMemo(() => {
103
- const { isValid: isFlameChartValid, isNonDelta, isDurationTooLong, } = isFlameChart
104
- ? validateFlameChartQuery(profileSource)
105
- : { isValid: true, isNonDelta: false, isDurationTooLong: false };
106
- const isInvalidFlameChartQuery = isFlameChart && !isFlameChartValid;
107
- if (isLoading && !isInvalidFlameChartQuery) {
108
- return (_jsx("div", { className: "h-auto overflow-clip", "data-testid": TEST_IDS.FLAMEGRAPH_SKELETON, children: isRenderedAsFlamegraph ? (_jsx(SandwichFlameGraphSkeleton, { isHalfScreen: isHalfScreen, isDarkMode: isDarkMode })) : (_jsx(FlameGraphSkeleton, { isHalfScreen: isHalfScreen, isDarkMode: isDarkMode })) }));
109
- }
110
- // Do necessary checks to ensure that flame chart can be rendered for this query.
111
- if (isInvalidFlameChartQuery) {
112
- if (isNonDelta) {
113
- return (_jsx(ErrorContent, { errorMessage: _jsxs(_Fragment, { children: [_jsx("span", { children: "To use the Flame chart, please switch to a Delta profile." }), flamechartHelpText ?? null] }) }));
114
- }
115
- else if (isDurationTooLong) {
116
- return (_jsx(ErrorContent, { errorMessage: _jsxs(_Fragment, { children: [_jsx("span", { children: "Flame chart is unavailable for queries longer than 15 minutes. Please select a point in the metrics graph to continue." }), flamechartHelpText ?? null] }) }));
117
- }
118
- else {
119
- return (_jsx(ErrorContent, { errorMessage: _jsxs(_Fragment, { children: [_jsx("span", { children: "The Flame chart is not available for this query." }), flamechartHelpText ?? null] }) }));
120
- }
121
- }
122
- if (arrow === undefined)
123
- return _jsx("div", { className: "mx-auto text-center", children: "No data..." });
124
- if (total === 0n && !loading)
125
- return _jsx("div", { className: "mx-auto text-center", children: "Profile has no samples" });
126
- if (arrow !== undefined) {
127
- return (_jsx("div", { className: "relative", children: _jsx("div", { ref: flameChartRef, children: _jsx(FlameGraphArrow, { width: width, arrow: arrow, total: total, filtered: filtered, curPath: effectiveCurPathArrow, setCurPath: setCurPathArrowWrapper, profileType: profileType, isHalfScreen: isHalfScreen, mappingsListFromMetadata: mappingsList, filenamesListFromMetadata: filenamesList, compareAbsolute: isCompareAbsolute, isFlameChart: isFlameChart, profileSource: profileSource, isRenderedAsFlamegraph: isRenderedAsFlamegraph, isInSandwichView: isInSandwichView, tooltipId: tooltipId, maxFrameCount: maxFrameCount, isExpanded: isExpanded, colorBy: colorBy, zoomControlsRef: zoomControlsRef }) }) }));
128
- }
129
- }, [
130
- isLoading,
131
- arrow,
132
- total,
133
- loading,
134
- width,
135
- filtered,
136
- profileType,
137
- isHalfScreen,
138
- isDarkMode,
139
- isCompareAbsolute,
140
- isFlameChart,
141
- profileSource,
142
- flameChartRef,
143
- flamechartHelpText,
144
- isRenderedAsFlamegraph,
145
- isInSandwichView,
146
- effectiveCurPathArrow,
147
- setCurPathArrowWrapper,
148
- tooltipId,
149
- maxFrameCount,
150
- isExpanded,
151
- mappingsList,
152
- filenamesList,
153
- colorBy,
154
- zoomControlsRef,
155
- ]);
156
- useEffect(() => {
157
- if (isTrimmed) {
158
- console.info(`Trimmed ${trimmedFormatted} (${trimmedPercentage}%) too small values.`);
159
- }
160
- }, [isTrimmed, trimmedFormatted, trimmedPercentage]);
161
- if (error != null) {
162
- onError?.(error);
163
- if (authenticationErrorMessage !== undefined && error.code === 'UNAUTHENTICATED') {
164
- return _jsx(ErrorContent, { errorMessage: authenticationErrorMessage });
165
- }
166
- // Check for specific merge errors
167
- const errorMessageLower = error.message?.toLowerCase() ?? '';
168
- const isMergeError = errorMessageLower.includes('failed to merge flame chart records');
169
- const isTimestampError = errorMessageLower.includes('multiple samples for the same timestamp is not allowed');
170
- if (isMergeError || isTimestampError) {
171
- return (_jsx(ErrorContent, { errorMessage: _jsxs(_Fragment, { children: [_jsx("span", { className: "font-semibold", children: "Unable to display overlapping data" }), _jsx("span", { className: "text-gray-600 dark:text-gray-400", children: "The selected data contains overlapping samples from multiple nodes or threads that cannot be merged." }), _jsx("span", { className: "text-gray-600 dark:text-gray-400", children: "To view this data, please apply more specific filters:" }), _jsxs("ul", { className: "list-disc list-inside text-left max-w-md mx-auto text-gray-600 dark:text-gray-400", children: [_jsx("li", { children: "Select a specific node from the node selector" }), _jsx("li", { children: "Filter by either CPU or thread" })] })] }) }));
172
- }
173
- return (_jsx(ErrorContent, { errorMessage: _jsxs(_Fragment, { children: [_jsx("span", { children: capitalizeOnlyFirstLetter(error.message) }), isFlameChart ? flamechartHelpText ?? null : null] }) }));
243
+ if (arrow !== undefined) {
244
+ return /*#__PURE__*/_jsx("div", {
245
+ className: "relative",
246
+ children: /*#__PURE__*/_jsx("div", {
247
+ ref: flameChartRef,
248
+ children: /*#__PURE__*/_jsx(FlameGraphArrow, {
249
+ width: width,
250
+ arrow: arrow,
251
+ total: total,
252
+ filtered: filtered,
253
+ curPath: effectiveCurPathArrow,
254
+ setCurPath: setCurPathArrowWrapper,
255
+ profileType: profileType,
256
+ isHalfScreen: isHalfScreen,
257
+ mappingsListFromMetadata: mappingsList,
258
+ filenamesListFromMetadata: filenamesList,
259
+ compareAbsolute: isCompareAbsolute,
260
+ isFlameChart: isFlameChart,
261
+ profileSource: profileSource,
262
+ isRenderedAsFlamegraph: isRenderedAsFlamegraph,
263
+ isInSandwichView: isInSandwichView,
264
+ tooltipId: tooltipId,
265
+ maxFrameCount: maxFrameCount,
266
+ isExpanded: isExpanded,
267
+ colorBy: colorBy,
268
+ zoomControlsRef: zoomControlsRef
269
+ })
270
+ })
271
+ });
272
+ }
273
+ }, [isLoading, arrow, total, loading, width, filtered, profileType, isHalfScreen, isDarkMode, isCompareAbsolute, isFlameChart, profileSource, flameChartRef, flamechartHelpText, isRenderedAsFlamegraph, isInSandwichView, effectiveCurPathArrow, setCurPathArrowWrapper, tooltipId, maxFrameCount, isExpanded, mappingsList, filenamesList, colorBy, zoomControlsRef]);
274
+ useEffect(function () {
275
+ if (isTrimmed) {
276
+ console.info("Trimmed ".concat(trimmedFormatted, " (").concat(trimmedPercentage, "%) too small values."));
174
277
  }
175
- return (_jsx(AnimatePresence, { children: _jsxs(motion.div, { className: "relative h-full w-full", initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.5 }, children: [compareMode ? _jsx(DiffLegend, {}) : null, _jsx("div", { className: cx(!isInSandwichView ? 'min-h-48' : ''), id: "h-flame-graph", ...testId(TEST_IDS.FLAMEGRAPH_CONTAINER), children: _jsx(_Fragment, { children: flameGraph }) }), !isInSandwichView && (_jsxs("p", { className: "my-2 text-xs", children: ["Showing ", totalFormatted, ' ', isFiltered ? (_jsxs("span", { children: ["(", filteredPercentage, "%) filtered of ", totalUnfilteredFormatted, ' '] })) : (_jsx(_Fragment, {})), "values.", ' '] }))] }, "flame-graph-loaded") }));
278
+ }, [isTrimmed, trimmedFormatted, trimmedPercentage]);
279
+ if (error != null) {
280
+ var _error$message$toLowe, _error$message;
281
+ onError === null || onError === void 0 || onError(error);
282
+ if (authenticationErrorMessage !== undefined && error.code === 'UNAUTHENTICATED') {
283
+ return /*#__PURE__*/_jsx(ErrorContent, {
284
+ errorMessage: authenticationErrorMessage
285
+ });
286
+ }
287
+
288
+ // Check for specific merge errors
289
+ var errorMessageLower = (_error$message$toLowe = (_error$message = error.message) === null || _error$message === void 0 ? void 0 : _error$message.toLowerCase()) !== null && _error$message$toLowe !== void 0 ? _error$message$toLowe : '';
290
+ var isMergeError = errorMessageLower.includes('failed to merge flame chart records');
291
+ var isTimestampError = errorMessageLower.includes('multiple samples for the same timestamp is not allowed');
292
+ if (isMergeError || isTimestampError) {
293
+ return /*#__PURE__*/_jsx(ErrorContent, {
294
+ errorMessage: /*#__PURE__*/_jsxs(_Fragment, {
295
+ children: [/*#__PURE__*/_jsx("span", {
296
+ className: "font-semibold",
297
+ children: "Unable to display overlapping data"
298
+ }), /*#__PURE__*/_jsx("span", {
299
+ className: "text-gray-600 dark:text-gray-400",
300
+ children: "The selected data contains overlapping samples from multiple nodes or threads that cannot be merged."
301
+ }), /*#__PURE__*/_jsx("span", {
302
+ className: "text-gray-600 dark:text-gray-400",
303
+ children: "To view this data, please apply more specific filters:"
304
+ }), /*#__PURE__*/_jsxs("ul", {
305
+ className: "list-disc list-inside text-left max-w-md mx-auto text-gray-600 dark:text-gray-400",
306
+ children: [/*#__PURE__*/_jsx("li", {
307
+ children: "Select a specific node from the node selector"
308
+ }), /*#__PURE__*/_jsx("li", {
309
+ children: "Filter by either CPU or thread"
310
+ })]
311
+ })]
312
+ })
313
+ });
314
+ }
315
+ return /*#__PURE__*/_jsx(ErrorContent, {
316
+ errorMessage: /*#__PURE__*/_jsxs(_Fragment, {
317
+ children: [/*#__PURE__*/_jsx("span", {
318
+ children: capitalizeOnlyFirstLetter(error.message)
319
+ }), isFlameChart ? flamechartHelpText !== null && flamechartHelpText !== void 0 ? flamechartHelpText : null : null]
320
+ })
321
+ });
322
+ }
323
+ return /*#__PURE__*/_jsx(AnimatePresence, {
324
+ children: /*#__PURE__*/_jsxs(motion.div, {
325
+ className: "relative h-full w-full",
326
+ initial: {
327
+ opacity: 0
328
+ },
329
+ animate: {
330
+ opacity: 1
331
+ },
332
+ transition: {
333
+ duration: 0.5
334
+ },
335
+ children: [compareMode ? /*#__PURE__*/_jsx(DiffLegend, {}) : null, /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
336
+ className: cx(!isInSandwichView ? 'min-h-48' : ''),
337
+ id: "h-flame-graph"
338
+ }, testId(TEST_IDS.FLAMEGRAPH_CONTAINER)), {}, {
339
+ children: /*#__PURE__*/_jsx(_Fragment, {
340
+ children: flameGraph
341
+ })
342
+ })), !isInSandwichView && /*#__PURE__*/_jsxs("p", {
343
+ className: "my-2 text-xs",
344
+ children: ["Showing ", totalFormatted, ' ', isFiltered ? /*#__PURE__*/_jsxs("span", {
345
+ children: ["(", filteredPercentage, "%) filtered of ", totalUnfilteredFormatted, ' ']
346
+ }) : /*#__PURE__*/_jsx(_Fragment, {}), "values.", ' ']
347
+ })]
348
+ }, "flame-graph-loaded")
349
+ });
176
350
  };
177
- export default ProfileFlameGraph;
351
+ export default ProfileFlameGraph;