Skip to content

Commit a07f9b6

Browse files
committed
add strict devtools
1 parent b3bff15 commit a07f9b6

File tree

6 files changed

+40
-7
lines changed

6 files changed

+40
-7
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Security-Policy" content="script-src 'self'; worker-src blob:; ">
5+
<title>Plotly.js "strict" Devtools</title>
6+
7+
<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"/>
8+
<link rel="stylesheet" type="text/css" href="./style.css">
9+
</head>
10+
<body>
11+
<header>
12+
<img src="http://images.plot.ly/logo/plotlyjs-logo@2x.png" onClick="Tabs.reload();" />
13+
<span id="reload-time"></span>
14+
15+
<input id="mocks-search" type="text" placeholder="mocks search" />
16+
</header>
17+
18+
<section id="mocks-list"></section>
19+
<div id="plots">
20+
<div id="graph"></div>
21+
</div>
22+
<div id="snapshot"></div>
23+
24+
<script src="../../node_modules/mathjax/MathJax.js?config=TeX-AMS-MML_SVG"></script>
25+
<script charset="utf-8" id="source" src="../../build/plotly.js"></script>
26+
<script charset="utf-8" src="../../build/test_dashboard-bundle.js"></script>
27+
</body>
28+
</html>

devtools/test_dashboard/server.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ var http = require('http');
44
var ecstatic = require('ecstatic');
55
var open = require('open');
66
var browserify = require('browserify');
7+
var minimist = require('minimist');
78

89
var constants = require('../../tasks/util/constants');
910
var makeWatchifiedBundle = require('../../tasks/util/watchified_bundle');
1011
var shortcutPaths = require('../../tasks/util/shortcut_paths');
1112

12-
var PORT = process.argv[2] || 3000;
13-
13+
var args = minimist(process.argv.slice(2), {});
14+
var PORT = args.port || 3000;
15+
var strict = args.strict;
1416

1517
// Create server
1618
var server = http.createServer(ecstatic({
@@ -21,9 +23,9 @@ var server = http.createServer(ecstatic({
2123
}));
2224

2325
// Make watchified bundle for plotly.js
24-
var bundlePlotly = makeWatchifiedBundle(function() {
26+
var bundlePlotly = makeWatchifiedBundle(strict, function() {
2527
// open up browser window on first bundle callback
26-
open('http://localhost:' + PORT + '/devtools/test_dashboard/index.html');
28+
open('http://localhost:' + PORT + '/devtools/test_dashboard/index' + (strict ? '-strict' : '') + '.html');
2729
});
2830

2931
// Bundle devtools code

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"test-requirejs": "node tasks/test_requirejs.js",
5252
"test-plain-obj": "node tasks/test_plain_obj.js",
5353
"test": "npm run test-jasmine -- --nowatch && npm run test-bundle && npm run test-image && npm run test-export && npm run test-syntax && npm run lint",
54+
"strict": "node devtools/test_dashboard/server.js --strict",
5455
"start": "node devtools/test_dashboard/server.js",
5556
"baseline": "node test/image/make_baseline.js",
5657
"noci-baseline": "npm run cibuild && ./tasks/noci_test.sh image && git checkout dist && echo 'Please do not commit unless the change was expected!'",

tasks/util/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function startsWithLowerCase(v) {
1717
}
1818

1919
var pathToPlotlyIndex = path.join(pathToLib, 'index.js');
20+
var pathToPlotlyStrict = path.join(pathToLib, 'index-strict.js');
2021
var mainIndex = fs.readFileSync(pathToPlotlyIndex, 'utf-8');
2122
var allTraces = fs.readdirSync(path.join(pathToSrc, 'traces'))
2223
.filter(startsWithLowerCase);
@@ -179,6 +180,7 @@ module.exports = {
179180
allTraces: allTraces,
180181
mainIndex: mainIndex,
181182
pathToPlotlyIndex: pathToPlotlyIndex,
183+
pathToPlotlyStrict: pathToPlotlyStrict,
182184
pathToPlotlyCore: path.join(pathToSrc, 'core.js'),
183185
pathToPlotlyVersion: path.join(pathToSrc, 'version.js'),
184186
pathToPlotlyBuild: path.join(pathToBuild, 'plotly.js'),

tasks/util/watchified_bundle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ var common = require('./common');
1717
* @param {function} onFirstBundleCallback executed when first bundle is completed
1818
*
1919
*/
20-
module.exports = function makeWatchifiedBundle(onFirstBundleCallback) {
21-
var b = browserify(constants.pathToPlotlyIndex, {
20+
module.exports = function makeWatchifiedBundle(strict, onFirstBundleCallback) {
21+
var b = browserify(strict ? constants.pathToPlotlyStrict : constants.pathToPlotlyIndex, {
2222
debug: true,
2323
standalone: 'Plotly',
2424
ignoreTransform: './tasks/compress_attributes.js',

tasks/watch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ var makeWatchifiedBundle = require('./util/watchified_bundle');
22
var noop = function() {};
33

44
// make a watchified bundle for plotly.js and run it!
5-
var watchifiedBundle = makeWatchifiedBundle(noop);
5+
var watchifiedBundle = makeWatchifiedBundle(false, noop);
66
watchifiedBundle();

0 commit comments

Comments
 (0)