init
This commit is contained in:
16
node_modules/combine-source-map/.npmignore
generated
vendored
Normal file
16
node_modules/combine-source-map/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
|
||||
node_modules
|
||||
npm-debug.log
|
||||
tmp
|
8
node_modules/combine-source-map/.travis.yml
generated
vendored
Normal file
8
node_modules/combine-source-map/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "iojs-v2.4"
|
||||
before_install:
|
||||
- npm install --global npm
|
23
node_modules/combine-source-map/LICENSE
generated
vendored
Normal file
23
node_modules/combine-source-map/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Copyright 2013 Thorsten Lorenz.
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
111
node_modules/combine-source-map/README.md
generated
vendored
Normal file
111
node_modules/combine-source-map/README.md
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
# combine-source-map [](http://travis-ci.org/thlorenz/combine-source-map)
|
||||
|
||||
Add source maps of multiple files, offset them and then combine them into one source map.
|
||||
|
||||
```js
|
||||
var convert = require('convert-source-map');
|
||||
var combine = require('combine-source-map');
|
||||
|
||||
var fooComment = '//# sourceMappingURL=data:application/json;base64,eyJ2Z [..] pzJylcbiJdfQ==';
|
||||
var barComment = '//# sourceMappingURL=data:application/json;base64,eyJ2Z [..] VjaycpXG4iXX0=';
|
||||
|
||||
var fooFile = {
|
||||
source: '(function() {\n\n console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + fooComment
|
||||
, sourceFile: 'foo.js'
|
||||
};
|
||||
var barFile = {
|
||||
source: '(function() {\n\n console.log(alert(\'alerts suck\'));\n\n}).call(this);\n' + '\n' + barComment
|
||||
, sourceFile: 'bar.js'
|
||||
};
|
||||
|
||||
var offset = { line: 2 };
|
||||
var base64 = combine
|
||||
.create('bundle.js')
|
||||
.addFile(fooFile, offset)
|
||||
.addFile(barFile, { line: offset.line + 8 })
|
||||
.base64();
|
||||
|
||||
var sm = convert.fromBase64(base64).toObject();
|
||||
console.log(sm);
|
||||
```
|
||||
|
||||
```
|
||||
{ version: 3,
|
||||
file: 'bundle.js',
|
||||
sources: [ 'foo.coffee', 'bar.coffee' ],
|
||||
names: [],
|
||||
mappings: ';;;AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ;;;;;ACAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ',
|
||||
sourcesContent:
|
||||
[ 'console.log(require \'./bar.js\')\n',
|
||||
'console.log(alert \'alerts suck\')\n' ] }
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
npm install combine-source-map
|
||||
|
||||
## API
|
||||
|
||||
### create()
|
||||
|
||||
```
|
||||
/**
|
||||
* @name create
|
||||
* @function
|
||||
* @param file {String} optional name of the generated file
|
||||
* @param sourceRoot { String} optional sourceRoot of the map to be generated
|
||||
* @return {Object} Combiner instance to which source maps can be added and later combined
|
||||
*/
|
||||
```
|
||||
|
||||
### Combiner.prototype.addFile(opts, offset)
|
||||
|
||||
```
|
||||
/**
|
||||
* Adds map to underlying source map.
|
||||
* If source contains a source map comment that has the source of the original file inlined it will offset these
|
||||
* mappings and include them.
|
||||
* If no source map comment is found or it has no source inlined, mappings for the file will be generated and included
|
||||
*
|
||||
* @name addMap
|
||||
* @function
|
||||
* @param opts {Object} { sourceFile: {String}, source: {String} }
|
||||
* @param offset {Object} { line: {Number}, column: {Number} }
|
||||
*/
|
||||
```
|
||||
|
||||
### Combiner.prototype.base64()
|
||||
|
||||
```
|
||||
/**
|
||||
* @name base64
|
||||
* @function
|
||||
* @return {String} base64 encoded combined source map
|
||||
*/
|
||||
```
|
||||
|
||||
### Combiner.prototype.comment()
|
||||
|
||||
```
|
||||
/**
|
||||
* @name comment
|
||||
* @function
|
||||
* @return {String} base64 encoded sourceMappingUrl comment of the combined source map
|
||||
*/
|
||||
```
|
||||
|
||||
### removeComments(src)
|
||||
|
||||
```
|
||||
/**
|
||||
* @name removeComments
|
||||
* @function
|
||||
* @param src
|
||||
* @return {String} src with all sourceMappingUrl comments removed
|
||||
*/
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
Read and run the [more elaborate example](https://github.com/thlorenz/combine-source-map/blob/master/example/two-files.js)
|
||||
in order to get a better idea how things work.
|
26
node_modules/combine-source-map/example/two-files-short.js
generated
vendored
Normal file
26
node_modules/combine-source-map/example/two-files-short.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
var convert = require('convert-source-map');
|
||||
var combine = require('..');
|
||||
|
||||
var fooComment = '//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9vLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZm9vLmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Q0FBQTtDQUFBLENBQUEsQ0FBQSxJQUFPLEdBQUs7Q0FBWiIsInNvdXJjZXNDb250ZW50IjpbImNvbnNvbGUubG9nKHJlcXVpcmUgJy4vYmFyLmpzJylcbiJdfQ==';
|
||||
var barComment = '//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiYmFyLmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Q0FBQTtDQUFBLENBQUEsQ0FBQSxJQUFPLEdBQUs7Q0FBWiIsInNvdXJjZXNDb250ZW50IjpbImNvbnNvbGUubG9nKGFsZXJ0ICdhbGVydHMgc3VjaycpXG4iXX0=';
|
||||
|
||||
var fooFile = {
|
||||
source: '(function() {\n\n console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + fooComment
|
||||
, sourceFile: 'foo.js'
|
||||
};
|
||||
var barFile = {
|
||||
source: '(function() {\n\n console.log(alert(\'alerts suck\'));\n\n}).call(this);\n' + '\n' + barComment
|
||||
, sourceFile: 'bar.js'
|
||||
};
|
||||
|
||||
var offset = { line: 2 };
|
||||
var base64 = combine
|
||||
.create('bundle.js')
|
||||
.addFile(fooFile, offset)
|
||||
.addFile(barFile, { line: offset.line + 8 })
|
||||
.base64();
|
||||
|
||||
var sm = convert.fromBase64(base64).toObject();
|
||||
console.log(sm);
|
46
node_modules/combine-source-map/example/two-files.js
generated
vendored
Normal file
46
node_modules/combine-source-map/example/two-files.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
var convert = require('convert-source-map');
|
||||
var combine = require('..');
|
||||
|
||||
var foo = {
|
||||
version : 3,
|
||||
file : 'foo.js',
|
||||
sourceRoot : '',
|
||||
sources : [ 'foo.coffee' ],
|
||||
names : [],
|
||||
mappings : ';AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ',
|
||||
sourcesContent : [ 'console.log(require \'./bar.js\')\n' ] };
|
||||
|
||||
var bar = {
|
||||
version : 3,
|
||||
file : 'bar.js',
|
||||
sourceRoot : '',
|
||||
sources : [ 'bar.coffee' ],
|
||||
names : [],
|
||||
mappings : ';AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ',
|
||||
sourcesContent : [ 'console.log(alert \'alerts suck\')\n' ] };
|
||||
|
||||
|
||||
var fooComment = convert.fromObject(foo).toComment();
|
||||
var barComment = convert.fromObject(bar).toComment();
|
||||
|
||||
var fooFile = {
|
||||
source: '(function() {\n\n console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + fooComment
|
||||
, sourceFile: 'foo.js'
|
||||
};
|
||||
var barFile = {
|
||||
source: '(function() {\n\n console.log(alert(\'alerts suck\'));\n\n}).call(this);\n' + '\n' + barComment
|
||||
, sourceFile: 'bar.js'
|
||||
};
|
||||
|
||||
var offset = { line: 2 };
|
||||
var base64 = combine
|
||||
.create('bundle.js')
|
||||
.addFile(fooFile, offset)
|
||||
.addFile(barFile, { line: offset.line + 8 })
|
||||
.base64();
|
||||
|
||||
var sm = convert.fromBase64(base64).toObject();
|
||||
console.log('Combined source maps:\n', sm);
|
||||
console.log('\nMappings:\n', sm.mappings);
|
155
node_modules/combine-source-map/index.js
generated
vendored
Normal file
155
node_modules/combine-source-map/index.js
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var convert = require('convert-source-map');
|
||||
var memoize = require('lodash.memoize');
|
||||
var createGenerator = require('inline-source-map');
|
||||
var pathIsAbsolute = require('./lib/path-is-absolute');
|
||||
var mappingsFromMap = require('./lib/mappings-from-map');
|
||||
|
||||
var protocolRx = /^[a-z]+:\/\//;
|
||||
|
||||
/**
|
||||
* Rebases a relative path in 'sourceFile' to be relative
|
||||
* to the path where 'sourceFile' is located.
|
||||
*
|
||||
* This is necessary before adding relative paths to the
|
||||
* new combined map to ensure all paths are relative to their
|
||||
* original source.
|
||||
*
|
||||
* The 'sourceRoot' from the original source map is joined
|
||||
* as well to ensure the complete path.
|
||||
*
|
||||
* Resulting paths that are absolute are passed along directly.
|
||||
*
|
||||
* @param sourceFile {String} path to the original source file that references a map
|
||||
* @param relativeRoot {String} sourceRoot in sourceFile's map to combine with relativePath
|
||||
* @param relativePath {String} source path from sourceFile's map
|
||||
*/
|
||||
var rebaseRelativePath = memoize(function(sourceFile, relativeRoot, relativePath) {
|
||||
if (!relativePath) {
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
// join relative path to root (e.g. 'src/' + 'file.js')
|
||||
var relativeRootedPath = relativeRoot ? path.join(relativeRoot, relativePath) : relativePath;
|
||||
relativeRootedPath = relativeRootedPath.replace(/\\/g, '/');
|
||||
sourceFile = sourceFile.replace(/\\/g, '/');
|
||||
|
||||
if (sourceFile === relativeRootedPath || // same path,
|
||||
pathIsAbsolute(relativeRootedPath) || // absolute path, nor
|
||||
protocolRx.test(relativeRootedPath)) { // absolute protocol need rebasing
|
||||
return relativeRootedPath;
|
||||
}
|
||||
|
||||
// make relative to source file
|
||||
return path.join(path.dirname(sourceFile), relativeRootedPath).replace(/\\/g, '/');
|
||||
}, function(a, b, c) {
|
||||
return a + '::' + b + '::' + c;
|
||||
});
|
||||
|
||||
function resolveMap(source) {
|
||||
var gen = convert.fromSource(source);
|
||||
return gen ? gen.toObject() : null;
|
||||
}
|
||||
|
||||
function hasInlinedSource(existingMap) {
|
||||
return existingMap.sourcesContent && !!existingMap.sourcesContent[0];
|
||||
}
|
||||
|
||||
function Combiner(file, sourceRoot) {
|
||||
// since we include the original code in the map sourceRoot actually not needed
|
||||
this.generator = createGenerator({ file: file || 'generated.js', sourceRoot: sourceRoot });
|
||||
}
|
||||
|
||||
Combiner.prototype._addGeneratedMap = function (sourceFile, source, offset) {
|
||||
this.generator.addGeneratedMappings(sourceFile, source, offset);
|
||||
this.generator.addSourceContent(sourceFile, source);
|
||||
return this;
|
||||
};
|
||||
|
||||
Combiner.prototype._addExistingMap = function (sourceFile, source, existingMap, offset) {
|
||||
var mappings = mappingsFromMap(existingMap);
|
||||
|
||||
// add all of the sources from the map
|
||||
for (var i = 0, len = existingMap.sources.length; i < len; i++) {
|
||||
if (!existingMap.sourcesContent) continue;
|
||||
|
||||
this.generator.addSourceContent(
|
||||
rebaseRelativePath(sourceFile, existingMap.sourceRoot, existingMap.sources[i]),
|
||||
existingMap.sourcesContent[i]);
|
||||
}
|
||||
|
||||
// add the mappings, preserving the original mapping 'source'
|
||||
mappings.forEach(function(mapping) {
|
||||
// Add the mappings one at a time because 'inline-source-map' doesn't handle
|
||||
// mapping source filenames. The mapping.source already takes sourceRoot into account
|
||||
// per the SMConsumer.eachMapping function, so pass null for the root here.
|
||||
this.generator.addMappings(
|
||||
rebaseRelativePath(sourceFile, null, mapping.source), [mapping], offset);
|
||||
}, this);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds map to underlying source map.
|
||||
* If source contains a source map comment that has the source of the original file inlined it will offset these
|
||||
* mappings and include them.
|
||||
* If no source map comment is found or it has no source inlined, mappings for the file will be generated and included
|
||||
*
|
||||
* @name addMap
|
||||
* @function
|
||||
* @param opts {Object} { sourceFile: {String}, source: {String} }
|
||||
* @param offset {Object} { line: {Number}, column: {Number} }
|
||||
*/
|
||||
Combiner.prototype.addFile = function (opts, offset) {
|
||||
|
||||
offset = offset || {};
|
||||
if (!offset.hasOwnProperty('line')) offset.line = 0;
|
||||
if (!offset.hasOwnProperty('column')) offset.column = 0;
|
||||
|
||||
var existingMap = resolveMap(opts.source);
|
||||
|
||||
return existingMap && hasInlinedSource(existingMap)
|
||||
? this._addExistingMap(opts.sourceFile, opts.source, existingMap, offset)
|
||||
: this._addGeneratedMap(opts.sourceFile, opts.source, offset);
|
||||
};
|
||||
|
||||
/**
|
||||
* @name base64
|
||||
* @function
|
||||
* @return {String} base64 encoded combined source map
|
||||
*/
|
||||
Combiner.prototype.base64 = function () {
|
||||
return this.generator.base64Encode();
|
||||
};
|
||||
|
||||
/**
|
||||
* @name comment
|
||||
* @function
|
||||
* @return {String} base64 encoded sourceMappingUrl comment of the combined source map
|
||||
*/
|
||||
Combiner.prototype.comment = function () {
|
||||
return this.generator.inlineMappingUrl();
|
||||
};
|
||||
|
||||
/**
|
||||
* @name create
|
||||
* @function
|
||||
* @param file {String} optional name of the generated file
|
||||
* @param sourceRoot {String} optional sourceRoot of the map to be generated
|
||||
* @return {Object} Combiner instance to which source maps can be added and later combined
|
||||
*/
|
||||
exports.create = function (file, sourceRoot) { return new Combiner(file, sourceRoot); };
|
||||
|
||||
/**
|
||||
* @name removeComments
|
||||
* @function
|
||||
* @param src
|
||||
* @return {String} src with all sourceMappingUrl comments removed
|
||||
*/
|
||||
exports.removeComments = function (src) {
|
||||
if (!src.replace) return src;
|
||||
return src.replace(convert.commentRegex, '').replace(convert.mapFileCommentRegex, '');
|
||||
};
|
30
node_modules/combine-source-map/lib/mappings-from-map.js
generated
vendored
Normal file
30
node_modules/combine-source-map/lib/mappings-from-map.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
var SMConsumer = require('source-map').SourceMapConsumer;
|
||||
|
||||
/**
|
||||
* @name mappingsFromMap
|
||||
* @function
|
||||
* @param map {Object} the JSON.parse()'ed map
|
||||
* @return {Array} array of mappings
|
||||
*/
|
||||
module.exports = function (map) {
|
||||
var consumer = new SMConsumer(map);
|
||||
var mappings = [];
|
||||
|
||||
consumer.eachMapping(function (mapping) {
|
||||
// only set source if we have original position to handle edgecase (see inline-source-map tests)
|
||||
mappings.push({
|
||||
original: mapping.originalColumn != null ? {
|
||||
column: mapping.originalColumn
|
||||
, line: mapping.originalLine
|
||||
} : undefined
|
||||
, generated: {
|
||||
column: mapping.generatedColumn
|
||||
, line: mapping.generatedLine
|
||||
}
|
||||
, source: mapping.originalColumn != null ? mapping.source : undefined
|
||||
, name: mapping.name
|
||||
});
|
||||
});
|
||||
|
||||
return mappings;
|
||||
}
|
20
node_modules/combine-source-map/lib/path-is-absolute.js
generated
vendored
Normal file
20
node_modules/combine-source-map/lib/path-is-absolute.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
function posix(path) {
|
||||
return path.charAt(0) === '/';
|
||||
};
|
||||
|
||||
function win32(path) {
|
||||
// https://github.com/joyent/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
|
||||
var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
|
||||
var result = splitDeviceRe.exec(path);
|
||||
var device = result[1] || '';
|
||||
var isUnc = !!device && device.charAt(1) !== ':';
|
||||
|
||||
// UNC paths are always absolute
|
||||
return !!result[2] || isUnc;
|
||||
};
|
||||
|
||||
module.exports = process.platform === 'win32' ? win32 : posix;
|
||||
module.exports.posix = posix;
|
||||
module.exports.win32 = win32;
|
21
node_modules/combine-source-map/lib/path-is-absolute.license
generated
vendored
Normal file
21
node_modules/combine-source-map/lib/path-is-absolute.license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
16
node_modules/combine-source-map/node_modules/convert-source-map/.npmignore
generated
vendored
Normal file
16
node_modules/combine-source-map/node_modules/convert-source-map/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
|
||||
node_modules
|
||||
npm-debug.log
|
||||
tmp
|
5
node_modules/combine-source-map/node_modules/convert-source-map/.travis.yml
generated
vendored
Normal file
5
node_modules/combine-source-map/node_modules/convert-source-map/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
- 0.10
|
||||
- 0.11
|
23
node_modules/combine-source-map/node_modules/convert-source-map/LICENSE
generated
vendored
Normal file
23
node_modules/combine-source-map/node_modules/convert-source-map/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Copyright 2013 Thorsten Lorenz.
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
121
node_modules/combine-source-map/node_modules/convert-source-map/README.md
generated
vendored
Normal file
121
node_modules/combine-source-map/node_modules/convert-source-map/README.md
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
# convert-source-map [](http://travis-ci.org/thlorenz/convert-source-map)
|
||||
|
||||
[](https://nodei.co/npm/convert-source-map/)
|
||||
|
||||
Converts a source-map from/to different formats and allows adding/changing properties.
|
||||
|
||||
```js
|
||||
var convert = require('convert-source-map');
|
||||
|
||||
var json = convert
|
||||
.fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9vLmpzIiwic291cmNlcyI6WyJjb25zb2xlLmxvZyhcImhpXCIpOyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=')
|
||||
.toJSON();
|
||||
|
||||
var modified = convert
|
||||
.fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9vLmpzIiwic291cmNlcyI6WyJjb25zb2xlLmxvZyhcImhpXCIpOyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=')
|
||||
.setProperty('sources', [ 'CONSOLE.LOG("HI");' ])
|
||||
.toJSON();
|
||||
|
||||
console.log(json);
|
||||
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":"/"}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### fromObject(obj)
|
||||
|
||||
Returns source map converter from given object.
|
||||
|
||||
### fromJSON(json)
|
||||
|
||||
Returns source map converter from given json string.
|
||||
|
||||
### fromBase64(base64)
|
||||
|
||||
Returns source map converter from given base64 encoded json string.
|
||||
|
||||
### fromComment(comment)
|
||||
|
||||
Returns source map converter from given base64 encoded json string prefixed with `//# sourceMappingURL=...`.
|
||||
|
||||
### fromMapFileComment(comment, mapFileDir)
|
||||
|
||||
Returns source map converter from given `filename` by parsing `//# sourceMappingURL=filename`.
|
||||
|
||||
`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])
|
||||
|
||||
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
|
||||
found.
|
||||
|
||||
The sourcemap will be read from the map file found by parsing `# sourceMappingURL=file` comment. For more info see
|
||||
fromMapFileComment.
|
||||
|
||||
### toObject()
|
||||
|
||||
Returns a copy of the underlying source map.
|
||||
|
||||
### toJSON([space])
|
||||
|
||||
Converts source map to json string. If `space` is given (optional), this will be passed to
|
||||
[JSON.stringify](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify) when the
|
||||
JSON string is generated.
|
||||
|
||||
### toBase64()
|
||||
|
||||
Converts source map to base64 encoded json string.
|
||||
|
||||
### toComment([options])
|
||||
|
||||
Converts source map to an inline comment that can be appended to the source-file.
|
||||
|
||||
By default, the comment is formatted like: `//# sourceMappingURL=...`, which you would
|
||||
normally see in a JS source file.
|
||||
|
||||
When `options.multiline == true`, the comment is formatted like: `/*# sourceMappingURL=... */`, which you would find in a CSS source file.
|
||||
|
||||
### addProperty(key, value)
|
||||
|
||||
Adds given property to the source map. Throws an error if property already exists.
|
||||
|
||||
### setProperty(key, value)
|
||||
|
||||
Sets given property to the source map. If property doesn't exist it is added, otherwise its value is updated.
|
||||
|
||||
### getProperty(key)
|
||||
|
||||
Gets given property of the source map.
|
||||
|
||||
### removeComments(src)
|
||||
|
||||
Returns `src` with all source map comments removed
|
||||
|
||||
### removeMapFileComments(src)
|
||||
|
||||
Returns `src` with all source map comments pointing to map files removed.
|
||||
|
||||
### commentRegex
|
||||
|
||||
Returns the regex used to find source map comments.
|
||||
|
||||
### mapFileCommentRegex
|
||||
|
||||
Returns the regex used to find source map comments pointing to map files.
|
||||
|
||||
|
||||
[](https://bitdeli.com/free "Bitdeli Badge")
|
15
node_modules/combine-source-map/node_modules/convert-source-map/example/comment-to-json.js
generated
vendored
Normal file
15
node_modules/combine-source-map/node_modules/convert-source-map/example/comment-to-json.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
var convert = require('..');
|
||||
|
||||
var json = convert
|
||||
.fromComment('//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9vLmpzIiwic291cmNlcyI6WyJjb25zb2xlLmxvZyhcImhpXCIpOyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=')
|
||||
.toJSON();
|
||||
|
||||
var modified = convert
|
||||
.fromComment('//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9vLmpzIiwic291cmNlcyI6WyJjb25zb2xlLmxvZyhcImhpXCIpOyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=')
|
||||
.setProperty('sources', [ 'CONSOLE.LOG("HI");' ])
|
||||
.toJSON();
|
||||
|
||||
console.log(json);
|
||||
console.log(modified);
|
156
node_modules/combine-source-map/node_modules/convert-source-map/index.js
generated
vendored
Normal file
156
node_modules/combine-source-map/node_modules/convert-source-map/index.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
'use strict';
|
||||
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
|
||||
|
||||
function decodeBase64(base64) {
|
||||
return new Buffer(base64, 'base64').toString();
|
||||
}
|
||||
|
||||
function stripComment(sm) {
|
||||
return sm.split(',').pop();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// for some odd reason //# .. captures in 1 and /* .. */ in 2
|
||||
var filename = r[1] || r[2];
|
||||
var filepath = path.join(dir, filename);
|
||||
|
||||
try {
|
||||
return fs.readFileSync(filepath, 'utf8');
|
||||
} catch (e) {
|
||||
throw new Error('An error occurred while trying to read the map file at ' + filepath + '\n' + e);
|
||||
}
|
||||
}
|
||||
|
||||
function Converter (sm, opts) {
|
||||
opts = opts || {};
|
||||
|
||||
if (opts.isFileComment) sm = readFromFileMap(sm, opts.commentFileDir);
|
||||
if (opts.hasComment) sm = stripComment(sm);
|
||||
if (opts.isEncoded) sm = decodeBase64(sm);
|
||||
if (opts.isJSON || opts.isEncoded) sm = JSON.parse(sm);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
Converter.prototype.toBase64 = function () {
|
||||
var json = this.toJSON();
|
||||
return new Buffer(json).toString('base64');
|
||||
};
|
||||
|
||||
Converter.prototype.toComment = function (options) {
|
||||
var base64 = this.toBase64();
|
||||
var data = 'sourceMappingURL=data:application/json;base64,' + base64;
|
||||
return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
|
||||
};
|
||||
|
||||
// returns copy instead of original
|
||||
Converter.prototype.toObject = function () {
|
||||
return JSON.parse(this.toJSON());
|
||||
};
|
||||
|
||||
Converter.prototype.addProperty = function (key, value) {
|
||||
if (this.sourcemap.hasOwnProperty(key)) throw new Error('property %s already exists on the sourcemap, use set property instead');
|
||||
return this.setProperty(key, value);
|
||||
};
|
||||
|
||||
Converter.prototype.setProperty = function (key, value) {
|
||||
this.sourcemap[key] = value;
|
||||
return this;
|
||||
};
|
||||
|
||||
Converter.prototype.getProperty = function (key) {
|
||||
return this.sourcemap[key];
|
||||
};
|
||||
|
||||
exports.fromObject = function (obj) {
|
||||
return new Converter(obj);
|
||||
};
|
||||
|
||||
exports.fromJSON = function (json) {
|
||||
return new Converter(json, { isJSON: true });
|
||||
};
|
||||
|
||||
exports.fromBase64 = function (base64) {
|
||||
return new Converter(base64, { isEncoded: true });
|
||||
};
|
||||
|
||||
exports.fromComment = function (comment) {
|
||||
comment = comment
|
||||
.replace(/^\/\*/g, '//')
|
||||
.replace(/\*\/$/g, '');
|
||||
|
||||
return new Converter(comment, { isEncoded: true, hasComment: true });
|
||||
};
|
||||
|
||||
exports.fromMapFileComment = function (comment, dir) {
|
||||
return new Converter(comment, { commentFileDir: dir, isFileComment: true, isJSON: true });
|
||||
};
|
||||
|
||||
// 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;
|
||||
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;
|
||||
return m ? exports.fromMapFileComment(m.pop(), dir) : null;
|
||||
};
|
||||
|
||||
exports.removeComments = function (src) {
|
||||
commentRx.lastIndex = 0;
|
||||
return src.replace(commentRx, '');
|
||||
};
|
||||
|
||||
exports.removeMapFileComments = function (src) {
|
||||
mapFileCommentRx.lastIndex = 0;
|
||||
return src.replace(mapFileCommentRx, '');
|
||||
};
|
||||
|
||||
Object.defineProperty(exports, 'commentRegex', {
|
||||
get: function getCommentRegex () {
|
||||
commentRx.lastIndex = 0;
|
||||
return commentRx;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(exports, 'mapFileCommentRegex', {
|
||||
get: function getMapFileCommentRegex () {
|
||||
mapFileCommentRx.lastIndex = 0;
|
||||
return mapFileCommentRx;
|
||||
}
|
||||
});
|
36
node_modules/combine-source-map/node_modules/convert-source-map/package.json
generated
vendored
Normal file
36
node_modules/combine-source-map/node_modules/convert-source-map/package.json
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "convert-source-map",
|
||||
"version": "1.1.3",
|
||||
"description": "Converts a source-map from/to different formats and allows adding/changing properties.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/thlorenz/convert-source-map.git"
|
||||
},
|
||||
"homepage": "https://github.com/thlorenz/convert-source-map",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"inline-source-map": "~0.3.1",
|
||||
"tap": "~0.4.13"
|
||||
},
|
||||
"keywords": [
|
||||
"convert",
|
||||
"sourcemap",
|
||||
"source",
|
||||
"map",
|
||||
"browser",
|
||||
"debug"
|
||||
],
|
||||
"author": {
|
||||
"name": "Thorsten Lorenz",
|
||||
"email": "thlorenz@gmx.de",
|
||||
"url": "http://thlorenz.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engine": {
|
||||
"node": ">=0.6"
|
||||
}
|
||||
}
|
138
node_modules/combine-source-map/node_modules/convert-source-map/test/comment-regex.js
generated
vendored
Normal file
138
node_modules/combine-source-map/node_modules/convert-source-map/test/comment-regex.js
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
'use strict';
|
||||
/*jshint asi: true */
|
||||
|
||||
var test = require('tap').test
|
||||
, generator = require('inline-source-map')
|
||||
, rx = require('..').commentRegex
|
||||
, mapFileRx = require('..').mapFileCommentRegex
|
||||
|
||||
function comment(prefix, suffix) {
|
||||
rx.lastIndex = 0;
|
||||
return rx.test(prefix + 'sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix)
|
||||
}
|
||||
|
||||
function commentWithCharSet(prefix, suffix, sep) {
|
||||
sep = sep || ':';
|
||||
rx.lastIndex = 0;
|
||||
return rx.test(prefix + 'sourceMappingURL=data:application/json;charset' + sep +'utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix)
|
||||
}
|
||||
|
||||
// Source Map v2 Tests
|
||||
test('comment regex old spec - @', function (t) {
|
||||
[
|
||||
'//@ ',
|
||||
' //@ ', // with leading space
|
||||
'\t//@ ', // with leading tab
|
||||
'//@ ', // with leading text
|
||||
'/*@ ', // multi line style
|
||||
' /*@ ', // multi line style with leading spaces
|
||||
'\t/*@ ', // multi line style with leading tab
|
||||
'/*@ ', // multi line style with leading text
|
||||
].forEach(function (x) {
|
||||
t.ok(comment(x, ''), 'matches ' + x)
|
||||
t.ok(commentWithCharSet(x, ''), 'matches ' + x + ' with charset')
|
||||
t.ok(commentWithCharSet(x, '', '='), 'matches ' + x + ' with charset')
|
||||
});
|
||||
|
||||
[
|
||||
' @// @',
|
||||
' @/* @',
|
||||
].forEach(function (x) { t.ok(!comment(x, ''), 'should not match ' + x) })
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('comment regex new spec - #', function (t) {
|
||||
[
|
||||
' //# ', // with leading spaces
|
||||
'\t//# ', // with leading tab
|
||||
'//# ', // with leading text
|
||||
'/*# ', // multi line style
|
||||
' /*# ', // multi line style with leading spaces
|
||||
'\t/*# ', // multi line style with leading tab
|
||||
'/*# ', // multi line style with leading text
|
||||
].forEach(function (x) {
|
||||
t.ok(comment(x, ''), 'matches ' + x)
|
||||
t.ok(commentWithCharSet(x, ''), 'matches ' + x + ' with charset')
|
||||
t.ok(commentWithCharSet(x, '', '='), 'matches ' + x + ' with charset')
|
||||
});
|
||||
|
||||
[
|
||||
' #// #',
|
||||
' #/* #',
|
||||
].forEach(function (x) { t.ok(!comment(x, ''), 'should not match ' + x) })
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
function mapFileCommentWrap(s1, s2) {
|
||||
mapFileRx.lastIndex = 0;
|
||||
return mapFileRx.test(s1 + 'sourceMappingURL=foo.js.map' + s2)
|
||||
}
|
||||
|
||||
test('mapFileComment regex old spec - @', function (t) {
|
||||
|
||||
[
|
||||
['//@ ', ''],
|
||||
[' //@ ', ''], // with leading spaces
|
||||
['\t//@ ', ''], // with a leading tab
|
||||
['///@ ', ''], // with a leading text
|
||||
[';//@ ', ''], // with a leading text
|
||||
['return//@ ', ''], // with a leading text
|
||||
].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) });
|
||||
|
||||
[
|
||||
[' @// @', ''],
|
||||
['var sm = "//@ ', '"'], // not inside a string
|
||||
['var sm = \'//@ ', '\''], // not inside a string
|
||||
['var sm = \' //@ ', '\''], // not inside a string
|
||||
].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) })
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('mapFileComment regex new spec - #', function (t) {
|
||||
[
|
||||
['//# ', ''],
|
||||
[' //# ', ''], // with leading space
|
||||
['\t//# ', ''], // with leading tab
|
||||
['///# ', ''], // with leading text
|
||||
[';//# ', ''], // with leading text
|
||||
['return//# ', ''], // with leading text
|
||||
].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) });
|
||||
|
||||
[
|
||||
[' #// #', ''],
|
||||
['var sm = "//# ', '"'], // not inside a string
|
||||
['var sm = \'//# ', '\''], // not inside a string
|
||||
['var sm = \' //# ', '\''], // not inside a string
|
||||
].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) })
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('mapFileComment regex /* */ old spec - @', function (t) {
|
||||
[ [ '/*@ ', '*/' ]
|
||||
, [' /*@ ', ' */ ' ] // with leading spaces
|
||||
, [ '\t/*@ ', ' \t*/\t '] // with a leading tab
|
||||
, [ 'leading string/*@ ', '*/' ] // with a leading string
|
||||
, [ '/*@ ', ' \t*/\t '] // with trailing whitespace
|
||||
].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) });
|
||||
|
||||
[ ['/*@ ', ' */ */ ' ], // not the last thing on its line
|
||||
['/*@ ', ' */ more text ' ] // not the last thing on its line
|
||||
].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) });
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('mapFileComment regex /* */ new spec - #', function (t) {
|
||||
[ [ '/*# ', '*/' ]
|
||||
, [' /*# ', ' */ ' ] // with leading spaces
|
||||
, [ '\t/*# ', ' \t*/\t '] // with a leading tab
|
||||
, [ 'leading string/*# ', '*/' ] // with a leading string
|
||||
, [ '/*# ', ' \t*/\t '] // with trailing whitespace
|
||||
].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) });
|
||||
|
||||
[ ['/*# ', ' */ */ ' ], // not the last thing on its line
|
||||
['/*# ', ' */ more text ' ] // not the last thing on its line
|
||||
].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) });
|
||||
t.end()
|
||||
})
|
207
node_modules/combine-source-map/node_modules/convert-source-map/test/convert-source-map.js
generated
vendored
Normal file
207
node_modules/combine-source-map/node_modules/convert-source-map/test/convert-source-map.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
'use strict';
|
||||
/*jshint asi: true */
|
||||
|
||||
var test = require('tap').test
|
||||
, generator = require('inline-source-map')
|
||||
, convert = require('..')
|
||||
|
||||
var gen = generator()
|
||||
.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 })
|
||||
|
||||
, base64 = gen.base64Encode()
|
||||
, comment = gen.inlineMappingUrl()
|
||||
, json = gen.toString()
|
||||
, obj = JSON.parse(json)
|
||||
|
||||
test('different formats', function (t) {
|
||||
|
||||
t.equal(convert.fromComment(comment).toComment(), comment, 'comment -> comment')
|
||||
t.equal(convert.fromComment(comment).toBase64(), base64, 'comment -> base64')
|
||||
t.equal(convert.fromComment(comment).toJSON(), json, 'comment -> json')
|
||||
t.deepEqual(convert.fromComment(comment).toObject(), obj, 'comment -> object')
|
||||
|
||||
t.equal(convert.fromBase64(base64).toBase64(), base64, 'base64 -> base64')
|
||||
t.equal(convert.fromBase64(base64).toComment(), comment, 'base64 -> comment')
|
||||
t.equal(convert.fromBase64(base64).toJSON(), json, 'base64 -> json')
|
||||
t.deepEqual(convert.fromBase64(base64).toObject(), obj, 'base64 -> object')
|
||||
|
||||
t.equal(convert.fromJSON(json).toJSON(), json, 'json -> json')
|
||||
t.equal(convert.fromJSON(json).toBase64(), base64, 'json -> base64')
|
||||
t.equal(convert.fromJSON(json).toComment(), comment, 'json -> comment')
|
||||
t.deepEqual(convert.fromJSON(json).toObject(), obj, 'json -> object')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('to object returns a copy', function (t) {
|
||||
var c = convert.fromJSON(json)
|
||||
var o = c.toObject()
|
||||
o.version = '99';
|
||||
t.equal(c.toObject().version, 3, 'setting property on returned object does not affect original')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('to multi-line map', function (t) {
|
||||
var c = convert.fromObject(obj);
|
||||
var s = c.toComment({ multiline: true });
|
||||
t.similar(s, /^\/\*# sourceMappingURL=.+ \*\/$/);
|
||||
t.end();
|
||||
})
|
||||
|
||||
test('from source', 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;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9'
|
||||
, otherMap = '//# sourceMappingURL=data:application/json;base64,otherZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9'
|
||||
|
||||
function getComment(src) {
|
||||
var map = convert.fromSource(src);
|
||||
return map ? map.toComment() : null;
|
||||
}
|
||||
|
||||
t.equal(getComment(foo), null, 'no comment returns null')
|
||||
t.equal(getComment(foo + map), map, 'beginning of last line')
|
||||
t.equal(getComment(foo + ' ' + map), map, 'indented of last line')
|
||||
t.equal(getComment(foo + ' ' + map + '\n\n'), map, 'indented on last non empty line')
|
||||
t.equal(getComment(foo + map + '\nconsole.log("more code");\nfoo()\n'), map, 'in the middle of code')
|
||||
t.equal(getComment(foo + otherMap + '\n' + map), map, 'finds last map in source')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('from source with a large source', 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;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9'
|
||||
, otherMap = '//# sourceMappingURL=data:application/json;base64,otherZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9'
|
||||
|
||||
function getComment(src) {
|
||||
var map = convert.fromSource(src, true);
|
||||
return map ? map.toComment() : null;
|
||||
}
|
||||
|
||||
t.equal(getComment(foo), null, 'no comment returns null')
|
||||
t.equal(getComment(foo + map), map, 'beginning of last line')
|
||||
t.equal(getComment(foo + ' ' + map), map, 'indented of last line')
|
||||
t.equal(getComment(foo + ' ' + map + '\n\n'), map, 'indented on last non empty line')
|
||||
t.equal(getComment(foo + map + '\nconsole.log("more code");\nfoo()\n'), map, 'in the middle of code')
|
||||
t.equal(getComment(foo + otherMap + '\n' + map), map, 'finds last map in source')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('remove comments', function (t) {
|
||||
var foo = [
|
||||
'function foo() {'
|
||||
, ' console.log("hello I am foo");'
|
||||
, ' console.log("who are you");'
|
||||
, '}'
|
||||
, ''
|
||||
, 'foo();'
|
||||
, ''
|
||||
].join('\n')
|
||||
// this one is old spec on purpose
|
||||
, map = '//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9'
|
||||
, otherMap = '//# sourceMappingURL=data:application/json;base64,ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9'
|
||||
, extraCode = '\nconsole.log("more code");\nfoo()\n'
|
||||
|
||||
t.equal(convert.removeComments(foo + map), foo, 'from last line')
|
||||
t.equal(convert.removeComments(foo + map + extraCode), foo + extraCode, 'from the middle of code')
|
||||
t.equal(convert.removeComments(foo + otherMap + extraCode + map), foo + extraCode, 'multiple comments from the middle of code')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('remove map file comments', function (t) {
|
||||
var foo = [
|
||||
'function foo() {'
|
||||
, ' console.log("hello I am foo");'
|
||||
, ' console.log("who are you");'
|
||||
, '}'
|
||||
, ''
|
||||
, 'foo();'
|
||||
, ''
|
||||
].join('\n')
|
||||
, fileMap1 = '//# sourceMappingURL=foo.js.map'
|
||||
, fileMap2 = '/*# sourceMappingURL=foo.js.map */';
|
||||
|
||||
t.equal(convert.removeMapFileComments(foo + fileMap1), foo, '// style filemap comment')
|
||||
t.equal(convert.removeMapFileComments(foo + fileMap2), foo, '/* */ style filemap comment')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('pretty json', function (t) {
|
||||
var mod = convert.fromJSON(json).toJSON(2)
|
||||
, expected = JSON.stringify(obj, null, 2);
|
||||
|
||||
t.equal(
|
||||
mod
|
||||
, expected
|
||||
, 'pretty prints json when space is given')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('adding properties', function (t) {
|
||||
var mod = convert
|
||||
.fromJSON(json)
|
||||
.addProperty('foo', 'bar')
|
||||
.toJSON()
|
||||
, expected = JSON.parse(json);
|
||||
expected.foo = 'bar';
|
||||
t.equal(
|
||||
mod
|
||||
, JSON.stringify(expected)
|
||||
, 'includes added property'
|
||||
)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('setting properties', function (t) {
|
||||
var mod = convert
|
||||
.fromJSON(json)
|
||||
.setProperty('version', '2')
|
||||
.setProperty('mappings', ';;;UACG')
|
||||
.setProperty('should add', 'this')
|
||||
.toJSON()
|
||||
, expected = JSON.parse(json);
|
||||
expected.version = '2';
|
||||
expected.mappings = ';;;UACG';
|
||||
expected['should add'] = 'this';
|
||||
t.equal(
|
||||
mod
|
||||
, JSON.stringify(expected)
|
||||
, 'includes new property and changes existing properties'
|
||||
)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('getting properties', function (t) {
|
||||
var sm = convert.fromJSON(json)
|
||||
|
||||
t.equal(sm.getProperty('version'), 3, 'gets version')
|
||||
t.deepEqual(sm.getProperty('sources'), ['foo.js', 'bar.js'], 'gets sources')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('return null fromSource when largeSource is true', function(t) {
|
||||
var mod = convert.fromSource('', true)
|
||||
, expected = null;
|
||||
|
||||
t.equal(
|
||||
mod
|
||||
, expected
|
||||
, 'return value should be null'
|
||||
)
|
||||
t.end()
|
||||
})
|
14
node_modules/combine-source-map/node_modules/convert-source-map/test/fixtures/map-file-comment-double-slash.css
generated
vendored
Normal file
14
node_modules/combine-source-map/node_modules/convert-source-map/test/fixtures/map-file-comment-double-slash.css
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
.header {
|
||||
background: #444;
|
||||
border: solid;
|
||||
padding: 10px;
|
||||
border-radius: 10px 5px 10px 5px;
|
||||
color: #b4b472; }
|
||||
|
||||
#main li {
|
||||
color: green;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
font-size: 18px; }
|
||||
|
||||
//# sourceMappingURL=map-file-comment.css.map
|
14
node_modules/combine-source-map/node_modules/convert-source-map/test/fixtures/map-file-comment-inline.css
generated
vendored
Normal file
14
node_modules/combine-source-map/node_modules/convert-source-map/test/fixtures/map-file-comment-inline.css
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
.header {
|
||||
background: #444;
|
||||
border: solid;
|
||||
padding: 10px;
|
||||
border-radius: 10px 5px 10px 5px;
|
||||
color: #b4b472; }
|
||||
|
||||
#main li {
|
||||
color: green;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
font-size: 18px; }
|
||||
|
||||
/*# sourceMappingURL=data:application/json;base64,ewoidmVyc2lvbiI6ICIzIiwKIm1hcHBpbmdzIjogIkFBQUEsd0JBQXlCO0VBQ3ZCLFVBQVUsRUFBRSxJQUFJO0VBQ2hCLE1BQU0sRUFBRSxLQUFLO0VBQ2IsT0FBTyxFQUFFLElBQUk7RUFDYixhQUFhLEVBQUUsaUJBQWlCO0VBQ2hDLEtBQUssRUFBRSxPQUFrQjs7QUFHM0Isd0JBQXlCO0VBQ3ZCLE9BQU8sRUFBRSxJQUFJOztBQ1RmLGdCQUFpQjtFQUNmLFVBQVUsRUFBRSxJQUFJO0VBQ2hCLEtBQUssRUFBRSxNQUFNOztBQUdmLGtCQUFtQjtFQUNqQixNQUFNLEVBQUUsSUFBSTtFQUNaLE9BQU8sRUFBRSxJQUFJO0VBQ2IsVUFBVSxFQUFFLEtBQUs7RUFDakIsYUFBYSxFQUFFLEdBQUc7RUFDbEIsS0FBSyxFQUFFLEtBQUs7O0FBRWQsa0JBQW1CO0VBQ2pCLEtBQUssRUFBRSxLQUFLOztBQUdkLG1CQUFvQjtFQUNsQixLQUFLLEVBQUUsS0FBSztFQUNaLE1BQU0sRUFBRSxJQUFJO0VBQ1osT0FBTyxFQUFFLElBQUk7RUFDYixTQUFTLEVBQUUsSUFBSSIsCiJzb3VyY2VzIjogWyIuL2NsaWVudC9zYXNzL2NvcmUuc2NzcyIsIi4vY2xpZW50L3Nhc3MvbWFpbi5zY3NzIl0sCiJmaWxlIjogIm1hcC1maWxlLWNvbW1lbnQuY3NzIgp9 */
|
14
node_modules/combine-source-map/node_modules/convert-source-map/test/fixtures/map-file-comment.css
generated
vendored
Normal file
14
node_modules/combine-source-map/node_modules/convert-source-map/test/fixtures/map-file-comment.css
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
.header {
|
||||
background: #444;
|
||||
border: solid;
|
||||
padding: 10px;
|
||||
border-radius: 10px 5px 10px 5px;
|
||||
color: #b4b472; }
|
||||
|
||||
#main li {
|
||||
color: green;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
font-size: 18px; }
|
||||
|
||||
/*# sourceMappingURL=map-file-comment.css.map */
|
6
node_modules/combine-source-map/node_modules/convert-source-map/test/fixtures/map-file-comment.css.map
generated
vendored
Normal file
6
node_modules/combine-source-map/node_modules/convert-source-map/test/fixtures/map-file-comment.css.map
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": "3",
|
||||
"mappings": "AAAA,wBAAyB;EACvB,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,KAAK;EACb,OAAO,EAAE,IAAI;EACb,aAAa,EAAE,iBAAiB;EAChC,KAAK,EAAE,OAAkB;;AAG3B,wBAAyB;EACvB,OAAO,EAAE,IAAI;;ACTf,gBAAiB;EACf,UAAU,EAAE,IAAI;EAChB,KAAK,EAAE,MAAM;;AAGf,kBAAmB;EACjB,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,KAAK;EACjB,aAAa,EAAE,GAAG;EAClB,KAAK,EAAE,KAAK;;AAEd,kBAAmB;EACjB,KAAK,EAAE,KAAK;;AAGd,mBAAoB;EAClB,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,IAAI",
|
||||
"sources": ["./client/sass/core.scss","./client/sass/main.scss"],
|
||||
"file": "map-file-comment.css"
|
||||
}
|
70
node_modules/combine-source-map/node_modules/convert-source-map/test/map-file-comment.js
generated
vendored
Normal file
70
node_modules/combine-source-map/node_modules/convert-source-map/test/map-file-comment.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
/*jshint asi: true */
|
||||
|
||||
var test = require('tap').test
|
||||
, rx = require('..')
|
||||
, fs = require('fs')
|
||||
, convert = require('..')
|
||||
|
||||
test('\nresolving a "/*# sourceMappingURL=map-file-comment.css.map*/" style comment inside a given css content', function (t) {
|
||||
var css = fs.readFileSync(__dirname + '/fixtures/map-file-comment.css', 'utf8')
|
||||
var conv = convert.fromMapFileSource(css, __dirname + '/fixtures');
|
||||
var sm = conv.toObject();
|
||||
|
||||
t.deepEqual(
|
||||
sm.sources
|
||||
, [ './client/sass/core.scss',
|
||||
'./client/sass/main.scss' ]
|
||||
, 'resolves paths of original sources'
|
||||
)
|
||||
|
||||
t.equal(sm.file, 'map-file-comment.css', 'includes filename of generated file')
|
||||
t.equal(
|
||||
sm.mappings
|
||||
, 'AAAA,wBAAyB;EACvB,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,KAAK;EACb,OAAO,EAAE,IAAI;EACb,aAAa,EAAE,iBAAiB;EAChC,KAAK,EAAE,OAAkB;;AAG3B,wBAAyB;EACvB,OAAO,EAAE,IAAI;;ACTf,gBAAiB;EACf,UAAU,EAAE,IAAI;EAChB,KAAK,EAAE,MAAM;;AAGf,kBAAmB;EACjB,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,KAAK;EACjB,aAAa,EAAE,GAAG;EAClB,KAAK,EAAE,KAAK;;AAEd,kBAAmB;EACjB,KAAK,EAAE,KAAK;;AAGd,mBAAoB;EAClB,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,IAAI'
|
||||
, 'includes mappings'
|
||||
)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('\nresolving a "//# sourceMappingURL=map-file-comment.css.map" style comment inside a given css content', function (t) {
|
||||
var css = fs.readFileSync(__dirname + '/fixtures/map-file-comment-double-slash.css', 'utf8')
|
||||
var conv = convert.fromMapFileSource(css, __dirname + '/fixtures');
|
||||
var sm = conv.toObject();
|
||||
|
||||
t.deepEqual(
|
||||
sm.sources
|
||||
, [ './client/sass/core.scss',
|
||||
'./client/sass/main.scss' ]
|
||||
, 'resolves paths of original sources'
|
||||
)
|
||||
|
||||
t.equal(sm.file, 'map-file-comment.css', 'includes filename of generated file')
|
||||
t.equal(
|
||||
sm.mappings
|
||||
, 'AAAA,wBAAyB;EACvB,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,KAAK;EACb,OAAO,EAAE,IAAI;EACb,aAAa,EAAE,iBAAiB;EAChC,KAAK,EAAE,OAAkB;;AAG3B,wBAAyB;EACvB,OAAO,EAAE,IAAI;;ACTf,gBAAiB;EACf,UAAU,EAAE,IAAI;EAChB,KAAK,EAAE,MAAM;;AAGf,kBAAmB;EACjB,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,KAAK;EACjB,aAAa,EAAE,GAAG;EAClB,KAAK,EAAE,KAAK;;AAEd,kBAAmB;EACjB,KAAK,EAAE,KAAK;;AAGd,mBAAoB;EAClB,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,IAAI'
|
||||
, 'includes mappings'
|
||||
)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('\nresolving a /*# sourceMappingURL=data:application/json;base64,... */ style comment inside a given css content', function(t) {
|
||||
var css = fs.readFileSync(__dirname + '/fixtures/map-file-comment-inline.css', 'utf8')
|
||||
var conv = convert.fromSource(css, __dirname + '/fixtures')
|
||||
var sm = conv.toObject()
|
||||
|
||||
t.deepEqual(
|
||||
sm.sources
|
||||
, [ './client/sass/core.scss',
|
||||
'./client/sass/main.scss' ]
|
||||
, 'resolves paths of original sources'
|
||||
)
|
||||
|
||||
t.equal(sm.file, 'map-file-comment.css', 'includes filename of generated file')
|
||||
t.equal(
|
||||
sm.mappings
|
||||
, 'AAAA,wBAAyB;EACvB,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,KAAK;EACb,OAAO,EAAE,IAAI;EACb,aAAa,EAAE,iBAAiB;EAChC,KAAK,EAAE,OAAkB;;AAG3B,wBAAyB;EACvB,OAAO,EAAE,IAAI;;ACTf,gBAAiB;EACf,UAAU,EAAE,IAAI;EAChB,KAAK,EAAE,MAAM;;AAGf,kBAAmB;EACjB,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,KAAK;EACjB,aAAa,EAAE,GAAG;EAClB,KAAK,EAAE,KAAK;;AAEd,kBAAmB;EACjB,KAAK,EAAE,KAAK;;AAGd,mBAAoB;EAClB,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,IAAI'
|
||||
, 'includes mappings'
|
||||
)
|
||||
t.end()
|
||||
})
|
42
node_modules/combine-source-map/package.json
generated
vendored
Normal file
42
node_modules/combine-source-map/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "combine-source-map",
|
||||
"version": "0.8.0",
|
||||
"description": "Add source maps of multiple files, offset them and then combine them into one source map",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/thlorenz/combine-source-map.git"
|
||||
},
|
||||
"homepage": "https://github.com/thlorenz/combine-source-map",
|
||||
"dependencies": {
|
||||
"convert-source-map": "~1.1.0",
|
||||
"inline-source-map": "~0.6.0",
|
||||
"lodash.memoize": "~3.0.3",
|
||||
"source-map": "~0.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "~0.4.3"
|
||||
},
|
||||
"keywords": [
|
||||
"source",
|
||||
"map",
|
||||
"sourcemap",
|
||||
"bundle",
|
||||
"combine",
|
||||
"cat",
|
||||
"sourceMappingUrl",
|
||||
"browserify"
|
||||
],
|
||||
"author": {
|
||||
"name": "Thorsten Lorenz",
|
||||
"email": "thlorenz@gmx.de",
|
||||
"url": "http://thlorenz.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engine": {
|
||||
"node": ">=0.6"
|
||||
}
|
||||
}
|
347
node_modules/combine-source-map/test/combine-source-map.js
generated
vendored
Normal file
347
node_modules/combine-source-map/test/combine-source-map.js
generated
vendored
Normal file
@@ -0,0 +1,347 @@
|
||||
'use strict';
|
||||
/*jshint asi: true */
|
||||
|
||||
var test = require('tap').test;
|
||||
var convert = require('convert-source-map');
|
||||
var commentRegex = require('convert-source-map').commentRegex;
|
||||
var combine = require('..');
|
||||
var mappingsFromMap = require('../lib/mappings-from-map');
|
||||
|
||||
function checkMappings(foo, sm, lineOffset) {
|
||||
function inspect(obj, depth) {
|
||||
return require('util').inspect(obj, false, depth || 5, true);
|
||||
}
|
||||
|
||||
var fooMappings = mappingsFromMap(foo);
|
||||
var mappings = mappingsFromMap(sm);
|
||||
|
||||
var genLinesOffset = true;
|
||||
var origLinesSame = true;
|
||||
for (var i = 0; i < mappings.length; i++) {
|
||||
var fooGen = fooMappings[i].generated;
|
||||
var fooOrig = fooMappings[i].original;
|
||||
var gen = mappings[i].generated
|
||||
var orig = mappings[i].original;
|
||||
|
||||
if (gen.column !== fooGen.column || gen.line !== (fooGen.line + lineOffset)) {
|
||||
console.error(
|
||||
'generated mapping at %s not offset properly:\ninput: [%s]\noutput:[%s]\n\n',
|
||||
i ,
|
||||
inspect(fooGen),
|
||||
inspect(gen)
|
||||
);
|
||||
genLinesOffset = false;
|
||||
}
|
||||
|
||||
if (orig.column !== fooOrig.column || orig.line !== fooOrig.line) {
|
||||
console.error(
|
||||
'original mapping at %s is not the same as the genrated mapping:\ninput: [%s]\noutput:[%s]\n\n',
|
||||
i ,
|
||||
inspect(fooOrig),
|
||||
inspect(orig)
|
||||
);
|
||||
origLinesSame = false;
|
||||
}
|
||||
}
|
||||
return { genLinesOffset: genLinesOffset, origLinesSame: origLinesSame };
|
||||
}
|
||||
|
||||
var foo = {
|
||||
version : 3,
|
||||
file : 'foo.js',
|
||||
sourceRoot : '',
|
||||
sources : [ 'foo.coffee' ],
|
||||
names : [],
|
||||
mappings : ';AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ',
|
||||
sourcesContent : [ 'console.log(require \'./bar.js\')\n' ] };
|
||||
|
||||
test('add one file with inlined source', function (t) {
|
||||
|
||||
var mapComment = convert.fromObject(foo).toComment();
|
||||
var file = {
|
||||
id: 'xyz'
|
||||
, source: '(function() {\n\n console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + mapComment
|
||||
, sourceFile: 'foo.js'
|
||||
};
|
||||
|
||||
var lineOffset = 3
|
||||
var base64 = combine.create()
|
||||
.addFile(file, { line: lineOffset })
|
||||
.base64()
|
||||
|
||||
var sm = convert.fromBase64(base64).toObject();
|
||||
var res = checkMappings(foo, sm, lineOffset);
|
||||
|
||||
t.ok(res.genLinesOffset, 'all generated lines are offset properly and columns unchanged')
|
||||
t.ok(res.origLinesSame, 'all original lines and columns are unchanged')
|
||||
t.deepEqual(sm.sourcesContent, foo.sourcesContent, 'includes the original source')
|
||||
t.deepEqual(sm.sources, ['foo.coffee'], 'includes original filename')
|
||||
t.end()
|
||||
});
|
||||
|
||||
|
||||
test('add one file without inlined source', function (t) {
|
||||
|
||||
var mapComment = convert
|
||||
.fromObject(foo)
|
||||
.setProperty('sourcesContent', [])
|
||||
.toComment();
|
||||
|
||||
var file = {
|
||||
id: 'xyz'
|
||||
, source: '(function() {\n\n console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + mapComment
|
||||
, sourceFile: 'foo.js'
|
||||
};
|
||||
|
||||
var lineOffset = 3
|
||||
var base64 = combine.create()
|
||||
.addFile(file, { line: lineOffset })
|
||||
.base64()
|
||||
|
||||
var sm = convert.fromBase64(base64).toObject();
|
||||
var mappings = mappingsFromMap(sm);
|
||||
|
||||
t.deepEqual(sm.sourcesContent, [file.source], 'includes the generated source')
|
||||
t.deepEqual(sm.sources, ['foo.js'], 'includes generated filename')
|
||||
|
||||
t.deepEqual(
|
||||
mappings
|
||||
, [ { generated: { line: 4, column: 0 },
|
||||
original: { line: 1, column: 0 },
|
||||
source: 'foo.js', name: null },
|
||||
{ generated: { line: 5, column: 0 },
|
||||
original: { line: 2, column: 0 },
|
||||
source: 'foo.js', name: null },
|
||||
{ generated: { line: 6, column: 0 },
|
||||
original: { line: 3, column: 0 },
|
||||
source: 'foo.js', name: null },
|
||||
{ generated: { line: 7, column: 0 },
|
||||
original: { line: 4, column: 0 },
|
||||
source: 'foo.js', name: null },
|
||||
{ generated: { line: 8, column: 0 },
|
||||
original: { line: 5, column: 0 },
|
||||
source: 'foo.js', name: null },
|
||||
{ generated: { line: 9, column: 0 },
|
||||
original: { line: 6, column: 0 },
|
||||
source: 'foo.js', name: null },
|
||||
{ generated: { line: 10, column: 0 },
|
||||
original: { line: 7, column: 0 },
|
||||
source: 'foo.js', name: null } ]
|
||||
, 'generates mappings offset by the given line'
|
||||
)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('add one file with inlined sources from multiple files', function(t) {
|
||||
var gen1Map = {
|
||||
version: 3,
|
||||
sources: [ 'one.js', 'two.js' ],
|
||||
names: [],
|
||||
mappings: 'AAAA;ACAA',
|
||||
sourcesContent: [ 'console.log(1);', 'console.log(2);' ]
|
||||
};
|
||||
|
||||
var gen2Map = {
|
||||
version: 3,
|
||||
sources: [ 'three.js', 'four.js' ],
|
||||
names: [],
|
||||
mappings: 'AAAA;ACAA',
|
||||
sourcesContent: [ 'console.log(3);', 'console.log(4);' ]
|
||||
};
|
||||
|
||||
var base64 = combine.create()
|
||||
.addFile({
|
||||
source: 'console.log(1);\nconsole.log(2);\n' + convert.fromObject(gen1Map).toComment(),
|
||||
sourceFile: 'gen1.js'
|
||||
})
|
||||
.addFile({
|
||||
source: 'console.log(3);\nconsole.log(4);\n' + convert.fromObject(gen2Map).toComment(),
|
||||
sourceFile: 'gen2.js'
|
||||
}, {line: 2})
|
||||
.base64()
|
||||
|
||||
var sm = convert.fromBase64(base64).toObject();
|
||||
|
||||
|
||||
t.deepEqual(sm.sources, ['one.js', 'two.js', 'three.js', 'four.js'], 'include the correct source');
|
||||
|
||||
t.deepEqual(sm.sourcesContent, [
|
||||
'console.log(1);',
|
||||
'console.log(2);',
|
||||
'console.log(3);',
|
||||
'console.log(4);'
|
||||
], 'include the correct source file content');
|
||||
|
||||
t.deepEqual(
|
||||
mappingsFromMap(sm)
|
||||
, [ { original: { column: 0, line: 1 },
|
||||
generated: { column: 0, line: 1 },
|
||||
source: 'one.js',
|
||||
name: null },
|
||||
{ original: { column: 0, line: 1 },
|
||||
generated: { column: 0, line: 2 },
|
||||
source: 'two.js',
|
||||
name: null },
|
||||
{ original: { column: 0, line: 1 },
|
||||
generated: { column: 0, line: 3 },
|
||||
source: 'three.js',
|
||||
name: null },
|
||||
{ original: { column: 0, line: 1 },
|
||||
generated: { column: 0, line: 4 },
|
||||
source: 'four.js',
|
||||
name: null } ], 'should properly map multiple files');
|
||||
t.end()
|
||||
});
|
||||
|
||||
test('relative path from multiple files', function(t) {
|
||||
// Folder structure as follows:
|
||||
//
|
||||
// project
|
||||
// +- src
|
||||
// +- package1
|
||||
// +- sub
|
||||
// -- one.js
|
||||
// -- two.js
|
||||
// +- package2
|
||||
// +- sub
|
||||
// -- three.js
|
||||
// -- four.js
|
||||
// +- gen
|
||||
// +- gen1.js
|
||||
// +- gen2.js
|
||||
// -- combined.js
|
||||
//
|
||||
// Where 'one.js', 'two.js' were combined to 'gen1.js'
|
||||
// and 'three.js', 'four.js' were combined to 'gen2.js'.
|
||||
// Now 'gen1.js' and 'gen2.js' are being combined from
|
||||
// the project root folder.
|
||||
var gen1Map = {
|
||||
version: 3,
|
||||
sources: [ 'sub/one.js', 'sub/two.js' ],
|
||||
names: [],
|
||||
mappings: 'AAAA;ACAA',
|
||||
sourcesContent: [ 'console.log(1);', 'console.log(2);' ],
|
||||
sourceRoot: '../src/package1'
|
||||
};
|
||||
|
||||
var gen2Map = {
|
||||
version: 3,
|
||||
sources: [ 'sub/three.js', 'sub/four.js' ],
|
||||
names: [],
|
||||
mappings: 'AAAA;ACAA',
|
||||
sourcesContent: [ 'console.log(3);', 'console.log(4);' ],
|
||||
sourceRoot: '../src/package2'
|
||||
};
|
||||
|
||||
var base64 = combine.create()
|
||||
.addFile({
|
||||
source: 'console.log(1);\nconsole.log(2);\n' + convert.fromObject(gen1Map).toComment(),
|
||||
sourceFile: 'gen/gen1.js'
|
||||
})
|
||||
.addFile({
|
||||
source: 'console.log(3);\nconsole.log(4);\n' + convert.fromObject(gen2Map).toComment(),
|
||||
sourceFile: 'gen/gen2.js'
|
||||
}, {line: 2})
|
||||
.base64()
|
||||
|
||||
var sm = convert.fromBase64(base64).toObject();
|
||||
|
||||
t.deepEqual(sm.sources, ['src/package1/sub/one.js', 'src/package1/sub/two.js',
|
||||
'src/package2/sub/three.js', 'src/package2/sub/four.js'],
|
||||
'include the correct source');
|
||||
|
||||
t.deepEqual(sm.sourcesContent, [
|
||||
'console.log(1);',
|
||||
'console.log(2);',
|
||||
'console.log(3);',
|
||||
'console.log(4);'
|
||||
], 'include the correct source file content');
|
||||
|
||||
t.deepEqual(
|
||||
mappingsFromMap(sm)
|
||||
, [ { original: { column: 0, line: 1 },
|
||||
generated: { column: 0, line: 1 },
|
||||
source: 'src/package1/sub/one.js',
|
||||
name: null },
|
||||
{ original: { column: 0, line: 1 },
|
||||
generated: { column: 0, line: 2 },
|
||||
source: 'src/package1/sub/two.js',
|
||||
name: null },
|
||||
{ original: { column: 0, line: 1 },
|
||||
generated: { column: 0, line: 3 },
|
||||
source: 'src/package2/sub/three.js',
|
||||
name: null },
|
||||
{ original: { column: 0, line: 1 },
|
||||
generated: { column: 0, line: 4 },
|
||||
source: 'src/package2/sub/four.js',
|
||||
name: null } ], 'should properly map multiple files');
|
||||
t.end()
|
||||
});
|
||||
|
||||
test('relative path when source and file name are the same', function(t) {
|
||||
var gen1Map = {
|
||||
version: 3,
|
||||
sources: [ 'a/b/one.js' ],
|
||||
names: [],
|
||||
mappings: 'AAAA',
|
||||
file: 'a/b/one.js',
|
||||
sourcesContent: [ 'console.log(1);\n' ]
|
||||
};
|
||||
|
||||
var gen2Map = {
|
||||
version: 3,
|
||||
sources: [ 'a/b/two.js' ],
|
||||
names: [],
|
||||
mappings: 'AAAA',
|
||||
file: 'a/b/two.js',
|
||||
sourcesContent: [ 'console.log(2);\n' ]
|
||||
};
|
||||
|
||||
var base64 = combine.create()
|
||||
.addFile({
|
||||
source: 'console.log(1);\n' + convert.fromObject(gen1Map).toComment(),
|
||||
sourceFile: 'a/b/one.js'
|
||||
})
|
||||
.addFile({
|
||||
source: 'console.log(2);\n' + convert.fromObject(gen2Map).toComment(),
|
||||
sourceFile: 'a/b/two.js'
|
||||
}, {line: 1})
|
||||
.base64()
|
||||
|
||||
var sm = convert.fromBase64(base64).toObject();
|
||||
|
||||
t.deepEqual(sm.sources, ['a/b/one.js', 'a/b/two.js'],
|
||||
'include the correct source');
|
||||
|
||||
t.deepEqual(
|
||||
mappingsFromMap(sm)
|
||||
, [ { original: { column: 0, line: 1 },
|
||||
generated: { column: 0, line: 1 },
|
||||
source: 'a/b/one.js',
|
||||
name: null },
|
||||
{ original: { column: 0, line: 1 },
|
||||
generated: { column: 0, line: 2 },
|
||||
source: 'a/b/two.js',
|
||||
name: null } ], 'should properly map multiple files');
|
||||
t.end()
|
||||
});
|
||||
|
||||
test('remove comments', function (t) {
|
||||
var mapComment = convert.fromObject(foo).toComment();
|
||||
|
||||
function sourcemapComments(src) {
|
||||
var matches = src.match(commentRegex);
|
||||
return matches ? matches.length : 0;
|
||||
}
|
||||
|
||||
t.equal(sourcemapComments('var a = 1;\n' + mapComment), 1);
|
||||
|
||||
[ ''
|
||||
, 'var a = 1;\n' + mapComment
|
||||
, 'var a = 1;\n' + mapComment + '\nvar b = 5;\n' + mapComment
|
||||
] .forEach(function (x) {
|
||||
var removed = combine.removeComments(x)
|
||||
t.equal(sourcemapComments(removed), 0)
|
||||
})
|
||||
t.end()
|
||||
})
|
Reference in New Issue
Block a user