@jridgewell/trace-mapping
Advanced tools
Comparing version 0.3.23 to 0.3.24
@@ -197,4 +197,5 @@ (function (global, factory) { | ||
const parsed = typeof map === 'string' ? JSON.parse(map) : map; | ||
if (!('sections' in parsed)) | ||
if (!('sections' in parsed)) { | ||
return new TraceMap(parsed, mapUrl); | ||
} | ||
const mappings = []; | ||
@@ -204,3 +205,4 @@ const sources = []; | ||
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 = { | ||
@@ -213,6 +215,7 @@ version: 3, | ||
mappings, | ||
ignoreList, | ||
}; | ||
return presortedDecodedMap(joined); | ||
}; | ||
function recurse(input, mapUrl, mappings, sources, sourcesContent, names, lineOffset, columnOffset, stopLine, stopColumn) { | ||
function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { | ||
const { sections } = input; | ||
@@ -233,6 +236,6 @@ for (let i = 0; i < sections.length; i++) { | ||
} | ||
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) { | ||
function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { | ||
if ('sections' in input) | ||
@@ -244,3 +247,3 @@ return recurse(...arguments); | ||
const decoded = decodedMappings(map); | ||
const { resolvedSources, sourcesContent: contents } = map; | ||
const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map; | ||
append(sources, resolvedSources); | ||
@@ -253,2 +256,5 @@ append(names, map.names); | ||
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++) { | ||
@@ -316,2 +322,3 @@ const lineI = lineOffset + i; | ||
this.sourcesContent = sourcesContent; | ||
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined; | ||
const from = resolve(sourceRoot || '', stripFilename(mapUrl)); | ||
@@ -445,2 +452,9 @@ this.resolvedSources = sources.map((s) => resolve(s || '', from)); | ||
} | ||
function sourceIndex(map, source) { | ||
const { sources, resolvedSources } = map; | ||
let index = sources.indexOf(source); | ||
if (index === -1) | ||
index = resolvedSources.indexOf(source); | ||
return index; | ||
} | ||
/** | ||
@@ -450,11 +464,19 @@ * Retrieves the source content for a particular source, if its found. Returns null if not. | ||
function sourceContentFor(map, source) { | ||
const { sources, resolvedSources, sourcesContent } = map; | ||
const { sourcesContent } = map; | ||
if (sourcesContent == null) | ||
return null; | ||
let index = sources.indexOf(source); | ||
if (index === -1) | ||
index = resolvedSources.indexOf(source); | ||
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 | ||
@@ -491,2 +513,3 @@ * maps. | ||
mappings, | ||
ignoreList: map.ignoreList || map.x_google_ignoreList, | ||
}; | ||
@@ -576,2 +599,3 @@ } | ||
exports.generatedPositionFor = generatedPositionFor; | ||
exports.isIgnored = isIgnored; | ||
exports.originalPositionFor = originalPositionFor; | ||
@@ -578,0 +602,0 @@ exports.presortedDecodedMap = presortedDecodedMap; |
@@ -15,2 +15,3 @@ import type { SourceMapSegment } from './sourcemap-segment'; | ||
sourcesContent: SourceMapV3['sourcesContent']; | ||
ignoreList: SourceMapV3['ignoreList']; | ||
resolvedSources: string[]; | ||
@@ -60,2 +61,6 @@ private _encoded; | ||
/** | ||
* Determines if the source is marked to ignore by the source map. | ||
*/ | ||
export declare function isIgnored(map: TraceMap, source: string): boolean; | ||
/** | ||
* A helper that skips sorting of the input map's mappings array, which can be expensive for larger | ||
@@ -62,0 +67,0 @@ * maps. |
@@ -10,2 +10,3 @@ import type { SourceMapSegment } from './sourcemap-segment'; | ||
version: 3; | ||
ignoreList?: number[]; | ||
} | ||
@@ -51,4 +52,15 @@ export interface EncodedSourceMap extends SourceMapV3 { | ||
export type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND; | ||
export type SourceMapInput = string | Ro<EncodedSourceMap> | Ro<DecodedSourceMap> | TraceMap; | ||
export type SectionedSourceMapInput = SourceMapInput | Ro<SectionedSourceMap>; | ||
export type XInput = { | ||
x_google_ignoreList?: SourceMapV3['ignoreList']; | ||
}; | ||
export type EncodedSourceMapXInput = EncodedSourceMap & XInput; | ||
export type DecodedSourceMapXInput = DecodedSourceMap & XInput; | ||
export type SectionedSourceMapXInput = Omit<SectionedSourceMap, 'sections'> & { | ||
sections: SectionXInput[]; | ||
}; | ||
export type SectionXInput = Omit<Section, 'map'> & { | ||
map: EncodedSourceMapXInput | DecodedSourceMapXInput | SectionedSourceMapXInput; | ||
}; | ||
export type SourceMapInput = string | Ro<EncodedSourceMapXInput> | Ro<DecodedSourceMapXInput> | TraceMap; | ||
export type SectionedSourceMapInput = SourceMapInput | Ro<SectionedSourceMapXInput>; | ||
export type Needle = { | ||
@@ -88,2 +100,3 @@ line: number; | ||
resolvedSources: SourceMapV3['sources']; | ||
ignoreList: SourceMapV3['ignoreList']; | ||
} | ||
@@ -90,0 +103,0 @@ export type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T; |
{ | ||
"name": "@jridgewell/trace-mapping", | ||
"version": "0.3.23", | ||
"version": "0.3.24", | ||
"description": "Trace the original position through a source map", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
168713
1408