@parca/profile 0.19.140 → 0.19.143

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 (182) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/GraphTooltipArrow/Content.js +224 -30
  3. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
  4. package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
  5. package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
  6. package/dist/GraphTooltipArrow/index.js +86 -56
  7. package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
  8. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +94 -68
  9. package/dist/MatchersInput/SuggestionItem.js +91 -12
  10. package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
  11. package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
  12. package/dist/MatchersInput/SuggestionsList.js +371 -157
  13. package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
  14. package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
  15. package/dist/MatchersInput/index.js +308 -115
  16. package/dist/MetricsCircle/index.js +39 -3
  17. package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
  18. package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
  19. package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
  20. package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
  21. package/dist/MetricsGraph/index.js +552 -203
  22. package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
  23. package/dist/MetricsGraph/utils/colorMapping.js +24 -17
  24. package/dist/MetricsSeries/index.js +70 -7
  25. package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
  26. package/dist/PreSelectedMatchers/index.js +249 -102
  27. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
  28. package/dist/ProfileExplorer/ProfileExplorerCompare.js +240 -45
  29. package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
  30. package/dist/ProfileExplorer/index.js +183 -32
  31. package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
  32. package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
  33. package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
  34. package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
  35. package/dist/ProfileFlameChart/index.js +260 -126
  36. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +283 -85
  37. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
  38. package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
  39. package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
  40. package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
  41. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  42. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +71 -45
  43. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
  44. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
  45. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
  46. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
  47. package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
  48. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
  49. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
  50. package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
  51. package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
  52. package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
  53. package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
  54. package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
  55. package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
  56. package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
  57. package/dist/ProfileFlameGraph/index.js +322 -147
  58. package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
  59. package/dist/ProfileMetricsGraph/index.js +515 -256
  60. package/dist/ProfileSelector/CompareButton.js +132 -12
  61. package/dist/ProfileSelector/MetricsGraphSection.js +228 -63
  62. package/dist/ProfileSelector/index.d.ts +1 -1
  63. package/dist/ProfileSelector/index.d.ts.map +1 -1
  64. package/dist/ProfileSelector/index.js +734 -142
  65. package/dist/ProfileSelector/useAutoQuerySelector.d.ts +1 -3
  66. package/dist/ProfileSelector/useAutoQuerySelector.d.ts.map +1 -1
  67. package/dist/ProfileSelector/useAutoQuerySelector.js +280 -132
  68. package/dist/ProfileSource.js +230 -163
  69. package/dist/ProfileTypeSelector/index.js +214 -125
  70. package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
  71. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +137 -32
  72. package/dist/ProfileView/components/ColorStackLegend.js +182 -54
  73. package/dist/ProfileView/components/DashboardItems/index.js +87 -28
  74. package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
  75. package/dist/ProfileView/components/DiffLegend.js +172 -29
  76. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
  77. package/dist/ProfileView/components/InvertCallStack/index.js +97 -9
  78. package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
  79. package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
  80. package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
  81. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +191 -118
  82. package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
  83. package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
  84. package/dist/ProfileView/components/ShareButton/index.js +352 -62
  85. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  86. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +664 -192
  87. package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
  88. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +196 -155
  89. package/dist/ProfileView/components/Toolbars/index.js +441 -21
  90. package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
  91. package/dist/ProfileView/components/ViewSelector/index.js +186 -82
  92. package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
  93. package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
  94. package/dist/ProfileView/components/VisualizationPanel.js +185 -8
  95. package/dist/ProfileView/context/DashboardContext.js +74 -26
  96. package/dist/ProfileView/context/ProfileViewContext.js +56 -15
  97. package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
  98. package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
  99. package/dist/ProfileView/hooks/useResetFlameGraphState.js +31 -10
  100. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
  101. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +53 -17
  102. package/dist/ProfileView/hooks/useVisualizationState.js +229 -69
  103. package/dist/ProfileView/index.js +383 -45
  104. package/dist/ProfileView/types/visualization.js +1 -13
  105. package/dist/ProfileView/utils/colorUtils.js +8 -7
  106. package/dist/ProfileViewWithData.js +319 -225
  107. package/dist/QueryControls/index.js +418 -47
  108. package/dist/Sandwich/components/CalleesSection.js +54 -4
  109. package/dist/Sandwich/components/CallersSection.js +97 -27
  110. package/dist/Sandwich/components/TableSection.js +77 -4
  111. package/dist/Sandwich/index.js +125 -12
  112. package/dist/Sandwich/utils/processRowData.js +48 -39
  113. package/dist/SelectWithRefresh/index.js +102 -28
  114. package/dist/SimpleMatchers/Select.js +520 -187
  115. package/dist/SimpleMatchers/index.js +590 -288
  116. package/dist/SourceView/Highlighter.js +230 -70
  117. package/dist/SourceView/LineNo.js +72 -17
  118. package/dist/SourceView/index.js +177 -101
  119. package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
  120. package/dist/SourceView/lang-detector/index.js +28 -14
  121. package/dist/SourceView/useSelectedLineRange.js +72 -20
  122. package/dist/Table/ColorCell.js +42 -1
  123. package/dist/Table/ColumnsVisibility.js +114 -6
  124. package/dist/Table/MoreDropdown.js +107 -21
  125. package/dist/Table/TableContextMenu.js +144 -134
  126. package/dist/Table/TableContextMenuWrapper.js +59 -14
  127. package/dist/Table/hooks/useColorManagement.js +58 -16
  128. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  129. package/dist/Table/hooks/useTableConfiguration.js +323 -167
  130. package/dist/Table/index.js +217 -123
  131. package/dist/Table/utils/functions.js +169 -144
  132. package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
  133. package/dist/TimelineGuide/index.js +209 -16
  134. package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
  135. package/dist/TopTable/index.js +325 -121
  136. package/dist/contexts/LabelsQueryProvider.js +94 -32
  137. package/dist/contexts/UnifiedLabelsContext.js +114 -49
  138. package/dist/contexts/utils.js +37 -15
  139. package/dist/hooks/urlParsers.js +27 -15
  140. package/dist/hooks/useColorBy.js +47 -10
  141. package/dist/hooks/useCompareModeMeta.js +112 -62
  142. package/dist/hooks/useDashboardItems.js +52 -11
  143. package/dist/hooks/useLabels.js +295 -52
  144. package/dist/hooks/useQueryState.d.ts +1 -1
  145. package/dist/hooks/useQueryState.d.ts.map +1 -1
  146. package/dist/hooks/useQueryState.js +375 -329
  147. package/dist/index.js +11 -6
  148. package/dist/testdata/fg-diff.json +3750 -0
  149. package/dist/testdata/fg-simple.json +1879 -0
  150. package/dist/testdata/link_data.json +56 -0
  151. package/dist/testdata/tabular.json +30 -0
  152. package/dist/testdata/test_flamegraph.json +26846 -0
  153. package/dist/testdata/test_graph.json +53 -0
  154. package/dist/useDelayedLoader.js +32 -18
  155. package/dist/useGrpcQuery/index.js +71 -11
  156. package/dist/useHasProfileData.js +90 -12
  157. package/dist/useQuery.js +205 -64
  158. package/dist/useSumBy.d.ts.map +1 -1
  159. package/dist/useSumBy.js +294 -138
  160. package/dist/utils.js +62 -30
  161. package/package.json +9 -9
  162. package/src/GraphTooltipArrow/index.tsx +3 -0
  163. package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
  164. package/src/MatchersInput/SuggestionsList.tsx +11 -10
  165. package/src/MatchersInput/index.tsx +1 -1
  166. package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
  167. package/src/PreSelectedMatchers/index.tsx +3 -0
  168. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -2
  169. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +3 -0
  170. package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
  171. package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
  172. package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
  173. package/src/ProfileSelector/index.tsx +31 -9
  174. package/src/ProfileSelector/useAutoQuerySelector.ts +64 -42
  175. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +3 -0
  176. package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
  177. package/src/Table/hooks/useTableConfiguration.tsx +7 -13
  178. package/src/hooks/useQueryState.ts +18 -3
  179. package/src/useDelayedLoader.ts +10 -10
  180. package/src/useSumBy.ts +12 -18
  181. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
  182. package/dist/hooks/useQueryState.test.js +0 -868
