@parca/profile 0.19.139 → 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 (132) hide show
  1. package/CHANGELOG.md +4 -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/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
  23. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +5 -5
  24. package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
  25. package/dist/ProfileView/components/ColorStackLegend.js +2 -3
  26. package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
  27. package/dist/ProfileView/components/InvertCallStack/index.js +5 -4
  28. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +1 -2
  29. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
  30. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +14 -16
  31. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +84 -170
  32. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  33. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +16 -20
  34. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
  35. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +4 -5
  36. package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
  37. package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
  38. package/dist/ProfileView/components/Toolbars/index.js +1 -1
  39. package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
  40. package/dist/ProfileView/components/ViewSelector/index.js +8 -14
  41. package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
  42. package/dist/ProfileView/context/DashboardContext.js +6 -6
  43. package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
  44. package/dist/ProfileView/hooks/useResetFlameGraphState.js +5 -4
  45. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
  46. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +25 -26
  47. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
  48. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +13 -8
  49. package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
  50. package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
  51. package/dist/ProfileView/hooks/useVisualizationState.js +35 -51
  52. package/dist/ProfileViewWithData.d.ts.map +1 -1
  53. package/dist/ProfileViewWithData.js +19 -28
  54. package/dist/Sandwich/index.d.ts.map +1 -1
  55. package/dist/Sandwich/index.js +4 -3
  56. package/dist/SourceView/index.d.ts.map +1 -1
  57. package/dist/SourceView/index.js +4 -2
  58. package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
  59. package/dist/SourceView/useSelectedLineRange.js +21 -16
  60. package/dist/Table/MoreDropdown.d.ts.map +1 -1
  61. package/dist/Table/MoreDropdown.js +8 -11
  62. package/dist/Table/TableContextMenu.d.ts.map +1 -1
  63. package/dist/Table/TableContextMenu.js +10 -13
  64. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  65. package/dist/Table/hooks/useTableConfiguration.js +3 -4
  66. package/dist/Table/index.d.ts.map +1 -1
  67. package/dist/Table/index.js +11 -9
  68. package/dist/TopTable/index.d.ts.map +1 -1
  69. package/dist/TopTable/index.js +3 -4
  70. package/dist/hooks/urlParsers.d.ts +18 -0
  71. package/dist/hooks/urlParsers.d.ts.map +1 -0
  72. package/dist/hooks/urlParsers.js +32 -0
  73. package/dist/hooks/useColorBy.d.ts +5 -0
  74. package/dist/hooks/useColorBy.d.ts.map +1 -0
  75. package/dist/hooks/useColorBy.js +26 -0
  76. package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
  77. package/dist/hooks/useCompareModeMeta.js +55 -86
  78. package/dist/hooks/useDashboardItems.d.ts +5 -0
  79. package/dist/hooks/useDashboardItems.d.ts.map +1 -0
  80. package/dist/hooks/useDashboardItems.js +27 -0
  81. package/dist/hooks/useQueryState.d.ts +3 -3
  82. package/dist/hooks/useQueryState.d.ts.map +1 -1
  83. package/dist/hooks/useQueryState.js +105 -105
  84. package/dist/hooks/useQueryState.test.js +186 -302
  85. package/dist/index.d.ts +3 -2
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +3 -12
  88. package/dist/useSumBy.d.ts +1 -1
  89. package/dist/useSumBy.d.ts.map +1 -1
  90. package/dist/useSumBy.js +2 -2
  91. package/package.json +8 -7
  92. package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +11 -13
  93. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +4 -9
  94. package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
  95. package/src/ProfileFlameChart/index.tsx +21 -28
  96. package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +10 -9
  97. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +5 -3
  98. package/src/ProfileFlameGraph/index.tsx +6 -9
  99. package/src/ProfileMetricsGraph/index.tsx +6 -8
  100. package/src/ProfileSelector/MetricsGraphSection.tsx +5 -10
  101. package/src/ProfileSelector/index.tsx +32 -31
  102. package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +10 -6
  103. package/src/ProfileView/components/ColorStackLegend.tsx +2 -4
  104. package/src/ProfileView/components/InvertCallStack/index.tsx +5 -4
  105. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +94 -192
  106. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
  107. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +24 -25
  108. package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +4 -5
  109. package/src/ProfileView/components/Toolbars/index.tsx +3 -3
  110. package/src/ProfileView/components/ViewSelector/index.tsx +9 -16
  111. package/src/ProfileView/context/DashboardContext.tsx +6 -6
  112. package/src/ProfileView/hooks/useResetFlameGraphState.ts +6 -4
  113. package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +24 -26
  114. package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +16 -8
  115. package/src/ProfileView/hooks/useVisualizationState.ts +61 -69
  116. package/src/ProfileViewWithData.tsx +29 -35
  117. package/src/Sandwich/index.tsx +4 -3
  118. package/src/SourceView/index.tsx +4 -2
  119. package/src/SourceView/useSelectedLineRange.ts +34 -19
  120. package/src/Table/MoreDropdown.tsx +9 -11
  121. package/src/Table/TableContextMenu.tsx +10 -13
  122. package/src/Table/hooks/useTableConfiguration.tsx +3 -4
  123. package/src/Table/index.tsx +12 -21
  124. package/src/TopTable/index.tsx +3 -4
  125. package/src/hooks/urlParsers.ts +38 -0
  126. package/src/hooks/useColorBy.ts +42 -0
  127. package/src/hooks/useCompareModeMeta.ts +61 -91
  128. package/src/hooks/useDashboardItems.ts +46 -0
  129. package/src/hooks/useQueryState.test.tsx +275 -345
  130. package/src/hooks/useQueryState.ts +136 -118
  131. package/src/index.tsx +16 -15
  132. package/src/useSumBy.ts +3 -3
