@parca/profile 0.19.139 → 0.19.142

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/CHANGELOG.md +8 -0
  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 +103 -73
  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.js +240 -49
  28. package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
  29. package/dist/ProfileExplorer/index.js +183 -32
  30. package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
  31. package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
  32. package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
  33. package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
  34. package/dist/ProfileFlameChart/index.js +266 -134
  35. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +287 -88
  36. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
  37. package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
  38. package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
  39. package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
  40. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  41. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +71 -45
  42. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
  43. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
  44. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
  45. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
  46. package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
  47. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
  48. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
  49. package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
  50. package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
  51. package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
  52. package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
  53. package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
  54. package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
  55. package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
  56. package/dist/ProfileFlameGraph/index.js +324 -148
  57. package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
  58. package/dist/ProfileMetricsGraph/index.js +518 -259
  59. package/dist/ProfileSelector/CompareButton.js +132 -12
  60. package/dist/ProfileSelector/MetricsGraphSection.js +234 -67
  61. package/dist/ProfileSelector/index.d.ts.map +1 -1
  62. package/dist/ProfileSelector/index.js +730 -142
  63. package/dist/ProfileSelector/useAutoQuerySelector.js +249 -130
  64. package/dist/ProfileSource.js +230 -163
  65. package/dist/ProfileTypeSelector/index.js +214 -125
  66. package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
  67. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +139 -33
  68. package/dist/ProfileView/components/ColorStackLegend.js +184 -55
  69. package/dist/ProfileView/components/DashboardItems/index.js +87 -28
  70. package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
  71. package/dist/ProfileView/components/DiffLegend.js +172 -29
  72. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
  73. package/dist/ProfileView/components/InvertCallStack/index.js +99 -10
  74. package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
  75. package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
  76. package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
  77. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +188 -120
  78. package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
  79. package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
  80. package/dist/ProfileView/components/ShareButton/index.js +352 -62
  81. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  82. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +675 -195
  83. package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
  84. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +198 -157
  85. package/dist/ProfileView/components/Toolbars/index.js +441 -21
  86. package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
  87. package/dist/ProfileView/components/ViewSelector/index.js +211 -91
  88. package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
  89. package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
  90. package/dist/ProfileView/components/VisualizationPanel.js +185 -8
  91. package/dist/ProfileView/context/DashboardContext.js +84 -28
  92. package/dist/ProfileView/context/ProfileViewContext.js +56 -15
  93. package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
  94. package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
  95. package/dist/ProfileView/hooks/useResetFlameGraphState.js +31 -10
  96. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +72 -29
  97. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +39 -13
  98. package/dist/ProfileView/hooks/useVisualizationState.js +262 -87
  99. package/dist/ProfileView/index.js +383 -45
  100. package/dist/ProfileView/types/visualization.js +1 -13
  101. package/dist/ProfileView/utils/colorUtils.js +8 -7
  102. package/dist/ProfileViewWithData.js +332 -237
  103. package/dist/QueryControls/index.js +418 -47
  104. package/dist/Sandwich/components/CalleesSection.js +54 -4
  105. package/dist/Sandwich/components/CallersSection.js +97 -27
  106. package/dist/Sandwich/components/TableSection.js +77 -4
  107. package/dist/Sandwich/index.js +125 -12
  108. package/dist/Sandwich/utils/processRowData.js +48 -39
  109. package/dist/SelectWithRefresh/index.js +102 -28
  110. package/dist/SimpleMatchers/Select.js +520 -187
  111. package/dist/SimpleMatchers/index.js +590 -288
  112. package/dist/SourceView/Highlighter.js +230 -70
  113. package/dist/SourceView/LineNo.js +72 -17
  114. package/dist/SourceView/index.js +177 -101
  115. package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
  116. package/dist/SourceView/lang-detector/index.js +28 -14
  117. package/dist/SourceView/useSelectedLineRange.js +97 -16
  118. package/dist/Table/ColorCell.js +42 -1
  119. package/dist/Table/ColumnsVisibility.js +114 -6
  120. package/dist/Table/MoreDropdown.js +121 -27
  121. package/dist/Table/TableContextMenu.js +150 -139
  122. package/dist/Table/TableContextMenuWrapper.js +59 -14
  123. package/dist/Table/hooks/useColorManagement.js +58 -16
  124. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  125. package/dist/Table/hooks/useTableConfiguration.js +331 -168
  126. package/dist/Table/index.js +222 -126
  127. package/dist/Table/utils/functions.js +169 -144
  128. package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
  129. package/dist/TimelineGuide/index.js +209 -16
  130. package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
  131. package/dist/TopTable/index.js +340 -122
  132. package/dist/contexts/LabelsQueryProvider.js +94 -32
  133. package/dist/contexts/UnifiedLabelsContext.js +114 -49
  134. package/dist/contexts/utils.js +37 -15
  135. package/dist/hooks/useCompareModeMeta.js +157 -94
  136. package/dist/hooks/useLabels.js +295 -52
  137. package/dist/hooks/useQueryState.js +371 -330
  138. package/dist/index.js +21 -16
  139. package/dist/testdata/fg-diff.json +3750 -0
  140. package/dist/testdata/fg-simple.json +1879 -0
  141. package/dist/testdata/link_data.json +56 -0
  142. package/dist/testdata/tabular.json +30 -0
  143. package/dist/testdata/test_flamegraph.json +26846 -0
  144. package/dist/testdata/test_graph.json +53 -0
  145. package/dist/useDelayedLoader.js +32 -18
  146. package/dist/useGrpcQuery/index.js +71 -11
  147. package/dist/useHasProfileData.js +90 -12
  148. package/dist/useQuery.js +205 -64
  149. package/dist/useSumBy.d.ts.map +1 -1
  150. package/dist/useSumBy.js +294 -138
  151. package/dist/utils.js +62 -30
  152. package/package.json +9 -9
  153. package/src/GraphTooltipArrow/index.tsx +3 -0
  154. package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
  155. package/src/MatchersInput/SuggestionsList.tsx +11 -10
  156. package/src/MatchersInput/index.tsx +1 -1
  157. package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
  158. package/src/PreSelectedMatchers/index.tsx +3 -0
  159. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +3 -0
  160. package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
  161. package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
  162. package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
  163. package/src/ProfileSelector/index.tsx +30 -7
  164. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +3 -0
  165. package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
  166. package/src/Table/hooks/useTableConfiguration.tsx +7 -13
  167. package/src/useDelayedLoader.ts +10 -10
  168. package/src/useSumBy.ts +12 -18
  169. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -541
  170. package/dist/hooks/useQueryState.test.js +0 -984
