format: prettify entire project
This commit is contained in:
359
node_modules/source-map/lib/source-map-consumer.js
generated
vendored
359
node_modules/source-map/lib/source-map-consumer.js
generated
vendored
@ -17,14 +17,14 @@ function SourceMapConsumer(aSourceMap, aSourceMapURL) {
|
||||
sourceMap = util.parseSourceMapInput(aSourceMap);
|
||||
}
|
||||
|
||||
return sourceMap.sections != null
|
||||
? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
|
||||
return sourceMap.sections != null ?
|
||||
new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
|
||||
: new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
|
||||
}
|
||||
|
||||
SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
|
||||
SourceMapConsumer.fromSourceMap = function (aSourceMap, aSourceMapURL) {
|
||||
return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The version of the source mapping spec that we are consuming.
|
||||
@ -71,7 +71,7 @@ Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
|
||||
}
|
||||
|
||||
return this.__generatedMappings;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
SourceMapConsumer.prototype.__originalMappings = null;
|
||||
@ -84,13 +84,13 @@ Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
|
||||
}
|
||||
|
||||
return this.__originalMappings;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
SourceMapConsumer.prototype._charIsMappingSeparator =
|
||||
function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
|
||||
var c = aStr.charAt(index);
|
||||
return c === ";" || c === ",";
|
||||
return c === ';' || c === ',';
|
||||
};
|
||||
|
||||
/**
|
||||
@ -100,7 +100,7 @@ SourceMapConsumer.prototype._charIsMappingSeparator =
|
||||
*/
|
||||
SourceMapConsumer.prototype._parseMappings =
|
||||
function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
|
||||
throw new Error("Subclasses must implement _parseMappings");
|
||||
throw new Error('Subclasses must implement _parseMappings');
|
||||
};
|
||||
|
||||
SourceMapConsumer.GENERATED_ORDER = 1;
|
||||
@ -132,29 +132,32 @@ SourceMapConsumer.prototype.eachMapping =
|
||||
|
||||
var mappings;
|
||||
switch (order) {
|
||||
case SourceMapConsumer.GENERATED_ORDER:
|
||||
mappings = this._generatedMappings;
|
||||
break;
|
||||
case SourceMapConsumer.ORIGINAL_ORDER:
|
||||
mappings = this._originalMappings;
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unknown order of iteration.");
|
||||
case SourceMapConsumer.GENERATED_ORDER:
|
||||
mappings = this._generatedMappings;
|
||||
break;
|
||||
case SourceMapConsumer.ORIGINAL_ORDER:
|
||||
mappings = this._originalMappings;
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown order of iteration.');
|
||||
}
|
||||
|
||||
var sourceRoot = this.sourceRoot;
|
||||
mappings.map(function (mapping) {
|
||||
var source = mapping.source === null ? null : this._sources.at(mapping.source);
|
||||
source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
|
||||
return {
|
||||
source: source,
|
||||
generatedLine: mapping.generatedLine,
|
||||
generatedColumn: mapping.generatedColumn,
|
||||
originalLine: mapping.originalLine,
|
||||
originalColumn: mapping.originalColumn,
|
||||
name: mapping.name === null ? null : this._names.at(mapping.name)
|
||||
};
|
||||
}, this).forEach(aCallback, context);
|
||||
mappings
|
||||
.map(function (mapping) {
|
||||
var source =
|
||||
mapping.source === null ? null : this._sources.at(mapping.source);
|
||||
source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
|
||||
return {
|
||||
source: source,
|
||||
generatedLine: mapping.generatedLine,
|
||||
generatedColumn: mapping.generatedColumn,
|
||||
originalLine: mapping.originalLine,
|
||||
originalColumn: mapping.originalColumn,
|
||||
name: mapping.name === null ? null : this._names.at(mapping.name),
|
||||
};
|
||||
}, this)
|
||||
.forEach(aCallback, context);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -190,7 +193,7 @@ SourceMapConsumer.prototype.allGeneratedPositionsFor =
|
||||
var needle = {
|
||||
source: util.getArg(aArgs, 'source'),
|
||||
originalLine: line,
|
||||
originalColumn: util.getArg(aArgs, 'column', 0)
|
||||
originalColumn: util.getArg(aArgs, 'column', 0),
|
||||
};
|
||||
|
||||
needle.source = this._findSourceIndex(needle.source);
|
||||
@ -200,12 +203,14 @@ SourceMapConsumer.prototype.allGeneratedPositionsFor =
|
||||
|
||||
var mappings = [];
|
||||
|
||||
var index = this._findMapping(needle,
|
||||
this._originalMappings,
|
||||
"originalLine",
|
||||
"originalColumn",
|
||||
util.compareByOriginalPositions,
|
||||
binarySearch.LEAST_UPPER_BOUND);
|
||||
var index = this._findMapping(
|
||||
needle,
|
||||
this._originalMappings,
|
||||
'originalLine',
|
||||
'originalColumn',
|
||||
util.compareByOriginalPositions,
|
||||
binarySearch.LEAST_UPPER_BOUND
|
||||
);
|
||||
if (index >= 0) {
|
||||
var mapping = this._originalMappings[index];
|
||||
|
||||
@ -220,7 +225,7 @@ SourceMapConsumer.prototype.allGeneratedPositionsFor =
|
||||
mappings.push({
|
||||
line: util.getArg(mapping, 'generatedLine', null),
|
||||
column: util.getArg(mapping, 'generatedColumn', null),
|
||||
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
|
||||
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null),
|
||||
});
|
||||
|
||||
mapping = this._originalMappings[++index];
|
||||
@ -232,13 +237,15 @@ SourceMapConsumer.prototype.allGeneratedPositionsFor =
|
||||
// a mapping for a different line than the one we were searching for.
|
||||
// Since mappings are sorted, this is guaranteed to find all mappings for
|
||||
// the line we are searching for.
|
||||
while (mapping &&
|
||||
mapping.originalLine === line &&
|
||||
mapping.originalColumn == originalColumn) {
|
||||
while (
|
||||
mapping &&
|
||||
mapping.originalLine === line &&
|
||||
mapping.originalColumn == originalColumn
|
||||
) {
|
||||
mappings.push({
|
||||
line: util.getArg(mapping, 'generatedLine', null),
|
||||
column: util.getArg(mapping, 'generatedColumn', null),
|
||||
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
|
||||
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null),
|
||||
});
|
||||
|
||||
mapping = this._originalMappings[++index];
|
||||
@ -322,8 +329,10 @@ function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
|
||||
// be particularly problematic when the source root is a prefix of the
|
||||
// source (valid, but why??). See github issue #199 and bugzil.la/1188982.
|
||||
.map(function (source) {
|
||||
return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
|
||||
? util.relative(sourceRoot, source)
|
||||
return (
|
||||
sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
|
||||
) ?
|
||||
util.relative(sourceRoot, source)
|
||||
: source;
|
||||
});
|
||||
|
||||
@ -352,7 +361,7 @@ BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
|
||||
* Utility function to find the index of a source. Returns -1 if not
|
||||
* found.
|
||||
*/
|
||||
BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
|
||||
BasicSourceMapConsumer.prototype._findSourceIndex = function (aSource) {
|
||||
var relativeSource = aSource;
|
||||
if (this.sourceRoot != null) {
|
||||
relativeSource = util.relative(this.sourceRoot, relativeSource);
|
||||
@ -383,55 +392,65 @@ BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
|
||||
* The URL at which the source map can be found (optional)
|
||||
* @returns BasicSourceMapConsumer
|
||||
*/
|
||||
BasicSourceMapConsumer.fromSourceMap =
|
||||
function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
|
||||
var smc = Object.create(BasicSourceMapConsumer.prototype);
|
||||
BasicSourceMapConsumer.fromSourceMap = function SourceMapConsumer_fromSourceMap(
|
||||
aSourceMap,
|
||||
aSourceMapURL
|
||||
) {
|
||||
var smc = Object.create(BasicSourceMapConsumer.prototype);
|
||||
|
||||
var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
|
||||
var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
|
||||
smc.sourceRoot = aSourceMap._sourceRoot;
|
||||
smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
|
||||
smc.sourceRoot);
|
||||
smc.file = aSourceMap._file;
|
||||
smc._sourceMapURL = aSourceMapURL;
|
||||
smc._absoluteSources = smc._sources.toArray().map(function (s) {
|
||||
return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
|
||||
});
|
||||
var names = (smc._names = ArraySet.fromArray(
|
||||
aSourceMap._names.toArray(),
|
||||
true
|
||||
));
|
||||
var sources = (smc._sources = ArraySet.fromArray(
|
||||
aSourceMap._sources.toArray(),
|
||||
true
|
||||
));
|
||||
smc.sourceRoot = aSourceMap._sourceRoot;
|
||||
smc.sourcesContent = aSourceMap._generateSourcesContent(
|
||||
smc._sources.toArray(),
|
||||
smc.sourceRoot
|
||||
);
|
||||
smc.file = aSourceMap._file;
|
||||
smc._sourceMapURL = aSourceMapURL;
|
||||
smc._absoluteSources = smc._sources.toArray().map(function (s) {
|
||||
return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
|
||||
});
|
||||
|
||||
// Because we are modifying the entries (by converting string sources and
|
||||
// names to indices into the sources and names ArraySets), we have to make
|
||||
// a copy of the entry or else bad things happen. Shared mutable state
|
||||
// strikes again! See github issue #191.
|
||||
// Because we are modifying the entries (by converting string sources and
|
||||
// names to indices into the sources and names ArraySets), we have to make
|
||||
// a copy of the entry or else bad things happen. Shared mutable state
|
||||
// strikes again! See github issue #191.
|
||||
|
||||
var generatedMappings = aSourceMap._mappings.toArray().slice();
|
||||
var destGeneratedMappings = smc.__generatedMappings = [];
|
||||
var destOriginalMappings = smc.__originalMappings = [];
|
||||
var generatedMappings = aSourceMap._mappings.toArray().slice();
|
||||
var destGeneratedMappings = (smc.__generatedMappings = []);
|
||||
var destOriginalMappings = (smc.__originalMappings = []);
|
||||
|
||||
for (var i = 0, length = generatedMappings.length; i < length; i++) {
|
||||
var srcMapping = generatedMappings[i];
|
||||
var destMapping = new Mapping;
|
||||
destMapping.generatedLine = srcMapping.generatedLine;
|
||||
destMapping.generatedColumn = srcMapping.generatedColumn;
|
||||
for (var i = 0, length = generatedMappings.length; i < length; i++) {
|
||||
var srcMapping = generatedMappings[i];
|
||||
var destMapping = new Mapping();
|
||||
destMapping.generatedLine = srcMapping.generatedLine;
|
||||
destMapping.generatedColumn = srcMapping.generatedColumn;
|
||||
|
||||
if (srcMapping.source) {
|
||||
destMapping.source = sources.indexOf(srcMapping.source);
|
||||
destMapping.originalLine = srcMapping.originalLine;
|
||||
destMapping.originalColumn = srcMapping.originalColumn;
|
||||
if (srcMapping.source) {
|
||||
destMapping.source = sources.indexOf(srcMapping.source);
|
||||
destMapping.originalLine = srcMapping.originalLine;
|
||||
destMapping.originalColumn = srcMapping.originalColumn;
|
||||
|
||||
if (srcMapping.name) {
|
||||
destMapping.name = names.indexOf(srcMapping.name);
|
||||
}
|
||||
|
||||
destOriginalMappings.push(destMapping);
|
||||
if (srcMapping.name) {
|
||||
destMapping.name = names.indexOf(srcMapping.name);
|
||||
}
|
||||
|
||||
destGeneratedMappings.push(destMapping);
|
||||
destOriginalMappings.push(destMapping);
|
||||
}
|
||||
|
||||
quickSort(smc.__originalMappings, util.compareByOriginalPositions);
|
||||
destGeneratedMappings.push(destMapping);
|
||||
}
|
||||
|
||||
return smc;
|
||||
};
|
||||
quickSort(smc.__originalMappings, util.compareByOriginalPositions);
|
||||
|
||||
return smc;
|
||||
};
|
||||
|
||||
/**
|
||||
* The version of the source mapping spec that we are consuming.
|
||||
@ -444,7 +463,7 @@ BasicSourceMapConsumer.prototype._version = 3;
|
||||
Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
|
||||
get: function () {
|
||||
return this._absoluteSources.slice();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
@ -485,11 +504,9 @@ BasicSourceMapConsumer.prototype._parseMappings =
|
||||
generatedLine++;
|
||||
index++;
|
||||
previousGeneratedColumn = 0;
|
||||
}
|
||||
else if (aStr.charAt(index) === ',') {
|
||||
} else if (aStr.charAt(index) === ',') {
|
||||
index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mapping = new Mapping();
|
||||
mapping.generatedLine = generatedLine;
|
||||
|
||||
@ -573,20 +590,28 @@ BasicSourceMapConsumer.prototype._parseMappings =
|
||||
* we are searching for in the given "haystack" of mappings.
|
||||
*/
|
||||
BasicSourceMapConsumer.prototype._findMapping =
|
||||
function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
|
||||
aColumnName, aComparator, aBias) {
|
||||
function SourceMapConsumer_findMapping(
|
||||
aNeedle,
|
||||
aMappings,
|
||||
aLineName,
|
||||
aColumnName,
|
||||
aComparator,
|
||||
aBias
|
||||
) {
|
||||
// To return the position we are searching for, we must first find the
|
||||
// mapping for the given position and then return the opposite position it
|
||||
// points to. Because the mappings are sorted, we can use binary search to
|
||||
// find the best mapping.
|
||||
|
||||
if (aNeedle[aLineName] <= 0) {
|
||||
throw new TypeError('Line must be greater than or equal to 1, got '
|
||||
+ aNeedle[aLineName]);
|
||||
throw new TypeError(
|
||||
'Line must be greater than or equal to 1, got ' + aNeedle[aLineName]
|
||||
);
|
||||
}
|
||||
if (aNeedle[aColumnName] < 0) {
|
||||
throw new TypeError('Column must be greater than or equal to 0, got '
|
||||
+ aNeedle[aColumnName]);
|
||||
throw new TypeError(
|
||||
'Column must be greater than or equal to 0, got ' + aNeedle[aColumnName]
|
||||
);
|
||||
}
|
||||
|
||||
return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
|
||||
@ -647,14 +672,14 @@ BasicSourceMapConsumer.prototype.originalPositionFor =
|
||||
function SourceMapConsumer_originalPositionFor(aArgs) {
|
||||
var needle = {
|
||||
generatedLine: util.getArg(aArgs, 'line'),
|
||||
generatedColumn: util.getArg(aArgs, 'column')
|
||||
generatedColumn: util.getArg(aArgs, 'column'),
|
||||
};
|
||||
|
||||
var index = this._findMapping(
|
||||
needle,
|
||||
this._generatedMappings,
|
||||
"generatedLine",
|
||||
"generatedColumn",
|
||||
'generatedLine',
|
||||
'generatedColumn',
|
||||
util.compareByGeneratedPositionsDeflated,
|
||||
util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
|
||||
);
|
||||
@ -666,7 +691,11 @@ BasicSourceMapConsumer.prototype.originalPositionFor =
|
||||
var source = util.getArg(mapping, 'source', null);
|
||||
if (source !== null) {
|
||||
source = this._sources.at(source);
|
||||
source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
|
||||
source = util.computeSourceURL(
|
||||
this.sourceRoot,
|
||||
source,
|
||||
this._sourceMapURL
|
||||
);
|
||||
}
|
||||
var name = util.getArg(mapping, 'name', null);
|
||||
if (name !== null) {
|
||||
@ -676,7 +705,7 @@ BasicSourceMapConsumer.prototype.originalPositionFor =
|
||||
source: source,
|
||||
line: util.getArg(mapping, 'originalLine', null),
|
||||
column: util.getArg(mapping, 'originalColumn', null),
|
||||
name: name
|
||||
name: name,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -685,7 +714,7 @@ BasicSourceMapConsumer.prototype.originalPositionFor =
|
||||
source: null,
|
||||
line: null,
|
||||
column: null,
|
||||
name: null
|
||||
name: null,
|
||||
};
|
||||
};
|
||||
|
||||
@ -698,8 +727,12 @@ BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
|
||||
if (!this.sourcesContent) {
|
||||
return false;
|
||||
}
|
||||
return this.sourcesContent.length >= this._sources.size() &&
|
||||
!this.sourcesContent.some(function (sc) { return sc == null; });
|
||||
return (
|
||||
this.sourcesContent.length >= this._sources.size() &&
|
||||
!this.sourcesContent.some(function (sc) {
|
||||
return sc == null;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -724,21 +757,21 @@ BasicSourceMapConsumer.prototype.sourceContentFor =
|
||||
}
|
||||
|
||||
var url;
|
||||
if (this.sourceRoot != null
|
||||
&& (url = util.urlParse(this.sourceRoot))) {
|
||||
if (this.sourceRoot != null && (url = util.urlParse(this.sourceRoot))) {
|
||||
// XXX: file:// URIs and absolute paths lead to unexpected behavior for
|
||||
// many users. We can help them out when they expect file:// URIs to
|
||||
// behave like it would if they were running a local HTTP server. See
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
|
||||
var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
|
||||
if (url.scheme == "file"
|
||||
&& this._sources.has(fileUriAbsPath)) {
|
||||
return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
|
||||
var fileUriAbsPath = relativeSource.replace(/^file:\/\//, '');
|
||||
if (url.scheme == 'file' && this._sources.has(fileUriAbsPath)) {
|
||||
return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)];
|
||||
}
|
||||
|
||||
if ((!url.path || url.path == "/")
|
||||
&& this._sources.has("/" + relativeSource)) {
|
||||
return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
|
||||
if (
|
||||
(!url.path || url.path == '/') &&
|
||||
this._sources.has('/' + relativeSource)
|
||||
) {
|
||||
return this.sourcesContent[this._sources.indexOf('/' + relativeSource)];
|
||||
}
|
||||
}
|
||||
|
||||
@ -748,8 +781,7 @@ BasicSourceMapConsumer.prototype.sourceContentFor =
|
||||
// return null, so we provide a flag to exit gracefully.
|
||||
if (nullOnMissing) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Error('"' + relativeSource + '" is not in the SourceMap.');
|
||||
}
|
||||
};
|
||||
@ -785,21 +817,21 @@ BasicSourceMapConsumer.prototype.generatedPositionFor =
|
||||
return {
|
||||
line: null,
|
||||
column: null,
|
||||
lastColumn: null
|
||||
lastColumn: null,
|
||||
};
|
||||
}
|
||||
|
||||
var needle = {
|
||||
source: source,
|
||||
originalLine: util.getArg(aArgs, 'line'),
|
||||
originalColumn: util.getArg(aArgs, 'column')
|
||||
originalColumn: util.getArg(aArgs, 'column'),
|
||||
};
|
||||
|
||||
var index = this._findMapping(
|
||||
needle,
|
||||
this._originalMappings,
|
||||
"originalLine",
|
||||
"originalColumn",
|
||||
'originalLine',
|
||||
'originalColumn',
|
||||
util.compareByOriginalPositions,
|
||||
util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
|
||||
);
|
||||
@ -811,7 +843,7 @@ BasicSourceMapConsumer.prototype.generatedPositionFor =
|
||||
return {
|
||||
line: util.getArg(mapping, 'generatedLine', null),
|
||||
column: util.getArg(mapping, 'generatedColumn', null),
|
||||
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
|
||||
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -819,7 +851,7 @@ BasicSourceMapConsumer.prototype.generatedPositionFor =
|
||||
return {
|
||||
line: null,
|
||||
column: null,
|
||||
lastColumn: null
|
||||
lastColumn: null,
|
||||
};
|
||||
};
|
||||
|
||||
@ -892,7 +924,7 @@ function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
|
||||
|
||||
var lastOffset = {
|
||||
line: -1,
|
||||
column: 0
|
||||
column: 0,
|
||||
};
|
||||
this._sections = sections.map(function (s) {
|
||||
if (s.url) {
|
||||
@ -904,8 +936,10 @@ function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
|
||||
var offsetLine = util.getArg(offset, 'line');
|
||||
var offsetColumn = util.getArg(offset, 'column');
|
||||
|
||||
if (offsetLine < lastOffset.line ||
|
||||
(offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
|
||||
if (
|
||||
offsetLine < lastOffset.line ||
|
||||
(offsetLine === lastOffset.line && offsetColumn < lastOffset.column)
|
||||
) {
|
||||
throw new Error('Section offsets must be ordered and non-overlapping.');
|
||||
}
|
||||
lastOffset = offset;
|
||||
@ -915,10 +949,10 @@ function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
|
||||
// The offset fields are 0-based, but we use 1-based indices when
|
||||
// encoding/decoding from VLQ.
|
||||
generatedLine: offsetLine + 1,
|
||||
generatedColumn: offsetColumn + 1
|
||||
generatedColumn: offsetColumn + 1,
|
||||
},
|
||||
consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
|
||||
}
|
||||
consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@ -942,7 +976,7 @@ Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
|
||||
}
|
||||
}
|
||||
return sources;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
@ -968,21 +1002,23 @@ IndexedSourceMapConsumer.prototype.originalPositionFor =
|
||||
function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
|
||||
var needle = {
|
||||
generatedLine: util.getArg(aArgs, 'line'),
|
||||
generatedColumn: util.getArg(aArgs, 'column')
|
||||
generatedColumn: util.getArg(aArgs, 'column'),
|
||||
};
|
||||
|
||||
// Find the section containing the generated position we're trying to map
|
||||
// to an original position.
|
||||
var sectionIndex = binarySearch.search(needle, this._sections,
|
||||
function(needle, section) {
|
||||
var sectionIndex = binarySearch.search(
|
||||
needle,
|
||||
this._sections,
|
||||
function (needle, section) {
|
||||
var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
|
||||
if (cmp) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return (needle.generatedColumn -
|
||||
section.generatedOffset.generatedColumn);
|
||||
});
|
||||
return needle.generatedColumn - section.generatedOffset.generatedColumn;
|
||||
}
|
||||
);
|
||||
var section = this._sections[sectionIndex];
|
||||
|
||||
if (!section) {
|
||||
@ -990,18 +1026,18 @@ IndexedSourceMapConsumer.prototype.originalPositionFor =
|
||||
source: null,
|
||||
line: null,
|
||||
column: null,
|
||||
name: null
|
||||
name: null,
|
||||
};
|
||||
}
|
||||
|
||||
return section.consumer.originalPositionFor({
|
||||
line: needle.generatedLine -
|
||||
(section.generatedOffset.generatedLine - 1),
|
||||
column: needle.generatedColumn -
|
||||
(section.generatedOffset.generatedLine === needle.generatedLine
|
||||
? section.generatedOffset.generatedColumn - 1
|
||||
: 0),
|
||||
bias: aArgs.bias
|
||||
line: needle.generatedLine - (section.generatedOffset.generatedLine - 1),
|
||||
column:
|
||||
needle.generatedColumn -
|
||||
(section.generatedOffset.generatedLine === needle.generatedLine ?
|
||||
section.generatedOffset.generatedColumn - 1
|
||||
: 0),
|
||||
bias: aArgs.bias,
|
||||
});
|
||||
};
|
||||
|
||||
@ -1033,8 +1069,7 @@ IndexedSourceMapConsumer.prototype.sourceContentFor =
|
||||
}
|
||||
if (nullOnMissing) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Error('"' + aSource + '" is not in the SourceMap.');
|
||||
}
|
||||
};
|
||||
@ -1053,7 +1088,7 @@ IndexedSourceMapConsumer.prototype.sourceContentFor =
|
||||
* and an object is returned with the following properties:
|
||||
*
|
||||
* - line: The line number in the generated source, or null. The
|
||||
* line number is 1-based.
|
||||
* line number is 1-based.
|
||||
* - column: The column number in the generated source, or null.
|
||||
* The column number is 0-based.
|
||||
*/
|
||||
@ -1064,18 +1099,22 @@ IndexedSourceMapConsumer.prototype.generatedPositionFor =
|
||||
|
||||
// Only consider this section if the requested source is in the list of
|
||||
// sources of the consumer.
|
||||
if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
|
||||
if (
|
||||
section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
var generatedPosition = section.consumer.generatedPositionFor(aArgs);
|
||||
if (generatedPosition) {
|
||||
var ret = {
|
||||
line: generatedPosition.line +
|
||||
line:
|
||||
generatedPosition.line +
|
||||
(section.generatedOffset.generatedLine - 1),
|
||||
column: generatedPosition.column +
|
||||
(section.generatedOffset.generatedLine === generatedPosition.line
|
||||
? section.generatedOffset.generatedColumn - 1
|
||||
: 0)
|
||||
column:
|
||||
generatedPosition.column +
|
||||
(section.generatedOffset.generatedLine === generatedPosition.line ?
|
||||
section.generatedOffset.generatedColumn - 1
|
||||
: 0),
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
@ -1083,7 +1122,7 @@ IndexedSourceMapConsumer.prototype.generatedPositionFor =
|
||||
|
||||
return {
|
||||
line: null,
|
||||
column: null
|
||||
column: null,
|
||||
};
|
||||
};
|
||||
|
||||
@ -1103,7 +1142,11 @@ IndexedSourceMapConsumer.prototype._parseMappings =
|
||||
var mapping = sectionMappings[j];
|
||||
|
||||
var source = section.consumer._sources.at(mapping.source);
|
||||
source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
|
||||
source = util.computeSourceURL(
|
||||
section.consumer.sourceRoot,
|
||||
source,
|
||||
this._sourceMapURL
|
||||
);
|
||||
this._sources.add(source);
|
||||
source = this._sources.indexOf(source);
|
||||
|
||||
@ -1120,15 +1163,16 @@ IndexedSourceMapConsumer.prototype._parseMappings =
|
||||
// generated file.
|
||||
var adjustedMapping = {
|
||||
source: source,
|
||||
generatedLine: mapping.generatedLine +
|
||||
(section.generatedOffset.generatedLine - 1),
|
||||
generatedColumn: mapping.generatedColumn +
|
||||
(section.generatedOffset.generatedLine === mapping.generatedLine
|
||||
? section.generatedOffset.generatedColumn - 1
|
||||
generatedLine:
|
||||
mapping.generatedLine + (section.generatedOffset.generatedLine - 1),
|
||||
generatedColumn:
|
||||
mapping.generatedColumn +
|
||||
(section.generatedOffset.generatedLine === mapping.generatedLine ?
|
||||
section.generatedOffset.generatedColumn - 1
|
||||
: 0),
|
||||
originalLine: mapping.originalLine,
|
||||
originalColumn: mapping.originalColumn,
|
||||
name: name
|
||||
name: name,
|
||||
};
|
||||
|
||||
this.__generatedMappings.push(adjustedMapping);
|
||||
@ -1138,7 +1182,10 @@ IndexedSourceMapConsumer.prototype._parseMappings =
|
||||
}
|
||||
}
|
||||
|
||||
quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
|
||||
quickSort(
|
||||
this.__generatedMappings,
|
||||
util.compareByGeneratedPositionsDeflated
|
||||
);
|
||||
quickSort(this.__originalMappings, util.compareByOriginalPositions);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user