* A BasicSourceMapConsumer instance represents a parsed source map which we can * query for information about the original file positions by giving it a file * position in the generated source. * * The first parameter is the raw source map (either as a JSON string, or * already parsed to an obj
| 171 | * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# |
| 172 | */ |
| 173 | class BasicSourceMapConsumer extends SourceMapConsumer { |
| 174 | constructor(aSourceMap, aSourceMapURL) { |
| 175 | return super(INTERNAL).then(that => { |
| 176 | let sourceMap = aSourceMap; |
| 177 | if (typeof aSourceMap === "string") { |
| 178 | sourceMap = util.parseSourceMapInput(aSourceMap); |
| 179 | } |
| 180 | |
| 181 | const version = util.getArg(sourceMap, "version"); |
| 182 | const sources = util.getArg(sourceMap, "sources").map(String); |
| 183 | // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which |
| 184 | // requires the array) to play nice here. |
| 185 | const names = util.getArg(sourceMap, "names", []); |
| 186 | const sourceRoot = util.getArg(sourceMap, "sourceRoot", null); |
| 187 | const sourcesContent = util.getArg(sourceMap, "sourcesContent", null); |
| 188 | const mappings = util.getArg(sourceMap, "mappings"); |
| 189 | const file = util.getArg(sourceMap, "file", null); |
| 190 | const x_google_ignoreList = util.getArg( |
| 191 | sourceMap, |
| 192 | "x_google_ignoreList", |
| 193 | null |
| 194 | ); |
| 195 | |
| 196 | // Once again, Sass deviates from the spec and supplies the version as a |
| 197 | // string rather than a number, so we use loose equality checking here. |
| 198 | if (version != that._version) { |
| 199 | throw new Error("Unsupported version: " + version); |
| 200 | } |
| 201 | |
| 202 | that._sourceLookupCache = new Map(); |
| 203 | |
| 204 | // Pass `true` below to allow duplicate names and sources. While source maps |
| 205 | // are intended to be compressed and deduplicated, the TypeScript compiler |
| 206 | // sometimes generates source maps with duplicates in them. See Github issue |
| 207 | // #72 and bugzil.la/889492. |
| 208 | that._names = ArraySet.fromArray(names.map(String), true); |
| 209 | that._sources = ArraySet.fromArray(sources, true); |
| 210 | |
| 211 | that._absoluteSources = ArraySet.fromArray( |
| 212 | that._sources.toArray().map(function (s) { |
| 213 | return util.computeSourceURL(sourceRoot, s, aSourceMapURL); |
| 214 | }), |
| 215 | true |
| 216 | ); |
| 217 | |
| 218 | that.sourceRoot = sourceRoot; |
| 219 | that.sourcesContent = sourcesContent; |
| 220 | that._mappings = mappings; |
| 221 | that._sourceMapURL = aSourceMapURL; |
| 222 | that.file = file; |
| 223 | that.x_google_ignoreList = x_google_ignoreList; |
| 224 | |
| 225 | that._computedColumnSpans = false; |
| 226 | that._mappingsPtr = 0; |
| 227 | that._wasm = null; |
| 228 | |
| 229 | return wasm().then(w => { |
| 230 | that._wasm = w; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…