Comparing version 0.5.1 to 0.5.2
# changelog | ||
## 0.5.2 | ||
* Handle CSS sourcemap comments | ||
## 0.5.1 | ||
@@ -4,0 +8,0 @@ |
@@ -10,3 +10,2 @@ 'use strict'; | ||
var utils_decodeMappings = decodeMappings; | ||
var cache = {}; | ||
@@ -97,4 +96,4 @@ | ||
*/ | ||
var utils_atob = atob; | ||
function atob(base64) { | ||
@@ -114,3 +113,3 @@ return new Buffer(base64, 'base64').toString('utf8'); | ||
*/ | ||
var utils_getMapFromUrl = getMapFromUrl; | ||
function getMapFromUrl(url, base, sync) { | ||
@@ -124,3 +123,3 @@ if (/^data/.test(url)) { | ||
var json = utils_atob(match[1]); | ||
var json = atob(match[1]); | ||
var map = JSON.parse(json); | ||
@@ -139,4 +138,2 @@ return sync ? map : sander__default.Promise.resolve(map); | ||
var utils_getSourceMappingUrl = getSourceMappingUrl; | ||
function getSourceMappingUrl(str) { | ||
@@ -156,6 +153,12 @@ var index, substring, url, match; | ||
url = match ? match[0] : null; | ||
// possibly a better way to do this, but we don't want to exclude whitespace | ||
// from the sourceMappingURL because it might not have been correctly encoded | ||
if (url && url.slice(-2) === '*/') { | ||
url = url.slice(0, -2).trim(); | ||
} | ||
return url; | ||
} | ||
var utils_getMap = getMap; | ||
function getMap(node, sourceMapByPath, sync) { | ||
@@ -166,3 +169,3 @@ if (node.file in sourceMapByPath) { | ||
} else { | ||
var url = utils_getSourceMappingUrl(node.content); | ||
var url = getSourceMappingUrl(node.content); | ||
@@ -174,9 +177,9 @@ if (!url) { | ||
return utils_getMapFromUrl(url, node.file, sync); | ||
return getMapFromUrl(url, node.file, sync); | ||
} | ||
} | ||
var _Node___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var Node___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _Node__Promise = sander__default.Promise; | ||
var Node__Promise = sander__default.Promise; | ||
@@ -188,3 +191,3 @@ var Node = (function () { | ||
_Node___classCallCheck(this, Node); | ||
Node___classCallCheck(this, Node); | ||
@@ -219,3 +222,3 @@ this.file = file ? path__default.resolve(file) : null; | ||
return utils_getMap(_this, sourceMapByPath).then(function (map) { | ||
return getMap(_this, sourceMapByPath).then(function (map) { | ||
if (!map) return null; | ||
@@ -226,3 +229,3 @@ | ||
var decodingStart = process.hrtime(); | ||
_this.mappings = utils_decodeMappings(map.mappings); | ||
_this.mappings = decodeMappings(map.mappings); | ||
var decodingTime = process.hrtime(decodingStart); | ||
@@ -243,3 +246,3 @@ _this._stats.decodingTime = 1000000000 * decodingTime[0] + decodingTime[1]; | ||
}); | ||
return _Node__Promise.all(promises); | ||
return Node__Promise.all(promises); | ||
}); | ||
@@ -256,3 +259,3 @@ }); | ||
var map = utils_getMap(this, sourceMapByPath, true); | ||
var map = getMap(this, sourceMapByPath, true); | ||
var sourcesContent = undefined; | ||
@@ -264,3 +267,3 @@ | ||
this.map = map; | ||
this.mappings = utils_decodeMappings(map.mappings); | ||
this.mappings = decodeMappings(map.mappings); | ||
@@ -352,4 +355,4 @@ sourcesContent = map.sourcesContent || []; | ||
var _Node = Node; | ||
function getContent(node, sourcesContentByPath) { | ||
@@ -364,3 +367,3 @@ if (node.file in sourcesContentByPath) { | ||
return _Node__Promise.resolve(node.content); | ||
return Node__Promise.resolve(node.content); | ||
} | ||
@@ -378,4 +381,4 @@ | ||
*/ | ||
var utils_btoa = btoa; | ||
function btoa(str) { | ||
@@ -385,7 +388,7 @@ return new Buffer(str).toString('base64'); | ||
var _SourceMap___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var SourceMap___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var SourceMap = (function () { | ||
function SourceMap(properties) { | ||
_SourceMap___classCallCheck(this, SourceMap); | ||
SourceMap___classCallCheck(this, SourceMap); | ||
@@ -406,3 +409,3 @@ this.version = 3; | ||
SourceMap.prototype.toUrl = function toUrl() { | ||
return 'data:application/json;charset=utf-8;base64,' + utils_btoa(this.toString()); | ||
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString()); | ||
}; | ||
@@ -413,5 +416,2 @@ | ||
var _SourceMap = SourceMap; | ||
var utils_encodeMappings = encodeMappings; | ||
function encodeMappings(decoded) { | ||
@@ -463,3 +463,3 @@ var offsets = { | ||
var _Chain___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var Chain___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
@@ -470,3 +470,3 @@ var SOURCEMAP_COMMENT = /\s+\/\/#\s+sourceMappingURL=([^\r\n]+)/g; | ||
function Chain(node, sourcesContentByPath) { | ||
_Chain___classCallCheck(this, Chain); | ||
Chain___classCallCheck(this, Chain); | ||
@@ -556,3 +556,3 @@ this.node = node; | ||
var encodingStart = process.hrtime(); | ||
var mappings = utils_encodeMappings(resolved); | ||
var mappings = encodeMappings(resolved); | ||
var encodingTime = process.hrtime(encodingStart); | ||
@@ -563,3 +563,3 @@ this._stats.encodingTime = 1000000000 * encodingTime[0] + encodingTime[1]; | ||
return new _SourceMap({ | ||
return new SourceMap({ | ||
file: path.basename(this.node.file), | ||
@@ -611,4 +611,4 @@ sources: allSources.map(function (source) { | ||
var _Chain = Chain; | ||
function tally(nodes, stat) { | ||
@@ -628,3 +628,3 @@ return nodes.reduce(function (total, node) { | ||
return node.load(sourcesContentByPath, sourceMapByPath).then(function () { | ||
return node.isOriginalSource ? null : new _Chain(node, sourcesContentByPath); | ||
return node.isOriginalSource ? null : new Chain(node, sourcesContentByPath); | ||
}); | ||
@@ -643,3 +643,3 @@ } | ||
node.loadSync(sourcesContentByPath, sourceMapByPath); | ||
return node.isOriginalSource ? null : new _Chain(node, sourcesContentByPath); | ||
return node.isOriginalSource ? null : new Chain(node, sourcesContentByPath); | ||
} | ||
@@ -650,3 +650,3 @@ | ||
var node = new _Node({ file: file }); | ||
var node = new Node({ file: file }); | ||
@@ -653,0 +653,0 @@ var sourcesContentByPath = {}; |
{ | ||
"name": "sorcery", | ||
"description": "Resolve a chain of sourcemaps back to the original source", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"author": "Rich Harris", | ||
@@ -24,2 +24,3 @@ "repository": "https://github.com/Rich-Harris/sorcery", | ||
"gobble-esperanto-bundle": "^0.1.7", | ||
"less": "^2.5.0", | ||
"mocha": "^2.1.0", | ||
@@ -26,0 +27,0 @@ "promise-map-series": "^0.2.1", |
@@ -15,3 +15,10 @@ export default function getSourceMappingUrl ( str ) { | ||
url = match ? match[0] : null; | ||
// possibly a better way to do this, but we don't want to exclude whitespace | ||
// from the sourceMappingURL because it might not have been correctly encoded | ||
if ( url && url.slice( -2 ) === '*/' ) { | ||
url = url.slice( 0, -2 ).trim(); | ||
} | ||
return url; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42706
12