@parca/profile 0.19.140 → 0.19.143

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