init
This commit is contained in:
16
client/node_modules/combine-source-map/.npmignore
generated
vendored
Normal file
16
client/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
client/node_modules/combine-source-map/.travis.yml
generated
vendored
Normal file
8
client/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
client/node_modules/combine-source-map/LICENSE
generated
vendored
Normal file
23
client/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
client/node_modules/combine-source-map/README.md
generated
vendored
Normal file
111
client/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
client/node_modules/combine-source-map/example/two-files-short.js
generated
vendored
Normal file
26
client/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
client/node_modules/combine-source-map/example/two-files.js
generated
vendored
Normal file
46
client/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
client/node_modules/combine-source-map/index.js
generated
vendored
Normal file
155
client/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
client/node_modules/combine-source-map/lib/mappings-from-map.js
generated
vendored
Normal file
30
client/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
client/node_modules/combine-source-map/lib/path-is-absolute.js
generated
vendored
Normal file
20
client/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
client/node_modules/combine-source-map/lib/path-is-absolute.license
generated
vendored
Normal file
21
client/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.
|
||||
42
client/node_modules/combine-source-map/package.json
generated
vendored
Normal file
42
client/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
client/node_modules/combine-source-map/test/combine-source-map.js
generated
vendored
Normal file
347
client/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