You've already forked codtracker-js
format: prettify entire project
This commit is contained in:
8
node_modules/source-map-js/lib/array-set.js
generated
vendored
8
node_modules/source-map-js/lib/array-set.js
generated
vendored
@ -7,7 +7,7 @@
|
||||
|
||||
var util = require('./util');
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
var hasNativeMap = typeof Map !== "undefined";
|
||||
var hasNativeMap = typeof Map !== 'undefined';
|
||||
|
||||
/**
|
||||
* A data structure which is a combination of an array and a set. Adding a new
|
||||
@ -38,7 +38,9 @@ ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
||||
* @returns Number
|
||||
*/
|
||||
ArraySet.prototype.size = function ArraySet_size() {
|
||||
return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
|
||||
return hasNativeMap ?
|
||||
this._set.size
|
||||
: Object.getOwnPropertyNames(this._set).length;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -85,7 +87,7 @@ ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
||||
if (hasNativeMap) {
|
||||
var idx = this._set.get(aStr);
|
||||
if (idx >= 0) {
|
||||
return idx;
|
||||
return idx;
|
||||
}
|
||||
} else {
|
||||
var sStr = util.toSetString(aStr);
|
||||
|
14
node_modules/source-map-js/lib/base64-vlq.js
generated
vendored
14
node_modules/source-map-js/lib/base64-vlq.js
generated
vendored
@ -67,9 +67,7 @@ var VLQ_CONTINUATION_BIT = VLQ_BASE;
|
||||
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
||||
*/
|
||||
function toVLQSigned(aValue) {
|
||||
return aValue < 0
|
||||
? ((-aValue) << 1) + 1
|
||||
: (aValue << 1) + 0;
|
||||
return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,16 +79,14 @@ function toVLQSigned(aValue) {
|
||||
function fromVLQSigned(aValue) {
|
||||
var isNegative = (aValue & 1) === 1;
|
||||
var shifted = aValue >> 1;
|
||||
return isNegative
|
||||
? -shifted
|
||||
: shifted;
|
||||
return isNegative ? -shifted : shifted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base 64 VLQ encoded value.
|
||||
*/
|
||||
exports.encode = function base64VLQ_encode(aValue) {
|
||||
var encoded = "";
|
||||
var encoded = '';
|
||||
var digit;
|
||||
|
||||
var vlq = toVLQSigned(aValue);
|
||||
@ -121,12 +117,12 @@ exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
|
||||
|
||||
do {
|
||||
if (aIndex >= strLen) {
|
||||
throw new Error("Expected more digits in base 64 VLQ value.");
|
||||
throw new Error('Expected more digits in base 64 VLQ value.');
|
||||
}
|
||||
|
||||
digit = base64.decode(aStr.charCodeAt(aIndex++));
|
||||
if (digit === -1) {
|
||||
throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
|
||||
throw new Error('Invalid base64 digit: ' + aStr.charAt(aIndex - 1));
|
||||
}
|
||||
|
||||
continuation = !!(digit & VLQ_CONTINUATION_BIT);
|
||||
|
25
node_modules/source-map-js/lib/base64.js
generated
vendored
25
node_modules/source-map-js/lib/base64.js
generated
vendored
@ -5,7 +5,8 @@
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
||||
var intToCharMap =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
||||
|
||||
/**
|
||||
* Encode an integer in the range of 0 to 63 to a single base 64 digit.
|
||||
@ -14,7 +15,7 @@ exports.encode = function (number) {
|
||||
if (0 <= number && number < intToCharMap.length) {
|
||||
return intToCharMap[number];
|
||||
}
|
||||
throw new TypeError("Must be between 0 and 63: " + number);
|
||||
throw new TypeError('Must be between 0 and 63: ' + number);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -22,34 +23,34 @@ exports.encode = function (number) {
|
||||
* failure.
|
||||
*/
|
||||
exports.decode = function (charCode) {
|
||||
var bigA = 65; // 'A'
|
||||
var bigZ = 90; // 'Z'
|
||||
var bigA = 65; // 'A'
|
||||
var bigZ = 90; // 'Z'
|
||||
|
||||
var littleA = 97; // 'a'
|
||||
var littleA = 97; // 'a'
|
||||
var littleZ = 122; // 'z'
|
||||
|
||||
var zero = 48; // '0'
|
||||
var nine = 57; // '9'
|
||||
var zero = 48; // '0'
|
||||
var nine = 57; // '9'
|
||||
|
||||
var plus = 43; // '+'
|
||||
var slash = 47; // '/'
|
||||
var plus = 43; // '+'
|
||||
var slash = 47; // '/'
|
||||
|
||||
var littleOffset = 26;
|
||||
var numberOffset = 52;
|
||||
|
||||
// 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
if (bigA <= charCode && charCode <= bigZ) {
|
||||
return (charCode - bigA);
|
||||
return charCode - bigA;
|
||||
}
|
||||
|
||||
// 26 - 51: abcdefghijklmnopqrstuvwxyz
|
||||
if (littleA <= charCode && charCode <= littleZ) {
|
||||
return (charCode - littleA + littleOffset);
|
||||
return charCode - littleA + littleOffset;
|
||||
}
|
||||
|
||||
// 52 - 61: 0123456789
|
||||
if (zero <= charCode && charCode <= nine) {
|
||||
return (charCode - zero + numberOffset);
|
||||
return charCode - zero + numberOffset;
|
||||
}
|
||||
|
||||
// 62: +
|
||||
|
16
node_modules/source-map-js/lib/binary-search.js
generated
vendored
16
node_modules/source-map-js/lib/binary-search.js
generated
vendored
@ -36,8 +36,7 @@ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
|
||||
if (cmp === 0) {
|
||||
// Found the element we are looking for.
|
||||
return mid;
|
||||
}
|
||||
else if (cmp > 0) {
|
||||
} else if (cmp > 0) {
|
||||
// Our needle is greater than aHaystack[mid].
|
||||
if (aHigh - mid > 1) {
|
||||
// The element is in the upper half.
|
||||
@ -51,8 +50,7 @@ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Our needle is less than aHaystack[mid].
|
||||
if (mid - aLow > 1) {
|
||||
// The element is in the lower half.
|
||||
@ -91,8 +89,14 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
|
||||
aCompare, aBias || exports.GREATEST_LOWER_BOUND);
|
||||
var index = recursiveSearch(
|
||||
-1,
|
||||
aHaystack.length,
|
||||
aNeedle,
|
||||
aHaystack,
|
||||
aCompare,
|
||||
aBias || exports.GREATEST_LOWER_BOUND
|
||||
);
|
||||
if (index < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
19
node_modules/source-map-js/lib/mapping-list.js
generated
vendored
19
node_modules/source-map-js/lib/mapping-list.js
generated
vendored
@ -17,8 +17,11 @@ function generatedPositionAfter(mappingA, mappingB) {
|
||||
var lineB = mappingB.generatedLine;
|
||||
var columnA = mappingA.generatedColumn;
|
||||
var columnB = mappingB.generatedColumn;
|
||||
return lineB > lineA || lineB == lineA && columnB >= columnA ||
|
||||
util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
|
||||
return (
|
||||
lineB > lineA ||
|
||||
(lineB == lineA && columnB >= columnA) ||
|
||||
util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,7 +33,7 @@ function MappingList() {
|
||||
this._array = [];
|
||||
this._sorted = true;
|
||||
// Serves as infimum
|
||||
this._last = {generatedLine: -1, generatedColumn: 0};
|
||||
this._last = { generatedLine: -1, generatedColumn: 0 };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,10 +42,12 @@ function MappingList() {
|
||||
*
|
||||
* NOTE: The order of the mappings is NOT guaranteed.
|
||||
*/
|
||||
MappingList.prototype.unsortedForEach =
|
||||
function MappingList_forEach(aCallback, aThisArg) {
|
||||
this._array.forEach(aCallback, aThisArg);
|
||||
};
|
||||
MappingList.prototype.unsortedForEach = function MappingList_forEach(
|
||||
aCallback,
|
||||
aThisArg
|
||||
) {
|
||||
this._array.forEach(aCallback, aThisArg);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add the given source mapping.
|
||||
|
169
node_modules/source-map-js/lib/quick-sort.js
generated
vendored
169
node_modules/source-map-js/lib/quick-sort.js
generated
vendored
@ -16,92 +16,91 @@
|
||||
// a ~3500ms mean speed-up in `bench/bench.html`.
|
||||
|
||||
function SortTemplate(comparator) {
|
||||
|
||||
/**
|
||||
* Swap the elements indexed by `x` and `y` in the array `ary`.
|
||||
*
|
||||
* @param {Array} ary
|
||||
* The array.
|
||||
* @param {Number} x
|
||||
* The index of the first item.
|
||||
* @param {Number} y
|
||||
* The index of the second item.
|
||||
*/
|
||||
function swap(ary, x, y) {
|
||||
var temp = ary[x];
|
||||
ary[x] = ary[y];
|
||||
ary[y] = temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random integer within the range `low .. high` inclusive.
|
||||
*
|
||||
* @param {Number} low
|
||||
* The lower bound on the range.
|
||||
* @param {Number} high
|
||||
* The upper bound on the range.
|
||||
*/
|
||||
function randomIntInRange(low, high) {
|
||||
return Math.round(low + (Math.random() * (high - low)));
|
||||
}
|
||||
|
||||
/**
|
||||
* The Quick Sort algorithm.
|
||||
*
|
||||
* @param {Array} ary
|
||||
* An array to sort.
|
||||
* @param {function} comparator
|
||||
* Function to use to compare two items.
|
||||
* @param {Number} p
|
||||
* Start index of the array
|
||||
* @param {Number} r
|
||||
* End index of the array
|
||||
*/
|
||||
function doQuickSort(ary, comparator, p, r) {
|
||||
// If our lower bound is less than our upper bound, we (1) partition the
|
||||
// array into two pieces and (2) recurse on each half. If it is not, this is
|
||||
// the empty array and our base case.
|
||||
|
||||
if (p < r) {
|
||||
// (1) Partitioning.
|
||||
//
|
||||
// The partitioning chooses a pivot between `p` and `r` and moves all
|
||||
// elements that are less than or equal to the pivot to the before it, and
|
||||
// all the elements that are greater than it after it. The effect is that
|
||||
// once partition is done, the pivot is in the exact place it will be when
|
||||
// the array is put in sorted order, and it will not need to be moved
|
||||
// again. This runs in O(n) time.
|
||||
|
||||
// Always choose a random pivot so that an input array which is reverse
|
||||
// sorted does not cause O(n^2) running time.
|
||||
var pivotIndex = randomIntInRange(p, r);
|
||||
var i = p - 1;
|
||||
|
||||
swap(ary, pivotIndex, r);
|
||||
var pivot = ary[r];
|
||||
|
||||
// Immediately after `j` is incremented in this loop, the following hold
|
||||
// true:
|
||||
//
|
||||
// * Every element in `ary[p .. i]` is less than or equal to the pivot.
|
||||
//
|
||||
// * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
|
||||
for (var j = p; j < r; j++) {
|
||||
if (comparator(ary[j], pivot, false) <= 0) {
|
||||
i += 1;
|
||||
swap(ary, i, j);
|
||||
}
|
||||
}
|
||||
|
||||
swap(ary, i + 1, j);
|
||||
var q = i + 1;
|
||||
|
||||
// (2) Recurse on each half.
|
||||
|
||||
doQuickSort(ary, comparator, p, q - 1);
|
||||
doQuickSort(ary, comparator, q + 1, r);
|
||||
/**
|
||||
* Swap the elements indexed by `x` and `y` in the array `ary`.
|
||||
*
|
||||
* @param {Array} ary
|
||||
* The array.
|
||||
* @param {Number} x
|
||||
* The index of the first item.
|
||||
* @param {Number} y
|
||||
* The index of the second item.
|
||||
*/
|
||||
function swap(ary, x, y) {
|
||||
var temp = ary[x];
|
||||
ary[x] = ary[y];
|
||||
ary[y] = temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random integer within the range `low .. high` inclusive.
|
||||
*
|
||||
* @param {Number} low
|
||||
* The lower bound on the range.
|
||||
* @param {Number} high
|
||||
* The upper bound on the range.
|
||||
*/
|
||||
function randomIntInRange(low, high) {
|
||||
return Math.round(low + Math.random() * (high - low));
|
||||
}
|
||||
|
||||
/**
|
||||
* The Quick Sort algorithm.
|
||||
*
|
||||
* @param {Array} ary
|
||||
* An array to sort.
|
||||
* @param {function} comparator
|
||||
* Function to use to compare two items.
|
||||
* @param {Number} p
|
||||
* Start index of the array
|
||||
* @param {Number} r
|
||||
* End index of the array
|
||||
*/
|
||||
function doQuickSort(ary, comparator, p, r) {
|
||||
// If our lower bound is less than our upper bound, we (1) partition the
|
||||
// array into two pieces and (2) recurse on each half. If it is not, this is
|
||||
// the empty array and our base case.
|
||||
|
||||
if (p < r) {
|
||||
// (1) Partitioning.
|
||||
//
|
||||
// The partitioning chooses a pivot between `p` and `r` and moves all
|
||||
// elements that are less than or equal to the pivot to the before it, and
|
||||
// all the elements that are greater than it after it. The effect is that
|
||||
// once partition is done, the pivot is in the exact place it will be when
|
||||
// the array is put in sorted order, and it will not need to be moved
|
||||
// again. This runs in O(n) time.
|
||||
|
||||
// Always choose a random pivot so that an input array which is reverse
|
||||
// sorted does not cause O(n^2) running time.
|
||||
var pivotIndex = randomIntInRange(p, r);
|
||||
var i = p - 1;
|
||||
|
||||
swap(ary, pivotIndex, r);
|
||||
var pivot = ary[r];
|
||||
|
||||
// Immediately after `j` is incremented in this loop, the following hold
|
||||
// true:
|
||||
//
|
||||
// * Every element in `ary[p .. i]` is less than or equal to the pivot.
|
||||
//
|
||||
// * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
|
||||
for (var j = p; j < r; j++) {
|
||||
if (comparator(ary[j], pivot, false) <= 0) {
|
||||
i += 1;
|
||||
swap(ary, i, j);
|
||||
}
|
||||
}
|
||||
|
||||
swap(ary, i + 1, j);
|
||||
var q = i + 1;
|
||||
|
||||
// (2) Recurse on each half.
|
||||
|
||||
doQuickSort(ary, comparator, p, q - 1);
|
||||
doQuickSort(ary, comparator, q + 1, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return doQuickSort;
|
||||
}
|
||||
|
338
node_modules/source-map-js/lib/source-map-consumer.js
generated
vendored
338
node_modules/source-map-js/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,14 +132,14 @@ 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;
|
||||
@ -151,7 +151,7 @@ SourceMapConsumer.prototype.eachMapping =
|
||||
for (var i = 0, n = mappings.length; i < n; i++) {
|
||||
var mapping = mappings[i];
|
||||
var source = mapping.source === null ? null : sources.at(mapping.source);
|
||||
if(source !== null) {
|
||||
if (source !== null) {
|
||||
source = util.computeSourceURL(sourceRoot, source, sourceMapURL);
|
||||
}
|
||||
boundCallback({
|
||||
@ -160,7 +160,7 @@ SourceMapConsumer.prototype.eachMapping =
|
||||
generatedColumn: mapping.generatedColumn,
|
||||
originalLine: mapping.originalLine,
|
||||
originalColumn: mapping.originalColumn,
|
||||
name: mapping.name === null ? null : names.at(mapping.name)
|
||||
name: mapping.name === null ? null : names.at(mapping.name),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -198,7 +198,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);
|
||||
@ -208,12 +208,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];
|
||||
|
||||
@ -228,7 +230,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];
|
||||
@ -240,13 +242,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];
|
||||
@ -330,8 +334,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;
|
||||
});
|
||||
|
||||
@ -360,7 +366,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);
|
||||
@ -391,55 +397,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.
|
||||
@ -452,7 +468,7 @@ BasicSourceMapConsumer.prototype._version = 3;
|
||||
Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
|
||||
get: function () {
|
||||
return this._absoluteSources.slice();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
@ -527,11 +543,9 @@ BasicSourceMapConsumer.prototype._parseMappings =
|
||||
|
||||
sortGenerated(generatedMappings, subarrayStart);
|
||||
subarrayStart = generatedMappings.length;
|
||||
}
|
||||
else if (aStr.charAt(index) === ',') {
|
||||
} else if (aStr.charAt(index) === ',') {
|
||||
index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mapping = new Mapping();
|
||||
mapping.generatedLine = generatedLine;
|
||||
|
||||
@ -614,20 +628,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);
|
||||
@ -688,14 +710,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)
|
||||
);
|
||||
@ -707,7 +729,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) {
|
||||
@ -717,7 +743,7 @@ BasicSourceMapConsumer.prototype.originalPositionFor =
|
||||
source: source,
|
||||
line: util.getArg(mapping, 'originalLine', null),
|
||||
column: util.getArg(mapping, 'originalColumn', null),
|
||||
name: name
|
||||
name: name,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -726,7 +752,7 @@ BasicSourceMapConsumer.prototype.originalPositionFor =
|
||||
source: null,
|
||||
line: null,
|
||||
column: null,
|
||||
name: null
|
||||
name: null,
|
||||
};
|
||||
};
|
||||
|
||||
@ -739,8 +765,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;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -765,21 +795,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)];
|
||||
}
|
||||
}
|
||||
|
||||
@ -789,8 +819,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.');
|
||||
}
|
||||
};
|
||||
@ -826,21 +855,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)
|
||||
);
|
||||
@ -852,7 +881,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),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -860,7 +889,7 @@ BasicSourceMapConsumer.prototype.generatedPositionFor =
|
||||
return {
|
||||
line: null,
|
||||
column: null,
|
||||
lastColumn: null
|
||||
lastColumn: null,
|
||||
};
|
||||
};
|
||||
|
||||
@ -933,7 +962,7 @@ function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
|
||||
|
||||
var lastOffset = {
|
||||
line: -1,
|
||||
column: 0
|
||||
column: 0,
|
||||
};
|
||||
this._sections = sections.map(function (s) {
|
||||
if (s.url) {
|
||||
@ -945,8 +974,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;
|
||||
@ -956,10 +987,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),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@ -983,7 +1014,7 @@ Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
|
||||
}
|
||||
}
|
||||
return sources;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
@ -1009,21 +1040,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) {
|
||||
@ -1031,18 +1064,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,
|
||||
});
|
||||
};
|
||||
|
||||
@ -1074,8 +1107,7 @@ IndexedSourceMapConsumer.prototype.sourceContentFor =
|
||||
}
|
||||
if (nullOnMissing) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Error('"' + aSource + '" is not in the SourceMap.');
|
||||
}
|
||||
};
|
||||
@ -1094,7 +1126,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.
|
||||
*/
|
||||
@ -1105,18 +1137,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;
|
||||
}
|
||||
@ -1124,7 +1160,7 @@ IndexedSourceMapConsumer.prototype.generatedPositionFor =
|
||||
|
||||
return {
|
||||
line: null,
|
||||
column: null
|
||||
column: null,
|
||||
};
|
||||
};
|
||||
|
||||
@ -1144,8 +1180,12 @@ IndexedSourceMapConsumer.prototype._parseMappings =
|
||||
var mapping = sectionMappings[j];
|
||||
|
||||
var source = section.consumer._sources.at(mapping.source);
|
||||
if(source !== null) {
|
||||
source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
|
||||
if (source !== null) {
|
||||
source = util.computeSourceURL(
|
||||
section.consumer.sourceRoot,
|
||||
source,
|
||||
this._sourceMapURL
|
||||
);
|
||||
}
|
||||
this._sources.add(source);
|
||||
source = this._sources.indexOf(source);
|
||||
@ -1163,15 +1203,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);
|
||||
@ -1181,7 +1222,10 @@ IndexedSourceMapConsumer.prototype._parseMappings =
|
||||
}
|
||||
}
|
||||
|
||||
quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
|
||||
quickSort(
|
||||
this.__generatedMappings,
|
||||
util.compareByGeneratedPositionsDeflated
|
||||
);
|
||||
quickSort(this.__originalMappings, util.compareByOriginalPositions);
|
||||
};
|
||||
|
||||
|
258
node_modules/source-map-js/lib/source-map-generator.js
generated
vendored
258
node_modules/source-map-js/lib/source-map-generator.js
generated
vendored
@ -25,7 +25,11 @@ function SourceMapGenerator(aArgs) {
|
||||
this._file = util.getArg(aArgs, 'file', null);
|
||||
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
|
||||
this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
|
||||
this._ignoreInvalidMapping = util.getArg(aArgs, 'ignoreInvalidMapping', false);
|
||||
this._ignoreInvalidMapping = util.getArg(
|
||||
aArgs,
|
||||
'ignoreInvalidMapping',
|
||||
false
|
||||
);
|
||||
this._sources = new ArraySet();
|
||||
this._names = new ArraySet();
|
||||
this._mappings = new MappingList();
|
||||
@ -39,56 +43,60 @@ SourceMapGenerator.prototype._version = 3;
|
||||
*
|
||||
* @param aSourceMapConsumer The SourceMap.
|
||||
*/
|
||||
SourceMapGenerator.fromSourceMap =
|
||||
function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
|
||||
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
||||
var generator = new SourceMapGenerator(Object.assign(generatorOps || {}, {
|
||||
SourceMapGenerator.fromSourceMap = function SourceMapGenerator_fromSourceMap(
|
||||
aSourceMapConsumer,
|
||||
generatorOps
|
||||
) {
|
||||
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
||||
var generator = new SourceMapGenerator(
|
||||
Object.assign(generatorOps || {}, {
|
||||
file: aSourceMapConsumer.file,
|
||||
sourceRoot: sourceRoot
|
||||
}));
|
||||
aSourceMapConsumer.eachMapping(function (mapping) {
|
||||
var newMapping = {
|
||||
generated: {
|
||||
line: mapping.generatedLine,
|
||||
column: mapping.generatedColumn
|
||||
}
|
||||
sourceRoot: sourceRoot,
|
||||
})
|
||||
);
|
||||
aSourceMapConsumer.eachMapping(function (mapping) {
|
||||
var newMapping = {
|
||||
generated: {
|
||||
line: mapping.generatedLine,
|
||||
column: mapping.generatedColumn,
|
||||
},
|
||||
};
|
||||
|
||||
if (mapping.source != null) {
|
||||
newMapping.source = mapping.source;
|
||||
if (sourceRoot != null) {
|
||||
newMapping.source = util.relative(sourceRoot, newMapping.source);
|
||||
}
|
||||
|
||||
newMapping.original = {
|
||||
line: mapping.originalLine,
|
||||
column: mapping.originalColumn,
|
||||
};
|
||||
|
||||
if (mapping.source != null) {
|
||||
newMapping.source = mapping.source;
|
||||
if (sourceRoot != null) {
|
||||
newMapping.source = util.relative(sourceRoot, newMapping.source);
|
||||
}
|
||||
|
||||
newMapping.original = {
|
||||
line: mapping.originalLine,
|
||||
column: mapping.originalColumn
|
||||
};
|
||||
|
||||
if (mapping.name != null) {
|
||||
newMapping.name = mapping.name;
|
||||
}
|
||||
if (mapping.name != null) {
|
||||
newMapping.name = mapping.name;
|
||||
}
|
||||
}
|
||||
|
||||
generator.addMapping(newMapping);
|
||||
});
|
||||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||||
var sourceRelative = sourceFile;
|
||||
if (sourceRoot !== null) {
|
||||
sourceRelative = util.relative(sourceRoot, sourceFile);
|
||||
}
|
||||
generator.addMapping(newMapping);
|
||||
});
|
||||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||||
var sourceRelative = sourceFile;
|
||||
if (sourceRoot !== null) {
|
||||
sourceRelative = util.relative(sourceRoot, sourceFile);
|
||||
}
|
||||
|
||||
if (!generator._sources.has(sourceRelative)) {
|
||||
generator._sources.add(sourceRelative);
|
||||
}
|
||||
if (!generator._sources.has(sourceRelative)) {
|
||||
generator._sources.add(sourceRelative);
|
||||
}
|
||||
|
||||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||||
if (content != null) {
|
||||
generator.setSourceContent(sourceFile, content);
|
||||
}
|
||||
});
|
||||
return generator;
|
||||
};
|
||||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||||
if (content != null) {
|
||||
generator.setSourceContent(sourceFile, content);
|
||||
}
|
||||
});
|
||||
return generator;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a single mapping from original source line and column to the generated
|
||||
@ -133,7 +141,7 @@ SourceMapGenerator.prototype.addMapping =
|
||||
originalLine: original != null && original.line,
|
||||
originalColumn: original != null && original.column,
|
||||
source: source,
|
||||
name: name
|
||||
name: name,
|
||||
});
|
||||
};
|
||||
|
||||
@ -181,14 +189,18 @@ SourceMapGenerator.prototype.setSourceContent =
|
||||
* relative to the SourceMapGenerator.
|
||||
*/
|
||||
SourceMapGenerator.prototype.applySourceMap =
|
||||
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
|
||||
function SourceMapGenerator_applySourceMap(
|
||||
aSourceMapConsumer,
|
||||
aSourceFile,
|
||||
aSourceMapPath
|
||||
) {
|
||||
var sourceFile = aSourceFile;
|
||||
// If aSourceFile is omitted, we will use the file property of the SourceMap
|
||||
if (aSourceFile == null) {
|
||||
if (aSourceMapConsumer.file == null) {
|
||||
throw new Error(
|
||||
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
|
||||
'or the source map\'s "file" property. Both were omitted.'
|
||||
'or the source map\'s "file" property. Both were omitted.'
|
||||
);
|
||||
}
|
||||
sourceFile = aSourceMapConsumer.file;
|
||||
@ -209,13 +221,13 @@ SourceMapGenerator.prototype.applySourceMap =
|
||||
// Check if it can be mapped by the source map, then update the mapping.
|
||||
var original = aSourceMapConsumer.originalPositionFor({
|
||||
line: mapping.originalLine,
|
||||
column: mapping.originalColumn
|
||||
column: mapping.originalColumn,
|
||||
});
|
||||
if (original.source != null) {
|
||||
// Copy mapping
|
||||
mapping.source = original.source;
|
||||
if (aSourceMapPath != null) {
|
||||
mapping.source = util.join(aSourceMapPath, mapping.source)
|
||||
mapping.source = util.join(aSourceMapPath, mapping.source);
|
||||
}
|
||||
if (sourceRoot != null) {
|
||||
mapping.source = util.relative(sourceRoot, mapping.source);
|
||||
@ -237,7 +249,6 @@ SourceMapGenerator.prototype.applySourceMap =
|
||||
if (name != null && !newNames.has(name)) {
|
||||
newNames.add(name);
|
||||
}
|
||||
|
||||
}, this);
|
||||
this._sources = newSources;
|
||||
this._names = newNames;
|
||||
@ -269,16 +280,25 @@ SourceMapGenerator.prototype.applySourceMap =
|
||||
* in to one of these categories.
|
||||
*/
|
||||
SourceMapGenerator.prototype._validateMapping =
|
||||
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
|
||||
aName) {
|
||||
function SourceMapGenerator_validateMapping(
|
||||
aGenerated,
|
||||
aOriginal,
|
||||
aSource,
|
||||
aName
|
||||
) {
|
||||
// When aOriginal is truthy but has empty values for .line and .column,
|
||||
// it is most likely a programmer error. In this case we throw a very
|
||||
// specific error message to try to guide them the right way.
|
||||
// For example: https://github.com/Polymer/polymer-bundler/pull/519
|
||||
if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
|
||||
var message = 'original.line and original.column are not numbers -- you probably meant to omit ' +
|
||||
'the original mapping entirely and only map the generated position. If so, pass ' +
|
||||
'null for the original mapping instead of an object with empty or null values.'
|
||||
if (
|
||||
aOriginal &&
|
||||
typeof aOriginal.line !== 'number' &&
|
||||
typeof aOriginal.column !== 'number'
|
||||
) {
|
||||
var message =
|
||||
'original.line and original.column are not numbers -- you probably meant to omit ' +
|
||||
'the original mapping entirely and only map the generated position. If so, pass ' +
|
||||
'null for the original mapping instead of an object with empty or null values.';
|
||||
|
||||
if (this._ignoreInvalidMapping) {
|
||||
if (typeof console !== 'undefined' && console.warn) {
|
||||
@ -290,27 +310,42 @@ SourceMapGenerator.prototype._validateMapping =
|
||||
}
|
||||
}
|
||||
|
||||
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
||||
&& aGenerated.line > 0 && aGenerated.column >= 0
|
||||
&& !aOriginal && !aSource && !aName) {
|
||||
if (
|
||||
aGenerated &&
|
||||
'line' in aGenerated &&
|
||||
'column' in aGenerated &&
|
||||
aGenerated.line > 0 &&
|
||||
aGenerated.column >= 0 &&
|
||||
!aOriginal &&
|
||||
!aSource &&
|
||||
!aName
|
||||
) {
|
||||
// Case 1.
|
||||
return;
|
||||
}
|
||||
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
||||
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal
|
||||
&& aGenerated.line > 0 && aGenerated.column >= 0
|
||||
&& aOriginal.line > 0 && aOriginal.column >= 0
|
||||
&& aSource) {
|
||||
} else if (
|
||||
aGenerated &&
|
||||
'line' in aGenerated &&
|
||||
'column' in aGenerated &&
|
||||
aOriginal &&
|
||||
'line' in aOriginal &&
|
||||
'column' in aOriginal &&
|
||||
aGenerated.line > 0 &&
|
||||
aGenerated.column >= 0 &&
|
||||
aOriginal.line > 0 &&
|
||||
aOriginal.column >= 0 &&
|
||||
aSource
|
||||
) {
|
||||
// Cases 2 and 3.
|
||||
return;
|
||||
}
|
||||
else {
|
||||
var message = 'Invalid mapping: ' + JSON.stringify({
|
||||
generated: aGenerated,
|
||||
source: aSource,
|
||||
original: aOriginal,
|
||||
name: aName
|
||||
});
|
||||
} else {
|
||||
var message =
|
||||
'Invalid mapping: ' +
|
||||
JSON.stringify({
|
||||
generated: aGenerated,
|
||||
source: aSource,
|
||||
original: aOriginal,
|
||||
name: aName,
|
||||
});
|
||||
|
||||
if (this._ignoreInvalidMapping) {
|
||||
if (typeof console !== 'undefined' && console.warn) {
|
||||
@ -318,7 +353,7 @@ SourceMapGenerator.prototype._validateMapping =
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
throw new Error(message)
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -344,7 +379,7 @@ SourceMapGenerator.prototype._serializeMappings =
|
||||
var mappings = this._mappings.toArray();
|
||||
for (var i = 0, len = mappings.length; i < len; i++) {
|
||||
mapping = mappings[i];
|
||||
next = ''
|
||||
next = '';
|
||||
|
||||
if (mapping.generatedLine !== previousGeneratedLine) {
|
||||
previousGeneratedColumn = 0;
|
||||
@ -352,18 +387,20 @@ SourceMapGenerator.prototype._serializeMappings =
|
||||
next += ';';
|
||||
previousGeneratedLine++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (i > 0) {
|
||||
if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
|
||||
if (
|
||||
!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
next += ',';
|
||||
}
|
||||
}
|
||||
|
||||
next += base64VLQ.encode(mapping.generatedColumn
|
||||
- previousGeneratedColumn);
|
||||
next += base64VLQ.encode(
|
||||
mapping.generatedColumn - previousGeneratedColumn
|
||||
);
|
||||
previousGeneratedColumn = mapping.generatedColumn;
|
||||
|
||||
if (mapping.source != null) {
|
||||
@ -372,12 +409,14 @@ SourceMapGenerator.prototype._serializeMappings =
|
||||
previousSource = sourceIdx;
|
||||
|
||||
// lines are stored 0-based in SourceMap spec version 3
|
||||
next += base64VLQ.encode(mapping.originalLine - 1
|
||||
- previousOriginalLine);
|
||||
next += base64VLQ.encode(
|
||||
mapping.originalLine - 1 - previousOriginalLine
|
||||
);
|
||||
previousOriginalLine = mapping.originalLine - 1;
|
||||
|
||||
next += base64VLQ.encode(mapping.originalColumn
|
||||
- previousOriginalColumn);
|
||||
next += base64VLQ.encode(
|
||||
mapping.originalColumn - previousOriginalColumn
|
||||
);
|
||||
previousOriginalColumn = mapping.originalColumn;
|
||||
|
||||
if (mapping.name != null) {
|
||||
@ -403,8 +442,8 @@ SourceMapGenerator.prototype._generateSourcesContent =
|
||||
source = util.relative(aSourceRoot, source);
|
||||
}
|
||||
var key = util.toSetString(source);
|
||||
return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
|
||||
? this._sourcesContents[key]
|
||||
return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) ?
|
||||
this._sourcesContents[key]
|
||||
: null;
|
||||
}, this);
|
||||
};
|
||||
@ -412,33 +451,34 @@ SourceMapGenerator.prototype._generateSourcesContent =
|
||||
/**
|
||||
* Externalize the source map.
|
||||
*/
|
||||
SourceMapGenerator.prototype.toJSON =
|
||||
function SourceMapGenerator_toJSON() {
|
||||
var map = {
|
||||
version: this._version,
|
||||
sources: this._sources.toArray(),
|
||||
names: this._names.toArray(),
|
||||
mappings: this._serializeMappings()
|
||||
};
|
||||
if (this._file != null) {
|
||||
map.file = this._file;
|
||||
}
|
||||
if (this._sourceRoot != null) {
|
||||
map.sourceRoot = this._sourceRoot;
|
||||
}
|
||||
if (this._sourcesContents) {
|
||||
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
|
||||
}
|
||||
|
||||
return map;
|
||||
SourceMapGenerator.prototype.toJSON = function SourceMapGenerator_toJSON() {
|
||||
var map = {
|
||||
version: this._version,
|
||||
sources: this._sources.toArray(),
|
||||
names: this._names.toArray(),
|
||||
mappings: this._serializeMappings(),
|
||||
};
|
||||
if (this._file != null) {
|
||||
map.file = this._file;
|
||||
}
|
||||
if (this._sourceRoot != null) {
|
||||
map.sourceRoot = this._sourceRoot;
|
||||
}
|
||||
if (this._sourcesContents) {
|
||||
map.sourcesContent = this._generateSourcesContent(
|
||||
map.sources,
|
||||
map.sourceRoot
|
||||
);
|
||||
}
|
||||
|
||||
return map;
|
||||
};
|
||||
|
||||
/**
|
||||
* Render the source map being generated to a string.
|
||||
*/
|
||||
SourceMapGenerator.prototype.toString =
|
||||
function SourceMapGenerator_toString() {
|
||||
return JSON.stringify(this.toJSON());
|
||||
};
|
||||
SourceMapGenerator.prototype.toString = function SourceMapGenerator_toString() {
|
||||
return JSON.stringify(this.toJSON());
|
||||
};
|
||||
|
||||
exports.SourceMapGenerator = SourceMapGenerator;
|
||||
|
262
node_modules/source-map-js/lib/source-node.js
generated
vendored
262
node_modules/source-map-js/lib/source-node.js
generated
vendored
@ -18,7 +18,7 @@ var NEWLINE_CODE = 10;
|
||||
// Private symbol for identifying `SourceNode`s when multiple versions of
|
||||
// the source-map library are loaded. This MUST NOT CHANGE across
|
||||
// versions!
|
||||
var isSourceNode = "$$$isSourceNode$$$";
|
||||
var isSourceNode = '$$$isSourceNode$$$';
|
||||
|
||||
/**
|
||||
* SourceNodes provide a way to abstract over interpolating/concatenating
|
||||
@ -52,7 +52,11 @@ function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
|
||||
* SourceMapConsumer should be relative to.
|
||||
*/
|
||||
SourceNode.fromStringWithSourceMap =
|
||||
function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
|
||||
function SourceNode_fromStringWithSourceMap(
|
||||
aGeneratedCode,
|
||||
aSourceMapConsumer,
|
||||
aRelativePath
|
||||
) {
|
||||
// The SourceNode we want to fill with the generated code
|
||||
// and the SourceMap
|
||||
var node = new SourceNode();
|
||||
@ -63,20 +67,22 @@ SourceNode.fromStringWithSourceMap =
|
||||
// Processed fragments are accessed by calling `shiftNextLine`.
|
||||
var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
|
||||
var remainingLinesIndex = 0;
|
||||
var shiftNextLine = function() {
|
||||
var shiftNextLine = function () {
|
||||
var lineContents = getNextLine();
|
||||
// The last line of a file might not have a newline.
|
||||
var newLine = getNextLine() || "";
|
||||
var newLine = getNextLine() || '';
|
||||
return lineContents + newLine;
|
||||
|
||||
function getNextLine() {
|
||||
return remainingLinesIndex < remainingLines.length ?
|
||||
remainingLines[remainingLinesIndex++] : undefined;
|
||||
remainingLines[remainingLinesIndex++]
|
||||
: undefined;
|
||||
}
|
||||
};
|
||||
|
||||
// We need to remember the position of "remainingLines"
|
||||
var lastGeneratedLine = 1, lastGeneratedColumn = 0;
|
||||
var lastGeneratedLine = 1,
|
||||
lastGeneratedColumn = 0;
|
||||
|
||||
// The generate SourceNodes we need a code range.
|
||||
// To extract it current and last mapping is used.
|
||||
@ -98,10 +104,13 @@ SourceNode.fromStringWithSourceMap =
|
||||
// Associate the code between "lastGeneratedColumn" and
|
||||
// "mapping.generatedColumn" with "lastMapping"
|
||||
var nextLine = remainingLines[remainingLinesIndex] || '';
|
||||
var code = nextLine.substr(0, mapping.generatedColumn -
|
||||
lastGeneratedColumn);
|
||||
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
|
||||
lastGeneratedColumn);
|
||||
var code = nextLine.substr(
|
||||
0,
|
||||
mapping.generatedColumn - lastGeneratedColumn
|
||||
);
|
||||
remainingLines[remainingLinesIndex] = nextLine.substr(
|
||||
mapping.generatedColumn - lastGeneratedColumn
|
||||
);
|
||||
lastGeneratedColumn = mapping.generatedColumn;
|
||||
addMappingWithCode(lastMapping, code);
|
||||
// No more remaining code, continue
|
||||
@ -119,7 +128,9 @@ SourceNode.fromStringWithSourceMap =
|
||||
if (lastGeneratedColumn < mapping.generatedColumn) {
|
||||
var nextLine = remainingLines[remainingLinesIndex] || '';
|
||||
node.add(nextLine.substr(0, mapping.generatedColumn));
|
||||
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
|
||||
remainingLines[remainingLinesIndex] = nextLine.substr(
|
||||
mapping.generatedColumn
|
||||
);
|
||||
lastGeneratedColumn = mapping.generatedColumn;
|
||||
}
|
||||
lastMapping = mapping;
|
||||
@ -131,7 +142,7 @@ SourceNode.fromStringWithSourceMap =
|
||||
addMappingWithCode(lastMapping, shiftNextLine());
|
||||
}
|
||||
// and add the remaining lines without any mapping
|
||||
node.add(remainingLines.splice(remainingLinesIndex).join(""));
|
||||
node.add(remainingLines.splice(remainingLinesIndex).join(''));
|
||||
}
|
||||
|
||||
// Copy sourcesContent into SourceNode
|
||||
@ -151,14 +162,19 @@ SourceNode.fromStringWithSourceMap =
|
||||
if (mapping === null || mapping.source === undefined) {
|
||||
node.add(code);
|
||||
} else {
|
||||
var source = aRelativePath
|
||||
? util.join(aRelativePath, mapping.source)
|
||||
var source =
|
||||
aRelativePath ?
|
||||
util.join(aRelativePath, mapping.source)
|
||||
: mapping.source;
|
||||
node.add(new SourceNode(mapping.originalLine,
|
||||
mapping.originalColumn,
|
||||
source,
|
||||
code,
|
||||
mapping.name));
|
||||
node.add(
|
||||
new SourceNode(
|
||||
mapping.originalLine,
|
||||
mapping.originalColumn,
|
||||
source,
|
||||
code,
|
||||
mapping.name
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -174,15 +190,14 @@ SourceNode.prototype.add = function SourceNode_add(aChunk) {
|
||||
aChunk.forEach(function (chunk) {
|
||||
this.add(chunk);
|
||||
}, this);
|
||||
}
|
||||
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
||||
} else if (aChunk[isSourceNode] || typeof aChunk === 'string') {
|
||||
if (aChunk) {
|
||||
this.children.push(aChunk);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new TypeError(
|
||||
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
||||
'Expected a SourceNode, string, or an array of SourceNodes and strings. Got ' +
|
||||
aChunk
|
||||
);
|
||||
}
|
||||
return this;
|
||||
@ -196,16 +211,15 @@ SourceNode.prototype.add = function SourceNode_add(aChunk) {
|
||||
*/
|
||||
SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
|
||||
if (Array.isArray(aChunk)) {
|
||||
for (var i = aChunk.length-1; i >= 0; i--) {
|
||||
for (var i = aChunk.length - 1; i >= 0; i--) {
|
||||
this.prepend(aChunk[i]);
|
||||
}
|
||||
}
|
||||
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
||||
} else if (aChunk[isSourceNode] || typeof aChunk === 'string') {
|
||||
this.children.unshift(aChunk);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new TypeError(
|
||||
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
||||
'Expected a SourceNode, string, or an array of SourceNodes and strings. Got ' +
|
||||
aChunk
|
||||
);
|
||||
}
|
||||
return this;
|
||||
@ -224,13 +238,14 @@ SourceNode.prototype.walk = function SourceNode_walk(aFn) {
|
||||
chunk = this.children[i];
|
||||
if (chunk[isSourceNode]) {
|
||||
chunk.walk(aFn);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (chunk !== '') {
|
||||
aFn(chunk, { source: this.source,
|
||||
line: this.line,
|
||||
column: this.column,
|
||||
name: this.name });
|
||||
aFn(chunk, {
|
||||
source: this.source,
|
||||
line: this.line,
|
||||
column: this.column,
|
||||
name: this.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -248,7 +263,7 @@ SourceNode.prototype.join = function SourceNode_join(aSep) {
|
||||
var len = this.children.length;
|
||||
if (len > 0) {
|
||||
newChildren = [];
|
||||
for (i = 0; i < len-1; i++) {
|
||||
for (i = 0; i < len - 1; i++) {
|
||||
newChildren.push(this.children[i]);
|
||||
newChildren.push(aSep);
|
||||
}
|
||||
@ -265,15 +280,19 @@ SourceNode.prototype.join = function SourceNode_join(aSep) {
|
||||
* @param aPattern The pattern to replace.
|
||||
* @param aReplacement The thing to replace the pattern with.
|
||||
*/
|
||||
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
|
||||
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(
|
||||
aPattern,
|
||||
aReplacement
|
||||
) {
|
||||
var lastChild = this.children[this.children.length - 1];
|
||||
if (lastChild[isSourceNode]) {
|
||||
lastChild.replaceRight(aPattern, aReplacement);
|
||||
}
|
||||
else if (typeof lastChild === 'string') {
|
||||
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
|
||||
}
|
||||
else {
|
||||
} else if (typeof lastChild === 'string') {
|
||||
this.children[this.children.length - 1] = lastChild.replace(
|
||||
aPattern,
|
||||
aReplacement
|
||||
);
|
||||
} else {
|
||||
this.children.push(''.replace(aPattern, aReplacement));
|
||||
}
|
||||
return this;
|
||||
@ -286,10 +305,12 @@ SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, a
|
||||
* @param aSourceFile The filename of the source file
|
||||
* @param aSourceContent The content of the source file
|
||||
*/
|
||||
SourceNode.prototype.setSourceContent =
|
||||
function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
|
||||
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
|
||||
};
|
||||
SourceNode.prototype.setSourceContent = function SourceNode_setSourceContent(
|
||||
aSourceFile,
|
||||
aSourceContent
|
||||
) {
|
||||
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
|
||||
};
|
||||
|
||||
/**
|
||||
* Walk over the tree of SourceNodes. The walking function is called for each
|
||||
@ -316,7 +337,7 @@ SourceNode.prototype.walkSourceContents =
|
||||
* and concatenates all the various snippets together to one string.
|
||||
*/
|
||||
SourceNode.prototype.toString = function SourceNode_toString() {
|
||||
var str = "";
|
||||
var str = '';
|
||||
this.walk(function (chunk) {
|
||||
str += chunk;
|
||||
});
|
||||
@ -327,87 +348,92 @@ SourceNode.prototype.toString = function SourceNode_toString() {
|
||||
* Returns the string representation of this source node along with a source
|
||||
* map.
|
||||
*/
|
||||
SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
|
||||
var generated = {
|
||||
code: "",
|
||||
line: 1,
|
||||
column: 0
|
||||
};
|
||||
var map = new SourceMapGenerator(aArgs);
|
||||
var sourceMappingActive = false;
|
||||
var lastOriginalSource = null;
|
||||
var lastOriginalLine = null;
|
||||
var lastOriginalColumn = null;
|
||||
var lastOriginalName = null;
|
||||
this.walk(function (chunk, original) {
|
||||
generated.code += chunk;
|
||||
if (original.source !== null
|
||||
&& original.line !== null
|
||||
&& original.column !== null) {
|
||||
if(lastOriginalSource !== original.source
|
||||
|| lastOriginalLine !== original.line
|
||||
|| lastOriginalColumn !== original.column
|
||||
|| lastOriginalName !== original.name) {
|
||||
map.addMapping({
|
||||
source: original.source,
|
||||
original: {
|
||||
line: original.line,
|
||||
column: original.column
|
||||
},
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column
|
||||
},
|
||||
name: original.name
|
||||
});
|
||||
}
|
||||
lastOriginalSource = original.source;
|
||||
lastOriginalLine = original.line;
|
||||
lastOriginalColumn = original.column;
|
||||
lastOriginalName = original.name;
|
||||
sourceMappingActive = true;
|
||||
} else if (sourceMappingActive) {
|
||||
map.addMapping({
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column
|
||||
}
|
||||
});
|
||||
lastOriginalSource = null;
|
||||
sourceMappingActive = false;
|
||||
}
|
||||
for (var idx = 0, length = chunk.length; idx < length; idx++) {
|
||||
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
|
||||
generated.line++;
|
||||
generated.column = 0;
|
||||
// Mappings end at eol
|
||||
if (idx + 1 === length) {
|
||||
lastOriginalSource = null;
|
||||
sourceMappingActive = false;
|
||||
} else if (sourceMappingActive) {
|
||||
SourceNode.prototype.toStringWithSourceMap =
|
||||
function SourceNode_toStringWithSourceMap(aArgs) {
|
||||
var generated = {
|
||||
code: '',
|
||||
line: 1,
|
||||
column: 0,
|
||||
};
|
||||
var map = new SourceMapGenerator(aArgs);
|
||||
var sourceMappingActive = false;
|
||||
var lastOriginalSource = null;
|
||||
var lastOriginalLine = null;
|
||||
var lastOriginalColumn = null;
|
||||
var lastOriginalName = null;
|
||||
this.walk(function (chunk, original) {
|
||||
generated.code += chunk;
|
||||
if (
|
||||
original.source !== null &&
|
||||
original.line !== null &&
|
||||
original.column !== null
|
||||
) {
|
||||
if (
|
||||
lastOriginalSource !== original.source ||
|
||||
lastOriginalLine !== original.line ||
|
||||
lastOriginalColumn !== original.column ||
|
||||
lastOriginalName !== original.name
|
||||
) {
|
||||
map.addMapping({
|
||||
source: original.source,
|
||||
original: {
|
||||
line: original.line,
|
||||
column: original.column
|
||||
column: original.column,
|
||||
},
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column
|
||||
column: generated.column,
|
||||
},
|
||||
name: original.name
|
||||
name: original.name,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
generated.column++;
|
||||
lastOriginalSource = original.source;
|
||||
lastOriginalLine = original.line;
|
||||
lastOriginalColumn = original.column;
|
||||
lastOriginalName = original.name;
|
||||
sourceMappingActive = true;
|
||||
} else if (sourceMappingActive) {
|
||||
map.addMapping({
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column,
|
||||
},
|
||||
});
|
||||
lastOriginalSource = null;
|
||||
sourceMappingActive = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
this.walkSourceContents(function (sourceFile, sourceContent) {
|
||||
map.setSourceContent(sourceFile, sourceContent);
|
||||
});
|
||||
for (var idx = 0, length = chunk.length; idx < length; idx++) {
|
||||
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
|
||||
generated.line++;
|
||||
generated.column = 0;
|
||||
// Mappings end at eol
|
||||
if (idx + 1 === length) {
|
||||
lastOriginalSource = null;
|
||||
sourceMappingActive = false;
|
||||
} else if (sourceMappingActive) {
|
||||
map.addMapping({
|
||||
source: original.source,
|
||||
original: {
|
||||
line: original.line,
|
||||
column: original.column,
|
||||
},
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column,
|
||||
},
|
||||
name: original.name,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
generated.column++;
|
||||
}
|
||||
}
|
||||
});
|
||||
this.walkSourceContents(function (sourceFile, sourceContent) {
|
||||
map.setSourceContent(sourceFile, sourceContent);
|
||||
});
|
||||
|
||||
return { code: generated.code, map: map };
|
||||
};
|
||||
return { code: generated.code, map: map };
|
||||
};
|
||||
|
||||
exports.SourceNode = SourceNode;
|
||||
|
89
node_modules/source-map-js/lib/util.js
generated
vendored
89
node_modules/source-map-js/lib/util.js
generated
vendored
@ -26,7 +26,8 @@ function getArg(aArgs, aName, aDefaultValue) {
|
||||
}
|
||||
exports.getArg = getArg;
|
||||
|
||||
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
|
||||
var urlRegexp =
|
||||
/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
|
||||
var dataUrlRegexp = /^data:.+\,.+$/;
|
||||
|
||||
function urlParse(aUrl) {
|
||||
@ -39,7 +40,7 @@ function urlParse(aUrl) {
|
||||
auth: match[2],
|
||||
host: match[3],
|
||||
port: match[4],
|
||||
path: match[5]
|
||||
path: match[5],
|
||||
};
|
||||
}
|
||||
exports.urlParse = urlParse;
|
||||
@ -57,7 +58,7 @@ function urlGenerate(aParsedUrl) {
|
||||
url += aParsedUrl.host;
|
||||
}
|
||||
if (aParsedUrl.port) {
|
||||
url += ":" + aParsedUrl.port
|
||||
url += ':' + aParsedUrl.port;
|
||||
}
|
||||
if (aParsedUrl.path) {
|
||||
url += aParsedUrl.path;
|
||||
@ -78,7 +79,7 @@ var MAX_CACHED_INPUTS = 32;
|
||||
function lruMemoize(f) {
|
||||
var cache = [];
|
||||
|
||||
return function(input) {
|
||||
return function (input) {
|
||||
for (var i = 0; i < cache.length; i++) {
|
||||
if (cache[i].input === input) {
|
||||
var temp = cache[0];
|
||||
@ -131,13 +132,13 @@ var normalize = lruMemoize(function normalize(aPath) {
|
||||
var i = 0;
|
||||
while (true) {
|
||||
start = i;
|
||||
i = path.indexOf("/", start);
|
||||
i = path.indexOf('/', start);
|
||||
if (i === -1) {
|
||||
parts.push(path.slice(start));
|
||||
break;
|
||||
} else {
|
||||
parts.push(path.slice(start, i));
|
||||
while (i < path.length && path[i] === "/") {
|
||||
while (i < path.length && path[i] === '/') {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@ -193,11 +194,11 @@ exports.normalize = normalize;
|
||||
* - Joining for example 'http://' and 'www.example.com' is also supported.
|
||||
*/
|
||||
function join(aRoot, aPath) {
|
||||
if (aRoot === "") {
|
||||
aRoot = ".";
|
||||
if (aRoot === '') {
|
||||
aRoot = '.';
|
||||
}
|
||||
if (aPath === "") {
|
||||
aPath = ".";
|
||||
if (aPath === '') {
|
||||
aPath = '.';
|
||||
}
|
||||
var aPathUrl = urlParse(aPath);
|
||||
var aRootUrl = urlParse(aRoot);
|
||||
@ -223,8 +224,9 @@ function join(aRoot, aPath) {
|
||||
return urlGenerate(aRootUrl);
|
||||
}
|
||||
|
||||
var joined = aPath.charAt(0) === '/'
|
||||
? aPath
|
||||
var joined =
|
||||
aPath.charAt(0) === '/' ?
|
||||
aPath
|
||||
: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
|
||||
|
||||
if (aRootUrl) {
|
||||
@ -246,8 +248,8 @@ exports.isAbsolute = function (aPath) {
|
||||
* @param aPath The path or URL to be made relative to aRoot.
|
||||
*/
|
||||
function relative(aRoot, aPath) {
|
||||
if (aRoot === "") {
|
||||
aRoot = ".";
|
||||
if (aRoot === '') {
|
||||
aRoot = '.';
|
||||
}
|
||||
|
||||
aRoot = aRoot.replace(/\/$/, '');
|
||||
@ -258,7 +260,7 @@ function relative(aRoot, aPath) {
|
||||
// a prefix that fits, or we run out of components to remove.
|
||||
var level = 0;
|
||||
while (aPath.indexOf(aRoot + '/') !== 0) {
|
||||
var index = aRoot.lastIndexOf("/");
|
||||
var index = aRoot.lastIndexOf('/');
|
||||
if (index < 0) {
|
||||
return aPath;
|
||||
}
|
||||
@ -275,16 +277,16 @@ function relative(aRoot, aPath) {
|
||||
}
|
||||
|
||||
// Make sure we add a "../" for each component we removed from the root.
|
||||
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
|
||||
return Array(level + 1).join('../') + aPath.substr(aRoot.length + 1);
|
||||
}
|
||||
exports.relative = relative;
|
||||
|
||||
var supportsNullProto = (function () {
|
||||
var obj = Object.create(null);
|
||||
return !('__proto__' in obj);
|
||||
}());
|
||||
})();
|
||||
|
||||
function identity (s) {
|
||||
function identity(s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -326,15 +328,17 @@ function isProtoString(s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 2) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
|
||||
s.charCodeAt(length - 4) !== 116 /* 't' */ ||
|
||||
s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
|
||||
s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
|
||||
s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
|
||||
s.charCodeAt(length - 8) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 9) !== 95 /* '_' */) {
|
||||
if (
|
||||
s.charCodeAt(length - 1) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 2) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
|
||||
s.charCodeAt(length - 4) !== 116 /* 't' */ ||
|
||||
s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
|
||||
s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
|
||||
s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
|
||||
s.charCodeAt(length - 8) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 9) !== 95 /* '_' */
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -385,8 +389,12 @@ function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
||||
}
|
||||
exports.compareByOriginalPositions = compareByOriginalPositions;
|
||||
|
||||
function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
|
||||
var cmp
|
||||
function compareByOriginalPositionsNoSource(
|
||||
mappingA,
|
||||
mappingB,
|
||||
onlyCompareOriginal
|
||||
) {
|
||||
var cmp;
|
||||
|
||||
cmp = mappingA.originalLine - mappingB.originalLine;
|
||||
if (cmp !== 0) {
|
||||
@ -421,7 +429,11 @@ exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
|
||||
* source/name/original line and column the same. Useful when searching for a
|
||||
* mapping with a stubbed out mapping.
|
||||
*/
|
||||
function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
|
||||
function compareByGeneratedPositionsDeflated(
|
||||
mappingA,
|
||||
mappingB,
|
||||
onlyCompareGenerated
|
||||
) {
|
||||
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
@ -449,9 +461,14 @@ function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGene
|
||||
|
||||
return strcmp(mappingA.name, mappingB.name);
|
||||
}
|
||||
exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
|
||||
exports.compareByGeneratedPositionsDeflated =
|
||||
compareByGeneratedPositionsDeflated;
|
||||
|
||||
function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
|
||||
function compareByGeneratedPositionsDeflatedNoLine(
|
||||
mappingA,
|
||||
mappingB,
|
||||
onlyCompareGenerated
|
||||
) {
|
||||
var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||||
if (cmp !== 0 || onlyCompareGenerated) {
|
||||
return cmp;
|
||||
@ -474,7 +491,8 @@ function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompa
|
||||
|
||||
return strcmp(mappingA.name, mappingB.name);
|
||||
}
|
||||
exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
|
||||
exports.compareByGeneratedPositionsDeflatedNoLine =
|
||||
compareByGeneratedPositionsDeflatedNoLine;
|
||||
|
||||
function strcmp(aStr1, aStr2) {
|
||||
if (aStr1 === aStr2) {
|
||||
@ -528,7 +546,8 @@ function compareByGeneratedPositionsInflated(mappingA, mappingB) {
|
||||
|
||||
return strcmp(mappingA.name, mappingB.name);
|
||||
}
|
||||
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
|
||||
exports.compareByGeneratedPositionsInflated =
|
||||
compareByGeneratedPositionsInflated;
|
||||
|
||||
/**
|
||||
* Strip any JSON XSSI avoidance prefix from the string (as documented
|
||||
@ -577,7 +596,7 @@ function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
|
||||
if (sourceMapURL) {
|
||||
var parsed = urlParse(sourceMapURL);
|
||||
if (!parsed) {
|
||||
throw new Error("sourceMapURL could not be parsed");
|
||||
throw new Error('sourceMapURL could not be parsed');
|
||||
}
|
||||
if (parsed.path) {
|
||||
// Strip the last path component, but keep the "/".
|
||||
|
Reference in New Issue
Block a user