@parca/profile 0.19.140 → 0.19.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/dist/GraphTooltipArrow/Content.js +224 -30
- package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
- package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
- package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/index.js +86 -56
- package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +104 -72
- package/dist/MatchersInput/SuggestionItem.js +91 -12
- package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
- package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
- package/dist/MatchersInput/SuggestionsList.js +371 -157
- package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
- package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
- package/dist/MatchersInput/index.js +308 -115
- package/dist/MetricsCircle/index.js +39 -3
- package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
- package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
- package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
- package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
- package/dist/MetricsGraph/index.js +552 -203
- package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
- package/dist/MetricsGraph/utils/colorMapping.js +24 -17
- package/dist/MetricsSeries/index.js +70 -7
- package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
- package/dist/PreSelectedMatchers/index.js +249 -102
- package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
- package/dist/ProfileExplorer/ProfileExplorerCompare.js +241 -45
- package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
- package/dist/ProfileExplorer/index.js +183 -32
- package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
- package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
- package/dist/ProfileFlameChart/SamplesStrips/index.d.ts +2 -2
- package/dist/ProfileFlameChart/SamplesStrips/index.d.ts.map +1 -1
- package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
- package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
- package/dist/ProfileFlameChart/index.d.ts.map +1 -1
- package/dist/ProfileFlameChart/index.js +267 -129
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +288 -89
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
- package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
- package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +72 -47
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
- package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
- package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
- package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
- package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
- package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
- package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
- package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
- package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/index.js +324 -150
- package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
- package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
- package/dist/ProfileMetricsGraph/index.js +519 -258
- package/dist/ProfileSelector/CompareButton.js +132 -12
- package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
- package/dist/ProfileSelector/MetricsGraphSection.js +236 -64
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +727 -141
- package/dist/ProfileSelector/useAutoQuerySelector.js +249 -130
- package/dist/ProfileSource.js +230 -163
- package/dist/ProfileTypeSelector/index.js +214 -125
- package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +141 -35
- package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
- package/dist/ProfileView/components/ColorStackLegend.js +185 -55
- package/dist/ProfileView/components/DashboardItems/index.js +87 -28
- package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
- package/dist/ProfileView/components/DiffLegend.js +172 -29
- package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
- package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
- package/dist/ProfileView/components/InvertCallStack/index.js +100 -12
- package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
- package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
- package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +2 -1
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +188 -118
- package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
- package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
- package/dist/ProfileView/components/ShareButton/index.js +352 -62
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +678 -194
- package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +199 -157
- package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
- package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/index.js +441 -21
- package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
- package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
- package/dist/ProfileView/components/ViewSelector/index.js +212 -86
- package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
- package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
- package/dist/ProfileView/components/VisualizationPanel.js +185 -8
- package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
- package/dist/ProfileView/context/DashboardContext.js +85 -29
- package/dist/ProfileView/context/ProfileViewContext.js +56 -15
- package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
- package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
- package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetFlameGraphState.js +32 -12
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +40 -19
- package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
- package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useVisualizationState.js +258 -67
- package/dist/ProfileView/index.js +383 -45
- package/dist/ProfileView/types/visualization.js +1 -13
- package/dist/ProfileView/utils/colorUtils.js +8 -7
- package/dist/ProfileViewWithData.d.ts.map +1 -1
- package/dist/ProfileViewWithData.js +332 -228
- package/dist/QueryControls/index.js +418 -47
- package/dist/Sandwich/components/CalleesSection.js +54 -4
- package/dist/Sandwich/components/CallersSection.js +97 -27
- package/dist/Sandwich/components/TableSection.js +77 -4
- package/dist/Sandwich/index.d.ts.map +1 -1
- package/dist/Sandwich/index.js +126 -14
- package/dist/Sandwich/utils/processRowData.js +48 -39
- package/dist/SelectWithRefresh/index.js +102 -28
- package/dist/SimpleMatchers/Select.js +520 -187
- package/dist/SimpleMatchers/index.js +590 -288
- package/dist/SourceView/Highlighter.js +230 -70
- package/dist/SourceView/LineNo.js +72 -17
- package/dist/SourceView/index.d.ts.map +1 -1
- package/dist/SourceView/index.js +178 -104
- package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
- package/dist/SourceView/lang-detector/index.js +28 -14
- package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
- package/dist/SourceView/useSelectedLineRange.js +99 -23
- package/dist/Table/ColorCell.js +42 -1
- package/dist/Table/ColumnsVisibility.js +114 -6
- package/dist/Table/MoreDropdown.d.ts.map +1 -1
- package/dist/Table/MoreDropdown.js +122 -25
- package/dist/Table/TableContextMenu.d.ts.map +1 -1
- package/dist/Table/TableContextMenu.js +151 -137
- package/dist/Table/TableContextMenuWrapper.js +59 -14
- package/dist/Table/hooks/useColorManagement.js +58 -16
- package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
- package/dist/Table/hooks/useTableConfiguration.js +333 -169
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +222 -128
- package/dist/Table/utils/functions.js +169 -144
- package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
- package/dist/TimelineGuide/index.js +209 -16
- package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
- package/dist/TopTable/index.d.ts.map +1 -1
- package/dist/TopTable/index.js +342 -123
- package/dist/contexts/LabelsQueryProvider.js +94 -32
- package/dist/contexts/UnifiedLabelsContext.js +114 -49
- package/dist/contexts/utils.js +37 -15
- package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
- package/dist/hooks/useCompareModeMeta.js +158 -64
- package/dist/hooks/useLabels.js +295 -52
- package/dist/hooks/useQueryState.d.ts +3 -3
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +373 -332
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -8
- package/dist/testdata/fg-diff.json +3750 -0
- package/dist/testdata/fg-simple.json +1879 -0
- package/dist/testdata/link_data.json +56 -0
- package/dist/testdata/tabular.json +30 -0
- package/dist/testdata/test_flamegraph.json +26846 -0
- package/dist/testdata/test_graph.json +53 -0
- package/dist/useDelayedLoader.js +32 -18
- package/dist/useGrpcQuery/index.js +71 -11
- package/dist/useHasProfileData.js +90 -12
- package/dist/useQuery.js +205 -64
- package/dist/useSumBy.d.ts +1 -1
- package/dist/useSumBy.d.ts.map +1 -1
- package/dist/useSumBy.js +294 -138
- package/dist/utils.js +62 -30
- package/package.json +9 -10
- package/src/GraphTooltipArrow/index.tsx +3 -0
- package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +13 -11
- package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
- package/src/MatchersInput/SuggestionsList.tsx +11 -10
- package/src/MatchersInput/index.tsx +1 -1
- package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
- package/src/PreSelectedMatchers/index.tsx +3 -0
- package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -4
- package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
- package/src/ProfileFlameChart/index.tsx +28 -21
- package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +9 -10
- package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +6 -5
- package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
- package/src/ProfileFlameGraph/index.tsx +9 -6
- package/src/ProfileMetricsGraph/index.tsx +8 -6
- package/src/ProfileSelector/MetricsGraphSection.tsx +10 -5
- package/src/ProfileSelector/index.tsx +61 -39
- package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +6 -10
- package/src/ProfileView/components/ColorStackLegend.tsx +4 -2
- package/src/ProfileView/components/InvertCallStack/index.tsx +4 -5
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +192 -94
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
- package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +28 -24
- package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +5 -4
- package/src/ProfileView/components/Toolbars/index.tsx +3 -3
- package/src/ProfileView/components/ViewSelector/index.tsx +16 -9
- package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
- package/src/ProfileView/context/DashboardContext.tsx +6 -6
- package/src/ProfileView/hooks/useResetFlameGraphState.ts +4 -6
- package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +26 -24
- package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +8 -16
- package/src/ProfileView/hooks/useVisualizationState.ts +69 -61
- package/src/ProfileViewWithData.tsx +35 -29
- package/src/Sandwich/index.tsx +3 -4
- package/src/SourceView/index.tsx +2 -4
- package/src/SourceView/useSelectedLineRange.ts +19 -34
- package/src/Table/MoreDropdown.tsx +11 -9
- package/src/Table/TableContextMenu.tsx +13 -10
- package/src/Table/hooks/useTableConfiguration.tsx +11 -16
- package/src/Table/index.tsx +21 -12
- package/src/TopTable/index.tsx +4 -3
- package/src/hooks/useCompareModeMeta.ts +91 -61
- package/src/hooks/useQueryState.test.tsx +345 -275
- package/src/hooks/useQueryState.ts +118 -136
- package/src/index.tsx +15 -16
- package/src/useDelayedLoader.ts +10 -10
- package/src/useSumBy.ts +15 -21
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
- package/dist/hooks/urlParsers.d.ts +0 -18
- package/dist/hooks/urlParsers.d.ts.map +0 -1
- package/dist/hooks/urlParsers.js +0 -32
- package/dist/hooks/useColorBy.d.ts +0 -5
- package/dist/hooks/useColorBy.d.ts.map +0 -1
- package/dist/hooks/useColorBy.js +0 -26
- package/dist/hooks/useDashboardItems.d.ts +0 -5
- package/dist/hooks/useDashboardItems.d.ts.map +0 -1
- package/dist/hooks/useDashboardItems.js +0 -27
- package/dist/hooks/useQueryState.test.js +0 -868
- package/src/hooks/urlParsers.ts +0 -38
- package/src/hooks/useColorBy.ts +0 -42
- package/src/hooks/useDashboardItems.ts +0 -46
|
@@ -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
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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,
|
|
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
|
-
|
|
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,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
|
-
import {
|
|
16
|
-
import {
|
|
23
|
+
import { useURLState } from '@parca/components';
|
|
24
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
25
|
function calculateTruncatedText(text, textElement, maxWidth) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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;
|
|
44
54
|
}
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
}
|
|
56
|
+
(_textElement$parentEl3 = textElement.parentElement) === null || _textElement$parentEl3 === void 0 || _textElement$parentEl3.removeChild(tempElement);
|
|
57
|
+
return result;
|
|
47
58
|
}
|
|
48
|
-
function TextWithEllipsis(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
});
|
|
63
88
|
}
|
|
64
|
-
export default TextWithEllipsis;
|
|
89
|
+
export default TextWithEllipsis;
|