🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

source-map

Package Overview
Dependencies
Maintainers
25
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

source-map - npm Package Compare versions

Comparing version
0.8.0-beta.0
to
0.8.0
+2
-2
lib/array-set.js

@@ -63,3 +63,3 @@ /* -*- Mode: js; js-indent-level: 2; -*- */

has(aStr) {
return this._set.has(aStr);
return this._set.has(aStr);
}

@@ -75,3 +75,3 @@

if (idx >= 0) {
return idx;
return idx;
}

@@ -78,0 +78,0 @@ throw new Error('"' + aStr + '" is not in the set.');

@@ -70,23 +70,6 @@ /* -*- Mode: js; js-indent-level: 2; -*- */

function toVLQSigned(aValue) {
return aValue < 0
? ((-aValue) << 1) + 1
: (aValue << 1) + 0;
return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0;
}
/**
* Converts to a two-complement value from a value where the sign bit is
* placed in the least significant bit. For example, as decimals:
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
*/
// eslint-disable-next-line no-unused-vars
function fromVLQSigned(aValue) {
const isNegative = (aValue & 1) === 1;
const shifted = aValue >> 1;
return isNegative
? -shifted
: shifted;
}
/**
* Returns the base 64 VLQ encoded value.

@@ -93,0 +76,0 @@ */

@@ -8,3 +8,4 @@ /* -*- Mode: js; js-indent-level: 2; -*- */

const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
const intToCharMap =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");

@@ -14,3 +15,3 @@ /**

*/
exports.encode = function(number) {
exports.encode = function (number) {
if (0 <= number && number < intToCharMap.length) {

@@ -17,0 +18,0 @@ return intToCharMap[number];

@@ -48,3 +48,3 @@ /* -*- Mode: js; js-indent-level: 2; -*- */

// we are in termination case (3) or (2) and return the appropriate thing.
if (aBias == exports.LEAST_UPPER_BOUND) {
if (aBias === exports.LEAST_UPPER_BOUND) {
return aHigh < aHaystack.length ? aHigh : -1;

@@ -91,4 +91,10 @@ }

let index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
aCompare, aBias || exports.GREATEST_LOWER_BOUND);
let index = recursiveSearch(
-1,
aHaystack.length,
aNeedle,
aHaystack,
aCompare,
aBias || exports.GREATEST_LOWER_BOUND
);
if (index < 0) {

@@ -98,3 +104,3 @@ return -1;

// We have found either the exact element, or the next-closest element than
// We have found either the exact element, or the next-closest element to
// the one we are searching for. However, there may be more than one such

@@ -101,0 +107,0 @@ // element. Make sure we always return the smallest of these.

@@ -20,4 +20,7 @@ /* -*- Mode: js; js-indent-level: 2; -*- */

const 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
);
}

@@ -35,3 +38,3 @@

// Serves as infimum
this._last = {generatedLine: -1, generatedColumn: 0};
this._last = { generatedLine: -1, generatedColumn: 0 };
}

@@ -38,0 +41,0 @@

@@ -7,4 +7,3 @@ "use strict";

if (typeof mappingsWasm === "string") {
return fetch(mappingsWasm)
.then(response => response.arrayBuffer());
return fetch(mappingsWasm).then(response => response.arrayBuffer());
}

@@ -15,6 +14,8 @@ if (mappingsWasm instanceof ArrayBuffer) {

throw new Error("You must provide the string URL or ArrayBuffer contents " +
"of lib/mappings.wasm by calling " +
"SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) " +
"before using SourceMapConsumer");
throw new Error(
"You must provide the string URL or ArrayBuffer contents " +
"of lib/mappings.wasm by calling " +
"SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) " +
"before using SourceMapConsumer"
);
};

@@ -21,0 +22,0 @@

@@ -24,3 +24,5 @@ "use strict";

module.exports.initialize = _ => {
console.debug("SourceMapConsumer.initialize is a no-op when running in node.js");
console.debug(
"SourceMapConsumer.initialize is a no-op when running in node.js"
);
};

@@ -190,2 +190,7 @@ /* -*- Mode: js; js-indent-level: 2; -*- */

const file = util.getArg(sourceMap, "file", null);
const x_google_ignoreList = util.getArg(
sourceMap,
"x_google_ignoreList",
null
);

@@ -207,5 +212,8 @@ // Once again, Sass deviates from the spec and supplies the version as a

that._absoluteSources = ArraySet.fromArray(that._sources.toArray().map(function(s) {
return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
}), true);
that._absoluteSources = ArraySet.fromArray(
that._sources.toArray().map(function (s) {
return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
}),
true
);

@@ -217,2 +225,3 @@ that.sourceRoot = sourceRoot;

that.file = file;
that.x_google_ignoreList = x_google_ignoreList;

@@ -243,3 +252,7 @@ that._computedColumnSpans = false;

// Treat the source as map-relative overall by default.
const sourceAsMapRelative = util.computeSourceURL(null, aSource, this._sourceMapURL);
const sourceAsMapRelative = util.computeSourceURL(
null,
aSource,
this._sourceMapURL
);
if (this._absoluteSources.has(sourceAsMapRelative)) {

@@ -252,3 +265,7 @@ const index = this._absoluteSources.indexOf(sourceAsMapRelative);

// Fall back to treating the source as sourceRoot-relative.
const sourceAsSourceRootRelative = util.computeSourceURL(this.sourceRoot, aSource, this._sourceMapURL);
const sourceAsSourceRootRelative = util.computeSourceURL(
this.sourceRoot,
aSource,
this._sourceMapURL
);
if (this._absoluteSources.has(sourceAsSourceRootRelative)) {

@@ -298,4 +315,10 @@ const index = this._absoluteSources.indexOf(sourceAsSourceRootRelative);

const mappingsBufPtr = this._wasm.exports.allocate_mappings(size);
const mappingsBuf = new Uint8Array(this._wasm.exports.memory.buffer, mappingsBufPtr, size);
// Interpret signed result of allocate_mappings as unsigned, otherwise
// addresses higher than 2GB will be negative.
const mappingsBufPtr = this._wasm.exports.allocate_mappings(size) >>> 0;
const mappingsBuf = new Uint8Array(
this._wasm.exports.memory.buffer,
mappingsBufPtr,
size
);
for (let i = 0; i < size; i++) {

@@ -311,6 +334,7 @@ mappingsBuf[i] = aStr.charCodeAt(i);

// XXX: keep these error codes in sync with `fitzgen/source-map-mappings`.
// XXX: keep these error codes in sync with `wasm-mappings`.
switch (error) {
case 1:
msg += "the mappings contained a negative line, column, source index, or name index";
msg +=
"the mappings contained a negative line, column, source index, or name index";
break;

@@ -358,10 +382,10 @@ case 2:

switch (order) {
case SourceMapConsumer.GENERATED_ORDER:
this._wasm.exports.by_generated_location(this._getMappingsPtr());
break;
case SourceMapConsumer.ORIGINAL_ORDER:
this._wasm.exports.by_original_location(this._getMappingsPtr());
break;
default:
throw new Error("Unknown order of iteration.");
case SourceMapConsumer.GENERATED_ORDER:
this._wasm.exports.by_generated_location(this._getMappingsPtr());
break;
case SourceMapConsumer.ORIGINAL_ORDER:
this._wasm.exports.by_original_location(this._getMappingsPtr());
break;
default:
throw new Error("Unknown order of iteration.");
}

@@ -403,3 +427,4 @@ }

});
}, () => {
},
() => {
this._wasm.exports.all_generated_locations_for(

@@ -465,3 +490,3 @@ this._getMappingsPtr(),

generatedLine: util.getArg(aArgs, "line"),
generatedColumn: util.getArg(aArgs, "column")
generatedColumn: util.getArg(aArgs, "column"),
};

@@ -477,3 +502,7 @@

let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
let bias = util.getArg(
aArgs,
"bias",
SourceMapConsumer.GREATEST_LOWER_BOUND
);
if (bias == null) {

@@ -484,10 +513,13 @@ bias = SourceMapConsumer.GREATEST_LOWER_BOUND;

let mapping;
this._wasm.withMappingCallback(m => mapping = m, () => {
this._wasm.exports.original_location_for(
this._getMappingsPtr(),
needle.generatedLine - 1,
needle.generatedColumn,
bias
);
});
this._wasm.withMappingCallback(
m => (mapping = m),
() => {
this._wasm.exports.original_location_for(
this._getMappingsPtr(),
needle.generatedLine - 1,
needle.generatedColumn,
bias
);
}
);

@@ -510,3 +542,3 @@ if (mapping) {

column: util.getArg(mapping, "originalColumn", null),
name
name,
};

@@ -520,3 +552,3 @@ }

column: null,
name: null
name: null,
};

@@ -533,4 +565,8 @@ }

}
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;
})
);
}

@@ -594,3 +630,3 @@

column: null,
lastColumn: null
lastColumn: null,
};

@@ -602,3 +638,3 @@ }

originalLine: util.getArg(aArgs, "line"),
originalColumn: util.getArg(aArgs, "column")
originalColumn: util.getArg(aArgs, "column"),
};

@@ -614,3 +650,7 @@

let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
let bias = util.getArg(
aArgs,
"bias",
SourceMapConsumer.GREATEST_LOWER_BOUND
);
if (bias == null) {

@@ -621,11 +661,14 @@ bias = SourceMapConsumer.GREATEST_LOWER_BOUND;

let mapping;
this._wasm.withMappingCallback(m => mapping = m, () => {
this._wasm.exports.generated_location_for(
this._getMappingsPtr(),
needle.source,
needle.originalLine - 1,
needle.originalColumn,
bias
);
});
this._wasm.withMappingCallback(
m => (mapping = m),
() => {
this._wasm.exports.generated_location_for(
this._getMappingsPtr(),
needle.source,
needle.originalLine - 1,
needle.originalColumn,
bias
);
}
);

@@ -649,3 +692,3 @@ if (mapping) {

column: null,
lastColumn: null
lastColumn: null,
};

@@ -724,33 +767,44 @@ }

