@parca/profile 0.19.138 → 0.19.140

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 (138) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.d.ts.map +1 -1
  3. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +11 -13
  4. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
  5. package/dist/ProfileExplorer/ProfileExplorerCompare.js +4 -9
  6. package/dist/ProfileFlameChart/SamplesStrips/index.d.ts +2 -2
  7. package/dist/ProfileFlameChart/SamplesStrips/index.d.ts.map +1 -1
  8. package/dist/ProfileFlameChart/index.d.ts.map +1 -1
  9. package/dist/ProfileFlameChart/index.js +13 -19
  10. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
  11. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +8 -8
  12. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  13. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +4 -3
  14. package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
  15. package/dist/ProfileFlameGraph/index.js +6 -4
  16. package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
  17. package/dist/ProfileMetricsGraph/index.js +4 -6
  18. package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
  19. package/dist/ProfileSelector/MetricsGraphSection.js +5 -10
  20. package/dist/ProfileSelector/index.d.ts.map +1 -1
  21. package/dist/ProfileSelector/index.js +27 -25
  22. package/dist/ProfileSelector/useAutoQuerySelector.d.ts.map +1 -1
  23. package/dist/ProfileSelector/useAutoQuerySelector.js +3 -0
  24. package/dist/ProfileTypeSelector/index.d.ts.map +1 -1
  25. package/dist/ProfileTypeSelector/index.js +4 -0
  26. package/dist/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
  27. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +5 -5
  28. package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
  29. package/dist/ProfileView/components/ColorStackLegend.js +2 -3
  30. package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
  31. package/dist/ProfileView/components/InvertCallStack/index.js +5 -4
  32. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +1 -2
  33. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
  34. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +14 -16
  35. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +84 -170
  36. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  37. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +16 -20
  38. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
  39. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +4 -5
  40. package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
  41. package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
  42. package/dist/ProfileView/components/Toolbars/index.js +1 -1
  43. package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
  44. package/dist/ProfileView/components/ViewSelector/index.js +8 -14
  45. package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
  46. package/dist/ProfileView/context/DashboardContext.js +6 -6
  47. package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
  48. package/dist/ProfileView/hooks/useResetFlameGraphState.js +5 -4
  49. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
  50. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +25 -26
  51. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
  52. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +13 -8
  53. package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
  54. package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
  55. package/dist/ProfileView/hooks/useVisualizationState.js +35 -51
  56. package/dist/ProfileViewWithData.d.ts.map +1 -1
  57. package/dist/ProfileViewWithData.js +19 -28
  58. package/dist/Sandwich/index.d.ts.map +1 -1
  59. package/dist/Sandwich/index.js +4 -3
  60. package/dist/SourceView/index.d.ts.map +1 -1
  61. package/dist/SourceView/index.js +4 -2
  62. package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
  63. package/dist/SourceView/useSelectedLineRange.js +21 -16
  64. package/dist/Table/MoreDropdown.d.ts.map +1 -1
  65. package/dist/Table/MoreDropdown.js +8 -11
  66. package/dist/Table/TableContextMenu.d.ts.map +1 -1
  67. package/dist/Table/TableContextMenu.js +10 -13
  68. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  69. package/dist/Table/hooks/useTableConfiguration.js +3 -4
  70. package/dist/Table/index.d.ts.map +1 -1
  71. package/dist/Table/index.js +11 -9
  72. package/dist/TopTable/index.d.ts.map +1 -1
  73. package/dist/TopTable/index.js +3 -4
  74. package/dist/hooks/urlParsers.d.ts +18 -0
  75. package/dist/hooks/urlParsers.d.ts.map +1 -0
  76. package/dist/hooks/urlParsers.js +32 -0
  77. package/dist/hooks/useColorBy.d.ts +5 -0
  78. package/dist/hooks/useColorBy.d.ts.map +1 -0
  79. package/dist/hooks/useColorBy.js +26 -0
  80. package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
  81. package/dist/hooks/useCompareModeMeta.js +55 -86
  82. package/dist/hooks/useDashboardItems.d.ts +5 -0
  83. package/dist/hooks/useDashboardItems.d.ts.map +1 -0
  84. package/dist/hooks/useDashboardItems.js +27 -0
  85. package/dist/hooks/useQueryState.d.ts +3 -3
  86. package/dist/hooks/useQueryState.d.ts.map +1 -1
  87. package/dist/hooks/useQueryState.js +105 -105
  88. package/dist/hooks/useQueryState.test.js +186 -302
  89. package/dist/index.d.ts +3 -2
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +3 -12
  92. package/dist/useSumBy.d.ts +1 -1
  93. package/dist/useSumBy.d.ts.map +1 -1
  94. package/dist/useSumBy.js +2 -2
  95. package/package.json +12 -11
  96. package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +11 -13
  97. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +4 -9
  98. package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
  99. package/src/ProfileFlameChart/index.tsx +21 -28
  100. package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +10 -9
  101. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +5 -3
  102. package/src/ProfileFlameGraph/index.tsx +6 -9
  103. package/src/ProfileMetricsGraph/index.tsx +6 -8
  104. package/src/ProfileSelector/MetricsGraphSection.tsx +5 -10
  105. package/src/ProfileSelector/index.tsx +32 -31
  106. package/src/ProfileSelector/useAutoQuerySelector.ts +5 -0
  107. package/src/ProfileTypeSelector/index.tsx +4 -0
  108. package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +10 -6
  109. package/src/ProfileView/components/ColorStackLegend.tsx +2 -4
  110. package/src/ProfileView/components/InvertCallStack/index.tsx +5 -4
  111. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +94 -192
  112. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
  113. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +24 -25
  114. package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +4 -5
  115. package/src/ProfileView/components/Toolbars/index.tsx +3 -3
  116. package/src/ProfileView/components/ViewSelector/index.tsx +9 -16
  117. package/src/ProfileView/context/DashboardContext.tsx +6 -6
  118. package/src/ProfileView/hooks/useResetFlameGraphState.ts +6 -4
  119. package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +24 -26
  120. package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +16 -8
  121. package/src/ProfileView/hooks/useVisualizationState.ts +61 -69
  122. package/src/ProfileViewWithData.tsx +29 -35
  123. package/src/Sandwich/index.tsx +4 -3
  124. package/src/SourceView/index.tsx +4 -2
  125. package/src/SourceView/useSelectedLineRange.ts +34 -19
  126. package/src/Table/MoreDropdown.tsx +9 -11
  127. package/src/Table/TableContextMenu.tsx +10 -13
  128. package/src/Table/hooks/useTableConfiguration.tsx +3 -4
  129. package/src/Table/index.tsx +12 -21
  130. package/src/TopTable/index.tsx +3 -4
  131. package/src/hooks/urlParsers.ts +38 -0
  132. package/src/hooks/useColorBy.ts +42 -0
  133. package/src/hooks/useCompareModeMeta.ts +61 -91
  134. package/src/hooks/useDashboardItems.ts +46 -0
  135. package/src/hooks/useQueryState.test.tsx +275 -345
  136. package/src/hooks/useQueryState.ts +136 -118
  137. package/src/index.tsx +16 -15
  138. package/src/useSumBy.ts +3 -3
