@parca/profile 0.17.1 → 0.17.3

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 (120) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/GraphTooltipArrow/Content.d.ts +1 -2
  3. package/dist/GraphTooltipArrow/Content.d.ts.map +1 -1
  4. package/dist/GraphTooltipArrow/Content.js +1 -2
  5. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.d.ts +1 -2
  6. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.d.ts.map +1 -1
  7. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +1 -2
  8. package/dist/GraphTooltipArrow/useGraphTooltip/index.d.ts +1 -2
  9. package/dist/GraphTooltipArrow/useGraphTooltip/index.d.ts.map +1 -1
  10. package/dist/GraphTooltipArrow/useGraphTooltip/index.js +2 -2
  11. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.d.ts +2 -6
  12. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.d.ts.map +1 -1
  13. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.js +4 -5
  14. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.d.ts +20 -0
  15. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.d.ts.map +1 -0
  16. package/{src/Callgraph/constants.ts → dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.js} +12 -3
  17. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.d.ts +8 -51
  18. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.d.ts.map +1 -1
  19. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.js +59 -136
  20. package/dist/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.d.ts +8 -0
  21. package/dist/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.d.ts.map +1 -0
  22. package/dist/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.js +40 -0
  23. package/dist/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.d.ts +32 -0
  24. package/dist/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.d.ts.map +1 -0
  25. package/dist/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.js +40 -0
  26. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.d.ts +4 -5
  27. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.d.ts.map +1 -1
  28. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.js +62 -76
  29. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.d.ts +3 -3
  30. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.d.ts.map +1 -1
  31. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.js +9 -7
  32. package/dist/ProfileIcicleGraph/index.d.ts +3 -6
  33. package/dist/ProfileIcicleGraph/index.d.ts.map +1 -1
  34. package/dist/ProfileIcicleGraph/index.js +8 -17
  35. package/dist/ProfileView/components/DashboardItems/index.d.ts +3 -5
  36. package/dist/ProfileView/components/DashboardItems/index.d.ts.map +1 -1
  37. package/dist/ProfileView/components/DashboardItems/index.js +4 -9
  38. package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
  39. package/dist/ProfileView/components/Toolbars/index.js +1 -2
  40. package/dist/ProfileView/index.d.ts +1 -1
  41. package/dist/ProfileView/index.d.ts.map +1 -1
  42. package/dist/ProfileView/index.js +1 -13
  43. package/dist/ProfileView/types/visualization.d.ts +1 -1
  44. package/dist/ProfileView/types/visualization.d.ts.map +1 -1
  45. package/dist/index.d.ts +0 -4
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +0 -2
  48. package/dist/styles.css +1 -1
  49. package/package.json +5 -5
  50. package/src/GraphTooltipArrow/Content.tsx +0 -3
  51. package/src/GraphTooltipArrow/DockedGraphTooltip/index.tsx +0 -3
  52. package/src/GraphTooltipArrow/useGraphTooltip/index.ts +1 -3
  53. package/src/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.tsx +5 -13
  54. package/src/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.tsx +53 -0
  55. package/src/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.tsx +96 -310
  56. package/src/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.tsx +78 -0
  57. package/src/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.tsx +93 -0
  58. package/src/ProfileIcicleGraph/IcicleGraphArrow/index.tsx +108 -216
  59. package/src/ProfileIcicleGraph/IcicleGraphArrow/utils.ts +8 -15
  60. package/src/ProfileIcicleGraph/index.tsx +7 -38
  61. package/src/ProfileView/components/DashboardItems/index.tsx +2 -27
  62. package/src/ProfileView/components/Toolbars/index.tsx +0 -2
  63. package/src/ProfileView/index.tsx +0 -14
  64. package/src/ProfileView/types/visualization.ts +1 -1
  65. package/src/index.tsx +0 -5
  66. package/dist/Callgraph/constants.d.ts +0 -3
  67. package/dist/Callgraph/constants.d.ts.map +0 -1
  68. package/dist/Callgraph/constants.js +0 -14
  69. package/dist/Callgraph/index.d.ts +0 -11
  70. package/dist/Callgraph/index.d.ts.map +0 -1
  71. package/dist/Callgraph/index.js +0 -104
  72. package/dist/Callgraph/mockData/index.d.ts +0 -149
  73. package/dist/Callgraph/mockData/index.d.ts.map +0 -1
  74. package/dist/Callgraph/mockData/index.js +0 -594
  75. package/dist/Callgraph/utils.d.ts +0 -20
  76. package/dist/Callgraph/utils.d.ts.map +0 -1
  77. package/dist/Callgraph/utils.js +0 -97
  78. package/dist/GraphTooltip/ExpandOnHoverValue.d.ts +0 -7
  79. package/dist/GraphTooltip/ExpandOnHoverValue.d.ts.map +0 -1
  80. package/dist/GraphTooltip/ExpandOnHoverValue.js +0 -4
  81. package/dist/GraphTooltip/index.d.ts +0 -41
  82. package/dist/GraphTooltip/index.d.ts.map +0 -1
  83. package/dist/GraphTooltip/index.js +0 -201
  84. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.d.ts +0 -6
  85. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.d.ts.map +0 -1
  86. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.js +0 -59
  87. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.d.ts +0 -47
  88. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.d.ts.map +0 -1
  89. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.js +0 -93
  90. package/dist/ProfileIcicleGraph/IcicleGraph/index.d.ts +0 -14
  91. package/dist/ProfileIcicleGraph/IcicleGraph/index.d.ts.map +0 -1
  92. package/dist/ProfileIcicleGraph/IcicleGraph/index.js +0 -48
  93. package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.d.ts +0 -15
  94. package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.d.ts.map +0 -1
  95. package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.js +0 -57
  96. package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.d.ts +0 -8
  97. package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.d.ts.map +0 -1
  98. package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.js +0 -32
  99. package/dist/ProfileIcicleGraph/IcicleGraph/utils.d.ts +0 -7
  100. package/dist/ProfileIcicleGraph/IcicleGraph/utils.d.ts.map +0 -1
  101. package/dist/ProfileIcicleGraph/IcicleGraph/utils.js +0 -66
  102. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.d.ts +0 -9
  103. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.d.ts.map +0 -1
  104. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.js +0 -45
  105. package/dist/ProfileView/hooks/useGraphviz.d.ts +0 -12
  106. package/dist/ProfileView/hooks/useGraphviz.d.ts.map +0 -1
  107. package/dist/ProfileView/hooks/useGraphviz.js +0 -42
  108. package/src/Callgraph/index.tsx +0 -177
  109. package/src/Callgraph/mockData/index.ts +0 -605
  110. package/src/Callgraph/utils.ts +0 -141
  111. package/src/GraphTooltip/ExpandOnHoverValue.tsx +0 -30
  112. package/src/GraphTooltip/index.tsx +0 -509
  113. package/src/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.tsx +0 -96
  114. package/src/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.tsx +0 -266
  115. package/src/ProfileIcicleGraph/IcicleGraph/index.tsx +0 -123
  116. package/src/ProfileIcicleGraph/IcicleGraph/useColoredGraph.ts +0 -117
  117. package/src/ProfileIcicleGraph/IcicleGraph/useNodeColor.ts +0 -54
  118. package/src/ProfileIcicleGraph/IcicleGraph/utils.ts +0 -102
  119. package/src/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.tsx +0 -130
  120. package/src/ProfileView/hooks/useGraphviz.ts +0 -69