line: -1,
column: 0
column: 0,
};
return Promise.all(sections.map(s => {
if (s.url) {
// The url field will require support for asynchronicity.
// See https://github.com/mozilla/source-map/issues/16
throw new Error("Support for url field in sections not implemented.");
}
const offset = util.getArg(s, "offset");
const offsetLine = util.getArg(offset, "line");
const offsetColumn = util.getArg(offset, "column");
return Promise.all(
sections.map(s => {
if (s.url) {
// The url field will require support for asynchronicity.
// See https://github.com/mozilla/source-map/issues/16
throw new Error(
"Support for url field in sections not implemented."
);
}
const offset = util.getArg(s, "offset");
const offsetLine = util.getArg(offset, "line");
const offsetColumn = util.getArg(offset, "column");
if (offsetLine < lastOffset.line ||
(offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
throw new Error("Section offsets must be ordered and non-overlapping.");
}
lastOffset = offset;
if (
offsetLine < lastOffset.line ||
(offsetLine === lastOffset.line && offsetColumn < lastOffset.column)
) {
throw new Error(
"Section offsets must be ordered and non-overlapping."
);
}
lastOffset = offset;
const cons = new SourceMapConsumer(util.getArg(s, "map"), aSourceMapURL);
return cons.then(consumer => {
return {
generatedOffset: {
// The offset fields are 0-based, but we use 1-based indices when
// encoding/decoding from VLQ.
generatedLine: offsetLine + 1,
generatedColumn: offsetColumn + 1
},
consumer
};
});
})).then(s => {
const cons = new SourceMapConsumer(
util.getArg(s, "map"),
aSourceMapURL
);
return cons.then(consumer => {
return {
generatedOffset: {
// The offset fields are 0-based, but we use 1-based indices when
// encoding/decoding from VLQ.
generatedLine: offsetLine + 1,
generatedColumn: offsetColumn + 1,
},
consumer,
};
});
})
).then(s => {
that._sections = s;

@@ -797,3 +851,3 @@ return that;

generatedLine: util.getArg(aArgs, "line"),
generatedColumn: util.getArg(aArgs, "column")
generatedColumn: util.getArg(aArgs, "column"),
};

@@ -803,5 +857,8 @@

// to an original position.
const sectionIndex = binarySearch.search(needle, this._sections,
function(aNeedle, section) {
const cmp = aNeedle.generatedLine - section.generatedOffset.generatedLine;
const sectionIndex = binarySearch.search(
needle,
this._sections,
function (aNeedle, section) {
const cmp =
aNeedle.generatedLine - section.generatedOffset.generatedLine;
if (cmp) {

@@ -811,5 +868,10 @@ return cmp;

return (aNeedle.generatedColumn -
section.generatedOffset.generatedColumn);
});
// The generated column is 0-based, but the section offset column is
// stored 1-based.
return (
aNeedle.generatedColumn -
(section.generatedOffset.generatedColumn - 1)
);
}
);
const section = this._sections[sectionIndex];

@@ -822,3 +884,3 @@

column: null,
name: null
name: null,
};

@@ -828,9 +890,9 @@ }

return section.consumer.originalPositionFor({
line: needle.generatedLine -
(section.generatedOffset.generatedLine - 1),
column: needle.generatedColumn -
line: needle.generatedLine - (section.generatedOffset.generatedLine - 1),
column:
needle.generatedColumn -
(section.generatedOffset.generatedLine === needle.generatedLine
? section.generatedOffset.generatedColumn - 1
: 0),
bias: aArgs.bias
? section.generatedOffset.generatedColumn - 1
: 0),
bias: aArgs.bias,
});

@@ -844,3 +906,3 @@ }

hasContentsOfAllSources() {
return this._sections.every(function(s) {
return this._sections.every(function (s) {
return s.consumer.hasContentsOfAllSources();

@@ -935,3 +997,3 @@ });

column: null,
lastColumn: null
lastColumn: null,
};

@@ -950,4 +1012,5 @@ }

return section.consumer.allGeneratedPositionsFor(aArgs).map(
generatedPosition => {
return section.consumer
.allGeneratedPositionsFor(aArgs)
.map(generatedPosition => {
const lineShift = section.generatedOffset.generatedLine - 1;

@@ -974,4 +1037,3 @@ const columnShift = section.generatedOffset.generatedColumn - 1;

return generatedPosition;
}
);
});
}

@@ -982,5 +1044,3 @@

const nextSection =
index + 1 < this._sections.length
? this._sections[index + 1]
: null;
index + 1 < this._sections.length ? this._sections[index + 1] : null;
const { generatedOffset } = section;

@@ -991,23 +1051,27 @@

section.consumer.eachMapping(function(mapping) {
if (mapping.generatedLine === 1) {
mapping.generatedColumn += columnShift;
section.consumer.eachMapping(
function (mapping) {
if (mapping.generatedLine === 1) {
mapping.generatedColumn += columnShift;
if (typeof mapping.lastGeneratedColumn === "number") {
mapping.lastGeneratedColumn += columnShift;
if (typeof mapping.lastGeneratedColumn === "number") {
mapping.lastGeneratedColumn += columnShift;
}
}
}
if (
mapping.lastGeneratedColumn === Infinity &&
nextSection &&
mapping.generatedLine === nextSection.generatedOffset.generatedLine
) {
mapping.lastGeneratedColumn =
nextSection.generatedOffset.generatedColumn - 2;
}
mapping.generatedLine += lineShift;
if (
mapping.lastGeneratedColumn === Infinity &&
nextSection &&
mapping.generatedLine === nextSection.generatedOffset.generatedLine
) {
mapping.lastGeneratedColumn =
nextSection.generatedOffset.generatedColumn - 2;
}
mapping.generatedLine += lineShift;
aCallback.call(this, mapping);
}, aContext, aOrder);
aCallback.call(this, mapping);
},
aContext,
aOrder
);
});

@@ -1040,3 +1104,4 @@ }

const consumer = sourceMap.sections != null
const consumer =
sourceMap.sections != null
? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)

@@ -1043,0 +1108,0 @@ : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);

@@ -44,10 +44,10 @@ /* -*- Mode: js; js-indent-level: 2; -*- */

file: aSourceMapConsumer.file,
sourceRoot
sourceRoot,
});
aSourceMapConsumer.eachMapping(function(mapping) {
aSourceMapConsumer.eachMapping(function (mapping) {
const newMapping = {
generated: {
line: mapping.generatedLine,
column: mapping.generatedColumn
}
column: mapping.generatedColumn,
},
};

@@ -63,3 +63,3 @@

line: mapping.originalLine,
column: mapping.originalColumn
column: mapping.originalColumn,
};

@@ -74,5 +74,5 @@

});
aSourceMapConsumer.sources.forEach(function(sourceFile) {
aSourceMapConsumer.sources.forEach(function (sourceFile) {
let sourceRelative = sourceFile;
if (sourceRoot !== null) {
if (sourceRoot != null) {
sourceRelative = util.relative(sourceRoot, sourceFile);

@@ -130,6 +130,6 @@ }

generatedColumn: generated.column,
originalLine: original != null && original.line,
originalColumn: original != null && original.column,
originalLine: original && original.line,
originalColumn: original && original.column,
source,
name
name,
});

@@ -187,3 +187,3 @@ }

"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.'
);

@@ -200,9 +200,8 @@ }

