@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.
Files changed (253) hide show
  1. package/CHANGELOG.md +5 -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.d.ts.map +1 -1
  9. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +104 -72
  10. package/dist/MatchersInput/SuggestionItem.js +91 -12
  11. package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
  12. package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
  13. package/dist/MatchersInput/SuggestionsList.js +371 -157
  14. package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
  15. package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
  16. package/dist/MatchersInput/index.js +308 -115
  17. package/dist/MetricsCircle/index.js +39 -3
  18. package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
  19. package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
  20. package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
  21. package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
  22. package/dist/MetricsGraph/index.js +552 -203
  23. package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
  24. package/dist/MetricsGraph/utils/colorMapping.js +24 -17
  25. package/dist/MetricsSeries/index.js +70 -7
  26. package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
  27. package/dist/PreSelectedMatchers/index.js +249 -102
  28. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
  29. package/dist/ProfileExplorer/ProfileExplorerCompare.js +241 -45
  30. package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
  31. package/dist/ProfileExplorer/index.js +183 -32
  32. package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
  33. package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
  34. package/dist/ProfileFlameChart/SamplesStrips/index.d.ts +2 -2
  35. package/dist/ProfileFlameChart/SamplesStrips/index.d.ts.map +1 -1
  36. package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
  37. package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
  38. package/dist/ProfileFlameChart/index.d.ts.map +1 -1
  39. package/dist/ProfileFlameChart/index.js +267 -129
  40. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
  41. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +288 -89
  42. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
  43. package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
  44. package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
  45. package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
  46. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  47. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +72 -47
  48. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
  49. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
  50. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
  51. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
  52. package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
  53. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
  54. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
  55. package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
  56. package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
  57. package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
  58. package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
  59. package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
  60. package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
  61. package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
  62. package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
  63. package/dist/ProfileFlameGraph/index.js +324 -150
  64. package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
  65. package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
  66. package/dist/ProfileMetricsGraph/index.js +519 -258
  67. package/dist/ProfileSelector/CompareButton.js +132 -12
  68. package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
  69. package/dist/ProfileSelector/MetricsGraphSection.js +236 -64
  70. package/dist/ProfileSelector/index.d.ts.map +1 -1
  71. package/dist/ProfileSelector/index.js +727 -141
  72. package/dist/ProfileSelector/useAutoQuerySelector.js +249 -130
  73. package/dist/ProfileSource.js +230 -163
  74. package/dist/ProfileTypeSelector/index.js +214 -125
  75. package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
  76. package/dist/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
  77. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +141 -35
  78. package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
  79. package/dist/ProfileView/components/ColorStackLegend.js +185 -55
  80. package/dist/ProfileView/components/DashboardItems/index.js +87 -28
  81. package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
  82. package/dist/ProfileView/components/DiffLegend.js +172 -29
  83. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
  84. package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
  85. package/dist/ProfileView/components/InvertCallStack/index.js +100 -12
  86. package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
  87. package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
  88. package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
  89. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +2 -1
  90. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
  91. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +188 -118
  92. package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
  93. package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
  94. package/dist/ProfileView/components/ShareButton/index.js +352 -62
  95. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  96. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +678 -194
  97. package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
  98. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
  99. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +199 -157
  100. package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
  101. package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
  102. package/dist/ProfileView/components/Toolbars/index.js +441 -21
  103. package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
  104. package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
  105. package/dist/ProfileView/components/ViewSelector/index.js +212 -86
  106. package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
  107. package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
  108. package/dist/ProfileView/components/VisualizationPanel.js +185 -8
  109. package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
  110. package/dist/ProfileView/context/DashboardContext.js +85 -29
  111. package/dist/ProfileView/context/ProfileViewContext.js +56 -15
  112. package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
  113. package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
  114. package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
  115. package/dist/ProfileView/hooks/useResetFlameGraphState.js +32 -12
  116. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
  117. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
  118. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
  119. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +40 -19
  120. package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
  121. package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
  122. package/dist/ProfileView/hooks/useVisualizationState.js +258 -67
  123. package/dist/ProfileView/index.js +383 -45
  124. package/dist/ProfileView/types/visualization.js +1 -13
  125. package/dist/ProfileView/utils/colorUtils.js +8 -7
  126. package/dist/ProfileViewWithData.d.ts.map +1 -1
  127. package/dist/ProfileViewWithData.js +332 -228
  128. package/dist/QueryControls/index.js +418 -47
  129. package/dist/Sandwich/components/CalleesSection.js +54 -4
  130. package/dist/Sandwich/components/CallersSection.js +97 -27
  131. package/dist/Sandwich/components/TableSection.js +77 -4
  132. package/dist/Sandwich/index.d.ts.map +1 -1
  133. package/dist/Sandwich/index.js +126 -14
  134. package/dist/Sandwich/utils/processRowData.js +48 -39
  135. package/dist/SelectWithRefresh/index.js +102 -28
  136. package/dist/SimpleMatchers/Select.js +520 -187
  137. package/dist/SimpleMatchers/index.js +590 -288
  138. package/dist/SourceView/Highlighter.js +230 -70
  139. package/dist/SourceView/LineNo.js +72 -17
  140. package/dist/SourceView/index.d.ts.map +1 -1
  141. package/dist/SourceView/index.js +178 -104
  142. package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
  143. package/dist/SourceView/lang-detector/index.js +28 -14
  144. package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
  145. package/dist/SourceView/useSelectedLineRange.js +99 -23
  146. package/dist/Table/ColorCell.js +42 -1
  147. package/dist/Table/ColumnsVisibility.js +114 -6
  148. package/dist/Table/MoreDropdown.d.ts.map +1 -1
  149. package/dist/Table/MoreDropdown.js +122 -25
  150. package/dist/Table/TableContextMenu.d.ts.map +1 -1
  151. package/dist/Table/TableContextMenu.js +151 -137
  152. package/dist/Table/TableContextMenuWrapper.js +59 -14
  153. package/dist/Table/hooks/useColorManagement.js +58 -16
  154. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  155. package/dist/Table/hooks/useTableConfiguration.js +333 -169
  156. package/dist/Table/index.d.ts.map +1 -1
  157. package/dist/Table/index.js +222 -128
  158. package/dist/Table/utils/functions.js +169 -144
  159. package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
  160. package/dist/TimelineGuide/index.js +209 -16
  161. package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
  162. package/dist/TopTable/index.d.ts.map +1 -1
  163. package/dist/TopTable/index.js +342 -123
  164. package/dist/contexts/LabelsQueryProvider.js +94 -32
  165. package/dist/contexts/UnifiedLabelsContext.js +114 -49
  166. package/dist/contexts/utils.js +37 -15
  167. package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
  168. package/dist/hooks/useCompareModeMeta.js +158 -64
  169. package/dist/hooks/useLabels.js +295 -52
  170. package/dist/hooks/useQueryState.d.ts +3 -3
  171. package/dist/hooks/useQueryState.d.ts.map +1 -1
  172. package/dist/hooks/useQueryState.js +373 -332
  173. package/dist/index.d.ts +2 -3
  174. package/dist/index.d.ts.map +1 -1
  175. package/dist/index.js +22 -8
  176. package/dist/testdata/fg-diff.json +3750 -0
  177. package/dist/testdata/fg-simple.json +1879 -0
  178. package/dist/testdata/link_data.json +56 -0
  179. package/dist/testdata/tabular.json +30 -0
  180. package/dist/testdata/test_flamegraph.json +26846 -0
  181. package/dist/testdata/test_graph.json +53 -0
  182. package/dist/useDelayedLoader.js +32 -18
  183. package/dist/useGrpcQuery/index.js +71 -11
  184. package/dist/useHasProfileData.js +90 -12
  185. package/dist/useQuery.js +205 -64
  186. package/dist/useSumBy.d.ts +1 -1
  187. package/dist/useSumBy.d.ts.map +1 -1
  188. package/dist/useSumBy.js +294 -138
  189. package/dist/utils.js +62 -30
  190. package/package.json +9 -10
  191. package/src/GraphTooltipArrow/index.tsx +3 -0
  192. package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +13 -11
  193. package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
  194. package/src/MatchersInput/SuggestionsList.tsx +11 -10
  195. package/src/MatchersInput/index.tsx +1 -1
  196. package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
  197. package/src/PreSelectedMatchers/index.tsx +3 -0
  198. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -4
  199. package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
  200. package/src/ProfileFlameChart/index.tsx +28 -21
  201. package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +9 -10
  202. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +6 -5
  203. package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
  204. package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
  205. package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
  206. package/src/ProfileFlameGraph/index.tsx +9 -6
  207. package/src/ProfileMetricsGraph/index.tsx +8 -6
  208. package/src/ProfileSelector/MetricsGraphSection.tsx +10 -5
  209. package/src/ProfileSelector/index.tsx +61 -39
  210. package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +6 -10
  211. package/src/ProfileView/components/ColorStackLegend.tsx +4 -2
  212. package/src/ProfileView/components/InvertCallStack/index.tsx +4 -5
  213. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +192 -94
  214. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
  215. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +28 -24
  216. package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +5 -4
  217. package/src/ProfileView/components/Toolbars/index.tsx +3 -3
  218. package/src/ProfileView/components/ViewSelector/index.tsx +16 -9
  219. package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
  220. package/src/ProfileView/context/DashboardContext.tsx +6 -6
  221. package/src/ProfileView/hooks/useResetFlameGraphState.ts +4 -6
  222. package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +26 -24
  223. package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +8 -16
  224. package/src/ProfileView/hooks/useVisualizationState.ts +69 -61
  225. package/src/ProfileViewWithData.tsx +35 -29
  226. package/src/Sandwich/index.tsx +3 -4
  227. package/src/SourceView/index.tsx +2 -4
  228. package/src/SourceView/useSelectedLineRange.ts +19 -34
  229. package/src/Table/MoreDropdown.tsx +11 -9
  230. package/src/Table/TableContextMenu.tsx +13 -10
  231. package/src/Table/hooks/useTableConfiguration.tsx +11 -16
  232. package/src/Table/index.tsx +21 -12
  233. package/src/TopTable/index.tsx +4 -3
  234. package/src/hooks/useCompareModeMeta.ts +91 -61
  235. package/src/hooks/useQueryState.test.tsx +345 -275
  236. package/src/hooks/useQueryState.ts +118 -136
  237. package/src/index.tsx +15 -16
  238. package/src/useDelayedLoader.ts +10 -10
  239. package/src/useSumBy.ts +15 -21
  240. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
  241. package/dist/hooks/urlParsers.d.ts +0 -18
  242. package/dist/hooks/urlParsers.d.ts.map +0 -1
  243. package/dist/hooks/urlParsers.js +0 -32
  244. package/dist/hooks/useColorBy.d.ts +0 -5
  245. package/dist/hooks/useColorBy.d.ts.map +0 -1
  246. package/dist/hooks/useColorBy.js +0 -26
  247. package/dist/hooks/useDashboardItems.d.ts +0 -5
  248. package/dist/hooks/useDashboardItems.d.ts.map +0 -1
  249. package/dist/hooks/useDashboardItems.js +0 -27
  250. package/dist/hooks/useQueryState.test.js +0 -868
  251. package/src/hooks/urlParsers.ts +0 -38
  252. package/src/hooks/useColorBy.ts +0 -42
  253. 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"}
@@ -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,5 +0,0 @@
1
- export declare const useColorBy: () => {
2
- colorBy: string;
3
- setColorBy: (value: string) => void;
4
- };
5
- //# sourceMappingURL=useColorBy.d.ts.map
@@ -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"}
@@ -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,5 +0,0 @@
1
- export declare const useDashboardItems: () => {
2
- dashboardItems: string[];
3
- setDashboardItems: (items: string[]) => void;
4
- };
5
- //# sourceMappingURL=useDashboardItems.d.ts.map
@@ -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
- };