@parca/profile 0.15.19 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,45 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.16.0](https://github.com/parca-dev/parca/compare/ui-v0.15.26...ui-v0.16.0) (2022-09-13)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.15.25](https://github.com/parca-dev/parca/compare/ui-v0.15.24...ui-v0.15.25) (2022-09-13)
15
+
16
+ **Note:** Version bump only for package @parca/profile
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.15.24](https://github.com/parca-dev/parca/compare/ui-v0.15.23...ui-v0.15.24) (2022-09-13)
23
+
24
+
25
+
26
+ ## [0.15.19](https://github.com/parca-dev/parca/compare/ui-v0.15.17...ui-v0.15.19) (2022-09-08)
27
+
28
+
29
+
30
+ ## [0.15.17](https://github.com/parca-dev/parca/compare/ui-v0.15.10...ui-v0.15.17) (2022-09-07)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * **ui:** type all the things (string mode) ([e91ac9d](https://github.com/parca-dev/parca/commit/e91ac9deb8a200ed3c9a9c5d81ae71e13d49466e))
36
+
37
+
38
+
39
+ ## 0.15.10 (2022-08-30)
40
+
41
+
42
+
43
+
44
+
6
45
  ## [0.15.19](https://github.com/parca-dev/parca/compare/ui-v0.15.18...ui-v0.15.19) (2022-09-08)
7
46
 
8
47
 
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.15.19",
3
+ "version": "0.16.0",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
6
  "@iconify/react": "^3.2.2",
7
- "@parca/client": "^0.15.11",
8
- "@parca/dynamicsize": "^0.15.17",
9
- "@parca/functions": "^0.15.17",
10
- "@parca/parser": "^0.15.17",
7
+ "@parca/client": "^0.16.0",
8
+ "@parca/dynamicsize": "^0.16.0",
9
+ "@parca/functions": "^0.16.0",
10
+ "@parca/parser": "^0.16.0",
11
11
  "d3-scale": "^4.0.2",
12
12
  "d3-selection": "3.0.0",
13
13
  "react-copy-to-clipboard": "^5.1.0"
14
14
  },
15
+ "devDependencies": {
16
+ "@types/react-copy-to-clipboard": "5.0.4"
17
+ },
15
18
  "main": "src/index.tsx",
16
19
  "scripts": {
17
20
  "test": "jest --coverage --config ../../../jest.config.js ./src/*"
@@ -23,5 +26,5 @@
23
26
  "access": "public",
24
27
  "registry": "https://registry.npmjs.org/"
25
28
  },
26
- "gitHead": "bd028ff3e017cfeda0b743b2426f8d30f92b72f9"
29
+ "gitHead": "63fa76520f8a8b4c51b645f23117dde72bf0504d"
27
30
  }