@@ -12,8 +12,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
  import { useEffect, useMemo, useState } from 'react';
15
+ import { useQueryState } from 'nuqs';
15
16
  import { QueryRequest_ReportType } from '@parca/client';
16
- import { NumberParser, NumberSerializer, useGrpcMetadata, useParcaContext, useURLState, useURLStateCustom, } from '@parca/components';
17
+ import { useGrpcMetadata, useParcaContext } from '@parca/components';
17
18
  import { saveAsBlob } from '@parca/utilities';
18
19
  import { validateFlameChartQuery } from './ProfileFlameGraph';
19
20
  import { FIELD_FUNCTION_NAME } from './ProfileFlameGraph/FlameGraphArrow';
@@ -21,25 +22,19 @@ import { boundsFromProfileSource } from './ProfileFlameGraph/FlameGraphArrow/uti
21
22
  import { getStepCountFromScreenWidth, useQueryRange, } from './ProfileMetricsGraph/hooks/useQueryRange';
22
23
  import { ProfileView } from './ProfileView';
23
24
  import { useProfileFilters } from './ProfileView/components/ProfileFilters/useProfileFilters';
25
+ import { flamechartDimensionParser, groupByParser, intParam, invertCallStackParser, stringParam, } from './hooks/urlParsers';
26
+ import { useDashboardItems } from './hooks/useDashboardItems';
24
27
  import { useQuery } from './useQuery';
25
28
  import { downloadPprof } from './utils';
