@parca/profile 0.16.198 → 0.16.199

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 (57) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/Callgraph/index.d.ts +0 -1
  3. package/dist/GraphTooltip/ExpandOnHoverValue.d.ts +0 -1
  4. package/dist/GraphTooltip/index.d.ts +0 -1
  5. package/dist/GraphTooltipArrow/ExpandOnHoverValue.d.ts +6 -0
  6. package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +4 -0
  7. package/dist/GraphTooltipArrow/index.d.ts +43 -0
  8. package/dist/GraphTooltipArrow/index.js +244 -0
  9. package/dist/MatchersInput/SuggestionItem.d.ts +0 -1
  10. package/dist/MatchersInput/SuggestionsList.d.ts +0 -1
  11. package/dist/MatchersInput/index.d.ts +0 -1
  12. package/dist/MetricsCircle/index.d.ts +0 -1
  13. package/dist/MetricsGraph/MetricsTooltip/index.d.ts +0 -1
  14. package/dist/MetricsGraph/index.d.ts +0 -1
  15. package/dist/MetricsSeries/index.d.ts +0 -1
  16. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts +0 -1
  17. package/dist/ProfileExplorer/ProfileExplorerSingle.d.ts +0 -1
  18. package/dist/ProfileExplorer/index.d.ts +0 -1
  19. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.d.ts +0 -1
  20. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ColorStackLegend.d.ts +10 -0
  21. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ColorStackLegend.js +64 -0
  22. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.d.ts +48 -0
  23. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.js +150 -0
  24. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.d.ts +23 -0
  25. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.js +110 -0
  26. package/dist/ProfileIcicleGraph/IcicleGraphArrow/useNodeColor.d.ts +14 -0
  27. package/dist/ProfileIcicleGraph/IcicleGraphArrow/useNodeColor.js +26 -0
  28. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.d.ts +4 -0
  29. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.js +42 -0
  30. package/dist/ProfileIcicleGraph/index.d.ts +4 -3
  31. package/dist/ProfileIcicleGraph/index.js +7 -5
  32. package/dist/ProfileMetricsGraph/index.d.ts +0 -1
  33. package/dist/ProfileSelector/CompareButton.d.ts +0 -1
  34. package/dist/ProfileSelector/index.d.ts +0 -1
  35. package/dist/ProfileSource.d.ts +0 -1
  36. package/dist/ProfileTypeSelector/index.d.ts +0 -1
  37. package/dist/ProfileView/FilterByFunctionButton.d.ts +0 -1
  38. package/dist/ProfileView/ViewSelector.d.ts +0 -1
  39. package/dist/ProfileView/index.d.ts +2 -1
  40. package/dist/ProfileView/index.js +2 -2
  41. package/dist/ProfileViewWithData.d.ts +0 -1
  42. package/dist/ProfileViewWithData.js +15 -6
  43. package/dist/components/DiffLegend.d.ts +0 -1
  44. package/dist/components/ProfileShareButton/ResultBox.d.ts +0 -1
  45. package/dist/components/ProfileShareButton/index.d.ts +0 -1
  46. package/dist/styles.css +1 -1
  47. package/package.json +6 -5
  48. package/src/GraphTooltipArrow/ExpandOnHoverValue.tsx +30 -0
  49. package/src/GraphTooltipArrow/index.tsx +564 -0
  50. package/src/ProfileIcicleGraph/IcicleGraphArrow/ColorStackLegend.tsx +109 -0
  51. package/src/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.tsx +327 -0
  52. package/src/ProfileIcicleGraph/IcicleGraphArrow/index.tsx +212 -0
  53. package/src/ProfileIcicleGraph/IcicleGraphArrow/useNodeColor.ts +52 -0
  54. package/src/ProfileIcicleGraph/IcicleGraphArrow/utils.ts +51 -0
  55. package/src/ProfileIcicleGraph/index.tsx +34 -14
  56. package/src/ProfileView/index.tsx +4 -1
  57. package/src/ProfileViewWithData.tsx +20 -6
package/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.16.199](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.198...@parca/profile@0.16.199) (2023-07-05)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
6
10
  ## [0.16.198](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.188...@parca/profile@0.16.198) (2023-07-03)
7
11
 
