@parca/profile 0.19.140 → 0.19.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/dist/GraphTooltipArrow/Content.js +224 -30
- package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
- package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
- package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/index.js +86 -56
- package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +104 -72
- package/dist/MatchersInput/SuggestionItem.js +91 -12
- package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
- package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
- package/dist/MatchersInput/SuggestionsList.js +371 -157
- package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
- package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
- package/dist/MatchersInput/index.js +308 -115
- package/dist/MetricsCircle/index.js +39 -3
- package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
- package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
- package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
- package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
- package/dist/MetricsGraph/index.js +552 -203
- package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
- package/dist/MetricsGraph/utils/colorMapping.js +24 -17
- package/dist/MetricsSeries/index.js +70 -7
- package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
- package/dist/PreSelectedMatchers/index.js +249 -102
- package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
- package/dist/ProfileExplorer/ProfileExplorerCompare.js +241 -45
- package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
- package/dist/ProfileExplorer/index.js +183 -32
- package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
- package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
- package/dist/ProfileFlameChart/SamplesStrips/index.d.ts +2 -2
- package/dist/ProfileFlameChart/SamplesStrips/index.d.ts.map +1 -1
- package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
- package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
- package/dist/ProfileFlameChart/index.d.ts.map +1 -1
- package/dist/ProfileFlameChart/index.js +267 -129
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +288 -89
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
- package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
- package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +72 -47
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
- package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
- package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
- package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
- package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
- package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
- package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
- package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
- package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/index.js +324 -150
- package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
- package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
- package/dist/ProfileMetricsGraph/index.js +519 -258
- package/dist/ProfileSelector/CompareButton.js +132 -12
- package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
- package/dist/ProfileSelector/MetricsGraphSection.js +236 -64
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +727 -141
- package/dist/ProfileSelector/useAutoQuerySelector.js +249 -130
- package/dist/ProfileSource.js +230 -163
- package/dist/ProfileTypeSelector/index.js +214 -125
- package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +141 -35
- package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
- package/dist/ProfileView/components/ColorStackLegend.js +185 -55
- package/dist/ProfileView/components/DashboardItems/index.js +87 -28
- package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
- package/dist/ProfileView/components/DiffLegend.js +172 -29
- package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
- package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
- package/dist/ProfileView/components/InvertCallStack/index.js +100 -12
- package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
- package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
- package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +2 -1
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +188 -118
- package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
- package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
- package/dist/ProfileView/components/ShareButton/index.js +352 -62
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +678 -194
- package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +199 -157
- package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
- package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/index.js +441 -21
- package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
- package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
- package/dist/ProfileView/components/ViewSelector/index.js +212 -86
- package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
- package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
- package/dist/ProfileView/components/VisualizationPanel.js +185 -8
- package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
- package/dist/ProfileView/context/DashboardContext.js +85 -29
- package/dist/ProfileView/context/ProfileViewContext.js +56 -15
- package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
- package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
- package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetFlameGraphState.js +32 -12
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +40 -19
- package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
- package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useVisualizationState.js +258 -67
- package/dist/ProfileView/index.js +383 -45
- package/dist/ProfileView/types/visualization.js +1 -13
- package/dist/ProfileView/utils/colorUtils.js +8 -7
- package/dist/ProfileViewWithData.d.ts.map +1 -1
- package/dist/ProfileViewWithData.js +332 -228
- package/dist/QueryControls/index.js +418 -47
- package/dist/Sandwich/components/CalleesSection.js +54 -4
- package/dist/Sandwich/components/CallersSection.js +97 -27
- package/dist/Sandwich/components/TableSection.js +77 -4
- package/dist/Sandwich/index.d.ts.map +1 -1
- package/dist/Sandwich/index.js +126 -14
- package/dist/Sandwich/utils/processRowData.js +48 -39
- package/dist/SelectWithRefresh/index.js +102 -28
- package/dist/SimpleMatchers/Select.js +520 -187
- package/dist/SimpleMatchers/index.js +590 -288
- package/dist/SourceView/Highlighter.js +230 -70
- package/dist/SourceView/LineNo.js +72 -17
- package/dist/SourceView/index.d.ts.map +1 -1
- package/dist/SourceView/index.js +178 -104
- package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
- package/dist/SourceView/lang-detector/index.js +28 -14
- package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
- package/dist/SourceView/useSelectedLineRange.js +99 -23
- package/dist/Table/ColorCell.js +42 -1
- package/dist/Table/ColumnsVisibility.js +114 -6
- package/dist/Table/MoreDropdown.d.ts.map +1 -1
- package/dist/Table/MoreDropdown.js +122 -25
- package/dist/Table/TableContextMenu.d.ts.map +1 -1
- package/dist/Table/TableContextMenu.js +151 -137
- package/dist/Table/TableContextMenuWrapper.js +59 -14
- package/dist/Table/hooks/useColorManagement.js +58 -16
- package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
- package/dist/Table/hooks/useTableConfiguration.js +333 -169
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +222 -128
- package/dist/Table/utils/functions.js +169 -144
- package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
- package/dist/TimelineGuide/index.js +209 -16
- package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
- package/dist/TopTable/index.d.ts.map +1 -1
- package/dist/TopTable/index.js +342 -123
- package/dist/contexts/LabelsQueryProvider.js +94 -32
- package/dist/contexts/UnifiedLabelsContext.js +114 -49
- package/dist/contexts/utils.js +37 -15
- package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
- package/dist/hooks/useCompareModeMeta.js +158 -64
- package/dist/hooks/useLabels.js +295 -52
- package/dist/hooks/useQueryState.d.ts +3 -3
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +373 -332
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -8
- package/dist/testdata/fg-diff.json +3750 -0
- package/dist/testdata/fg-simple.json +1879 -0
- package/dist/testdata/link_data.json +56 -0
- package/dist/testdata/tabular.json +30 -0
- package/dist/testdata/test_flamegraph.json +26846 -0
- package/dist/testdata/test_graph.json +53 -0
- package/dist/useDelayedLoader.js +32 -18
- package/dist/useGrpcQuery/index.js +71 -11
- package/dist/useHasProfileData.js +90 -12
- package/dist/useQuery.js +205 -64
- package/dist/useSumBy.d.ts +1 -1
- package/dist/useSumBy.d.ts.map +1 -1
- package/dist/useSumBy.js +294 -138
- package/dist/utils.js +62 -30
- package/package.json +9 -10
- package/src/GraphTooltipArrow/index.tsx +3 -0
- package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +13 -11
- package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
- package/src/MatchersInput/SuggestionsList.tsx +11 -10
- package/src/MatchersInput/index.tsx +1 -1
- package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
- package/src/PreSelectedMatchers/index.tsx +3 -0
- package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -4
- package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
- package/src/ProfileFlameChart/index.tsx +28 -21
- package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +9 -10
- package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +6 -5
- package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
- package/src/ProfileFlameGraph/index.tsx +9 -6
- package/src/ProfileMetricsGraph/index.tsx +8 -6
- package/src/ProfileSelector/MetricsGraphSection.tsx +10 -5
- package/src/ProfileSelector/index.tsx +61 -39
- package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +6 -10
- package/src/ProfileView/components/ColorStackLegend.tsx +4 -2
- package/src/ProfileView/components/InvertCallStack/index.tsx +4 -5
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +192 -94
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
- package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +28 -24
- package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +5 -4
- package/src/ProfileView/components/Toolbars/index.tsx +3 -3
- package/src/ProfileView/components/ViewSelector/index.tsx +16 -9
- package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
- package/src/ProfileView/context/DashboardContext.tsx +6 -6
- package/src/ProfileView/hooks/useResetFlameGraphState.ts +4 -6
- package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +26 -24
- package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +8 -16
- package/src/ProfileView/hooks/useVisualizationState.ts +69 -61
- package/src/ProfileViewWithData.tsx +35 -29
- package/src/Sandwich/index.tsx +3 -4
- package/src/SourceView/index.tsx +2 -4
- package/src/SourceView/useSelectedLineRange.ts +19 -34
- package/src/Table/MoreDropdown.tsx +11 -9
- package/src/Table/TableContextMenu.tsx +13 -10
- package/src/Table/hooks/useTableConfiguration.tsx +11 -16
- package/src/Table/index.tsx +21 -12
- package/src/TopTable/index.tsx +4 -3
- package/src/hooks/useCompareModeMeta.ts +91 -61
- package/src/hooks/useQueryState.test.tsx +345 -275
- package/src/hooks/useQueryState.ts +118 -136
- package/src/index.tsx +15 -16
- package/src/useDelayedLoader.ts +10 -10
- package/src/useSumBy.ts +15 -21
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
- package/dist/hooks/urlParsers.d.ts +0 -18
- package/dist/hooks/urlParsers.d.ts.map +0 -1
- package/dist/hooks/urlParsers.js +0 -32
- package/dist/hooks/useColorBy.d.ts +0 -5
- package/dist/hooks/useColorBy.d.ts.map +0 -1
- package/dist/hooks/useColorBy.js +0 -26
- package/dist/hooks/useDashboardItems.d.ts +0 -5
- package/dist/hooks/useDashboardItems.d.ts.map +0 -1
- package/dist/hooks/useDashboardItems.js +0 -27
- package/dist/hooks/useQueryState.test.js +0 -868
- package/src/hooks/urlParsers.ts +0 -38
- package/src/hooks/useColorBy.ts +0 -42
- package/src/hooks/useDashboardItems.ts +0 -46
|
@@ -1,3 +1,15 @@
|
|
|
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
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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; } }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
1
13
|
// Copyright 2022 The Parca Authors
|
|
2
14
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
15
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,342 +22,371 @@
|
|
|
10
22
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
23
|
// See the License for the specific language governing permissions and
|
|
12
24
|
// limitations under the License.
|
|
25
|
+
|
|
13
26
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
14
|
-
import {
|
|
15
|
-
import { DateTimeRange, useParcaContext } from '@parca/components';
|
|
27
|
+
import { DateTimeRange, useParcaContext, useURLState, useURLStateBatch } from '@parca/components';
|
|
16
28
|
import { Query } from '@parca/parser';
|
|
17
29
|
import { ProfileSelectionFromParams } from '../ProfileSource';
|
|
18
30
|
import { useResetFlameGraphState } from '../ProfileView/hooks/useResetFlameGraphState';
|
|
19
31
|
import { useResetStateOnProfileTypeChange } from '../ProfileView/hooks/useResetStateOnProfileTypeChange';
|
|
20
32
|
import { DEFAULT_EMPTY_SUM_BY, sumByToParam, useSumBy, useSumByFromParams } from '../useSumBy';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
33
|
+
export var useQueryState = function useQueryState() {
|
|
34
|
+
var _ref, _ref2;
|
|
35
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
36
|
+
var _useParcaContext = useParcaContext(),
|
|
37
|
+
queryClient = _useParcaContext.queryServiceClient;
|
|
38
|
+
var _options$suffix = options.suffix,
|
|
39
|
+
suffix = _options$suffix === void 0 ? '' : _options$suffix,
|
|
40
|
+
_options$defaultExpre = options.defaultExpression,
|
|
41
|
+
defaultExpression = _options$defaultExpre === void 0 ? '' : _options$defaultExpre,
|
|
42
|
+
_options$defaultTimeS = options.defaultTimeSelection,
|
|
43
|
+
defaultTimeSelection = _options$defaultTimeS === void 0 ? 'relative:minute|15' : _options$defaultTimeS,
|
|
44
|
+
defaultFrom = options.defaultFrom,
|
|
45
|
+
defaultTo = options.defaultTo,
|
|
46
|
+
_options$comparing = options.comparing,
|
|
47
|
+
comparing = _options$comparing === void 0 ? false : _options$comparing,
|
|
48
|
+
onProfileTypeChange = options.onProfileTypeChange;
|
|
49
|
+
var batchUpdates = useURLStateBatch();
|
|
50
|
+
var resetFlameGraphState = useResetFlameGraphState();
|
|
51
|
+
var resetStateOnProfileTypeChange = useResetStateOnProfileTypeChange();
|
|
52
|
+
|
|
53
|
+
// URL state hooks with appropriate suffixes
|
|
54
|
+
var _useURLState = useURLState("expression".concat(suffix), {
|
|
55
|
+
defaultValue: defaultExpression
|
|
56
|
+
}),
|
|
57
|
+
_useURLState2 = _slicedToArray(_useURLState, 2),
|
|
58
|
+
expression = _useURLState2[0],
|
|
59
|
+
setExpressionState = _useURLState2[1];
|
|
60
|
+
var _useURLState3 = useURLState("from".concat(suffix), {
|
|
61
|
+
defaultValue: defaultFrom === null || defaultFrom === void 0 ? void 0 : defaultFrom.toString()
|
|
62
|
+
}),
|
|
63
|
+
_useURLState4 = _slicedToArray(_useURLState3, 2),
|
|
64
|
+
from = _useURLState4[0],
|
|
65
|
+
setFromState = _useURLState4[1];
|
|
66
|
+
var _useURLState5 = useURLState("to".concat(suffix), {
|
|
67
|
+
defaultValue: defaultTo === null || defaultTo === void 0 ? void 0 : defaultTo.toString()
|
|
68
|
+
}),
|
|
69
|
+
_useURLState6 = _slicedToArray(_useURLState5, 2),
|
|
70
|
+
to = _useURLState6[0],
|
|
71
|
+
setToState = _useURLState6[1];
|
|
72
|
+
var _useURLState7 = useURLState("time_selection".concat(suffix), {
|
|
73
|
+
defaultValue: defaultTimeSelection
|
|
74
|
+
}),
|
|
75
|
+
_useURLState8 = _slicedToArray(_useURLState7, 2),
|
|
76
|
+
timeSelection = _useURLState8[0],
|
|
77
|
+
setTimeSelectionState = _useURLState8[1];
|
|
78
|
+
var _useURLState9 = useURLState("sum_by".concat(suffix)),
|
|
79
|
+
_useURLState0 = _slicedToArray(_useURLState9, 2),
|
|
80
|
+
sumByParam = _useURLState0[0],
|
|
81
|
+
setSumByParam = _useURLState0[1];
|
|
82
|
+
var _useURLState1 = useURLState('group_by', {
|
|
83
|
+
alwaysReturnArray: true
|
|
84
|
+
}),
|
|
85
|
+
_useURLState10 = _slicedToArray(_useURLState1, 2),
|
|
86
|
+
setGroupByParam = _useURLState10[1];
|
|
87
|
+
var _useURLState11 = useURLState("merge_from".concat(suffix)),
|
|
88
|
+
_useURLState12 = _slicedToArray(_useURLState11, 2),
|
|
89
|
+
mergeFrom = _useURLState12[0],
|
|
90
|
+
setMergeFromState = _useURLState12[1];
|
|
91
|
+
var _useURLState13 = useURLState("merge_to".concat(suffix)),
|
|
92
|
+
_useURLState14 = _slicedToArray(_useURLState13, 2),
|
|
93
|
+
mergeTo = _useURLState14[0],
|
|
94
|
+
setMergeToState = _useURLState14[1];
|
|
95
|
+
|
|
96
|
+
// ProfileSelection URL state hooks - reuses merge_from/merge_to but adds selection
|
|
97
|
+
var _useURLState15 = useURLState("selection".concat(suffix)),
|
|
98
|
+
_useURLState16 = _slicedToArray(_useURLState15, 2),
|
|
99
|
+
selectionParam = _useURLState16[0],
|
|
100
|
+
setSelectionParam = _useURLState16[1];
|
|
101
|
+
|
|
102
|
+
// Parse sumBy from URL parameter format
|
|
103
|
+
var sumBy = useSumByFromParams(sumByParam);
|
|
104
|
+
|
|
105
|
+
// Draft state management
|
|
106
|
+
var _useState = useState(expression !== null && expression !== void 0 ? expression : defaultExpression),
|
|
107
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
108
|
+
draftExpression = _useState2[0],
|
|
109
|
+
setDraftExpression = _useState2[1];
|
|
110
|
+
var _useState3 = useState((_ref = from !== null && from !== void 0 ? from : defaultFrom === null || defaultFrom === void 0 ? void 0 : defaultFrom.toString()) !== null && _ref !== void 0 ? _ref : ''),
|
|
111
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
112
|
+
draftFrom = _useState4[0],
|
|
113
|
+
setDraftFrom = _useState4[1];
|
|
114
|
+
var _useState5 = useState((_ref2 = to !== null && to !== void 0 ? to : defaultTo === null || defaultTo === void 0 ? void 0 : defaultTo.toString()) !== null && _ref2 !== void 0 ? _ref2 : ''),
|
|
115
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
116
|
+
draftTo = _useState6[0],
|
|
117
|
+
setDraftTo = _useState6[1];
|
|
118
|
+
var _useState7 = useState(timeSelection !== null && timeSelection !== void 0 ? timeSelection : defaultTimeSelection),
|
|
119
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
120
|
+
draftTimeSelection = _useState8[0],
|
|
121
|
+
setDraftTimeSelection = _useState8[1];
|
|
122
|
+
// Parse the draft query to extract profile information
|
|
123
|
+
var draftQuery = useMemo(function () {
|
|
124
|
+
try {
|
|
125
|
+
return Query.parse(draftExpression !== null && draftExpression !== void 0 ? draftExpression : '');
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.warn('Failed to parse draft expression', {
|
|
128
|
+
expression: draftExpression,
|
|
129
|
+
error: error instanceof Error ? error.message : String(error)
|
|
130
|
+
});
|
|
131
|
+
return Query.parse('');
|
|
132
|
+
}
|
|
133
|
+
}, [draftExpression]);
|
|
134
|
+
var query = useMemo(function () {
|
|
135
|
+
try {
|
|
136
|
+
return Query.parse(expression !== null && expression !== void 0 ? expression : '');
|
|
137
|
+
} catch (error_0) {
|
|
138
|
+
console.warn('Failed to parse expression', {
|
|
139
|
+
expression: expression,
|
|
140
|
+
error: error_0 instanceof Error ? error_0.message : String(error_0)
|
|
141
|
+
});
|
|
142
|
+
return Query.parse('');
|
|
143
|
+
}
|
|
144
|
+
}, [expression]);
|
|
145
|
+
var draftProfileType = useMemo(function () {
|
|
146
|
+
return draftQuery.profileType();
|
|
147
|
+
}, [draftQuery]);
|
|
148
|
+
var draftProfileName = useMemo(function () {
|
|
149
|
+
return draftQuery.profileName();
|
|
150
|
+
}, [draftQuery]);
|
|
151
|
+
var profileType = useMemo(function () {
|
|
152
|
+
return query.profileType();
|
|
153
|
+
}, [query]);
|
|
154
|
+
|
|
155
|
+
// Compute draft time range for label fetching
|
|
156
|
+
var draftTimeRange = useMemo(function () {
|
|
157
|
+
return DateTimeRange.fromRangeKey(draftTimeSelection !== null && draftTimeSelection !== void 0 ? draftTimeSelection : defaultTimeSelection, draftFrom !== '' ? parseInt(draftFrom) : defaultFrom, draftTo !== '' ? parseInt(draftTo) : defaultTo);
|
|
158
|
+
}, [draftTimeSelection, draftFrom, draftTo, defaultTimeSelection, defaultFrom, defaultTo]);
|
|
159
|
+
// Use combined sumBy hook for fetching labels and computing defaults (based on committed state)
|
|
160
|
+
var _useSumBy = useSumBy(queryClient, (profileType === null || profileType === void 0 ? void 0 : profileType.profileName) !== '' ? profileType : draftProfileType, draftTimeRange, draftProfileType, draftTimeRange, sumBy),
|
|
161
|
+
computedSumByFromURL = _useSumBy.sumBy,
|
|
162
|
+
sumBySelectionLoading = _useSumBy.isLoading,
|
|
163
|
+
draftSumBy = _useSumBy.draftSumBy,
|
|
164
|
+
setDraftSumBy = _useSumBy.setDraftSumBy,
|
|
165
|
+
isDraftSumByLoading = _useSumBy.isDraftSumByLoading;
|
|
166
|
+
|
|
167
|
+
// Sync draft state with URL state when URL changes externally
|
|
168
|
+
useEffect(function () {
|
|
169
|
+
setDraftExpression(expression !== null && expression !== void 0 ? expression : defaultExpression);
|
|
170
|
+
}, [expression, defaultExpression]);
|
|
171
|
+
useEffect(function () {
|
|
172
|
+
var _ref3;
|
|
173
|
+
setDraftFrom((_ref3 = from !== null && from !== void 0 ? from : defaultFrom === null || defaultFrom === void 0 ? void 0 : defaultFrom.toString()) !== null && _ref3 !== void 0 ? _ref3 : '');
|
|
174
|
+
}, [from, defaultFrom]);
|
|
175
|
+
useEffect(function () {
|
|
176
|
+
var _ref4;
|
|
177
|
+
setDraftTo((_ref4 = to !== null && to !== void 0 ? to : defaultTo === null || defaultTo === void 0 ? void 0 : defaultTo.toString()) !== null && _ref4 !== void 0 ? _ref4 : '');
|
|
178
|
+
}, [to, defaultTo]);
|
|
179
|
+
useEffect(function () {
|
|
180
|
+
setDraftTimeSelection(timeSelection !== null && timeSelection !== void 0 ? timeSelection : defaultTimeSelection);
|
|
181
|
+
}, [timeSelection, defaultTimeSelection]);
|
|
182
|
+
useEffect(function () {
|
|
183
|
+
setDraftSumBy(sumBy);
|
|
184
|
+
}, [sumBy, setDraftSumBy]);
|
|
185
|
+
|
|
186
|
+
// Sync computed sumBy to URL if URL doesn't already have a value
|
|
187
|
+
// to ensure the shared URL can always pick it up.
|
|
188
|
+
useEffect(function () {
|
|
189
|
+
if (sumByParam === undefined && computedSumByFromURL !== undefined && !sumBySelectionLoading) {
|
|
190
|
+
setSumByParam(sumByToParam(computedSumByFromURL));
|
|
191
|
+
}
|
|
192
|
+
}, [sumByParam, computedSumByFromURL, sumBySelectionLoading, setSumByParam]);
|
|
193
|
+
|
|
194
|
+
// Construct the QuerySelection object (committed state from URL)
|
|
195
|
+
var querySelection = useMemo(function () {
|
|
196
|
+
var range = DateTimeRange.fromRangeKey(timeSelection !== null && timeSelection !== void 0 ? timeSelection : defaultTimeSelection, from !== undefined && from !== '' ? parseInt(from) : defaultFrom, to !== undefined && to !== '' ? parseInt(to) : defaultTo);
|
|
197
|
+
return _objectSpread({
|
|
198
|
+
expression: expression !== null && expression !== void 0 ? expression : defaultExpression,
|
|
199
|
+
from: range.getFromMs(),
|
|
200
|
+
to: range.getToMs(),
|
|
201
|
+
timeSelection: range.getRangeKey(),
|
|
202
|
+
sumBy: computedSumByFromURL
|
|
203
|
+
}, mergeFrom !== undefined && mergeFrom !== '' && mergeTo !== undefined && mergeTo !== '' ? {
|
|
204
|
+
mergeFrom: mergeFrom,
|
|
205
|
+
mergeTo: mergeTo
|
|
206
|
+
} : {});
|
|
207
|
+
}, [expression, from, to, timeSelection, computedSumByFromURL, mergeFrom, mergeTo, defaultExpression, defaultTimeSelection, defaultFrom, defaultTo]);
|
|
208
|
+
|
|
209
|
+
// Construct the draft QuerySelection object (local draft state)
|
|
210
|
+
var draftSelection = useMemo(function () {
|
|
211
|
+
var isDelta = draftProfileType.delta;
|
|
212
|
+
var draftMergeFrom = isDelta ? (BigInt(draftTimeRange.getFromMs()) * 1000000n).toString() : undefined;
|
|
213
|
+
var draftMergeTo = isDelta ? (BigInt(draftTimeRange.getToMs()) * 1000000n).toString() : undefined;
|
|
214
|
+
var finalSumBy = draftSumBy !== null && draftSumBy !== void 0 ? draftSumBy : computedSumByFromURL;
|
|
215
|
+
return _objectSpread({
|
|
216
|
+
expression: draftExpression !== null && draftExpression !== void 0 ? draftExpression : defaultExpression,
|
|
217
|
+
from: draftTimeRange.getFromMs(),
|
|
218
|
+
to: draftTimeRange.getToMs(),
|
|
219
|
+
timeSelection: draftTimeRange.getRangeKey(),
|
|
220
|
+
sumBy: finalSumBy
|
|
221
|
+
}, draftMergeFrom !== undefined && draftMergeFrom !== '' && draftMergeTo !== undefined && draftMergeTo !== '' ? {
|
|
222
|
+
mergeFrom: draftMergeFrom,
|
|
223
|
+
mergeTo: draftMergeTo
|
|
224
|
+
} : {});
|
|
225
|
+
}, [draftExpression, draftTimeRange, draftSumBy, computedSumByFromURL, draftProfileType.delta, defaultExpression]);
|
|
226
|
+
|
|
227
|
+
// Compute ProfileSelection from URL params
|
|
228
|
+
var profileSelection = useMemo(function () {
|
|
229
|
+
return ProfileSelectionFromParams(mergeFrom, mergeTo, selectionParam);
|
|
230
|
+
}, [mergeFrom, mergeTo, selectionParam]);
|
|
231
|
+
|
|
232
|
+
// Compute ProfileSource from ProfileSelection
|
|
233
|
+
var profileSource = useMemo(function () {
|
|
234
|
+
if (profileSelection === null) return null;
|
|
235
|
+
return profileSelection.ProfileSource();
|
|
236
|
+
}, [profileSelection]);
|
|
237
|
+
|
|
238
|
+
// Commit draft changes to URL
|
|
239
|
+
// Optional refreshedTimeRange parameter allows re-evaluating relative time ranges (e.g., "last 15 minutes")
|
|
240
|
+
// to the current moment when the Search button is clicked
|
|
241
|
+
// Optional expression parameter allows updating the expression before committing
|
|
242
|
+
var commitDraft = useCallback(function (refreshedTimeRange, expression_0) {
|
|
243
|
+
batchUpdates(function () {
|
|
244
|
+
var _refreshedTimeRange$f, _refreshedTimeRange$f2, _refreshedTimeRange$t, _refreshedTimeRange$t2, _refreshedTimeRange$t3;
|
|
245
|
+
// Use provided expression or current draft expression
|
|
246
|
+
var finalExpression = expression_0 !== null && expression_0 !== void 0 ? expression_0 : draftExpression;
|
|
247
|
+
|
|
248
|
+
// Update draft state with new expression if provided
|
|
249
|
+
if (expression_0 !== undefined) {
|
|
250
|
+
setDraftExpression(expression_0);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Calculate the actual from/to values from draftSelection if not provided
|
|
254
|
+
var calculatedFrom = draftSelection.from.toString();
|
|
255
|
+
var calculatedTo = draftSelection.to.toString();
|
|
256
|
+
var finalFrom = (_refreshedTimeRange$f = refreshedTimeRange === null || refreshedTimeRange === void 0 || (_refreshedTimeRange$f2 = refreshedTimeRange.from) === null || _refreshedTimeRange$f2 === void 0 ? void 0 : _refreshedTimeRange$f2.toString()) !== null && _refreshedTimeRange$f !== void 0 ? _refreshedTimeRange$f : draftFrom !== '' ? draftFrom : calculatedFrom;
|
|
257
|
+
var finalTo = (_refreshedTimeRange$t = refreshedTimeRange === null || refreshedTimeRange === void 0 || (_refreshedTimeRange$t2 = refreshedTimeRange.to) === null || _refreshedTimeRange$t2 === void 0 ? void 0 : _refreshedTimeRange$t2.toString()) !== null && _refreshedTimeRange$t !== void 0 ? _refreshedTimeRange$t : draftTo !== '' ? draftTo : calculatedTo;
|
|
258
|
+
var finalTimeSelection = (_refreshedTimeRange$t3 = refreshedTimeRange === null || refreshedTimeRange === void 0 ? void 0 : refreshedTimeRange.timeSelection) !== null && _refreshedTimeRange$t3 !== void 0 ? _refreshedTimeRange$t3 : draftTimeSelection;
|
|
259
|
+
|
|
260
|
+
// Update draft state with refreshed time range if provided
|
|
261
|
+
if ((refreshedTimeRange === null || refreshedTimeRange === void 0 ? void 0 : refreshedTimeRange.from) !== undefined) {
|
|
262
|
+
setDraftFrom(finalFrom);
|
|
263
|
+
}
|
|
264
|
+
if ((refreshedTimeRange === null || refreshedTimeRange === void 0 ? void 0 : refreshedTimeRange.to) !== undefined) {
|
|
265
|
+
setDraftTo(finalTo);
|
|
266
|
+
}
|
|
267
|
+
if ((refreshedTimeRange === null || refreshedTimeRange === void 0 ? void 0 : refreshedTimeRange.timeSelection) !== undefined) {
|
|
268
|
+
setDraftTimeSelection(finalTimeSelection);
|
|
269
|
+
}
|
|
270
|
+
setExpressionState(finalExpression);
|
|
271
|
+
setFromState(finalFrom);
|
|
272
|
+
setToState(finalTo);
|
|
273
|
+
setTimeSelectionState(finalTimeSelection);
|
|
274
|
+
|
|
275
|
+
// Auto-calculate merge parameters for delta profiles
|
|
276
|
+
// Parse the final expression to check if it's a delta profile
|
|
277
|
+
var finalQuery = Query.parse(finalExpression);
|
|
278
|
+
var isDelta_0 = finalQuery.profileType().delta;
|
|
279
|
+
if (isDelta_0) {
|
|
280
|
+
setSumByParam(sumByToParam(draftSumBy));
|
|
281
|
+
} else {
|
|
282
|
+
setSumByParam(DEFAULT_EMPTY_SUM_BY);
|
|
283
|
+
}
|
|
284
|
+
if (isDelta_0 && finalFrom !== '' && finalTo !== '') {
|
|
285
|
+
var fromMs = parseInt(finalFrom);
|
|
286
|
+
var toMs = parseInt(finalTo);
|
|
287
|
+
setMergeFromState((BigInt(fromMs) * 1000000n).toString());
|
|
288
|
+
setMergeToState((BigInt(toMs) * 1000000n).toString());
|
|
289
|
+
|
|
290
|
+
// Auto-select the time range for delta profiles (but not in compare mode)
|
|
291
|
+
// This applies both on initial load AND when Search is clicked
|
|
292
|
+
// The selection will use the final expression and the updated time range
|
|
293
|
+
if (!comparing) {
|
|
294
|
+
setSelectionParam(finalExpression);
|
|
295
|
+
} else {
|
|
296
|
+
setSelectionParam(undefined);
|
|
223
297
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
//
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
console.warn('Failed to parse query selection expression', {
|
|
320
|
-
expression: querySelection.expression,
|
|
321
|
-
error: error instanceof Error ? error.message : String(error),
|
|
322
|
-
});
|
|
323
|
-
return Query.parse('');
|
|
324
|
-
}
|
|
325
|
-
}, [querySelection.expression]);
|
|
326
|
-
return {
|
|
327
|
-
// Current committed state
|
|
328
|
-
querySelection,
|
|
329
|
-
// Draft state
|
|
330
|
-
draftSelection,
|
|
331
|
-
// Draft setters
|
|
332
|
-
setDraftExpression,
|
|
333
|
-
setDraftTimeRange,
|
|
334
|
-
setDraftSumBy: setDraftSumByCallback,
|
|
335
|
-
setDraftProfileName,
|
|
336
|
-
setDraftMatchers,
|
|
337
|
-
// Commit function
|
|
338
|
-
commitDraft,
|
|
339
|
-
// ProfileSelection state
|
|
340
|
-
profileSelection,
|
|
341
|
-
profileSource,
|
|
342
|
-
setProfileSelection,
|
|
343
|
-
// Loading state
|
|
344
|
-
sumByLoading: isDraftSumByLoading || sumBySelectionLoading,
|
|
345
|
-
draftParsedQuery,
|
|
346
|
-
parsedQuery,
|
|
347
|
-
setExpressionParam: setExpressionState,
|
|
348
|
-
setSumByParam,
|
|
349
|
-
setGroupByParam,
|
|
350
|
-
};
|
|
351
|
-
};
|
|
298
|
+
} else {
|
|
299
|
+
setMergeFromState(undefined);
|
|
300
|
+
setMergeToState(undefined);
|
|
301
|
+
// Clear ProfileSelection for non-delta profiles
|
|
302
|
+
setSelectionParam(undefined);
|
|
303
|
+
}
|
|
304
|
+
resetFlameGraphState();
|
|
305
|
+
if (draftProfileType.toString() !== Query.parse(querySelection.expression).profileType().toString()) {
|
|
306
|
+
resetStateOnProfileTypeChange();
|
|
307
|
+
onProfileTypeChange === null || onProfileTypeChange === void 0 || onProfileTypeChange();
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}, [batchUpdates, draftExpression, draftFrom, draftTo, draftTimeSelection, draftSumBy, draftSelection.from, draftSelection.to, comparing, setExpressionState, setFromState, setToState, setTimeSelectionState, setSumByParam, setMergeFromState, setMergeToState, setSelectionParam, resetFlameGraphState, resetStateOnProfileTypeChange, onProfileTypeChange, draftProfileType, querySelection.expression]);
|
|
311
|
+
var setDraftTimeRange = useCallback(function (newFrom, newTo, newTimeSelection) {
|
|
312
|
+
setDraftFrom(newFrom.toString());
|
|
313
|
+
setDraftTo(newTo.toString());
|
|
314
|
+
setDraftTimeSelection(newTimeSelection);
|
|
315
|
+
}, []);
|
|
316
|
+
var setDraftSumByCallback = useCallback(function (newSumBy) {
|
|
317
|
+
setDraftSumBy(newSumBy);
|
|
318
|
+
}, [setDraftSumBy]);
|
|
319
|
+
var setDraftProfileName = useCallback(function (newProfileName) {
|
|
320
|
+
if (newProfileName === '') return;
|
|
321
|
+
var _draftQuery$setProfil = draftQuery.setProfileName(newProfileName),
|
|
322
|
+
_draftQuery$setProfil2 = _slicedToArray(_draftQuery$setProfil, 2),
|
|
323
|
+
newQuery = _draftQuery$setProfil2[0],
|
|
324
|
+
changed = _draftQuery$setProfil2[1];
|
|
325
|
+
if (changed) {
|
|
326
|
+
setDraftExpression(newQuery.toString());
|
|
327
|
+
setDraftSumBy(undefined);
|
|
328
|
+
}
|
|
329
|
+
}, [draftQuery, setDraftSumBy]);
|
|
330
|
+
var setDraftMatchers = useCallback(function (matchers) {
|
|
331
|
+
var newExpression = "".concat(draftProfileName, "{").concat(matchers, "}");
|
|
332
|
+
setDraftExpression(newExpression);
|
|
333
|
+
}, [draftProfileName]);
|
|
334
|
+
|
|
335
|
+
// Set ProfileSelection (auto-commits to URL immediately)
|
|
336
|
+
var setProfileSelection = useCallback(function (mergeFrom_0, mergeTo_0, query_0) {
|
|
337
|
+
batchUpdates(function () {
|
|
338
|
+
setSelectionParam(query_0.toString());
|
|
339
|
+
setMergeFromState(mergeFrom_0.toString());
|
|
340
|
+
setMergeToState(mergeTo_0.toString());
|
|
341
|
+
});
|
|
342
|
+
}, [batchUpdates, setSelectionParam, setMergeFromState, setMergeToState]);
|
|
343
|
+
var draftParsedQuery = useMemo(function () {
|
|
344
|
+
try {
|
|
345
|
+
var _draftSelection$expre;
|
|
346
|
+
return Query.parse((_draftSelection$expre = draftSelection.expression) !== null && _draftSelection$expre !== void 0 ? _draftSelection$expre : '');
|
|
347
|
+
} catch (error_1) {
|
|
348
|
+
console.warn('Failed to parse draft selection expression', {
|
|
349
|
+
expression: draftSelection.expression,
|
|
350
|
+
error: error_1 instanceof Error ? error_1.message : String(error_1)
|
|
351
|
+
});
|
|
352
|
+
return Query.parse('');
|
|
353
|
+
}
|
|
354
|
+
}, [draftSelection.expression]);
|
|
355
|
+
var parsedQuery = useMemo(function () {
|
|
356
|
+
try {
|
|
357
|
+
var _querySelection$expre;
|
|
358
|
+
return Query.parse((_querySelection$expre = querySelection.expression) !== null && _querySelection$expre !== void 0 ? _querySelection$expre : '');
|
|
359
|
+
} catch (error_2) {
|
|
360
|
+
console.warn('Failed to parse query selection expression', {
|
|
361
|
+
expression: querySelection.expression,
|
|
362
|
+
error: error_2 instanceof Error ? error_2.message : String(error_2)
|
|
363
|
+
});
|
|
364
|
+
return Query.parse('');
|
|
365
|
+
}
|
|
366
|
+
}, [querySelection.expression]);
|
|
367
|
+
return {
|
|
368
|
+
// Current committed state
|
|
369
|
+
querySelection: querySelection,
|
|
370
|
+
// Draft state
|
|
371
|
+
draftSelection: draftSelection,
|
|
372
|
+
// Draft setters
|
|
373
|
+
setDraftExpression: setDraftExpression,
|
|
374
|
+
setDraftTimeRange: setDraftTimeRange,
|
|
375
|
+
setDraftSumBy: setDraftSumByCallback,
|
|
376
|
+
setDraftProfileName: setDraftProfileName,
|
|
377
|
+
setDraftMatchers: setDraftMatchers,
|
|
378
|
+
// Commit function
|
|
379
|
+
commitDraft: commitDraft,
|
|
380
|
+
// ProfileSelection state
|
|
381
|
+
profileSelection: profileSelection,
|
|
382
|
+
profileSource: profileSource,
|
|
383
|
+
setProfileSelection: setProfileSelection,
|
|
384
|
+
// Loading state
|
|
385
|
+
sumByLoading: isDraftSumByLoading || sumBySelectionLoading,
|
|
386
|
+
draftParsedQuery: draftParsedQuery,
|
|
387
|
+
parsedQuery: parsedQuery,
|
|
388
|
+
setExpressionParam: setExpressionState,
|
|
389
|
+
setSumByParam: setSumByParam,
|
|
390
|
+
setGroupByParam: setGroupByParam
|
|
391
|
+
};
|
|
392
|
+
};
|