26
29
  export const ProfileViewWithData = ({ queryClient, profileSource, showVisualizationSelector, onSwitchToFifteenMinutes, }) => {
27
30
  const metadata = useGrpcMetadata();
28
- const [dashboardItems, setDashboardItems] = useURLState('dashboard_items', {
29
- alwaysReturnArray: true,
30
- });
31
- const [sourceBuildID] = useURLState('source_buildid');
32
- const [sourceFilename] = useURLState('source_filename');
33
- const [groupBy] = useURLState('group_by', {
34
- defaultValue: [FIELD_FUNCTION_NAME],
35
- alwaysReturnArray: true,
36
- });
37
- const [sandwichFunctionName] = useURLState('sandwich_function_name');
38
- const [flamechartDimension] = useURLState('flamechart_dimension', {
39
- alwaysReturnArray: true,
40
- });
41
- const [invertStack] = useURLState('invert_call_stack');
42
- const invertCallStack = invertStack === 'true';
31
+ const { dashboardItems, setDashboardItems } = useDashboardItems();
32
+ const [sourceBuildID] = useQueryState('source_buildid', stringParam);
33
+ const [sourceFilename] = useQueryState('source_filename', stringParam);
34
+ const [groupBy] = useQueryState('group_by', groupByParser.withDefault([FIELD_FUNCTION_NAME]));
35
+ const [sandwichFunctionName] = useQueryState('sandwich_function_name', stringParam);
36
+ const [flamechartDimension] = useQueryState('flamechart_dimension', flamechartDimensionParser);
37
+ const [invertCallStack] = useQueryState('invert_call_stack', invertCallStackParser);
43
38
  const [pprofDownloading, setPprofDownloading] = useState(false);
44
39
  const { protoFilters } = useProfileFilters();
45
40
  useEffect(() => {
@@ -73,7 +68,7 @@ export const ProfileViewWithData = ({ queryClient, profileSource, showVisualizat
73
68
  skip: !dashboardItems.includes('flamegraph'),
74
69
  nodeTrimThreshold,
75
70
  groupBy,
76
- invertCallStack,
71
+ invertCallStack: invertCallStack ?? false,
77
72
  protoFilters,
78
73
  });
79
74
  const samplesEnabled = !!(dashboardItems.includes('flamechart') &&
@@ -85,11 +80,7 @@ export const ProfileViewWithData = ({ queryClient, profileSource, showVisualizat
85
80
  }, [profileSource]);
86
81
  const samplesSumBy = useMemo(() => (flamechartDimension ?? []).map(f => f.startsWith('labels.') ? f.slice('labels.'.length) : f), [flamechartDimension]);
87
82
  // Samples step count: 2px per data point for finer granularity in strips
88
- const [samplesStepCount] = useURLStateCustom('samples_step_count', {
89
- defaultValue: String(getStepCountFromScreenWidth(2)),
90
- parse: NumberParser,
91
- stringify: NumberSerializer,
92
- });
83
+ const [samplesStepCount] = useQueryState('samples_step_count', intParam.withDefault(getStepCountFromScreenWidth(2)));
93
84
  const { isLoading: samplesLoading, response: samplesRangeResponse, error: samplesError, stepDurationMs: samplesStepMs, } = useQueryRange(queryClient, samplesEnabled ? profileSource.query.toString() : '', samplesFromMs, samplesToMs, samplesSumBy, samplesStepCount, !samplesEnabled);
94
85
  // Map QueryRange response to SamplesData
95
86
  // TODO (manoj): Check if we can skip this mapping and adapt the CPUSampleStrips to work directly with the QueryRange response format.
@@ -123,24 +114,24 @@ export const ProfileViewWithData = ({ queryClient, profileSource, showVisualizat
123
114
  });
124
115
  const { isLoading: sourceLoading, response: sourceResponse, error: sourceError, } = useQuery(queryClient, profileSource, QueryRequest_ReportType.SOURCE, {
125
116
  skip: !dashboardItems.includes('source'),
126
- sourceBuildID,
127
- sourceFilename,
117
+ sourceBuildID: sourceBuildID ?? undefined,
118
+ sourceFilename: sourceFilename ?? undefined,
128
119
  protoFilters,
129
120
  });
130
121
  const { isLoading: callersFlamegraphLoading, response: callersFlamegraphResponse, error: callersFlamegraphError, } = useQuery(queryClient, profileSource, QueryRequest_ReportType.FLAMEGRAPH_ARROW, {
131
122
  nodeTrimThreshold,
132
123
  groupBy: [FIELD_FUNCTION_NAME],
133
124
  invertCallStack: true,
134
- sandwichByFunction: sandwichFunctionName,
135
- skip: sandwichFunctionName === undefined && !dashboardItems.includes('sandwich'),
125
+ sandwichByFunction: sandwichFunctionName ?? undefined,
126
+ skip: sandwichFunctionName == null && !dashboardItems.includes('sandwich'),
136
127
  protoFilters,
137
128
  });
138
129
  const { isLoading: calleesFlamegraphLoading, response: calleesFlamegraphResponse, error: calleesFlamegraphError, } = useQuery(queryClient, profileSource, QueryRequest_ReportType.FLAMEGRAPH_ARROW, {
139
130
  nodeTrimThreshold,
140
131
  groupBy: [FIELD_FUNCTION_NAME],
141
132
  invertCallStack: false,
142
- sandwichByFunction: sandwichFunctionName,
143
- skip: sandwichFunctionName === undefined && !dashboardItems.includes('sandwich'),
133
+ sandwichByFunction: sandwichFunctionName ?? undefined,
134
+ skip: sandwichFunctionName == null && !dashboardItems.includes('sandwich'),
144
135
  protoFilters,
145
136
  });
146
137
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Sandwich/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAO9C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAC,YAAY,EAAC,MAAM,oCAAoC,CAAC;AAIhE,UAAU,KAAK;IACb,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,QAAA,MAAM,QAAQ,mCAuEZ,CAAC;AAEH,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Sandwich/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAO9C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAC,YAAY,EAAC,MAAM,oCAAoC,CAAC;AAKhE,UAAU,KAAK;IACb,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,QAAA,MAAM,QAAQ,mCAuEZ,CAAC;AAEH,eAAe,QAAQ,CAAC"}
@@ -13,21 +13,22 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
13
13
  // limitations under the License.
14
14
  import React, { useRef, useState } from 'react';
15
15
  import { AnimatePresence, motion } from 'framer-motion';
16
- import { useURLState } from '@parca/components';
16
+ import { useQueryState } from 'nuqs';
17
17
  import { TEST_IDS, testId } from '@parca/test-utils';
18
18
  import { useDashboard } from '../ProfileView/context/DashboardContext';
19
19
  import { useVisualizationState } from '../ProfileView/hooks/useVisualizationState';
20
+ import { stringParam } from '../hooks/urlParsers';
20
21
  import { CalleesSection } from './components/CalleesSection';
21
22
  import { CallersSection } from './components/CallersSection';
22
23
  const Sandwich = React.memo(function Sandwich({ sandwichData, profileSource, }) {
23
24
  const { dashboardItems } = useDashboard();
24
- const [sandwichFunctionName] = useURLState('sandwich_function_name');
25
+ const [sandwichFunctionName] = useQueryState('sandwich_function_name', stringParam);
25
26
  const callersRef = React.useRef(null);
26
27
  const calleesRef = React.useRef(null);
27
28
  const [isExpanded, setIsExpanded] = useState(false);
28
29
  const defaultMaxFrames = 10;
29
30
  const callersCalleesContainerRef = useRef(null);
30
31
  const { curPathArrow, setCurPathArrow } = useVisualizationState();
31
- return (_jsx("section", { className: "flex flex-row h-full w-full", ...testId(TEST_IDS.SANDWICH_CONTAINER), children: _jsx(AnimatePresence, { children: _jsx(motion.div, { className: "h-full w-full", initial: { display: 'none', opacity: 0 }, animate: { display: 'block', opacity: 1 }, transition: { duration: 0.5 }, children: _jsx("div", { className: "relative flex flex-row", children: sandwichFunctionName !== undefined ? (_jsxs("div", { className: "w-full flex flex-col", ref: callersCalleesContainerRef, children: [_jsx(CallersSection, { callersRef: callersRef, callersFlamegraphData: sandwichData.callers, profileSource: profileSource, curPathArrow: curPathArrow, setCurPathArrow: setCurPathArrow, isExpanded: isExpanded, setIsExpanded: setIsExpanded, defaultMaxFrames: defaultMaxFrames }), _jsx("div", { className: "h-4" }), _jsx(CalleesSection, { calleesRef: calleesRef, calleesFlamegraphData: sandwichData.callees, profileSource: profileSource, curPathArrow: curPathArrow, setCurPathArrow: setCurPathArrow })] })) : (_jsx("div", { className: "items-center justify-center flex h-full w-full", ...testId(TEST_IDS.SANDWICH_NO_FUNCTION_SELECTED), children: _jsx("p", { className: "text-sm", children: dashboardItems.includes('table') ? ('Please select a function to view its callers and callees.') : (_jsxs(_Fragment, { children: ["Use the right-click menu on the Flame", ' ', dashboardItems.includes('flamegraph') ? 'Graph' : 'Chart', " to choose a function to view its callers and callees."] })) }) })) }) }, "sandwich-loaded") }) }));
32
+ return (_jsx("section", { className: "flex flex-row h-full w-full", ...testId(TEST_IDS.SANDWICH_CONTAINER), children: _jsx(AnimatePresence, { children: _jsx(motion.div, { className: "h-full w-full", initial: { display: 'none', opacity: 0 }, animate: { display: 'block', opacity: 1 }, transition: { duration: 0.5 }, children: _jsx("div", { className: "relative flex flex-row", children: sandwichFunctionName != null ? (_jsxs("div", { className: "w-full flex flex-col", ref: callersCalleesContainerRef, children: [_jsx(CallersSection, { callersRef: callersRef, callersFlamegraphData: sandwichData.callers, profileSource: profileSource, curPathArrow: curPathArrow, setCurPathArrow: setCurPathArrow, isExpanded: isExpanded, setIsExpanded: setIsExpanded, defaultMaxFrames: defaultMaxFrames }), _jsx("div", { className: "h-4" }), _jsx(CalleesSection, { calleesRef: calleesRef, calleesFlamegraphData: sandwichData.callees, profileSource: profileSource, curPathArrow: curPathArrow, setCurPathArrow: setCurPathArrow })] })) : (_jsx("div", { className: "items-center justify-center flex h-full w-full", ...testId(TEST_IDS.SANDWICH_NO_FUNCTION_SELECTED), children: _jsx("p", { className: "text-sm", children: dashboardItems.includes('table') ? ('Please select a function to view its callers and callees.') : (_jsxs(_Fragment, { children: ["Use the right-click menu on the Flame", ' ', dashboardItems.includes('flamegraph') ? 'Graph' : 'Chart', " to choose a function to view its callers and callees."] })) }) })) }) }, "sandwich-loaded") }) }));
32
33
  });
33
34
  export default Sandwich;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/SourceView/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAM7D,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAQrC,UAAU,eAAe;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC;CACnD;AAID,eAAO,MAAM,UAAU,6CAqKrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/SourceView/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAO7D,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AASrC,UAAU,eAAe;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC;CACnD;AAID,eAAO,MAAM,UAAU,6CAqKrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
@@ -14,15 +14,17 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
14
14
  import React, { useCallback, useEffect, useMemo } from 'react';
15
15
  import { tableFromIPC } from '@uwdata/flechette';
16
16
  import { AnimatePresence, motion } from 'framer-motion';
17
+ import { useQueryState } from 'nuqs';
17
18
  import { Item, Menu, useContextMenu } from 'react-contexify';
18
- import { SourceSkeleton, useParcaContext, useURLState } from '@parca/components';
19
+ import { SourceSkeleton, useParcaContext } from '@parca/components';
19
20
  import { ExpandOnHover } from '../GraphTooltipArrow/ExpandOnHoverValue';
21
+ import { stringParam } from '../hooks/urlParsers';
20
22
  import { alignedUint8Array, truncateStringReverse } from '../utils';
21
23
  import { Highlighter, profileAwareRenderer } from './Highlighter';
22
24
  import useLineRange from './useSelectedLineRange';
23
25
  const MENU_ID = 'source-view-context-menu';
24
26
  export const SourceView = React.memo(function SourceView({ data, loading, total, filtered, setActionButtons, }) {
25
- const [sourceFileName] = useURLState('source_filename');
27
+ const [sourceFileName] = useQueryState('source_filename', stringParam);
26
28
  const { isDarkMode, sourceViewContextMenuItems = [] } = useParcaContext();
27
29
  const sourceCode = useMemo(() => {
28
30
  if (data === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"useSelectedLineRange.d.ts","sourceRoot":"","sources":["../../src/SourceView/useSelectedLineRange.ts"],"names":[],"mappings":"AAiBA,UAAU,SAAS;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAED,QAAA,MAAM,YAAY,QAAO,SAmBxB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"useSelectedLineRange.d.ts","sourceRoot":"","sources":["../../src/SourceView/useSelectedLineRange.ts"],"names":[],"mappings":"AAiCA,UAAU,SAAS;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAED,QAAA,MAAM,YAAY,QAAO,SAkBxB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -10,23 +10,28 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { useMemo } from 'react';
14
- import { useURLState } from '@parca/components';
13
+ import { useCallback } from 'react';
14
+ import { createParser, useQueryState } from 'nuqs';
15
+ const lineRangeParser = createParser({
16
+ parse: (value) => {
17
+ const [start, end] = value.split('-');
18
+ const startNum = parseInt(start, 10);
19
+ if (isNaN(startNum))
20
+ return null;
21
+ const endNum = end !== undefined ? parseInt(end, 10) : startNum;
22
+ return { start: startNum, end: isNaN(endNum) ? startNum : endNum };
23
+ },
24
+ serialize: (value) => `${value.start}-${value.end}`,
25
+ }).withOptions({ history: 'replace' });
15
26
  const useLineRange = () => {
16
- const [sourceLine, setSourceLine] = useURLState('source_line');
17
- const [startLine, endLine] = useMemo(() => {
18
- if (sourceLine == null) {
19
- return [-1, -1];
20
- }
21
- const [start, end] = sourceLine.split('-');
22
- if (end === undefined) {
23
- return [parseInt(start, 10), parseInt(start, 10)];
24
- }
25
- return [parseInt(start, 10), parseInt(end, 10)];
26
- }, [sourceLine]);
27
- const setLineRange = (start, end) => {
28
- setSourceLine(`${start}-${end}`);
27
+ const [lineRange, setRawLineRange] = useQueryState('source_line', lineRangeParser.withDefault({ start: -1, end: -1 }));
28
+ const setLineRange = useCallback((start, end) => {
29
+ void setRawLineRange({ start, end });
30
+ }, [setRawLineRange]);
31
+ return {
32
+ startLine: lineRange.start,
33
+ endLine: lineRange.end,
34
+ setLineRange,
29
35
  };
30
- return { startLine, endLine, setLineRange };
31
36
  };
32
37
  export default useLineRange;
@@ -1 +1 @@
1
- {"version":3,"file":"MoreDropdown.d.ts","sourceRoot":"","sources":["../../src/Table/MoreDropdown.tsx"],"names":[],"mappings":"AAkBA,QAAA,MAAM,YAAY,GAAI,kBAAgB;IAAC,YAAY,EAAE,MAAM,CAAA;CAAC,KAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAgElF,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"MoreDropdown.d.ts","sourceRoot":"","sources":["../../src/Table/MoreDropdown.tsx"],"names":[],"mappings":"AAsBA,QAAA,MAAM,YAAY,GAAI,kBAAgB;IAAC,YAAY,EAAE,MAAM,CAAA;CAAC,KAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IA0DlF,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -13,20 +13,17 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
13
13
  // limitations under the License.
14
14
  import { Menu } from '@headlessui/react';
15
15
  import { Icon } from '@iconify/react';
16
- import { useParcaContext, useURLState, useURLStateBatch } from '@parca/components';
16
+ import { useQueryState } from 'nuqs';
17
+ import { useParcaContext } from '@parca/components';
18
+ import { stringParam } from '../hooks/urlParsers';
19
+ import { useDashboardItems } from '../hooks/useDashboardItems';
17
20
  const MoreDropdown = ({ functionName }) => {
18
- const [_, setSandwichFunctionName] = useURLState('sandwich_function_name');
19
- const [dashboardItems, setDashboardItems] = useURLState('dashboard_items', {
20
- alwaysReturnArray: true,
21
- });
21
+ const [_, setSandwichFunctionName] = useQueryState('sandwich_function_name', stringParam);
22
+ const { dashboardItems, setDashboardItems } = useDashboardItems();
22
23
  const { enableSandwichView } = useParcaContext();
23
- const batchUpdates = useURLStateBatch();
24
24
  const onSandwichViewSelect = () => {
25
- // Batch updates to combine setSandwichFunctionName + setDashboardItems into single URL navigation
26
- batchUpdates(() => {
27
- setSandwichFunctionName(functionName.trim());
28
- setDashboardItems([...dashboardItems, 'sandwich']);
29
- });
25
+ void setSandwichFunctionName(functionName.trim());
26
+ setDashboardItems([...dashboardItems, 'sandwich']);
30
27
  };
31
28
  const menuItems = [];
32
29
  if (enableSandwichView === true) {
@@ -1 +1 @@
1
- {"version":3,"file":"TableContextMenu.d.ts","sourceRoot":"","sources":["../../src/Table/TableContextMenu.tsx"],"names":[],"mappings":"AAiBA,OAAO,yCAAyC,CAAC;AAKjD,OAAO,EAAC,KAAK,GAAG,EAAC,MAAM,GAAG,CAAC;AAG3B,OAAO,EAAC,KAAK,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAElD,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;CAChD;AAED,QAAA,MAAM,gBAAgB,GAAI,kEAOvB,qBAAqB,KAAG,KAAK,CAAC,GAAG,CAAC,OAmMpC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"TableContextMenu.d.ts","sourceRoot":"","sources":["../../src/Table/TableContextMenu.tsx"],"names":[],"mappings":"AAkBA,OAAO,yCAAyC,CAAC;AAKjD,OAAO,EAAC,KAAK,GAAG,EAAC,MAAM,GAAG,CAAC;AAK3B,OAAO,EAAC,KAAK,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAElD,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;CAChD;AAED,QAAA,MAAM,gBAAgB,GAAI,kEAOvB,qBAAqB,KAAG,KAAK,CAAC,GAAG,CAAC,OA6LpC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -13,28 +13,25 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  // limitations under the License.
14
14
  import { Icon } from '@iconify/react';
15
15
  import cx from 'classnames';
16
+ import { useQueryState } from 'nuqs';
16
17
  import { Item, Menu, Submenu } from 'react-contexify';
17
18
  import 'react-contexify/dist/ReactContexify.css';
18
- import { useParcaContext, useURLState, useURLStateBatch } from '@parca/components';
19
+ import { useParcaContext } from '@parca/components';
19
20
  import { valueFormatter } from '@parca/utilities';
20
21
  import { getTextForCumulative } from '../ProfileFlameGraph/FlameGraphArrow/utils';
22
+ import { stringParam } from '../hooks/urlParsers';
23
+ import { useDashboardItems } from '../hooks/useDashboardItems';
21
24
  import { truncateString } from '../utils';
22
25
  const TableContextMenu = ({ menuId, row, unit, total, totalUnfiltered, columnVisibility, }) => {
23
- const [_, setSandwichFunctionName] = useURLState('sandwich_function_name');
24
- const [dashboardItems, setDashboardItems] = useURLState('dashboard_items', {
25
- alwaysReturnArray: true,
26
- });
26
+ const [_, setSandwichFunctionName] = useQueryState('sandwich_function_name', stringParam);
27
+ const { dashboardItems, setDashboardItems } = useDashboardItems();
27
28
  const { enableSandwichView, isDarkMode } = useParcaContext();
28
- const batchUpdates = useURLStateBatch();
29
29
  const onSandwichViewSelect = () => {
30
30
  if (row?.name != null && row.name.length > 0) {
31
- // Batch updates to combine setSandwichFunctionName + setDashboardItems into single URL navigation
32
- batchUpdates(() => {
33
- setSandwichFunctionName(row.name.trim());
34
- if (!dashboardItems.includes('sandwich')) {
35
- setDashboardItems([...dashboardItems, 'sandwich']);
36
- }
37
- });
31
+ void setSandwichFunctionName(row.name.trim());
32
+ if (!dashboardItems.includes('sandwich')) {
33
+ setDashboardItems([...dashboardItems, 'sandwich']);
34
+ }
38
35
  }
39
36
  };
40
37
  const handleCopyItem = (text) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useTableConfiguration.d.ts","sourceRoot":"","sources":["../../../src/Table/hooks/useTableConfiguration.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAqB,KAAK,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAKxE,OAAO,EAAC,KAAK,GAAG,EAAC,MAAM,IAAI,CAAC;AAE5B,OAAO,EAA2B,KAAK,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAE7E,UAAU,0BAA0B;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,kBAAkB;IAC1B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,cAAc,EAAE,KAAK,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAC,CAAC,CAAC;IACnD,gBAAgB,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;CAC/C;AAED,wBAAgB,qBAAqB,CAAC,EACpC,IAAS,EACT,KAAK,EACL,QAAQ,EACR,WAAW,GACZ,EAAE,0BAA0B,GAAG,kBAAkB,CA+KjD"}
1
+ {"version":3,"file":"useTableConfiguration.d.ts","sourceRoot":"","sources":["../../../src/Table/hooks/useTableConfiguration.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAqB,KAAK,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAKxE,OAAO,EAAC,KAAK,GAAG,EAAC,MAAM,IAAI,CAAC;AAG5B,OAAO,EAA2B,KAAK,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAE7E,UAAU,0BAA0B;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,kBAAkB;IAC1B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,cAAc,EAAE,KAAK,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAC,CAAC,CAAC;IACnD,gBAAgB,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;CAC/C;AAED,wBAAgB,qBAAqB,CAAC,EACpC,IAAS,EACT,KAAK,EACL,QAAQ,EACR,WAAW,GACZ,EAAE,0BAA0B,GAAG,kBAAkB,CA6KjD"}
@@ -13,15 +13,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  // limitations under the License.
14
14
  import { useEffect, useMemo, useState } from 'react';
15
15
  import { createColumnHelper } from '@tanstack/table-core';
16
- import { useURLState } from '@parca/components';
16
+ import { useQueryState } from 'nuqs';
17
17
  import { valueFormatter } from '@parca/utilities';
18
+ import { tableColumnsParser } from '../../hooks/urlParsers';
18
19
  import { ColorCell } from '../ColorCell';
19
20
  import { addPlusSign, ratioString } from '../utils/functions';
20
21
  export function useTableConfiguration({ unit = '', total, filtered, compareMode, }) {
21
22
  const columnHelper = createColumnHelper();
22
- const [tableColumns] = useURLState('table_columns', {
23
- alwaysReturnArray: true,
24
- });
23
+ const [tableColumns] = useQueryState('table_columns', tableColumnsParser);
25
24
  const [columnVisibility, setColumnVisibility] = useState(() => {
26
25
  return {
27
26
  color: true,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Table/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAErE,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAYlD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAU1C,OAAO,EAAC,OAAO,EAAmC,MAAM,mBAAmB,CAAC;AAE5E,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AACjD,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AACzD,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AACjE,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAC7D,eAAO,MAAM,UAAU,SAAS,CAAC;AACjC,eAAO,MAAM,eAAe,cAAc,CAAC;AAC3C,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC;IACxD,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,KAAK,wCAyMhB,CAAC;AAEH,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Table/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAErE,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAQlD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAa1C,OAAO,EAAC,OAAO,EAAmC,MAAM,mBAAmB,CAAC;AAE5E,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AACjD,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AACzD,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AACjE,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAC7D,eAAO,MAAM,UAAU,SAAS,CAAC;AACjC,eAAO,MAAM,eAAe,cAAc,CAAC;AAC3C,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC;IACxD,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,KAAK,wCAiMhB,CAAC;AAEH,eAAe,KAAK,CAAC"}
@@ -14,11 +14,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
15
15
  import { tableFromIPC } from '@uwdata/flechette';
16
16
  import { AnimatePresence, motion } from 'framer-motion';
17
+ import { useQueryState } from 'nuqs';
17
18
  import { useContextMenu } from 'react-contexify';
18
- import { Table as TableComponent, TableSkeleton, useParcaContext, useURLState, } from '@parca/components';
19
+ import { Table as TableComponent, TableSkeleton, useParcaContext } from '@parca/components';
19
20
  import { useCurrentColorProfile } from '@parca/hooks';
20
21
  import useMappingList, { useFilenamesList, } from '../ProfileFlameGraph/FlameGraphArrow/useMappingList';
21
22
  import { useProfileViewContext } from '../ProfileView/context/ProfileViewContext';
23
+ import { stringParam } from '../hooks/urlParsers';
24
+ import { useColorBy } from '../hooks/useColorBy';
25
+ import { useDashboardItems } from '../hooks/useDashboardItems';
22
26
  import { alignedUint8Array } from '../utils';
23
27
  import TableContextMenuWrapper from './TableContextMenuWrapper';
24
28
  import { useColorManagement } from './hooks/useColorManagement';
@@ -37,11 +41,9 @@ export const FIELD_CALLERS = 'callers';
37
41
  export const FIELD_CALLEES = 'callees';
38
42
  export const Table = React.memo(function Table({ data, total, filtered, profileType, loading, isHalfScreen, unit, metadataMappingFiles, error, }) {
39
43
  const currentColorProfile = useCurrentColorProfile();
40
- const [dashboardItems] = useURLState('dashboard_items', {
41
- alwaysReturnArray: true,
42
- });
43
- const [_, setSandwichFunctionName] = useURLState('sandwich_function_name');
44
- const [colorBy, setColorBy] = useURLState('color_by');
44
+ const { dashboardItems } = useDashboardItems();
45
+ const [_, setSandwichFunctionName] = useQueryState('sandwich_function_name', stringParam);
46
+ const { colorBy, setColorBy } = useColorBy();
45
47
  const { isDarkMode } = useParcaContext();
46
48
  const { compareMode } = useProfileViewContext();
47
49
  const MENU_ID = 'table-context-menu';
@@ -61,7 +63,7 @@ export const Table = React.memo(function Table({ data, total, filtered, profileT
61
63
  // If there is only one mapping file, we want to color by filename by default.
62
64
  useEffect(() => {
63
65
  if (mappingsListCount === 1 && colorBy !== 'filename') {
64
- setColorBy('filename');
66
+ void setColorBy('filename');
65
67
  }
66
68
  // eslint-disable-next-line react-hooks/exhaustive-deps
67
69
  }, [mappingsListCount]);
@@ -70,7 +72,7 @@ export const Table = React.memo(function Table({ data, total, filtered, profileT
70
72
  currentColorProfile,
71
73
  mappingsList,
72
74
  filenamesList,
73
- colorBy: colorBy,
75
+ colorBy,
74
76
  });
75
77
  unit = useMemo(() => unit ?? profileType?.sampleUnit ?? '', [unit, profileType?.sampleUnit]);
76
78
  const tableConfig = useTableConfiguration({
@@ -82,7 +84,7 @@ export const Table = React.memo(function Table({ data, total, filtered, profileT
82
84
  const { columns, initialSorting, columnVisibility } = tableConfig;
83
85
  const selectSpan = useCallback((span) => {
84
86
  if (!dashboardItems.includes('flamegraph')) {
85
- setSandwichFunctionName(span.trim());
87
+ void setSandwichFunctionName(span.trim());
86
88
  }
87
89
  }, [setSandwichFunctionName, dashboardItems]);
88
90
  const onRowClick = useCallback((row) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TopTable/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAI7D,OAAO,EAAC,GAAG,EAAW,WAAW,EAAC,MAAM,eAAe,CAAC;AAExD,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAK1B,UAAU,aAAa;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC;CACnD;AAED,eAAO,MAAM,QAAQ,GAAI,MAAM,WAAW,GAAG,SAAS,KAAG,MAcxD,CAAC;AAYF,eAAO,MAAM,QAAQ,2CA4KnB,CAAC;AAEH,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TopTable/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAI7D,OAAO,EAAC,GAAG,EAAW,WAAW,EAAC,MAAM,eAAe,CAAC;AAExD,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAM1B,UAAU,aAAa;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC;CACnD;AAED,eAAO,MAAM,QAAQ,GAAI,MAAM,WAAW,GAAG,SAAS,KAAG,MAcxD,CAAC;AAYF,eAAO,MAAM,QAAQ,2CA0KnB,CAAC;AAEH,eAAe,QAAQ,CAAC"}
@@ -13,9 +13,10 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
13
13
  // limitations under the License.
14
14
  import React, { useCallback, useEffect, useMemo } from 'react';
15
15
  import { createColumnHelper } from '@tanstack/react-table';
16
- import { Button, Table, useURLState } from '@parca/components';
16
+ import { Button, Table } from '@parca/components';
17
17
  import { getLastItem, isSearchMatch, parseParams, valueFormatter, } from '@parca/utilities';
18
18
  import { useProfileViewContext } from '../ProfileView/context/ProfileViewContext';
19
+ import { useDashboardItems } from '../hooks/useDashboardItems';
19
20
  import { hexifyAddress } from '../utils';
20
21
  export const RowLabel = (meta) => {
21
22
  if (meta === undefined)
@@ -38,9 +39,7 @@ const addPlusSign = (num) => {
38
39
  };
39
40
  export const TopTable = React.memo(function TopTable({ data: top, sampleUnit: unit, navigateTo, loading, currentSearchString, setActionButtons, }) {
40
41
  const router = parseParams(window?.location.search);
41
- const [dashboardItems] = useURLState('dashboard_items', {
42
- alwaysReturnArray: true,
43
- });
42
+ const { dashboardItems } = useDashboardItems();
44
43
  const { compareMode } = useProfileViewContext();
45
44
  const columns = useMemo(() => {
46
45
  const cols = [
@@ -0,0 +1,18 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,32 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ export declare const useColorBy: () => {
2
+ colorBy: string;
3
+ setColorBy: (value: string) => void;
4
+ };
5
+ //# sourceMappingURL=useColorBy.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,26 @@
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 +1 @@
1
- {"version":3,"file":"useCompareModeMeta.d.ts","sourceRoot":"","sources":["../../src/hooks/useCompareModeMeta.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO;IACpC,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,KAAK,IAAI,CAAC;CA0G7C,CAAC"}
1
+ {"version":3,"file":"useCompareModeMeta.d.ts","sourceRoot":"","sources":["../../src/hooks/useCompareModeMeta.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO;IACpC,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,KAAK,IAAI,CAAC;CA0E7C,CAAC"}