@@ -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","sourceRo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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"}
@@ -11,100 +11,69 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { useCallback } from 'react';
14
- import { useURLState, useURLStateBatch } from '@parca/components';
14
+ import { useQueryStates } from 'nuqs';
15
+ import { boolParam, stringParam } from './urlParsers';
15
16
  /**
16
17
  * Hook to manage compare mode state and operations
17
18
  * Returns compare mode flags and a function to close compare mode
18
19
  */
19
20
  export const useCompareModeMeta = () => {
20
- const batchUpdates = useURLStateBatch();
21
- // Side A URL state (only setters needed)
22
- const [, setExpressionA] = useURLState('expression_a');
23
- const [, setFromA] = useURLState('from_a');
24
- const [, setToA] = useURLState('to_a');
25
- const [, setTimeSelectionA] = useURLState('time_selection_a');
26
- const [, setSumByA] = useURLState('sum_by_a');
27
- const [, setMergeFromA] = useURLState('merge_from_a');
28
- const [, setMergeToA] = useURLState('merge_to_a');
29
- const [, setSelectionA] = useURLState('selection_a');
30
- // Side B URL state
31
- const [expressionB, setExpressionB] = useURLState('expression_b');
32
- const [fromB, setFromB] = useURLState('from_b');
33
- const [toB, setToB] = useURLState('to_b');
34
- const [timeSelectionB, setTimeSelectionB] = useURLState('time_selection_b');
35
- const [sumByB, setSumByB] = useURLState('sum_by_b');
36
- const [mergeFromB, setMergeFromB] = useURLState('merge_from_b');
37
- const [mergeToB, setMergeToB] = useURLState('merge_to_b');
38
- const [selectionB, setSelectionB] = useURLState('selection_b');
39
- // Compare mode flags (expose values for routing decisions)
40
- const [compareA, setCompareA] = useURLState('compare_a');
41
- const [compareB, setCompareB] = useURLState('compare_b');
42
- const [compareAbsolute, setCompareAbsolute] = useURLState('compare_absolute');
21
+ const [state, setState] = useQueryStates({
22
+ // Side A
23
+ expression_a: stringParam,
24
+ from_a: stringParam,
25
+ to_a: stringParam,
26
+ time_selection_a: stringParam,
27
+ sum_by_a: stringParam,
28
+ merge_from_a: stringParam,
29
+ merge_to_a: stringParam,
30
+ selection_a: stringParam,
31
+ // Side B
32
+ expression_b: stringParam,
33
+ from_b: stringParam,
34
+ to_b: stringParam,
35
+ time_selection_b: stringParam,
36
+ sum_by_b: stringParam,
37
+ merge_from_b: stringParam,
38
+ merge_to_b: stringParam,
39
+ selection_b: stringParam,
40
+ // Compare flags
41
+ compare_a: boolParam,
42
+ compare_b: boolParam,
43
+ compare_absolute: boolParam,
44
+ }, { history: 'replace' });
43
45
  const closeCompareMode = useCallback((side) => {
44
- batchUpdates(() => {
45
- // If closing side A, swap A and B params first (keep B's data as the single view)
46
- if (side === 'A') {
47
- // Copy B to A
48
- setExpressionA(expressionB);
49
- setFromA(fromB);
50
- setToA(toB);
51
- setTimeSelectionA(timeSelectionB);
52
- setSumByA(sumByB);
53
- setMergeFromA(mergeFromB);
54
- setMergeToA(mergeToB);
55
- setSelectionA(selectionB);
46
+ // If closing side A, swap B → A first (keep B's data as the single view)
47
+ const swapAFromB = side === 'A'
48
+ ? {
49
+ expression_a: state.expression_b,
50
+ from_a: state.from_b,
51
+ to_a: state.to_b,
52
+ time_selection_a: state.time_selection_b,
53
+ sum_by_a: state.sum_by_b,
54
+ merge_from_a: state.merge_from_b,
55
+ merge_to_a: state.merge_to_b,
56
+ selection_a: state.selection_b,
56
57
  }
57
- // Clear all B params
58
- setExpressionB(undefined);
59
- setFromB(undefined);
60
- setToB(undefined);
61
- setTimeSelectionB(undefined);
62
- setSumByB(undefined);
63
- setMergeFromB(undefined);
64
- setMergeToB(undefined);
65
- setSelectionB(undefined);
66
- // Clear compare mode flags
67
- setCompareA(undefined);
68
- setCompareB(undefined);
69
- setCompareAbsolute(undefined);
58
+ : {};
59
+ // Atomic update: swap A (if needed), clear all B params and compare flags
60
+ void setState({
61
+ ...swapAFromB,
62
+ expression_b: null,
63
+ from_b: null,
64
+ to_b: null,
65
+ time_selection_b: null,
66
+ sum_by_b: null,
67
+ merge_from_b: null,
68
+ merge_to_b: null,
69
+ selection_b: null,
70
+ compare_a: null,
71
+ compare_b: null,
72
+ compare_absolute: null,
70
73
  });
71
- }, [
72
- batchUpdates,
73
- // Side A setters
74
- setExpressionA,
75
- setFromA,
76
- setToA,
77
- setTimeSelectionA,
78
- setSumByA,
79
- setMergeFromA,
80
- setMergeToA,
81
- setSelectionA,
82
- // Side B values (for swapping)
83
- expressionB,
84
- fromB,
85
- toB,
86
- timeSelectionB,
87
- sumByB,
88
- mergeFromB,
89
- mergeToB,
90
- selectionB,
91
- // Side B setters
92
- setExpressionB,
93
- setFromB,
94
- setToB,
95
- setTimeSelectionB,
96
- setSumByB,
97
- setMergeFromB,
98
- setMergeToB,
99
- setSelectionB,
100
- // Compare flags
101
- setCompareA,
102
- setCompareB,
103
- setCompareAbsolute,
104
- ]);
105
- // Derive isCompareMode from flags
106
- const isCompareMode = compareA === 'true' || compareB === 'true';
107
- const isCompareAbsolute = compareAbsolute === 'true';
74
+ }, [state, setState]);
75
+ const isCompareMode = state.compare_a === true || state.compare_b === true;
76
+ const isCompareAbsolute = state.compare_absolute === true;
108
77
  return {
109
78
  isCompareMode,
110
79
  isCompareAbsolute,
@@ -0,0 +1,5 @@
1
+ export declare const useDashboardItems: () => {
2
+ dashboardItems: string[];
3
+ setDashboardItems: (items: string[]) => void;
4
+ };
5
+ //# sourceMappingURL=useDashboardItems.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,27 @@
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
+ };
@@ -29,9 +29,9 @@ interface UseQueryStateReturn {
29
29
  sumByLoading: boolean;
30
30
  draftParsedQuery: Query | null;
31
31
  parsedQuery: Query | null;
32
- setExpressionParam: (value: string | undefined) => void;
33
- setSumByParam: (value: string | undefined) => void;
34
- setGroupByParam: (value: string[] | undefined) => void;
32
+ setExpressionParam: (value: string | null) => void;
33
+ setSumByParam: (value: string | null) => void;
34
+ setGroupByParam: (value: string[] | null) => void;
35
35
  }
36
36
  export declare const useQueryState: (options?: UseQueryStateOptions) => UseQueryStateReturn;
37
37
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"useQueryState.d.ts","sourceRoot":"","sources":["../../src/hooks/useQueryState.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAC,gBAAgB,EAA8B,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAK7F,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;CAClC;AAED,UAAU,mBAAmB;IAE3B,cAAc,EAAE,cAAc,CAAC;IAG/B,cAAc,EAAE,cAAc,CAAC;IAG/B,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7E,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,KAAK,IAAI,CAAC;IACrD,mBAAmB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAG7C,WAAW,EAAE,CAAC,kBAAkB,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;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