8
12
  **Note:** Version bump only for package @parca/profile
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Callgraph as CallgraphType } from '@parca/client';
3
2
  export interface Props {
4
3
  data: CallgraphType;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  value: string | number | undefined;
4
3
  displayValue?: string | number | undefined;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CallgraphNode, CallgraphNodeMeta, FlamegraphNode, FlamegraphNodeMeta, FlamegraphRootNode } from '@parca/client';
3
2
  import { Location, Mapping, Function as ParcaFunction } from '@parca/client/dist/parca/metastore/v1alpha1/metastore';
4
3
  interface ExtendedCallgraphNodeMeta extends CallgraphNodeMeta {
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ value: string | number | undefined;
3
+ displayValue?: string | number | undefined;
4
+ }
5
+ export declare const ExpandOnHover: ({ value, displayValue }: Props) => JSX.Element;
6
+ export {};
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const ExpandOnHover = ({ value, displayValue }) => {
3
+ return (_jsxs("div", { className: "group relative w-full", children: [_jsx("div", { className: "w-full overflow-hidden text-ellipsis whitespace-nowrap", children: displayValue ?? value }), _jsx("div", { className: "absolute -inset-2 hidden h-fit max-w-[500px] whitespace-normal break-all rounded bg-gray-50 p-2 shadow-[0_0_10px_2px_rgba(0,0,0,0.3)] group-hover:flex dark:bg-gray-900", children: value })] }));
4
+ };
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { Table } from 'apache-arrow';
3
+ import { CallgraphNode, CallgraphNodeMeta, FlamegraphNode, FlamegraphNodeMeta, FlamegraphRootNode } from '@parca/client';
4
+ import { Location, Mapping, Function as ParcaFunction } from '@parca/client/dist/parca/metastore/v1alpha1/metastore';
5
+ interface ExtendedCallgraphNodeMeta extends CallgraphNodeMeta {
6
+ lineIndex: number;
7
+ locationIndex: number;
8
+ }
9
+ interface HoveringNode extends FlamegraphRootNode, FlamegraphNode, CallgraphNode {
10
+ diff: bigint;
11
+ meta?: FlamegraphNodeMeta | ExtendedCallgraphNodeMeta;
12
+ }
13
+ interface GraphTooltipProps {
14
+ table: Table<any>;
15
+ x?: number;
16
+ y?: number;
17
+ unit: string;
18
+ total: bigint;
19
+ totalUnfiltered: bigint;
20
+ hoveringNode?: HoveringNode;
21
+ contextElement: Element | null;
22
+ isFixed?: boolean;
23
+ virtualContextElement?: boolean;
24
+ strings?: string[];
25
+ mappings?: Mapping[];
26
+ locations?: Location[];
27
+ functions?: ParcaFunction[];
28
+ type?: string;
29
+ }
30
+ export declare const GraphTooltipContent: ({ hoveringNode, unit, total, totalUnfiltered, isFixed, strings, mappings, locations, functions, type, }: {
31
+ hoveringNode: HoveringNode;
32
+ unit: string;
33
+ total: bigint;
34
+ totalUnfiltered: bigint;
35
+ isFixed: boolean;
36
+ strings?: string[] | undefined;
37
+ mappings?: Mapping[] | undefined;
38
+ locations?: Location[] | undefined;
39
+ functions?: ParcaFunction[] | undefined;
40
+ type?: string | undefined;
41
+ }) => React.JSX.Element;
42
+ declare const GraphTooltip: ({ table, x, y, unit, total, totalUnfiltered, contextElement, isFixed, virtualContextElement, strings, mappings, locations, functions, type, }: GraphTooltipProps) => React.JSX.Element;
43
+ export default GraphTooltip;
@@ -0,0 +1,244 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // Copyright 2022 The Parca Authors
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { useEffect, useMemo, useState } from 'react';
15
+ import { pointer } from 'd3-selection';
16
+ import { CopyToClipboard } from 'react-copy-to-clipboard';
17
+ import { usePopper } from 'react-popper';
18
+ import { useKeyDown } from '@parca/components';
19
+ import { selectHoveringRow, useAppSelector } from '@parca/store';
20
+ import { divide, getLastItem, valueFormatter } from '@parca/utilities';
21
+ import { hexifyAddress, truncateString, truncateStringReverse } from '../';
22
+ import { FIELD_CUMULATIVE, FIELD_DIFF, FIELD_FUNCTION_FILE_NAME, FIELD_FUNCTION_NAME, FIELD_LOCATION_ADDRESS, FIELD_MAPPING_BUILD_ID, FIELD_MAPPING_FILE, } from '../ProfileIcicleGraph/IcicleGraphArrow';
23
+ import { ExpandOnHover } from './ExpandOnHoverValue';
24
+ const NoData = () => {
25
+ return _jsx("span", { className: "rounded bg-gray-200 px-2 dark:bg-gray-800", children: "Not available" });
26
+ };
27
+ const virtualElement = {
28
+ getBoundingClientRect: () =>
29
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
30
+ ({
31
+ width: 0,
32
+ height: 0,
33
+ top: 0,
34
+ left: 0,
35
+ right: 0,
36
+ bottom: 0,
37
+ }),
38
+ };
39
+ function generateGetBoundingClientRect(contextElement, x = 0, y = 0) {
40
+ const domRect = contextElement.getBoundingClientRect();
41
+ return () =>
42
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
43
+ ({
44
+ width: 0,
45
+ height: 0,
46
+ top: domRect.y + y,
47
+ left: domRect.x + x,
48
+ right: domRect.x + x,
49
+ bottom: domRect.y + y,
50
+ });
51
+ }
52
+ const TooltipMetaInfo = ({ hoveringNode, onCopy, strings, mappings, locations, functions, type = 'flamegraph', }) => {
53
+ // populate meta from the flamegraph metadata tables
54
+ if (type === 'flamegraph' &&
55
+ locations !== undefined &&
56
+ hoveringNode.meta?.locationIndex !== undefined &&
57
+ hoveringNode.meta.locationIndex !== 0) {
58
+ const location = locations[hoveringNode.meta.locationIndex - 1];
59
+ hoveringNode.meta.location = location;
60
+ if (location !== undefined) {
61
+ if (mappings !== undefined &&
62
+ location.mappingIndex !== undefined &&
63
+ location.mappingIndex !== 0) {
64
+ const mapping = mappings[location.mappingIndex - 1];
65
+ if (strings !== undefined && mapping !== undefined) {
66
+ mapping.file =
67
+ mapping?.fileStringIndex !== undefined ? strings[mapping.fileStringIndex] : '';
68
+ mapping.buildId =
69
+ mapping?.buildIdStringIndex !== undefined ? strings[mapping.buildIdStringIndex] : '';
70
+ }
71
+ hoveringNode.meta.mapping = mapping;
72
+ }
73
+ if (functions !== undefined &&
74
+ location.lines !== undefined &&
75
+ hoveringNode.meta.lineIndex !== undefined &&
76
+ hoveringNode.meta.lineIndex < location.lines.length) {
77
+ const func = functions[location.lines[hoveringNode.meta.lineIndex].functionIndex - 1];
78
+ if (strings !== undefined) {
79
+ func.name = strings[func.nameStringIndex];
80
+ func.systemName = strings[func.systemNameStringIndex];
81
+ func.filename = strings[func.filenameStringIndex];
82
+ }
83
+ hoveringNode.meta.function = func;
84
+ }
85
+ }
86
+ }
87
+ const getTextForFile = (hoveringNode) => {
88
+ if (hoveringNode.meta?.function == null)
89
+ return '<unknown>';
90
+ return `${hoveringNode.meta.function.filename} ${hoveringNode.meta.line?.line !== undefined && hoveringNode.meta.line?.line !== 0n
91
+ ? ` +${hoveringNode.meta.line.line.toString()}`
92
+ : `${hoveringNode.meta.function?.startLine !== undefined &&
93
+ hoveringNode.meta.function?.startLine !== 0n
94
+ ? ` +${hoveringNode.meta.function.startLine}`
95
+ : ''}`}`;
96
+ };
97
+ const file = getTextForFile(hoveringNode);
98
+ 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 ||
99
+ 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 ||
100
+ 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) }) })) })] })] }));
101
+ };
102
+ let timeoutHandle = null;
103
+ export const GraphTooltipContent = ({ hoveringNode, unit, total, totalUnfiltered, isFixed, strings, mappings, locations, functions, type = 'flamegraph', }) => {
104
+ const [isCopied, setIsCopied] = useState(false);
105
+ const onCopy = () => {
106
+ setIsCopied(true);
107
+ if (timeoutHandle !== null) {
108
+ clearTimeout(timeoutHandle);
109
+ }
110
+ timeoutHandle = setTimeout(() => setIsCopied(false), 3000);
111
+ };
112
+ const hoveringNodeCumulative = hoveringNode.cumulative;
113
+ const diff = hoveringNode.diff;
114
+ const prevValue = hoveringNodeCumulative - diff;
115
+ const diffRatio = diff !== 0n ? divide(diff, prevValue) : 0;
116
+ const diffSign = diff > 0 ? '+' : '';
117
+ const diffValueText = diffSign + valueFormatter(diff, unit, 1);
118
+ const diffPercentageText = diffSign + (diffRatio * 100).toFixed(2) + '%';
119
+ const diffText = `${diffValueText} (${diffPercentageText})`;
120
+ const getTextForCumulative = (hoveringNodeCumulative) => {
121
+ const filtered = totalUnfiltered > total
122
+ ? ` / ${(100 * divide(hoveringNodeCumulative, total)).toFixed(2)}% of filtered`
123
+ : '';
124
+ return `${valueFormatter(hoveringNodeCumulative, unit, 2)}
125
+ (${(100 * divide(hoveringNodeCumulative, totalUnfiltered)).toFixed(2)}%${filtered})`;
126
+ };
127
+ 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 &&
128
+ 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 &&
129
+ 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.' })] }) }) }));
130
+ };
131
+ const GraphTooltip = ({ table, x, y, unit, total, totalUnfiltered, contextElement, isFixed = false, virtualContextElement = true, strings, mappings, locations, functions, type = 'flamegraph', }) => {
132
+ const hoveringNodeState = useAppSelector(selectHoveringRow);
133
+ const hoveringNode = useMemo(() => {
134
+ const s = hoveringNodeState;
135
+ if (s === undefined) {
136
+ return undefined;
137
+ }
138
+ const mappingFile = table.getChild(FIELD_MAPPING_FILE)?.get(s.row) ?? '';
139
+ const mappingBuildID = table.getChild(FIELD_MAPPING_BUILD_ID)?.get(s.row) ?? '';
140
+ const locationAddress = table.getChild(FIELD_LOCATION_ADDRESS)?.get(s.row) ?? 0n;
141
+ const functionName = table.getChild(FIELD_FUNCTION_NAME)?.get(s.row) ?? '';
142
+ const functionFileName = table.getChild(FIELD_FUNCTION_FILE_NAME)?.get(s.row) ?? '';
143
+ const cumulative = table.getChild(FIELD_CUMULATIVE)?.get(s.row) ?? 0n;
144
+ const diff = table.getChild(FIELD_DIFF)?.get(s.row) ?? 0n;
145
+ const fhn = {
146
+ id: '',
147
+ flat: 0n,
148
+ children: [],
149
+ cumulative,
150
+ diff: diff === null ? 0n : diff,
151
+ meta: {
152
+ locationIndex: 0,
153
+ lineIndex: 0,
154
+ mapping: {
155
+ id: '',
156
+ start: 0n,
157
+ limit: 0n,
158
+ offset: 0n,
159
+ file: mappingFile,
160
+ buildId: mappingBuildID,
161
+ hasFunctions: false,
162
+ hasFilenames: false,
163
+ hasLineNumbers: false,
164
+ hasInlineFrames: false,
165
+ fileStringIndex: 0,
166
+ buildIdStringIndex: 0,
167
+ },
168
+ location: {
169
+ id: '',
170
+ address: locationAddress,
171
+ mappingId: '',
172
+ isFolded: false,
173
+ lines: [],
174
+ mappingIndex: 0,
175
+ },
176
+ function: {
177
+ id: '',
178
+ startLine: 0n,
179
+ name: functionName,
180
+ systemName: '',
181
+ filename: functionFileName,
182
+ nameStringIndex: 0,
183
+ systemNameStringIndex: 0,
184
+ filenameStringIndex: 0,
185
+ },
186
+ },
187
+ };
188
+ return fhn;
189
+ }, [table, hoveringNodeState]);
190
+ const [popperElement, setPopperElement] = useState(null);
191
+ const { styles, attributes, ...popperProps } = usePopper(virtualContextElement ? virtualElement : contextElement, popperElement, {
192
+ placement: 'bottom-start',
193
+ strategy: 'absolute',
194
+ modifiers: [
195
+ {
196
+ name: 'preventOverflow',
197
+ options: {
198
+ tether: false,
199
+ altAxis: true,
200
+ boundary: contextElement ?? undefined,
201
+ },
202
+ },
203
+ {
204
+ name: 'offset',
205
+ options: {
206
+ offset: [30, 30],
207
+ },
208
+ },
209
+ {
210
+ name: 'flip',
211
+ options: {
212
+ boundary: contextElement ?? undefined,
213
+ },
214
+ },
215
+ ],
216
+ });
217
+ const { isShiftDown } = useKeyDown();
218
+ useEffect(() => {
219
+ if (contextElement === null)
220
+ return;
221
+ const onMouseMove = (e) => {
222
+ if (isShiftDown) {
223
+ return;
224
+ }
225
+ let tooltipX = x;
226
+ let tooltipY = y;
227
+ if (tooltipX == null || tooltipY == null) {
228
+ const rel = pointer(e);
229
+ tooltipX = rel[0];
230
+ tooltipY = rel[1];
231
+ }
232
+ virtualElement.getBoundingClientRect = generateGetBoundingClientRect(contextElement, tooltipX, tooltipY);
233
+ void popperProps.update?.();
234
+ };
235
+ contextElement.addEventListener('mousemove', onMouseMove);
236
+ return () => {
237
+ contextElement.removeEventListener('mousemove', onMouseMove);
238
+ };
239
+ }, [contextElement, popperProps, isShiftDown, x, y]);
240
+ if (hoveringNode === undefined || hoveringNode == null)
241
+ return _jsx(_Fragment, {});
242
+ 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 }) }));
243
+ };
244
+ export default GraphTooltip;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  isHighlighted: boolean;
4
3
  onHighlight: () => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare class Suggestion {
3
2
  type: string;
4
3
  typeahead: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { LabelsResponse, QueryServiceClient } from '@parca/client';
3
2
  import { Query } from '@parca/parser';
4
3
  interface MatchersInputProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface MetricsCircleProps {
3
2
  cx: number;
4
3
  cy: number;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { HighlightedSeries } from '../';
3
2
  interface Props {
4
3
  x: number;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Label, MetricsSeries as MetricsSeriesPb } from '@parca/client';
3
2
  import { DateTimeRange } from '@parca/components';
4
3
  import { MergedProfileSelection } from '..';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import * as d3 from 'd3';
3
2
  interface MetricsSeriesProps {
4
3
  data: any;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { QueryServiceClient } from '@parca/client';
3
2
  import type { NavigateFunction } from '@parca/utilities';
4
3
  import { ProfileSelection } from '..';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { QueryServiceClient } from '@parca/client';
3
2
  import type { NavigateFunction } from '@parca/utilities';
4
3
  import { ProfileSelection } from '..';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { QueryServiceClient } from '@parca/client';
3
2
  import type { NavigateFunction } from '@parca/utilities';
4
3
  interface ProfileExplorerProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { NavigateFunction } from '@parca/utilities';
3
2
  interface Props {
4
3
  navigateTo?: NavigateFunction;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { NavigateFunction } from '@parca/utilities';
3
+ import { mappingColors } from './IcicleGraphNodes';
4
+ interface Props {
5
+ mappingColors: mappingColors;
6
+ navigateTo?: NavigateFunction;
7
+ compareMode?: boolean;
8
+ }
9
+ declare const ColorStackLegend: ({ mappingColors, navigateTo, compareMode, }: Props) => React.JSX.Element;
10
+ export default ColorStackLegend;
@@ -0,0 +1,64 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Copyright 2022 The Parca Authors
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { useMemo } from 'react';
15
+ import { Icon } from '@iconify/react';
16
+ import cx from 'classnames';
17
+ import { useURLState } from '@parca/components';
18
+ import { USER_PREFERENCES, useUserPreference } from '@parca/hooks';
19
+ import { EVERYTHING_ELSE } from '@parca/store';
20
+ const ColorStackLegend = ({ mappingColors, navigateTo, compareMode = false, }) => {
21
+ const [colorProfileName] = useUserPreference(USER_PREFERENCES.FLAMEGRAPH_COLOR_PROFILE.key);
22
+ const [currentSearchString, setSearchString] = useURLState({ param: 'search_string', navigateTo });
23
+ const stackColorArray = useMemo(() => {
24
+ return Object.entries(mappingColors).sort(([featureA], [featureB]) => {
25
+ if (featureA === EVERYTHING_ELSE) {
26
+ return 1;
27
+ }
28
+ if (featureB === EVERYTHING_ELSE) {
29
+ return -1;
30
+ }
31
+ return featureA?.localeCompare(featureB ?? '') ?? 0;
32
+ });
33
+ }, [mappingColors]);
34
+ if (mappingColors === undefined) {
35
+ return _jsx(_Fragment, {});
36
+ }
37
+ if (Object.entries(mappingColors).length === 0) {
38
+ return _jsx(_Fragment, {});
39
+ }
40
+ if (colorProfileName === 'default' || compareMode) {
41
+ return _jsx(_Fragment, {});
42
+ }
43
+ return (_jsx("div", { className: "my-6 flex flex-wrap justify-center gap-2", children: stackColorArray.map(([feature, color]) => {
44
+ const filteringAllowed = feature !== EVERYTHING_ELSE;
45
+ const isHighlighted = currentSearchString === feature;
46
+ return (_jsxs("div", { className: cx('flex items-center justify-between gap-1 text-ellipsis p-1 pr-2', {
47
+ 'cursor-pointer': filteringAllowed,
48
+ 'bg-gray-200 dark:bg-gray-800': isHighlighted,
49
+ }), onClick: () => {
50
+ if (!filteringAllowed) {
51
+ return;
52
+ }
53
+ if (isHighlighted) {
54
+ setSearchString('');
55
+ return;
56
+ }
57
+ setSearchString(feature);
58
+ }, children: [_jsxs("div", { className: "flex items-center", children: [_jsx("div", { className: "mr-1 inline-block h-4 w-4", style: { backgroundColor: color } }), _jsx("span", { className: "text-sm", children: feature })] }), isHighlighted ? (_jsx(Icon, { icon: "radix-icons:cross-circled", onClick: e => {
59
+ setSearchString('');
60
+ e.stopPropagation();
61
+ } })) : null] }, feature));
62
+ }) }));
63
+ };
64
+ export default ColorStackLegend;
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import { Table } from 'apache-arrow';
3
+ export declare const RowHeight = 26;
4
+ interface IcicleGraphNodesProps {
5
+ table: Table<any>;
6
+ row: number;
7
+ mappingColors: mappingColors;
8
+ childRows: number[];
9
+ x: number;
10
+ y: number;
11
+ total: bigint;
12
+ totalWidth: number;
13
+ level: number;
14
+ curPath: string[];
15
+ setCurPath: (path: string[]) => void;
16
+ path: string[];
17
+ xScale: (value: bigint) => number;
18
+ searchString?: string;
19
+ sortBy: string;
20
+ darkMode: boolean;
21
+ compareMode: boolean;
22
+ }
23
+ export declare const IcicleGraphNodes: React.NamedExoticComponent<IcicleGraphNodesProps>;
24
+ export interface mappingColors {
25
+ [key: string]: string;
26
+ }
27
+ interface IcicleNodeProps {
28
+ x: number;
29
+ y: number;
30
+ height: number;
31
+ totalWidth: number;
32
+ curPath: string[];
33
+ level: number;
34
+ table: Table<any>;
35
+ row: number;
36
+ mappingColors: mappingColors;
37
+ path: string[];
38
+ total: bigint;
39
+ setCurPath: (path: string[]) => void;
40
+ xScale: (value: bigint) => number;
41
+ isRoot?: boolean;
42
+ searchString?: string;
43
+ sortBy: string;
44
+ darkMode: boolean;
45
+ compareMode: boolean;
46
+ }
47
+ export declare const IcicleNode: React.NamedExoticComponent<IcicleNodeProps>;
48
+ export {};