summaryrefslogtreecommitdiff
path: root/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js')
-rw-r--r--node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js390
1 files changed, 215 insertions, 175 deletions
diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js
index c373bc39..3be0f36e 100644
--- a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js
+++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js
@@ -170,8 +170,9 @@
// segment should go. Either way, we want to insert after that. And there may be multiple
// generated segments associated with an original location, so there may need to move several
// indexes before we find where we need to insert.
- const index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine));
- insert(originalLine, (memo.lastIndex = index + 1), [sourceColumn, i, seg[COLUMN]]);
+ let index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine));
+ memo.lastIndex = ++index;
+ insert(originalLine, index, [sourceColumn, i, seg[COLUMN]]);
}
}
return sources;
@@ -192,14 +193,16 @@
}
const AnyMap = function (map, mapUrl) {
- const parsed = typeof map === 'string' ? JSON.parse(map) : map;
- if (!('sections' in parsed))
+ const parsed = parse(map);
+ if (!('sections' in parsed)) {
return new TraceMap(parsed, mapUrl);
+ }
const mappings = [];
const sources = [];
const sourcesContent = [];
const names = [];
- recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, 0, 0, Infinity, Infinity);
+ const ignoreList = [];
+ recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, ignoreList, 0, 0, Infinity, Infinity);
const joined = {
version: 3,
file: parsed.file,
@@ -207,10 +210,14 @@
sources,
sourcesContent,
mappings,
+ ignoreList,
};
- return exports.presortedDecodedMap(joined);
+ return presortedDecodedMap(joined);
};
- function recurse(input, mapUrl, mappings, sources, sourcesContent, names, lineOffset, columnOffset, stopLine, stopColumn) {
+ function parse(map) {
+ return typeof map === 'string' ? JSON.parse(map) : map;
+ }
+ function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
const { sections } = input;
for (let i = 0; i < sections.length; i++) {
const { map, offset } = sections[i];
@@ -226,17 +233,18 @@
sc = columnOffset + nextOffset.column;
}
}
- addSection(map, mapUrl, mappings, sources, sourcesContent, names, lineOffset + offset.line, columnOffset + offset.column, sl, sc);
+ addSection(map, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset + offset.line, columnOffset + offset.column, sl, sc);
}
}
- function addSection(input, mapUrl, mappings, sources, sourcesContent, names, lineOffset, columnOffset, stopLine, stopColumn) {
- if ('sections' in input)
+ function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
+ const parsed = parse(input);
+ if ('sections' in parsed)
return recurse(...arguments);
- const map = new TraceMap(input, mapUrl);
+ const map = new TraceMap(parsed, mapUrl);
const sourcesOffset = sources.length;
const namesOffset = names.length;
- const decoded = exports.decodedMappings(map);
- const { resolvedSources, sourcesContent: contents } = map;
+ const decoded = decodedMappings(map);
+ const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map;
append(sources, resolvedSources);
append(names, map.names);
if (contents)
@@ -244,6 +252,9 @@
else
for (let i = 0; i < resolvedSources.length; i++)
sourcesContent.push(null);
+ if (ignores)
+ for (let i = 0; i < ignores.length; i++)
+ ignoreList.push(ignores[i] + sourcesOffset);
for (let i = 0; i < decoded.length; i++) {
const lineI = lineOffset + i;
// We can only add so many lines before we step into the range that the next section's map
@@ -293,208 +304,198 @@
const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
const LEAST_UPPER_BOUND = -1;
const GREATEST_LOWER_BOUND = 1;
+ class TraceMap {
+ constructor(map, mapUrl) {
+ const isString = typeof map === 'string';
+ if (!isString && map._decodedMemo)
+ return map;
+ const parsed = (isString ? JSON.parse(map) : map);
+ const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
+ this.version = version;
+ this.file = file;
+ this.names = names || [];
+ this.sourceRoot = sourceRoot;
+ this.sources = sources;
+ this.sourcesContent = sourcesContent;
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
+ const from = resolve(sourceRoot || '', stripFilename(mapUrl));
+ this.resolvedSources = sources.map((s) => resolve(s || '', from));
+ const { mappings } = parsed;
+ if (typeof mappings === 'string') {
+ this._encoded = mappings;
+ this._decoded = undefined;
+ }
+ else {
+ this._encoded = undefined;
+ this._decoded = maybeSort(mappings, isString);
+ }
+ this._decodedMemo = memoizedState();
+ this._bySources = undefined;
+ this._bySourceMemos = undefined;
+ }
+ }
+ /**
+ * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
+ * with public access modifiers.
+ */
+ function cast(map) {
+ return map;
+ }
/**
* Returns the encoded (VLQ string) form of the SourceMap's mappings field.
*/
- exports.encodedMappings = void 0;
+ function encodedMappings(map) {
+ var _a;
+ var _b;
+ return ((_a = (_b = cast(map))._encoded) !== null && _a !== void 0 ? _a : (_b._encoded = sourcemapCodec.encode(cast(map)._decoded)));
+ }
/**
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
*/
- exports.decodedMappings = void 0;
+ function decodedMappings(map) {
+ var _a;
+ return ((_a = cast(map))._decoded || (_a._decoded = sourcemapCodec.decode(cast(map)._encoded)));
+ }
/**
* A low-level API to find the segment associated with a generated line/column (think, from a
* stack trace). Line and column here are 0-based, unlike `originalPositionFor`.
*/
- exports.traceSegment = void 0;
+ function traceSegment(map, line, column) {
+ const decoded = decodedMappings(map);
+ // It's common for parent source maps to have pointers to lines that have no
+ // mapping (like a "//# sourceMappingURL=") at the end of the child file.
+ if (line >= decoded.length)
+ return null;
+ const segments = decoded[line];
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
+ return index === -1 ? null : segments[index];
+ }
/**
* A higher-level API to find the source/line/column associated with a generated line/column
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
* `source-map` library.
*/
- exports.originalPositionFor = void 0;
+ function originalPositionFor(map, needle) {
+ let { line, column, bias } = needle;
+ line--;
+ if (line < 0)
+ throw new Error(LINE_GTR_ZERO);
+ if (column < 0)
+ throw new Error(COL_GTR_EQ_ZERO);
+ const decoded = decodedMappings(map);
+ // It's common for parent source maps to have pointers to lines that have no
+ // mapping (like a "//# sourceMappingURL=") at the end of the child file.
+ if (line >= decoded.length)
+ return OMapping(null, null, null, null);
+ const segments = decoded[line];
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
+ if (index === -1)
+ return OMapping(null, null, null, null);
+ const segment = segments[index];
+ if (segment.length === 1)
+ return OMapping(null, null, null, null);
+ const { names, resolvedSources } = map;
+ return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
+ }
/**
* Finds the generated line/column position of the provided source/line/column source position.
*/
- exports.generatedPositionFor = void 0;
+ function generatedPositionFor(map, needle) {
+ const { source, line, column, bias } = needle;
+ return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
+ }
/**
* Finds all generated line/column positions of the provided source/line/column source position.
*/
- exports.allGeneratedPositionsFor = void 0;
+ function allGeneratedPositionsFor(map, needle) {
+ const { source, line, column, bias } = needle;
+ // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit.
+ return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);
+ }
/**
* Iterates each mapping in generated position order.
*/
- exports.eachMapping = void 0;
+ function eachMapping(map, cb) {
+ const decoded = decodedMappings(map);
+ const { names, resolvedSources } = map;
+ for (let i = 0; i < decoded.length; i++) {
+ const line = decoded[i];
+ for (let j = 0; j < line.length; j++) {
+ const seg = line[j];
+ const generatedLine = i + 1;
+ const generatedColumn = seg[0];
+ let source = null;
+ let originalLine = null;
+ let originalColumn = null;
+ let name = null;
+ if (seg.length !== 1) {
+ source = resolvedSources[seg[1]];
+ originalLine = seg[2] + 1;
+ originalColumn = seg[3];
+ }
+ if (seg.length === 5)
+ name = names[seg[4]];
+ cb({
+ generatedLine,
+ generatedColumn,
+ source,
+ originalLine,
+ originalColumn,
+ name,
+ });
+ }
+ }
+ }
+ function sourceIndex(map, source) {
+ const { sources, resolvedSources } = map;
+ let index = sources.indexOf(source);
+ if (index === -1)
+ index = resolvedSources.indexOf(source);
+ return index;
+ }
/**
* Retrieves the source content for a particular source, if its found. Returns null if not.
*/
- exports.sourceContentFor = void 0;
+ function sourceContentFor(map, source) {
+ const { sourcesContent } = map;
+ if (sourcesContent == null)
+ return null;
+ const index = sourceIndex(map, source);
+ return index === -1 ? null : sourcesContent[index];
+ }
+ /**
+ * Determines if the source is marked to ignore by the source map.
+ */
+ function isIgnored(map, source) {
+ const { ignoreList } = map;
+ if (ignoreList == null)
+ return false;
+ const index = sourceIndex(map, source);
+ return index === -1 ? false : ignoreList.includes(index);
+ }
/**
* A helper that skips sorting of the input map's mappings array, which can be expensive for larger
* maps.
*/
- exports.presortedDecodedMap = void 0;
+ function presortedDecodedMap(map, mapUrl) {
+ const tracer = new TraceMap(clone(map, []), mapUrl);
+ cast(tracer)._decoded = map.mappings;
+ return tracer;
+ }
/**
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
* a sourcemap, or to JSON.stringify.
*/
- exports.decodedMap = void 0;
+ function decodedMap(map) {
+ return clone(map, decodedMappings(map));
+ }
/**
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
* a sourcemap, or to JSON.stringify.
*/
- exports.encodedMap = void 0;
- class TraceMap {
- constructor(map, mapUrl) {
- const isString = typeof map === 'string';
- if (!isString && map._decodedMemo)
- return map;
- const parsed = (isString ? JSON.parse(map) : map);
- const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
- this.version = version;
- this.file = file;
- this.names = names || [];
- this.sourceRoot = sourceRoot;
- this.sources = sources;
- this.sourcesContent = sourcesContent;
- const from = resolve(sourceRoot || '', stripFilename(mapUrl));
- this.resolvedSources = sources.map((s) => resolve(s || '', from));
- const { mappings } = parsed;
- if (typeof mappings === 'string') {
- this._encoded = mappings;
- this._decoded = undefined;
- }
- else {
- this._encoded = undefined;
- this._decoded = maybeSort(mappings, isString);
- }
- this._decodedMemo = memoizedState();
- this._bySources = undefined;
- this._bySourceMemos = undefined;
- }
+ function encodedMap(map) {
+ return clone(map, encodedMappings(map));
}
- (() => {
- exports.encodedMappings = (map) => {
- var _a;
- return ((_a = map._encoded) !== null && _a !== void 0 ? _a : (map._encoded = sourcemapCodec.encode(map._decoded)));
- };
- exports.decodedMappings = (map) => {
- return (map._decoded || (map._decoded = sourcemapCodec.decode(map._encoded)));
- };
- exports.traceSegment = (map, line, column) => {
- const decoded = exports.decodedMappings(map);
- // It's common for parent source maps to have pointers to lines that have no
- // mapping (like a "//# sourceMappingURL=") at the end of the child file.
- if (line >= decoded.length)
- return null;
- const segments = decoded[line];
- const index = traceSegmentInternal(segments, map._decodedMemo, line, column, GREATEST_LOWER_BOUND);
- return index === -1 ? null : segments[index];
- };
- exports.originalPositionFor = (map, { line, column, bias }) => {
- line--;
- if (line < 0)
- throw new Error(LINE_GTR_ZERO);
- if (column < 0)
- throw new Error(COL_GTR_EQ_ZERO);
- const decoded = exports.decodedMappings(map);
- // It's common for parent source maps to have pointers to lines that have no
- // mapping (like a "//# sourceMappingURL=") at the end of the child file.
- if (line >= decoded.length)
- return OMapping(null, null, null, null);
- const segments = decoded[line];
- const index = traceSegmentInternal(segments, map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
- if (index === -1)
- return OMapping(null, null, null, null);
- const segment = segments[index];
- if (segment.length === 1)
- return OMapping(null, null, null, null);
- const { names, resolvedSources } = map;
- return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
- };
- exports.allGeneratedPositionsFor = (map, { source, line, column, bias }) => {
- // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit.
- return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);
- };
- exports.generatedPositionFor = (map, { source, line, column, bias }) => {
- return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
- };
- exports.eachMapping = (map, cb) => {
- const decoded = exports.decodedMappings(map);
- const { names, resolvedSources } = map;
- for (let i = 0; i < decoded.length; i++) {
- const line = decoded[i];
- for (let j = 0; j < line.length; j++) {
- const seg = line[j];
- const generatedLine = i + 1;
- const generatedColumn = seg[0];
- let source = null;
- let originalLine = null;
- let originalColumn = null;
- let name = null;
- if (seg.length !== 1) {
- source = resolvedSources[seg[1]];
- originalLine = seg[2] + 1;
- originalColumn = seg[3];
- }
- if (seg.length === 5)
- name = names[seg[4]];
- cb({
- generatedLine,
- generatedColumn,
- source,
- originalLine,
- originalColumn,
- name,
- });
- }
- }
- };
- exports.sourceContentFor = (map, source) => {
- const { sources, resolvedSources, sourcesContent } = map;
- if (sourcesContent == null)
- return null;
- let index = sources.indexOf(source);
- if (index === -1)
- index = resolvedSources.indexOf(source);
- return index === -1 ? null : sourcesContent[index];
- };
- exports.presortedDecodedMap = (map, mapUrl) => {
- const tracer = new TraceMap(clone(map, []), mapUrl);
- tracer._decoded = map.mappings;
- return tracer;
- };
- exports.decodedMap = (map) => {
- return clone(map, exports.decodedMappings(map));
- };
- exports.encodedMap = (map) => {
- return clone(map, exports.encodedMappings(map));
- };
- function generatedPosition(map, source, line, column, bias, all) {
- line--;
- if (line < 0)
- throw new Error(LINE_GTR_ZERO);
- if (column < 0)
- throw new Error(COL_GTR_EQ_ZERO);
- const { sources, resolvedSources } = map;
- let sourceIndex = sources.indexOf(source);
- if (sourceIndex === -1)
- sourceIndex = resolvedSources.indexOf(source);
- if (sourceIndex === -1)
- return all ? [] : GMapping(null, null);
- const generated = (map._bySources || (map._bySources = buildBySources(exports.decodedMappings(map), (map._bySourceMemos = sources.map(memoizedState)))));
- const segments = generated[sourceIndex][line];
- if (segments == null)
- return all ? [] : GMapping(null, null);
- const memo = map._bySourceMemos[sourceIndex];
- if (all)
- return sliceGeneratedPositions(segments, memo, line, column, bias);
- const index = traceSegmentInternal(segments, memo, line, column, bias);
- if (index === -1)
- return GMapping(null, null);
- const segment = segments[index];
- return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
- }
- })();
function clone(map, mappings) {
return {
version: map.version,
@@ -504,6 +505,7 @@
sources: map.sources,
sourcesContent: map.sourcesContent,
mappings,
+ ignoreList: map.ignoreList || map.x_google_ignoreList,
};
}
function OMapping(source, line, column, name) {
@@ -550,11 +552,49 @@
}
return result;
}
+ function generatedPosition(map, source, line, column, bias, all) {
+ var _a;
+ line--;
+ if (line < 0)
+ throw new Error(LINE_GTR_ZERO);
+ if (column < 0)
+ throw new Error(COL_GTR_EQ_ZERO);
+ const { sources, resolvedSources } = map;
+ let sourceIndex = sources.indexOf(source);
+ if (sourceIndex === -1)
+ sourceIndex = resolvedSources.indexOf(source);
+ if (sourceIndex === -1)
+ return all ? [] : GMapping(null, null);
+ const generated = ((_a = cast(map))._bySources || (_a._bySources = buildBySources(decodedMappings(map), (cast(map)._bySourceMemos = sources.map(memoizedState)))));
+ const segments = generated[sourceIndex][line];
+ if (segments == null)
+ return all ? [] : GMapping(null, null);
+ const memo = cast(map)._bySourceMemos[sourceIndex];
+ if (all)
+ return sliceGeneratedPositions(segments, memo, line, column, bias);
+ const index = traceSegmentInternal(segments, memo, line, column, bias);
+ if (index === -1)
+ return GMapping(null, null);
+ const segment = segments[index];
+ return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
+ }
exports.AnyMap = AnyMap;
exports.GREATEST_LOWER_BOUND = GREATEST_LOWER_BOUND;
exports.LEAST_UPPER_BOUND = LEAST_UPPER_BOUND;
exports.TraceMap = TraceMap;
+ exports.allGeneratedPositionsFor = allGeneratedPositionsFor;
+ exports.decodedMap = decodedMap;
+ exports.decodedMappings = decodedMappings;
+ exports.eachMapping = eachMapping;
+ exports.encodedMap = encodedMap;
+ exports.encodedMappings = encodedMappings;
+ exports.generatedPositionFor = generatedPositionFor;
+ exports.isIgnored = isIgnored;
+ exports.originalPositionFor = originalPositionFor;
+ exports.presortedDecodedMap = presortedDecodedMap;
+ exports.sourceContentFor = sourceContentFor;
+ exports.traceSegment = traceSegment;
}));
//# sourceMappingURL=trace-mapping.umd.js.map