diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-04-20 03:09:25 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-04-24 16:14:29 +0200 |
commit | 82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 (patch) | |
tree | 965f6eb89b84d65a62b49008fd972c004832ccd1 /node_modules/convert-source-map | |
parent | e6e0cbc387c2a77b48e4065c229daa65bf1aa0fa (diff) | |
download | wallet-core-82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8.tar.xz |
Reorganize module loading.
We now use webpack instead of SystemJS, effectively bundling modules
into one file (plus commons chunks) for every entry point. This results
in a much smaller extension size (almost half). Furthermore we use
yarn/npm even for extension run-time dependencies. This relieves us
from manually vendoring and building dependencies. It's also easier to
understand for new developers familiar with node.
Diffstat (limited to 'node_modules/convert-source-map')
-rw-r--r-- | node_modules/convert-source-map/.travis.yml | 8 | ||||
-rw-r--r-- | node_modules/convert-source-map/README.md | 20 | ||||
-rw-r--r-- | node_modules/convert-source-map/example/comment-to-json.js | 6 | ||||
-rw-r--r-- | node_modules/convert-source-map/index.js | 67 | ||||
-rw-r--r-- | node_modules/convert-source-map/package.json | 8 | ||||
-rw-r--r-- | node_modules/convert-source-map/test/comment-regex.js | 9 | ||||
-rw-r--r-- | node_modules/convert-source-map/test/convert-source-map.js | 52 |
7 files changed, 92 insertions, 78 deletions
diff --git a/node_modules/convert-source-map/.travis.yml b/node_modules/convert-source-map/.travis.yml index a55b235f9..86bd20065 100644 --- a/node_modules/convert-source-map/.travis.yml +++ b/node_modules/convert-source-map/.travis.yml @@ -1,5 +1,7 @@ language: node_js node_js: - - 0.8 - - 0.10 - - 0.11
\ No newline at end of file + - "0.10" + - "0.12" + - "4" + - "6" + - "node" diff --git a/node_modules/convert-source-map/README.md b/node_modules/convert-source-map/README.md index 8ce7d4817..2a2b6e7a3 100644 --- a/node_modules/convert-source-map/README.md +++ b/node_modules/convert-source-map/README.md @@ -8,12 +8,12 @@ Converts a source-map from/to different formats and allows adding/changing prop var convert = require('convert-source-map'); var json = convert - .fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9vLmpzIiwic291cmNlcyI6WyJjb25zb2xlLmxvZyhcImhpXCIpOyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=') + .fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQvZm9vLm1pbi5qcyIsInNvdXJjZXMiOlsic3JjL2Zvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=') .toJSON(); var modified = convert - .fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9vLmpzIiwic291cmNlcyI6WyJjb25zb2xlLmxvZyhcImhpXCIpOyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=') - .setProperty('sources', [ 'CONSOLE.LOG("HI");' ]) + .fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQvZm9vLm1pbi5qcyIsInNvdXJjZXMiOlsic3JjL2Zvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=') + .setProperty('sources', [ 'SRC/FOO.JS' ]) .toJSON(); console.log(json); @@ -21,8 +21,8 @@ console.log(modified); ``` ```json -{"version":3,"file":"foo.js","sources":["console.log(\"hi\");"],"names":[],"mappings":"AAAA","sourceRoot":"/"} -{"version":3,"file":"foo.js","sources":["CONSOLE.LOG(\"HI\");"],"names":[],"mappings":"AAAA","sourceRoot":"/"} +{"version":3,"file":"build/foo.min.js","sources":["src/foo.js"],"names":[],"mappings":"AAAA","sourceRoot":"/"} +{"version":3,"file":"build/foo.min.js","sources":["SRC/FOO.JS"],"names":[],"mappings":"AAAA","sourceRoot":"/"} ``` ## API @@ -50,14 +50,10 @@ Returns source map converter from given `filename` by parsing `//# sourceMapping `filename` must point to a file that is found inside the `mapFileDir`. Most tools store this file right next to the generated file, i.e. the one containing the source map. -### fromSource(source[, largeSource]) +### fromSource(source) Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found. -If `largeSource` is set to `true`, an algorithm that does not use regex is applied to find the source map. This is faster and especially useful if you're running into "call stack size exceeded" errors with the default algorithm. - -However, it is less accurate and may match content that isn't a source map comment. - ### fromMapFileSource(source, mapFileDir) Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was @@ -111,11 +107,11 @@ Returns `src` with all source map comments pointing to map files removed. ### commentRegex -Returns the regex used to find source map comments. +Provides __a fresh__ RegExp each time it is accessed. Can be used to find source map comments. ### mapFileCommentRegex -Returns the regex used to find source map comments pointing to map files. +Provides __a fresh__ RegExp each time it is accessed. Can be used to find source map comments pointing to map files. ### generateMapFileComment(file, [options]) diff --git a/node_modules/convert-source-map/example/comment-to-json.js b/node_modules/convert-source-map/example/comment-to-json.js index dfab18617..a9bc2f128 100644 --- a/node_modules/convert-source-map/example/comment-to-json.js +++ b/node_modules/convert-source-map/example/comment-to-json.js @@ -3,12 +3,12 @@ var convert = require('..'); var json = convert - .fromComment('//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9vLmpzIiwic291cmNlcyI6WyJjb25zb2xlLmxvZyhcImhpXCIpOyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=') + .fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQvZm9vLm1pbi5qcyIsInNvdXJjZXMiOlsic3JjL2Zvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=') .toJSON(); var modified = convert - .fromComment('//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9vLmpzIiwic291cmNlcyI6WyJjb25zb2xlLmxvZyhcImhpXCIpOyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=') - .setProperty('sources', [ 'CONSOLE.LOG("HI");' ]) + .fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQvZm9vLm1pbi5qcyIsInNvdXJjZXMiOlsic3JjL2Zvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=') + .setProperty('sources', [ 'SRC/FOO.JS' ]) .toJSON(); console.log(json); diff --git a/node_modules/convert-source-map/index.js b/node_modules/convert-source-map/index.js index 3e6fe2934..e171a673c 100644 --- a/node_modules/convert-source-map/index.js +++ b/node_modules/convert-source-map/index.js @@ -2,11 +2,20 @@ var fs = require('fs'); var path = require('path'); -var commentRx = /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+;)?base64,(.*)$/mg; -var mapFileCommentRx = - //Example (Extra space between slashes added to solve Safari bug. Exclude space in production): - // / /# sourceMappingURL=foo.js.map /*# sourceMappingURL=foo.js.map */ - /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg +Object.defineProperty(exports, 'commentRegex', { + get: function getCommentRegex () { + return /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/mg; + } +}); + +Object.defineProperty(exports, 'mapFileCommentRegex', { + get: function getMapFileCommentRegex () { + //Example (Extra space between slashes added to solve Safari bug. Exclude space in production): + // / /# sourceMappingURL=foo.js.map /*# sourceMappingURL=foo.js.map */ + return /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg; + } +}); + function decodeBase64(base64) { return new Buffer(base64, 'base64').toString(); @@ -19,8 +28,7 @@ function stripComment(sm) { function readFromFileMap(sm, dir) { // NOTE: this will only work on the server since it attempts to read the map file - var r = mapFileCommentRx.exec(sm); - mapFileCommentRx.lastIndex = 0; + var r = exports.mapFileCommentRegex.exec(sm); // for some odd reason //# .. captures in 1 and /* .. */ in 2 var filename = r[1] || r[2]; @@ -44,16 +52,6 @@ function Converter (sm, opts) { this.sourcemap = sm; } -function convertFromLargeSource(content){ - var lines = content.split('\n'); - var line; - // find first line which contains a source map starting at end of content - for (var i = lines.length - 1; i > 0; i--) { - line = lines[i] - if (~line.indexOf('sourceMappingURL=data:')) return exports.fromComment(line); - } -} - Converter.prototype.toJSON = function (space) { return JSON.stringify(this.sourcemap, null, space); }; @@ -65,7 +63,7 @@ Converter.prototype.toBase64 = function () { Converter.prototype.toComment = function (options) { var base64 = this.toBase64(); - var data = 'sourceMappingURL=data:application/json;base64,' + base64; + var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data; }; @@ -113,49 +111,26 @@ exports.fromMapFileComment = function (comment, dir) { }; // Finds last sourcemap comment in file or returns null if none was found -exports.fromSource = function (content, largeSource) { - if (largeSource) { - var res = convertFromLargeSource(content); - return res ? res : null; - } - - var m = content.match(commentRx); - commentRx.lastIndex = 0; +exports.fromSource = function (content) { + var m = content.match(exports.commentRegex); return m ? exports.fromComment(m.pop()) : null; }; // Finds last sourcemap comment in file or returns null if none was found exports.fromMapFileSource = function (content, dir) { - var m = content.match(mapFileCommentRx); - mapFileCommentRx.lastIndex = 0; + var m = content.match(exports.mapFileCommentRegex); return m ? exports.fromMapFileComment(m.pop(), dir) : null; }; exports.removeComments = function (src) { - commentRx.lastIndex = 0; - return src.replace(commentRx, ''); + return src.replace(exports.commentRegex, ''); }; exports.removeMapFileComments = function (src) { - mapFileCommentRx.lastIndex = 0; - return src.replace(mapFileCommentRx, ''); + return src.replace(exports.mapFileCommentRegex, ''); }; exports.generateMapFileComment = function (file, options) { var data = 'sourceMappingURL=' + file; return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data; }; - -Object.defineProperty(exports, 'commentRegex', { - get: function getCommentRegex () { - commentRx.lastIndex = 0; - return commentRx; - } -}); - -Object.defineProperty(exports, 'mapFileCommentRegex', { - get: function getMapFileCommentRegex () { - mapFileCommentRx.lastIndex = 0; - return mapFileCommentRx; - } -}); diff --git a/node_modules/convert-source-map/package.json b/node_modules/convert-source-map/package.json index 4225190e4..6d25f40ab 100644 --- a/node_modules/convert-source-map/package.json +++ b/node_modules/convert-source-map/package.json @@ -1,10 +1,10 @@ { "name": "convert-source-map", - "version": "1.3.0", + "version": "1.5.0", "description": "Converts a source-map from/to different formats and allows adding/changing properties.", "main": "index.js", "scripts": { - "test": "tap test/*.js" + "test": "tap test/*.js --color" }, "repository": { "type": "git", @@ -13,8 +13,8 @@ "homepage": "https://github.com/thlorenz/convert-source-map", "dependencies": {}, "devDependencies": { - "inline-source-map": "~0.3.1", - "tap": "~0.4.13" + "inline-source-map": "~0.6.2", + "tap": "~9.0.0" }, "keywords": [ "convert", diff --git a/node_modules/convert-source-map/test/comment-regex.js b/node_modules/convert-source-map/test/comment-regex.js index 16331ccb8..7e588dad4 100644 --- a/node_modules/convert-source-map/test/comment-regex.js +++ b/node_modules/convert-source-map/test/comment-regex.js @@ -3,17 +3,16 @@ var test = require('tap').test , generator = require('inline-source-map') - , rx = require('..').commentRegex - , mapFileRx = require('..').mapFileCommentRegex + , convert = require('..') function comment(prefix, suffix) { - rx.lastIndex = 0; + var rx = convert.commentRegex; return rx.test(prefix + 'sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix) } function commentWithCharSet(prefix, suffix, sep) { sep = sep || ':'; - rx.lastIndex = 0; + var rx = convert.commentRegex; return rx.test(prefix + 'sourceMappingURL=data:application/json;charset' + sep +'utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix) } @@ -66,7 +65,7 @@ test('comment regex new spec - #', function (t) { }) function mapFileCommentWrap(s1, s2) { - mapFileRx.lastIndex = 0; + var mapFileRx = convert.mapFileCommentRegex; return mapFileRx.test(s1 + 'sourceMappingURL=foo.js.map' + s2) } diff --git a/node_modules/convert-source-map/test/convert-source-map.js b/node_modules/convert-source-map/test/convert-source-map.js index ea243f5f7..d57d69d14 100644 --- a/node_modules/convert-source-map/test/convert-source-map.js +++ b/node_modules/convert-source-map/test/convert-source-map.js @@ -5,7 +5,7 @@ var test = require('tap').test , generator = require('inline-source-map') , convert = require('..') -var gen = generator() +var gen = generator({charset:"utf-8"}) .addMappings('foo.js', [{ original: { line: 2, column: 3 } , generated: { line: 5, column: 10 } }], { line: 5 }) .addGeneratedMappings('bar.js', 'var a = 2;\nconsole.log(a)', { line: 23, column: 22 }) @@ -64,8 +64,8 @@ test('from source', function (t) { , 'foo();' , '' ].join('\n') - , map = '//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' - , otherMap = '//# sourceMappingURL=data:application/json;base64,otherZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + , map = '//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + , otherMap = '//# sourceMappingURL=data:application/json;charset=utf-8;base64,otherZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' function getComment(src) { var map = convert.fromSource(src); @@ -91,8 +91,8 @@ test('from source with a large source', function (t) { , 'foo();' , '' ].join('\n') - , map = '//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' - , otherMap = '//# sourceMappingURL=data:application/json;base64,otherZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + , map = '//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + , otherMap = '//# sourceMappingURL=data:application/json;charset=utf-8;base64,otherZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' function getComment(src) { var map = convert.fromSource(src, true); @@ -211,3 +211,45 @@ test('return null fromSource when largeSource is true', function(t) { ) t.end() }) + +test('commentRegex returns new RegExp on each get', function(t) { + var foo = [ + 'function foo() {' + , ' console.log("hello I am foo");' + , ' console.log("who are you");' + , '}' + , '' + , 'foo();' + , '' + ].join('\n') + , map = '//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + , re = convert.commentRegex + + re.exec(foo + map) + + t.equal(re.lastIndex, 372, 'has an updated lastIndex') + t.equal(convert.commentRegex.lastIndex, 0, 'a fresh RegExp has lastIndex of 0') + + t.end() +}) + +test('mapFileCommentRegex returns new RegExp on each get', function(t) { + var foo = [ + 'function foo() {' + , ' console.log("hello I am foo");' + , ' console.log("who are you");' + , '}' + , '' + , 'foo();' + , '' + ].join('\n') + , map = '//# sourceMappingURL=foo.js.map' + , re = convert.mapFileCommentRegex + + re.exec(foo + map) + + t.equal(re.lastIndex, 119, 'has an updated lastIndex') + t.equal(convert.mapFileCommentRegex.lastIndex, 0, 'a fresh RegExp has lastIndex of 0') + + t.end() +}) |