// the names array.
const newSources = this._mappings.toArray().length > 0
? new ArraySet()
: this._sources;
const newSources =
this._mappings.toArray().length > 0 ? new ArraySet() : this._sources;
const newNames = new ArraySet();
// Find mappings for the "sourceFile"
this._mappings.unsortedForEach(function(mapping) {
this._mappings.unsortedForEach(function (mapping) {
if (mapping.source === sourceFile && mapping.originalLine != null) {

@@ -212,3 +211,3 @@ // Check if it can be mapped by the source map, then update the mapping.

line: mapping.originalLine,
column: mapping.originalColumn
column: mapping.originalColumn,
});

@@ -241,3 +240,2 @@ if (original.source != null) {

}
}, this);

@@ -248,3 +246,3 @@ this._sources = newSources;

// Copy sourcesContents of applied map.
aSourceMapConsumer.sources.forEach(function(srcFile) {
aSourceMapConsumer.sources.forEach(function (srcFile) {
const content = aSourceMapConsumer.sourceContentFor(srcFile);

@@ -279,29 +277,49 @@ if (content != null) {

// For example: https://github.com/Polymer/polymer-bundler/pull/519
if (aOriginal && typeof aOriginal.line !== "number" && typeof aOriginal.column !== "number") {
throw new Error(
"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"
) {
throw new Error(
"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 (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.
} 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.
} else {
throw new Error("Invalid mapping: " + JSON.stringify({
generated: aGenerated,
source: aSource,
original: aOriginal,
name: aName
}));
throw new Error(
"Invalid mapping: " +
JSON.stringify({
generated: aGenerated,
source: aSource,
original: aOriginal,
name: aName,
})
);
}

@@ -339,3 +357,5 @@ }

} else if (i > 0) {
if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
if (
!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])
) {
continue;

@@ -346,4 +366,5 @@ }

next += base64VLQ.encode(mapping.generatedColumn
- previousGeneratedColumn);
next += base64VLQ.encode(
mapping.generatedColumn - previousGeneratedColumn
);
previousGeneratedColumn = mapping.generatedColumn;

@@ -357,8 +378,10 @@

// 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;

@@ -380,3 +403,3 @@

_generateSourcesContent(aSources, aSourceRoot) {
return aSources.map(function(source) {
return aSources.map(function (source) {
if (!this._sourcesContents) {

@@ -403,3 +426,3 @@ return null;

names: this._names.toArray(),
mappings: this._serializeMappings()
mappings: this._serializeMappings(),
};

@@ -413,3 +436,6 @@ if (this._file != null) {

if (this._sourcesContents) {
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
map.sourcesContent = this._generateSourcesContent(
map.sources,
map.sourceRoot
);
}

@@ -416,0 +442,0 @@

@@ -38,3 +38,3 @@ /* -*- Mode: js; js-indent-level: 2; -*- */

this.children = [];
this.sourceContents = {};
this.sourceContents = Object.create(null);
this.line = aLine == null ? null : aLine;

@@ -56,3 +56,7 @@ this.column = aColumn == null ? null : aColumn;

*/
static fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
static fromStringWithSourceMap(
aGeneratedCode,
aSourceMapConsumer,
aRelativePath
) {
// The SourceNode we want to fill with the generated code

@@ -68,3 +72,3 @@ // and the SourceMap

let remainingLinesIndex = 0;
const shiftNextLine = function() {
const shiftNextLine = function () {
const lineContents = getNextLine();

@@ -76,4 +80,5 @@ // The last line of a file might not have a newline.

function getNextLine() {
return remainingLinesIndex < remainingLines.length ?
remainingLines[remainingLinesIndex++] : undefined;
return remainingLinesIndex < remainingLines.length
? remainingLines[remainingLinesIndex++]
: undefined;
}

@@ -83,3 +88,4 @@ };

// We need to remember the position of "remainingLines"
let lastGeneratedLine = 1, lastGeneratedColumn = 0;
let lastGeneratedLine = 1,
lastGeneratedColumn = 0;

@@ -92,3 +98,3 @@ // The generate SourceNodes we need a code range.

aSourceMapConsumer.eachMapping(function(mapping) {
aSourceMapConsumer.eachMapping(function (mapping) {
if (lastMapping !== null) {

@@ -108,6 +114,9 @@ // We add the code from "lastMapping" to "mapping":

nextLine = remainingLines[remainingLinesIndex] || "";
const code = nextLine.substr(0, mapping.generatedColumn -
lastGeneratedColumn);
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
lastGeneratedColumn);
const code = nextLine.substr(
0,
mapping.generatedColumn - lastGeneratedColumn
);
remainingLines[remainingLinesIndex] = nextLine.substr(
mapping.generatedColumn - lastGeneratedColumn
);
lastGeneratedColumn = mapping.generatedColumn;

@@ -130,3 +139,5 @@ addMappingWithCode(lastMapping, code);

node.add(nextLine.substr(0, mapping.generatedColumn));
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
remainingLines[remainingLinesIndex] = nextLine.substr(
mapping.generatedColumn
);
lastGeneratedColumn = mapping.generatedColumn;

@@ -147,3 +158,3 @@ }

// Copy sourcesContent into SourceNode
aSourceMapConsumer.sources.forEach(function(sourceFile) {
aSourceMapConsumer.sources.forEach(function (sourceFile) {
const content = aSourceMapConsumer.sourceContentFor(sourceFile);

@@ -167,7 +178,11 @@ if (content != null) {

: 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
)
);
}

@@ -185,3 +200,3 @@ }

if (Array.isArray(aChunk)) {
aChunk.forEach(function(chunk) {
aChunk.forEach(function (chunk) {
this.add(chunk);

@@ -195,3 +210,4 @@ }, this);

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
);

@@ -217,3 +233,4 @@ }

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
);

@@ -238,6 +255,8 @@ }

} 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,
});
}

@@ -281,3 +300,6 @@ }

} else if (typeof lastChild === "string") {
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
this.children[this.children.length - 1] = lastChild.replace(
aPattern,
aReplacement
);
} else {

@@ -325,3 +347,3 @@ this.children.push("".replace(aPattern, aReplacement));

let str = "";
this.walk(function(chunk) {
this.walk(function (chunk) {
str += chunk;

@@ -340,3 +362,3 @@ });

line: 1,
column: 0
column: 0,
};

@@ -349,11 +371,15 @@ const map = new SourceMapGenerator(aArgs);

let lastOriginalName = null;
this.walk(function(chunk, original) {
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) {
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({

@@ -363,9 +389,9 @@ source: original.source,

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,
});

@@ -382,4 +408,4 @@ }

line: generated.line,
column: generated.column
}
column: generated.column,
},
});

@@ -402,9 +428,9 @@ lastOriginalSource = null;

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,
});

@@ -417,3 +443,3 @@ }

});
this.walkSourceContents(function(sourceFile, sourceContent) {
this.walkSourceContents(function (sourceFile, sourceContent) {
map.setSourceContent(sourceFile, sourceContent);

@@ -420,0 +446,0 @@ });

@@ -26,11 +26,10 @@ /* -*- Mode: js; js-indent-level: 2; -*- */

}
throw new Error('"' + aName + '" is a required argument.');
throw new Error('"' + aName + '" is a required argument.');
}
exports.getArg = getArg;
const supportsNullProto = (function() {
const supportsNullProto = (function () {
const obj = Object.create(null);
return !("__proto__" in obj);
}());
})();

@@ -80,11 +79,13 @@ function identity(s) {

/* eslint-disable no-multi-spaces */
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;

@@ -155,3 +156,4 @@ }

}
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
exports.compareByGeneratedPositionsInflated =
compareByGeneratedPositionsInflated;

@@ -209,3 +211,3 @@ /**

do {
const ident = prefix + (id++);
const ident = prefix + id++;
if (str.indexOf(ident) === -1) return ident;

@@ -344,3 +346,5 @@ } while (true);

if (rootType === "scheme-relative") {
return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(PROTOCOL.length);
return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(
PROTOCOL.length
);
}

@@ -352,3 +356,5 @@

if (rootType === "path-absolute") {
return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(PROTOCOL_AND_HOST.length);
return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(
PROTOCOL_AND_HOST.length
);
}

@@ -355,0 +361,0 @@

@@ -25,3 +25,4 @@ const readWasm = require("../lib/read-wasm");

cachedWasm = readWasm().then(buffer => {
cachedWasm = readWasm()
.then(buffer => {
return WebAssembly.instantiate(buffer, {

@@ -68,42 +69,72 @@ env: {

start_all_generated_locations_for() { console.time("all_generated_locations_for"); },
end_all_generated_locations_for() { console.timeEnd("all_generated_locations_for"); },
start_all_generated_locations_for() {
console.time("all_generated_locations_for");
},
end_all_generated_locations_for() {
console.timeEnd("all_generated_locations_for");
},
start_compute_column_spans() { console.time("compute_column_spans"); },
end_compute_column_spans() { console.timeEnd("compute_column_spans"); },
start_compute_column_spans() {
console.time("compute_column_spans");
},
end_compute_column_spans() {
console.timeEnd("compute_column_spans");
},
start_generated_location_for() { console.time("generated_location_for"); },
end_generated_location_for() { console.timeEnd("generated_location_for"); },
start_generated_location_for() {
console.time("generated_location_for");
},
end_generated_location_for() {
console.timeEnd("generated_location_for");
},
start_original_location_for() { console.time("original_location_for"); },
end_original_location_for() { console.timeEnd("original_location_for"); },
start_original_location_for() {
console.time("original_location_for");
},
end_original_location_for() {
console.timeEnd("original_location_for");
},
start_parse_mappings() { console.time("parse_mappings"); },
end_parse_mappings() { console.timeEnd("parse_mappings"); },
start_parse_mappings() {
console.time("parse_mappings");
},
end_parse_mappings() {
console.timeEnd("parse_mappings");
},
start_sort_by_generated_location() { console.time("sort_by_generated_location"); },
end_sort_by_generated_location() { console.timeEnd("sort_by_generated_location"); },
start_sort_by_generated_location() {
console.time("sort_by_generated_location");
},
end_sort_by_generated_location() {
console.timeEnd("sort_by_generated_location");
},
start_sort_by_original_location() { console.time("sort_by_original_location"); },
end_sort_by_original_location() { console.timeEnd("sort_by_original_location"); },
}
start_sort_by_original_location() {
console.time("sort_by_original_location");
},
end_sort_by_original_location() {
console.timeEnd("sort_by_original_location");
},
},
});
}).then(Wasm => {
return {
exports: Wasm.instance.exports,
withMappingCallback: (mappingCallback, f) => {
callbackStack.push(mappingCallback);
try {
f();
} finally {
callbackStack.pop();
}
}
};
}).then(null, e => {
cachedWasm = null;
throw e;
});
})
.then(Wasm => {
return {
exports: Wasm.instance.exports,
withMappingCallback: (mappingCallback, f) => {
callbackStack.push(mappingCallback);
try {
f();
} finally {
callbackStack.pop();
}
},
};
})
.then(null, e => {
cachedWasm = null;
throw e;
});
return cachedWasm;
};
{
"name": "source-map",
"description": "Generates and consumes source maps",
"version": "0.8.0-beta.0",
"version": "0.8.0",
"homepage": "https://github.com/mozilla/source-map",

@@ -47,3 +47,3 @@ "author": "Nick Fitzgerald <nfitzgerald@mozilla.com>",

"type": "git",
"url": "http://github.com/mozilla/source-map.git"
"url": "git+ssh://git@github.com/mozilla/source-map.git"
},

@@ -53,3 +53,2 @@ "main": "./source-map.js",

"browser": {
"./lib/url.js": "./lib/url-browser.js",
"./lib/read-wasm.js": "./lib/read-wasm-browser.js"

@@ -62,37 +61,22 @@ },

],
"publishConfig": {
"tag": "next"
},
"engines": {
"node": ">= 8"
"node": ">= 12"
},
"license": "BSD-3-Clause",
"scripts": {
"lint": "eslint *.js lib/ test/",
"prebuild": "npm run lint",
"test": "node test/run-tests.js",
"coverage": "nyc node test/run-tests.js",
"setup": "mkdir -p coverage && cp -n .waiting.html coverage/index.html || true",
"dev:live": "live-server --port=4103 --ignorePattern='(js|css|png)$' coverage",
"dev:watch": "watch 'npm run coverage' lib/ test/",
"predev": "npm run setup",
"dev": "npm-run-all -p --silent dev:*",
"clean": "rm -rf coverage .nyc_output",
"toc": "doctoc --title '## Table of Contents' README.md && doctoc --title '## Table of Contents' CONTRIBUTING.md"
"lint": "eslint --fix *.js lib/ test/ --ignore-pattern 'test/source-map-tests/**'",
"test": "git submodule update --init --recursive; node test/run-tests.js",
"coverage": "c8 --reporter=text --reporter=html npm test",
"prettier": "prettier --write .",
"clean": "rm -rf coverage",
"toc": "doctoc --github --notitle README.md CONTRIBUTING.md"
},
"devDependencies": {
"doctoc": "^1.3.1",
"eslint": "^4.19.1",
"live-server": "^1.2.0",
"npm-run-all": "^4.1.2",
"nyc": "^11.7.1",
"watch": "^1.0.2"
"c8": "^7.12.0",
"doctoc": "^2.2.1",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"prettier": "^2.7.1"
},
"nyc": {
"reporter": "html"
},
"typings": "source-map",
"dependencies": {
"whatwg-url": "^7.0.0"
}
"dependencies": {}
}
+174
-159
# Source Map
[![Build Status](https://travis-ci.org/mozilla/source-map.png?branch=master)](https://travis-ci.org/mozilla/source-map)
[![Coverage Status](https://coveralls.io/repos/github/mozilla/source-map/badge.svg)](https://coveralls.io/github/mozilla/source-map)
[![NPM](https://nodei.co/npm/source-map.png?downloads=true&downloadRank=true)](https://www.npmjs.com/package/source-map)

@@ -20,16 +16,17 @@

<script src="https://unpkg.com/source-map@0.7.3/dist/source-map.js"></script>
<script>
sourceMap.SourceMapConsumer.initialize({
"lib/mappings.wasm": "https://unpkg.com/source-map@0.7.3/lib/mappings.wasm"
});
</script>
```html
<script src="https://unpkg.com/source-map@0.7.3/dist/source-map.js"></script>
<script>
sourceMap.SourceMapConsumer.initialize({
"lib/mappings.wasm": "https://unpkg.com/source-map@0.7.3/lib/mappings.wasm",
});
</script>
```
--------------------------------------------------------------------------------
---
<!-- `npm run toc` to regenerate the Table of Contents -->
## Table of Contents
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents

@@ -83,11 +80,11 @@ - [Examples](#examples)

version: 3,
file: 'min.js',
names: ['bar', 'baz', 'n'],
sources: ['one.js', 'two.js'],
sourceRoot: 'http://example.com/www/js/',
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
file: "min.js",
names: ["bar", "baz", "n"],
sources: ["one.js", "two.js"],
sourceRoot: "http://example.com/www/js/",
mappings:
"CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA",
};
const whatever = await SourceMapConsumer.with(rawSourceMap, null, consumer => {
console.log(consumer.sources);

@@ -97,6 +94,8 @@ // [ 'http://example.com/www/js/one.js',

console.log(consumer.originalPositionFor({
line: 2,
column: 28
}));
console.log(
consumer.originalPositionFor({
line: 2,
column: 28,
})
);
// { source: 'http://example.com/www/js/two.js',

@@ -107,7 +106,9 @@ // line: 2,

console.log(consumer.generatedPositionFor({
source: 'http://example.com/www/js/two.js',
line: 2,
column: 10
}));
console.log(
consumer.generatedPositionFor({
source: "http://example.com/www/js/two.js",
line: 2,
column: 10,
})
);
// { line: 2, column: 28 }

@@ -133,19 +134,19 @@

switch (ast.type) {
case 'BinaryExpression':
return new SourceNode(
ast.location.line,
ast.location.column,
ast.location.source,
[compile(ast.left), " + ", compile(ast.right)]
);
case 'Literal':
return new SourceNode(
ast.location.line,
ast.location.column,
ast.location.source,
String(ast.value)
);
// ...
default:
throw new Error("Bad AST");
case "BinaryExpression":
return new SourceNode(
ast.location.line,
ast.location.column,
ast.location.source,
[compile(ast.left), " + ", compile(ast.right)]
);
case "Literal":
return new SourceNode(
ast.location.line,
ast.location.column,
ast.location.source,
String(ast.value)
);
// ...
default:
throw new Error("Bad AST");
}

@@ -155,5 +156,7 @@ }

var ast = parse("40 + 2", "add.js");
console.log(compile(ast).toStringWithSourceMap({
file: 'add.js'
}));
console.log(
compile(ast).toStringWithSourceMap({
file: "add.js",
})
);
// { code: '40 + 2',

@@ -167,3 +170,3 @@ // map: [object SourceMapGenerator] }

var map = new SourceMapGenerator({
file: "source-mapped.js"
file: "source-mapped.js",
});

@@ -174,3 +177,3 @@

line: 10,
column: 35
column: 35,
},

@@ -180,5 +183,5 @@ source: "foo.js",

line: 33,
column: 2
column: 2,
},
name: "christopher"
name: "christopher",
});

@@ -196,3 +199,3 @@

// Node.js
var sourceMap = require('source-map');
var sourceMap = require("source-map");

@@ -220,3 +223,3 @@ // Browser builds

* `"lib/mappings.wasm"`: A `String` containing the URL of the
- `"lib/mappings.wasm"`: A `String` containing the URL of the
`lib/mappings.wasm` file, or an `ArrayBuffer` with the contents of `lib/mappings.wasm`.

@@ -226,3 +229,3 @@

sourceMap.SourceMapConsumer.initialize({
"lib/mappings.wasm": "https://example.com/source-map/lib/mappings.wasm"
"lib/mappings.wasm": "https://example.com/source-map/lib/mappings.wasm",
});

@@ -237,17 +240,21 @@ ```

* `version`: Which version of the source map spec this map is following.
- `version`: Which version of the source map spec this map is following.
* `sources`: An array of URLs to the original source files.
- `sources`: An array of URLs to the original source files.
* `names`: An array of identifiers which can be referenced by individual
- `names`: An array of identifiers which can be referenced by individual
mappings.
* `sourceRoot`: Optional. The URL root from which all sources are relative.
- `sourceRoot`: Optional. The URL root from which all sources are relative.
* `sourcesContent`: Optional. An array of contents of the original source files.
- `sourcesContent`: Optional. An array of contents of the original source files.
* `mappings`: A string of base64 VLQs which contain the actual mappings.
- `mappings`: A string of base64 VLQs which contain the actual mappings.
* `file`: Optional. The generated filename this source map is associated with.
- `file`: Optional. The generated filename this source map is associated with.
- `x_google_ignoreList`: Optional. An additional extension field which is an array
of indices refering to urls in the sources array. This is used to identify third-party
sources, that the developer might want to avoid when debugging. [Read more](https://developer.chrome.com/articles/x-google-ignore-list/)
The promise of the constructed souce map consumer is returned.

@@ -270,4 +277,3 @@

Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl`
(see the `SourceMapConsumer` constructor for details. Then, invoke the `async
function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait
(see the `SourceMapConsumer` constructor for details. Then, invoke the `async function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait
for `f` to complete, call `destroy` on the consumer, and return `f`'s return

@@ -317,3 +323,3 @@ value.

// Before:
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" });
// [ { line: 2,

@@ -329,3 +335,3 @@ // column: 1 },

// After:
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" });
// [ { line: 2,

@@ -348,3 +354,3 @@ // column: 1,

* `line`: The line number in the generated source. Line numbers in
- `line`: The line number in the generated source. Line numbers in
this library are 1-based (note that the underlying source map

@@ -354,9 +360,9 @@ specification uses 0-based line numbers -- this library handles the

* `column`: The column number in the generated source. Column numbers
- `column`: The column number in the generated source. Column numbers
in this library are 0-based.
* `bias`: Either `SourceMapConsumer.GREATEST_LOWER_BOUND` or
- `bias`: Either `SourceMapConsumer.GREATEST_LOWER_BOUND` or
`SourceMapConsumer.LEAST_UPPER_BOUND`. Specifies whether to return the closest
element that is smaller than or greater than the one we are searching for,
respectively, if the exact element cannot be found. Defaults to
respectively, if the exact element cannot be found. Defaults to
`SourceMapConsumer.GREATEST_LOWER_BOUND`.

@@ -366,15 +372,15 @@

* `source`: The original source file, or null if this information is not
- `source`: The original source file, or null if this information is not
available.
* `line`: The line number in the original source, or null if this information is
not available. The line number is 1-based.
- `line`: The line number in the original source, or null if this information is
not available. The line number is 1-based.
* `column`: The column number in the original source, or null if this
information is not available. The column number is 0-based.
- `column`: The column number in the original source, or null if this
information is not available. The column number is 0-based.
* `name`: The original identifier, or null if this information is not available.
- `name`: The original identifier, or null if this information is not available.
```js
consumer.originalPositionFor({ line: 2, column: 10 })
consumer.originalPositionFor({ line: 2, column: 10 });
// { source: 'foo.coffee',

@@ -385,3 +391,6 @@ // line: 2,

consumer.originalPositionFor({ line: 99999999999999999, column: 999999999999999 })
consumer.originalPositionFor({
line: 99999999999999999,
column: 999999999999999,
});
// { source: null,

@@ -399,8 +408,8 @@ // line: null,

* `source`: The filename of the original source.
- `source`: The filename of the original source.
* `line`: The line number in the original source. The line number is
- `line`: The line number in the original source. The line number is
1-based.
* `column`: The column number in the original source. The column
- `column`: The column number in the original source. The column
number is 0-based.

@@ -410,10 +419,10 @@

* `line`: The line number in the generated source, or null. The line
- `line`: The line number in the generated source, or null. The line
number is 1-based.
* `column`: The column number in the generated source, or null. The
- `column`: The column number in the generated source, or null. The
column number is 0-based.
```js
consumer.generatedPositionFor({ source: "example.js", line: 2, column: 10 })
consumer.generatedPositionFor({ source: "example.js", line: 2, column: 10 });
// { line: 1,

@@ -434,8 +443,8 @@ // column: 56 }

* `source`: The filename of the original source.
- `source`: The filename of the original source.
* `line`: The line number in the original source. The line number is
- `line`: The line number in the original source. The line number is
1-based.
* `column`: Optional. The column number in the original source. The
- `column`: Optional. The column number in the original source. The
column number is 0-based.

@@ -445,10 +454,10 @@

* `line`: The line number in the generated source, or null. The line
- `line`: The line number in the generated source, or null. The line
number is 1-based.
* `column`: The column number in the generated source, or null. The
- `column`: The column number in the generated source, or null. The
column number is 0-based.
```js
consumer.allGeneratedpositionsfor({ line: 2, source: "foo.coffee" })
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" });
// [ { line: 2,

@@ -491,6 +500,6 @@ // column: 1 },

```js
consumer.sources
consumer.sources;
// [ "my-cool-lib.clj" ]
consumer.sourceContentFor("my-cool-lib.clj")
consumer.sourceContentFor("my-cool-lib.clj");
// "..."

@@ -510,10 +519,9 @@

* `callback`: The function that is called with each mapping. Mappings have the
form `{ source, generatedLine, generatedColumn, originalLine, originalColumn,
name }`
- `callback`: The function that is called with each mapping. Mappings have the
form `{ source, generatedLine, generatedColumn, originalLine, originalColumn, name }`.
* `context`: Optional. If specified, this object will be the value of `this`
- `context`: Optional. If specified, this object will be the value of `this`
every time that `callback` is called.
* `order`: Either `SourceMapConsumer.GENERATED_ORDER` or
- `order`: Either `SourceMapConsumer.GENERATED_ORDER` or
`SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to iterate over

@@ -525,3 +533,5 @@ the mappings sorted by the generated file's line/column order or the

```js
consumer.eachMapping(function (m) { console.log(m); })
consumer.eachMapping(function (m) {
console.log(m);
});
// ...

@@ -542,2 +552,3 @@ // { source: 'illmatic.js',

```
### SourceMapGenerator

@@ -552,8 +563,8 @@

* `file`: The filename of the generated source that this source map is
- `file`: The filename of the generated source that this source map is
associated with.
* `sourceRoot`: A root for all relative URLs in this source map.
- `sourceRoot`: A root for all relative URLs in this source map.
* `skipValidation`: Optional. When `true`, disables validation of mappings as
- `skipValidation`: Optional. When `true`, disables validation of mappings as
they are added. This can improve performance but should be used with

@@ -566,3 +577,3 @@ discretion, as a last resort. Even then, one should avoid using this flag when

file: "my-generated-javascript-file.js",
sourceRoot: "http://example.com/app/js/"
sourceRoot: "http://example.com/app/js/",
});

@@ -575,3 +586,3 @@ ```

* `sourceMapConsumer` The SourceMap.
- `sourceMapConsumer` The SourceMap.

@@ -588,9 +599,9 @@ ```js

* `generated`: An object with the generated line and column positions.
- `generated`: An object with the generated line and column positions.
* `original`: An object with the original line and column positions.
- `original`: An object with the original line and column positions.
* `source`: The original source file (relative to the sourceRoot).
- `source`: The original source file (relative to the sourceRoot).
* `name`: An optional original token name for this mapping.
- `name`: An optional original token name for this mapping.

@@ -601,4 +612,4 @@ ```js

original: { line: 128, column: 0 },
generated: { line: 3, column: 456 }
})
generated: { line: 3, column: 456 },
});
```

@@ -610,9 +621,11 @@

* `sourceFile` the URL of the original source file.
- `sourceFile` the URL of the original source file.
* `sourceContent` the content of the source file.
- `sourceContent` the content of the source file.
```js
generator.setSourceContent("module-one.scm",
fs.readFileSync("path/to/module-one.scm"))
generator.setSourceContent(
"module-one.scm",
fs.readFileSync("path/to/module-one.scm")
);
```

@@ -627,9 +640,9 @@

* `sourceMapConsumer`: The SourceMap to be applied.
- `sourceMapConsumer`: The SourceMap to be applied.
* `sourceFile`: Optional. The filename of the source file.
- `sourceFile`: Optional. The filename of the source file.
If omitted, sourceMapConsumer.file will be used, if it exists.
Otherwise an error will be thrown.
* `sourceMapPath`: Optional. The dirname of the path to the SourceMap
- `sourceMapPath`: Optional. The dirname of the path to the SourceMap
to be applied. If relative, it is relative to the SourceMap.

@@ -650,3 +663,3 @@

```js
generator.toString()
generator.toString();
// '{"version":3,"sources":["module-one.scm"],"names":[],"mappings":"...snip...","file":"my-generated-javascript-file.js","sourceRoot":"http://example.com/app/js/"}'

@@ -665,15 +678,15 @@ ```

* `line`: The original line number associated with this source node, or null if
it isn't associated with an original line. The line number is 1-based.
- `line`: The original line number associated with this source node, or null if
it isn't associated with an original line. The line number is 1-based.
* `column`: The original column number associated with this source node, or null
if it isn't associated with an original column. The column number
- `column`: The original column number associated with this source node, or null
if it isn't associated with an original column. The column number
is 0-based.
* `source`: The original source's filename; null if no filename is provided.
- `source`: The original source's filename; null if no filename is provided.
* `chunk`: Optional. Is immediately passed to `SourceNode.prototype.add`, see
- `chunk`: Optional. Is immediately passed to `SourceNode.prototype.add`, see
below.
* `name`: Optional. The original identifier.
- `name`: Optional. The original identifier.

@@ -692,12 +705,17 @@ ```js

* `code`: The generated code
- `code`: The generated code.
* `sourceMapConsumer` The SourceMap for the generated code
- `sourceMapConsumer` The SourceMap for the generated code.
* `relativePath` The optional path that relative sources in `sourceMapConsumer`
- `relativePath` The optional path that relative sources in `sourceMapConsumer`
should be relative to.
```js
const consumer = await new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map", "utf8"));
const node = SourceNode.fromStringWithSourceMap(fs.readFileSync("path/to/my-file.js"), consumer);
const consumer = await new SourceMapConsumer(
fs.readFileSync("path/to/my-file.js.map", "utf8")
);
const node = SourceNode.fromStringWithSourceMap(
fs.readFileSync("path/to/my-file.js"),
consumer
);
```

@@ -709,4 +727,4 @@

* `chunk`: A string snippet of generated JS code, another instance of
`SourceNode`, or an array where each member is one of those things.
- `chunk`: A string snippet of generated JS code, another instance of
`SourceNode`, or an array where each member is one of those things.

@@ -723,4 +741,4 @@ ```js

* `chunk`: A string snippet of generated JS code, another instance of
`SourceNode`, or an array where each member is one of those things.
- `chunk`: A string snippet of generated JS code, another instance of
`SourceNode`, or an array where each member is one of those things.

@@ -736,9 +754,11 @@ ```js

* `sourceFile`: The filename of the source file
- `sourceFile`: The filename of the source file.
* `sourceContent`: The content of the source file
- `sourceContent`: The content of the source file.
```js
node.setSourceContent("module-one.scm",
fs.readFileSync("path/to/module-one.scm"))
node.setSourceContent(
"module-one.scm",
fs.readFileSync("path/to/module-one.scm")
);
```

@@ -752,3 +772,3 @@

* `fn`: The traversal function.
- `fn`: The traversal function.

@@ -759,9 +779,8 @@ ```js

"dos",
[
"tres",
new SourceNode(5, 6, "c.js", "quatro")
]
["tres", new SourceNode(5, 6, "c.js", "quatro")],
]);
node.walk(function (code, loc) { console.log("WALK:", code, loc); })
node.walk(function (code, loc) {
console.log("WALK:", code, loc);
});
// WALK: uno { source: 'b.js', line: 3, column: 4, name: null }

@@ -778,3 +797,3 @@ // WALK: dos { source: 'a.js', line: 1, column: 2, name: null }

* `fn`: The traversal function.
- `fn`: The traversal function.

@@ -790,3 +809,5 @@ ```js

var node = new SourceNode(null, null, null, [a, b, c]);
node.walkSourceContents(function (source, contents) { console.log("WALK:", source, ":", contents); })
node.walkSourceContents(function (source, contents) {
console.log("WALK:", source, ":", contents);
});
// WALK: a.js : original a

@@ -802,3 +823,3 @@ // WALK: b.js : original b

* `sep`: The separator.
- `sep`: The separator.

@@ -810,3 +831,3 @@ ```js

var node = new SourceNode(null, null, null, [ lhs, operand, rhs ]);
var node = new SourceNode(null, null, null, [lhs, operand, rhs]);
var joinedNode = node.join(" ");

@@ -820,5 +841,5 @@ ```

* `pattern`: The pattern to replace.
- `pattern`: The pattern to replace.
* `replacement`: The thing to replace the pattern with.
- `replacement`: The thing to replace the pattern with.

@@ -839,9 +860,6 @@ ```js

"dos",
[
"tres",
new SourceNode(5, 6, "c.js", "quatro")
]
["tres", new SourceNode(5, 6, "c.js", "quatro")],
]);
node.toString()
node.toString();
// 'unodostresquatro'

@@ -862,11 +880,8 @@ ```

"dos",
[
"tres",
new SourceNode(5, 6, "c.js", "quatro")
]
["tres", new SourceNode(5, 6, "c.js", "quatro")],
]);
node.toStringWithSourceMap({ file: "my-output-file.js" })
node.toStringWithSourceMap({ file: "my-output-file.js" });
// { code: 'unodostresquatro',
// map: [object SourceMapGenerator] }
```

@@ -10,232 +10,280 @@ // Type definitions for source-map 0.7

export interface StartOfSourceMap {
file?: string;
sourceRoot?: string;
skipValidation?: boolean;
file?: string;
sourceRoot?: string;
skipValidation?: boolean;
}
export interface RawSourceMap {
version: number;
sources: string[];
names: string[];
sourceRoot?: string;
sourcesContent?: string[];
mappings: string;
file: string;
version: number;
sources: string[];
names: string[];
sourceRoot?: string;
sourcesContent?: string[];
mappings: string;
file: string;
}
export interface RawIndexMap extends StartOfSourceMap {
version: number;
sections: RawSection[];
version: number;
sections: RawSection[];
}
export interface RawSection {
offset: Position;
map: RawSourceMap;
offset: Position;
map: RawSourceMap;
}
export interface Position {
line: number;
column: number;
line: number;
column: number;
}
export interface NullablePosition {
line: number | null;
column: number | null;
lastColumn: number | null;
line: number | null;
column: number | null;
lastColumn: number | null;
}
export interface MappedPosition {
source: string;
line: number;
column: number;
name?: string;
source: string;
line: number;
column: number;
name?: string;
}
export interface NullableMappedPosition {
source: string | null;
line: number | null;
column: number | null;
name: string | null;
source: string | null;
line: number | null;
column: number | null;
name: string | null;
}
export interface MappingItem {
source: string;
generatedLine: number;
generatedColumn: number;
originalLine: number;
originalColumn: number;
name: string;
source: string;
generatedLine: number;
generatedColumn: number;
lastGeneratedColumn: number | null;
originalLine: number;
originalColumn: number;
name: string;
}
export interface Mapping {
generated: Position;
original: Position;
source: string;
name?: string;
generated: Position;
original: Position;
source: string;
name?: string;
}
export interface CodeWithSourceMap {
code: string;
map: SourceMapGenerator;
code: string;
map: SourceMapGenerator;
}
export interface SourceMappings {
"lib/mappings.wasm": SourceMapUrl | ArrayBuffer;
}
export interface SourceMapConsumer {
/**
* Compute the last column for each generated mapping. The last column is
* inclusive.
*/
computeColumnSpans(): void;
/**
* Compute the last column for each generated mapping. The last column is
* inclusive.
*/
computeColumnSpans(): void;
/**
* Returns the original source, line, and column information for the generated
* source's line and column positions provided. The only argument is an object
* with the following properties:
*
* - line: The line number in the generated source.
* - column: The column number in the generated source.
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
* closest element that is smaller than or greater than the one we are
* searching for, respectively, if the exact element cannot be found.
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
*
* and an object is returned with the following properties:
*
* - source: The original source file, or null.
* - line: The line number in the original source, or null.
* - column: The column number in the original source, or null.
* - name: The original identifier, or null.
*/
originalPositionFor(generatedPosition: Position & { bias?: number }): NullableMappedPosition;
/**
* Returns the original source, line, and column information for the generated
* source's line and column positions provided. The only argument is an object
* with the following properties:
*
* - line: The line number in the generated source.
* - column: The column number in the generated source.
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
* closest element that is smaller than or greater than the one we are
* searching for, respectively, if the exact element cannot be found.
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
*
* and an object is returned with the following properties:
*
* - source: The original source file, or null.
* - line: The line number in the original source, or null.
* - column: The column number in the original source, or null.
* - name: The original identifier, or null.
*/
originalPositionFor(
generatedPosition: Position & { bias?: number }
): NullableMappedPosition;
/**
* Returns the generated line and column information for the original source,
* line, and column positions provided. The only argument is an object with
* the following properties:
*
* - source: The filename of the original source.
* - line: The line number in the original source.
* - column: The column number in the original source.
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
* closest element that is smaller than or greater than the one we are
* searching for, respectively, if the exact element cannot be found.
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
*
* and an object is returned with the following properties:
*
* - line: The line number in the generated source, or null.
* - column: The column number in the generated source, or null.
*/
generatedPositionFor(originalPosition: MappedPosition & { bias?: number }): NullablePosition;
/**
* Returns the generated line and column information for the original source,
* line, and column positions provided. The only argument is an object with
* the following properties:
*
* - source: The filename of the original source.
* - line: The line number in the original source.
* - column: The column number in the original source.
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
* closest element that is smaller than or greater than the one we are
* searching for, respectively, if the exact element cannot be found.
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
*
* and an object is returned with the following properties:
*
* - line: The line number in the generated source, or null.
* - column: The column number in the generated source, or null.
*/
generatedPositionFor(
originalPosition: MappedPosition & { bias?: number }
): NullablePosition;
/**
* Returns all generated line and column information for the original source,
* line, and column provided. If no column is provided, returns all mappings
* corresponding to a either the line we are searching for or the next
* closest line that has any mappings. Otherwise, returns all mappings
* corresponding to the given line and either the column we are searching for
* or the next closest column that has any offsets.
*
* The only argument is an object with the following properties:
*
* - source: The filename of the original source.
* - line: The line number in the original source.
* - column: Optional. the column number in the original source.
*
* and an array of objects is returned, each with the following properties:
*
* - line: The line number in the generated source, or null.
* - column: The column number in the generated source, or null.
*/
allGeneratedPositionsFor(originalPosition: MappedPosition): NullablePosition[];
/**
* Returns all generated line and column information for the original source,
* line, and column provided. If no column is provided, returns all mappings
* corresponding to a either the line we are searching for or the next
* closest line that has any mappings. Otherwise, returns all mappings
* corresponding to the given line and either the column we are searching for
* or the next closest column that has any offsets.
*
* The only argument is an object with the following properties:
*
* - source: The filename of the original source.
* - line: The line number in the original source.
* - column: Optional. the column number in the original source.
*
* and an array of objects is returned, each with the following properties:
*
* - line: The line number in the generated source, or null.
* - column: The column number in the generated source, or null.
*/
allGeneratedPositionsFor(
originalPosition: MappedPosition
): NullablePosition[];
/**
* Return true if we have the source content for every source in the source
* map, false otherwise.
*/
hasContentsOfAllSources(): boolean;
/**
* Return true if we have the source content for every source in the source
* map, false otherwise.
*/
hasContentsOfAllSources(): boolean;
/**
* Returns the original source content. The only argument is the url of the
* original source file. Returns null if no original source content is
* available.
*/
sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null;
/**
* Returns the original source content. The only argument is the url of the
* original source file. Returns null if no original source content is
* available.
*/
sourceContentFor(
source: string,
returnNullOnMissing?: boolean
): string | null;
/**
* Iterate over each mapping between an original source/line/column and a
* generated line/column in this source map.
*
* @param callback
* The function that is called with each mapping.
* @param context
* Optional. If specified, this object will be the value of `this` every
* time that `aCallback` is called.
* @param order
* Either `SourceMapConsumer.GENERATED_ORDER` or
* `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
* iterate over the mappings sorted by the generated file's line/column
* order or the original's source/line/column order, respectively. Defaults to
* `SourceMapConsumer.GENERATED_ORDER`.
*/
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
/**
* Free this source map consumer's associated wasm data that is manually-managed.
* Alternatively, you can use SourceMapConsumer.with to avoid needing to remember to call destroy.
*/
destroy(): void;
/**
* Iterate over each mapping between an original source/line/column and a
* generated line/column in this source map.
*
* @param callback
* The function that is called with each mapping.
* @param context
* Optional. If specified, this object will be the value of `this` every
* time that `aCallback` is called.
* @param order
* Either `SourceMapConsumer.GENERATED_ORDER` or
* `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
* iterate over the mappings sorted by the generated file's line/column
* order or the original's source/line/column order, respectively. Defaults to
* `SourceMapConsumer.GENERATED_ORDER`.
*/
eachMapping(
callback: (mapping: MappingItem) => void,
context?: any,
order?: number
): void;
/**
* Free this source map consumer's associated wasm data that is manually-managed.
* Alternatively, you can use SourceMapConsumer.with to avoid needing to remember to call destroy.
*/
destroy(): void;
}
export interface SourceMapConsumerConstructor {
prototype: SourceMapConsumer;
prototype: SourceMapConsumer;
GENERATED_ORDER: number;
ORIGINAL_ORDER: number;
GREATEST_LOWER_BOUND: number;
LEAST_UPPER_BOUND: number;
GENERATED_ORDER: number;
ORIGINAL_ORDER: number;
GREATEST_LOWER_BOUND: number;
LEAST_UPPER_BOUND: number;
new (rawSourceMap: RawSourceMap, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>;
new (rawSourceMap: RawIndexMap, sourceMapUrl?: SourceMapUrl): Promise<IndexedSourceMapConsumer>;
new (rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer | IndexedSourceMapConsumer>;
new (
rawSourceMap: RawSourceMap,
sourceMapUrl?: SourceMapUrl
): Promise<BasicSourceMapConsumer>;
new (
rawSourceMap: RawIndexMap,
sourceMapUrl?: SourceMapUrl
): Promise<IndexedSourceMapConsumer>;
new (
rawSourceMap: RawSourceMap | RawIndexMap | string,
sourceMapUrl?: SourceMapUrl
): Promise<BasicSourceMapConsumer | IndexedSourceMapConsumer>;
/**
* Create a BasicSourceMapConsumer from a SourceMapGenerator.
*
* @param sourceMap
* The source map that will be consumed.
*/
fromSourceMap(sourceMap: SourceMapGenerator, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>;
/**
* When using SourceMapConsumer outside of node.js, for example on the Web, it
* needs to know from what URL to load lib/mappings.wasm. You must inform it
* by calling initialize before constructing any SourceMapConsumers.
*
* @param mappings an object with the following property:
* - "lib/mappings.wasm": A String containing the URL of the
* lib/mappings.wasm file, or an ArrayBuffer with the contents of
* lib/mappings.wasm.
*/
initialize(mappings: SourceMappings): void;
/**
* Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl`
* (see the `SourceMapConsumer` constructor for details. Then, invoke the `async
* function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait
* for `f` to complete, call `destroy` on the consumer, and return `f`'s return
* value.
*
* You must not use the consumer after `f` completes!
*
* By using `with`, you do not have to remember to manually call `destroy` on
* the consumer, since it will be called automatically once `f` completes.
*
* ```js
* const xSquared = await SourceMapConsumer.with(
* myRawSourceMap,
* null,
* async function (consumer) {
* // Use `consumer` inside here and don't worry about remembering
* // to call `destroy`.
*
* const x = await whatever(consumer);
* return x * x;
* }
* );
*
* // You may not use that `consumer` anymore out here; it has
* // been destroyed. But you can use `xSquared`.
* console.log(xSquared);
* ```
*/
with<T>(rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl: SourceMapUrl | null | undefined, callback: (consumer: BasicSourceMapConsumer | IndexedSourceMapConsumer) => Promise<T> | T): Promise<T>;
/**
* Create a BasicSourceMapConsumer from a SourceMapGenerator.
*
* @param sourceMap
* The source map that will be consumed.
*/
fromSourceMap(
sourceMap: SourceMapGenerator,
sourceMapUrl?: SourceMapUrl
): Promise<BasicSourceMapConsumer>;
/**
* Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl`
* (see the `SourceMapConsumer` constructor for details. Then, invoke the `async
* function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait
* for `f` to complete, call `destroy` on the consumer, and return `f`'s return
* value.
*
* You must not use the consumer after `f` completes!
*
* By using `with`, you do not have to remember to manually call `destroy` on
* the consumer, since it will be called automatically once `f` completes.
*
* ```js
* const xSquared = await SourceMapConsumer.with(
* myRawSourceMap,
* null,
* async function (consumer) {
* // Use `consumer` inside here and don't worry about remembering
* // to call `destroy`.
*
* const x = await whatever(consumer);
* return x * x;
* }
* );
*
* // You may not use that `consumer` anymore out here; it has
* // been destroyed. But you can use `xSquared`.
* console.log(xSquared);
* ```
*/
with<T>(
rawSourceMap: RawSourceMap | RawIndexMap | string,
sourceMapUrl: SourceMapUrl | null | undefined,
callback: (
consumer: BasicSourceMapConsumer | IndexedSourceMapConsumer
) => Promise<T> | T
): Promise<T>;
}

@@ -246,20 +294,20 @@

export interface BasicSourceMapConsumer extends SourceMapConsumer {
file: string;
sourceRoot: string;
sources: string[];
sourcesContent: string[];
file: string;
sourceRoot: string;
sources: string[];
sourcesContent: string[];
}
export interface BasicSourceMapConsumerConstructor {
prototype: BasicSourceMapConsumer;
prototype: BasicSourceMapConsumer;
new (rawSourceMap: RawSourceMap | string): Promise<BasicSourceMapConsumer>;
new (rawSourceMap: RawSourceMap | string): Promise<BasicSourceMapConsumer>;
/**
* Create a BasicSourceMapConsumer from a SourceMapGenerator.
*
* @param sourceMap
* The source map that will be consumed.
*/
fromSourceMap(sourceMap: SourceMapGenerator): Promise<BasicSourceMapConsumer>;
/**
* Create a BasicSourceMapConsumer from a SourceMapGenerator.
*
* @param sourceMap
* The source map that will be consumed.
*/
fromSourceMap(sourceMap: SourceMapGenerator): Promise<BasicSourceMapConsumer>;
}

@@ -270,9 +318,9 @@

export interface IndexedSourceMapConsumer extends SourceMapConsumer {
sources: string[];
sources: string[];
}
export interface IndexedSourceMapConsumerConstructor {
prototype: IndexedSourceMapConsumer;
prototype: IndexedSourceMapConsumer;
new (rawSourceMap: RawIndexMap | string): Promise<IndexedSourceMapConsumer>;
new (rawSourceMap: RawIndexMap | string): Promise<IndexedSourceMapConsumer>;
}

@@ -283,91 +331,97 @@

export class SourceMapGenerator {
constructor(startOfSourceMap?: StartOfSourceMap);
constructor(startOfSourceMap?: StartOfSourceMap);
/**
* Creates a new SourceMapGenerator based on a SourceMapConsumer
*
* @param sourceMapConsumer The SourceMap.
*/
static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator;
/**
* Creates a new SourceMapGenerator based on a SourceMapConsumer
*
* @param sourceMapConsumer The SourceMap.
*/
static fromSourceMap(
sourceMapConsumer: SourceMapConsumer
): SourceMapGenerator;
/**
* Add a single mapping from original source line and column to the generated
* source's line and column for this source map being created. The mapping
* object should have the following properties:
*
* - generated: An object with the generated line and column positions.
* - original: An object with the original line and column positions.
* - source: The original source file (relative to the sourceRoot).
* - name: An optional original token name for this mapping.
*/
addMapping(mapping: Mapping): void;
/**
* Add a single mapping from original source line and column to the generated
* source's line and column for this source map being created. The mapping
* object should have the following properties:
*
* - generated: An object with the generated line and column positions.
* - original: An object with the original line and column positions.
* - source: The original source file (relative to the sourceRoot).
* - name: An optional original token name for this mapping.
*/
addMapping(mapping: Mapping): void;
/**
* Set the source content for a source file.
*/
setSourceContent(sourceFile: string, sourceContent: string): void;
/**
* Set the source content for a source file.
*/
setSourceContent(sourceFile: string, sourceContent: string): void;
/**
* Applies the mappings of a sub-source-map for a specific source file to the
* source map being generated. Each mapping to the supplied source file is
* rewritten using the supplied source map. Note: The resolution for the
* resulting mappings is the minimium of this map and the supplied map.
*
* @param sourceMapConsumer The source map to be applied.
* @param sourceFile Optional. The filename of the source file.
* If omitted, SourceMapConsumer's file property will be used.
* @param sourceMapPath Optional. The dirname of the path to the source map
* to be applied. If relative, it is relative to the SourceMapConsumer.
* This parameter is needed when the two source maps aren't in the same
* directory, and the source map to be applied contains relative source
* paths. If so, those relative source paths need to be rewritten
* relative to the SourceMapGenerator.
*/
applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void;
/**
* Applies the mappings of a sub-source-map for a specific source file to the
* source map being generated. Each mapping to the supplied source file is
* rewritten using the supplied source map. Note: The resolution for the
* resulting mappings is the minimium of this map and the supplied map.
*
* @param sourceMapConsumer The source map to be applied.
* @param sourceFile Optional. The filename of the source file.
* If omitted, SourceMapConsumer's file property will be used.
* @param sourceMapPath Optional. The dirname of the path to the source map
* to be applied. If relative, it is relative to the SourceMapConsumer.
* This parameter is needed when the two source maps aren't in the same
* directory, and the source map to be applied contains relative source
* paths. If so, those relative source paths need to be rewritten
* relative to the SourceMapGenerator.
*/
applySourceMap(
sourceMapConsumer: SourceMapConsumer,
sourceFile?: string,
sourceMapPath?: string
): void;
toString(): string;
toString(): string;
toJSON(): RawSourceMap;
toJSON(): RawSourceMap;
}
export class SourceNode {
children: SourceNode[];
sourceContents: any;
line: number;
column: number;
source: string;
name: string;
children: SourceNode[];
sourceContents: any;
line: number;
column: number;
source: string;
name: string;
constructor();
constructor(
line: number | null,
column: number | null,
source: string | null,
chunks?: Array<(string | SourceNode)> | SourceNode | string,
name?: string
);
constructor();
constructor(
line: number | null,
column: number | null,
source: string | null,
chunks?: Array<string | SourceNode> | SourceNode | string,
name?: string
);
static fromStringWithSourceMap(
code: string,
sourceMapConsumer: SourceMapConsumer,
relativePath?: string
): SourceNode;
static fromStringWithSourceMap(
code: string,
sourceMapConsumer: SourceMapConsumer,
relativePath?: string
): SourceNode;
add(chunk: Array<(string | SourceNode)> | SourceNode | string): SourceNode;
add(chunk: Array<string | SourceNode> | SourceNode | string): SourceNode;
prepend(chunk: Array<(string | SourceNode)> | SourceNode | string): SourceNode;
prepend(chunk: Array<string | SourceNode> | SourceNode | string): SourceNode;
setSourceContent(sourceFile: string, sourceContent: string): void;
setSourceContent(sourceFile: string, sourceContent: string): void;
walk(fn: (chunk: string, mapping: MappedPosition) => void): void;
walk(fn: (chunk: string, mapping: MappedPosition) => void): void;
walkSourceContents(fn: (file: string, content: string) => void): void;
walkSourceContents(fn: (file: string, content: string) => void): void;
join(sep: string): SourceNode;
join(sep: string): SourceNode;
replaceRight(pattern: string, replacement: string): SourceNode;
replaceRight(pattern: string, replacement: string): SourceNode;
toString(): string;
toString(): string;
toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap;
toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap;
}
/*
* Copyright 2009-2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE.txt or:
* Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause
*/
exports.SourceMapGenerator = require("./lib/source-map-generator").SourceMapGenerator;
exports.SourceMapConsumer = require("./lib/source-map-consumer").SourceMapConsumer;
exports.SourceMapGenerator =
require("./lib/source-map-generator").SourceMapGenerator;
exports.SourceMapConsumer =
require("./lib/source-map-consumer").SourceMapConsumer;
exports.SourceNode = require("./lib/source-node").SourceNode;
# Change Log
## 0.8.0-beta.0
### Breaking changes
* [#350](https://github.com/mozilla/source-map/pull/350) -
Change browser detection logic for WASM loading.
* [#363](https://github.com/mozilla/source-map/pull/363) -
Change WASM loading detection to rely on `package.json#browser` field.
* [#362](https://github.com/mozilla/source-map/pull/362) -
Remove the `dist/` bundle.
* [#371](https://github.com/mozilla/source-map/pull/371) -
Reimplement sourcemap URL processing using the WHATWG URL API.
### Nonbreaking changes:
* [#339](https://github.com/mozilla/source-map/pull/339) -
Allow initializing the consumer `mappings.wasm` file as an `ArrayBuffer`.
### Internal Improvements:
* [#347](https://github.com/mozilla/source-map/pull/347) -
Improve tests.
* [#352](https://github.com/mozilla/source-map/pull/352) -
Improve documentation.
* [#361](https://github.com/mozilla/source-map/pull/361) -
Use newer Webpack CLI when bundling.
* [#364](https://github.com/mozilla/source-map/pull/364) -
Convert `IndexedSourceMapConsumer` implementation to pass more through
to `BasicSourceMapConsumer`.
* [#366](https://github.com/mozilla/source-map/pull/366) -
Normalize internal URL representation to be easier to follow.
* [#341](https://github.com/mozilla/source-map/pull/341) -
Use async functions to simplify `SourceMapConsumer.with` implementation.
## 0.7.3
* Fix a bug where nested uses of `SourceMapConsumer` could result in a
`TypeError`. [#338](https://github.com/mozilla/source-map/issues/338)
[#330](https://github.com/mozilla/source-map/issues/330)
[#319](https://github.com/mozilla/source-map/issues/319)
## 0.7.2
* Another 3x speed up in `SourceMapConsumer`. Read about it here:
http://fitzgeraldnick.com/2018/02/26/speed-without-wizardry.html
## 0.7.1
* Updated TypeScript typings. [#321][]
[#321]: https://github.com/mozilla/source-map/pull/321
## 0.7.0
* `SourceMapConsumer` now uses WebAssembly, and is **much** faster! Read about
it here:
https://hacks.mozilla.org/2018/01/oxidizing-source-maps-with-rust-and-webassembly/
* **Breaking change:** `new SourceMapConsumer` now returns a `Promise` object
that resolves to the newly constructed `SourceMapConsumer` instance, rather
than returning the new instance immediately.
* **Breaking change:** when you're done using a `SourceMapConsumer` instance,
you must call `SourceMapConsumer.prototype.destroy` on it. After calling
`destroy`, you must not use the instance again.
* **Breaking change:** `SourceMapConsumer` used to be able to handle lines,
columns numbers and source and name indices up to `2^53 - 1` (aka
`Number.MAX_SAFE_INTEGER`). It can now only handle them up to `2^32 - 1`.
* **Breaking change:** The `source-map` library now uses modern ECMAScript-isms:
`let`, arrow functions, `async`, etc. Use Babel to compile it down to
ECMAScript 5 if you need to support older JavaScript environments.
* **Breaking change:** Drop support for Node < 8. If you want to support older
versions of node, please use v0.6 or below.
## 0.5.6
* Fix for regression when people were using numbers as names in source maps. See
#236.
## 0.5.5
* Fix "regression" of unsupported, implementation behavior that half the world
happens to have come to depend on. See #235.
* Fix regression involving function hoisting in SpiderMonkey. See #233.
## 0.5.4
* Large performance improvements to source-map serialization. See #228 and #229.
## 0.5.3
* Do not include unnecessary distribution files. See
commit ef7006f8d1647e0a83fdc60f04f5a7ca54886f86.
## 0.5.2
* Include browser distributions of the library in package.json's `files`. See
issue #212.
## 0.5.1
* Fix latent bugs in IndexedSourceMapConsumer.prototype._parseMappings. See
ff05274becc9e6e1295ed60f3ea090d31d843379.
## 0.5.0
* Node 0.8 is no longer supported.
* Use webpack instead of dryice for bundling.
* Big speedups serializing source maps. See pull request #203.
* Fix a bug with `SourceMapConsumer.prototype.sourceContentFor` and sources that
explicitly start with the source root. See issue #199.
## 0.4.4
* Fix an issue where using a `SourceMapGenerator` after having created a
`SourceMapConsumer` from it via `SourceMapConsumer.fromSourceMap` failed. See
issue #191.
* Fix an issue with where `SourceMapGenerator` would mistakenly consider
different mappings as duplicates of each other and avoid generating them. See
issue #192.
## 0.4.3
* A very large number of performance improvements, particularly when parsing
source maps. Collectively about 75% of time shaved off of the source map
parsing benchmark!
* Fix a bug in `SourceMapConsumer.prototype.allGeneratedPositionsFor` and fuzzy
searching in the presence of a column option. See issue #177.
* Fix a bug with joining a source and its source root when the source is above
the root. See issue #182.
* Add the `SourceMapConsumer.prototype.hasContentsOfAllSources` method to
determine when all sources' contents are inlined into the source map. See
issue #190.
## 0.4.2
* Add an `.npmignore` file so that the benchmarks aren't pulled down by
dependent projects. Issue #169.
* Add an optional `column` argument to
`SourceMapConsumer.prototype.allGeneratedPositionsFor` and better handle lines
with no mappings. Issues #172 and #173.
## 0.4.1
* Fix accidentally defining a global variable. #170.
## 0.4.0
* The default direction for fuzzy searching was changed back to its original
direction. See #164.
* There is now a `bias` option you can supply to `SourceMapConsumer` to control
the fuzzy searching direction. See #167.
* About an 8% speed up in parsing source maps. See #159.
* Added a benchmark for parsing and generating source maps.
## 0.3.0
* Change the default direction that searching for positions fuzzes when there is
not an exact match. See #154.
* Support for environments using json2.js for JSON serialization. See #156.
## 0.2.0
* Support for consuming "indexed" source maps which do not have any remote
sections. See pull request #127. This introduces a minor backwards
incompatibility if you are monkey patching `SourceMapConsumer.prototype`
methods.
## 0.1.43
* Performance improvements for `SourceMapGenerator` and `SourceNode`. See issue
#148 for some discussion and issues #150, #151, and #152 for implementations.
## 0.1.42
* Fix an issue where `SourceNode`s from different versions of the source-map
library couldn't be used in conjunction with each other. See issue #142.
## 0.1.41
* Fix a bug with getting the source content of relative sources with a "./"
prefix. See issue #145 and [Bug 1090768](bugzil.la/1090768).
* Add the `SourceMapConsumer.prototype.computeColumnSpans` method to compute the
column span of each mapping.
* Add the `SourceMapConsumer.prototype.allGeneratedPositionsFor` method to find
all generated positions associated with a given original source and line.
## 0.1.40
* Performance improvements for parsing source maps in SourceMapConsumer.
## 0.1.39
* Fix a bug where setting a source's contents to null before any source content
had been set before threw a TypeError. See issue #131.
## 0.1.38
* Fix a bug where finding relative paths from an empty path were creating
absolute paths. See issue #129.
## 0.1.37
* Fix a bug where if the source root was an empty string, relative source paths
would turn into absolute source paths. Issue #124.
## 0.1.36
* Allow the `names` mapping property to be an empty string. Issue #121.
## 0.1.35
* A third optional parameter was added to `SourceNode.fromStringWithSourceMap`
to specify a path that relative sources in the second parameter should be
relative to. Issue #105.
* If no file property is given to a `SourceMapGenerator`, then the resulting
source map will no longer have a `null` file property. The property will
simply not exist. Issue #104.
* Fixed a bug where consecutive newlines were ignored in `SourceNode`s.
Issue #116.
## 0.1.34
* Make `SourceNode` work with windows style ("\r\n") newlines. Issue #103.
* Fix bug involving source contents and the
`SourceMapGenerator.prototype.applySourceMap`. Issue #100.
## 0.1.33
* Fix some edge cases surrounding path joining and URL resolution.
* Add a third parameter for relative path to
`SourceMapGenerator.prototype.applySourceMap`.
* Fix issues with mappings and EOLs.
## 0.1.32
* Fixed a bug where SourceMapConsumer couldn't handle negative relative columns
(issue 92).
* Fixed test runner to actually report number of failed tests as its process
exit code.
* Fixed a typo when reporting bad mappings (issue 87).
## 0.1.31
* Delay parsing the mappings in SourceMapConsumer until queried for a source
location.
* Support Sass source maps (which at the time of writing deviate from the spec
in small ways) in SourceMapConsumer.
## 0.1.30
* Do not join source root with a source, when the source is a data URI.
* Extend the test runner to allow running single specific test files at a time.
* Performance improvements in `SourceNode.prototype.walk` and
`SourceMapConsumer.prototype.eachMapping`.
* Source map browser builds will now work inside Workers.
* Better error messages when attempting to add an invalid mapping to a
`SourceMapGenerator`.
## 0.1.29
* Allow duplicate entries in the `names` and `sources` arrays of source maps
(usually from TypeScript) we are parsing. Fixes github issue 72.
## 0.1.28
* Skip duplicate mappings when creating source maps from SourceNode; github
issue 75.
## 0.1.27
* Don't throw an error when the `file` property is missing in SourceMapConsumer,
we don't use it anyway.
## 0.1.26
* Fix SourceNode.fromStringWithSourceMap for empty maps. Fixes github issue 70.
## 0.1.25
* Make compatible with browserify
## 0.1.24
* Fix issue with absolute paths and `file://` URIs. See
https://bugzilla.mozilla.org/show_bug.cgi?id=885597
## 0.1.23
* Fix issue with absolute paths and sourcesContent, github issue 64.
## 0.1.22
* Ignore duplicate mappings in SourceMapGenerator. Fixes github issue 21.
## 0.1.21
* Fixed handling of sources that start with a slash so that they are relative to
the source root's host.
## 0.1.20
* Fixed github issue #43: absolute URLs aren't joined with the source root
anymore.
## 0.1.19
* Using Travis CI to run tests.
## 0.1.18
* Fixed a bug in the handling of sourceRoot.
## 0.1.17
* Added SourceNode.fromStringWithSourceMap.
## 0.1.16
* Added missing documentation.
* Fixed the generating of empty mappings in SourceNode.
## 0.1.15
* Added SourceMapGenerator.applySourceMap.
## 0.1.14
* The sourceRoot is now handled consistently.
## 0.1.13
* Added SourceMapGenerator.fromSourceMap.
## 0.1.12
* SourceNode now generates empty mappings too.
## 0.1.11
* Added name support to SourceNode.
## 0.1.10
* Added sourcesContent support to the customer and generator.
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause
*/
"use strict";
/**
* Browser 'URL' implementations have been found to handle non-standard URL
* schemes poorly, and schemes like
*
* webpack:///src/folder/file.js
*
* are very common in source maps. For the time being we use a JS
* implementation in these contexts instead. See
*
* * https://bugzilla.mozilla.org/show_bug.cgi?id=1374505
* * https://bugs.chromium.org/p/chromium/issues/detail?id=734880
*/
module.exports = require("whatwg-url").URL;

Sorry, the diff of this file is not supported yet