@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,455 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// eslint-disable-next-line import/named
|
|
3
|
-
import { act, renderHook, waitFor } from '@testing-library/react';
|
|
4
|
-
// eslint-disable-next-line import/no-unresolved
|
|
5
|
-
import { NuqsTestingAdapter } from 'nuqs/adapters/testing';
|
|
6
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
7
|
-
import { decodeProfileFilters, useProfileFiltersUrlState } from './useProfileFiltersUrlState';
|
|
8
|
-
// Helper to create wrapper with NuqsTestingAdapter
|
|
9
|
-
const createWrapper = (searchParams = {}, onUrlUpdate) => {
|
|
10
|
-
const Wrapper = ({ children }) => (_jsx(NuqsTestingAdapter, { searchParams: searchParams, onUrlUpdate: onUrlUpdate, hasMemory: true, children: children }));
|
|
11
|
-
Wrapper.displayName = 'NuqsTestingWrapper';
|
|
12
|
-
return Wrapper;
|
|
13
|
-
};
|
|
14
|
-
describe('useProfileFiltersUrlState', () => {
|
|
15
|
-
describe('decodeProfileFilters', () => {
|
|
16
|
-
it('should return empty array for empty string', () => {
|
|
17
|
-
expect(decodeProfileFilters('')).toEqual([]);
|
|
18
|
-
});
|
|
19
|
-
it('should return empty array for undefined', () => {
|
|
20
|
-
expect(decodeProfileFilters(undefined)).toEqual([]);
|
|
21
|
-
});
|
|
22
|
-
it('should decode stack filter with function_name', () => {
|
|
23
|
-
// Format: type:field:match:value -> s:fn:=:testFunc
|
|
24
|
-
const encoded = 's:fn:=:testFunc';
|
|
25
|
-
const result = decodeProfileFilters(encoded);
|
|
26
|
-
expect(result).toHaveLength(1);
|
|
27
|
-
expect(result[0]).toMatchObject({
|
|
28
|
-
type: 'stack',
|
|
29
|
-
field: 'function_name',
|
|
30
|
-
matchType: 'equal',
|
|
31
|
-
value: 'testFunc',
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
it('should decode frame filter with binary', () => {
|
|
35
|
-
const encoded = 'f:b:!=:libc.so';
|
|
36
|
-
const result = decodeProfileFilters(encoded);
|
|
37
|
-
expect(result).toHaveLength(1);
|
|
38
|
-
expect(result[0]).toMatchObject({
|
|
39
|
-
type: 'frame',
|
|
40
|
-
field: 'binary',
|
|
41
|
-
matchType: 'not_equal',
|
|
42
|
-
value: 'libc.so',
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
it('should decode filter with contains match', () => {
|
|
46
|
-
const encoded = 's:fn:~:runtime';
|
|
47
|
-
const result = decodeProfileFilters(encoded);
|
|
48
|
-
expect(result).toHaveLength(1);
|
|
49
|
-
expect(result[0]).toMatchObject({
|
|
50
|
-
type: 'stack',
|
|
51
|
-
field: 'function_name',
|
|
52
|
-
matchType: 'contains',
|
|
53
|
-
value: 'runtime',
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
it('should decode filter with not_contains match', () => {
|
|
57
|
-
const encoded = 'f:b:!~:node';
|
|
58
|
-
const result = decodeProfileFilters(encoded);
|
|
59
|
-
expect(result).toHaveLength(1);
|
|
60
|
-
expect(result[0]).toMatchObject({
|
|
61
|
-
type: 'frame',
|
|
62
|
-
field: 'binary',
|
|
63
|
-
matchType: 'not_contains',
|
|
64
|
-
value: 'node',
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
it('should decode filter with starts_with match', () => {
|
|
68
|
-
const encoded = 's:fn:^:std::';
|
|
69
|
-
const result = decodeProfileFilters(encoded);
|
|
70
|
-
expect(result).toHaveLength(1);
|
|
71
|
-
expect(result[0]).toMatchObject({
|
|
72
|
-
type: 'stack',
|
|
73
|
-
field: 'function_name',
|
|
74
|
-
matchType: 'starts_with',
|
|
75
|
-
value: 'std::',
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
it('should decode filter with not_starts_with match', () => {
|
|
79
|
-
const encoded = 'f:fn:!^:tokio::';
|
|
80
|
-
const result = decodeProfileFilters(encoded);
|
|
81
|
-
expect(result).toHaveLength(1);
|
|
82
|
-
expect(result[0]).toMatchObject({
|
|
83
|
-
type: 'frame',
|
|
84
|
-
field: 'function_name',
|
|
85
|
-
matchType: 'not_starts_with',
|
|
86
|
-
value: 'tokio::',
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
it('should decode multiple filters', () => {
|
|
90
|
-
const encoded = 's:fn:=:testFunc,f:b:!=:libc.so';
|
|
91
|
-
const result = decodeProfileFilters(encoded);
|
|
92
|
-
expect(result).toHaveLength(2);
|
|
93
|
-
expect(result[0]).toMatchObject({
|
|
94
|
-
type: 'stack',
|
|
95
|
-
field: 'function_name',
|
|
96
|
-
matchType: 'equal',
|
|
97
|
-
value: 'testFunc',
|
|
98
|
-
});
|
|
99
|
-
expect(result[1]).toMatchObject({
|
|
100
|
-
type: 'frame',
|
|
101
|
-
field: 'binary',
|
|
102
|
-
matchType: 'not_equal',
|
|
103
|
-
value: 'libc.so',
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
it('should decode preset filter', () => {
|
|
107
|
-
const encoded = 'p:hide_libc:enabled';
|
|
108
|
-
const result = decodeProfileFilters(encoded);
|
|
109
|
-
expect(result).toHaveLength(1);
|
|
110
|
-
expect(result[0]).toMatchObject({
|
|
111
|
-
type: 'hide_libc',
|
|
112
|
-
value: 'enabled',
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
it('should handle values with colons', () => {
|
|
116
|
-
const encoded = 'p:some_preset:value:with:colons';
|
|
117
|
-
const result = decodeProfileFilters(encoded);
|
|
118
|
-
expect(result).toHaveLength(1);
|
|
119
|
-
expect(result[0]).toMatchObject({
|
|
120
|
-
type: 'some_preset',
|
|
121
|
-
value: 'value:with:colons',
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
it('should decode all field types', () => {
|
|
125
|
-
const testCases = [
|
|
126
|
-
{ encoded: 's:fn:=:test', expectedField: 'function_name' },
|
|
127
|
-
{ encoded: 's:b:=:test', expectedField: 'binary' },
|
|
128
|
-
{ encoded: 's:sn:=:test', expectedField: 'system_name' },
|
|
129
|
-
{ encoded: 's:f:=:test', expectedField: 'filename' },
|
|
130
|
-
{ encoded: 's:a:=:test', expectedField: 'address' },
|
|
131
|
-
{ encoded: 's:ln:=:test', expectedField: 'line_number' },
|
|
132
|
-
];
|
|
133
|
-
for (const { encoded, expectedField } of testCases) {
|
|
134
|
-
const result = decodeProfileFilters(encoded);
|
|
135
|
-
expect(result[0].field).toBe(expectedField);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
it('should return empty array for malformed input', () => {
|
|
139
|
-
// This should not throw - it returns empty array on error
|
|
140
|
-
expect(() => decodeProfileFilters('malformed')).not.toThrow();
|
|
141
|
-
});
|
|
142
|
-
it('should generate unique IDs for each filter', () => {
|
|
143
|
-
const encoded = 's:fn:=:func1,s:fn:=:func2,s:fn:=:func3';
|
|
144
|
-
const result = decodeProfileFilters(encoded);
|
|
145
|
-
const ids = result.map(f => f.id);
|
|
146
|
-
const uniqueIds = new Set(ids);
|
|
147
|
-
expect(uniqueIds.size).toBe(ids.length);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
describe('Basic functionality', () => {
|
|
151
|
-
it('should initialize with empty filters when no URL params', () => {
|
|
152
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), { wrapper: createWrapper() });
|
|
153
|
-
expect(result.current.appliedFilters).toEqual([]);
|
|
154
|
-
});
|
|
155
|
-
it('should read filters from URL', async () => {
|
|
156
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
157
|
-
wrapper: createWrapper({ profile_filters: 's:fn:=:testFunc' }),
|
|
158
|
-
});
|
|
159
|
-
await waitFor(() => {
|
|
160
|
-
expect(result.current.appliedFilters).toHaveLength(1);
|
|
161
|
-
expect(result.current.appliedFilters[0]).toMatchObject({
|
|
162
|
-
type: 'stack',
|
|
163
|
-
field: 'function_name',
|
|
164
|
-
matchType: 'equal',
|
|
165
|
-
value: 'testFunc',
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
it('should update URL when setting filters', async () => {
|
|
170
|
-
const onUrlUpdate = vi.fn();
|
|
171
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
172
|
-
wrapper: createWrapper({}, onUrlUpdate),
|
|
173
|
-
});
|
|
174
|
-
const newFilters = [
|
|
175
|
-
{
|
|
176
|
-
id: 'test-1',
|
|
177
|
-
type: 'frame',
|
|
178
|
-
field: 'binary',
|
|
179
|
-
matchType: 'not_contains',
|
|
180
|
-
value: 'libc.so',
|
|
181
|
-
},
|
|
182
|
-
];
|
|
183
|
-
act(() => {
|
|
184
|
-
result.current.setAppliedFilters(newFilters);
|
|
185
|
-
});
|
|
186
|
-
await waitFor(() => {
|
|
187
|
-
expect(onUrlUpdate).toHaveBeenCalled();
|
|
188
|
-
const lastCall = onUrlUpdate.mock.calls[onUrlUpdate.mock.calls.length - 1][0];
|
|
189
|
-
expect(lastCall.searchParams.get('profile_filters')).toBe('f:b:!~:libc.so');
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
it('should clear URL param when setting empty filters', async () => {
|
|
193
|
-
const onUrlUpdate = vi.fn();
|
|
194
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
195
|
-
wrapper: createWrapper({ profile_filters: 's:fn:=:testFunc' }, onUrlUpdate),
|
|
196
|
-
});
|
|
197
|
-
act(() => {
|
|
198
|
-
result.current.setAppliedFilters([]);
|
|
199
|
-
});
|
|
200
|
-
await waitFor(() => {
|
|
201
|
-
expect(onUrlUpdate).toHaveBeenCalled();
|
|
202
|
-
const lastCall = onUrlUpdate.mock.calls[onUrlUpdate.mock.calls.length - 1][0];
|
|
203
|
-
expect(lastCall.searchParams.has('profile_filters')).toBe(false);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
describe('forceApplyFilters', () => {
|
|
208
|
-
it('should provide forceApplyFilters method', () => {
|
|
209
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), { wrapper: createWrapper() });
|
|
210
|
-
expect(typeof result.current.forceApplyFilters).toBe('function');
|
|
211
|
-
});
|
|
212
|
-
it('should force apply filters overwriting existing', async () => {
|
|
213
|
-
const onUrlUpdate = vi.fn();
|
|
214
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
215
|
-
wrapper: createWrapper({ profile_filters: 's:fn:=:existingFunc' }, onUrlUpdate),
|
|
216
|
-
});
|
|
217
|
-
// Verify existing filter is loaded
|
|
218
|
-
await waitFor(() => {
|
|
219
|
-
expect(result.current.appliedFilters).toHaveLength(1);
|
|
220
|
-
});
|
|
221
|
-
const newFilters = [
|
|
222
|
-
{
|
|
223
|
-
id: 'forced-1',
|
|
224
|
-
type: 'frame',
|
|
225
|
-
field: 'binary',
|
|
226
|
-
matchType: 'not_contains',
|
|
227
|
-
value: 'forcedValue',
|
|
228
|
-
},
|
|
229
|
-
];
|
|
230
|
-
act(() => {
|
|
231
|
-
result.current.forceApplyFilters(newFilters);
|
|
232
|
-
});
|
|
233
|
-
await waitFor(() => {
|
|
234
|
-
expect(onUrlUpdate).toHaveBeenCalled();
|
|
235
|
-
const lastCall = onUrlUpdate.mock.calls[onUrlUpdate.mock.calls.length - 1][0];
|
|
236
|
-
expect(lastCall.searchParams.get('profile_filters')).toBe('f:b:!~:forcedValue');
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
it('should clear filters when force applying empty array', async () => {
|
|
240
|
-
const onUrlUpdate = vi.fn();
|
|
241
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
242
|
-
wrapper: createWrapper({ profile_filters: 's:fn:=:existingFunc' }, onUrlUpdate),
|
|
243
|
-
});
|
|
244
|
-
act(() => {
|
|
245
|
-
result.current.forceApplyFilters([]);
|
|
246
|
-
});
|
|
247
|
-
await waitFor(() => {
|
|
248
|
-
expect(onUrlUpdate).toHaveBeenCalled();
|
|
249
|
-
const lastCall = onUrlUpdate.mock.calls[onUrlUpdate.mock.calls.length - 1][0];
|
|
250
|
-
expect(lastCall.searchParams.has('profile_filters')).toBe(false);
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
describe('Preset filter encoding', () => {
|
|
255
|
-
it('should encode preset filters correctly', async () => {
|
|
256
|
-
const onUrlUpdate = vi.fn();
|
|
257
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
258
|
-
wrapper: createWrapper({}, onUrlUpdate),
|
|
259
|
-
});
|
|
260
|
-
const presetFilters = [
|
|
261
|
-
{
|
|
262
|
-
id: 'preset-1',
|
|
263
|
-
type: 'hide_libc',
|
|
264
|
-
value: 'enabled',
|
|
265
|
-
},
|
|
266
|
-
];
|
|
267
|
-
act(() => {
|
|
268
|
-
result.current.setAppliedFilters(presetFilters);
|
|
269
|
-
});
|
|
270
|
-
await waitFor(() => {
|
|
271
|
-
expect(onUrlUpdate).toHaveBeenCalled();
|
|
272
|
-
const lastCall = onUrlUpdate.mock.calls[onUrlUpdate.mock.calls.length - 1][0];
|
|
273
|
-
expect(lastCall.searchParams.get('profile_filters')).toBe('p:hide_libc:enabled');
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
it('should handle mixed preset and regular filters', async () => {
|
|
277
|
-
const onUrlUpdate = vi.fn();
|
|
278
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
279
|
-
wrapper: createWrapper({}, onUrlUpdate),
|
|
280
|
-
});
|
|
281
|
-
const mixedFilters = [
|
|
282
|
-
{
|
|
283
|
-
id: 'preset-1',
|
|
284
|
-
type: 'hide_libc',
|
|
285
|
-
value: 'enabled',
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
id: 'regular-1',
|
|
289
|
-
type: 'frame',
|
|
290
|
-
field: 'binary',
|
|
291
|
-
matchType: 'not_contains',
|
|
292
|
-
value: 'node',
|
|
293
|
-
},
|
|
294
|
-
];
|
|
295
|
-
act(() => {
|
|
296
|
-
result.current.setAppliedFilters(mixedFilters);
|
|
297
|
-
});
|
|
298
|
-
await waitFor(() => {
|
|
299
|
-
expect(onUrlUpdate).toHaveBeenCalled();
|
|
300
|
-
const lastCall = onUrlUpdate.mock.calls[onUrlUpdate.mock.calls.length - 1][0];
|
|
301
|
-
expect(lastCall.searchParams.get('profile_filters')).toBe('p:hide_libc:enabled,f:b:!~:node');
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
describe('URL encoding edge cases', () => {
|
|
306
|
-
it('should handle special characters in filter values', async () => {
|
|
307
|
-
const onUrlUpdate = vi.fn();
|
|
308
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
309
|
-
wrapper: createWrapper({}, onUrlUpdate),
|
|
310
|
-
});
|
|
311
|
-
const filtersWithSpecialChars = [
|
|
312
|
-
{
|
|
313
|
-
id: 'special-1',
|
|
314
|
-
type: 'stack',
|
|
315
|
-
field: 'function_name',
|
|
316
|
-
matchType: 'contains',
|
|
317
|
-
value: 'std::vector<int>',
|
|
318
|
-
},
|
|
319
|
-
];
|
|
320
|
-
act(() => {
|
|
321
|
-
result.current.setAppliedFilters(filtersWithSpecialChars);
|
|
322
|
-
});
|
|
323
|
-
await waitFor(() => {
|
|
324
|
-
expect(onUrlUpdate).toHaveBeenCalled();
|
|
325
|
-
const lastCall = onUrlUpdate.mock.calls[onUrlUpdate.mock.calls.length - 1][0];
|
|
326
|
-
const filterValue = lastCall.searchParams.get('profile_filters');
|
|
327
|
-
// The value should contain the encoded special characters
|
|
328
|
-
expect(filterValue).toContain('std%3A%3Avector%3Cint%3E');
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
it('should filter out incomplete filters when encoding', async () => {
|
|
332
|
-
const onUrlUpdate = vi.fn();
|
|
333
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
334
|
-
wrapper: createWrapper({}, onUrlUpdate),
|
|
335
|
-
});
|
|
336
|
-
const incompleteFilters = [
|
|
337
|
-
{
|
|
338
|
-
id: 'complete-1',
|
|
339
|
-
type: 'frame',
|
|
340
|
-
field: 'binary',
|
|
341
|
-
matchType: 'not_contains',
|
|
342
|
-
value: 'valid',
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
id: 'incomplete-1',
|
|
346
|
-
type: 'frame',
|
|
347
|
-
// Missing field, matchType
|
|
348
|
-
value: '',
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
id: 'incomplete-2',
|
|
352
|
-
type: undefined,
|
|
353
|
-
value: 'value',
|
|
354
|
-
},
|
|
355
|
-
];
|
|
356
|
-
act(() => {
|
|
357
|
-
result.current.setAppliedFilters(incompleteFilters);
|
|
358
|
-
});
|
|
359
|
-
await waitFor(() => {
|
|
360
|
-
expect(onUrlUpdate).toHaveBeenCalled();
|
|
361
|
-
const lastCall = onUrlUpdate.mock.calls[onUrlUpdate.mock.calls.length - 1][0];
|
|
362
|
-
// Only the complete filter should be encoded
|
|
363
|
-
expect(lastCall.searchParams.get('profile_filters')).toBe('f:b:!~:valid');
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
describe('Memoization', () => {
|
|
368
|
-
it('should return empty array with consistent structure when no filters', () => {
|
|
369
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), { wrapper: createWrapper() });
|
|
370
|
-
// Empty filters should be an empty array (not undefined or null)
|
|
371
|
-
expect(Array.isArray(result.current.appliedFilters)).toBe(true);
|
|
372
|
-
expect(result.current.appliedFilters).toHaveLength(0);
|
|
373
|
-
});
|
|
374
|
-
it('should always return array (never undefined)', () => {
|
|
375
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), { wrapper: createWrapper() });
|
|
376
|
-
expect(Array.isArray(result.current.appliedFilters)).toBe(true);
|
|
377
|
-
expect(result.current.appliedFilters).toEqual([]);
|
|
378
|
-
});
|
|
379
|
-
it('should return correctly structured filters from URL', async () => {
|
|
380
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
381
|
-
wrapper: createWrapper({ profile_filters: 's:fn:=:testFunc' }),
|
|
382
|
-
});
|
|
383
|
-
await waitFor(() => {
|
|
384
|
-
expect(result.current.appliedFilters).toHaveLength(1);
|
|
385
|
-
});
|
|
386
|
-
// Verify the filter structure is correct
|
|
387
|
-
const filter = result.current.appliedFilters[0];
|
|
388
|
-
expect(filter).toHaveProperty('id');
|
|
389
|
-
expect(filter).toHaveProperty('type', 'stack');
|
|
390
|
-
expect(filter).toHaveProperty('field', 'function_name');
|
|
391
|
-
expect(filter).toHaveProperty('matchType', 'equal');
|
|
392
|
-
// eslint-disable-next-line jest-dom/prefer-to-have-value
|
|
393
|
-
expect(filter).toHaveProperty('value', 'testFunc');
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
describe('View switching scenarios', () => {
|
|
397
|
-
it('should completely replace filters when switching views using forceApplyFilters', async () => {
|
|
398
|
-
const onUrlUpdate = vi.fn();
|
|
399
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
400
|
-
wrapper: createWrapper({ profile_filters: 's:fn:=:viewAFunc,f:b:!=:viewABinary' }, onUrlUpdate),
|
|
401
|
-
});
|
|
402
|
-
await waitFor(() => {
|
|
403
|
-
expect(result.current.appliedFilters).toHaveLength(2);
|
|
404
|
-
});
|
|
405
|
-
// Switch to View B (completely different filter)
|
|
406
|
-
const viewBFilters = [
|
|
407
|
-
{
|
|
408
|
-
id: 'viewB-1',
|
|
409
|
-
type: 'frame',
|
|
410
|
-
field: 'function_name',
|
|
411
|
-
matchType: 'contains',
|
|
412
|
-
value: 'viewBOnly',
|
|
413
|
-
},
|
|
414
|
-
];
|
|
415
|
-
act(() => {
|
|
416
|
-
result.current.forceApplyFilters(viewBFilters);
|
|
417
|
-
});
|
|
418
|
-
await waitFor(() => {
|
|
419
|
-
expect(onUrlUpdate).toHaveBeenCalled();
|
|
420
|
-
const lastCall = onUrlUpdate.mock.calls[onUrlUpdate.mock.calls.length - 1][0];
|
|
421
|
-
const filterValue = lastCall.searchParams.get('profile_filters');
|
|
422
|
-
// View A's filters should be completely gone
|
|
423
|
-
expect(filterValue).not.toContain('viewAFunc');
|
|
424
|
-
expect(filterValue).not.toContain('viewABinary');
|
|
425
|
-
// Only View B's filter should be present
|
|
426
|
-
expect(filterValue).toBe('f:fn:~:viewBOnly');
|
|
427
|
-
});
|
|
428
|
-
});
|
|
429
|
-
it('should not change filters when clicking the same view tab', async () => {
|
|
430
|
-
const { result } = renderHook(() => useProfileFiltersUrlState(), {
|
|
431
|
-
wrapper: createWrapper({ profile_filters: 's:fn:=:existingFilter' }),
|
|
432
|
-
});
|
|
433
|
-
await waitFor(() => {
|
|
434
|
-
expect(result.current.appliedFilters).toHaveLength(1);
|
|
435
|
-
});
|
|
436
|
-
// Apply the same filters (simulating clicking the same view tab)
|
|
437
|
-
const sameFilters = [
|
|
438
|
-
{
|
|
439
|
-
id: 'same-1',
|
|
440
|
-
type: 'stack',
|
|
441
|
-
field: 'function_name',
|
|
442
|
-
matchType: 'equal',
|
|
443
|
-
value: 'existingFilter',
|
|
444
|
-
},
|
|
445
|
-
];
|
|
446
|
-
act(() => {
|
|
447
|
-
result.current.forceApplyFilters(sameFilters);
|
|
448
|
-
});
|
|
449
|
-
await waitFor(() => {
|
|
450
|
-
expect(result.current.appliedFilters).toHaveLength(1);
|
|
451
|
-
expect(result.current.appliedFilters[0].value).toBe('existingFilter');
|
|
452
|
-
});
|
|
453
|
-
});
|
|
454
|
-
});
|
|
455
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createParser } from 'nuqs';
|
|
2
|
-
export declare const stringParam: import("nuqs").SingleParserBuilder<string>;
|
|
3
|
-
export declare const boolParam: import("nuqs").SingleParserBuilder<boolean>;
|
|
4
|
-
export declare const intParam: import("nuqs").SingleParserBuilder<number>;
|
|
5
|
-
export declare const commaArrayParam: import("nuqs").SingleParserBuilder<string[]>;
|
|
6
|
-
export declare const invertCallStackParser: Omit<import("nuqs").SingleParserBuilder<boolean>, "parseServerSide"> & {
|
|
7
|
-
readonly defaultValue: boolean;
|
|
8
|
-
parseServerSide(value: string | string[] | undefined): boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare const groupByParser: import("nuqs").SingleParserBuilder<string[]>;
|
|
11
|
-
export declare const flamechartDimensionParser: import("nuqs").SingleParserBuilder<string[]>;
|
|
12
|
-
export declare const tableColumnsParser: import("nuqs").SingleParserBuilder<string[]>;
|
|
13
|
-
export declare const hiddenBinariesParser: Omit<import("nuqs").SingleParserBuilder<string[]>, "parseServerSide"> & {
|
|
14
|
-
readonly defaultValue: string[];
|
|
15
|
-
parseServerSide(value: string | string[] | undefined): string[];
|
|
16
|
-
};
|
|
17
|
-
export declare function jsonParser<T>(): ReturnType<typeof createParser<T>>;
|
|
18
|
-
//# sourceMappingURL=urlParsers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urlParsers.d.ts","sourceRoot":"","sources":["../../src/hooks/urlParsers.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,YAAY,EAAgE,MAAM,MAAM,CAAC;AAKjG,eAAO,MAAM,WAAW,4CAAkC,CAAC;AAC3D,eAAO,MAAM,SAAS,6CAAmC,CAAC;AAC1D,eAAO,MAAM,QAAQ,4CAAmC,CAAC;AACzD,eAAO,MAAM,eAAe,8CAAuD,CAAC;AAGpF,eAAO,MAAM,qBAAqB;;;CAA+B,CAAC;AAClE,eAAO,MAAM,aAAa,8CAAkB,CAAC;AAC7C,eAAO,MAAM,yBAAyB,8CAAkB,CAAC;AACzD,eAAO,MAAM,kBAAkB,8CAAkB,CAAC;AAClD,eAAO,MAAM,oBAAoB;;;CAAkC,CAAC;AAGpE,wBAAgB,UAAU,CAAC,CAAC,KAAK,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAMlE"}
|
package/dist/hooks/urlParsers.js
DELETED
|
@@ -1,32 +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 { createParser, parseAsArrayOf, parseAsBoolean, parseAsInteger, parseAsString } from 'nuqs';
|
|
14
|
-
const opts = { history: 'replace' };
|
|
15
|
-
// === Base parsers with common options ===
|
|
16
|
-
export const stringParam = parseAsString.withOptions(opts);
|
|
17
|
-
export const boolParam = parseAsBoolean.withOptions(opts);
|
|
18
|
-
export const intParam = parseAsInteger.withOptions(opts);
|
|
19
|
-
export const commaArrayParam = parseAsArrayOf(parseAsString, ',').withOptions(opts);
|
|
20
|
-
// === Param-specific parsers with defaults ===
|
|
21
|
-
export const invertCallStackParser = boolParam.withDefault(false);
|
|
22
|
-
export const groupByParser = commaArrayParam;
|
|
23
|
-
export const flamechartDimensionParser = commaArrayParam;
|
|
24
|
-
export const tableColumnsParser = commaArrayParam;
|
|
25
|
-
export const hiddenBinariesParser = commaArrayParam.withDefault([]);
|
|
26
|
-
// === JSON parser with BigInt support ===
|
|
27
|
-
export function jsonParser() {
|
|
28
|
-
return createParser({
|
|
29
|
-
parse: (value) => JSON.parse(value),
|
|
30
|
-
serialize: (value) => JSON.stringify(value, (_, v) => (typeof v === 'bigint' ? v.toString() : v)),
|
|
31
|
-
}).withOptions(opts);
|
|
32
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useColorBy.d.ts","sourceRoot":"","sources":["../../src/hooks/useColorBy.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,UAAU,QAAO;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAkBrC,CAAC"}
|
package/dist/hooks/useColorBy.js
DELETED
|
@@ -1,26 +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 { useCallback } from 'react';
|
|
14
|
-
import { useQueryState } from 'nuqs';
|
|
15
|
-
import { USER_PREFERENCES, useUserPreference } from '@parca/hooks';
|
|
16
|
-
import { stringParam } from './urlParsers';
|
|
17
|
-
export const useColorBy = () => {
|
|
18
|
-
const [colorByPreference, setColorByPreference] = useUserPreference(USER_PREFERENCES.COLOR_BY.key);
|
|
19
|
-
const [colorByRaw, setRawColorBy] = useQueryState('color_by', stringParam);
|
|
20
|
-
const colorBy = colorByRaw ?? colorByPreference ?? 'binary';
|
|
21
|
-
const setColorBy = useCallback((value) => {
|
|
22
|
-
void setRawColorBy(value);
|
|
23
|
-
setColorByPreference(value);
|
|
24
|
-
}, [setRawColorBy, setColorByPreference]);
|
|
25
|
-
return { colorBy, setColorBy };
|
|
26
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDashboardItems.d.ts","sourceRoot":"","sources":["../../src/hooks/useDashboardItems.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,iBAAiB,QAAO;IACnC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAsB9C,CAAC"}
|
|
@@ -1,27 +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 { useCallback, useMemo } from 'react';
|
|
14
|
-
import { parseAsArrayOf, parseAsString, useQueryState } from 'nuqs';
|
|
15
|
-
import { useParcaContext } from '@parca/components';
|
|
16
|
-
const opts = { history: 'replace' };
|
|
17
|
-
export const useDashboardItems = () => {
|
|
18
|
-
const { defaultDashboardItems } = useParcaContext();
|
|
19
|
-
const parser = useMemo(() => parseAsArrayOf(parseAsString, ',')
|
|
20
|
-
.withDefault(defaultDashboardItems ?? ['flamegraph'])
|
|
21
|
-
.withOptions(opts), [defaultDashboardItems]);
|
|
22
|
-
const [dashboardItems, setRawDashboardItems] = useQueryState('dashboard_items', parser);
|
|
23
|
-
const setDashboardItems = useCallback((items) => {
|
|
24
|
-
void setRawDashboardItems(items);
|
|
25
|
-
}, [setRawDashboardItems]);
|
|
26
|
-
return { dashboardItems, setDashboardItems };
|
|
27
|
-
};
|