react app

This commit is contained in:
Mario Romano
2016-04-06 17:52:19 +01:00
parent f7e6ef55a2
commit 29df96a085
4425 changed files with 446323 additions and 0 deletions

16
react-app/node_modules/convert-source-map/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,16 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
node_modules
npm-debug.log
tmp

View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- 0.8
- 0.10
- 0.11

23
react-app/node_modules/convert-source-map/LICENSE generated vendored Normal file
View 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.

129
react-app/node_modules/convert-source-map/README.md generated vendored Normal file
View File

@@ -0,0 +1,129 @@
# convert-source-map [![build status](https://secure.travis-ci.org/thlorenz/convert-source-map.png)](http://travis-ci.org/thlorenz/convert-source-map)
[![NPM](https://nodei.co/npm/convert-source-map.png?downloads=true&stars=true)](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.
### generateMapFileComment(file, [options])
Returns a comment that links to an external source map via `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.
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/thlorenz/convert-source-map/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

View 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);

161
react-app/node_modules/convert-source-map/index.js generated vendored Normal file
View File

@@ -0,0 +1,161 @@
'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, '');
};
exports.generateMapFileComment = function (file, options) {
var data = 'sourceMappingURL=' + file;
return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
};
Object.defineProperty(exports, 'commentRegex', {
get: function getCommentRegex () {
commentRx.lastIndex = 0;
return commentRx;
}
});
Object.defineProperty(exports, 'mapFileCommentRegex', {
get: function getMapFileCommentRegex () {
mapFileCommentRx.lastIndex = 0;
return mapFileCommentRx;
}
});

91
react-app/node_modules/convert-source-map/package.json generated vendored Normal file
View File

@@ -0,0 +1,91 @@
{
"_args": [
[
"convert-source-map@^1.1.0",
"/Users/mromano/dev/react-sfs/node_modules/babel-core"
]
],
"_from": "convert-source-map@>=1.1.0 <2.0.0",
"_id": "convert-source-map@1.2.0",
"_inCache": true,
"_installable": true,
"_location": "/convert-source-map",
"_nodeVersion": "4.3.1-rc.2",
"_npmOperationalInternal": {
"host": "packages-5-east.internal.npmjs.com",
"tmp": "tmp/convert-source-map-1.2.0.tgz_1456506734770_0.5290673428680748"
},
"_npmUser": {
"email": "thlorenz@gmx.de",
"name": "thlorenz"
},
"_npmVersion": "2.14.15",
"_phantomChildren": {},
"_requested": {
"name": "convert-source-map",
"raw": "convert-source-map@^1.1.0",
"rawSpec": "^1.1.0",
"scope": null,
"spec": ">=1.1.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/babel-core"
],
"_resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.2.0.tgz",
"_shasum": "44c08c2506f10fb3ca6fd888d5a3444cf8d6a669",
"_shrinkwrap": null,
"_spec": "convert-source-map@^1.1.0",
"_where": "/Users/mromano/dev/react-sfs/node_modules/babel-core",
"author": {
"email": "thlorenz@gmx.de",
"name": "Thorsten Lorenz",
"url": "http://thlorenz.com"
},
"bugs": {
"url": "https://github.com/thlorenz/convert-source-map/issues"
},
"dependencies": {},
"description": "Converts a source-map from/to different formats and allows adding/changing properties.",
"devDependencies": {
"inline-source-map": "~0.3.1",
"tap": "~0.4.13"
},
"directories": {},
"dist": {
"shasum": "44c08c2506f10fb3ca6fd888d5a3444cf8d6a669",
"tarball": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.2.0.tgz"
},
"engine": {
"node": ">=0.6"
},
"gitHead": "c840d5ab5a1cfa4c8eb902283cac3fb120a6f466",
"homepage": "https://github.com/thlorenz/convert-source-map",
"keywords": [
"convert",
"sourcemap",
"source",
"map",
"browser",
"debug"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"email": "thlorenz@gmx.de",
"name": "thlorenz"
}
],
"name": "convert-source-map",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/thlorenz/convert-source-map.git"
},
"scripts": {
"test": "tap test/*.js"
},
"version": "1.2.0"
}

View 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()
})

View File

@@ -0,0 +1,213 @@
'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('to map file comment', function (t) {
t.equal(convert.generateMapFileComment('index.js.map'), '//# sourceMappingURL=index.js.map');
t.equal(convert.generateMapFileComment('index.css.map', { multiline: true }), '/*# sourceMappingURL=index.css.map */');
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()
})

View 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

View 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 */

View 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 */

View 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"
}

View 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()
})