Skip to content

Commit daf7391

Browse files
ochameausquarewave
authored andcommitted
Integrate DevTools Reps to render Tracer object previews.
1 parent 41e95eb commit daf7391

File tree

8 files changed

+72
-42
lines changed

8 files changed

+72
-42
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"common-tags": "^1.8.2",
7676
"copy-to-clipboard": "^3.3.3",
7777
"core-js": "^3.40.0",
78+
"devtools-reps": "^0.24.0",
7879
"escape-string-regexp": "^4.0.0",
7980
"gecko-profiler-demangle": "^0.3.3",
8081
"idb": "^8.0.0",

res/css/global.css

+14
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,17 @@
2929
.colored-border.ellipsis {
3030
opacity: 0;
3131
}
32+
33+
/* Colors for DevTools Reps */
34+
:root {
35+
--number-color: #058b00;
36+
--string-color: #dd00a9;
37+
--null-color: #5c5c5f;
38+
--object-color: #0074e8;
39+
--caption-color: #0074e8;
40+
--location-color: #5c5c5f;
41+
--source-link-color: #0060df;
42+
--node-color: #003eaa;
43+
--reference-color: #0074e8;
44+
--comment-node-color: #5c5c5f;
45+
}

src/components/stack-chart/Canvas.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ class StackChartCanvasImpl extends React.PureComponent<Props> {
497497
callTreeSummaryStrategy="timing"
498498
durationText={formatMilliseconds(duration)}
499499
displayStackType={displayStackType}
500-
args={JSON.stringify(argumentSummaries, null, 2) || null}
500+
args={argumentSummaries}
501501
/>
502502
);
503503
};

src/components/tooltip/CallNode.js

+24-10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ import type {
3232
} from 'firefox-profiler/profile-logic/profile-data';
3333
import type { CallNodeInfo } from 'firefox-profiler/profile-logic/call-node-info';
3434

35+
import {
36+
REPS,
37+
MODE,
38+
} from 'devtools-reps'
39+
const { Rep } = REPS;
40+
41+
3542
import './CallNode.css';
3643
import classNames from 'classnames';
3744

@@ -129,7 +136,7 @@ type Props = {|
129136
+timings?: TimingsForPath,
130137
+callTreeSummaryStrategy: CallTreeSummaryStrategy,
131138
+displayStackType: boolean,
132-
+args?: string | null,
139+
+args?: Array<{...}>,
133140
|};
134141

135142
/**
@@ -425,15 +432,22 @@ export class TooltipCallNode extends React.PureComponent<Props> {
425432
];
426433
}
427434

428-
let argsEl = null;
435+
let argumentsElement = null;
429436
if (args) {
430-
argsEl = [
431-
<div className="tooltipLabel" key="resource">
432-
args:
433-
</div>,
434-
];
435-
for (let line of args.split("\n")) {
436-
argsEl.push(line);
437+
if (args.length == 0) {
438+
argumentsElement = <div className="arguments">No arguments.</div>;
439+
} else {
440+
let argsEl = [];
441+
for(const previewObject of args) {
442+
argsEl.push(Rep({
443+
object: previewObject,
444+
mode: MODE.LONG,
445+
}));
446+
}
447+
argumentsElement = <div className="arguments">
448+
<div className="argumentsLabel">Arguments</div>
449+
{argsEl}
450+
</div>;
437451
}
438452
}
439453

@@ -551,9 +565,9 @@ export class TooltipCallNode extends React.PureComponent<Props> {
551565
{pageAndParentPageURL}
552566
{fileName}
553567
{resource}
554-
{argsEl}
555568
</div>
556569
{this._renderCategoryTimings(timings)}
570+
{argumentsElement}
557571
</div>
558572
</div>
559573
);

src/components/tooltip/Tooltip.css

+9
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,12 @@
145145
.sidebar .tooltipDetailSeparator {
146146
display: none;
147147
}
148+
149+
.argumentsLabel {
150+
/* match tooltips label, without being aligned to the right */
151+
color: var(--grey-50);
152+
}
153+
.arguments > span {
154+
display: block;
155+
border-bottom: 1px solid var(--grey-40);
156+
}

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import '../res/css/global.css';
1515
import '../res/css/categories.css';
1616
import '../res/css/network.css';
1717
import 'react-splitter-layout/lib/index.css';
18+
import 'devtools-reps/reps.css';
1819

1920
import React from 'react';
2021
import { createRoot } from 'react-dom/client';

webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const config = {
5757
...includes,
5858
path.join(__dirname, 'node_modules', 'photon-colors'),
5959
path.join(__dirname, 'node_modules', 'react-splitter-layout'),
60+
path.join(__dirname, 'node_modules', 'devtools-reps'),
6061
],
6162
},
6263
{

yarn.lock

+21-31
Original file line numberDiff line numberDiff line change
@@ -4571,6 +4571,16 @@ devtools-license-check@^0.9.0:
45714571
dependencies:
45724572
license-checker "^9.0.3"
45734573

4574+
devtools-reps@^0.24.0:
4575+
version "0.24.0"
4576+
resolved "https://registry.yarnpkg.com/devtools-reps/-/devtools-reps-0.24.0.tgz#8c5c01772d9cd99338044ff9ed653b64f6b01d23"
4577+
integrity sha512-WJMldq/924AB5U0CVG7ljwgvls99/XWuMC36p6NaE00CjYh5P38blAExzSaw7quRaO4/6yly/BOa6SSirunkqQ==
4578+
dependencies:
4579+
prop-types "^15.7.2"
4580+
react "^16.8.6"
4581+
react-dom "^16.8.6"
4582+
react-dom-factories "^1.0.2"
4583+
45744584
dezalgo@^1.0.0:
45754585
version "1.0.3"
45764586
resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.3.tgz#7f742de066fc748bc8db820569dddce49bf0d456"
@@ -10575,7 +10585,7 @@ prompts@^2.0.1:
1057510585
kleur "^3.0.3"
1057610586
sisteransi "^1.0.4"
1057710587

10578-
prop-types@^15.6.2, prop-types@^15.8.1:
10588+
prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
1057910589
version "15.8.1"
1058010590
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
1058110591
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
@@ -10768,7 +10778,12 @@ [email protected]:
1076810778
minimist "^1.2.0"
1076910779
strip-json-comments "~2.0.1"
1077010780

10771-
react-dom@^16.13.1:
10781+
react-dom-factories@^1.0.2:
10782+
version "1.0.2"
10783+
resolved "https://registry.yarnpkg.com/react-dom-factories/-/react-dom-factories-1.0.2.tgz#eb7705c4db36fb501b3aa38ff759616aa0ff96e0"
10784+
integrity sha512-Bmic2N3oKji7vw9qjDr2dmwHvOATbFSnKy7EH0uT/qjvzIUsiXp6Yquk72LJ3WfMtRnq3ujXMMo7GsJeLPfFWw==
10785+
10786+
react-dom@^16.13.1, react-dom@^16.8.6:
1077210787
version "16.14.0"
1077310788
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.14.0.tgz#7ad838ec29a777fb3c75c3a190f661cf92ab8b89"
1077410789
integrity sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==
@@ -10829,7 +10844,7 @@ react-transition-group@^4.4.5:
1082910844
loose-envify "^1.4.0"
1083010845
prop-types "^15.6.2"
1083110846

10832-
react@^16.13.1:
10847+
react@^16.13.1, react@^16.8.6:
1083310848
version "16.14.0"
1083410849
resolved "https://registry.yarnpkg.com/react/-/react-16.14.0.tgz#94d776ddd0aaa37da3eda8fc5b6b18a4c9a3114d"
1083510850
integrity sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==
@@ -12057,7 +12072,7 @@ string-natural-compare@^3.0.1:
1205712072
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4"
1205812073
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==
1205912074

12060-
"string-width-cjs@npm:string-width@^4.2.0":
12075+
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
1206112076
version "4.2.3"
1206212077
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
1206312078
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -12075,15 +12090,6 @@ string-width@^3.0.0:
1207512090
is-fullwidth-code-point "^2.0.0"
1207612091
strip-ansi "^5.1.0"
1207712092

12078-
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
12079-
version "4.2.3"
12080-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
12081-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
12082-
dependencies:
12083-
emoji-regex "^8.0.0"
12084-
is-fullwidth-code-point "^3.0.0"
12085-
strip-ansi "^6.0.1"
12086-
1208712093
string-width@^5.0.0, string-width@^5.0.1, string-width@^5.1.2:
1208812094
version "5.1.2"
1208912095
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
@@ -12188,7 +12194,7 @@ stringify-object@^3.3.0:
1218812194
is-obj "^1.0.1"
1218912195
is-regexp "^1.0.0"
1219012196

12191-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
12197+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
1219212198
version "6.0.1"
1219312199
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
1219412200
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -12209,13 +12215,6 @@ strip-ansi@^5.1.0, strip-ansi@^5.2.0:
1220912215
dependencies:
1221012216
ansi-regex "^4.1.0"
1221112217

12212-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
12213-
version "6.0.1"
12214-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
12215-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
12216-
dependencies:
12217-
ansi-regex "^5.0.1"
12218-
1221912218
strip-ansi@^7.0.1:
1222012219
version "7.1.0"
1222112220
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -13833,7 +13832,7 @@ [email protected], workbox-window@^7.3.0:
1383313832
"@types/trusted-types" "^2.0.2"
1383413833
workbox-core "7.3.0"
1383513834

13836-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
13835+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
1383713836
version "7.0.0"
1383813837
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
1383913838
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -13851,15 +13850,6 @@ wrap-ansi@^6.2.0:
1385113850
string-width "^4.1.0"
1385213851
strip-ansi "^6.0.0"
1385313852

13854-
wrap-ansi@^7.0.0:
13855-
version "7.0.0"
13856-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
13857-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
13858-
dependencies:
13859-
ansi-styles "^4.0.0"
13860-
string-width "^4.1.0"
13861-
strip-ansi "^6.0.0"
13862-
1386313853
wrap-ansi@^8.0.1, wrap-ansi@^8.1.0:
1386413854
version "8.1.0"
1386513855
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)