@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,13 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
4
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
5
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
6
+ 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."); }
7
+ 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; } }
8
+ 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; }
9
+ 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; } }
10
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
2
11
  // Copyright 2022 The Parca Authors
3
12
  // Licensed under the Apache License, Version 2.0 (the "License");
4
13
  // you may not use this file except in compliance with the License.
@@ -11,6 +20,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
11
20
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
21
  // See the License for the specific language governing permissions and
13
22
  // limitations under the License.
23
+
14
24
  import React, { useCallback, useEffect, useMemo } from 'react';
15
25
  import { tableFromIPC } from '@uwdata/flechette';
16
26
  import { AnimatePresence, motion } from 'framer-motion';
@@ -22,110 +32,176 @@ import { stringParam } from '../hooks/urlParsers';
22
32
  import { alignedUint8Array, truncateStringReverse } from '../utils';
23
33
  import { Highlighter, profileAwareRenderer } from './Highlighter';
24
34
  import useLineRange from './useSelectedLineRange';
25
- const MENU_ID = 'source-view-context-menu';
26
- export const SourceView = React.memo(function SourceView({ data, loading, total, filtered, setActionButtons, }) {
27
- const [sourceFileName] = useQueryState('source_filename', stringParam);
28
- const { isDarkMode, sourceViewContextMenuItems = [] } = useParcaContext();
29
- const sourceCode = useMemo(() => {
30
- if (data === undefined) {
31
- return [''];
32
- }
33
- // To use the array index as line number
34
- return ['', ...data.source.split('\n')];
35
- }, [data]);
36
- const { show } = useContextMenu({
37
- id: MENU_ID,
35
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
36
+ var MENU_ID = 'source-view-context-menu';
37
+ export var SourceView = /*#__PURE__*/React.memo(function SourceView(_ref) {
38
+ var data = _ref.data,
39
+ loading = _ref.loading,
40
+ total = _ref.total,
41
+ filtered = _ref.filtered,
42
+ setActionButtons = _ref.setActionButtons;
43
+ var _useQueryState = useQueryState('source_filename', stringParam),
44
+ _useQueryState2 = _slicedToArray(_useQueryState, 1),
45
+ sourceFileName = _useQueryState2[0];
46
+ var _useParcaContext = useParcaContext(),
47
+ isDarkMode = _useParcaContext.isDarkMode,
48
+ _useParcaContext$sour = _useParcaContext.sourceViewContextMenuItems,
49
+ sourceViewContextMenuItems = _useParcaContext$sour === void 0 ? [] : _useParcaContext$sour;
50
+ var sourceCode = useMemo(function () {
51
+ if (data === undefined) {
52
+ return [''];
53
+ }
54
+ // To use the array index as line number
55
+ return [''].concat(_toConsumableArray(data.source.split('\n')));
56
+ }, [data]);
57
+ var _useContextMenu = useContextMenu({
58
+ id: MENU_ID
59
+ }),
60
+ show = _useContextMenu.show;
61
+ var _useLineRange = useLineRange(),
62
+ startLine = _useLineRange.startLine,
63
+ endLine = _useLineRange.endLine;
64
+ var sourceTable = useMemo(function () {
65
+ if (data === undefined) {
66
+ return null;
67
+ }
68
+ var table = tableFromIPC(alignedUint8Array(data.record), {
69
+ useBigInt: true
38
70
  });
39
- const { startLine, endLine } = useLineRange();
40
- const sourceTable = useMemo(() => {
41
- if (data === undefined) {
42
- return null;
43
- }
44
- const table = tableFromIPC(alignedUint8Array(data.record), { useBigInt: true });
45
- return {
46
- numRows: table.numRows,
47
- lineNumbers: table.getChild('line_number'),
48
- cumulative: table.getChild('cumulative'),
49
- flat: table.getChild('flat'),
50
- };
51
- }, [data]);
52
- const getLineData = useCallback((lineNumber) => {
53
- if (sourceTable === null || sourceTable.lineNumbers === null) {
54
- return undefined;
55
- }
56
- const { numRows, lineNumbers, cumulative, flat } = sourceTable;
57
- let lo = 0;
58
- let hi = numRows - 1;
59
- while (lo <= hi) {
60
- const mid = (lo + hi) >>> 1;
61
- const midVal = Number(lineNumbers.get(mid));
62
- if (midVal === lineNumber) {
63
- return {
64
- cumulative: cumulative?.get(mid) ?? 0n,
65
- flat: flat?.get(mid) ?? 0n,
66
- };
67
- }
68
- if (midVal < lineNumber) {
69
- lo = mid + 1;
70
- }
71
- else {
72
- hi = mid - 1;
73
- }
74
- }
75
- return undefined;
76
- }, [sourceTable]);
77
- const getProfileDataForLine = useCallback((line) => {
78
- const data = getLineData(line);
79
- if (data === undefined) {
80
- return undefined;
81
- }
82
- if (data.cumulative === 0n && data.flat === 0n) {
83
- return undefined;
84
- }
71
+ return {
72
+ numRows: table.numRows,
73
+ lineNumbers: table.getChild('line_number'),
74
+ cumulative: table.getChild('cumulative'),
75
+ flat: table.getChild('flat')
76
+ };
77
+ }, [data]);
78
+ var getLineData = useCallback(function (lineNumber) {
79
+ if (sourceTable === null || sourceTable.lineNumbers === null) {
80
+ return undefined;
81
+ }
82
+ var numRows = sourceTable.numRows,
83
+ lineNumbers = sourceTable.lineNumbers,
84
+ cumulative = sourceTable.cumulative,
85
+ flat = sourceTable.flat;
86
+ var lo = 0;
87
+ var hi = numRows - 1;
88
+ while (lo <= hi) {
89
+ var mid = lo + hi >>> 1;
90
+ var midVal = Number(lineNumbers.get(mid));
91
+ if (midVal === lineNumber) {
92
+ var _ref2, _ref3;
85
93
  return {
86
- line,
87
- cumulative: Number(data.cumulative),
88
- flat: Number(data.flat),
94
+ cumulative: (_ref2 = cumulative === null || cumulative === void 0 ? void 0 : cumulative.get(mid)) !== null && _ref2 !== void 0 ? _ref2 : 0n,
95
+ flat: (_ref3 = flat === null || flat === void 0 ? void 0 : flat.get(mid)) !== null && _ref3 !== void 0 ? _ref3 : 0n
89
96
  };
90
- }, [getLineData]);
91
- const [selectedCode, profileData] = useMemo(() => {
92
- if (startLine === -1 && endLine === -1) {
93
- return ['', []];
94
- }
95
- if (startLine === endLine) {
96
- const profileData = [];
97
- const profileDataForLine = getProfileDataForLine(startLine);
98
- if (profileDataForLine != null) {
99
- profileData.push(profileDataForLine);
100
- }
101
- return [sourceCode[startLine - 1], profileData];
102
- }
103
- let code = '';
104
- const profileData = [];
105
- for (let i = startLine; i <= endLine; i++) {
106
- code += sourceCode[i] + '\n';
107
- const profileDataForLine = getProfileDataForLine(i);
108
- if (profileDataForLine != null) {
109
- profileData.push(profileDataForLine);
110
- }
111
- }
112
- return [code, profileData];
113
- }, [startLine, endLine, sourceCode, getProfileDataForLine]);
114
- useEffect(() => {
115
- setActionButtons?.(_jsx("div", { className: "px-2", children: _jsx(ExpandOnHover, { value: sourceFileName, displayValue: truncateStringReverse(sourceFileName, 50) }) }));
116
- }, [sourceFileName, setActionButtons]);
117
- if (loading) {
118
- return (_jsx("div", { className: "h-auto overflow-clip", children: _jsx(SourceSkeleton, { isDarkMode: isDarkMode }) }));
97
+ }
98
+ if (midVal < lineNumber) {
99
+ lo = mid + 1;
100
+ } else {
101
+ hi = mid - 1;
102
+ }
119
103
  }
120
- if (data === undefined) {
121
- return _jsx(_Fragment, { children: "Source code not uploaded for this build." });
104
+ return undefined;
105
+ }, [sourceTable]);
106
+ var getProfileDataForLine = useCallback(function (line) {
107
+ var data_0 = getLineData(line);
108
+ if (data_0 === undefined) {
109
+ return undefined;
122
110
  }
123
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
124
- const onContextMenu = (event) => {
125
- show({
126
- event,
127
- });
111
+ if (data_0.cumulative === 0n && data_0.flat === 0n) {
112
+ return undefined;
113
+ }
114
+ return {
115
+ line: line,
116
+ cumulative: Number(data_0.cumulative),
117
+ flat: Number(data_0.flat)
128
118
  };
129
- return (_jsx(AnimatePresence, { children: _jsxs(motion.div, { className: "h-full w-full", initial: { display: 'none', opacity: 0 }, animate: { display: 'block', opacity: 1 }, transition: { duration: 0.5 }, children: [_jsx(Highlighter, { file: sourceFileName, content: data.source, renderer: profileAwareRenderer(getLineData, total, filtered, onContextMenu) }), sourceViewContextMenuItems.length > 0 ? (_jsx(Menu, { id: MENU_ID, children: sourceViewContextMenuItems.map(item => (_jsx(Item, { onClick: () => item.action(selectedCode, profileData), children: item.label }, item.id))) })) : null] }, "source-view-loaded") }));
119
+ }, [getLineData]);
120
+ var _useMemo = useMemo(function () {
121
+ if (startLine === -1 && endLine === -1) {
122
+ return ['', []];
123
+ }
124
+ if (startLine === endLine) {
125
+ var profileData = [];
126
+ var profileDataForLine = getProfileDataForLine(startLine);
127
+ if (profileDataForLine != null) {
128
+ profileData.push(profileDataForLine);
129
+ }
130
+ return [sourceCode[startLine - 1], profileData];
131
+ }
132
+ var code = '';
133
+ var profileData_0 = [];
134
+ for (var i = startLine; i <= endLine; i++) {
135
+ code += sourceCode[i] + '\n';
136
+ var profileDataForLine_0 = getProfileDataForLine(i);
137
+ if (profileDataForLine_0 != null) {
138
+ profileData_0.push(profileDataForLine_0);
139
+ }
140
+ }
141
+ return [code, profileData_0];
142
+ }, [startLine, endLine, sourceCode, getProfileDataForLine]),
143
+ _useMemo2 = _slicedToArray(_useMemo, 2),
144
+ selectedCode = _useMemo2[0],
145
+ profileData_1 = _useMemo2[1];
146
+ useEffect(function () {
147
+ setActionButtons === null || setActionButtons === void 0 || setActionButtons(/*#__PURE__*/_jsx("div", {
148
+ className: "px-2",
149
+ children: /*#__PURE__*/_jsx(ExpandOnHover, {
150
+ value: sourceFileName,
151
+ displayValue: truncateStringReverse(sourceFileName, 50)
152
+ })
153
+ }));
154
+ }, [sourceFileName, setActionButtons]);
155
+ if (loading) {
156
+ return /*#__PURE__*/_jsx("div", {
157
+ className: "h-auto overflow-clip",
158
+ children: /*#__PURE__*/_jsx(SourceSkeleton, {
159
+ isDarkMode: isDarkMode
160
+ })
161
+ });
162
+ }
163
+ if (data === undefined) {
164
+ return /*#__PURE__*/_jsx(_Fragment, {
165
+ children: "Source code not uploaded for this build."
166
+ });
167
+ }
168
+
169
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
170
+ var onContextMenu = function onContextMenu(event) {
171
+ show({
172
+ event: event
173
+ });
174
+ };
175
+ return /*#__PURE__*/_jsx(AnimatePresence, {
176
+ children: /*#__PURE__*/_jsxs(motion.div, {
177
+ className: "h-full w-full",
178
+ initial: {
179
+ display: 'none',
180
+ opacity: 0
181
+ },
182
+ animate: {
183
+ display: 'block',
184
+ opacity: 1
185
+ },
186
+ transition: {
187
+ duration: 0.5
188
+ },
189
+ children: [/*#__PURE__*/_jsx(Highlighter, {
190
+ file: sourceFileName,
191
+ content: data.source,
192
+ renderer: profileAwareRenderer(getLineData, total, filtered, onContextMenu)
193
+ }), sourceViewContextMenuItems.length > 0 ? /*#__PURE__*/_jsx(Menu, {
194
+ id: MENU_ID,
195
+ children: sourceViewContextMenuItems.map(function (item) {
196
+ return /*#__PURE__*/_jsx(Item, {
197
+ onClick: function onClick() {
198
+ return item.action(selectedCode, profileData_1);
199
+ },
200
+ children: item.label
201
+ }, item.id);
202
+ })
203
+ }) : null]
204
+ }, "source-view-loaded")
205
+ });
130
206
  });
131
- export default SourceView;
207
+ export default SourceView;