Skip to content

Commit f9c7744

Browse files
committed
Embed iongraph-web and use for iongraph.json source files
1 parent 85ce74d commit f9c7744

File tree

5 files changed

+86
-14
lines changed

5 files changed

+86
-14
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"escape-string-regexp": "^4.0.0",
8181
"gecko-profiler-demangle": "^0.3.3",
8282
"idb": "^8.0.3",
83+
"iongraph-web": "0.1.3",
8384
"jszip": "^3.10.1",
8485
"long": "^5.3.2",
8586
"memoize-immutable": "^3.0.0",
@@ -206,7 +207,7 @@
206207
"tsx"
207208
],
208209
"transformIgnorePatterns": [
209-
"/node_modules/(?!(query-string|decode-uri-component|split-on-first|filter-obj|@fetch-mock/jest|fetch-mock)/)"
210+
"/node_modules/(?!(query-string|decode-uri-component|iongraph-web|split-on-first|filter-obj|@fetch-mock/jest|fetch-mock)/)"
210211
],
211212
"moduleNameMapper": {
212213
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ftl)$": "<rootDir>/src/test/fixtures/mocks/file-mock.ts",

src/components/app/BottomBox.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import classNames from 'classnames';
99
import { SourceView } from '../shared/SourceView';
1010
import { AssemblyView } from '../shared/AssemblyView';
1111
import { AssemblyViewToggleButton } from './AssemblyViewToggleButton';
12+
import { IonGraphView } from '../shared/IonGraphView';
1213
import { CodeLoadingOverlay } from './CodeLoadingOverlay';
1314
import { CodeErrorOverlay } from './CodeErrorOverlay';
1415
import {
@@ -177,6 +178,7 @@ class BottomBoxImpl extends React.PureComponent<Props> {
177178
assemblyViewCode && assemblyViewCode.type === 'AVAILABLE'
178179
? assemblyViewCode.instructions
179180
: [];
181+
const sourceIsIonGraph = path !== null && path.endsWith('iongraph.json');
180182

181183
// The bottom box has one or more side-by-side panes.
182184
// At the moment it always has either one or two panes:
@@ -212,15 +214,23 @@ class BottomBoxImpl extends React.PureComponent<Props> {
212214
</div>
213215
<div className="bottom-sourceview-wrapper">
214216
{sourceViewFile !== null ? (
215-
<SourceView
216-
disableOverscan={disableOverscan}
217-
timings={globalLineTimings}
218-
sourceCode={sourceCode}
219-
filePath={path}
220-
scrollToHotSpotGeneration={sourceViewScrollGeneration}
221-
hotSpotTimings={selectedCallNodeLineTimings}
222-
ref={this._sourceView}
223-
/>
217+
sourceIsIonGraph ? (
218+
<IonGraphView
219+
timings={globalLineTimings}
220+
hotSpotTimings={selectedCallNodeLineTimings}
221+
sourceCode={sourceCode}
222+
/>
223+
) : (
224+
<SourceView
225+
disableOverscan={disableOverscan}
226+
timings={globalLineTimings}
227+
sourceCode={sourceCode}
228+
filePath={path}
229+
scrollToHotSpotGeneration={sourceViewScrollGeneration}
230+
hotSpotTimings={selectedCallNodeLineTimings}
231+
ref={this._sourceView}
232+
/>
233+
)
224234
) : null}
225235
{sourceViewCode !== undefined &&
226236
sourceViewCode.type === 'LOADING' ? (
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
import type { LineTimings } from 'firefox-profiler/types';
5+
6+
import { GraphViewer } from 'iongraph-web';
7+
import type { Func } from 'iongraph-web';
8+
import 'iongraph-web/dist/style.css';
9+
10+
import { useMemo } from 'react';
11+
12+
type IonGraphViewProps = {
13+
readonly sourceCode: string;
14+
// TODO: use these when https://github.com/mozilla-spidermonkey/iongraph-web/issues/3 is resolved.
15+
readonly timings: LineTimings;
16+
readonly hotSpotTimings: LineTimings;
17+
};
18+
19+
export function IonGraphView(props: IonGraphViewProps) {
20+
let func = useMemo(() => {
21+
if (props.sourceCode.trim() === '') {
22+
return null;
23+
}
24+
return JSON.parse(props.sourceCode) as Func;
25+
}, [props.sourceCode]);
26+
27+
if (!func) {
28+
return <div />;
29+
}
30+
return <GraphViewer func={func} />;
31+
}

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const config = {
5858
...includes,
5959
path.join(__dirname, 'node_modules', 'photon-colors'),
6060
path.join(__dirname, 'node_modules', 'react-splitter-layout'),
61+
path.join(__dirname, 'node_modules', 'iongraph-web'),
6162
],
6263
},
6364
{

yarn.lock

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6429,6 +6429,11 @@ interpret@^3.1.1:
64296429
resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4"
64306430
integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==
64316431

6432+
6433+
version "0.1.3"
6434+
resolved "https://registry.yarnpkg.com/iongraph-web/-/iongraph-web-0.1.3.tgz#f91c07532cfd5d123ab94928326dfb22d6960389"
6435+
integrity sha512-XA87Qdc0XsrhnhugzjJS/Nd2u2TYy6lgx58ruSXJWdW1+H995G45pxtsZxaI2ORCbxYe5UC5sHwABlnmHmE3Yw==
6436+
64326437
64336438
version "1.9.1"
64346439
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3"
@@ -11320,7 +11325,16 @@ string-length@^4.0.2:
1132011325
char-regex "^1.0.2"
1132111326
strip-ansi "^6.0.0"
1132211327

11323-
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
11328+
"string-width-cjs@npm:string-width@^4.2.0":
11329+
version "4.2.3"
11330+
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
11331+
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
11332+
dependencies:
11333+
emoji-regex "^8.0.0"
11334+
is-fullwidth-code-point "^3.0.0"
11335+
strip-ansi "^6.0.1"
11336+
11337+
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
1132411338
version "4.2.3"
1132511339
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
1132611340
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -11442,7 +11456,7 @@ stringify-object@^3.3.0:
1144211456
is-obj "^1.0.1"
1144311457
is-regexp "^1.0.0"
1144411458

11445-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
11459+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
1144611460
version "6.0.1"
1144711461
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
1144811462
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -11456,6 +11470,13 @@ strip-ansi@^0.3.0:
1145611470
dependencies:
1145711471
ansi-regex "^0.2.1"
1145811472

11473+
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
11474+
version "6.0.1"
11475+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
11476+
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
11477+
dependencies:
11478+
ansi-regex "^5.0.1"
11479+
1145911480
strip-ansi@^7.0.1, strip-ansi@^7.1.0:
1146011481
version "7.1.0"
1146111482
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -12971,8 +12992,16 @@ [email protected], workbox-window@^7.3.0:
1297112992
"@types/trusted-types" "^2.0.2"
1297212993
workbox-core "7.3.0"
1297312994

12974-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
12975-
name wrap-ansi-cjs
12995+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
12996+
version "7.0.0"
12997+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
12998+
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
12999+
dependencies:
13000+
ansi-styles "^4.0.0"
13001+
string-width "^4.1.0"
13002+
strip-ansi "^6.0.0"
13003+
13004+
wrap-ansi@^7.0.0:
1297613005
version "7.0.0"
1297713006
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
1297813007
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==

0 commit comments

Comments
 (0)