@@ -1,7 +0,0 @@
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 {};
7
- //# sourceMappingURL=ExpandOnHoverValue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpandOnHoverValue.d.ts","sourceRoot":"","sources":["../../src/GraphTooltip/ExpandOnHoverValue.tsx"],"names":[],"mappings":"AAaA,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC5C;AAED,eAAO,MAAM,aAAa,4BAA2B,KAAK,KAAG,GAAG,CAAC,OAWhE,CAAC"}
@@ -1,4 +0,0 @@
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
- };
@@ -1,41 +0,0 @@
1
- import { CallgraphNode, CallgraphNodeMeta, FlamegraphNode, FlamegraphNodeMeta, FlamegraphRootNode } from '@parca/client';
2
- import { Location, Mapping, Function as ParcaFunction } from '@parca/client/dist/parca/metastore/v1alpha1/metastore';
3
- interface ExtendedCallgraphNodeMeta extends CallgraphNodeMeta {
4
- lineIndex: number;
5
- locationIndex: number;
6
- }
7
- interface HoveringNode extends FlamegraphRootNode, FlamegraphNode, CallgraphNode {
8
- diff: bigint;
9
- meta?: FlamegraphNodeMeta | ExtendedCallgraphNodeMeta;
10
- }
11
- interface GraphTooltipProps {
12
- x?: number;
13
- y?: number;
14
- unit: string;
15
- total: bigint;
16
- totalUnfiltered: bigint;
17
- hoveringNode?: HoveringNode;
18
- contextElement: Element | null;
19
- isFixed?: boolean;
20
- virtualContextElement?: boolean;
21
- strings?: string[];
22
- mappings?: Mapping[];
23
- locations?: Location[];
24
- functions?: ParcaFunction[];
25
- type?: string;
26
- }
27
- export declare const GraphTooltipContent: ({ hoveringNode, unit, total, totalUnfiltered, isFixed, strings, mappings, locations, functions, type, }: {
28
- hoveringNode: HoveringNode;
29
- unit: string;
30
- total: bigint;
31
- totalUnfiltered: bigint;
32
- isFixed: boolean;
33
- strings?: string[];
34
- mappings?: Mapping[];
35
- locations?: Location[];
36
- functions?: ParcaFunction[];
37
- type?: string;
38
- }) => JSX.Element;
39
- declare const GraphTooltip: ({ x, y, unit, total, totalUnfiltered, hoveringNode: hoveringNodeProp, contextElement, isFixed, virtualContextElement, strings, mappings, locations, functions, type, }: GraphTooltipProps) => JSX.Element;
40
- export default GraphTooltip;
41
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/GraphTooltip/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,IAAI,aAAa,EAC1B,MAAM,uDAAuD,CAAC;AAY/D,UAAU,yBAA0B,SAAQ,iBAAiB;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,YAAa,SAAQ,kBAAkB,EAAE,cAAc,EAAE,aAAa;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,kBAAkB,GAAG,yBAAyB,CAAC;CACvD;AAED,UAAU,iBAAiB;IACzB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,cAAc,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAgLD,eAAO,MAAM,mBAAmB,4GAW7B;IACD,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,KAAG,GAAG,CAAC,OAoHP,CAAC;AAEF,QAAA,MAAM,YAAY,2KAef,iBAAiB,KAAG,GAAG,CAAC,OA6G1B,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,201 +0,0 @@
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 { usePopper } from 'react-popper';
17
- import { CopyToClipboard, useKeyDown } from '@parca/components';
18
- import { selectHoveringNode, useAppSelector } from '@parca/store';
19
- import { divide, getLastItem, valueFormatter } from '@parca/utilities';
20
- import { hexifyAddress, truncateString, truncateStringReverse } from '../';
21
- import { ExpandOnHover } from './ExpandOnHoverValue';
22
- const NoData = () => {
23
- return _jsx("span", { className: "rounded bg-gray-200 px-2 dark:bg-gray-800", children: "Not available" });
24
- };
25
- const virtualElement = {
26
- getBoundingClientRect: () =>
27
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
28
- ({
29
- width: 0,
30
- height: 0,
31
- top: 0,
32
- left: 0,
33
- right: 0,
34
- bottom: 0,
35
- }),
36
- };
37
- function generateGetBoundingClientRect(contextElement, x = 0, y = 0) {
38
- const domRect = contextElement.getBoundingClientRect();
39
- return () =>
40
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
41
- ({
42
- width: 0,
43
- height: 0,
44
- top: domRect.y + y,
45
- left: domRect.x + x,
46
- right: domRect.x + x,
47
- bottom: domRect.y + y,
48
- });
49
- }
50
- const TooltipMetaInfo = ({ hoveringNode, onCopy, strings, mappings, locations, functions, type = 'flamegraph', }) => {
51
- // populate meta from the flamegraph metadata tables
52
- if (type === 'flamegraph' &&
53
- locations !== undefined &&
54
- hoveringNode.meta?.locationIndex !== undefined &&
55
- hoveringNode.meta.locationIndex !== 0) {
56
- const location = locations[hoveringNode.meta.locationIndex - 1];
57
- hoveringNode.meta.location = location;
58
- if (location !== undefined) {
59
- if (mappings !== undefined &&
60
- location.mappingIndex !== undefined &&
61
- location.mappingIndex !== 0) {
62
- const mapping = mappings[location.mappingIndex - 1];
63
- if (strings !== undefined && mapping !== undefined) {
64
- mapping.file =
65
- mapping?.fileStringIndex !== undefined ? strings[mapping.fileStringIndex] : '';
66
- mapping.buildId =
67
- mapping?.buildIdStringIndex !== undefined ? strings[mapping.buildIdStringIndex] : '';
68
- }
69
- hoveringNode.meta.mapping = mapping;
70
- }
71
- if (functions !== undefined &&
72
- location.lines !== undefined &&
73
- hoveringNode.meta.lineIndex !== undefined &&
74
- hoveringNode.meta.lineIndex < location.lines.length) {
75
- const func = functions[location.lines[hoveringNode.meta.lineIndex].functionIndex - 1];
76
- if (strings !== undefined) {
77
- func.name = strings[func.nameStringIndex];
78
- func.systemName = strings[func.systemNameStringIndex];
79
- func.filename = strings[func.filenameStringIndex];
80
- }
81
- hoveringNode.meta.function = func;
82
- }
83
- }
84
- }
85
- const getTextForFile = (hoveringNode) => {
86
- if (hoveringNode.meta?.function == null)
87
- return '<unknown>';
88
- return `${hoveringNode.meta.function.filename} ${hoveringNode.meta.line?.line !== undefined && hoveringNode.meta.line?.line !== 0n
89
- ? ` +${hoveringNode.meta.line.line.toString()}`
90
- : `${hoveringNode.meta.function?.startLine !== undefined &&
91
- hoveringNode.meta.function?.startLine !== 0n
92
- ? ` +${hoveringNode.meta.function.startLine}`
93
- : ''}`}`;
94
- };
95
- const file = getTextForFile(hoveringNode);
96
- 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 ||
97
- 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 ||
98
- 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) }) })) })] })] }));
99
- };
100
- let timeoutHandle = null;
101
- export const GraphTooltipContent = ({ hoveringNode, unit, total, totalUnfiltered, isFixed, strings, mappings, locations, functions, type = 'flamegraph', }) => {
102
- const [isCopied, setIsCopied] = useState(false);
103
- const onCopy = () => {
104
- setIsCopied(true);
105
- if (timeoutHandle !== null) {
106
- clearTimeout(timeoutHandle);
107
- }
108
- timeoutHandle = setTimeout(() => setIsCopied(false), 3000);
109
- };
110
- const hoveringNodeCumulative = hoveringNode.cumulative;
111
- // '?? 0n' is needed because because diff is undefined in callgraph for some nodes,
112
- // even though the type doesn't allow it.
113
- const diff = hoveringNode.diff ?? 0n;
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
- ? ` / ${divide(hoveringNodeCumulative * 100n, total).toFixed(2)}% of filtered`
123
- : '';
124
- return `${valueFormatter(hoveringNodeCumulative, unit, 2)}
125
- (${divide(hoveringNodeCumulative * 100n, 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 = ({ x, y, unit, total, totalUnfiltered, hoveringNode: hoveringNodeProp, contextElement, isFixed = false, virtualContextElement = true, strings, mappings, locations, functions, type = 'flamegraph', }) => {
132
- const hoveringNodeState = useAppSelector(selectHoveringNode);
133
- // @ts-expect-error
134
- const hoveringNode = useMemo(() => {
135
- const h = hoveringNodeProp ?? hoveringNodeState;
136
- if (h == null) {
137
- return h;
138
- }
139
- // Cloning the object to avoid the mutating error as this is Redux store object and we are modifying the meta object in GraphTooltipContent component.
140
- return {
141
- ...h,
142
- meta: {
143
- ...h.meta,
144
- },
145
- };
146
- }, [hoveringNodeProp, hoveringNodeState]);
147
- const [popperElement, setPopperElement] = useState(null);
148
- const { styles, attributes, ...popperProps } = usePopper(virtualContextElement ? virtualElement : contextElement, popperElement, {
149
- placement: 'bottom-start',
150
- strategy: 'absolute',
151
- modifiers: [
152
- {
153
- name: 'preventOverflow',
154
- options: {
155
- tether: false,
156
- altAxis: true,
157
- boundary: contextElement ?? undefined,
158
- },
159
- },
160
- {
161
- name: 'offset',
162
- options: {
163
- offset: [30, 30],
164
- },
165
- },
166
- {
167
- name: 'flip',
168
- options: {
169
- boundary: contextElement ?? undefined,
170
- },
171
- },
172
- ],
173
- });
174
- const { isShiftDown } = useKeyDown();
175
- useEffect(() => {
176
- if (contextElement === null)
177
- return;
178
- const onMouseMove = (e) => {
179
- if (isShiftDown) {
180
- return;
181
- }
182
- let tooltipX = x;
183
- let tooltipY = y;
184
- if (tooltipX == null || tooltipY == null) {
185
- const rel = pointer(e);
186
- tooltipX = rel[0];
187
- tooltipY = rel[1];
188
- }
189
- virtualElement.getBoundingClientRect = generateGetBoundingClientRect(contextElement, tooltipX, tooltipY);
190
- void popperProps.update?.();
191
- };
192
- contextElement.addEventListener('mousemove', onMouseMove);
193
- return () => {
194
- contextElement.removeEventListener('mousemove', onMouseMove);
195
- };
196
- }, [contextElement, popperProps, isShiftDown, x, y]);
197
- if (hoveringNode === undefined || hoveringNode == null)
198
- return _jsx(_Fragment, {});
199
- 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 }) }));
200
- };
201
- export default GraphTooltip;
@@ -1,6 +0,0 @@
1
- interface Props {
2
- compareMode?: boolean;
3
- }
4
- declare const ColorStackLegend: ({ compareMode }: Props) => JSX.Element;
5
- export default ColorStackLegend;
6
- //# sourceMappingURL=ColorStackLegend.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColorStackLegend.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.tsx"],"names":[],"mappings":"AAsBA,UAAU,KAAK;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,QAAA,MAAM,gBAAgB,oBAA2B,KAAK,KAAG,GAAG,CAAC,OAmE5D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,59 +0,0 @@
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, selectStackColors, useAppSelector } from '@parca/store';
20
- const ColorStackLegend = ({ compareMode = false }) => {
21
- const [colorProfileName] = useUserPreference(USER_PREFERENCES.FLAMEGRAPH_COLOR_PROFILE.key);
22
- const [currentSearchString, setSearchString] = useURLState('search_string');
23
- const stackColors = useAppSelector(selectStackColors);
24
- const stackColorArray = useMemo(() => {
25
- return Object.entries(stackColors).sort(([featureA], [featureB]) => {
26
- if (featureA === EVERYTHING_ELSE) {
27
- return 1;
28
- }
29
- if (featureB === EVERYTHING_ELSE) {
30
- return -1;
31
- }
32
- return featureA?.localeCompare(featureB ?? '') ?? 0;
33
- });
34
- }, [stackColors]);
35
- if (colorProfileName === 'default' || compareMode) {
36
- return _jsx(_Fragment, {});
37
- }
38
- return (_jsx("div", { className: "my-6 flex flex-wrap justify-center gap-2", children: stackColorArray.map(([feature, color]) => {
39
- const filteringAllowed = feature !== EVERYTHING_ELSE;
40
- const isHighlighted = currentSearchString === feature;
41
- return (_jsxs("div", { className: cx('flex items-center justify-between gap-1 text-ellipsis p-1 pr-2', {
42
- 'cursor-pointer': filteringAllowed,
43
- 'bg-gray-200 dark:bg-gray-800': isHighlighted,
44
- }), onClick: () => {
45
- if (!filteringAllowed) {
46
- return;
47
- }
48
- if (isHighlighted) {
49
- setSearchString('');
50
- return;
51
- }
52
- setSearchString(feature);
53
- }, children: [_jsxs("div", { className: "flex items-center", children: [_jsx("div", { className: "mr-1 inline-block h-4 w-4 rounded-[4px]", style: { backgroundColor: color } }), _jsx("span", { className: "text-sm", children: feature })] }), isHighlighted ? (_jsx(Icon, { icon: "radix-icons:cross-circled", onClick: e => {
54
- setSearchString('');
55
- e.stopPropagation();
56
- } })) : null] }, feature));
57
- }) }));
58
- };
59
- export default ColorStackLegend;
@@ -1,47 +0,0 @@
1
- import React from 'react';
2
- import { FlamegraphNode } from '@parca/client';
3
- import { Location, Mapping, Function as ParcaFunction } from '@parca/client/dist/parca/metastore/v1alpha1/metastore';
4
- import { type ScaleFunction } from '@parca/utilities';
5
- export declare const RowHeight = 26;
6
- interface IcicleGraphNodesProps {
7
- data: FlamegraphNode[];
8
- strings: string[];
9
- mappings: Mapping[];
10
- locations: Location[];
11
- functions: ParcaFunction[];
12
- x: number;
13
- y: number;
14
- total: bigint;
15
- totalWidth: number;
16
- level: number;
17
- curPath: string[];
18
- setCurPath: (path: string[]) => void;
19
- path: string[];
20
- xScale: ScaleFunction;
21
- searchString?: string;
22
- compareMode: boolean;
23
- }
24
- export declare const IcicleGraphNodes: React.NamedExoticComponent<IcicleGraphNodesProps>;
25
- interface IcicleNodeProps {
26
- x: number;
27
- y: number;
28
- height: number;
29
- totalWidth: number;
30
- curPath: string[];
31
- level: number;
32
- data: FlamegraphNode;
33
- strings: string[];
34
- mappings: Mapping[];
35
- locations: Location[];
36
- functions: ParcaFunction[];
37
- path: string[];
38
- total: bigint;
39
- setCurPath: (path: string[]) => void;
40
- xScale: ScaleFunction;
41
- isRoot?: boolean;
42
- searchString?: string;
43
- compareMode: boolean;
44
- }
45
- export declare const IcicleNode: React.NamedExoticComponent<IcicleNodeProps>;
46
- export {};
47
- //# sourceMappingURL=IcicleGraphNodes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IcicleGraphNodes.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAgB,MAAM,OAAO,CAAC;AAIrC,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,IAAI,aAAa,EAC1B,MAAM,uDAAuD,CAAC;AAG/D,OAAO,EAA6B,KAAK,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAKhF,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,UAAU,qBAAqB;IAC7B,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACrC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,mDA4D3B,CAAC;AAEH,UAAU,eAAe;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACrC,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;CACtB;AAYD,eAAO,MAAM,UAAU,6CAyHrB,CAAC"}
@@ -1,93 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, 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 React, { useMemo } from 'react';
15
- import cx from 'classnames';
16
- import { useKeyDown } from '@parca/components';
17
- import { selectBinaries, setHoveringNode, useAppDispatch, useAppSelector } from '@parca/store';
18
- import { isSearchMatch, scaleLinear } from '@parca/utilities';
19
- import useNodeColor from './useNodeColor';
20
- import { nodeLabel } from './utils';
21
- export const RowHeight = 26;
22
- export const IcicleGraphNodes = React.memo(function IcicleGraphNodesNoMemo({ data, strings, mappings, locations, functions, x, y, xScale, total, totalWidth, level, path, setCurPath, curPath, searchString, compareMode, }) {
23
- const binaries = useAppSelector(selectBinaries);
24
- const nodes = curPath.length === 0
25
- ? data
26
- : data.filter(d => d != null &&
27
- curPath[0] ===
28
- nodeLabel(d, strings, mappings, locations, functions, binaries.length > 1));
29
- return (_jsx("g", { transform: `translate(${x}, ${y})`, children: nodes.map(function nodeMapper(d, i) {
30
- const start = nodes.slice(0, i).reduce((sum, d) => sum + d.cumulative, 0n);
31
- const xStart = xScale(start);
32
- return (_jsx(IcicleNode, { x: xStart, y: 0, totalWidth: totalWidth, height: RowHeight, path: path, setCurPath: setCurPath, level: level, curPath: curPath, data: d, strings: strings, mappings: mappings, locations: locations, functions: functions, total: total, xScale: xScale, searchString: searchString, compareMode: compareMode }, `node-${level}-${i}`));
33
- }) }));
34
- });
35
- const icicleRectStyles = {
36
- cursor: 'pointer',
37
- transition: 'opacity .15s linear',
38
- };
39
- const fadedIcicleRectStyles = {
40
- cursor: 'pointer',
41
- transition: 'opacity .15s linear',
42
- opacity: '0.5',
43
- };
44
- export const IcicleNode = React.memo(function IcicleNodeNoMemo({ x, y, height, setCurPath, curPath, level, path, data, strings, mappings, locations, functions, total, totalWidth, xScale, isRoot = false, searchString, compareMode, }) {
45
- const binaries = useAppSelector(selectBinaries);
46
- const dispatch = useAppDispatch();
47
- const { isShiftDown } = useKeyDown();
48
- const colorResult = useNodeColor({ data, compareMode });
49
- const name = useMemo(() => {
50
- return isRoot
51
- ? 'root'
52
- : nodeLabel(data, strings, mappings, locations, functions, binaries.length > 1);
53
- }, [data, strings, mappings, locations, functions, isRoot, binaries]);
54
- const nextPath = path.concat([name]);
55
- const isFaded = curPath.length > 0 && name !== curPath[curPath.length - 1];
56
- const styles = isFaded ? fadedIcicleRectStyles : icicleRectStyles;
57
- const nextLevel = level + 1;
58
- const cumulative = data.cumulative;
59
- const nextCurPath = curPath.length === 0 ? [] : curPath.slice(1);
60
- const newXScale = nextCurPath.length === 0 && curPath.length === 1
61
- ? scaleLinear([0n, cumulative], [0, totalWidth])
62
- : xScale;
63
- const width = nextCurPath.length > 0 || (nextCurPath.length === 0 && curPath.length === 1)
64
- ? totalWidth
65
- : xScale(cumulative);
66
- const { isHighlightEnabled = false, isHighlighted = false } = useMemo(() => {
67
- if (searchString === undefined || searchString === '') {
68
- return { isHighlightEnabled: false };
69
- }
70
- return { isHighlightEnabled: true, isHighlighted: isSearchMatch(searchString, name) };
71
- }, [searchString, name]);
72
- if (width <= 1) {
73
- return _jsx(_Fragment, { children: null });
74
- }
75
- const onMouseEnter = () => {
76
- if (isShiftDown)
77
- return;
78
- // need to add id and flat for tooltip purposes
79
- dispatch(setHoveringNode({ ...data, id: '', flat: 0n }));
80
- };
81
- const onMouseLeave = () => {
82
- if (isShiftDown)
83
- return;
84
- dispatch(setHoveringNode(undefined));
85
- };
86
- return (_jsxs(_Fragment, { children: [_jsxs("g", { transform: `translate(${x + 1}, ${y + 1})`, style: styles, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onClick: () => {
87
- setCurPath(nextPath);
88
- }, children: [_jsx("rect", { x: 0, y: 0, width: width, height: height, style: {
89
- fill: colorResult,
90
- }, className: cx('stroke-white dark:stroke-gray-700', {
91
- 'opacity-50': isHighlightEnabled && !isHighlighted,
92
- }) }), width > 5 && (_jsx("svg", { width: width - 5, height: height, children: _jsx("text", { x: 5, y: 15, style: { fontSize: '12px' }, children: name }) }))] }), data.children !== undefined && data.children.length > 0 && (_jsx(IcicleGraphNodes, { data: data.children, strings: strings, mappings: mappings, locations: locations, functions: functions, x: x, y: RowHeight, xScale: newXScale, total: total, totalWidth: totalWidth, level: nextLevel, path: nextPath, curPath: nextCurPath, setCurPath: setCurPath, searchString: searchString, compareMode: compareMode }))] }));
93
- });
@@ -1,14 +0,0 @@
1
- import { Flamegraph } from '@parca/client';
2
- import { ProfileType } from '@parca/parser';
3
- interface IcicleGraphProps {
4
- graph: Flamegraph;
5
- total: bigint;
6
- filtered: bigint;
7
- profileType?: ProfileType;
8
- width?: number;
9
- curPath: string[];
10
- setCurPath: (path: string[]) => void;
11
- }
12
- export declare const IcicleGraph: import("react").NamedExoticComponent<IcicleGraphProps>;
13
- export default IcicleGraph;
14
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/IcicleGraph/index.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAU1C,UAAU,gBAAgB;IACxB,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,WAAW,wDAmFtB,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -1,48 +0,0 @@
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 { memo, useEffect, useMemo, useRef, useState } from 'react';
15
- import { useURLState } from '@parca/components';
16
- import { setHoveringNode, useAppDispatch } from '@parca/store';
17
- import { scaleLinear, selectQueryParam } from '@parca/utilities';
18
- import GraphTooltip from '../../GraphTooltip';
19
- import { useProfileViewContext } from '../../ProfileView/context/ProfileViewContext';
20
- import ColorStackLegend from './ColorStackLegend';
21
- import { IcicleNode, RowHeight } from './IcicleGraphNodes';
22
- import useColoredGraph from './useColoredGraph';
23
- export const IcicleGraph = memo(function IcicleGraph({ graph, total, filtered, width, setCurPath, curPath, profileType, }) {
24
- const dispatch = useAppDispatch();
25
- const [height, setHeight] = useState(0);
26
- const svg = useRef(null);
27
- const ref = useRef(null);
28
- const coloredGraph = useColoredGraph(graph);
29
- const [currentSearchString] = useURLState('search_string');
30
- const { compareMode } = useProfileViewContext();
31
- const isColorStackLegendEnabled = selectQueryParam('color_stack_legend') === 'true';
32
- useEffect(() => {
33
- if (ref.current != null) {
34
- setHeight(ref?.current.getBoundingClientRect().height);
35
- }
36
- }, [width, coloredGraph]);
37
- const xScale = useMemo(() => {
38
- if (width === undefined) {
39
- return scaleLinear([0n, total], [0, 1]);
40
- }
41
- return scaleLinear([0n, total], [0, width]);
42
- }, [total, width]);
43
- if (coloredGraph.root === undefined || width === undefined) {
44
- return _jsx(_Fragment, {});
45
- }
46
- return (_jsxs("div", { onMouseLeave: () => dispatch(setHoveringNode(undefined)), children: [isColorStackLegendEnabled && _jsx(ColorStackLegend, { compareMode: compareMode }), _jsx(GraphTooltip, { unit: profileType?.sampleUnit ?? '', total: total, totalUnfiltered: total + filtered, contextElement: svg.current, strings: coloredGraph.stringTable, mappings: coloredGraph.mapping, locations: coloredGraph.locations, functions: coloredGraph.function }), _jsx("svg", { className: "font-robotoMono", width: width, height: height, preserveAspectRatio: "xMinYMid", ref: svg, children: _jsx("g", { ref: ref, children: _jsx("g", { transform: 'translate(0, 0)', children: _jsx(IcicleNode, { x: 0, y: 0, totalWidth: width, height: RowHeight, setCurPath: setCurPath, curPath: curPath, data: coloredGraph.root, strings: coloredGraph.stringTable, mappings: coloredGraph.mapping, locations: coloredGraph.locations, functions: coloredGraph.function, total: total, xScale: xScale, path: [], level: 0, isRoot: true, searchString: currentSearchString, compareMode: compareMode }) }) }) })] }));
47
- });
48
- export default IcicleGraph;
@@ -1,15 +0,0 @@
1
- import { Flamegraph, FlamegraphNode, FlamegraphRootNode } from '@parca/client';
2
- export interface ColoredFlamegraphNode extends FlamegraphNode {
3
- feature?: string;
4
- children: ColoredFlamegraphNode[];
5
- }
6
- export interface ColoredFlamgraphRootNode extends FlamegraphRootNode {
7
- feature?: string;
8
- children: ColoredFlamegraphNode[];
9
- }
10
- export interface ColoredFlamegraph extends Flamegraph {
11
- root: ColoredFlamgraphRootNode;
12
- }
13
- declare const useColoredGraph: (graph: Flamegraph) => ColoredFlamegraph;
14
- export default useColoredGraph;
15
- //# sourceMappingURL=useColoredGraph.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useColoredGraph.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/IcicleGraph/useColoredGraph.ts"],"names":[],"mappings":"AAeA,OAAO,EAAC,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAmB7E,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,qBAAqB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,qBAAqB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,IAAI,EAAE,wBAAwB,CAAC;CAChC;AAkCD,QAAA,MAAM,eAAe,UAAW,UAAU,KAAG,iBAkC5C,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,57 +0,0 @@
1
- // Copyright 2022 The Parca Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- import { useEffect, useMemo } from 'react';
14
- import { USER_PREFERENCES, useUserPreference } from '@parca/hooks';
15
- import { selectDarkMode, setFeatures, useAppDispatch, useAppSelector, } from '@parca/store';
16
- import { extractFeature } from './utils';
17
- const colorNodes = (nodes, strings, mappings, locations, functions, features) => {
18
- if (nodes === undefined) {
19
- return [];
20
- }
21
- return nodes.map(node => {
22
- const coloredNode = {
23
- ...node,
24
- };
25
- if (node.children != null) {
26
- coloredNode.children = colorNodes(node.children, strings, mappings, locations, functions, features);
27
- }
28
- const feature = extractFeature(node, mappings, locations, strings);
29
- coloredNode.feature = feature.name;
30
- features[feature.name] = feature.type;
31
- return coloredNode;
32
- });
33
- };
34
- const useColoredGraph = (graph) => {
35
- const dispatch = useAppDispatch();
36
- const [colorProfile] = useUserPreference(USER_PREFERENCES.FLAMEGRAPH_COLOR_PROFILE.key);
37
- const isDarkMode = useAppSelector(selectDarkMode);
38
- const [coloredGraph, features] = useMemo(() => {
39
- if (graph.root == null) {
40
- return [graph, {}];
41
- }
42
- const features = {};
43
- const coloredGraph = {
44
- ...graph,
45
- root: {
46
- ...graph.root,
47
- children: colorNodes(graph.root.children ?? [], graph.stringTable, graph.mapping, graph.locations, graph.function, features),
48
- },
49
- };
50
- return [coloredGraph, features];
51
- }, [graph]);
52
- useEffect(() => {
53
- dispatch(setFeatures({ features, colorProfileName: colorProfile, isDarkMode }));
54
- }, [features, colorProfile, dispatch, isDarkMode]);
55
- return coloredGraph;
56
- };
57
- export default useColoredGraph;