@@ -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":"AAiBA,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":"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,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,53 +16,74 @@ 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 { useURLState } from '@parca/components';
24
+ import { jsx as _jsx } from "react/jsx-runtime";
16
25
  function calculateTruncatedText(text, textElement, maxWidth) {
17
- // Create a temporary element for measurement
18
- const tempElement = textElement.cloneNode();
19
- tempElement.textContent = text;
20
- textElement.parentElement?.appendChild(tempElement);
21
- // If the text fits, return it
22
- const fullWidth = tempElement.getComputedTextLength();
23
- if (fullWidth <= maxWidth) {
24
- textElement.parentElement?.removeChild(tempElement);
25
- return text;
26
- }
27
- // Binary search to find the maximum text that fits
28
- let start = 0;
29
- let end = text.length;
30
- let result = text;
31
- while (start < end) {
32
- const mid = Math.floor((start + end + 1) / 2);
33
- const truncated = text.slice(-mid);
34
- tempElement.textContent = truncated;
35
- const currentWidth = tempElement.getComputedTextLength();
36
- if (currentWidth <= maxWidth) {
37
- result = truncated;
38
- start = mid;
39
- }
40
- else {
41
- end = mid - 1;
42
- }
26
+ var _textElement$parentEl, _textElement$parentEl3;
27
+ // Create a temporary element for measurement
28
+ var tempElement = textElement.cloneNode();
29
+ tempElement.textContent = text;
30
+ (_textElement$parentEl = textElement.parentElement) === null || _textElement$parentEl === void 0 || _textElement$parentEl.appendChild(tempElement);
31
+
32
+ // If the text fits, return it
33
+ var fullWidth = tempElement.getComputedTextLength();
34
+ if (fullWidth <= maxWidth) {
35
+ var _textElement$parentEl2;
36
+ (_textElement$parentEl2 = textElement.parentElement) === null || _textElement$parentEl2 === void 0 || _textElement$parentEl2.removeChild(tempElement);
37
+ return text;
38
+ }
39
+
40
+ // Binary search to find the maximum text that fits
41
+ var start = 0;
42
+ var end = text.length;
43
+ var result = text;
44
+ while (start < end) {
45
+ var mid = Math.floor((start + end + 1) / 2);
46
+ var truncated = text.slice(-mid);
47
+ tempElement.textContent = truncated;
48
+ var currentWidth = tempElement.getComputedTextLength();
49
+ if (currentWidth <= maxWidth) {
50
+ result = truncated;
51
+ start = mid;
52
+ } else {
53
+ end = mid - 1;
43
54
  }
44
- textElement.parentElement?.removeChild(tempElement);
45
- return result;
55
+ }
56
+ (_textElement$parentEl3 = textElement.parentElement) === null || _textElement$parentEl3 === void 0 || _textElement$parentEl3.removeChild(tempElement);
57
+ return result;
46
58
  }
47
- function TextWithEllipsis({ text, x, y, width }) {
48
- const textRef = useRef(null);
49
- const [displayText, setDisplayText] = useState(text);
50
- const [alignFunctionName] = useURLState('align_function_name');
51
- const showFunctionNameFromLeft = alignFunctionName === 'left' || alignFunctionName === undefined;
52
- useEffect(() => {
53
- const textElement = textRef.current;
54
- if (textElement === null)
55
- return;
56
- const newText = showFunctionNameFromLeft
57
- ? text
58
- : calculateTruncatedText(text, textElement, width);
59
- setDisplayText(newText);
60
- }, [text, width, showFunctionNameFromLeft]);
61
- return (_jsx("text", { ref: textRef, x: x, y: y, className: "text-xs", children: displayText }));
59
+ function TextWithEllipsis(_ref) {
60
+ 'use no memo';
61
+
62
+ var text = _ref.text,
63
+ x = _ref.x,
64
+ y = _ref.y,
65
+ width = _ref.width;
66
+ var textRef = useRef(null);
67
+ var _useState = useState(text),
68
+ _useState2 = _slicedToArray(_useState, 2),
69
+ displayText = _useState2[0],
70
+ setDisplayText = _useState2[1];
71
+ var _useURLState = useURLState('align_function_name'),
72
+ _useURLState2 = _slicedToArray(_useURLState, 1),
73
+ alignFunctionName = _useURLState2[0];
74
+ var showFunctionNameFromLeft = alignFunctionName === 'left' || alignFunctionName === undefined;
75
+ useEffect(function () {
76
+ var textElement = textRef.current;
77
+ if (textElement === null) return;
78
+ var newText = showFunctionNameFromLeft ? text : calculateTruncatedText(text, textElement, width);
79
+ setDisplayText(newText);
80
+ }, [text, width, showFunctionNameFromLeft]);
81
+ return /*#__PURE__*/_jsx("text", {
82
+ ref: textRef,
83
+ x: x,
84
+ y: y,
85
+ className: "text-xs",
86
+ children: displayText
87
+ });
62
88
  }
63
- export default TextWithEllipsis;
89
+ 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"}