8889841cindex.js000066600000002707150432033560006224 0ustar00 /** * Module dependencies. */ var css = require('css'); var convertSourceMap = require('convert-source-map'); var parse = css.parse; var stringify = css.stringify; /** * Expose `rework`. */ exports = module.exports = rework; /** * Initialize a new stylesheet `Rework` with `str`. * * @param {String} str * @param {Object} options * @return {Rework} * @api public */ function rework(str, options) { return new Rework(parse(str, options)); } /** * Initialize a new stylesheet `Rework` with `obj`. * * @param {Object} obj * @api private */ function Rework(obj) { this.obj = obj; } /** * Use the given plugin `fn(style, rework)`. * * @param {Function} fn * @return {Rework} * @api public */ Rework.prototype.use = function(fn){ fn(this.obj.stylesheet, this); return this; }; /** * Stringify the stylesheet. * * @param {Object} options * @return {String} * @api public */ Rework.prototype.toString = function(options){ options = options || {}; var result = stringify(this.obj, options); if (options.sourcemap && !options.sourcemapAsObject) { result = result.code + '\n' + sourcemapToComment(result.map); } return result; }; /** * Convert sourcemap to base64-encoded comment * * @param {Object} map * @return {String} * @api private */ function sourcemapToComment(map) { var content = convertSourceMap.fromObject(map).toBase64(); return '/*# sourceMappingURL=data:application/json;base64,' + content + ' */'; } node_modules/convert-source-map/test/map-file-comment.js000066600000006463150432033560017437 0ustar00'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() }) node_modules/convert-source-map/test/comment-regex.js000066600000005350150432033560017051 0ustar00'use strict'; /*jshint asi: true */ var test = require('tap').test , generator = require('inline-source-map') , rx = require('..').commentRegex , mapFileRx = require('..').mapFileCommentRegex function comment(s) { rx.lastIndex = 0; return rx.test(s + 'sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9') } test('comment regex old spec - @', function (t) { [ '//@ ' , ' //@ ' , '\t//@ ' ].forEach(function (x) { t.ok(comment(x), 'matches ' + x) }); [ '///@ ' , '}}//@ ' , ' @// @' ].forEach(function (x) { t.ok(!comment(x), 'does not match ' + x) }) t.end() }) test('comment regex new spec - #', function (t) { [ '//# ' , ' //# ' , '\t//# ' ].forEach(function (x) { t.ok(comment(x), 'matches ' + x) }); [ '///# ' , '}}//# ' , ' #// #' ].forEach(function (x) { t.ok(!comment(x), 'does not match ' + x) }) t.end() }) function mapFileComment(s) { mapFileRx.lastIndex = 0; return mapFileRx.test(s + 'sourceMappingURL=foo.js.map') } test('mapFileComment regex old spec - @', function (t) { [ '//@ ' , ' //@ ' , '\t//@ ' ].forEach(function (x) { t.ok(mapFileComment(x), 'matches ' + x) }); [ '///@ ' , '}}//@ ' , ' @// @' ].forEach(function (x) { t.ok(!mapFileComment(x), 'does not match ' + x) }) t.end() }) test('mapFileComment regex new spec - #', function (t) { [ '//# ' , ' //# ' , '\t//# ' ].forEach(function (x) { t.ok(mapFileComment(x), 'matches ' + x) }); [ '///# ' , '}}//# ' , ' #// #' ].forEach(function (x) { t.ok(!mapFileComment(x), 'does 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) { [ [ '/*@ ', '*/' ] , [' /*@ ', ' */ ' ] , [ '\t/*@ ', ' \t*/\t '] ].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) }); [ [ '/*/*@ ', '*/' ] , ['}}/*@ ', ' */ ' ] , [ ' @/*@ ', ' \t*/\t '] ].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) }); t.end() }) test('mapFileComment regex /* */ new spec - #', function (t) { [ [ '/*# ', '*/' ] , [' /*# ', ' */ ' ] , [ '\t/*# ', ' \t*/\t '] ].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) }); [ [ '/*/*# ', '*/' ] , ['}}/*# ', ' */ ' ] , [ ' #/*# ', ' \t*/\t '] ].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) }); t.end() }) node_modules/convert-source-map/test/fixtures/map-file-comment.css000066600000000374150432033560021457 0ustar00.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 */ node_modules/convert-source-map/test/fixtures/map-file-comment-inline.css000066600000002011150432033560022721 0ustar00.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 */ node_modules/convert-source-map/test/fixtures/map-file-comment-double-slash.css000066600000000371150432033560024034 0ustar00.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 node_modules/convert-source-map/test/fixtures/map-file-comment.css.map000066600000001107150432033560022226 0ustar00{ "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" } node_modules/convert-source-map/test/convert-source-map.js000066600000013612150432033560020030 0ustar00'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('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('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,otherZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' , 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 + 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() }) node_modules/convert-source-map/index.js000066600000007624150432033560014435 0ustar00'use strict'; var fs = require('fs'); var path = require('path'); var commentRx = /^[ \t]*(?:\/\/|\/\*)[@#][ \t]+sourceMappingURL=data:(?:application|text)\/json;base64,(.+)(?:\*\/)?/mg; var mapFileCommentRx = // //# sourceMappingURL=foo.js.map /*# sourceMappingURL=foo.js.map */ /(?:^[ \t]*\/\/[@|#][ \t]+sourceMappingURL=(.+?)[ \t]*$)|(?:^[ \t]*\/\*[@#][ \t]+sourceMappingURL=(.+?)[ \t]*\*\/[ \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 || {}; try { 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; } catch(e) { console.error(e); return null; } } 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 () { var base64 = this.toBase64(); return '//# sourceMappingURL=data:application/json;base64,' + base64; }; // 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) { 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.__defineGetter__('commentRegex', function () { commentRx.lastIndex = 0; return commentRx; }); exports.__defineGetter__('mapFileCommentRegex', function () { mapFileCommentRx.lastIndex = 0; return mapFileCommentRx; }); node_modules/convert-source-map/README.md000066600000007172150432033560014245 0ustar00# 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) Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found. ### 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() Converts source map to base64 encoded json string prefixed with `//# sourceMappingURL=...`. ### 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. [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/thlorenz/convert-source-map/trend.png)](https://bitdeli.com/free "Bitdeli Badge") node_modules/convert-source-map/.npmignore000066600000000145150432033560014756 0ustar00lib-cov *.seed *.log *.csv *.dat *.out *.pid *.gz pids logs results node_modules npm-debug.log tmp node_modules/convert-source-map/example/comment-to-json.js000066600000001203150432033560017775 0ustar00'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); node_modules/convert-source-map/.travis.yml000066600000000064150432033560015070 0ustar00language: node_js node_js: - 0.8 - 0.10 - 0.11node_modules/convert-source-map/LICENSE000066600000002066150432033560013770 0ustar00Copyright 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. node_modules/convert-source-map/package.json000066600000001423150432033560015245 0ustar00{ "name": "convert-source-map", "version": "0.3.5", "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.0", "tap": "~0.4.3" }, "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" } } Readme.md000066600000010200150432033560006261 0ustar00# rework [![Build Status](https://travis-ci.org/reworkcss/rework.png)](https://travis-ci.org/reworkcss/rework) CSS manipulations built on [`css`](https://github.com/reworkcss/css), allowing you to automate vendor prefixing, create your own properties, inline images, anything you can imagine! Please refer to [`css`](https://github.com/reworkcss/css) for AST documentation and to report parser/stringifier issues. ## Installation $ npm install rework ## Usage ```js var rework = require('rework'); var pluginA = require('pluginA'); var pluginB = require('pluginB'); rework('body { font-size: 12px; }', { source: 'source.css' }) .use(pluginA) .use(pluginB) .toString({ sourcemap: true }) ``` ## API ### rework(code, [options]) Accepts a CSS string and returns a new `Rework` instance. The `options` are passed directly to `css.parse`. ### Rework#use(fn) Use the given plugin `fn`. A rework "plugin" is simply a function accepting the stylesheet root node and the `Rework` instance. ### Rework#toString([options]) Returns the string representation of the manipulated CSS. The `options` are passed directly to `css.stringify`. Unlike `css.stringify`, if you pass `sourcemap: true` a string will still be returned, with the source map inlined. Also use `sourcemapAsObject: true` if you want the `css.stringify` return value. ## Plugins Rework has a rich collection of plugins and mixins. Browse all the [Rework plugins](https://www.npmjs.org/search?q=rework) available on npm. Plugins of particular note: - [at2x](https://github.com/reworkcss/rework-plugin-at2x/) – serve high resolution images - [calc](https://github.com/reworkcss/rework-calc) – resolve simple `calc()` expressions - [colors](https://github.com/reworkcss/rework-plugin-colors/) – color helpers like `rgba(#fc0, .5)` - [ease](https://github.com/reworkcss/rework-plugin-ease/) – several additional easing functions - [extend](https://github.com/reworkcss/rework-inherit/) – `extend: selector` support - [function](https://github.com/reworkcss/rework-plugin-function/) – user-defined CSS functions - [import](https://github.com/reworkcss/rework-import) – read and inline CSS via `@import` - [inline](https://github.com/reworkcss/rework-plugin-inline) – inline assets as data URIs - [mixin](https://github.com/reworkcss/rework-plugin-mixin/) – custom property logic with mixins - [npm](https://github.com/reworkcss/rework-npm) - inline CSS via `@import` using node's module resolver - [references](https://github.com/reworkcss/rework-plugin-references/) – property references like `height: @width` - [url](https://github.com/reworkcss/rework-plugin-url/) – rewrite `url()`s with a given function - [variables](https://github.com/reworkcss/rework-vars/) – W3C-style variables ## Built with rework - [styl](https://github.com/visionmedia/styl) - [rework-pure-css](https://github.com/ianstormtaylor/rework-pure-css) - [rework-suit](https://github.com/suitcss/rework-suit) - [resin](https://github.com/topcoat/resin) - [Myth](https://github.com/segmentio/myth) ## License (The MIT License) Copyright (c) 2012–2013 TJ Holowaychuk Copyright (c) 2014 Contributors 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. package.json000066600000001165150432033560007042 0ustar00{ "name": "rework", "version": "1.0.1", "description": "Plugin framework for CSS preprocessing", "main": "index", "files": [ "index.js" ], "dependencies": { "css": "^2.0.0", "convert-source-map": "^0.3.3" }, "devDependencies": { "mocha": "^1.20.1", "should": "^4.0.4" }, "scripts": { "test": "mocha --require should --reporter spec" }, "keywords": [ "css", "manipulation", "preprocess", "transform", "server" ], "author": "TJ Holowaychuk ", "repository": { "type": "git", "url": "git://github.com/reworkcss/rework.git" } }