Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ jobs:
echo https://$CIRCLE_BUILD_NUM-$PROJECT_NUM-gh.circle-artifacts.com/0/dist/plotly.js
echo https://$CIRCLE_BUILD_NUM-$PROJECT_NUM-gh.circle-artifacts.com/0/dist/plotly.min.js
echo https://$CIRCLE_BUILD_NUM-$PROJECT_NUM-gh.circle-artifacts.com/0/dist/plot-schema.json
- run:
name: Test certain bundles against function constructors
command: npm run no-new-func
- run:
name: Test plotly bundles againt unexpected characters
command: npm run no-bad-char
- run:
name: Test certain bundles against function constructors
command: npm run no-new-func

workflows:
version: 2
Expand Down
3 changes: 1 addition & 2 deletions lib/index-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ Plotly.register([
require('./pie')
]);

require('./register_extra')(Plotly);
module.exports = Plotly;
module.exports = require('./register_extra')(Plotly);
3 changes: 1 addition & 2 deletions lib/index-cartesian.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ Plotly.register([
require('./violin')
]);

require('./register_extra')(Plotly);
module.exports = Plotly;
module.exports = require('./register_extra')(Plotly);
3 changes: 1 addition & 2 deletions lib/index-finance.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ Plotly.register([
require('./indicator')
]);

require('./register_extra')(Plotly);
module.exports = Plotly;
module.exports = require('./register_extra')(Plotly);
3 changes: 1 addition & 2 deletions lib/index-geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ Plotly.register([
require('./choropleth')
]);

require('./register_extra')(Plotly);
module.exports = Plotly;
module.exports = require('./register_extra')(Plotly);
3 changes: 1 addition & 2 deletions lib/index-gl2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ Plotly.register([
require('./parcoords')
]);

require('./register_extra')(Plotly);
module.exports = Plotly;
module.exports = require('./register_extra')(Plotly);
3 changes: 1 addition & 2 deletions lib/index-gl3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ Plotly.register([
require('./streamtube')
]);

require('./register_extra')(Plotly);
module.exports = Plotly;
module.exports = require('./register_extra')(Plotly);
3 changes: 1 addition & 2 deletions lib/index-mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ Plotly.register([
require('./densitymapbox')
]);

require('./register_extra')(Plotly);
module.exports = Plotly;
module.exports = require('./register_extra')(Plotly);
3 changes: 1 addition & 2 deletions lib/index-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@ Plotly.register([
require('./barpolar')
]);

require('./register_extra')(Plotly);
module.exports = Plotly;
module.exports = require('./register_extra')(Plotly);
3 changes: 1 addition & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,4 @@ Plotly.register([
require('./barpolar')
]);

require('./register_extra')(Plotly);
module.exports = Plotly;
module.exports = require('./register_extra')(Plotly);
2 changes: 2 additions & 0 deletions lib/register_extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ module.exports = function registerExtra(Plotly) {
Plotly.register([
require('./calendars')
]);

return Plotly;
};
44 changes: 27 additions & 17 deletions tasks/compress_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,46 @@ var through = require('through2');

// one line string with or without trailing comma
function makeStringRegex(attr) {
return attr + ': \'.*\'' + ',?';
return makeRegex(
attr + ': \'.*\'' + ',?'
);
}

// joined array of strings with or without trailing comma
function makeJoinedArrayRegex(attr) {
return attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + ',?';
return makeRegex(
attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + ',?'
);
}

// array with or without trailing comma
function makeArrayRegex(attr) {
return attr + ': \\[[\\s\\S]*?\\]' + ',?';
return makeRegex(
attr + ': \\[[\\s\\S]*?\\]' + ',?'
);
}

// ref: http://www.regexr.com/3cmac
var regexStr = [
makeStringRegex('description'),
makeJoinedArrayRegex('description'),
makeArrayRegex('requiredOpts'),
makeArrayRegex('otherOpts'),
makeStringRegex('hrName')
].join('|');

var regex = new RegExp(regexStr, 'g');
function makeRegex(regexStr) {
return (
new RegExp(regexStr, 'g')
);
}

module.exports = function() {
return through(function(buf, enc, next) {
var allChunks = [];
return through(function(chunk, enc, next) {
allChunks.push(chunk);
next();
}, function(done) {
var str = Buffer.concat(allChunks).toString('utf-8');
this.push(
buf.toString('utf-8')
.replace(regex, '')
str
.replace(makeStringRegex('description'), '')
.replace(makeJoinedArrayRegex('description'), '')
.replace(makeArrayRegex('requiredOpts'), '')
.replace(makeArrayRegex('otherOpts'), '')
.replace(makeStringRegex('hrName'), '')
);
next();
done();
});
};