@parca/profile 0.16.183 → 0.16.185
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 +8 -0
- package/dist/Callgraph/constants.js +2 -2
- package/dist/Callgraph/index.js +35 -45
- package/dist/Callgraph/mockData/index.js +28 -11
- package/dist/Callgraph/utils.js +51 -58
- package/dist/GraphTooltip/ExpandOnHoverValue.js +2 -14
- package/dist/GraphTooltip/index.d.ts +5 -5
- package/dist/GraphTooltip/index.js +96 -122
- package/dist/MatchersInput/SuggestionItem.js +5 -17
- package/dist/MatchersInput/SuggestionsList.js +29 -53
- package/dist/MatchersInput/index.js +58 -74
- package/dist/MetricsCircle/index.js +2 -16
- package/dist/MetricsGraph/MetricsTooltip/index.js +27 -53
- package/dist/MetricsGraph/index.js +79 -98
- package/dist/MetricsSeries/index.js +4 -19
- package/dist/ProfileExplorer/ProfileExplorerCompare.js +4 -16
- package/dist/ProfileExplorer/ProfileExplorerSingle.js +2 -14
- package/dist/ProfileExplorer/index.js +129 -88
- package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.js +15 -31
- package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.d.ts +4 -4
- package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.js +38 -54
- package/dist/ProfileIcicleGraph/IcicleGraph/index.d.ts +2 -2
- package/dist/ProfileIcicleGraph/IcicleGraph/index.js +15 -31
- package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.js +22 -26
- package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.js +8 -9
- package/dist/ProfileIcicleGraph/IcicleGraph/utils.js +18 -20
- package/dist/ProfileIcicleGraph/index.d.ts +2 -2
- package/dist/ProfileIcicleGraph/index.js +18 -30
- package/dist/ProfileMetricsGraph/index.js +36 -88
- package/dist/ProfileSelector/CompareButton.js +8 -20
- package/dist/ProfileSelector/index.js +69 -69
- package/dist/ProfileSource.js +56 -65
- package/dist/ProfileTypeSelector/index.js +14 -28
- package/dist/ProfileView/FilterByFunctionButton.js +6 -7
- package/dist/ProfileView/ViewSelector.js +18 -31
- package/dist/ProfileView/VisualizationPanel.js +4 -16
- package/dist/ProfileView/index.d.ts +2 -1
- package/dist/ProfileView/index.js +73 -151
- package/dist/ProfileViewWithData.js +50 -97
- package/dist/TopTable/index.js +55 -63
- package/dist/components/DiffLegend.js +16 -28
- package/dist/components/ProfileShareButton/ResultBox.js +7 -21
- package/dist/components/ProfileShareButton/index.js +31 -90
- package/dist/useDelayedLoader.js +7 -8
- package/dist/useGrpcQuery/index.js +6 -48
- package/dist/useQuery.js +14 -58
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +16 -68
- package/package.json +6 -6
- package/src/Callgraph/index.tsx +3 -3
- package/src/Callgraph/utils.ts +1 -1
- package/src/GraphTooltip/index.tsx +17 -17
- package/src/MetricsGraph/index.tsx +3 -3
- package/src/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.tsx +9 -10
- package/src/ProfileIcicleGraph/IcicleGraph/index.tsx +4 -8
- package/src/ProfileIcicleGraph/IcicleGraph/useNodeColor.ts +2 -2
- package/src/ProfileIcicleGraph/index.tsx +8 -8
- package/src/ProfileView/index.tsx +8 -3
- package/src/ProfileViewWithData.tsx +5 -0
- package/src/TopTable/index.tsx +3 -3
- package/src/utils.ts +2 -2
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
2
|
// Copyright 2022 The Parca Authors
|
|
25
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -39,69 +17,63 @@ import { CopyToClipboard } from 'react-copy-to-clipboard';
|
|
|
39
17
|
import { usePopper } from 'react-popper';
|
|
40
18
|
import { useKeyDown } from '@parca/components';
|
|
41
19
|
import { selectHoveringNode, useAppSelector } from '@parca/store';
|
|
42
|
-
import { getLastItem, valueFormatter } from '@parca/utilities';
|
|
20
|
+
import { divide, getLastItem, valueFormatter } from '@parca/utilities';
|
|
43
21
|
import { hexifyAddress, truncateString, truncateStringReverse } from '../';
|
|
44
22
|
import { ExpandOnHover } from './ExpandOnHoverValue';
|
|
45
|
-
|
|
46
|
-
return _jsx("span",
|
|
23
|
+
const NoData = () => {
|
|
24
|
+
return _jsx("span", { className: "rounded bg-gray-200 px-2 dark:bg-gray-800", children: "Not available" });
|
|
47
25
|
};
|
|
48
|
-
|
|
49
|
-
getBoundingClientRect:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
26
|
+
const virtualElement = {
|
|
27
|
+
getBoundingClientRect: () =>
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
29
|
+
({
|
|
30
|
+
width: 0,
|
|
31
|
+
height: 0,
|
|
32
|
+
top: 0,
|
|
33
|
+
left: 0,
|
|
34
|
+
right: 0,
|
|
35
|
+
bottom: 0,
|
|
36
|
+
}),
|
|
60
37
|
};
|
|
61
|
-
function generateGetBoundingClientRect(contextElement, x, y) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
bottom: domRect.y + y,
|
|
74
|
-
});
|
|
75
|
-
};
|
|
38
|
+
function generateGetBoundingClientRect(contextElement, x = 0, y = 0) {
|
|
39
|
+
const domRect = contextElement.getBoundingClientRect();
|
|
40
|
+
return () =>
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
42
|
+
({
|
|
43
|
+
width: 0,
|
|
44
|
+
height: 0,
|
|
45
|
+
top: domRect.y + y,
|
|
46
|
+
left: domRect.x + x,
|
|
47
|
+
right: domRect.x + x,
|
|
48
|
+
bottom: domRect.y + y,
|
|
49
|
+
});
|
|
76
50
|
}
|
|
77
|
-
|
|
78
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
79
|
-
var hoveringNode = _a.hoveringNode, onCopy = _a.onCopy, strings = _a.strings, mappings = _a.mappings, locations = _a.locations, functions = _a.functions, _m = _a.type, type = _m === void 0 ? 'flamegraph' : _m;
|
|
51
|
+
const TooltipMetaInfo = ({ hoveringNode, onCopy, strings, mappings, locations, functions, type = 'flamegraph', }) => {
|
|
80
52
|
// populate meta from the flamegraph metadata tables
|
|
81
53
|
if (type === 'flamegraph' &&
|
|
82
54
|
locations !== undefined &&
|
|
83
|
-
|
|
55
|
+
hoveringNode.meta?.locationIndex !== undefined &&
|
|
84
56
|
hoveringNode.meta.locationIndex !== 0) {
|
|
85
|
-
|
|
86
|
-
hoveringNode.meta.location =
|
|
87
|
-
if (
|
|
57
|
+
const location = locations[hoveringNode.meta.locationIndex - 1];
|
|
58
|
+
hoveringNode.meta.location = location;
|
|
59
|
+
if (location !== undefined) {
|
|
88
60
|
if (mappings !== undefined &&
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
61
|
+
location.mappingIndex !== undefined &&
|
|
62
|
+
location.mappingIndex !== 0) {
|
|
63
|
+
const mapping = mappings[location.mappingIndex - 1];
|
|
92
64
|
if (strings !== undefined && mapping !== undefined) {
|
|
93
65
|
mapping.file =
|
|
94
|
-
|
|
66
|
+
mapping?.fileStringIndex !== undefined ? strings[mapping.fileStringIndex] : '';
|
|
95
67
|
mapping.buildId =
|
|
96
|
-
|
|
68
|
+
mapping?.buildIdStringIndex !== undefined ? strings[mapping.buildIdStringIndex] : '';
|
|
97
69
|
}
|
|
98
70
|
hoveringNode.meta.mapping = mapping;
|
|
99
71
|
}
|
|
100
72
|
if (functions !== undefined &&
|
|
101
|
-
|
|
73
|
+
location.lines !== undefined &&
|
|
102
74
|
hoveringNode.meta.lineIndex !== undefined &&
|
|
103
|
-
hoveringNode.meta.lineIndex <
|
|
104
|
-
|
|
75
|
+
hoveringNode.meta.lineIndex < location.lines.length) {
|
|
76
|
+
const func = functions[location.lines[hoveringNode.meta.lineIndex].functionIndex - 1];
|
|
105
77
|
if (strings !== undefined) {
|
|
106
78
|
func.name = strings[func.nameStringIndex];
|
|
107
79
|
func.systemName = strings[func.systemNameStringIndex];
|
|
@@ -111,65 +83,68 @@ var TooltipMetaInfo = function (_a) {
|
|
|
111
83
|
}
|
|
112
84
|
}
|
|
113
85
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (((_a = hoveringNode.meta) === null || _a === void 0 ? void 0 : _a.function) == null)
|
|
86
|
+
const getTextForFile = (hoveringNode) => {
|
|
87
|
+
if (hoveringNode.meta?.function == null)
|
|
117
88
|
return '<unknown>';
|
|
118
|
-
return
|
|
119
|
-
?
|
|
120
|
-
:
|
|
121
|
-
|
|
122
|
-
?
|
|
123
|
-
: ''
|
|
89
|
+
return `${hoveringNode.meta.function.filename} ${hoveringNode.meta.line?.line !== undefined && hoveringNode.meta.line?.line !== 0n
|
|
90
|
+
? ` +${hoveringNode.meta.line.line.toString()}`
|
|
91
|
+
: `${hoveringNode.meta.function?.startLine !== undefined &&
|
|
92
|
+
hoveringNode.meta.function?.startLine !== 0n
|
|
93
|
+
? ` +${hoveringNode.meta.function.startLine}`
|
|
94
|
+
: ''}`}`;
|
|
124
95
|
};
|
|
125
|
-
|
|
126
|
-
return (_jsxs(_Fragment, { children: [_jsxs("tr", { children: [_jsx("td",
|
|
127
|
-
|
|
128
|
-
|
|
96
|
+
const file = getTextForFile(hoveringNode);
|
|
97
|
+
return (_jsxs(_Fragment, { children: [_jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "File" }), _jsx("td", { className: "w-3/4 break-all", children: hoveringNode.meta?.function?.filename == null ||
|
|
98
|
+
hoveringNode.meta?.function.filename === '' ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, { onCopy: onCopy, text: file, children: _jsx("button", { className: "cursor-pointer whitespace-nowrap text-left", children: _jsx(ExpandOnHover, { value: file, displayValue: truncateStringReverse(file, 40) }) }) })) })] }), _jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Address" }), _jsx("td", { className: "w-3/4 break-all", children: hoveringNode.meta?.location?.address == null ||
|
|
99
|
+
hoveringNode.meta?.location.address === 0n ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, { onCopy: onCopy, text: hexifyAddress(hoveringNode.meta.location.address), children: _jsx("button", { className: "cursor-pointer", children: hexifyAddress(hoveringNode.meta.location.address) }) })) })] }), _jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Binary" }), _jsx("td", { className: "w-3/4 break-all", children: hoveringNode.meta?.mapping == null || hoveringNode.meta.mapping.file === '' ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, { onCopy: onCopy, text: hoveringNode.meta.mapping.file, children: _jsx("button", { className: "cursor-pointer", children: getLastItem(hoveringNode.meta.mapping.file) }) })) })] }), _jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Build Id" }), _jsx("td", { className: "w-3/4 break-all", children: hoveringNode.meta?.mapping == null || hoveringNode.meta?.mapping.buildId === '' ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, { onCopy: onCopy, text: hoveringNode.meta.mapping.buildId, children: _jsx("button", { className: "cursor-pointer", children: truncateString(getLastItem(hoveringNode.meta.mapping.buildId), 28) }) })) })] })] }));
|
|
129
100
|
};
|
|
130
|
-
|
|
131
|
-
export
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
var onCopy = function () {
|
|
101
|
+
let timeoutHandle = null;
|
|
102
|
+
export const GraphTooltipContent = ({ hoveringNode, unit, total, totalUnfiltered, isFixed, strings, mappings, locations, functions, type = 'flamegraph', }) => {
|
|
103
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
104
|
+
const onCopy = () => {
|
|
135
105
|
setIsCopied(true);
|
|
136
106
|
if (timeoutHandle !== null) {
|
|
137
107
|
clearTimeout(timeoutHandle);
|
|
138
108
|
}
|
|
139
|
-
timeoutHandle = setTimeout(
|
|
109
|
+
timeoutHandle = setTimeout(() => setIsCopied(false), 3000);
|
|
140
110
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
?
|
|
111
|
+
const hoveringNodeCumulative = hoveringNode.cumulative;
|
|
112
|
+
const diff = hoveringNode.diff;
|
|
113
|
+
const prevValue = hoveringNodeCumulative - diff;
|
|
114
|
+
const diffRatio = diff !== 0n ? divide(diff, prevValue) : 0;
|
|
115
|
+
const diffSign = diff > 0 ? '+' : '';
|
|
116
|
+
const diffValueText = diffSign + valueFormatter(diff, unit, 1);
|
|
117
|
+
const diffPercentageText = diffSign + (diffRatio * 100).toFixed(2) + '%';
|
|
118
|
+
const diffText = `${diffValueText} (${diffPercentageText})`;
|
|
119
|
+
const getTextForCumulative = (hoveringNodeCumulative) => {
|
|
120
|
+
const filtered = totalUnfiltered > total
|
|
121
|
+
? ` / ${divide(hoveringNodeCumulative * 100n, total).toFixed(2)}% of filtered`
|
|
152
122
|
: '';
|
|
153
|
-
return
|
|
123
|
+
return `${valueFormatter(hoveringNodeCumulative, unit, 2)}
|
|
124
|
+
(${divide(hoveringNodeCumulative * 100n, totalUnfiltered).toFixed(2)}%${filtered})`;
|
|
154
125
|
};
|
|
155
|
-
return (_jsx("div",
|
|
156
|
-
hoveringNode.meta.function.name !== '' ? (_jsx(CopyToClipboard,
|
|
157
|
-
|
|
126
|
+
return (_jsx("div", { className: `flex text-sm ${isFixed ? 'w-full' : ''}`, children: _jsx("div", { className: `m-auto w-full ${isFixed ? 'w-full' : ''}`, children: _jsxs("div", { className: "min-h-52 flex w-[500px] flex-col justify-between rounded-lg border border-gray-300 bg-gray-50 p-3 shadow-lg dark:border-gray-500 dark:bg-gray-900", children: [_jsx("div", { className: "flex flex-row", children: _jsxs("div", { className: "mx-2", children: [_jsx("div", { className: "flex h-10 items-center break-all font-semibold", children: hoveringNode.meta === undefined ? (_jsx("p", { children: "root" })) : (_jsx(_Fragment, { children: hoveringNode.meta.function !== undefined &&
|
|
127
|
+
hoveringNode.meta.function.name !== '' ? (_jsx(CopyToClipboard, { onCopy: onCopy, text: hoveringNode.meta.function.name, children: _jsx("button", { className: "cursor-pointer text-left", children: hoveringNode.meta.function.name }) })) : (_jsx(_Fragment, { children: hoveringNode.meta.location !== undefined &&
|
|
128
|
+
hoveringNode.meta.location.address !== 0n ? (_jsx(CopyToClipboard, { onCopy: onCopy, text: hexifyAddress(hoveringNode.meta.location.address), children: _jsx("button", { className: "cursor-pointer text-left", children: hexifyAddress(hoveringNode.meta.location.address) }) })) : (_jsx("p", { children: "unknown" })) })) })) }), _jsx("table", { className: "my-2 w-full table-fixed pr-0 text-gray-700 dark:text-gray-300", children: _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Cumulative" }), _jsx("td", { className: "w-3/4", children: _jsx(CopyToClipboard, { onCopy: onCopy, text: getTextForCumulative(hoveringNodeCumulative), children: _jsx("button", { className: "cursor-pointer", children: getTextForCumulative(hoveringNodeCumulative) }) }) })] }), hoveringNode.diff !== undefined && diff !== 0n && (_jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Diff" }), _jsx("td", { className: "w-3/4", children: _jsx(CopyToClipboard, { onCopy: onCopy, text: diffText, children: _jsx("button", { className: "cursor-pointer", children: diffText }) }) })] })), _jsx(TooltipMetaInfo, { onCopy: onCopy, hoveringNode: hoveringNode, strings: strings, mappings: mappings, locations: locations, functions: functions, type: type })] }) })] }) }), _jsx("span", { className: "mx-2 block text-xs text-gray-500", children: isCopied ? 'Copied!' : 'Hold shift and click on a value to copy.' })] }) }) }));
|
|
158
129
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
var hoveringNodeState = useAppSelector(selectHoveringNode);
|
|
130
|
+
const GraphTooltip = ({ x, y, unit, total, totalUnfiltered, hoveringNode: hoveringNodeProp, contextElement, isFixed = false, virtualContextElement = true, strings, mappings, locations, functions, type = 'flamegraph', }) => {
|
|
131
|
+
const hoveringNodeState = useAppSelector(selectHoveringNode);
|
|
162
132
|
// @ts-expect-error
|
|
163
|
-
|
|
164
|
-
|
|
133
|
+
const hoveringNode = useMemo(() => {
|
|
134
|
+
const h = hoveringNodeProp ?? hoveringNodeState;
|
|
165
135
|
if (h == null) {
|
|
166
136
|
return h;
|
|
167
137
|
}
|
|
168
138
|
// Cloning the object to avoid the mutating error as this is Redux store object and we are modifying the meta object in GraphTooltipContent component.
|
|
169
|
-
return
|
|
139
|
+
return {
|
|
140
|
+
...h,
|
|
141
|
+
meta: {
|
|
142
|
+
...h.meta,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
170
145
|
}, [hoveringNodeProp, hoveringNodeState]);
|
|
171
|
-
|
|
172
|
-
|
|
146
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
147
|
+
const { styles, attributes, ...popperProps } = usePopper(virtualContextElement ? virtualElement : contextElement, popperElement, {
|
|
173
148
|
placement: 'bottom-start',
|
|
174
149
|
strategy: 'absolute',
|
|
175
150
|
modifiers: [
|
|
@@ -178,7 +153,7 @@ var GraphTooltip = function (_a) {
|
|
|
178
153
|
options: {
|
|
179
154
|
tether: false,
|
|
180
155
|
altAxis: true,
|
|
181
|
-
boundary: contextElement
|
|
156
|
+
boundary: contextElement ?? undefined,
|
|
182
157
|
},
|
|
183
158
|
},
|
|
184
159
|
{
|
|
@@ -190,37 +165,36 @@ var GraphTooltip = function (_a) {
|
|
|
190
165
|
{
|
|
191
166
|
name: 'flip',
|
|
192
167
|
options: {
|
|
193
|
-
boundary: contextElement
|
|
168
|
+
boundary: contextElement ?? undefined,
|
|
194
169
|
},
|
|
195
170
|
},
|
|
196
171
|
],
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
useEffect(
|
|
172
|
+
});
|
|
173
|
+
const { isShiftDown } = useKeyDown();
|
|
174
|
+
useEffect(() => {
|
|
200
175
|
if (contextElement === null)
|
|
201
176
|
return;
|
|
202
|
-
|
|
203
|
-
var _a;
|
|
177
|
+
const onMouseMove = (e) => {
|
|
204
178
|
if (isShiftDown) {
|
|
205
179
|
return;
|
|
206
180
|
}
|
|
207
|
-
|
|
208
|
-
|
|
181
|
+
let tooltipX = x;
|
|
182
|
+
let tooltipY = y;
|
|
209
183
|
if (tooltipX == null || tooltipY == null) {
|
|
210
|
-
|
|
184
|
+
const rel = pointer(e);
|
|
211
185
|
tooltipX = rel[0];
|
|
212
186
|
tooltipY = rel[1];
|
|
213
187
|
}
|
|
214
188
|
virtualElement.getBoundingClientRect = generateGetBoundingClientRect(contextElement, tooltipX, tooltipY);
|
|
215
|
-
void
|
|
189
|
+
void popperProps.update?.();
|
|
216
190
|
};
|
|
217
191
|
contextElement.addEventListener('mousemove', onMouseMove);
|
|
218
|
-
return
|
|
192
|
+
return () => {
|
|
219
193
|
contextElement.removeEventListener('mousemove', onMouseMove);
|
|
220
194
|
};
|
|
221
195
|
}, [contextElement, popperProps, isShiftDown, x, y]);
|
|
222
196
|
if (hoveringNode === undefined || hoveringNode == null)
|
|
223
197
|
return _jsx(_Fragment, {});
|
|
224
|
-
return isFixed ? (_jsx(GraphTooltipContent, { hoveringNode: hoveringNode, unit: unit, total: total, totalUnfiltered: totalUnfiltered, isFixed: isFixed, type: type })) : (_jsx("div",
|
|
198
|
+
return isFixed ? (_jsx(GraphTooltipContent, { hoveringNode: hoveringNode, unit: unit, total: total, totalUnfiltered: totalUnfiltered, isFixed: isFixed, type: type })) : (_jsx("div", { ref: setPopperElement, style: styles.popper, ...attributes.popper, children: _jsx(GraphTooltipContent, { hoveringNode: hoveringNode, unit: unit, total: total, totalUnfiltered: totalUnfiltered, isFixed: isFixed, strings: strings, mappings: mappings, locations: locations, functions: functions, type: type }) }));
|
|
225
199
|
};
|
|
226
200
|
export default GraphTooltip;
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
// Copyright 2022 The Parca Authors
|
|
14
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -24,16 +13,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
13
|
// limitations under the License.
|
|
25
14
|
import { useEffect, useRef } from 'react';
|
|
26
15
|
import cx from 'classnames';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
useEffect(function () {
|
|
16
|
+
const SuggestionItem = ({ isHighlighted, onHighlight, onApplySuggestion, onResetHighlight, value, }) => {
|
|
17
|
+
const ref = useRef(null);
|
|
18
|
+
useEffect(() => {
|
|
31
19
|
if (isHighlighted && ref.current != null) {
|
|
32
20
|
ref.current.scrollIntoView({ block: 'nearest' });
|
|
33
21
|
}
|
|
34
22
|
}, [isHighlighted]);
|
|
35
|
-
return (_jsx("div",
|
|
23
|
+
return (_jsx("div", { className: cx('relative cursor-default select-none py-2 pl-3 pr-9', {
|
|
36
24
|
'bg-indigo-600 text-white': isHighlighted,
|
|
37
|
-
}), onMouseOver:
|
|
25
|
+
}), onMouseOver: () => onHighlight(), onClick: () => onApplySuggestion(), onMouseOut: () => onResetHighlight(), ref: ref, children: value }));
|
|
38
26
|
};
|
|
39
27
|
export default SuggestionItem;
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
2
|
// Copyright 2022 The Parca Authors
|
|
14
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -27,38 +16,33 @@ import { Transition } from '@headlessui/react';
|
|
|
27
16
|
import { usePopper } from 'react-popper';
|
|
28
17
|
import { useParcaContext } from '@parca/components';
|
|
29
18
|
import SuggestionItem from './SuggestionItem';
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
export class Suggestion {
|
|
20
|
+
constructor(type, typeahead, value) {
|
|
32
21
|
this.type = type;
|
|
33
22
|
this.typeahead = typeahead;
|
|
34
23
|
this.value = value;
|
|
35
24
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var Suggestions = /** @class */ (function () {
|
|
40
|
-
function Suggestions() {
|
|
25
|
+
}
|
|
26
|
+
export class Suggestions {
|
|
27
|
+
constructor() {
|
|
41
28
|
this.literals = [];
|
|
42
29
|
this.labelNames = [];
|
|
43
30
|
this.labelValues = [];
|
|
44
31
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var Spinner = useParcaContext().loader;
|
|
50
|
-
return _jsx("div", __assign({ className: "pt-2 pb-4" }, { children: Spinner }));
|
|
32
|
+
}
|
|
33
|
+
const LoadingSpinner = () => {
|
|
34
|
+
const { loader: Spinner } = useParcaContext();
|
|
35
|
+
return _jsx("div", { className: "pt-2 pb-4", children: Spinner });
|
|
51
36
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var _c = usePopper(inputRef, popperElement, {
|
|
37
|
+
const SuggestionsList = ({ suggestions, applySuggestion, inputRef, runQuery, focusedInput, isLabelNamesLoading, isLabelValuesLoading, }) => {
|
|
38
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
39
|
+
const { styles, attributes } = usePopper(inputRef, popperElement, {
|
|
56
40
|
placement: 'bottom-start',
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
41
|
+
});
|
|
42
|
+
const [highlightedSuggestionIndex, setHighlightedSuggestionIndex] = useState(-1);
|
|
43
|
+
const [showSuggest, setShowSuggest] = useState(true);
|
|
44
|
+
const suggestionsLength = suggestions.literals.length + suggestions.labelNames.length + suggestions.labelValues.length;
|
|
45
|
+
const getSuggestion = useCallback((index) => {
|
|
62
46
|
if (index < suggestions.labelNames.length) {
|
|
63
47
|
return suggestions.labelNames[index];
|
|
64
48
|
}
|
|
@@ -67,24 +51,24 @@ var SuggestionsList = function (_a) {
|
|
|
67
51
|
}
|
|
68
52
|
return suggestions.labelValues[index - suggestions.labelNames.length - suggestions.literals.length];
|
|
69
53
|
}, [suggestions]);
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
const resetHighlight = useCallback(() => setHighlightedSuggestionIndex(-1), [setHighlightedSuggestionIndex]);
|
|
55
|
+
const applyHighlightedSuggestion = useCallback(() => {
|
|
72
56
|
applySuggestion(getSuggestion(highlightedSuggestionIndex));
|
|
73
57
|
resetHighlight();
|
|
74
58
|
}, [resetHighlight, applySuggestion, highlightedSuggestionIndex, getSuggestion]);
|
|
75
|
-
|
|
59
|
+
const applySuggestionWithIndex = useCallback((index) => {
|
|
76
60
|
applySuggestion(getSuggestion(index));
|
|
77
61
|
resetHighlight();
|
|
78
62
|
}, [resetHighlight, applySuggestion, getSuggestion]);
|
|
79
|
-
|
|
80
|
-
|
|
63
|
+
const highlightNext = useCallback(() => {
|
|
64
|
+
const nextIndex = highlightedSuggestionIndex + 1;
|
|
81
65
|
if (nextIndex === suggestionsLength) {
|
|
82
66
|
resetHighlight();
|
|
83
67
|
return;
|
|
84
68
|
}
|
|
85
69
|
setHighlightedSuggestionIndex(nextIndex);
|
|
86
70
|
}, [highlightedSuggestionIndex, suggestionsLength, resetHighlight]);
|
|
87
|
-
|
|
71
|
+
const highlightPrevious = useCallback(() => {
|
|
88
72
|
if (highlightedSuggestionIndex === -1) {
|
|
89
73
|
// Didn't select anything, so starting at the bottom.
|
|
90
74
|
setHighlightedSuggestionIndex(suggestionsLength - 1);
|
|
@@ -92,7 +76,7 @@ var SuggestionsList = function (_a) {
|
|
|
92
76
|
}
|
|
93
77
|
setHighlightedSuggestionIndex(highlightedSuggestionIndex - 1);
|
|
94
78
|
}, [highlightedSuggestionIndex, suggestionsLength]);
|
|
95
|
-
|
|
79
|
+
const handleKeyPress = useCallback((event) => {
|
|
96
80
|
if (event.key === 'Enter') {
|
|
97
81
|
// Disable new line in the text area
|
|
98
82
|
event.preventDefault();
|
|
@@ -111,7 +95,7 @@ var SuggestionsList = function (_a) {
|
|
|
111
95
|
}
|
|
112
96
|
setShowSuggest(true);
|
|
113
97
|
}, [highlightedSuggestionIndex, applyHighlightedSuggestion, runQuery]);
|
|
114
|
-
|
|
98
|
+
const handleKeyDown = useCallback((event) => {
|
|
115
99
|
// Don't need to handle any key interactions if no suggestions there.
|
|
116
100
|
if (suggestionsLength === 0 || !['Tab', 'ArrowUp', 'ArrowDown'].includes(event.key)) {
|
|
117
101
|
return;
|
|
@@ -137,26 +121,18 @@ var SuggestionsList = function (_a) {
|
|
|
137
121
|
highlightNext();
|
|
138
122
|
}
|
|
139
123
|
}, [suggestionsLength, highlightNext, highlightPrevious]);
|
|
140
|
-
useEffect(
|
|
124
|
+
useEffect(() => {
|
|
141
125
|
if (inputRef == null) {
|
|
142
126
|
return;
|
|
143
127
|
}
|
|
144
128
|
inputRef.addEventListener('keydown', handleKeyDown);
|
|
145
129
|
inputRef.addEventListener('keypress', handleKeyPress);
|
|
146
|
-
return
|
|
130
|
+
return () => {
|
|
147
131
|
inputRef.removeEventListener('keydown', handleKeyDown);
|
|
148
132
|
inputRef.removeEventListener('keypress', handleKeyPress);
|
|
149
133
|
};
|
|
150
134
|
}, [inputRef, highlightedSuggestionIndex, suggestions, handleKeyPress, handleKeyDown]);
|
|
151
|
-
return (_jsx(_Fragment, { children: suggestionsLength > 0 && (_jsx("div",
|
|
152
|
-
|
|
153
|
-
}, onApplySuggestion: function () {
|
|
154
|
-
return applySuggestionWithIndex(i + suggestions.labelNames.length);
|
|
155
|
-
}, onResetHighlight: function () { return resetHighlight(); }, value: l.value }, l.value)); }), isLabelValuesLoading ? (_jsx(LoadingSpinner, {})) : (_jsx(_Fragment, { children: suggestions.labelValues.map(function (l, i) { return (_jsx(SuggestionItem, { isHighlighted: highlightedSuggestionIndex ===
|
|
156
|
-
i + suggestions.labelNames.length + suggestions.literals.length, onHighlight: function () {
|
|
157
|
-
return setHighlightedSuggestionIndex(i + suggestions.labelNames.length + suggestions.literals.length);
|
|
158
|
-
}, onApplySuggestion: function () {
|
|
159
|
-
return applySuggestionWithIndex(i + suggestions.labelNames.length + suggestions.literals.length);
|
|
160
|
-
}, onResetHighlight: function () { return resetHighlight(); }, value: l.value }, l.value)); }) }))] })) })) }))) }));
|
|
135
|
+
return (_jsx(_Fragment, { children: suggestionsLength > 0 && (_jsx("div", { ref: setPopperElement, style: { ...styles.popper, marginLeft: 0 }, ...attributes.popper, className: "z-50", children: _jsx(Transition, { show: focusedInput && showSuggest, as: Fragment, leave: "transition ease-in duration-100", leaveFrom: "opacity-100", leaveTo: "opacity-0", children: _jsxs("div", { style: { width: inputRef?.offsetWidth }, className: "absolute z-10 mt-1 max-h-[400px] overflow-auto rounded-md bg-gray-50 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:bg-gray-900 sm:text-sm", children: [isLabelNamesLoading ? (_jsx(LoadingSpinner, {})) : (_jsx(_Fragment, { children: suggestions.labelNames.map((l, i) => (_jsx(SuggestionItem, { isHighlighted: highlightedSuggestionIndex === i, onHighlight: () => setHighlightedSuggestionIndex(i), onApplySuggestion: () => applySuggestionWithIndex(i), onResetHighlight: () => resetHighlight(), value: l.value }, l.value))) })), suggestions.literals.map((l, i) => (_jsx(SuggestionItem, { isHighlighted: highlightedSuggestionIndex === i + suggestions.labelNames.length, onHighlight: () => setHighlightedSuggestionIndex(i + suggestions.labelNames.length), onApplySuggestion: () => applySuggestionWithIndex(i + suggestions.labelNames.length), onResetHighlight: () => resetHighlight(), value: l.value }, l.value))), isLabelValuesLoading ? (_jsx(LoadingSpinner, {})) : (_jsx(_Fragment, { children: suggestions.labelValues.map((l, i) => (_jsx(SuggestionItem, { isHighlighted: highlightedSuggestionIndex ===
|
|
136
|
+
i + suggestions.labelNames.length + suggestions.literals.length, onHighlight: () => setHighlightedSuggestionIndex(i + suggestions.labelNames.length + suggestions.literals.length), onApplySuggestion: () => applySuggestionWithIndex(i + suggestions.labelNames.length + suggestions.literals.length), onResetHighlight: () => resetHighlight(), value: l.value }, l.value))) }))] }) }) })) }));
|
|
161
137
|
};
|
|
162
138
|
export default SuggestionsList;
|