@@ -1,4 +1,10 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { c as _c } from "react-compiler-runtime";
2
8
  // Copyright 2022 The Parca Authors
3
9
  // Licensed under the Apache License, Version 2.0 (the "License");
4
10
  // you may not use this file except in compliance with the License.
@@ -11,133 +17,331 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
11
17
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
18
  // See the License for the specific language governing permissions and
13
19
  // limitations under the License.
20
+
14
21
  import React, { useCallback, useEffect, useMemo } from 'react';
15
22
  import { createColumnHelper } from '@tanstack/react-table';
16
23
  import { Button, Table } from '@parca/components';
17
- import { getLastItem, isSearchMatch, parseParams, valueFormatter, } from '@parca/utilities';
24
+ import { getLastItem, isSearchMatch, parseParams, valueFormatter } from '@parca/utilities';
18
25
  import { useProfileViewContext } from '../ProfileView/context/ProfileViewContext';
19
26
  import { useDashboardItems } from '../hooks/useDashboardItems';
20
27
  import { hexifyAddress } from '../utils';
21
- export const RowLabel = (meta) => {
22
- if (meta === undefined)
23
- return '<unknown>';
24
- const mapping = `${meta?.mapping?.file !== undefined && meta?.mapping?.file !== ''
25
- ? `[${getLastItem(meta.mapping.file) ?? ''}]`
26
- : ''}`;
27
- if (meta.function?.name !== undefined && meta.function?.name !== '')
28
- return `${mapping} ${meta.function.name}`;
29
- const address = hexifyAddress(meta.location?.address);
30
- const fallback = `${mapping} ${address}`;
31
- return fallback === '' ? '<unknown>' : fallback;
28
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
29
+ export var RowLabel = function RowLabel(meta) {
30
+ var _meta$mapping, _meta$mapping2, _getLastItem, _meta$function, _meta$function2, _meta$location;
31
+ if (meta === undefined) return '<unknown>';
32
+ var mapping = "".concat((meta === null || meta === void 0 || (_meta$mapping = meta.mapping) === null || _meta$mapping === void 0 ? void 0 : _meta$mapping.file) !== undefined && (meta === null || meta === void 0 || (_meta$mapping2 = meta.mapping) === null || _meta$mapping2 === void 0 ? void 0 : _meta$mapping2.file) !== '' ? "[".concat((_getLastItem = getLastItem(meta.mapping.file)) !== null && _getLastItem !== void 0 ? _getLastItem : '', "]") : '');
33
+ if (((_meta$function = meta["function"]) === null || _meta$function === void 0 ? void 0 : _meta$function.name) !== undefined && ((_meta$function2 = meta["function"]) === null || _meta$function2 === void 0 ? void 0 : _meta$function2.name) !== '') return "".concat(mapping, " ").concat(meta["function"].name);
34
+ var address = hexifyAddress((_meta$location = meta.location) === null || _meta$location === void 0 ? void 0 : _meta$location.address);
35
+ var fallback = "".concat(mapping, " ").concat(address);
36
+ return fallback === '' ? '<unknown>' : fallback;
32
37
  };
33
- const columnHelper = createColumnHelper();
34
- const addPlusSign = (num) => {
35
- if (num.charAt(0) === '0' || num.charAt(0) === '-') {
36
- return num;
37
- }
38
- return `+${num}`;
38
+ var columnHelper = createColumnHelper();
39
+ var addPlusSign = function addPlusSign(num) {
40
+ if (num.charAt(0) === '0' || num.charAt(0) === '-') {
41
+ return num;
42
+ }
43
+ return "+".concat(num);
39
44
  };
40
- export const TopTable = React.memo(function TopTable({ data: top, sampleUnit: unit, navigateTo, loading, currentSearchString, setActionButtons, }) {
41
- const router = parseParams(window?.location.search);
42
- const { dashboardItems } = useDashboardItems();
43
- const { compareMode } = useProfileViewContext();
44
- const columns = useMemo(() => {
45
- const cols = [
46
- columnHelper.accessor('meta', {
47
- header: () => _jsx("span", { className: "text-left", children: "Name" }),
48
- cell: info => {
49
- const meta = info.row.original.meta;
50
- const name = RowLabel(meta);
51
- return name;
52
- },
53
- sortingFn: (a, b) => {
54
- const aName = RowLabel(a.original.meta);
55
- const bName = RowLabel(b.original.meta);
56
- return aName.localeCompare(bName);
57
- },
58
- }),
59
- columnHelper.accessor('flat', {
60
- header: () => 'Flat',
61
- cell: info => valueFormatter(info.getValue(), unit, 2),
62
- size: 150,
63
- meta: {
64
- align: 'right',
65
- },
66
- sortDescFirst: true,
67
- }),
68
- columnHelper.accessor('cumulative', {
69
- header: () => 'Cumulative',
70
- cell: info => valueFormatter(info.getValue(), unit, 2),
71
- size: 150,
72
- meta: {
73
- align: 'right',
74
- },
75
- sortDescFirst: true,
76
- }),
77
- ];
78
- if (compareMode) {
79
- cols.push(columnHelper.accessor('diff', {
80
- header: () => 'Diff',
81
- cell: info => addPlusSign(valueFormatter(info.getValue(), unit, 2)),
82
- size: 150,
83
- meta: {
84
- align: 'right',
85
- },
86
- sortDescFirst: true,
87
- }));
88
- }
89
- return cols;
90
- }, [unit, compareMode]);
91
- const selectSpan = useCallback((span) => {
92
- if (navigateTo != null) {
93
- navigateTo('/', {
94
- ...router,
95
- ...{ search_string: span.trim() },
96
- }, { replace: true });
97
- }
98
- }, [navigateTo, router]);
99
- const onRowClick = useCallback((row) => {
100
- // If there is only one dashboard item, we don't want to select a span
101
- if (dashboardItems.length <= 1) {
102
- return;
103
- }
104
- const meta = row.meta;
105
- if (meta === undefined) {
106
- return;
107
- }
108
- const name = RowLabel(meta);
109
- selectSpan(name);
110
- }, [selectSpan, dashboardItems.length]);
111
- const shouldHighlightRow = useCallback((row) => {
112
- const meta = row.meta;
113
- if (meta === undefined)
114
- return false;
115
- const name = RowLabel(meta);
116
- return isSearchMatch(currentSearchString, name);
117
- }, [currentSearchString]);
118
- const enableHighlighting = useMemo(() => {
119
- return currentSearchString != null && currentSearchString?.length > 0;
120
- }, [currentSearchString]);
121
- const clearSelection = useCallback(() => {
122
- if (navigateTo != null) {
123
- navigateTo('/', {
124
- ...router,
125
- ...{ search_string: '' },
126
- }, { replace: true });
127
- }
128
- }, [navigateTo, router]);
129
- useEffect(() => {
130
- if (setActionButtons === undefined) {
131
- return;
132
- }
133
- setActionButtons(dashboardItems.length > 1 ? (_jsx("div", { className: "ml-2", children: _jsx(Button, { color: "neutral", onClick: clearSelection, className: "w-auto", variant: "neutral", disabled: currentSearchString === undefined || currentSearchString.length === 0, children: "Clear selection" }) })) : (_jsx(_Fragment, {})));
134
- }, [dashboardItems, clearSelection, currentSearchString, setActionButtons]);
135
- const initialSorting = useMemo(() => {
136
- return [{ id: compareMode ? 'diff' : 'cumulative', desc: true }];
137
- }, [compareMode]);
138
- const total = top != null ? top.list.length : 0;
139
- if (total === 0 && !loading)
140
- return _jsx("div", { className: "mx-auto text-center", children: "Profile has no samples" });
141
- return (_jsx("div", { className: "relative", children: _jsx("div", { className: "font-robotoMono h-[80vh] w-full overflow-scroll", children: _jsx(Table, { data: top?.list ?? [], columns: columns, initialSorting: initialSorting, onRowClick: onRowClick, enableHighlighting: enableHighlighting, shouldHighlightRow: shouldHighlightRow, usePointerCursor: dashboardItems.length > 1 }) }) }));
45
+ export var TopTable = /*#__PURE__*/React.memo(function TopTable(t0) {
46
+ var $ = _c(45);
47
+ var top = t0.data,
48
+ unit = t0.sampleUnit,
49
+ navigateTo = t0.navigateTo,
50
+ loading = t0.loading,
51
+ currentSearchString = t0.currentSearchString,
52
+ setActionButtons = t0.setActionButtons;
53
+ var t1;
54
+ if ($[0] === Symbol["for"]("react.memo_cache_sentinel")) {
55
+ var _window;
56
+ t1 = parseParams((_window = window) === null || _window === void 0 ? void 0 : _window.location.search);
57
+ $[0] = t1;
58
+ } else {
59
+ t1 = $[0];
60
+ }
61
+ var router = t1;
62
+ var _useDashboardItems = useDashboardItems(),
63
+ dashboardItems = _useDashboardItems.dashboardItems;
64
+ var _useProfileViewContex = useProfileViewContext(),
65
+ compareMode = _useProfileViewContex.compareMode;
66
+ var t2;
67
+ if ($[1] === Symbol["for"]("react.memo_cache_sentinel")) {
68
+ t2 = columnHelper.accessor("meta", {
69
+ header: _temp,
70
+ cell: _temp2,
71
+ sortingFn: _temp3
72
+ });
73
+ $[1] = t2;
74
+ } else {
75
+ t2 = $[1];
76
+ }
77
+ var t3;
78
+ if ($[2] !== unit) {
79
+ t3 = columnHelper.accessor("flat", {
80
+ header: _temp4,
81
+ cell: function cell(info_0) {
82
+ return valueFormatter(info_0.getValue(), unit, 2);
83
+ },
84
+ size: 150,
85
+ meta: {
86
+ align: "right"
87
+ },
88
+ sortDescFirst: true
89
+ });
90
+ $[2] = unit;
91
+ $[3] = t3;
92
+ } else {
93
+ t3 = $[3];
94
+ }
95
+ var t4;
96
+ if ($[4] !== unit) {
97
+ t4 = columnHelper.accessor("cumulative", {
98
+ header: _temp5,
99
+ cell: function cell(info_1) {
100
+ return valueFormatter(info_1.getValue(), unit, 2);
101
+ },
102
+ size: 150,
103
+ meta: {
104
+ align: "right"
105
+ },
106
+ sortDescFirst: true
107
+ });
108
+ $[4] = unit;
109
+ $[5] = t4;
110
+ } else {
111
+ t4 = $[5];
112
+ }
113
+ var cols;
114
+ if ($[6] !== compareMode || $[7] !== t3 || $[8] !== t4 || $[9] !== unit) {
115
+ cols = [t2, t3, t4];
116
+ if (compareMode) {
117
+ var _t;
118
+ if ($[11] !== unit) {
119
+ _t = columnHelper.accessor("diff", {
120
+ header: _temp6,
121
+ cell: function cell(info_2) {
122
+ return addPlusSign(valueFormatter(info_2.getValue(), unit, 2));
123
+ },
124
+ size: 150,
125
+ meta: {
126
+ align: "right"
127
+ },
128
+ sortDescFirst: true
129
+ });
130
+ $[11] = unit;
131
+ $[12] = _t;
132
+ } else {
133
+ _t = $[12];
134
+ }
135
+ cols.push(_t);
136
+ }
137
+ $[6] = compareMode;
138
+ $[7] = t3;
139
+ $[8] = t4;
140
+ $[9] = unit;
141
+ $[10] = cols;
142
+ } else {
143
+ cols = $[10];
144
+ }
145
+ var columns = cols;
146
+ var t5;
147
+ if ($[13] !== navigateTo) {
148
+ t5 = function t5(span) {
149
+ if (navigateTo != null) {
150
+ navigateTo("/", _objectSpread(_objectSpread({}, router), {
151
+ search_string: span.trim()
152
+ }), {
153
+ replace: true
154
+ });
155
+ }
156
+ };
157
+ $[13] = navigateTo;
158
+ $[14] = t5;
159
+ } else {
160
+ t5 = $[14];
161
+ }
162
+ var selectSpan = t5;
163
+ var t6;
164
+ if ($[15] !== dashboardItems.length || $[16] !== selectSpan) {
165
+ t6 = function t6(row) {
166
+ if (dashboardItems.length <= 1) {
167
+ return;
168
+ }
169
+ var meta_0 = row.meta;
170
+ if (meta_0 === undefined) {
171
+ return;
172
+ }
173
+ var name_0 = RowLabel(meta_0);
174
+ selectSpan(name_0);
175
+ };
176
+ $[15] = dashboardItems.length;
177
+ $[16] = selectSpan;
178
+ $[17] = t6;
179
+ } else {
180
+ t6 = $[17];
181
+ }
182
+ var onRowClick = t6;
183
+ var t7;
184
+ if ($[18] !== currentSearchString) {
185
+ t7 = function t7(row_0) {
186
+ var meta_1 = row_0.meta;
187
+ if (meta_1 === undefined) {
188
+ return false;
189
+ }
190
+ var name_1 = RowLabel(meta_1);
191
+ return isSearchMatch(currentSearchString, name_1);
192
+ };
193
+ $[18] = currentSearchString;
194
+ $[19] = t7;
195
+ } else {
196
+ t7 = $[19];
197
+ }
198
+ var shouldHighlightRow = t7;
199
+ var enableHighlighting = currentSearchString != null && (currentSearchString === null || currentSearchString === void 0 ? void 0 : currentSearchString.length) > 0;
200
+ var t8;
201
+ if ($[20] !== navigateTo) {
202
+ t8 = function t8() {
203
+ if (navigateTo != null) {
204
+ navigateTo("/", _objectSpread(_objectSpread({}, router), {
205
+ search_string: ""
206
+ }), {
207
+ replace: true
208
+ });
209
+ }
210
+ };
211
+ $[20] = navigateTo;
212
+ $[21] = t8;
213
+ } else {
214
+ t8 = $[21];
215
+ }
216
+ var clearSelection = t8;
217
+ var t9;
218
+ if ($[22] !== clearSelection || $[23] !== currentSearchString || $[24] !== dashboardItems.length || $[25] !== setActionButtons) {
219
+ t9 = function t9() {
220
+ if (setActionButtons === undefined) {
221
+ return;
222
+ }
223
+ setActionButtons(dashboardItems.length > 1 ? /*#__PURE__*/_jsx("div", {
224
+ className: "ml-2",
225
+ children: /*#__PURE__*/_jsx(Button, {
226
+ color: "neutral",
227
+ onClick: clearSelection,
228
+ className: "w-auto",
229
+ variant: "neutral",
230
+ disabled: currentSearchString === undefined || currentSearchString.length === 0,
231
+ children: "Clear selection"
232
+ })
233
+ }) : /*#__PURE__*/_jsx(_Fragment, {}));
234
+ };
235
+ $[22] = clearSelection;
236
+ $[23] = currentSearchString;
237
+ $[24] = dashboardItems.length;
238
+ $[25] = setActionButtons;
239
+ $[26] = t9;
240
+ } else {
241
+ t9 = $[26];
242
+ }
243
+ var t10;
244
+ if ($[27] !== clearSelection || $[28] !== currentSearchString || $[29] !== dashboardItems || $[30] !== setActionButtons) {
245
+ t10 = [dashboardItems, clearSelection, currentSearchString, setActionButtons];
246
+ $[27] = clearSelection;
247
+ $[28] = currentSearchString;
248
+ $[29] = dashboardItems;
249
+ $[30] = setActionButtons;
250
+ $[31] = t10;
251
+ } else {
252
+ t10 = $[31];
253
+ }
254
+ useEffect(t9, t10);
255
+ var t11 = compareMode ? "diff" : "cumulative";
256
+ var t12;
257
+ if ($[32] !== t11) {
258
+ t12 = [{
259
+ id: t11,
260
+ desc: true
261
+ }];
262
+ $[32] = t11;
263
+ $[33] = t12;
264
+ } else {
265
+ t12 = $[33];
266
+ }
267
+ var initialSorting = t12;
268
+ var total = top != null ? top.list.length : 0;
269
+ if (total === 0 && !loading) {
270
+ var _t2;
271
+ if ($[34] === Symbol["for"]("react.memo_cache_sentinel")) {
272
+ _t2 = /*#__PURE__*/_jsx("div", {
273
+ className: "mx-auto text-center",
274
+ children: "Profile has no samples"
275
+ });
276
+ $[34] = _t2;
277
+ } else {
278
+ _t2 = $[34];
279
+ }
280
+ return _t2;
281
+ }
282
+ var t13;
283
+ if ($[35] !== (top === null || top === void 0 ? void 0 : top.list)) {
284
+ var _top$list;
285
+ t13 = (_top$list = top === null || top === void 0 ? void 0 : top.list) !== null && _top$list !== void 0 ? _top$list : [];
286
+ $[35] = top === null || top === void 0 ? void 0 : top.list;
287
+ $[36] = t13;
288
+ } else {
289
+ t13 = $[36];
290
+ }
291
+ var t14 = dashboardItems.length > 1;
292
+ var t15;
293
+ if ($[37] !== columns || $[38] !== enableHighlighting || $[39] !== initialSorting || $[40] !== onRowClick || $[41] !== shouldHighlightRow || $[42] !== t13 || $[43] !== t14) {
294
+ t15 = /*#__PURE__*/_jsx("div", {
295
+ className: "relative",
296
+ children: /*#__PURE__*/_jsx("div", {
297
+ className: "font-robotoMono h-[80vh] w-full overflow-scroll",
298
+ children: /*#__PURE__*/_jsx(Table, {
299
+ data: t13,
300
+ columns: columns,
301
+ initialSorting: initialSorting,
302
+ onRowClick: onRowClick,
303
+ enableHighlighting: enableHighlighting,
304
+ shouldHighlightRow: shouldHighlightRow,
305
+ usePointerCursor: t14
306
+ })
307
+ })
308
+ });
309
+ $[37] = columns;
310
+ $[38] = enableHighlighting;
311
+ $[39] = initialSorting;
312
+ $[40] = onRowClick;
313
+ $[41] = shouldHighlightRow;
314
+ $[42] = t13;
315
+ $[43] = t14;
316
+ $[44] = t15;
317
+ } else {
318
+ t15 = $[44];
319
+ }
320
+ return t15;
142
321
  });
143
322
  export default TopTable;
323
+ function _temp() {
324
+ return /*#__PURE__*/_jsx("span", {
325
+ className: "text-left",
326
+ children: "Name"
327
+ });
328
+ }
329
+ function _temp2(info) {
330
+ var meta = info.row.original.meta;
331
+ var name = RowLabel(meta);
332
+ return name;
333
+ }
334
+ function _temp3(a, b) {
335
+ var aName = RowLabel(a.original.meta);
336
+ var bName = RowLabel(b.original.meta);
337
+ return aName.localeCompare(bName);
338
+ }
339
+ function _temp4() {
340
+ return "Flat";
341
+ }
342
+ function _temp5() {
343
+ return "Cumulative";
344
+ }
345
+ function _temp6() {
346
+ return "Diff";
347
+ }
@@ -1,4 +1,10 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ import { c as _c } from "react-compiler-runtime";
2
8
  // Copyright 2022 The Parca Authors
3
9
  // Licensed under the Apache License, Version 2.0 (the "License");
4
10
  // you may not use this file except in compliance with the License.
@@ -11,6 +17,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
11
17
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
18
  // See the License for the specific language governing permissions and
13
19
  // limitations under the License.
20
+
14
21
  /**
15
22
  * LabelsQueryProvider - Data Fetching Layer
16
23
  *
@@ -31,40 +38,95 @@ import { jsx as _jsx } from "react/jsx-runtime";
31
38
  *
32
39
  * Consumer Hook: useLabelsQueryProvider()
33
40
  */
41
+
34
42
  import { createContext, useContext, useState } from 'react';
35
43
  import { useLabelNames, useLabelValues } from '../hooks/useLabels';
36
44
  import { useExtractedLabelNames } from './utils';
37
- const LabelsQueryProviderContext = createContext(null);
38
- export function LabelsQueryProvider({ children, queryClient, setMatchersString, runQuery, currentQuery, profileType, start, end, suffix, }) {
39
- const [currentLabelName, setCurrentLabelName] = useState(null);
40
- const { result: labelNamesResponse, loading: isLabelNamesLoading, refetch: labelNamesRefetch, } = useLabelNames(queryClient, profileType, start, end);
41
- const labelNames = useExtractedLabelNames(labelNamesResponse.response, labelNamesResponse.error);
42
- const { result: labelValuesOriginal, loading: isLabelValuesLoading, refetch: labelValuesRefetch, } = useLabelValues(queryClient, currentLabelName ?? '', profileType, start, end);
43
- const labelValues = labelValuesOriginal.response;
44
- const value = {
45
- labelNames,
46
- labelValues,
47
- isLabelNamesLoading,
48
- isLabelValuesLoading,
49
- refetchLabelValues: labelValuesRefetch,
50
- refetchLabelNames: labelNamesRefetch,
51
- queryClient,
52
- setMatchersString,
53
- runQuery,
54
- currentQuery,
55
- profileType,
56
- start,
57
- end,
58
- setCurrentLabelName,
59
- currentLabelName,
60
- suffix,
45
+ import { jsx as _jsx } from "react/jsx-runtime";
46
+ var LabelsQueryProviderContext = /*#__PURE__*/createContext(null);
47
+ export function LabelsQueryProvider(t0) {
48
+ var $ = _c(19);
49
+ var children = t0.children,
50
+ queryClient = t0.queryClient,
51
+ setMatchersString = t0.setMatchersString,
52
+ runQuery = t0.runQuery,
53
+ currentQuery = t0.currentQuery,
54
+ profileType = t0.profileType,
55
+ start = t0.start,
56
+ end = t0.end,
57
+ suffix = t0.suffix;
58
+ var _useState = useState(null),
59
+ _useState2 = _slicedToArray(_useState, 2),
60
+ currentLabelName = _useState2[0],
61
+ setCurrentLabelName = _useState2[1];
62
+ var _useLabelNames = useLabelNames(queryClient, profileType, start, end),
63
+ labelNamesResponse = _useLabelNames.result,
64
+ isLabelNamesLoading = _useLabelNames.loading,
65
+ labelNamesRefetch = _useLabelNames.refetch;
66
+ var labelNames = useExtractedLabelNames(labelNamesResponse.response, labelNamesResponse.error);
67
+ var _useLabelValues = useLabelValues(queryClient, currentLabelName !== null && currentLabelName !== void 0 ? currentLabelName : "", profileType, start, end),
68
+ labelValuesOriginal = _useLabelValues.result,
69
+ isLabelValuesLoading = _useLabelValues.loading,
70
+ labelValuesRefetch = _useLabelValues.refetch;
71
+ var labelValues = labelValuesOriginal.response;
72
+ var t1;
73
+ if ($[0] !== currentLabelName || $[1] !== currentQuery || $[2] !== end || $[3] !== isLabelNamesLoading || $[4] !== isLabelValuesLoading || $[5] !== labelNames || $[6] !== labelNamesRefetch || $[7] !== labelValues || $[8] !== labelValuesRefetch || $[9] !== profileType || $[10] !== queryClient || $[11] !== runQuery || $[12] !== setMatchersString || $[13] !== start || $[14] !== suffix) {
74
+ t1 = {
75
+ labelNames: labelNames,
76
+ labelValues: labelValues,
77
+ isLabelNamesLoading: isLabelNamesLoading,
78
+ isLabelValuesLoading: isLabelValuesLoading,
79
+ refetchLabelValues: labelValuesRefetch,
80
+ refetchLabelNames: labelNamesRefetch,
81
+ queryClient: queryClient,
82
+ setMatchersString: setMatchersString,
83
+ runQuery: runQuery,
84
+ currentQuery: currentQuery,
85
+ profileType: profileType,
86
+ start: start,
87
+ end: end,
88
+ setCurrentLabelName: setCurrentLabelName,
89
+ currentLabelName: currentLabelName,
90
+ suffix: suffix
61
91
  };
62
- return (_jsx(LabelsQueryProviderContext.Provider, { value: value, children: children }));
92
+ $[0] = currentLabelName;
93
+ $[1] = currentQuery;
94
+ $[2] = end;
95
+ $[3] = isLabelNamesLoading;
96
+ $[4] = isLabelValuesLoading;
97
+ $[5] = labelNames;
98
+ $[6] = labelNamesRefetch;
99
+ $[7] = labelValues;
100
+ $[8] = labelValuesRefetch;
101
+ $[9] = profileType;
102
+ $[10] = queryClient;
103
+ $[11] = runQuery;
104
+ $[12] = setMatchersString;
105
+ $[13] = start;
106
+ $[14] = suffix;
107
+ $[15] = t1;
108
+ } else {
109
+ t1 = $[15];
110
+ }
111
+ var value = t1;
112
+ var t2;
113
+ if ($[16] !== children || $[17] !== value) {
114
+ t2 = /*#__PURE__*/_jsx(LabelsQueryProviderContext.Provider, {
115
+ value: value,
116
+ children: children
117
+ });
118
+ $[16] = children;
119
+ $[17] = value;
120
+ $[18] = t2;
121
+ } else {
122
+ t2 = $[18];
123
+ }
124
+ return t2;
63
125
  }
64
126
  export function useLabelsQueryProvider() {
65
- const context = useContext(LabelsQueryProviderContext);
66
- if (context === null) {
67
- throw new Error('useLabelsQueryProvider must be used within a LabelsQueryProvider');
68
- }
69
- return context;
70
- }
127
+ var context = useContext(LabelsQueryProviderContext);
128
+ if (context === null) {
129
+ throw new Error("useLabelsQueryProvider must be used within a LabelsQueryProvider");
130
+ }
131
+ return context;
132
+ }