@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.
Files changed (61) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/Callgraph/constants.js +2 -2
  3. package/dist/Callgraph/index.js +35 -45
  4. package/dist/Callgraph/mockData/index.js +28 -11
  5. package/dist/Callgraph/utils.js +51 -58
  6. package/dist/GraphTooltip/ExpandOnHoverValue.js +2 -14
  7. package/dist/GraphTooltip/index.d.ts +5 -5
  8. package/dist/GraphTooltip/index.js +96 -122
  9. package/dist/MatchersInput/SuggestionItem.js +5 -17
  10. package/dist/MatchersInput/SuggestionsList.js +29 -53
  11. package/dist/MatchersInput/index.js +58 -74
  12. package/dist/MetricsCircle/index.js +2 -16
  13. package/dist/MetricsGraph/MetricsTooltip/index.js +27 -53
  14. package/dist/MetricsGraph/index.js +79 -98
  15. package/dist/MetricsSeries/index.js +4 -19
  16. package/dist/ProfileExplorer/ProfileExplorerCompare.js +4 -16
  17. package/dist/ProfileExplorer/ProfileExplorerSingle.js +2 -14
  18. package/dist/ProfileExplorer/index.js +129 -88
  19. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.js +15 -31
  20. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.d.ts +4 -4
  21. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.js +38 -54
  22. package/dist/ProfileIcicleGraph/IcicleGraph/index.d.ts +2 -2
  23. package/dist/ProfileIcicleGraph/IcicleGraph/index.js +15 -31
  24. package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.js +22 -26
  25. package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.js +8 -9
  26. package/dist/ProfileIcicleGraph/IcicleGraph/utils.js +18 -20
  27. package/dist/ProfileIcicleGraph/index.d.ts +2 -2
  28. package/dist/ProfileIcicleGraph/index.js +18 -30
  29. package/dist/ProfileMetricsGraph/index.js +36 -88
  30. package/dist/ProfileSelector/CompareButton.js +8 -20
  31. package/dist/ProfileSelector/index.js +69 -69
  32. package/dist/ProfileSource.js +56 -65
  33. package/dist/ProfileTypeSelector/index.js +14 -28
  34. package/dist/ProfileView/FilterByFunctionButton.js +6 -7
  35. package/dist/ProfileView/ViewSelector.js +18 -31
  36. package/dist/ProfileView/VisualizationPanel.js +4 -16
  37. package/dist/ProfileView/index.d.ts +2 -1
  38. package/dist/ProfileView/index.js +73 -151
  39. package/dist/ProfileViewWithData.js +50 -97
  40. package/dist/TopTable/index.js +55 -63
  41. package/dist/components/DiffLegend.js +16 -28
  42. package/dist/components/ProfileShareButton/ResultBox.js +7 -21
  43. package/dist/components/ProfileShareButton/index.js +31 -90
  44. package/dist/useDelayedLoader.js +7 -8
  45. package/dist/useGrpcQuery/index.js +6 -48
  46. package/dist/useQuery.js +14 -58
  47. package/dist/utils.d.ts +1 -1
  48. package/dist/utils.js +16 -68
  49. package/package.json +6 -6
  50. package/src/Callgraph/index.tsx +3 -3
  51. package/src/Callgraph/utils.ts +1 -1
  52. package/src/GraphTooltip/index.tsx +17 -17
  53. package/src/MetricsGraph/index.tsx +3 -3
  54. package/src/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.tsx +9 -10
  55. package/src/ProfileIcicleGraph/IcicleGraph/index.tsx +4 -8
  56. package/src/ProfileIcicleGraph/IcicleGraph/useNodeColor.ts +2 -2
  57. package/src/ProfileIcicleGraph/index.tsx +8 -8
  58. package/src/ProfileView/index.tsx +8 -3
  59. package/src/ProfileViewWithData.tsx +5 -0
  60. package/src/TopTable/index.tsx +3 -3
  61. 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
