Skip to content

Commit d6df77f

Browse files
authored
Merge pull request #7777 from plotly/cam/7776/update-devtools-script
chore: Update devtools scripts to avoid opening browser window
2 parents a405dde + 120327b commit d6df77f

8 files changed

Lines changed: 25 additions & 46 deletions

File tree

CONTRIBUTING.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,9 @@ making changes that affect the usage of regl shaders, you would need to run
169169
npm run regl-codegen
170170
```
171171

172-
to regenerate the regl code. This opens a browser window, runs through all
173-
traces with 'regl' in the tags, and stores the captured code into
174-
[src/generated/regl-codegen](https://github.com/plotly/plotly.js/blob/master/src/generated/regl-codegen). If no updates are necessary, it would be a no-op, but
175-
if there are changes, you would need to commit them.
172+
to regenerate the regl code. This will prompt you to open a browser window. This will then run through all
173+
traces with 'regl' in the tags, and store the captured code into
174+
[src/generated/regl-codegen](https://github.com/plotly/plotly.js/blob/master/src/generated/regl-codegen). If no updates are necessary, it will be a no-op, but if there are changes, you will need to commit them.
176175

177176
This is needed because regl performs codegen in runtime which breaks CSP
178177
compliance, and so for strict builds we pre-generate regl shader code here.

devtools/regl_codegen/index.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<!DOCTYPE html>
22
<html>
3+
34
<head>
4-
<title>REGL Codegen</title>
5-
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Droid+Sans|PT+Sans+Narrow|Gravitas+One|Droid+Sans+Mono|Droid+Serif|Raleway|Old+Standard+TT"/>
5+
<title>Plotly.js Devtools- REGL Codegen</title>
6+
<meta charset="utf-8">
7+
<link rel="stylesheet" type="text/css"
8+
href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Droid+Sans|PT+Sans+Narrow|Gravitas+One|Droid+Sans+Mono|Droid+Serif|Raleway|Old+Standard+TT" />
69
<link rel="stylesheet" type="text/css" href="../test_dashboard/style.css">
710
</head>
11+
812
<body>
913
<section id="mocks-list"></section>
1014
<div id="plots">
@@ -13,7 +17,8 @@
1317
<div id="snapshot"></div>
1418

1519
<script src="../../node_modules/mathjax/MathJax.js?config=TeX-AMS-MML_SVG"></script>
16-
<script charset="utf-8" id="source" type="module">import "../../build/plotly.js"</script>
20+
<script charset="utf-8" id="source" src="../../build/plotly.js"></script>
1721
<script charset="utf-8" src="../../build/regl_codegen-bundle.js"></script>
1822
</body>
23+
1924
</html>

devtools/regl_codegen/server.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { build } from 'esbuild';
33
import fs from 'fs';
44
import http from 'http';
55
import minimist from 'minimist';
6-
import open from 'open';
76
import path from 'path';
87
import { localDevReglCodegenConfig as config } from '../../esbuild-config.js';
98
import constants from '../../tasks/util/constants.js';
@@ -17,7 +16,6 @@ import {
1716

1817
var args = minimist(process.argv.slice(2), {});
1918
var PORT = args.port || 3000;
20-
var strict = args.strict;
2119

2220
var reglTraceList = ['parcoords', 'scattergl', 'scatterpolargl', 'splom'];
2321

@@ -68,7 +66,10 @@ await getMockFiles()
6866
server.listen(PORT);
6967

7068
// open up browser window
71-
open('http://localhost:' + PORT + '/devtools/regl_codegen/index' + (strict ? '-strict' : '') + '.html');
69+
const serverUrl = `http://localhost:${PORT}/devtools/regl_codegen/index.html`;
70+
console.log('\x1b[31mOpen the following link to launch a browser window and precompile the regl shaders.');
71+
console.log('This can be processor and memory intensive.\x1b[0m\n');
72+
console.log(` \x1b[1m\x1b[32m➜\x1b[0m \x1b[1mLocal:\x1b[0m \x1b[1m\x1b[36m${serverUrl}\x1b[0m\n`);
7273

7374
await build(config);
7475

devtools/test_dashboard/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<!DOCTYPE html>
22
<html>
3+
34
<head>
45
<title>Plotly.js Devtools</title>
56
<meta charset="utf-8">
6-
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Droid+Sans|PT+Sans+Narrow|Gravitas+One|Droid+Sans+Mono|Droid+Serif|Raleway|Old+Standard+TT"/>
7+
<link rel="stylesheet" type="text/css"
8+
href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Droid+Sans|PT+Sans+Narrow|Gravitas+One|Droid+Sans+Mono|Droid+Serif|Raleway|Old+Standard+TT" />
79
<link rel="stylesheet" type="text/css" href="./style.css">
810
</head>
11+
912
<body>
1013
<header>
1114
<img src="http://images.plot.ly/logo/plotlyjs-logo@2x.png" onClick="Tabs.reload();" />
@@ -23,9 +26,10 @@
2326

2427
<!-- Update UI elements if strict mode is enabled -->
2528
<script src="./strict.js"></script>
26-
29+
2730
<script src="../../node_modules/@plotly/mathjax-v2/MathJax.js?config=TeX-AMS-MML_SVG"></script>
2831
<script charset="utf-8" id="source" src="../../build/plotly.js"></script>
2932
<script charset="utf-8" src="../../build/test_dashboard-bundle.js"></script>
3033
</body>
34+
3135
</html>

devtools/test_dashboard/server.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import ecstatic from 'ecstatic';
22
import { build, context } from 'esbuild';
33
import http from 'http';
44
import minimist from 'minimist';
5-
import open from 'open';
65
import { devtoolsConfig, localDevConfig } from '../../esbuild-config.js';
76
import constants from '../../tasks/util/constants.js';
87
import { createMocksList, getMockFiles, readFiles, saveMockListToFile } from '../dashboard_utilities.mjs';
@@ -64,5 +63,6 @@ function devServer() {
6463
indexName += '.html';
6564

6665
// open up browser window
67-
open(`http://localhost:${PORT}/devtools/test_dashboard/${indexName}${strict ? '?strict=true' : ''}`);
66+
const serverUrl = `http://localhost:${PORT}/devtools/test_dashboard/${indexName}${strict ? '?strict=true' : ''}`;
67+
console.log(` \x1b[1m\x1b[32m➜\x1b[0m \x1b[1mLocal:\x1b[0m \x1b[1m\x1b[36m${serverUrl}\x1b[0m\n`);
6868
}

esbuild-config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ const localDevConfig = {
4747

4848
// Config used when building bundle to serve regl
4949
const localDevReglCodegenConfig = {
50-
...esbuildConfig,
50+
...devtoolsConfig,
5151
entryPoints: [path.join(constants.pathToRoot, 'devtools/regl_codegen', 'devtools.js')],
52-
outfile: './build/regl_codegen-bundle.js',
53-
sourcemap: false,
54-
minify: false
52+
outfile: './build/regl_codegen-bundle.js'
5553
};
5654

5755
module.exports = {

package-lock.json

Lines changed: 0 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@
161161
"madge": "^8.0.0",
162162
"minify-stream": "^2.1.0",
163163
"npm-link-check": "^5.0.1",
164-
"open": "^8.4.2",
165164
"pixelmatch": "^7.1.0",
166165
"prepend-file": "^2.0.1",
167166
"prettysize": "^2.0.0",

0 commit comments

Comments
 (0)