@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,3 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
1
  // Copyright 2022 The Parca Authors
3
2
  // Licensed under the Apache License, Version 2.0 (the "License");
4
3
  // you may not use this file except in compliance with the License.
@@ -11,228 +10,274 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
11
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
11
  // See the License for the specific language governing permissions and
13
12
  // limitations under the License.
13
+
14
14
  import React, { useCallback, useEffect, useRef } from 'react';
15
15
  import { EVERYTHING_ELSE } from '@parca/store';
16
16
  import { getLastItem } from '@parca/utilities';
17
17
  import { RowHeight } from './FlameGraphNodes';
18
- import { FIELD_CUMULATIVE, FIELD_DEPTH, FIELD_FUNCTION_FILE_NAME, FIELD_MAPPING_FILE, FIELD_TIMESTAMP, } from './index';
18
+ import { FIELD_CUMULATIVE, FIELD_DEPTH, FIELD_FUNCTION_FILE_NAME, FIELD_MAPPING_FILE, FIELD_TIMESTAMP } from './index';
19
19
  import { arrowToString, boundsFromProfileSource } from './utils';
20
- const MINIMAP_HEIGHT = 20;
21
- export const MiniMap = React.memo(function MiniMap({ containerRef, table, width, zoomedWidth, totalHeight, maxDepth, colorByColors: colors, colorBy, profileSource, isDarkMode, scrollLeft: _scrollLeft, scrollLeftRef, onZoomToPosition, onSetZoomWithScroll, }) {
22
- const canvasRef = useRef(null);
23
- const containerElRef = useRef(null);
24
- const isDragging = useRef(false);
25
- const dragStartX = useRef(0);
26
- const dragStartScrollLeft = useRef(0);
27
- // Render minimap canvas
28
- useEffect(() => {
29
- const canvas = canvasRef.current;
30
- if (canvas == null || width <= 0 || zoomedWidth <= 0)
31
- return;
32
- const dpr = window.devicePixelRatio !== 0 ? window.devicePixelRatio : 1;
33
- canvas.width = width * dpr;
34
- canvas.height = MINIMAP_HEIGHT * dpr;
35
- const ctx = canvas.getContext('2d');
36
- if (ctx == null)
37
- return;
38
- ctx.scale(dpr, dpr);
39
- ctx.clearRect(0, 0, width, MINIMAP_HEIGHT);
40
- // Background
41
- ctx.fillStyle = isDarkMode ? '#374151' : '#f3f4f6';
42
- ctx.fillRect(0, 0, width, MINIMAP_HEIGHT);
43
- const yScale = MINIMAP_HEIGHT / totalHeight;
44
- const tsBounds = boundsFromProfileSource(profileSource);
45
- const tsRange = Number(tsBounds[1]) - Number(tsBounds[0]);
46
- if (tsRange <= 0)
47
- return;
48
- const depthCol = table.getChild(FIELD_DEPTH);
49
- const cumulativeCol = table.getChild(FIELD_CUMULATIVE);
50
- const tsCol = table.getChild(FIELD_TIMESTAMP);
51
- const mappingCol = table.getChild(FIELD_MAPPING_FILE);
52
- const filenameCol = table.getChild(FIELD_FUNCTION_FILE_NAME);
53
- if (depthCol == null || cumulativeCol == null)
54
- return;
55
- const numRows = table.numRows;
56
- for (let row = 0; row < numRows; row++) {
57
- const depth = depthCol.get(row) ?? 0;
58
- if (depth === 0)
59
- continue; // skip root
60
- if (depth > maxDepth)
61
- continue;
62
- const cumulative = Number(cumulativeCol.get(row) ?? 0n);
63
- if (cumulative <= 0)
64
- continue;
65
- const nodeWidth = (cumulative / tsRange) * width;
66
- if (nodeWidth < 0.5)
67
- continue;
68
- const ts = tsCol != null ? Number(tsCol.get(row)) : 0;
69
- const x = ((ts - Number(tsBounds[0])) / tsRange) * width;
70
- const y = (depth - 1) * RowHeight * yScale;
71
- const h = Math.max(1, RowHeight * yScale);
72
- // Get color using same logic as useNodeColor
73
- const colorAttribute = colorBy === 'filename'
74
- ? arrowToString(filenameCol?.get(row))
75
- : colorBy === 'binary'
76
- ? arrowToString(mappingCol?.get(row))
77
- : null;
78
- const color = colors[getLastItem(colorAttribute ?? '') ?? EVERYTHING_ELSE];
79
- ctx.fillStyle = color ?? (isDarkMode ? '#6b7280' : '#9ca3af');
80
- ctx.fillRect(x, y, Math.max(0.5, nodeWidth), h);
20
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
21
+ var MINIMAP_HEIGHT = 20;
22
+ export var MiniMap = /*#__PURE__*/React.memo(function MiniMap(_ref) {
23
+ var _scrollLeftRef$curren;
24
+ var containerRef = _ref.containerRef,
25
+ table = _ref.table,
26
+ width = _ref.width,
27
+ zoomedWidth = _ref.zoomedWidth,
28
+ totalHeight = _ref.totalHeight,
29
+ maxDepth = _ref.maxDepth,
30
+ colors = _ref.colorByColors,
31
+ colorBy = _ref.colorBy,
32
+ profileSource = _ref.profileSource,
33
+ isDarkMode = _ref.isDarkMode,
34
+ _scrollLeft = _ref.scrollLeft,
35
+ scrollLeftRef = _ref.scrollLeftRef,
36
+ onZoomToPosition = _ref.onZoomToPosition,
37
+ onSetZoomWithScroll = _ref.onSetZoomWithScroll;
38
+ var canvasRef = useRef(null);
39
+ var containerElRef = useRef(null);
40
+ var isDragging = useRef(false);
41
+ var dragStartX = useRef(0);
42
+ var dragStartScrollLeft = useRef(0);
43
+
44
+ // Render minimap canvas
45
+ useEffect(function () {
46
+ var canvas = canvasRef.current;
47
+ if (canvas == null || width <= 0 || zoomedWidth <= 0) return;
48
+ var dpr = window.devicePixelRatio !== 0 ? window.devicePixelRatio : 1;
49
+ canvas.width = width * dpr;
50
+ canvas.height = MINIMAP_HEIGHT * dpr;
51
+ var ctx = canvas.getContext('2d');
52
+ if (ctx == null) return;
53
+ ctx.scale(dpr, dpr);
54
+ ctx.clearRect(0, 0, width, MINIMAP_HEIGHT);
55
+
56
+ // Background
57
+ ctx.fillStyle = isDarkMode ? '#374151' : '#f3f4f6';
58
+ ctx.fillRect(0, 0, width, MINIMAP_HEIGHT);
59
+ var yScale = MINIMAP_HEIGHT / totalHeight;
60
+ var tsBounds = boundsFromProfileSource(profileSource);
61
+ var tsRange = Number(tsBounds[1]) - Number(tsBounds[0]);
62
+ if (tsRange <= 0) return;
63
+ var depthCol = table.getChild(FIELD_DEPTH);
64
+ var cumulativeCol = table.getChild(FIELD_CUMULATIVE);
65
+ var tsCol = table.getChild(FIELD_TIMESTAMP);
66
+ var mappingCol = table.getChild(FIELD_MAPPING_FILE);
67
+ var filenameCol = table.getChild(FIELD_FUNCTION_FILE_NAME);
68
+ if (depthCol == null || cumulativeCol == null) return;
69
+ var numRows = table.numRows;
70
+ for (var row = 0; row < numRows; row++) {
71
+ var _depthCol$get, _cumulativeCol$get, _getLastItem;
72
+ var depth = (_depthCol$get = depthCol.get(row)) !== null && _depthCol$get !== void 0 ? _depthCol$get : 0;
73
+ if (depth === 0) continue; // skip root
74
+
75
+ if (depth > maxDepth) continue;
76
+ var cumulative = Number((_cumulativeCol$get = cumulativeCol.get(row)) !== null && _cumulativeCol$get !== void 0 ? _cumulativeCol$get : 0n);
77
+ if (cumulative <= 0) continue;
78
+ var nodeWidth = cumulative / tsRange * width;
79
+ if (nodeWidth < 0.5) continue;
80
+ var ts = tsCol != null ? Number(tsCol.get(row)) : 0;
81
+ var x = (ts - Number(tsBounds[0])) / tsRange * width;
82
+ var y = (depth - 1) * RowHeight * yScale;
83
+ var h = Math.max(1, RowHeight * yScale);
84
+
85
+ // Get color using same logic as useNodeColor
86
+ var colorAttribute = colorBy === 'filename' ? arrowToString(filenameCol === null || filenameCol === void 0 ? void 0 : filenameCol.get(row)) : colorBy === 'binary' ? arrowToString(mappingCol === null || mappingCol === void 0 ? void 0 : mappingCol.get(row)) : null;
87
+ var color = colors[(_getLastItem = getLastItem(colorAttribute !== null && colorAttribute !== void 0 ? colorAttribute : '')) !== null && _getLastItem !== void 0 ? _getLastItem : EVERYTHING_ELSE];
88
+ ctx.fillStyle = color !== null && color !== void 0 ? color : isDarkMode ? '#6b7280' : '#9ca3af';
89
+ ctx.fillRect(x, y, Math.max(0.5, nodeWidth), h);
90
+ }
91
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- zoomedWidth intentionally excluded: canvas is zoom-independent
92
+ }, [table, width, totalHeight, maxDepth, colorBy, colors, isDarkMode, profileSource]);
93
+ var isZoomed = zoomedWidth > width;
94
+ var sliderWidth = Math.max(20, width / zoomedWidth * width);
95
+ // Use scrollLeftRef for positioning — it's pre-set before flushSync during zoom changes,
96
+ // avoiding the 1-frame lag where viewport.scrollLeft is stale but zoomedWidth is already updated.
97
+ var currentScrollLeft = (_scrollLeftRef$curren = scrollLeftRef.current) !== null && _scrollLeftRef$curren !== void 0 ? _scrollLeftRef$curren : 0;
98
+ var sliderLeft = Math.min(currentScrollLeft / zoomedWidth * width, width - sliderWidth);
99
+ var EDGE_HIT_ZONE = 6;
100
+ var handleMouseDown = useCallback(function (e) {
101
+ var _containerElRef$curre;
102
+ e.preventDefault();
103
+ var rect = (_containerElRef$curre = containerElRef.current) === null || _containerElRef$curre === void 0 ? void 0 : _containerElRef$curre.getBoundingClientRect();
104
+ if (rect == null) return;
105
+ var clickX = e.clientX - rect.left;
106
+
107
+ // When not zoomed, clicking the minimap zooms into a +-50px region
108
+ if (!isZoomed) {
109
+ var regionPx = 100; // 50px on each side of the click
110
+ var targetZoom = width / regionPx;
111
+ onZoomToPosition === null || onZoomToPosition === void 0 || onZoomToPosition(clickX / width, targetZoom);
112
+ return;
113
+ }
114
+ var sliderRight = sliderLeft + sliderWidth;
115
+ var isNearLeftEdge = Math.abs(clickX - sliderLeft) <= EDGE_HIT_ZONE && clickX <= sliderLeft + EDGE_HIT_ZONE;
116
+ var isNearRightEdge = Math.abs(clickX - sliderRight) <= EDGE_HIT_ZONE && clickX >= sliderRight - EDGE_HIT_ZONE;
117
+
118
+ // Edge drag: resize the zoomed region by dragging one bound
119
+ if (isNearLeftEdge || isNearRightEdge) {
120
+ var edge = isNearLeftEdge ? 'left' : 'right';
121
+ // The opposite edge stays fixed in minimap coordinates
122
+ var anchorPx = edge === 'left' ? sliderRight : sliderLeft;
123
+ var MIN_SLIDER_PX = 10;
124
+ var edgeRafId = null;
125
+ var pendingEdgeEvent = null;
126
+ var applyEdgeMove = function applyEdgeMove() {
127
+ var _containerElRef$curre2;
128
+ edgeRafId = null;
129
+ var moveEvent = pendingEdgeEvent;
130
+ if (moveEvent == null) return;
131
+ pendingEdgeEvent = null;
132
+ var moveRect = (_containerElRef$curre2 = containerElRef.current) === null || _containerElRef$curre2 === void 0 ? void 0 : _containerElRef$curre2.getBoundingClientRect();
133
+ if (moveRect == null) return;
134
+ var edgePx = moveEvent.clientX - moveRect.left;
135
+ edgePx = Math.max(0, Math.min(edgePx, width));
136
+ var newLeft;
137
+ var newRight;
138
+ if (edge === 'left') {
139
+ newLeft = Math.min(edgePx, anchorPx - MIN_SLIDER_PX);
140
+ newRight = anchorPx;
141
+ } else {
142
+ newLeft = anchorPx;
143
+ newRight = Math.max(edgePx, anchorPx + MIN_SLIDER_PX);
144
+ }
145
+ var newSliderWidth = newRight - newLeft;
146
+ var newZoom = width / newSliderWidth;
147
+ var newScrollLeft = newLeft * newZoom;
148
+ onSetZoomWithScroll === null || onSetZoomWithScroll === void 0 || onSetZoomWithScroll(newZoom, newScrollLeft);
149
+ };
150
+ var handleEdgeMove = function handleEdgeMove(moveEvent) {
151
+ pendingEdgeEvent = moveEvent;
152
+ if (edgeRafId === null) {
153
+ edgeRafId = requestAnimationFrame(applyEdgeMove);
154
+ }
155
+ };
156
+ var _handleEdgeUp = function handleEdgeUp() {
157
+ if (edgeRafId !== null) {
158
+ cancelAnimationFrame(edgeRafId);
159
+ // Apply final position immediately on mouse up
160
+ applyEdgeMove();
161
+ }
162
+ document.removeEventListener('mousemove', handleEdgeMove);
163
+ document.removeEventListener('mouseup', _handleEdgeUp);
164
+ };
165
+ document.addEventListener('mousemove', handleEdgeMove);
166
+ document.addEventListener('mouseup', _handleEdgeUp);
167
+ return;
168
+ }
169
+
170
+ // Check if clicking inside the slider — start pan drag
171
+ if (clickX >= sliderLeft && clickX <= sliderRight) {
172
+ isDragging.current = true;
173
+ dragStartX.current = e.clientX;
174
+ dragStartScrollLeft.current = currentScrollLeft;
175
+ } else {
176
+ var _containerRef$current, _containerRef$current2, _containerRef$current3, _containerRef$current4;
177
+ // Click-to-jump: center viewport at click position
178
+ var targetCenter = clickX / width * zoomedWidth;
179
+ var containerWidth = (_containerRef$current = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.clientWidth) !== null && _containerRef$current !== void 0 ? _containerRef$current : width;
180
+ var newScrollLeft = targetCenter - containerWidth / 2;
181
+ if (containerRef.current != null) {
182
+ containerRef.current.scrollLeft = Math.max(0, Math.min(newScrollLeft, zoomedWidth - containerWidth));
183
+ }
184
+ // Also start dragging from new position
185
+ isDragging.current = true;
186
+ dragStartX.current = e.clientX;
187
+ dragStartScrollLeft.current = (_containerRef$current3 = (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.scrollLeft) !== null && _containerRef$current3 !== void 0 ? _containerRef$current3 : 0;
188
+ }
189
+ var handleMouseMove = function handleMouseMove(moveEvent) {
190
+ var _containerRef$current5, _containerRef$current6;
191
+ if (!isDragging.current) return;
192
+ var delta = moveEvent.clientX - dragStartX.current;
193
+ var scrollDelta = delta * (zoomedWidth / width);
194
+ var containerWidth = (_containerRef$current5 = (_containerRef$current6 = containerRef.current) === null || _containerRef$current6 === void 0 ? void 0 : _containerRef$current6.clientWidth) !== null && _containerRef$current5 !== void 0 ? _containerRef$current5 : width;
195
+ if (containerRef.current != null) {
196
+ containerRef.current.scrollLeft = Math.max(0, Math.min(dragStartScrollLeft.current + scrollDelta, zoomedWidth - containerWidth));
197
+ }
198
+ };
199
+ var _handleMouseUp = function handleMouseUp() {
200
+ isDragging.current = false;
201
+ document.removeEventListener('mousemove', handleMouseMove);
202
+ document.removeEventListener('mouseup', _handleMouseUp);
203
+ };
204
+ document.addEventListener('mousemove', handleMouseMove);
205
+ document.addEventListener('mouseup', _handleMouseUp);
206
+ }, [sliderLeft, sliderWidth, currentScrollLeft, width, zoomedWidth, containerRef, isZoomed, onZoomToPosition, onSetZoomWithScroll]);
207
+
208
+ // Forward wheel events to the container so zoom (Ctrl+scroll) works on the minimap
209
+ useEffect(function () {
210
+ var el = containerElRef.current;
211
+ if (el == null) return;
212
+ var handleWheel = function handleWheel(e) {
213
+ var _containerRef$current7;
214
+ if (!e.ctrlKey && !e.metaKey) return;
215
+ e.preventDefault();
216
+ (_containerRef$current7 = containerRef.current) === null || _containerRef$current7 === void 0 || _containerRef$current7.dispatchEvent(new WheelEvent('wheel', {
217
+ deltaY: e.deltaY,
218
+ deltaX: e.deltaX,
219
+ ctrlKey: e.ctrlKey,
220
+ metaKey: e.metaKey,
221
+ clientX: e.clientX,
222
+ clientY: e.clientY,
223
+ bubbles: true
224
+ }));
225
+ };
226
+ el.addEventListener('wheel', handleWheel, {
227
+ passive: false
228
+ });
229
+ return function () {
230
+ el.removeEventListener('wheel', handleWheel);
231
+ };
232
+ }, [containerRef]);
233
+ if (width <= 0) return null;
234
+ return /*#__PURE__*/_jsxs("div", {
235
+ ref: containerElRef,
236
+ className: "relative select-none cursor-pointer",
237
+ style: {
238
+ width: width,
239
+ height: MINIMAP_HEIGHT
240
+ },
241
+ onMouseDown: handleMouseDown,
242
+ children: [/*#__PURE__*/_jsx("canvas", {
243
+ ref: canvasRef,
244
+ style: {
245
+ width: width,
246
+ height: MINIMAP_HEIGHT,
247
+ display: 'block'
248
+ }
249
+ }), isZoomed && /*#__PURE__*/_jsxs(_Fragment, {
250
+ children: [/*#__PURE__*/_jsx("div", {
251
+ className: "absolute top-0 bottom-0 bg-black/30 dark:bg-black/50",
252
+ style: {
253
+ left: 0,
254
+ width: Math.max(0, sliderLeft)
81
255
  }
82
- // eslint-disable-next-line react-hooks/exhaustive-deps -- zoomedWidth intentionally excluded: canvas is zoom-independent
83
- }, [table, width, totalHeight, maxDepth, colorBy, colors, isDarkMode, profileSource]);
84
- const isZoomed = zoomedWidth > width;
85
- const sliderWidth = Math.max(20, (width / zoomedWidth) * width);
86
- // Use scrollLeftRef for positioning — it's pre-set before flushSync during zoom changes,
87
- // avoiding the 1-frame lag where viewport.scrollLeft is stale but zoomedWidth is already updated.
88
- const currentScrollLeft = scrollLeftRef.current ?? 0;
89
- const sliderLeft = Math.min((currentScrollLeft / zoomedWidth) * width, width - sliderWidth);
90
- const EDGE_HIT_ZONE = 6;
91
- const handleMouseDown = useCallback((e) => {
92
- e.preventDefault();
93
- const rect = containerElRef.current?.getBoundingClientRect();
94
- if (rect == null)
95
- return;
96
- const clickX = e.clientX - rect.left;
97
- // When not zoomed, clicking the minimap zooms into a +-50px region
98
- if (!isZoomed) {
99
- const regionPx = 100; // 50px on each side of the click
100
- const targetZoom = width / regionPx;
101
- onZoomToPosition?.(clickX / width, targetZoom);
102
- return;
256
+ }), /*#__PURE__*/_jsx("div", {
257
+ className: "absolute top-0 bottom-0 border-x-2 border-gray-500",
258
+ style: {
259
+ left: sliderLeft,
260
+ width: sliderWidth
103
261
  }
104
- const sliderRight = sliderLeft + sliderWidth;
105
- const isNearLeftEdge = Math.abs(clickX - sliderLeft) <= EDGE_HIT_ZONE && clickX <= sliderLeft + EDGE_HIT_ZONE;
106
- const isNearRightEdge = Math.abs(clickX - sliderRight) <= EDGE_HIT_ZONE && clickX >= sliderRight - EDGE_HIT_ZONE;
107
- // Edge drag: resize the zoomed region by dragging one bound
108
- if (isNearLeftEdge || isNearRightEdge) {
109
- const edge = isNearLeftEdge ? 'left' : 'right';
110
- // The opposite edge stays fixed in minimap coordinates
111
- const anchorPx = edge === 'left' ? sliderRight : sliderLeft;
112
- const MIN_SLIDER_PX = 10;
113
- let edgeRafId = null;
114
- let pendingEdgeEvent = null;
115
- const applyEdgeMove = () => {
116
- edgeRafId = null;
117
- const moveEvent = pendingEdgeEvent;
118
- if (moveEvent == null)
119
- return;
120
- pendingEdgeEvent = null;
121
- const moveRect = containerElRef.current?.getBoundingClientRect();
122
- if (moveRect == null)
123
- return;
124
- let edgePx = moveEvent.clientX - moveRect.left;
125
- edgePx = Math.max(0, Math.min(edgePx, width));
126
- let newLeft;
127
- let newRight;
128
- if (edge === 'left') {
129
- newLeft = Math.min(edgePx, anchorPx - MIN_SLIDER_PX);
130
- newRight = anchorPx;
131
- }
132
- else {
133
- newLeft = anchorPx;
134
- newRight = Math.max(edgePx, anchorPx + MIN_SLIDER_PX);
135
- }
136
- const newSliderWidth = newRight - newLeft;
137
- const newZoom = width / newSliderWidth;
138
- const newScrollLeft = newLeft * newZoom;
139
- onSetZoomWithScroll?.(newZoom, newScrollLeft);
140
- };
141
- const handleEdgeMove = (moveEvent) => {
142
- pendingEdgeEvent = moveEvent;
143
- if (edgeRafId === null) {
144
- edgeRafId = requestAnimationFrame(applyEdgeMove);
145
- }
146
- };
147
- const handleEdgeUp = () => {
148
- if (edgeRafId !== null) {
149
- cancelAnimationFrame(edgeRafId);
150
- // Apply final position immediately on mouse up
151
- applyEdgeMove();
152
- }
153
- document.removeEventListener('mousemove', handleEdgeMove);
154
- document.removeEventListener('mouseup', handleEdgeUp);
155
- };
156
- document.addEventListener('mousemove', handleEdgeMove);
157
- document.addEventListener('mouseup', handleEdgeUp);
158
- return;
262
+ }), /*#__PURE__*/_jsx("div", {
263
+ className: "absolute top-0 bottom-0 cursor-col-resize",
264
+ style: {
265
+ left: sliderLeft - EDGE_HIT_ZONE,
266
+ width: EDGE_HIT_ZONE * 2
159
267
  }
160
- // Check if clicking inside the slider — start pan drag
161
- if (clickX >= sliderLeft && clickX <= sliderRight) {
162
- isDragging.current = true;
163
- dragStartX.current = e.clientX;
164
- dragStartScrollLeft.current = currentScrollLeft;
268
+ }), /*#__PURE__*/_jsx("div", {
269
+ className: "absolute top-0 bottom-0 cursor-col-resize",
270
+ style: {
271
+ left: sliderLeft + sliderWidth - EDGE_HIT_ZONE,
272
+ width: EDGE_HIT_ZONE * 2
165
273
  }
166
- else {
167
- // Click-to-jump: center viewport at click position
168
- const targetCenter = (clickX / width) * zoomedWidth;
169
- const containerWidth = containerRef.current?.clientWidth ?? width;
170
- const newScrollLeft = targetCenter - containerWidth / 2;
171
- if (containerRef.current != null) {
172
- containerRef.current.scrollLeft = Math.max(0, Math.min(newScrollLeft, zoomedWidth - containerWidth));
173
- }
174
- // Also start dragging from new position
175
- isDragging.current = true;
176
- dragStartX.current = e.clientX;
177
- dragStartScrollLeft.current = containerRef.current?.scrollLeft ?? 0;
274
+ }), /*#__PURE__*/_jsx("div", {
275
+ className: "absolute top-0 bottom-0 bg-black/30 dark:bg-black/50",
276
+ style: {
277
+ left: sliderLeft + sliderWidth,
278
+ right: 0
178
279
  }
179
- const handleMouseMove = (moveEvent) => {
180
- if (!isDragging.current)
181
- return;
182
- const delta = moveEvent.clientX - dragStartX.current;
183
- const scrollDelta = delta * (zoomedWidth / width);
184
- const containerWidth = containerRef.current?.clientWidth ?? width;
185
- if (containerRef.current != null) {
186
- containerRef.current.scrollLeft = Math.max(0, Math.min(dragStartScrollLeft.current + scrollDelta, zoomedWidth - containerWidth));
187
- }
188
- };
189
- const handleMouseUp = () => {
190
- isDragging.current = false;
191
- document.removeEventListener('mousemove', handleMouseMove);
192
- document.removeEventListener('mouseup', handleMouseUp);
193
- };
194
- document.addEventListener('mousemove', handleMouseMove);
195
- document.addEventListener('mouseup', handleMouseUp);
196
- }, [
197
- sliderLeft,
198
- sliderWidth,
199
- currentScrollLeft,
200
- width,
201
- zoomedWidth,
202
- containerRef,
203
- isZoomed,
204
- onZoomToPosition,
205
- onSetZoomWithScroll,
206
- ]);
207
- // Forward wheel events to the container so zoom (Ctrl+scroll) works on the minimap
208
- useEffect(() => {
209
- const el = containerElRef.current;
210
- if (el == null)
211
- return;
212
- const handleWheel = (e) => {
213
- if (!e.ctrlKey && !e.metaKey)
214
- return;
215
- e.preventDefault();
216
- containerRef.current?.dispatchEvent(new WheelEvent('wheel', {
217
- deltaY: e.deltaY,
218
- deltaX: e.deltaX,
219
- ctrlKey: e.ctrlKey,
220
- metaKey: e.metaKey,
221
- clientX: e.clientX,
222
- clientY: e.clientY,
223
- bubbles: true,
224
- }));
225
- };
226
- el.addEventListener('wheel', handleWheel, { passive: false });
227
- return () => {
228
- el.removeEventListener('wheel', handleWheel);
229
- };
230
- }, [containerRef]);
231
- if (width <= 0)
232
- return null;
233
- return (_jsxs("div", { ref: containerElRef, className: "relative select-none cursor-pointer", style: { width, height: MINIMAP_HEIGHT }, onMouseDown: handleMouseDown, children: [_jsx("canvas", { ref: canvasRef, style: {
234
- width,
235
- height: MINIMAP_HEIGHT,
236
- display: 'block',
237
- } }), isZoomed && (_jsxs(_Fragment, { children: [_jsx("div", { className: "absolute top-0 bottom-0 bg-black/30 dark:bg-black/50", style: { left: 0, width: Math.max(0, sliderLeft) } }), _jsx("div", { className: "absolute top-0 bottom-0 border-x-2 border-gray-500", style: { left: sliderLeft, width: sliderWidth } }), _jsx("div", { className: "absolute top-0 bottom-0 cursor-col-resize", style: { left: sliderLeft - EDGE_HIT_ZONE, width: EDGE_HIT_ZONE * 2 } }), _jsx("div", { className: "absolute top-0 bottom-0 cursor-col-resize", style: { left: sliderLeft + sliderWidth - EDGE_HIT_ZONE, width: EDGE_HIT_ZONE * 2 } }), _jsx("div", { className: "absolute top-0 bottom-0 bg-black/30 dark:bg-black/50", style: { left: sliderLeft + sliderWidth, right: 0 } })] }))] }));
238
- });
280
+ })]
281
+ })]
282
+ });
283
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"TextWithEllipsis.d.ts","sourceRoot":"","sources":["../../../src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx"],"names":[],"mappings":"AAmBA,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf;AA2CD,iBAAS,gBAAgB,CAAC,EAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAC,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAuBjE;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"TextWithEllipsis.d.ts","sourceRoot":"","sources":["../../../src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx"],"names":[],"mappings":"AAqBA,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf;AA2CD,iBAAS,gBAAgB,CAAC,EAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAC,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAwBjE;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,4 +1,9 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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; } }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
2
7
  // Copyright 2022 The Parca Authors
3
8
  // Licensed under the Apache License, Version 2.0 (the "License");
4
9
  // you may not use this file except in compliance with the License.
@@ -11,54 +16,75 @@ import { jsx as _jsx } from "react/jsx-runtime";
11
16
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
17
  // See the License for the specific language governing permissions and
13
18
  // limitations under the License.
19
+
20
+ /* eslint-disable react-hooks/set-state-in-effect */
21
+
14
22
  import { useEffect, useRef, useState } from 'react';
15
23
  import { useQueryState } from 'nuqs';
16
24
  import { stringParam } from '../../hooks/urlParsers';
25
+ import { jsx as _jsx } from "react/jsx-runtime";
17
26
  function calculateTruncatedText(text, textElement, maxWidth) {
18
- // Create a temporary element for measurement
19
- const tempElement = textElement.cloneNode();
20
- tempElement.textContent = text;
21
- textElement.parentElement?.appendChild(tempElement);
22
- // If the text fits, return it
23
- const fullWidth = tempElement.getComputedTextLength();
24
- if (fullWidth <= maxWidth) {
25
- textElement.parentElement?.removeChild(tempElement);
26
- return text;
27
- }
28
- // Binary search to find the maximum text that fits
29
- let start = 0;
30
- let end = text.length;
31
- let result = text;
32
- while (start < end) {
33
- const mid = Math.floor((start + end + 1) / 2);
34
- const truncated = text.slice(-mid);
35
- tempElement.textContent = truncated;
36
- const currentWidth = tempElement.getComputedTextLength();
37
- if (currentWidth <= maxWidth) {
38
- result = truncated;
39
- start = mid;
40
- }
41
- else {
42
- end = mid - 1;
43
- }
27
+ var _textElement$parentEl, _textElement$parentEl3;
28
+ // Create a temporary element for measurement
29
+ var tempElement = textElement.cloneNode();
30
+ tempElement.textContent = text;
31
+ (_textElement$parentEl = textElement.parentElement) === null || _textElement$parentEl === void 0 || _textElement$parentEl.appendChild(tempElement);
32
+
33
+ // If the text fits, return it
34
+ var fullWidth = tempElement.getComputedTextLength();
35
+ if (fullWidth <= maxWidth) {
36
+ var _textElement$parentEl2;
37
+ (_textElement$parentEl2 = textElement.parentElement) === null || _textElement$parentEl2 === void 0 || _textElement$parentEl2.removeChild(tempElement);
38
+ return text;
39
+ }
40
+
41
+ // Binary search to find the maximum text that fits
42
+ var start = 0;
43
+ var end = text.length;
44
+ var result = text;
45
+ while (start < end) {
46
+ var mid = Math.floor((start + end + 1) / 2);
47
+ var truncated = text.slice(-mid);
48
+ tempElement.textContent = truncated;
49
+ var currentWidth = tempElement.getComputedTextLength();
50
+ if (currentWidth <= maxWidth) {
51
+ result = truncated;
52
+ start = mid;
53
+ } else {
54
+ end = mid - 1;
44
55
  }
45
- textElement.parentElement?.removeChild(tempElement);
46
- return result;
56
+ }
57
+ (_textElement$parentEl3 = textElement.parentElement) === null || _textElement$parentEl3 === void 0 || _textElement$parentEl3.removeChild(tempElement);
58
+ return result;
47
59
  }
48
- function TextWithEllipsis({ text, x, y, width }) {
49
- const textRef = useRef(null);
50
- const [displayText, setDisplayText] = useState(text);
51
- const [alignFunctionName] = useQueryState('align_function_name', stringParam.withDefault('left'));
52
- const showFunctionNameFromLeft = alignFunctionName === 'left';
53
- useEffect(() => {
54
- const textElement = textRef.current;
55
- if (textElement === null)
56
- return;
57
- const newText = showFunctionNameFromLeft
58
- ? text
59
- : calculateTruncatedText(text, textElement, width);
60
- setDisplayText(newText);
61
- }, [text, width, showFunctionNameFromLeft]);
62
- return (_jsx("text", { ref: textRef, x: x, y: y, className: "text-xs", children: displayText }));
60
+ function TextWithEllipsis(_ref) {
61
+ 'use no memo';
62
+
63
+ var text = _ref.text,
64
+ x = _ref.x,
65
+ y = _ref.y,
66
+ width = _ref.width;
67
+ var textRef = useRef(null);
68
+ var _useState = useState(text),
69
+ _useState2 = _slicedToArray(_useState, 2),
70
+ displayText = _useState2[0],
71
+ setDisplayText = _useState2[1];
72
+ var _useQueryState = useQueryState('align_function_name', stringParam.withDefault('left')),
73
+ _useQueryState2 = _slicedToArray(_useQueryState, 1),
74
+ alignFunctionName = _useQueryState2[0];
75
+ var showFunctionNameFromLeft = alignFunctionName === 'left';
76
+ useEffect(function () {
77
+ var textElement = textRef.current;
78
+ if (textElement === null) return;
79
+ var newText = showFunctionNameFromLeft ? text : calculateTruncatedText(text, textElement, width);
80
+ setDisplayText(newText);
81
+ }, [text, width, showFunctionNameFromLeft]);
82
+ return /*#__PURE__*/_jsx("text", {
83
+ ref: textRef,
84
+ x: x,
85
+ y: y,
86
+ className: "text-xs",
87
+ children: displayText
88
+ });
63
89
  }
64
- export default TextWithEllipsis;
90
+ export default TextWithEllipsis;
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipContext.d.ts","sourceRoot":"","sources":["../../../src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAgE,MAAM,OAAO,CAAC;AAErF,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,UAAU,mBAAmB;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACpE,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,eAAO,MAAM,iBAAiB,QAAO,mBAMpC,CAAC;AAEF,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAqC1D,CAAC"}
1
+ {"version":3,"file":"TooltipContext.d.ts","sourceRoot":"","sources":["../../../src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAgE,MAAM,OAAO,CAAC;AAErF,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,UAAU,mBAAmB;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACpE,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,eAAO,MAAM,iBAAiB,QAAO,mBAMpC,CAAC;AAEF,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAsC1D,CAAC"}