@@ -261,7 +261,7 @@ export function IcicleGraphRootNode({
261
261
  const onClick = (): void => setCurPath([]);
262
262
  const onMouseEnter = (): void => setHoveringNode(node);
263
263
  const onMouseLeave = (): void => setHoveringNode(undefined);
264
- const path = [];
264
+ const path: string[] = [];
265
265
 
266
266
  return (
267
267
  <g transform={'translate(0, 0)'}>
package/src/TopTable.tsx CHANGED
@@ -15,7 +15,7 @@ import React from 'react';
15
15
 
16
16
  import {getLastItem, valueFormatter, isSearchMatch} from '@parca/functions';
17
17
  import {useAppSelector, selectCompareMode, selectSearchNodeString} from '@parca/store';
18
- import {TopNodeMeta, Top} from '@parca/client';
18
+ import {TopNode, TopNodeMeta, Top} from '@parca/client';
19
19
 
20
20
  import {hexifyAddress} from './utils';
21
21
 
@@ -43,7 +43,10 @@ const Arrow = ({direction}: {direction: string | undefined}): JSX.Element => {
43
43
 
44
44
  const useSortableData = (
45
45
  top?: Top,
46
- config = {key: 'cumulative', direction: 'desc'}
46
+ config: {key: keyof TopNode | 'name'; direction: 'asc' | 'desc'} = {
47
+ key: 'cumulative',
48
+ direction: 'desc',
49
+ }
47
50
  ): {
48
51
  items:
49
52
  | Array<{
@@ -54,17 +57,20 @@ const useSortableData = (
54
57
  meta?: TopNodeMeta | undefined;
55
58
  }>
56
59
  | undefined;
57
- requestSort: (key: string) => void;
58
- sortConfig: {key: string; direction: string} | null;
60
+ requestSort: (key: keyof TopNode | 'name') => void;
61
+ sortConfig: {key: keyof TopNode | 'name'; direction: string} | null;
59
62
  } => {
60
- const [sortConfig, setSortConfig] = React.useState<{key: string; direction: string} | null>(
61
- config
62
- );
63
+ const [sortConfig, setSortConfig] = React.useState<{
64
+ key: keyof TopNode | 'name';
65
+ direction: string;
66
+ } | null>(config);
63
67
 
64
68
  const rawTableReport = top != null ? top.list : [];
65
69
 
66
70
  const items = rawTableReport.map(node => ({
67
71
  ...node,
72
+ // Warning: string to number can overflow
73
+ // https://github.com/timostamm/protobuf-ts/blob/master/MANUAL.md#bigint-support
68
74
  diff: Number(node.diff),
69
75
  cumulative: Number(node.cumulative),
70
76
  flat: Number(node.flat),
@@ -77,10 +83,21 @@ const useSortableData = (
77
83
  const sortableItems = [...items];
78
84
  if (sortConfig !== null) {
79
85
  sortableItems.sort((a, b) => {
80
- if (a[sortConfig.key] < b[sortConfig.key]) {
86
+ const itemA = a[sortConfig.key];
87
+ const itemB = b[sortConfig.key];
88
+ if (itemA === undefined && itemB === undefined) {
89
+ return 0;
90
+ }
91
+ if (itemA === undefined) {
92
+ return sortConfig.direction === 'asc' ? -1 : 1;
93
+ }
94
+ if (itemB === undefined) {
95
+ return sortConfig.direction === 'asc' ? 1 : -1;
96
+ }
97
+ if (itemA < itemB) {
81
98
  return sortConfig.direction === 'asc' ? -1 : 1;
82
99
  }
83
- if (a[sortConfig.key] > b[sortConfig.key]) {
100
+ if (itemA > itemB) {
84
101
  return sortConfig.direction === 'asc' ? 1 : -1;
85
102
  }
86
103
  return 0;
@@ -89,7 +106,7 @@ const useSortableData = (
89
106
  return sortableItems;
90
107
  }, [items, sortConfig]);
91
108
 
92
- const requestSort = (key: string): void => {
109
+ const requestSort = (key: keyof TopNode | 'name'): void => {
93
110
  let direction = 'desc';
94
111
  if (sortConfig != null && sortConfig.key === key && sortConfig.direction === 'desc') {
95
112
  direction = 'asc';
@@ -54,9 +54,13 @@ const ProfileShareModal = ({
54
54
  setLoading(false);
55
55
  setIsShared(true);
56
56
  } catch (err) {
57
- console.error(err);
58
- setLoading(false);
59
- setError(err.toString());
57
+ if (err instanceof Error) {
58
+ console.error(err);
59
+ setLoading(false);
60
+ // https://github.com/microsoft/TypeScript/issues/38347
61
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
62
+ setError(err.toString());
63
+ }
60
64
  }
61
65
  };
62
66
 
@@ -27,7 +27,7 @@ const useDelayedLoader = (isLoading = false, options?: DelayedLoaderOptions): bo
27
27
  showLoaderTimeout = setTimeout(() => {
28
28
  setIsLoaderVisible(true);
29
29
  }, delay);
30
- } else {
30
+ } else if (!isLoading && isLoaderVisible) {
31
31
  setIsLoaderVisible(false);
32
32
  }
33
33
  return () => clearTimeout(showLoaderTimeout);