- var NoData = function () {
46
- return _jsx("span", __assign({ className: "rounded bg-gray-200 px-2 dark:bg-gray-800" }, { children: "Not available" }));
23
+ const NoData = () => {
24
+ return _jsx("span", { className: "rounded bg-gray-200 px-2 dark:bg-gray-800", children: "Not available" });
47
25
  };
48
- var virtualElement = {
49
- getBoundingClientRect: function () {
50
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
51
- return ({
52
- width: 0,
53
- height: 0,
54
- top: 0,
55
- left: 0,
56
- right: 0,
57
- bottom: 0,
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
- if (x === void 0) { x = 0; }
63
- if (y === void 0) { y = 0; }
64
- var domRect = contextElement.getBoundingClientRect();
65
- return function () {
66
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
67
- return ({
68
- width: 0,
69
- height: 0,
70
- top: domRect.y + y,
71
- left: domRect.x + x,
72
- right: domRect.x + x,
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
- var TooltipMetaInfo = function (_a) {
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
- ((_b = hoveringNode.meta) === null || _b === void 0 ? void 0 : _b.locationIndex) !== undefined &&
55
+ hoveringNode.meta?.locationIndex !== undefined &&
84
56
  hoveringNode.meta.locationIndex !== 0) {
85
- var location_1 = locations[hoveringNode.meta.locationIndex - 1];
86
- hoveringNode.meta.location = location_1;
87
- if (location_1 !== undefined) {
57
+ const location = locations[hoveringNode.meta.locationIndex - 1];
58
+ hoveringNode.meta.location = location;
59
+ if (location !== undefined) {
88
60
  if (mappings !== undefined &&
89
- location_1.mappingIndex !== undefined &&
90
- location_1.mappingIndex !== 0) {
91
- var mapping = mappings[location_1.mappingIndex - 1];
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
- (mapping === null || mapping === void 0 ? void 0 : mapping.fileStringIndex) !== undefined ? strings[mapping.fileStringIndex] : '';
66
+ mapping?.fileStringIndex !== undefined ? strings[mapping.fileStringIndex] : '';
95
67
  mapping.buildId =
96
- (mapping === null || mapping === void 0 ? void 0 : mapping.buildIdStringIndex) !== undefined ? strings[mapping.buildIdStringIndex] : '';
68
+ mapping?.buildIdStringIndex !== undefined ? strings[mapping.buildIdStringIndex] : '';
97
69
  }
98
70
  hoveringNode.meta.mapping = mapping;
99
71
  }
100
72
  if (functions !== undefined &&
101
- location_1.lines !== undefined &&
73
+ location.lines !== undefined &&
102
74
  hoveringNode.meta.lineIndex !== undefined &&
103
- hoveringNode.meta.lineIndex < location_1.lines.length) {
104
- var func = functions[location_1.lines[hoveringNode.meta.lineIndex].functionIndex - 1];
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
- var getTextForFile = function (hoveringNode) {
115
- var _a, _b, _c, _d, _e;
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 "".concat(hoveringNode.meta.function.filename, " ").concat(((_b = hoveringNode.meta.line) === null || _b === void 0 ? void 0 : _b.line) !== undefined && ((_c = hoveringNode.meta.line) === null || _c === void 0 ? void 0 : _c.line) !== '0'
119
- ? " +".concat(hoveringNode.meta.line.line.toString())
120
- : "".concat(((_d = hoveringNode.meta.function) === null || _d === void 0 ? void 0 : _d.startLine) !== undefined &&
121
- ((_e = hoveringNode.meta.function) === null || _e === void 0 ? void 0 : _e.startLine) !== '0'
122
- ? " +".concat(hoveringNode.meta.function.startLine)
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
- var file = getTextForFile(hoveringNode);
126
- return (_jsxs(_Fragment, { children: [_jsxs("tr", { children: [_jsx("td", __assign({ className: "w-1/4" }, { children: "File" })), _jsx("td", __assign({ className: "w-3/4 break-all" }, { children: ((_d = (_c = hoveringNode.meta) === null || _c === void 0 ? void 0 : _c.function) === null || _d === void 0 ? void 0 : _d.filename) == null ||
127
- ((_e = hoveringNode.meta) === null || _e === void 0 ? void 0 : _e.function.filename) === '' ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, __assign({ onCopy: onCopy, text: file }, { children: _jsx("button", __assign({ className: "cursor-pointer whitespace-nowrap text-left" }, { children: _jsx(ExpandOnHover, { value: file, displayValue: truncateStringReverse(file, 40) }) })) }))) }))] }), _jsxs("tr", { children: [_jsx("td", __assign({ className: "w-1/4" }, { children: "Address" })), _jsx("td", __assign({ className: "w-3/4 break-all" }, { children: ((_g = (_f = hoveringNode.meta) === null || _f === void 0 ? void 0 : _f.location) === null || _g === void 0 ? void 0 : _g.address) == null ||
128
- ((_h = hoveringNode.meta) === null || _h === void 0 ? void 0 : _h.location.address) === '0' ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, __assign({ onCopy: onCopy, text: hexifyAddress(hoveringNode.meta.location.address) }, { children: _jsx("button", __assign({ className: "cursor-pointer" }, { children: hexifyAddress(hoveringNode.meta.location.address) })) }))) }))] }), _jsxs("tr", { children: [_jsx("td", __assign({ className: "w-1/4" }, { children: "Binary" })), _jsx("td", __assign({ className: "w-3/4 break-all" }, { children: ((_j = hoveringNode.meta) === null || _j === void 0 ? void 0 : _j.mapping) == null || hoveringNode.meta.mapping.file === '' ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, __assign({ onCopy: onCopy, text: hoveringNode.meta.mapping.file }, { children: _jsx("button", __assign({ className: "cursor-pointer" }, { children: getLastItem(hoveringNode.meta.mapping.file) })) }))) }))] }), _jsxs("tr", { children: [_jsx("td", __assign({ className: "w-1/4" }, { children: "Build Id" })), _jsx("td", __assign({ className: "w-3/4 break-all" }, { children: ((_k = hoveringNode.meta) === null || _k === void 0 ? void 0 : _k.mapping) == null || ((_l = hoveringNode.meta) === null || _l === void 0 ? void 0 : _l.mapping.buildId) === '' ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, __assign({ onCopy: onCopy, text: hoveringNode.meta.mapping.buildId }, { children: _jsx("button", __assign({ className: "cursor-pointer" }, { children: truncateString(getLastItem(hoveringNode.meta.mapping.buildId), 28) })) }))) }))] })] }));
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
- var timeoutHandle = null;
131
- export var GraphTooltipContent = function (_a) {
132
- var hoveringNode = _a.hoveringNode, unit = _a.unit, total = _a.total, totalUnfiltered = _a.totalUnfiltered, isFixed = _a.isFixed, strings = _a.strings, mappings = _a.mappings, locations = _a.locations, functions = _a.functions, _b = _a.type, type = _b === void 0 ? 'flamegraph' : _b;
133
- var _c = useState(false), isCopied = _c[0], setIsCopied = _c[1];
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(function () { return setIsCopied(false); }, 3000);
109
+ timeoutHandle = setTimeout(() => setIsCopied(false), 3000);
140
110
  };
141
- var hoveringNodeCumulative = parseFloat(hoveringNode.cumulative);
142
- var diff = hoveringNode.diff === undefined ? 0 : parseFloat(hoveringNode.diff);
143
- var prevValue = hoveringNodeCumulative - diff;
144
- var diffRatio = Math.abs(diff) > 0 ? diff / prevValue : 0;
145
- var diffSign = diff > 0 ? '+' : '';
146
- var diffValueText = diffSign + valueFormatter(diff, unit, 1);
147
- var diffPercentageText = diffSign + (diffRatio * 100).toFixed(2) + '%';
148
- var diffText = "".concat(diffValueText, " (").concat(diffPercentageText, ")");
149
- var getTextForCumulative = function (hoveringNodeCumulative) {
150
- var filtered = totalUnfiltered > total
151
- ? " / ".concat(((hoveringNodeCumulative * 100) / total).toFixed(2), "% of filtered")
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 "".concat(valueFormatter(hoveringNodeCumulative, unit, 2), "\n (").concat(((hoveringNodeCumulative * 100) / totalUnfiltered).toFixed(2), "%").concat(filtered, ")");
123
+ return `${valueFormatter(hoveringNodeCumulative, unit, 2)}
124
+ (${divide(hoveringNodeCumulative * 100n, totalUnfiltered).toFixed(2)}%${filtered})`;
154
125
  };
155
- return (_jsx("div", __assign({ className: "flex text-sm ".concat(isFixed ? 'w-full' : '') }, { children: _jsx("div", __assign({ className: "m-auto w-full ".concat(isFixed ? 'w-full' : '') }, { children: _jsxs("div", __assign({ 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", __assign({ className: "flex flex-row" }, { children: _jsxs("div", __assign({ className: "mx-2" }, { children: [_jsx("div", __assign({ 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 &&
156
- hoveringNode.meta.function.name !== '' ? (_jsx(CopyToClipboard, __assign({ onCopy: onCopy, text: hoveringNode.meta.function.name }, { children: _jsx("button", __assign({ className: "cursor-pointer text-left" }, { children: hoveringNode.meta.function.name })) }))) : (_jsx(_Fragment, { children: hoveringNode.meta.location !== undefined &&
157
- parseInt(hoveringNode.meta.location.address, 10) !== 0 ? (_jsx(CopyToClipboard, __assign({ onCopy: onCopy, text: hexifyAddress(hoveringNode.meta.location.address) }, { children: _jsx("button", __assign({ className: "cursor-pointer text-left" }, { children: hexifyAddress(hoveringNode.meta.location.address) })) }))) : (_jsx("p", { children: "unknown" })) })) })) })), _jsx("table", __assign({ 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", __assign({ className: "w-1/4" }, { children: "Cumulative" })), _jsx("td", __assign({ className: "w-3/4" }, { children: _jsx(CopyToClipboard, __assign({ onCopy: onCopy, text: getTextForCumulative(hoveringNodeCumulative) }, { children: _jsx("button", __assign({ className: "cursor-pointer" }, { children: getTextForCumulative(hoveringNodeCumulative) })) })) }))] }), hoveringNode.diff !== undefined && diff !== 0 && (_jsxs("tr", { children: [_jsx("td", __assign({ className: "w-1/4" }, { children: "Diff" })), _jsx("td", __assign({ className: "w-3/4" }, { children: _jsx(CopyToClipboard, __assign({ onCopy: onCopy, text: diffText }, { children: _jsx("button", __assign({ className: "cursor-pointer" }, { children: diffText })) })) }))] })), _jsx(TooltipMetaInfo, { onCopy: onCopy, hoveringNode: hoveringNode, strings: strings, mappings: mappings, locations: locations, functions: functions, type: type })] }) }))] })) })), _jsx("span", __assign({ className: "mx-2 block text-xs text-gray-500" }, { children: isCopied ? 'Copied!' : 'Hold shift and click on a value to copy.' }))] })) })) })));
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
- var GraphTooltip = function (_a) {
160
- var x = _a.x, y = _a.y, unit = _a.unit, total = _a.total, totalUnfiltered = _a.totalUnfiltered, hoveringNodeProp = _a.hoveringNode, contextElement = _a.contextElement, _b = _a.isFixed, isFixed = _b === void 0 ? false : _b, _c = _a.virtualContextElement, virtualContextElement = _c === void 0 ? true : _c, strings = _a.strings, mappings = _a.mappings, locations = _a.locations, functions = _a.functions, _d = _a.type, type = _d === void 0 ? 'flamegraph' : _d;
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
- var hoveringNode = useMemo(function () {
164
- var h = hoveringNodeProp !== null && hoveringNodeProp !== void 0 ? hoveringNodeProp : hoveringNodeState;
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 __assign(__assign({}, h), { meta: __assign({}, h.meta) });
139
+ return {
140
+ ...h,
141
+ meta: {
142
+ ...h.meta,
143
+ },
144
+ };
170
145
  }, [hoveringNodeProp, hoveringNodeState]);
171
- var _e = useState(null), popperElement = _e[0], setPopperElement = _e[1];
172
- var _f = usePopper(virtualContextElement ? virtualElement : contextElement, popperElement, {
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 !== null && contextElement !== void 0 ? contextElement : undefined,
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 !== null && contextElement !== void 0 ? contextElement : undefined,
168
+ boundary: contextElement ?? undefined,
194
169
  },
195
170
  },
196
171
  ],
197
- }), styles = _f.styles, attributes = _f.attributes, popperProps = __rest(_f, ["styles", "attributes"]);
198
- var isShiftDown = useKeyDown().isShiftDown;
199
- useEffect(function () {
172
+ });
173
+ const { isShiftDown } = useKeyDown();
174
+ useEffect(() => {
200
175
  if (contextElement === null)
201
176
  return;
202
- var onMouseMove = function (e) {
203
- var _a;
177
+ const onMouseMove = (e) => {
204
178
  if (isShiftDown) {
205
179
  return;
206
180
  }
207
- var tooltipX = x;
208
- var tooltipY = y;
181
+ let tooltipX = x;
182
+ let tooltipY = y;
209
183
  if (tooltipX == null || tooltipY == null) {
210
- var rel = pointer(e);
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 ((_a = popperProps.update) === null || _a === void 0 ? void 0 : _a.call(popperProps));
189
+ void popperProps.update?.();
216
190
  };
217
191
  contextElement.addEventListener('mousemove', onMouseMove);
218
- return function () {
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", __assign({ 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 }) })));
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
- var SuggestionItem = function (_a) {
28
- var isHighlighted = _a.isHighlighted, onHighlight = _a.onHighlight, onApplySuggestion = _a.onApplySuggestion, onResetHighlight = _a.onResetHighlight, value = _a.value;
29
- var ref = useRef(null);
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", __assign({ className: cx('relative cursor-default select-none py-2 pl-3 pr-9', {
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: function () { return onHighlight(); }, onClick: function () { return onApplySuggestion(); }, onMouseOut: function () { return onResetHighlight(); }, ref: ref }, { children: value })));
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
- var Suggestion = /** @class */ (function () {
31
- function Suggestion(type, typeahead, value) {
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
- return Suggestion;
37
- }());
38
- export { Suggestion };
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
- return Suggestions;
46
- }());
47
- export { Suggestions };
48
- var LoadingSpinner = function () {
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
- var SuggestionsList = function (_a) {
53
- var suggestions = _a.suggestions, applySuggestion = _a.applySuggestion, inputRef = _a.inputRef, runQuery = _a.runQuery, focusedInput = _a.focusedInput, isLabelNamesLoading = _a.isLabelNamesLoading, isLabelValuesLoading = _a.isLabelValuesLoading;
54
- var _b = useState(null), popperElement = _b[0], setPopperElement = _b[1];
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
- }), styles = _c.styles, attributes = _c.attributes;
58
- var _d = useState(-1), highlightedSuggestionIndex = _d[0], setHighlightedSuggestionIndex = _d[1];
59
- var _e = useState(true), showSuggest = _e[0], setShowSuggest = _e[1];
60
- var suggestionsLength = suggestions.literals.length + suggestions.labelNames.length + suggestions.labelValues.length;
61
- var getSuggestion = useCallback(function (index) {
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
- var resetHighlight = useCallback(function () { return setHighlightedSuggestionIndex(-1); }, [setHighlightedSuggestionIndex]);
71
- var applyHighlightedSuggestion = useCallback(function () {
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
- var applySuggestionWithIndex = useCallback(function (index) {
59
+ const applySuggestionWithIndex = useCallback((index) => {
76
60
  applySuggestion(getSuggestion(index));
77
61
  resetHighlight();
78
62
  }, [resetHighlight, applySuggestion, getSuggestion]);
79
- var highlightNext = useCallback(function () {
80
- var nextIndex = highlightedSuggestionIndex + 1;
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
- var highlightPrevious = useCallback(function () {
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
- var handleKeyPress = useCallback(function (event) {
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
- var handleKeyDown = useCallback(function (event) {
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(function () {
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 function () {
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", __assign({ ref: setPopperElement, style: __assign(__assign({}, styles.popper), { marginLeft: 0 }) }, attributes.popper, { className: "z-50" }, { children: _jsx(Transition, __assign({ show: focusedInput && showSuggest, as: Fragment, leave: "transition ease-in duration-100", leaveFrom: "opacity-100", leaveTo: "opacity-0" }, { children: _jsxs("div", __assign({ style: { width: inputRef === null || inputRef === void 0 ? void 0 : 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(function (l, i) { return (_jsx(SuggestionItem, { isHighlighted: highlightedSuggestionIndex === i, onHighlight: function () { return setHighlightedSuggestionIndex(i); }, onApplySuggestion: function () { return applySuggestionWithIndex(i); }, onResetHighlight: function () { return resetHighlight(); }, value: l.value }, l.value)); }) })), suggestions.literals.map(function (l, i) { return (_jsx(SuggestionItem, { isHighlighted: highlightedSuggestionIndex === i + suggestions.labelNames.length, onHighlight: function () {
152
- return setHighlightedSuggestionIndex(i + suggestions.labelNames.length);
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;