Socket
Socket
Sign inDemoInstall

sorcery

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sorcery - npm Package Compare versions

Comparing version 0.9.2 to 0.9.3

4

CHANGELOG.md
# changelog
## 0.9.3
* Update dependencies, use Bublé instead of Babel
## 0.9.1-2

@@ -4,0 +8,0 @@

538

dist/sorcery.cjs.js
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var path = require('path');
var sander = require('sander');
var crc32 = require('buffer-crc32');
crc32 = 'default' in crc32 ? crc32['default'] : crc32;
var crc32 = _interopDefault(require('buffer-crc32'));

@@ -11,22 +12,22 @@ var charToInteger = {};

'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split('').forEach(function (char, i) {
charToInteger[char] = i;
integerToChar[i] = char;
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
charToInteger[ char ] = i;
integerToChar[ i ] = char;
});
function decode$1(string) {
function decode$1 ( string ) {
var result = [],
len = string.length,
i,
hasContinuationBit,
shift = 0,
value = 0,
integer,
shouldNegate;
len = string.length,
i,
hasContinuationBit,
shift = 0,
value = 0,
integer,
shouldNegate;
for (i = 0; i < len; i += 1) {
integer = charToInteger[string[i]];
for ( i = 0; i < len; i += 1 ) {
integer = charToInteger[ string[i] ];
if (integer === undefined) {
throw new Error('Invalid character (' + string[i] + ')');
if ( integer === undefined ) {
throw new Error( 'Invalid character (' + string[i] + ')' );
}

@@ -39,3 +40,3 @@

if (hasContinuationBit) {
if ( hasContinuationBit ) {
shift += 5;

@@ -46,3 +47,3 @@ } else {

result.push(shouldNegate ? -value : value);
result.push( shouldNegate ? -value : value );

@@ -57,11 +58,11 @@ // reset

function encode$1(value) {
function encode$1 ( value ) {
var result, i;
if (typeof value === 'number') {
result = encodeInteger(value);
if ( typeof value === 'number' ) {
result = encodeInteger( value );
} else {
result = '';
for (i = 0; i < value.length; i += 1) {
result += encodeInteger(value[i]);
for ( i = 0; i < value.length; i += 1 ) {
result += encodeInteger( value[i] );
}

@@ -73,8 +74,7 @@ }

function encodeInteger(num) {
var result = '',
clamped;
function encodeInteger ( num ) {
var result = '', clamped;
if (num < 0) {
num = -num << 1 | 1;
if ( num < 0 ) {
num = ( -num << 1 ) | 1;
} else {

@@ -88,8 +88,8 @@ num <<= 1;

if (num > 0) {
if ( num > 0 ) {
clamped |= 32;
}
result += integerToChar[clamped];
} while (num > 0);
result += integerToChar[ clamped ];
} while ( num > 0 );

@@ -103,4 +103,5 @@ return result;

while (i--) segments[i] = decode$1(encodedSegments[i]);
return segments;
while (i--) {
segments[i] = decode$1(encodedSegments[i]);
}return segments;
}

@@ -218,10 +219,10 @@

function decodeMappings(mappings) {
var checksum = crc32(mappings);
function decodeMappings ( mappings ) {
var checksum = crc32( mappings );
if (!cache[checksum]) {
cache[checksum] = decode(mappings);
if ( !cache[ checksum ] ) {
cache[ checksum ] = decode( mappings );
}
return cache[checksum];
return cache[ checksum ];
}

@@ -234,4 +235,4 @@

*/
function atob(base64) {
return new Buffer(base64, 'base64').toString('utf8');
function atob ( base64 ) {
return new Buffer( base64, 'base64' ).toString( 'utf8' );
}

@@ -256,37 +257,36 @@

*/
function getMapFromUrl(url, base, sync) {
if (/^data:/.test(url)) {
// TODO beef this up
var match = /base64,(.+)$/.exec(url);
function getMapFromUrl ( url, base, sync ) {
if ( /^data:/.test( url ) ) { // TODO beef this up
var match = /base64,(.+)$/.exec( url );
if (!match) {
throw new Error(SOURCEMAPPING_URL$1 + ' is not base64-encoded');
if ( !match ) {
throw new Error( ("" + SOURCEMAPPING_URL$1 + " is not base64-encoded") );
}
var json = atob(match[1]);
var map = JSON.parse(json);
return sync ? map : sander.Promise.resolve(map);
var json = atob( match[1] );
var map = JSON.parse( json );
return sync ? map : sander.Promise.resolve( map );
}
url = path.resolve(path.dirname(base), decodeURI(url));
url = path.resolve( path.dirname( base ), decodeURI( url ) );
if (sync) {
return JSON.parse(sander.readFileSync(url).toString());
if ( sync ) {
return JSON.parse( sander.readFileSync( url ).toString() );
} else {
return sander.readFile(url).then(String).then(JSON.parse);
return sander.readFile( url ).then( String ).then( JSON.parse );
}
}
function getSourceMappingUrl(str) {
function getSourceMappingUrl ( str ) {
var index, substring, url, match;
// assume we want the last occurence
index = str.lastIndexOf(SOURCEMAPPING_URL$1 + '=');
index = str.lastIndexOf( ("" + SOURCEMAPPING_URL$1 + "=") );
if (index === -1) {
if ( index === -1 ) {
return null;
}
substring = str.substring(index + 17);
match = /^[^\r\n]+/.exec(substring);
substring = str.substring( index + 17 );
match = /^[^\r\n]+/.exec( substring );

@@ -297,4 +297,4 @@ url = match ? match[0] : null;

// from the sourceMappingURL because it might not have been correctly encoded
if (url && url.slice(-2) === '*/') {
url = url.slice(0, -2).trim();
if ( url && url.slice( -2 ) === '*/' ) {
url = url.slice( 0, -2 ).trim();
}

@@ -305,27 +305,29 @@

function getMap(node, sourceMapByPath, sync) {
if (node.file in sourceMapByPath) {
var map = sourceMapByPath[node.file];
return sync ? map : sander.Promise.resolve(map);
} else {
var url = getSourceMappingUrl(node.content);
function getMap ( node, sourceMapByPath, sync ) {
if ( node.file in sourceMapByPath ) {
var map = sourceMapByPath[ node.file ];
return sync ? map : sander.Promise.resolve( map );
}
if (!url) {
else {
var url = getSourceMappingUrl( node.content );
if ( !url ) {
node.isOriginalSource = true;
return sync ? null : sander.Promise.resolve(null);
return sync ? null : sander.Promise.resolve( null );
}
return getMapFromUrl(url, node.file, sync);
return getMapFromUrl( url, node.file, sync );
}
}
function Node(_ref) {
var file = _ref.file;
var content = _ref.content;
function Node (ref) {
var file = ref.file;
var content = ref.content;
this.file = file ? path.resolve(file) : null;
this.file = file ? path.resolve( file ) : null;
this.content = content || null; // sometimes exists in sourcesContent, sometimes doesn't
if (!this.file && this.content === null) {
throw new Error('A source must specify either file or content');
if ( !this.file && this.content === null ) {
throw new Error( 'A source must specify either file or content' );
}

@@ -349,25 +351,25 @@

Node.prototype = {
load: function load(sourcesContentByPath, sourceMapByPath) {
var _this = this;
load: function load ( sourcesContentByPath, sourceMapByPath ) {
var this$1 = this;
return getContent(this, sourcesContentByPath).then(function (content) {
_this.content = sourcesContentByPath[_this.file] = content;
return getContent( this, sourcesContentByPath ).then( function ( content ) {
this$1.content = sourcesContentByPath[ this$1.file ] = content;
return getMap(_this, sourceMapByPath).then(function (map) {
if (!map) return null;
return getMap( this$1, sourceMapByPath ).then( function ( map ) {
if ( !map ) return null;
_this.map = map;
this$1.map = map;
var decodingStart = process.hrtime();
_this.mappings = decodeMappings(map.mappings);
var decodingTime = process.hrtime(decodingStart);
_this._stats.decodingTime = 1e9 * decodingTime[0] + decodingTime[1];
this$1.mappings = decodeMappings( map.mappings );
var decodingTime = process.hrtime( decodingStart );
this$1._stats.decodingTime = 1e9 * decodingTime[0] + decodingTime[1];
var sourcesContent = map.sourcesContent || [];
var sourceRoot = path.resolve(path.dirname(_this.file), map.sourceRoot || '');
var sourceRoot = path.resolve( path.dirname( this$1.file ), map.sourceRoot || '' );
_this.sources = map.sources.map(function (source, i) {
this$1.sources = map.sources.map( function ( source, i ) {
return new Node({
file: source ? path.resolve(sourceRoot, source) : null,
file: source ? path.resolve( sourceRoot, source ) : null,
content: sourcesContent[i]

@@ -377,44 +379,39 @@ });

var promises = _this.sources.map(function (node) {
return node.load(sourcesContentByPath, sourceMapByPath);
});
return sander.Promise.all(promises);
var promises = this$1.sources.map( function ( node ) { return node.load( sourcesContentByPath, sourceMapByPath ); } );
return sander.Promise.all( promises );
});
});
},
loadSync: function loadSync(sourcesContentByPath, sourceMapByPath) {
var _this2 = this;
if (!this.content) {
if (!sourcesContentByPath[this.file]) {
sourcesContentByPath[this.file] = sander.readFileSync(this.file).toString();
loadSync: function loadSync ( sourcesContentByPath, sourceMapByPath ) {
if ( !this.content ) {
if ( !sourcesContentByPath[ this.file ] ) {
sourcesContentByPath[ this.file ] = sander.readFileSync( this.file ).toString();
}
this.content = sourcesContentByPath[this.file];
this.content = sourcesContentByPath[ this.file ];
}
var map = getMap(this, sourceMapByPath, true);
var sourcesContent = undefined;
var map = getMap( this, sourceMapByPath, true );
var sourcesContent;
if (!map) {
if ( !map ) {
this.isOriginalSource = true;
} else {
(function () {
_this2.map = map;
_this2.mappings = decodeMappings(map.mappings);
this.map = map;
this.mappings = decodeMappings( map.mappings );
sourcesContent = map.sourcesContent || [];
sourcesContent = map.sourcesContent || [];
var sourceRoot = path.resolve(path.dirname(_this2.file), map.sourceRoot || '');
var sourceRoot = path.resolve( path.dirname( this.file ), map.sourceRoot || '' );
_this2.sources = map.sources.map(function (source, i) {
var node = new Node({
file: path.resolve(sourceRoot, source),
content: sourcesContent[i]
});
this.sources = map.sources.map( function ( source, i ) {
var node = new Node({
file: path.resolve( sourceRoot, source ),
content: sourcesContent[i]
});
node.loadSync(sourcesContentByPath, sourceMapByPath);
return node;
});
})();
node.loadSync( sourcesContentByPath, sourceMapByPath );
return node;
});
}

@@ -424,20 +421,22 @@ },

/**
* Traces a segment back to its origin
* @param {number} lineIndex - the zero-based line index of the
segment as found in `this`
* @param {number} columnIndex - the zero-based column index of the
segment as found in `this`
* @param {string || null} - if specified, the name that should be
(eventually) returned, as it is closest to the generated code
* @returns {object}
@property {string} source - the filepath of the source
@property {number} line - the one-based line index
@property {number} column - the zero-based column index
@property {string || null} name - the name corresponding
to the segment being traced
*/
trace: function trace(lineIndex, columnIndex, name) {
* Traces a segment back to its origin
* @param {number} lineIndex - the zero-based line index of the
segment as found in `this`
* @param {number} columnIndex - the zero-based column index of the
segment as found in `this`
* @param {string || null} - if specified, the name that should be
(eventually) returned, as it is closest to the generated code
* @returns {object}
@property {string} source - the filepath of the source
@property {number} line - the one-based line index
@property {number} column - the zero-based column index
@property {string || null} name - the name corresponding
to the segment being traced
*/
trace: function trace ( lineIndex, columnIndex, name ) {
// If this node doesn't have a source map, we have
// to assume it is the original source
if (this.isOriginalSource) {
var this$1 = this;
if ( this.isOriginalSource ) {
return {

@@ -453,29 +452,29 @@ source: this.file,

// the intermediate file corresponds to in *its* source
var segments = this.mappings[lineIndex];
var segments = this.mappings[ lineIndex ];
if (!segments || segments.length === 0) {
if ( !segments || segments.length === 0 ) {
return null;
}
if (columnIndex != null) {
if ( columnIndex != null ) {
var len = segments.length;
var i = undefined;
var i;
for (i = 0; i < len; i += 1) {
for ( i = 0; i < len; i += 1 ) {
var generatedCodeColumn = segments[i][0];
if (generatedCodeColumn > columnIndex) {
if ( generatedCodeColumn > columnIndex ) {
break;
}
if (generatedCodeColumn === columnIndex) {
if (segments[i].length < 4) return null;
if ( generatedCodeColumn === columnIndex ) {
if ( segments[i].length < 4 ) return null;
var _sourceFileIndex = segments[i][1];
var _sourceCodeLine = segments[i][2];
var sourceFileIndex$1 = segments[i][1];
var sourceCodeLine$1 = segments[i][2];
var sourceCodeColumn = segments[i][3];
var _nameIndex = segments[i][4];
var nameIndex$1 = segments[i][4];
var _parent = this.sources[_sourceFileIndex];
return _parent.trace(_sourceCodeLine, sourceCodeColumn, this.map.names[_nameIndex] || name);
var parent$1 = this$1.sources[ sourceFileIndex$1 ];
return parent$1.trace( sourceCodeLine$1, sourceCodeColumn, this$1.map.names[ nameIndex$1 ] || name );
}

@@ -490,17 +489,17 @@ }

var parent = this.sources[sourceFileIndex];
return parent.trace(sourceCodeLine, null, this.map.names[nameIndex] || name);
var parent = this.sources[ sourceFileIndex ];
return parent.trace( sourceCodeLine, null, this.map.names[ nameIndex ] || name );
}
};
function getContent(node, sourcesContentByPath) {
if (node.file in sourcesContentByPath) {
node.content = sourcesContentByPath[node.file];
function getContent ( node, sourcesContentByPath ) {
if ( node.file in sourcesContentByPath ) {
node.content = sourcesContentByPath[ node.file ];
}
if (!node.content) {
return sander.readFile(node.file).then(String);
if ( !node.content ) {
return sander.readFile( node.file ).then( String );
}
return sander.Promise.resolve(node.content);
return sander.Promise.resolve( node.content );
}

@@ -513,34 +512,38 @@

*/
function btoa(str) {
return new Buffer(str).toString('base64');
function btoa ( str ) {
return new Buffer( str ).toString( 'base64' );
}
function SourceMap(properties) {
function SourceMap ( properties ) {
this.version = 3;
this.file = properties.file;
this.sources = properties.sources;
this.file = properties.file;
this.sources = properties.sources;
this.sourcesContent = properties.sourcesContent;
this.names = properties.names;
this.mappings = properties.mappings;
this.names = properties.names;
this.mappings = properties.mappings;
}
SourceMap.prototype = {
toString: function toString() {
return JSON.stringify(this);
toString: function toString () {
return JSON.stringify( this );
},
toUrl: function toUrl() {
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
toUrl: function toUrl () {
return 'data:application/json;charset=utf-8;base64,' + btoa( this.toString() );
}
};
function slash(path) {
return typeof path === 'string' ? path.replace(/\\/g, '/') : path;
function slash ( path ) {
return typeof path === 'string' ?
path.replace( /\\/g, '/' ) :
path;
}
var SOURCEMAP_COMMENT = new RegExp('\n*(?:' + ('\\/\\/[@#]\\s*' + SOURCEMAPPING_URL$1 + '=([^\'"]+)|') + ( // js
'\\/\\*#?\\s*' + SOURCEMAPPING_URL$1 + '=([^\'"]+)\\s\\*\\/)') + // css
'\\s*$', 'g');
var SOURCEMAP_COMMENT = new RegExp( "\n*(?:" +
"\\/\\/[@#]\\s*" + SOURCEMAPPING_URL$1 + "=([^'\"]+)|" + // js
"\\/\\*#?\\s*" + SOURCEMAPPING_URL$1 + "=([^'\"]+)\\s\\*\\/)" + // css
"\\s*$", 'g' );
function Chain(node, sourcesContentByPath) {
function Chain ( node, sourcesContentByPath ) {
this.node = node;

@@ -553,6 +556,6 @@ this.sourcesContentByPath = sourcesContentByPath;

Chain.prototype = {
stat: function stat() {
stat: function stat () {
return {
selfDecodingTime: this._stats.decodingTime / 1e6,
totalDecodingTime: (this._stats.decodingTime + tally(this.node.sources, 'decodingTime')) / 1e6,
totalDecodingTime: ( this._stats.decodingTime + tally( this.node.sources, 'decodingTime' ) ) / 1e6,

@@ -565,6 +568,6 @@ encodingTime: this._stats.encodingTime / 1e6,

},
apply: function apply() {
var _this = this;
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
apply: function apply ( options ) {
var this$1 = this;
if ( options === void 0 ) options = {};

@@ -574,29 +577,34 @@ var allNames = [];

var applySegment = function applySegment(segment, result) {
if (segment.length < 4) return;
var applySegment = function ( segment, result ) {
if ( segment.length < 4 ) return;
var traced = _this.node.sources[segment[1]].trace( // source
segment[2], // source code line
segment[3], // source code column
_this.node.map.names[segment[4]]);
var traced = this$1.node.sources[ segment[1] ].trace( // source
segment[2], // source code line
segment[3], // source code column
this$1.node.map.names[ segment[4] ]
);
if (!traced) {
_this._stats.untraceable += 1;
if ( !traced ) {
this$1._stats.untraceable += 1;
return;
}
var sourceIndex = allSources.indexOf(traced.source);
if (! ~sourceIndex) {
var sourceIndex = allSources.indexOf( traced.source );
if ( !~sourceIndex ) {
sourceIndex = allSources.length;
allSources.push(traced.source);
allSources.push( traced.source );
}
var newSegment = [segment[0], // generated code column
sourceIndex, traced.line - 1, traced.column];
var newSegment = [
segment[0], // generated code column
sourceIndex,
traced.line - 1,
traced.column
];
if (traced.name) {
var nameIndex = allNames.indexOf(traced.name);
if (! ~nameIndex) {
if ( traced.name ) {
var nameIndex = allNames.indexOf( traced.name );
if ( !~nameIndex ) {
nameIndex = allNames.length;
allNames.push(traced.name);
allNames.push( traced.name );
}

@@ -607,3 +615,3 @@

result[result.length] = newSegment;
result[ result.length ] = newSegment;
};

@@ -615,18 +623,16 @@

var i = this.node.mappings.length;
var resolved = new Array(i);
var resolved = new Array( i );
var j = undefined,
line = undefined,
result = undefined;
var j, line, result;
while (i--) {
line = this.node.mappings[i];
while ( i-- ) {
line = this$1.node.mappings[i];
resolved[i] = result = [];
for (j = 0; j < line.length; j += 1) {
applySegment(line[j], result);
for ( j = 0; j < line.length; j += 1 ) {
applySegment( line[j], result );
}
}
var tracingTime = process.hrtime(tracingStart);
var tracingTime = process.hrtime( tracingStart );
this._stats.tracingTime = 1e9 * tracingTime[0] + tracingTime[1];

@@ -636,4 +642,4 @@

var encodingStart = process.hrtime();
var mappings = encode(resolved);
var encodingTime = process.hrtime(encodingStart);
var mappings = encode( resolved );
var encodingTime = process.hrtime( encodingStart );
this._stats.encodingTime = 1e9 * encodingTime[0] + encodingTime[1];

@@ -644,9 +650,5 @@

return new SourceMap({
file: path.basename(this.node.file),
sources: allSources.map(function (source) {
return slash(path.relative(options.base || path.dirname(_this.node.file), source));
}),
sourcesContent: allSources.map(function (source) {
return includeContent ? _this.sourcesContentByPath[source] : null;
}),
file: path.basename( this.node.file ),
sources: allSources.map( function ( source ) { return slash( path.relative( options.base || path.dirname( this$1.node.file ), source ) ); } ),
sourcesContent: allSources.map( function ( source ) { return includeContent ? this$1.sourcesContentByPath[ source ] : null; } ),
names: allNames,

@@ -656,7 +658,9 @@ mappings: mappings

},
trace: function trace(oneBasedLineIndex, zeroBasedColumnIndex) {
return this.node.trace(oneBasedLineIndex - 1, zeroBasedColumnIndex, null);
trace: function trace ( oneBasedLineIndex, zeroBasedColumnIndex ) {
return this.node.trace( oneBasedLineIndex - 1, zeroBasedColumnIndex, null );
},
write: function write(dest, options) {
if (typeof dest !== 'string') {
write: function write ( dest, options ) {
if ( typeof dest !== 'string' ) {
options = dest;

@@ -668,18 +672,15 @@ dest = this.node.file;

var _processWriteOptions = processWriteOptions(dest, this, options);
var ref = processWriteOptions( dest, this, options ), resolved = ref.resolved, content = ref.content, map = ref.map;
var resolved = _processWriteOptions.resolved;
var content = _processWriteOptions.content;
var map = _processWriteOptions.map;
var promises = [ sander.writeFile( resolved, content ) ];
var promises = [sander.writeFile(resolved, content)];
if (!options.inline) {
promises.push(sander.writeFile(resolved + '.map', map.toString()));
if ( !options.inline ) {
promises.push( sander.writeFile( resolved + '.map', map.toString() ) );
}
return Promise.all(promises);
return Promise.all( promises );
},
writeSync: function writeSync(dest, options) {
if (typeof dest !== 'string') {
writeSync: function writeSync ( dest, options ) {
if ( typeof dest !== 'string' ) {
options = dest;

@@ -691,12 +692,8 @@ dest = this.node.file;

var _processWriteOptions2 = processWriteOptions(dest, this, options);
var ref = processWriteOptions( dest, this, options ), resolved = ref.resolved, content = ref.content, map = ref.map;
var resolved = _processWriteOptions2.resolved;
var content = _processWriteOptions2.content;
var map = _processWriteOptions2.map;
sander.writeFileSync( resolved, content );
sander.writeFileSync(resolved, content);
if (!options.inline) {
sander.writeFileSync(resolved + '.map', map.toString());
if ( !options.inline ) {
sander.writeFileSync( resolved + '.map', map.toString() );
}

@@ -706,14 +703,14 @@ }

function processWriteOptions(dest, chain, options) {
var resolved = path.resolve(dest);
function processWriteOptions ( dest, chain, options ) {
var resolved = path.resolve( dest );
var map = chain.apply({
includeContent: options.includeContent,
base: options.base ? path.resolve(options.base) : path.dirname(resolved)
base: options.base ? path.resolve( options.base ) : path.dirname( resolved )
});
var url = options.inline ? map.toUrl() : (options.absolutePath ? resolved : path.basename(resolved)) + '.map';
var url = options.inline ? map.toUrl() : ( options.absolutePath ? resolved : path.basename( resolved ) ) + '.map';
// TODO shouldn't url be relative?
var content = chain.node.content.replace(SOURCEMAP_COMMENT, '') + sourcemapComment(url, resolved);
var content = chain.node.content.replace( SOURCEMAP_COMMENT, '' ) + sourcemapComment( url, resolved );

@@ -723,46 +720,37 @@ return { resolved: resolved, content: content, map: map };

function tally(nodes, stat) {
return nodes.reduce(function (total, node) {
return total + node._stats[stat];
}, 0);
function tally ( nodes, stat ) {
return nodes.reduce( function ( total, node ) {
return total + node._stats[ stat ];
}, 0 );
}
function sourcemapComment(url, dest) {
var ext = path.extname(dest);
url = encodeURI(url);
function sourcemapComment ( url, dest ) {
var ext = path.extname( dest );
url = encodeURI( url );
if (ext === '.css') {
return '\n/*# ' + SOURCEMAPPING_URL$1 + '=' + url + ' */\n';
if ( ext === '.css' ) {
return ("\n/*# " + SOURCEMAPPING_URL$1 + "=" + url + " */\n");
}
return '\n//# ' + SOURCEMAPPING_URL$1 + '=' + url + '\n';
return ("\n//# " + SOURCEMAPPING_URL$1 + "=" + url + "\n");
}
function load(file, options) {
var _init = init(file, options);
function load ( file, options ) {
var ref = init( file, options ), node = ref.node, sourcesContentByPath = ref.sourcesContentByPath, sourceMapByPath = ref.sourceMapByPath;
var node = _init.node;
var sourcesContentByPath = _init.sourcesContentByPath;
var sourceMapByPath = _init.sourceMapByPath;
return node.load(sourcesContentByPath, sourceMapByPath).then(function () {
return node.isOriginalSource ? null : new Chain(node, sourcesContentByPath);
});
return node.load( sourcesContentByPath, sourceMapByPath )
.then( function () { return node.isOriginalSource ? null : new Chain( node, sourcesContentByPath ); } );
}
function loadSync(file) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
function loadSync ( file, options ) {
if ( options === void 0 ) options = {};
var _init2 = init(file, options);
var ref = init( file, options ), node = ref.node, sourcesContentByPath = ref.sourcesContentByPath, sourceMapByPath = ref.sourceMapByPath;
var node = _init2.node;
var sourcesContentByPath = _init2.sourcesContentByPath;
var sourceMapByPath = _init2.sourceMapByPath;
node.loadSync(sourcesContentByPath, sourceMapByPath);
return node.isOriginalSource ? null : new Chain(node, sourcesContentByPath);
node.loadSync( sourcesContentByPath, sourceMapByPath );
return node.isOriginalSource ? null : new Chain( node, sourcesContentByPath );
}
function init(file) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
function init ( file, options ) {
if ( options === void 0 ) options = {};

@@ -774,11 +762,11 @@ var node = new Node({ file: file });

if (options.content) {
Object.keys(options.content).forEach(function (key) {
sourcesContentByPath[path.resolve(key)] = options.content[key];
if ( options.content ) {
Object.keys( options.content ).forEach( function ( key ) {
sourcesContentByPath[ path.resolve( key ) ] = options.content[ key ];
});
}
if (options.sourcemaps) {
Object.keys(options.sourcemaps).forEach(function (key) {
sourceMapByPath[path.resolve(key)] = options.sourcemaps[key];
if ( options.sourcemaps ) {
Object.keys( options.sourcemaps ).forEach( function ( key ) {
sourceMapByPath[ path.resolve( key ) ] = options.sourcemaps[ key ];
});

@@ -785,0 +773,0 @@ }

@@ -8,22 +8,22 @@ import { resolve, dirname, relative, basename, extname } from 'path';

'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split('').forEach(function (char, i) {
charToInteger[char] = i;
integerToChar[i] = char;
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
charToInteger[ char ] = i;
integerToChar[ i ] = char;
});
function decode$1(string) {
function decode$1 ( string ) {
var result = [],
len = string.length,
i,
hasContinuationBit,
shift = 0,
value = 0,
integer,
shouldNegate;
len = string.length,
i,
hasContinuationBit,
shift = 0,
value = 0,
integer,
shouldNegate;
for (i = 0; i < len; i += 1) {
integer = charToInteger[string[i]];
for ( i = 0; i < len; i += 1 ) {
integer = charToInteger[ string[i] ];
if (integer === undefined) {
throw new Error('Invalid character (' + string[i] + ')');
if ( integer === undefined ) {
throw new Error( 'Invalid character (' + string[i] + ')' );
}

@@ -36,3 +36,3 @@

if (hasContinuationBit) {
if ( hasContinuationBit ) {
shift += 5;

@@ -43,3 +43,3 @@ } else {

result.push(shouldNegate ? -value : value);
result.push( shouldNegate ? -value : value );

@@ -54,11 +54,11 @@ // reset

function encode$1(value) {
function encode$1 ( value ) {
var result, i;
if (typeof value === 'number') {
result = encodeInteger(value);
if ( typeof value === 'number' ) {
result = encodeInteger( value );
} else {
result = '';
for (i = 0; i < value.length; i += 1) {
result += encodeInteger(value[i]);
for ( i = 0; i < value.length; i += 1 ) {
result += encodeInteger( value[i] );
}

@@ -70,8 +70,7 @@ }

function encodeInteger(num) {
var result = '',
clamped;
function encodeInteger ( num ) {
var result = '', clamped;
if (num < 0) {
num = -num << 1 | 1;
if ( num < 0 ) {
num = ( -num << 1 ) | 1;
} else {

@@ -85,8 +84,8 @@ num <<= 1;

if (num > 0) {
if ( num > 0 ) {
clamped |= 32;
}
result += integerToChar[clamped];
} while (num > 0);
result += integerToChar[ clamped ];
} while ( num > 0 );

@@ -100,4 +99,5 @@ return result;

while (i--) segments[i] = decode$1(encodedSegments[i]);
return segments;
while (i--) {
segments[i] = decode$1(encodedSegments[i]);
}return segments;
}

@@ -215,10 +215,10 @@

function decodeMappings(mappings) {
var checksum = crc32(mappings);
function decodeMappings ( mappings ) {
var checksum = crc32( mappings );
if (!cache[checksum]) {
cache[checksum] = decode(mappings);
if ( !cache[ checksum ] ) {
cache[ checksum ] = decode( mappings );
}
return cache[checksum];
return cache[ checksum ];
}

@@ -231,4 +231,4 @@

*/
function atob(base64) {
return new Buffer(base64, 'base64').toString('utf8');
function atob ( base64 ) {
return new Buffer( base64, 'base64' ).toString( 'utf8' );
}

@@ -253,37 +253,36 @@

*/
function getMapFromUrl(url, base, sync) {
if (/^data:/.test(url)) {
// TODO beef this up
var match = /base64,(.+)$/.exec(url);
function getMapFromUrl ( url, base, sync ) {
if ( /^data:/.test( url ) ) { // TODO beef this up
var match = /base64,(.+)$/.exec( url );
if (!match) {
throw new Error(SOURCEMAPPING_URL$1 + ' is not base64-encoded');
if ( !match ) {
throw new Error( ("" + SOURCEMAPPING_URL$1 + " is not base64-encoded") );
}
var json = atob(match[1]);
var map = JSON.parse(json);
return sync ? map : Promise.resolve(map);
var json = atob( match[1] );
var map = JSON.parse( json );
return sync ? map : Promise$1.resolve( map );
}
url = resolve(dirname(base), decodeURI(url));
url = resolve( dirname( base ), decodeURI( url ) );
if (sync) {
return JSON.parse(readFileSync(url).toString());
if ( sync ) {
return JSON.parse( readFileSync( url ).toString() );
} else {
return readFile(url).then(String).then(JSON.parse);
return readFile( url ).then( String ).then( JSON.parse );
}
}
function getSourceMappingUrl(str) {
function getSourceMappingUrl ( str ) {
var index, substring, url, match;
// assume we want the last occurence
index = str.lastIndexOf(SOURCEMAPPING_URL$1 + '=');
index = str.lastIndexOf( ("" + SOURCEMAPPING_URL$1 + "=") );
if (index === -1) {
if ( index === -1 ) {
return null;
}
substring = str.substring(index + 17);
match = /^[^\r\n]+/.exec(substring);
substring = str.substring( index + 17 );
match = /^[^\r\n]+/.exec( substring );

@@ -294,4 +293,4 @@ url = match ? match[0] : null;

// from the sourceMappingURL because it might not have been correctly encoded
if (url && url.slice(-2) === '*/') {
url = url.slice(0, -2).trim();
if ( url && url.slice( -2 ) === '*/' ) {
url = url.slice( 0, -2 ).trim();
}

@@ -302,27 +301,29 @@

function getMap(node, sourceMapByPath, sync) {
if (node.file in sourceMapByPath) {
var map = sourceMapByPath[node.file];
return sync ? map : Promise.resolve(map);
} else {
var url = getSourceMappingUrl(node.content);
function getMap ( node, sourceMapByPath, sync ) {
if ( node.file in sourceMapByPath ) {
var map = sourceMapByPath[ node.file ];
return sync ? map : Promise$1.resolve( map );
}
if (!url) {
else {
var url = getSourceMappingUrl( node.content );
if ( !url ) {
node.isOriginalSource = true;
return sync ? null : Promise.resolve(null);
return sync ? null : Promise$1.resolve( null );
}
return getMapFromUrl(url, node.file, sync);
return getMapFromUrl( url, node.file, sync );
}
}
function Node(_ref) {
var file = _ref.file;
var content = _ref.content;
function Node (ref) {
var file = ref.file;
var content = ref.content;
this.file = file ? resolve(file) : null;
this.file = file ? resolve( file ) : null;
this.content = content || null; // sometimes exists in sourcesContent, sometimes doesn't
if (!this.file && this.content === null) {
throw new Error('A source must specify either file or content');
if ( !this.file && this.content === null ) {
throw new Error( 'A source must specify either file or content' );
}

@@ -346,25 +347,25 @@

Node.prototype = {
load: function load(sourcesContentByPath, sourceMapByPath) {
var _this = this;
load: function load ( sourcesContentByPath, sourceMapByPath ) {
var this$1 = this;
return getContent(this, sourcesContentByPath).then(function (content) {
_this.content = sourcesContentByPath[_this.file] = content;
return getContent( this, sourcesContentByPath ).then( function ( content ) {
this$1.content = sourcesContentByPath[ this$1.file ] = content;
return getMap(_this, sourceMapByPath).then(function (map) {
if (!map) return null;
return getMap( this$1, sourceMapByPath ).then( function ( map ) {
if ( !map ) return null;
_this.map = map;
this$1.map = map;
var decodingStart = process.hrtime();
_this.mappings = decodeMappings(map.mappings);
var decodingTime = process.hrtime(decodingStart);
_this._stats.decodingTime = 1e9 * decodingTime[0] + decodingTime[1];
this$1.mappings = decodeMappings( map.mappings );
var decodingTime = process.hrtime( decodingStart );
this$1._stats.decodingTime = 1e9 * decodingTime[0] + decodingTime[1];
var sourcesContent = map.sourcesContent || [];
var sourceRoot = resolve(dirname(_this.file), map.sourceRoot || '');
var sourceRoot = resolve( dirname( this$1.file ), map.sourceRoot || '' );
_this.sources = map.sources.map(function (source, i) {
this$1.sources = map.sources.map( function ( source, i ) {
return new Node({
file: source ? resolve(sourceRoot, source) : null,
file: source ? resolve( sourceRoot, source ) : null,
content: sourcesContent[i]

@@ -374,44 +375,39 @@ });

var promises = _this.sources.map(function (node) {
return node.load(sourcesContentByPath, sourceMapByPath);
});
return Promise.all(promises);
var promises = this$1.sources.map( function ( node ) { return node.load( sourcesContentByPath, sourceMapByPath ); } );
return Promise$1.all( promises );
});
});
},
loadSync: function loadSync(sourcesContentByPath, sourceMapByPath) {
var _this2 = this;
if (!this.content) {
if (!sourcesContentByPath[this.file]) {
sourcesContentByPath[this.file] = readFileSync(this.file).toString();
loadSync: function loadSync ( sourcesContentByPath, sourceMapByPath ) {
if ( !this.content ) {
if ( !sourcesContentByPath[ this.file ] ) {
sourcesContentByPath[ this.file ] = readFileSync( this.file ).toString();
}
this.content = sourcesContentByPath[this.file];
this.content = sourcesContentByPath[ this.file ];
}
var map = getMap(this, sourceMapByPath, true);
var sourcesContent = undefined;
var map = getMap( this, sourceMapByPath, true );
var sourcesContent;
if (!map) {
if ( !map ) {
this.isOriginalSource = true;
} else {
(function () {
_this2.map = map;
_this2.mappings = decodeMappings(map.mappings);
this.map = map;
this.mappings = decodeMappings( map.mappings );
sourcesContent = map.sourcesContent || [];
sourcesContent = map.sourcesContent || [];
var sourceRoot = resolve(dirname(_this2.file), map.sourceRoot || '');
var sourceRoot = resolve( dirname( this.file ), map.sourceRoot || '' );
_this2.sources = map.sources.map(function (source, i) {
var node = new Node({
file: resolve(sourceRoot, source),
content: sourcesContent[i]
});
this.sources = map.sources.map( function ( source, i ) {
var node = new Node({
file: resolve( sourceRoot, source ),
content: sourcesContent[i]
});
node.loadSync(sourcesContentByPath, sourceMapByPath);
return node;
});
})();
node.loadSync( sourcesContentByPath, sourceMapByPath );
return node;
});
}

@@ -421,20 +417,22 @@ },

/**
* Traces a segment back to its origin
* @param {number} lineIndex - the zero-based line index of the
segment as found in `this`
* @param {number} columnIndex - the zero-based column index of the
segment as found in `this`
* @param {string || null} - if specified, the name that should be
(eventually) returned, as it is closest to the generated code
* @returns {object}
@property {string} source - the filepath of the source
@property {number} line - the one-based line index
@property {number} column - the zero-based column index
@property {string || null} name - the name corresponding
to the segment being traced
*/
trace: function trace(lineIndex, columnIndex, name) {
* Traces a segment back to its origin
* @param {number} lineIndex - the zero-based line index of the
segment as found in `this`
* @param {number} columnIndex - the zero-based column index of the
segment as found in `this`
* @param {string || null} - if specified, the name that should be
(eventually) returned, as it is closest to the generated code
* @returns {object}
@property {string} source - the filepath of the source
@property {number} line - the one-based line index
@property {number} column - the zero-based column index
@property {string || null} name - the name corresponding
to the segment being traced
*/
trace: function trace ( lineIndex, columnIndex, name ) {
// If this node doesn't have a source map, we have
// to assume it is the original source
if (this.isOriginalSource) {
var this$1 = this;
if ( this.isOriginalSource ) {
return {

@@ -450,29 +448,29 @@ source: this.file,

// the intermediate file corresponds to in *its* source
var segments = this.mappings[lineIndex];
var segments = this.mappings[ lineIndex ];
if (!segments || segments.length === 0) {
if ( !segments || segments.length === 0 ) {
return null;
}
if (columnIndex != null) {
if ( columnIndex != null ) {
var len = segments.length;
var i = undefined;
var i;
for (i = 0; i < len; i += 1) {
for ( i = 0; i < len; i += 1 ) {
var generatedCodeColumn = segments[i][0];
if (generatedCodeColumn > columnIndex) {
if ( generatedCodeColumn > columnIndex ) {
break;
}
if (generatedCodeColumn === columnIndex) {
if (segments[i].length < 4) return null;
if ( generatedCodeColumn === columnIndex ) {
if ( segments[i].length < 4 ) return null;
var _sourceFileIndex = segments[i][1];
var _sourceCodeLine = segments[i][2];
var sourceFileIndex$1 = segments[i][1];
var sourceCodeLine$1 = segments[i][2];
var sourceCodeColumn = segments[i][3];
var _nameIndex = segments[i][4];
var nameIndex$1 = segments[i][4];
var _parent = this.sources[_sourceFileIndex];
return _parent.trace(_sourceCodeLine, sourceCodeColumn, this.map.names[_nameIndex] || name);
var parent$1 = this$1.sources[ sourceFileIndex$1 ];
return parent$1.trace( sourceCodeLine$1, sourceCodeColumn, this$1.map.names[ nameIndex$1 ] || name );
}

@@ -487,17 +485,17 @@ }

var parent = this.sources[sourceFileIndex];
return parent.trace(sourceCodeLine, null, this.map.names[nameIndex] || name);
var parent = this.sources[ sourceFileIndex ];
return parent.trace( sourceCodeLine, null, this.map.names[ nameIndex ] || name );
}
};
function getContent(node, sourcesContentByPath) {
if (node.file in sourcesContentByPath) {
node.content = sourcesContentByPath[node.file];
function getContent ( node, sourcesContentByPath ) {
if ( node.file in sourcesContentByPath ) {
node.content = sourcesContentByPath[ node.file ];
}
if (!node.content) {
return readFile(node.file).then(String);
if ( !node.content ) {
return readFile( node.file ).then( String );
}
return Promise.resolve(node.content);
return Promise$1.resolve( node.content );
}

@@ -510,34 +508,38 @@

*/
function btoa(str) {
return new Buffer(str).toString('base64');
function btoa ( str ) {
return new Buffer( str ).toString( 'base64' );
}
function SourceMap(properties) {
function SourceMap ( properties ) {
this.version = 3;
this.file = properties.file;
this.sources = properties.sources;
this.file = properties.file;
this.sources = properties.sources;
this.sourcesContent = properties.sourcesContent;
this.names = properties.names;
this.mappings = properties.mappings;
this.names = properties.names;
this.mappings = properties.mappings;
}
SourceMap.prototype = {
toString: function toString() {
return JSON.stringify(this);
toString: function toString () {
return JSON.stringify( this );
},
toUrl: function toUrl() {
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
toUrl: function toUrl () {
return 'data:application/json;charset=utf-8;base64,' + btoa( this.toString() );
}
};
function slash(path) {
return typeof path === 'string' ? path.replace(/\\/g, '/') : path;
function slash ( path ) {
return typeof path === 'string' ?
path.replace( /\\/g, '/' ) :
path;
}
var SOURCEMAP_COMMENT = new RegExp('\n*(?:' + ('\\/\\/[@#]\\s*' + SOURCEMAPPING_URL$1 + '=([^\'"]+)|') + ( // js
'\\/\\*#?\\s*' + SOURCEMAPPING_URL$1 + '=([^\'"]+)\\s\\*\\/)') + // css
'\\s*$', 'g');
var SOURCEMAP_COMMENT = new RegExp( "\n*(?:" +
"\\/\\/[@#]\\s*" + SOURCEMAPPING_URL$1 + "=([^'\"]+)|" + // js
"\\/\\*#?\\s*" + SOURCEMAPPING_URL$1 + "=([^'\"]+)\\s\\*\\/)" + // css
"\\s*$", 'g' );
function Chain(node, sourcesContentByPath) {
function Chain ( node, sourcesContentByPath ) {
this.node = node;

@@ -550,6 +552,6 @@ this.sourcesContentByPath = sourcesContentByPath;

Chain.prototype = {
stat: function stat() {
stat: function stat () {
return {
selfDecodingTime: this._stats.decodingTime / 1e6,
totalDecodingTime: (this._stats.decodingTime + tally(this.node.sources, 'decodingTime')) / 1e6,
totalDecodingTime: ( this._stats.decodingTime + tally( this.node.sources, 'decodingTime' ) ) / 1e6,

@@ -562,6 +564,6 @@ encodingTime: this._stats.encodingTime / 1e6,

},
apply: function apply() {
var _this = this;
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
apply: function apply ( options ) {
var this$1 = this;
if ( options === void 0 ) options = {};

@@ -571,29 +573,34 @@ var allNames = [];

var applySegment = function applySegment(segment, result) {
if (segment.length < 4) return;
var applySegment = function ( segment, result ) {
if ( segment.length < 4 ) return;
var traced = _this.node.sources[segment[1]].trace( // source
segment[2], // source code line
segment[3], // source code column
_this.node.map.names[segment[4]]);
var traced = this$1.node.sources[ segment[1] ].trace( // source
segment[2], // source code line
segment[3], // source code column
this$1.node.map.names[ segment[4] ]
);
if (!traced) {
_this._stats.untraceable += 1;
if ( !traced ) {
this$1._stats.untraceable += 1;
return;
}
var sourceIndex = allSources.indexOf(traced.source);
if (! ~sourceIndex) {
var sourceIndex = allSources.indexOf( traced.source );
if ( !~sourceIndex ) {
sourceIndex = allSources.length;
allSources.push(traced.source);
allSources.push( traced.source );
}
var newSegment = [segment[0], // generated code column
sourceIndex, traced.line - 1, traced.column];
var newSegment = [
segment[0], // generated code column
sourceIndex,
traced.line - 1,
traced.column
];
if (traced.name) {
var nameIndex = allNames.indexOf(traced.name);
if (! ~nameIndex) {
if ( traced.name ) {
var nameIndex = allNames.indexOf( traced.name );
if ( !~nameIndex ) {
nameIndex = allNames.length;
allNames.push(traced.name);
allNames.push( traced.name );
}

@@ -604,3 +611,3 @@

result[result.length] = newSegment;
result[ result.length ] = newSegment;
};

@@ -612,18 +619,16 @@

var i = this.node.mappings.length;
var resolved = new Array(i);
var resolved = new Array( i );
var j = undefined,
line = undefined,
result = undefined;
var j, line, result;
while (i--) {
line = this.node.mappings[i];
while ( i-- ) {
line = this$1.node.mappings[i];
resolved[i] = result = [];
for (j = 0; j < line.length; j += 1) {
applySegment(line[j], result);
for ( j = 0; j < line.length; j += 1 ) {
applySegment( line[j], result );
}
}
var tracingTime = process.hrtime(tracingStart);
var tracingTime = process.hrtime( tracingStart );
this._stats.tracingTime = 1e9 * tracingTime[0] + tracingTime[1];

@@ -633,4 +638,4 @@

var encodingStart = process.hrtime();
var mappings = encode(resolved);
var encodingTime = process.hrtime(encodingStart);
var mappings = encode( resolved );
var encodingTime = process.hrtime( encodingStart );
this._stats.encodingTime = 1e9 * encodingTime[0] + encodingTime[1];

@@ -641,9 +646,5 @@

return new SourceMap({
file: basename(this.node.file),
sources: allSources.map(function (source) {
return slash(relative(options.base || dirname(_this.node.file), source));
}),
sourcesContent: allSources.map(function (source) {
return includeContent ? _this.sourcesContentByPath[source] : null;
}),
file: basename( this.node.file ),
sources: allSources.map( function ( source ) { return slash( relative( options.base || dirname( this$1.node.file ), source ) ); } ),
sourcesContent: allSources.map( function ( source ) { return includeContent ? this$1.sourcesContentByPath[ source ] : null; } ),
names: allNames,

@@ -653,7 +654,9 @@ mappings: mappings

},
trace: function trace(oneBasedLineIndex, zeroBasedColumnIndex) {
return this.node.trace(oneBasedLineIndex - 1, zeroBasedColumnIndex, null);
trace: function trace ( oneBasedLineIndex, zeroBasedColumnIndex ) {
return this.node.trace( oneBasedLineIndex - 1, zeroBasedColumnIndex, null );
},
write: function write(dest, options) {
if (typeof dest !== 'string') {
write: function write ( dest, options ) {
if ( typeof dest !== 'string' ) {
options = dest;

@@ -665,18 +668,15 @@ dest = this.node.file;

var _processWriteOptions = processWriteOptions(dest, this, options);
var ref = processWriteOptions( dest, this, options ), resolved = ref.resolved, content = ref.content, map = ref.map;
var resolved = _processWriteOptions.resolved;
var content = _processWriteOptions.content;
var map = _processWriteOptions.map;
var promises = [ writeFile( resolved, content ) ];
var promises = [writeFile(resolved, content)];
if (!options.inline) {
promises.push(writeFile(resolved + '.map', map.toString()));
if ( !options.inline ) {
promises.push( writeFile( resolved + '.map', map.toString() ) );
}
return Promise.all(promises);
return Promise.all( promises );
},
writeSync: function writeSync(dest, options) {
if (typeof dest !== 'string') {
writeSync: function writeSync ( dest, options ) {
if ( typeof dest !== 'string' ) {
options = dest;

@@ -688,12 +688,8 @@ dest = this.node.file;

var _processWriteOptions2 = processWriteOptions(dest, this, options);
var ref = processWriteOptions( dest, this, options ), resolved = ref.resolved, content = ref.content, map = ref.map;
var resolved = _processWriteOptions2.resolved;
var content = _processWriteOptions2.content;
var map = _processWriteOptions2.map;
writeFileSync( resolved, content );
writeFileSync(resolved, content);
if (!options.inline) {
writeFileSync(resolved + '.map', map.toString());
if ( !options.inline ) {
writeFileSync( resolved + '.map', map.toString() );
}

@@ -703,14 +699,14 @@ }

function processWriteOptions(dest, chain, options) {
var resolved = resolve(dest);
function processWriteOptions ( dest, chain, options ) {
var resolved = resolve( dest );
var map = chain.apply({
includeContent: options.includeContent,
base: options.base ? resolve(options.base) : dirname(resolved)
base: options.base ? resolve( options.base ) : dirname( resolved )
});
var url = options.inline ? map.toUrl() : (options.absolutePath ? resolved : basename(resolved)) + '.map';
var url = options.inline ? map.toUrl() : ( options.absolutePath ? resolved : basename( resolved ) ) + '.map';
// TODO shouldn't url be relative?
var content = chain.node.content.replace(SOURCEMAP_COMMENT, '') + sourcemapComment(url, resolved);
var content = chain.node.content.replace( SOURCEMAP_COMMENT, '' ) + sourcemapComment( url, resolved );

@@ -720,46 +716,37 @@ return { resolved: resolved, content: content, map: map };

function tally(nodes, stat) {
return nodes.reduce(function (total, node) {
return total + node._stats[stat];
}, 0);
function tally ( nodes, stat ) {
return nodes.reduce( function ( total, node ) {
return total + node._stats[ stat ];
}, 0 );
}
function sourcemapComment(url, dest) {
var ext = extname(dest);
url = encodeURI(url);
function sourcemapComment ( url, dest ) {
var ext = extname( dest );
url = encodeURI( url );
if (ext === '.css') {
return '\n/*# ' + SOURCEMAPPING_URL$1 + '=' + url + ' */\n';
if ( ext === '.css' ) {
return ("\n/*# " + SOURCEMAPPING_URL$1 + "=" + url + " */\n");
}
return '\n//# ' + SOURCEMAPPING_URL$1 + '=' + url + '\n';
return ("\n//# " + SOURCEMAPPING_URL$1 + "=" + url + "\n");
}
function load(file, options) {
var _init = init(file, options);
function load ( file, options ) {
var ref = init( file, options ), node = ref.node, sourcesContentByPath = ref.sourcesContentByPath, sourceMapByPath = ref.sourceMapByPath;
var node = _init.node;
var sourcesContentByPath = _init.sourcesContentByPath;
var sourceMapByPath = _init.sourceMapByPath;
return node.load(sourcesContentByPath, sourceMapByPath).then(function () {
return node.isOriginalSource ? null : new Chain(node, sourcesContentByPath);
});
return node.load( sourcesContentByPath, sourceMapByPath )
.then( function () { return node.isOriginalSource ? null : new Chain( node, sourcesContentByPath ); } );
}
function loadSync(file) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
function loadSync ( file, options ) {
if ( options === void 0 ) options = {};
var _init2 = init(file, options);
var ref = init( file, options ), node = ref.node, sourcesContentByPath = ref.sourcesContentByPath, sourceMapByPath = ref.sourceMapByPath;
var node = _init2.node;
var sourcesContentByPath = _init2.sourcesContentByPath;
var sourceMapByPath = _init2.sourceMapByPath;
node.loadSync(sourcesContentByPath, sourceMapByPath);
return node.isOriginalSource ? null : new Chain(node, sourcesContentByPath);
node.loadSync( sourcesContentByPath, sourceMapByPath );
return node.isOriginalSource ? null : new Chain( node, sourcesContentByPath );
}
function init(file) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
function init ( file, options ) {
if ( options === void 0 ) options = {};

@@ -771,11 +758,11 @@ var node = new Node({ file: file });

if (options.content) {
Object.keys(options.content).forEach(function (key) {
sourcesContentByPath[resolve(key)] = options.content[key];
if ( options.content ) {
Object.keys( options.content ).forEach( function ( key ) {
sourcesContentByPath[ resolve( key ) ] = options.content[ key ];
});
}
if (options.sourcemaps) {
Object.keys(options.sourcemaps).forEach(function (key) {
sourceMapByPath[resolve(key)] = options.sourcemaps[key];
if ( options.sourcemaps ) {
Object.keys( options.sourcemaps ).forEach( function ( key ) {
sourceMapByPath[ resolve( key ) ] = options.sourcemaps[ key ];
});

@@ -782,0 +769,0 @@ }

{
"name": "sorcery",
"description": "Resolve a chain of sourcemaps back to the original source",
"version": "0.9.2",
"version": "0.9.3",
"author": "Rich Harris",

@@ -12,23 +12,22 @@ "repository": "https://github.com/Rich-Harris/sorcery",

"buffer-crc32": "^0.2.5",
"minimist": "^1.1.0",
"sander": "^0.4.0",
"sourcemap-codec": "^1.2.0"
"minimist": "^1.2.0",
"sander": "^0.5.0",
"sourcemap-codec": "^1.3.0"
},
"devDependencies": {
"babel-preset-es2015-rollup": "^1.0.0",
"codecov.io": "^0.1.6",
"coffee-script": "^1.10.0",
"eslint": "^1.10.3",
"istanbul": "^0.4.0",
"less": "^2.5.3",
"mocha": "^2.3.3",
"promise-map-series": "^0.2.1",
"remap-istanbul": "^0.5.1",
"rollup": "^0.21.2",
"rollup-plugin-babel": "^2.2.0",
"rollup-plugin-commonjs": "^1.4.0",
"rollup-plugin-npm": "^1.1.0",
"eslint": "^2.8.0",
"istanbul": "^0.4.3",
"less": "^2.6.1",
"mocha": "^2.4.5",
"promise-map-series": "^0.2.2",
"remap-istanbul": "^0.6.3",
"rollup": "^0.25.8",
"rollup-plugin-buble": "^0.5.0",
"rollup-plugin-commonjs": "^2.2.1",
"rollup-plugin-npm": "^1.4.0",
"source-map": "^0.5.3",
"source-map-support": "^0.4.0",
"uglify-js": "^2.4.20"
"uglify-js": "^2.6.2"
},

@@ -35,0 +34,0 @@ "bin": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc