source-map
Advanced tools
| "use strict"; | ||
| let mappingsWasm = null; | ||
| module.exports = function readWasm() { | ||
| if (typeof mappingsWasm === "string") { | ||
| return fetch(mappingsWasm).then(response => response.arrayBuffer()); | ||
| } | ||
| if (mappingsWasm instanceof ArrayBuffer) { | ||
| return Promise.resolve(mappingsWasm); | ||
| } | ||
| 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" | ||
| ); | ||
| }; | ||
| module.exports.initialize = input => { | ||
| mappingsWasm = input; | ||
| }; |
+13
| /* -*- 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"; | ||
| // Note: This file is overridden in the 'package.json#browser' field to | ||
| // substitute lib/url-browser.js instead. | ||
| // Use the URL global for Node 10, and the 'url' module for Node 8. | ||
| module.exports = typeof URL === "function" ? URL : require("url").URL; |
+2
-2
@@ -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.'); |
+1
-18
@@ -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 @@ */ |
+3
-2
@@ -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]; |
+10
-4
@@ -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 @@ |
+21
-43
@@ -1,49 +0,27 @@ | ||
| /* Determine browser vs node environment by testing the default top level context. Solution courtesy of: https://stackoverflow.com/questions/17575790/environment-detection-node-js-or-browser */ | ||
| const isBrowserEnvironment = (function() { | ||
| // eslint-disable-next-line no-undef | ||
| return (typeof window !== "undefined") && (this === window); | ||
| }).call(); | ||
| "use strict"; | ||
| if (isBrowserEnvironment) { | ||
| // Web version of reading a wasm file into an array buffer. | ||
| // Note: This file is replaced with "read-wasm-browser.js" when this module is | ||
| // bundled with a packager that takes package.json#browser fields into account. | ||
| let mappingsWasm = null; | ||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
| module.exports = function readWasm() { | ||
| if (typeof mappingsWasm === "string") { | ||
| return fetch(mappingsWasm) | ||
| .then(response => response.arrayBuffer()); | ||
| } | ||
| if (mappingsWasm instanceof ArrayBuffer) { | ||
| return Promise.resolve(mappingsWasm); | ||
| } | ||
| 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"); | ||
| }; | ||
| module.exports = function readWasm() { | ||
| return new Promise((resolve, reject) => { | ||
| const wasmPath = path.join(__dirname, "mappings.wasm"); | ||
| fs.readFile(wasmPath, null, (error, data) => { | ||
| if (error) { | ||
| reject(error); | ||
| return; | ||
| } | ||
| module.exports.initialize = input => mappingsWasm = input; | ||
| } else { | ||
| // Node version of reading a wasm file into an array buffer. | ||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
| module.exports = function readWasm() { | ||
| return new Promise((resolve, reject) => { | ||
| const wasmPath = path.join(__dirname, "mappings.wasm"); | ||
| fs.readFile(wasmPath, null, (error, data) => { | ||
| if (error) { | ||
| reject(error); | ||
| return; | ||
| } | ||
| resolve(data.buffer); | ||
| }); | ||
| resolve(data.buffer); | ||
| }); | ||
| }; | ||
| }); | ||
| }; | ||
| module.exports.initialize = _ => { | ||
| console.debug("SourceMapConsumer.initialize is a no-op when running in node.js"); | ||
| }; | ||
| } | ||
| module.exports.initialize = _ => { | ||
| console.debug( | ||
| "SourceMapConsumer.initialize is a no-op when running in node.js" | ||
| ); | ||
| }; |
+282
-438
@@ -77,11 +77,2 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
| /** | ||
| * Parse the mappings in a string in to a data structure which we can easily | ||
| * query (the ordered arrays in the `this.__generatedMappings` and | ||
| * `this.__originalMappings` properties). | ||
| */ | ||
| _parseMappings(aStr, aSourceRoot) { | ||
| throw new Error("Subclasses must implement _parseMappings"); | ||
| } | ||
| /** | ||
| * Iterate over each mapping between an original source/line/column and a | ||
@@ -192,10 +183,15 @@ * generated line/column in this source map. | ||
| const version = util.getArg(sourceMap, "version"); | ||
| let sources = util.getArg(sourceMap, "sources"); | ||
| const sources = util.getArg(sourceMap, "sources").map(String); | ||
| // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which | ||
| // requires the array) to play nice here. | ||
| const names = util.getArg(sourceMap, "names", []); | ||
| let sourceRoot = util.getArg(sourceMap, "sourceRoot", null); | ||
| const sourceRoot = util.getArg(sourceMap, "sourceRoot", null); | ||
| const sourcesContent = util.getArg(sourceMap, "sourcesContent", null); | ||
| const mappings = util.getArg(sourceMap, "mappings"); | ||
| const file = util.getArg(sourceMap, "file", null); | ||
| const x_google_ignoreList = util.getArg( | ||
| sourceMap, | ||
| "x_google_ignoreList", | ||
| null | ||
| ); | ||
@@ -208,22 +204,4 @@ // Once again, Sass deviates from the spec and supplies the version as a | ||
| if (sourceRoot) { | ||
| sourceRoot = util.normalize(sourceRoot); | ||
| } | ||
| that._sourceLookupCache = new Map(); | ||
| sources = sources | ||
| .map(String) | ||
| // Some source maps produce relative source paths like "./foo.js" instead of | ||
| // "foo.js". Normalize these first so that future comparisons will succeed. | ||
| // See bugzil.la/1090768. | ||
| .map(util.normalize) | ||
| // Always ensure that absolute sources are internally stored relative to | ||
| // the source root, if the source root is absolute. Not doing this would | ||
| // be particularly problematic when the source root is a prefix of the | ||
| // source (valid, but why??). See github issue #199 and bugzil.la/1188982. | ||
| .map(function(source) { | ||
| return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source) | ||
| ? util.relative(sourceRoot, source) | ||
| : source; | ||
| }); | ||
| // Pass `true` below to allow duplicate names and sources. While source maps | ||
@@ -236,5 +214,8 @@ // are intended to be compressed and deduplicated, the TypeScript compiler | ||
| that._absoluteSources = that._sources.toArray().map(function(s) { | ||
| return util.computeSourceURL(sourceRoot, s, aSourceMapURL); | ||
| }); | ||
| that._absoluteSources = ArraySet.fromArray( | ||
| that._sources.toArray().map(function (s) { | ||
| return util.computeSourceURL(sourceRoot, s, aSourceMapURL); | ||
| }), | ||
| true | ||
| ); | ||
@@ -246,2 +227,3 @@ that.sourceRoot = sourceRoot; | ||
| that.file = file; | ||
| that.x_google_ignoreList = x_google_ignoreList; | ||
@@ -264,19 +246,34 @@ that._computedColumnSpans = false; | ||
| _findSourceIndex(aSource) { | ||
| let relativeSource = aSource; | ||
| if (this.sourceRoot != null) { | ||
| relativeSource = util.relative(this.sourceRoot, relativeSource); | ||
| // In the most common usecases, we'll be constantly looking up the index for the same source | ||
| // files, so we cache the index lookup to avoid constantly recomputing the full URLs. | ||
| const cachedIndex = this._sourceLookupCache.get(aSource); | ||
| if (typeof cachedIndex === "number") { | ||
| return cachedIndex; | ||
| } | ||
| if (this._sources.has(relativeSource)) { | ||
| return this._sources.indexOf(relativeSource); | ||
| // Treat the source as map-relative overall by default. | ||
| const sourceAsMapRelative = util.computeSourceURL( | ||
| null, | ||
| aSource, | ||
| this._sourceMapURL | ||
| ); | ||
| if (this._absoluteSources.has(sourceAsMapRelative)) { | ||
| const index = this._absoluteSources.indexOf(sourceAsMapRelative); | ||
| this._sourceLookupCache.set(aSource, index); | ||
| return index; | ||
| } | ||
| // Maybe aSource is an absolute URL as returned by |sources|. In | ||
| // this case we can't simply undo the transform. | ||
| for (let i = 0; i < this._absoluteSources.length; ++i) { | ||
| if (this._absoluteSources[i] == aSource) { | ||
| return i; | ||
| } | ||
| // Fall back to treating the source as sourceRoot-relative. | ||
| const sourceAsSourceRootRelative = util.computeSourceURL( | ||
| this.sourceRoot, | ||
| aSource, | ||
| this._sourceMapURL | ||
| ); | ||
| if (this._absoluteSources.has(sourceAsSourceRootRelative)) { | ||
| const index = this._absoluteSources.indexOf(sourceAsSourceRootRelative); | ||
| this._sourceLookupCache.set(aSource, index); | ||
| return index; | ||
| } | ||
| // To avoid this cache growing forever, we do not cache lookup misses. | ||
| return -1; | ||
@@ -299,3 +296,3 @@ } | ||
| get sources() { | ||
| return this._absoluteSources.slice(); | ||
| return this._absoluteSources.toArray(); | ||
| } | ||
@@ -305,3 +302,3 @@ | ||
| if (this._mappingsPtr === 0) { | ||
| this._parseMappings(this._mappings, this.sourceRoot); | ||
| this._parseMappings(); | ||
| } | ||
@@ -317,7 +314,14 @@ | ||
| */ | ||
| _parseMappings(aStr, aSourceRoot) { | ||
| _parseMappings() { | ||
| const aStr = this._mappings; | ||
| const size = aStr.length; | ||
| 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++) { | ||
@@ -333,6 +337,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; | ||
@@ -362,3 +367,2 @@ case 2: | ||
| const order = aOrder || SourceMapConsumer.GENERATED_ORDER; | ||
| const sourceRoot = this.sourceRoot; | ||
@@ -368,4 +372,3 @@ this._wasm.withMappingCallback( | ||
| if (mapping.source !== null) { | ||
| mapping.source = this._sources.at(mapping.source); | ||
| mapping.source = util.computeSourceURL(sourceRoot, mapping.source, this._sourceMapURL); | ||
| mapping.source = this._absoluteSources.at(mapping.source); | ||
@@ -376,2 +379,5 @@ if (mapping.name !== null) { | ||
| } | ||
| if (this._computedColumnSpans && mapping.lastGeneratedColumn === null) { | ||
| mapping.lastGeneratedColumn = Infinity; | ||
| } | ||
@@ -382,10 +388,10 @@ aCallback.call(context, mapping); | ||
| 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."); | ||
| } | ||
@@ -427,3 +433,4 @@ } | ||
| }); | ||
| }, () => { | ||
| }, | ||
| () => { | ||
| this._wasm.exports.all_generated_locations_for( | ||
@@ -489,3 +496,3 @@ this._getMappingsPtr(), | ||
| generatedLine: util.getArg(aArgs, "line"), | ||
| generatedColumn: util.getArg(aArgs, "column") | ||
| generatedColumn: util.getArg(aArgs, "column"), | ||
| }; | ||
@@ -501,3 +508,7 @@ | ||
| let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND); | ||
| let bias = util.getArg( | ||
| aArgs, | ||
| "bias", | ||
| SourceMapConsumer.GREATEST_LOWER_BOUND | ||
| ); | ||
| if (bias == null) { | ||
@@ -508,10 +519,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 | ||
| ); | ||
| } | ||
| ); | ||
@@ -522,4 +536,3 @@ if (mapping) { | ||
| if (source !== null) { | ||
| source = this._sources.at(source); | ||
| source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL); | ||
| source = this._absoluteSources.at(source); | ||
| } | ||
@@ -536,3 +549,3 @@ | ||
| column: util.getArg(mapping, "originalColumn", null), | ||
| name | ||
| name, | ||
| }; | ||
@@ -546,3 +559,3 @@ } | ||
| column: null, | ||
| name: null | ||
| name: null, | ||
| }; | ||
@@ -559,4 +572,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; | ||
| }) | ||
| ); | ||
| } | ||
@@ -579,26 +596,2 @@ | ||
| let relativeSource = aSource; | ||
| if (this.sourceRoot != null) { | ||
| relativeSource = util.relative(this.sourceRoot, relativeSource); | ||
| } | ||
| let url; | ||
| if (this.sourceRoot != null | ||
| && (url = util.urlParse(this.sourceRoot))) { | ||
| // XXX: file:// URIs and absolute paths lead to unexpected behavior for | ||
| // many users. We can help them out when they expect file:// URIs to | ||
| // behave like it would if they were running a local HTTP server. See | ||
| // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. | ||
| const fileUriAbsPath = relativeSource.replace(/^file:\/\//, ""); | ||
| if (url.scheme == "file" | ||
| && this._sources.has(fileUriAbsPath)) { | ||
| return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]; | ||
| } | ||
| if ((!url.path || url.path == "/") | ||
| && this._sources.has("/" + relativeSource)) { | ||
| return this.sourcesContent[this._sources.indexOf("/" + relativeSource)]; | ||
| } | ||
| } | ||
| // This function is used recursively from | ||
@@ -612,3 +605,3 @@ // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we | ||
| throw new Error('"' + relativeSource + '" is not in the SourceMap.'); | ||
| throw new Error('"' + aSource + '" is not in the SourceMap.'); | ||
| } | ||
@@ -646,3 +639,3 @@ | ||
| column: null, | ||
| lastColumn: null | ||
| lastColumn: null, | ||
| }; | ||
@@ -654,3 +647,3 @@ } | ||
| originalLine: util.getArg(aArgs, "line"), | ||
| originalColumn: util.getArg(aArgs, "column") | ||
| originalColumn: util.getArg(aArgs, "column"), | ||
| }; | ||
@@ -666,3 +659,7 @@ | ||
| let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND); | ||
| let bias = util.getArg( | ||
| aArgs, | ||
| "bias", | ||
| SourceMapConsumer.GREATEST_LOWER_BOUND | ||
| ); | ||
| if (bias == null) { | ||
@@ -673,11 +670,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 | ||
| ); | ||
| } | ||
| ); | ||
@@ -701,3 +701,3 @@ if (mapping) { | ||
| column: null, | ||
| lastColumn: null | ||
| lastColumn: null, | ||
| }; | ||
@@ -774,42 +774,46 @@ } | ||
| that._sources = new ArraySet(); | ||
| that._names = new ArraySet(); | ||
| that.__generatedMappings = null; | ||
| that.__originalMappings = null; | ||
| that.__generatedMappingsUnsorted = null; | ||
| that.__originalMappingsUnsorted = null; | ||
| let lastOffset = { | ||
| 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; | ||
@@ -821,75 +825,2 @@ return that; | ||
| // `__generatedMappings` and `__originalMappings` are arrays that hold the | ||
| // parsed mapping coordinates from the source map's "mappings" attribute. They | ||
| // are lazily instantiated, accessed via the `_generatedMappings` and | ||
| // `_originalMappings` getters respectively, and we only parse the mappings | ||
| // and create these arrays once queried for a source location. We jump through | ||
| // these hoops because there can be many thousands of mappings, and parsing | ||
| // them is expensive, so we only want to do it if we must. | ||
| // | ||
| // Each object in the arrays is of the form: | ||
| // | ||
| // { | ||
| // generatedLine: The line number in the generated code, | ||
| // generatedColumn: The column number in the generated code, | ||
| // source: The path to the original source file that generated this | ||
| // chunk of code, | ||
| // originalLine: The line number in the original source that | ||
| // corresponds to this chunk of generated code, | ||
| // originalColumn: The column number in the original source that | ||
| // corresponds to this chunk of generated code, | ||
| // name: The name of the original symbol which generated this chunk of | ||
| // code. | ||
| // } | ||
| // | ||
| // All properties except for `generatedLine` and `generatedColumn` can be | ||
| // `null`. | ||
| // | ||
| // `_generatedMappings` is ordered by the generated positions. | ||
| // | ||
| // `_originalMappings` is ordered by the original positions. | ||
| get _generatedMappings() { | ||
| if (!this.__generatedMappings) { | ||
| this._sortGeneratedMappings(); | ||
| } | ||
| return this.__generatedMappings; | ||
| } | ||
| get _originalMappings() { | ||
| if (!this.__originalMappings) { | ||
| this._sortOriginalMappings(); | ||
| } | ||
| return this.__originalMappings; | ||
| } | ||
| get _generatedMappingsUnsorted() { | ||
| if (!this.__generatedMappingsUnsorted) { | ||
| this._parseMappings(this._mappings, this.sourceRoot); | ||
| } | ||
| return this.__generatedMappingsUnsorted; | ||
| } | ||
| get _originalMappingsUnsorted() { | ||
| if (!this.__originalMappingsUnsorted) { | ||
| this._parseMappings(this._mappings, this.sourceRoot); | ||
| } | ||
| return this.__originalMappingsUnsorted; | ||
| } | ||
| _sortGeneratedMappings() { | ||
| const mappings = this._generatedMappingsUnsorted; | ||
| mappings.sort(util.compareByGeneratedPositionsDeflated); | ||
| this.__generatedMappings = mappings; | ||
| } | ||
| _sortOriginalMappings() { | ||
| const mappings = this._originalMappingsUnsorted; | ||
| mappings.sort(util.compareByOriginalPositions); | ||
| this.__originalMappings = mappings; | ||
| } | ||
| /** | ||
@@ -930,3 +861,3 @@ * The list of original sources. | ||
| generatedLine: util.getArg(aArgs, "line"), | ||
| generatedColumn: util.getArg(aArgs, "column") | ||
| generatedColumn: util.getArg(aArgs, "column"), | ||
| }; | ||
@@ -936,5 +867,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) { | ||
@@ -944,5 +878,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]; | ||
@@ -955,3 +894,3 @@ | ||
| column: null, | ||
| name: null | ||
| name: null, | ||
| }; | ||
@@ -961,9 +900,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, | ||
| }); | ||
@@ -977,3 +916,3 @@ } | ||
| hasContentsOfAllSources() { | ||
| return this._sections.every(function(s) { | ||
| return this._sections.every(function (s) { | ||
| return s.consumer.hasContentsOfAllSources(); | ||
@@ -1003,2 +942,12 @@ }); | ||
| _findSectionIndex(source) { | ||
| for (let i = 0; i < this._sections.length; i++) { | ||
| const { consumer } = this._sections[i]; | ||
| if (consumer._findSourceIndex(source) !== -1) { | ||
| return i; | ||
| } | ||
| } | ||
| return -1; | ||
| } | ||
| /** | ||
@@ -1023,22 +972,33 @@ * Returns the generated line and column information for the original source, | ||
| generatedPositionFor(aArgs) { | ||
| for (let i = 0; i < this._sections.length; i++) { | ||
| const section = this._sections[i]; | ||
| const index = this._findSectionIndex(util.getArg(aArgs, "source")); | ||
| const section = index >= 0 ? this._sections[index] : null; | ||
| const nextSection = | ||
| index >= 0 && index + 1 < this._sections.length | ||
| ? this._sections[index + 1] | ||
| : null; | ||
| // Only consider this section if the requested source is in the list of | ||
| // sources of the consumer. | ||
| if (section.consumer._findSourceIndex(util.getArg(aArgs, "source")) === -1) { | ||
| continue; | ||
| const generatedPosition = | ||
| section && section.consumer.generatedPositionFor(aArgs); | ||
| if (generatedPosition && generatedPosition.line !== null) { | ||
| const lineShift = section.generatedOffset.generatedLine - 1; | ||
| const columnShift = section.generatedOffset.generatedColumn - 1; | ||
| if (generatedPosition.line === 1) { | ||
| generatedPosition.column += columnShift; | ||
| if (typeof generatedPosition.lastColumn === "number") { | ||
| generatedPosition.lastColumn += columnShift; | ||
| } | ||
| } | ||
| const generatedPosition = section.consumer.generatedPositionFor(aArgs); | ||
| if (generatedPosition) { | ||
| const ret = { | ||
| line: generatedPosition.line + | ||
| (section.generatedOffset.generatedLine - 1), | ||
| column: generatedPosition.column + | ||
| (section.generatedOffset.generatedLine === generatedPosition.line | ||
| ? section.generatedOffset.generatedColumn - 1 | ||
| : 0) | ||
| }; | ||
| return ret; | ||
| if ( | ||
| generatedPosition.lastColumn === Infinity && | ||
| nextSection && | ||
| generatedPosition.line === nextSection.generatedOffset.generatedLine | ||
| ) { | ||
| generatedPosition.lastColumn = | ||
| nextSection.generatedOffset.generatedColumn - 2; | ||
| } | ||
| generatedPosition.line += lineShift; | ||
| return generatedPosition; | ||
| } | ||
@@ -1048,202 +1008,85 @@ | ||
| line: null, | ||
| column: null | ||
| column: null, | ||
| lastColumn: null, | ||
| }; | ||
| } | ||
| /** | ||
| * Parse the mappings in a string in to a data structure which we can easily | ||
| * query (the ordered arrays in the `this.__generatedMappings` and | ||
| * `this.__originalMappings` properties). | ||
| */ | ||
| _parseMappings(aStr, aSourceRoot) { | ||
| const generatedMappings = this.__generatedMappingsUnsorted = []; | ||
| const originalMappings = this.__originalMappingsUnsorted = []; | ||
| for (let i = 0; i < this._sections.length; i++) { | ||
| const section = this._sections[i]; | ||
| allGeneratedPositionsFor(aArgs) { | ||
| const index = this._findSectionIndex(util.getArg(aArgs, "source")); | ||
| const section = index >= 0 ? this._sections[index] : null; | ||
| const nextSection = | ||
| index >= 0 && index + 1 < this._sections.length | ||
| ? this._sections[index + 1] | ||
| : null; | ||
| const sectionMappings = []; | ||
| section.consumer.eachMapping(m => sectionMappings.push(m)); | ||
| if (!section) return []; | ||
| for (let j = 0; j < sectionMappings.length; j++) { | ||
| const mapping = sectionMappings[j]; | ||
| return section.consumer | ||
| .allGeneratedPositionsFor(aArgs) | ||
| .map(generatedPosition => { | ||
| const lineShift = section.generatedOffset.generatedLine - 1; | ||
| const columnShift = section.generatedOffset.generatedColumn - 1; | ||
| // TODO: test if null is correct here. The original code used | ||
| // `source`, which would actually have gotten used as null because | ||
| // var's get hoisted. | ||
| // See: https://github.com/mozilla/source-map/issues/333 | ||
| let source = util.computeSourceURL(section.consumer.sourceRoot, null, this._sourceMapURL); | ||
| this._sources.add(source); | ||
| source = this._sources.indexOf(source); | ||
| if (generatedPosition.line === 1) { | ||
| generatedPosition.column += columnShift; | ||
| if (typeof generatedPosition.lastColumn === "number") { | ||
| generatedPosition.lastColumn += columnShift; | ||
| } | ||
| } | ||
| let name = null; | ||
| if (mapping.name) { | ||
| this._names.add(mapping.name); | ||
| name = this._names.indexOf(mapping.name); | ||
| if ( | ||
| generatedPosition.lastColumn === Infinity && | ||
| nextSection && | ||
| generatedPosition.line === nextSection.generatedOffset.generatedLine | ||
| ) { | ||
| generatedPosition.lastColumn = | ||
| nextSection.generatedOffset.generatedColumn - 2; | ||
| } | ||
| generatedPosition.line += lineShift; | ||
| // The mappings coming from the consumer for the section have | ||
| // generated positions relative to the start of the section, so we | ||
| // need to offset them to be relative to the start of the concatenated | ||
| // generated file. | ||
| const adjustedMapping = { | ||
| source, | ||
| generatedLine: mapping.generatedLine + | ||
| (section.generatedOffset.generatedLine - 1), | ||
| generatedColumn: mapping.generatedColumn + | ||
| (section.generatedOffset.generatedLine === mapping.generatedLine | ||
| ? section.generatedOffset.generatedColumn - 1 | ||
| : 0), | ||
| originalLine: mapping.originalLine, | ||
| originalColumn: mapping.originalColumn, | ||
| name | ||
| }; | ||
| generatedMappings.push(adjustedMapping); | ||
| if (typeof adjustedMapping.originalLine === "number") { | ||
| originalMappings.push(adjustedMapping); | ||
| } | ||
| } | ||
| } | ||
| return generatedPosition; | ||
| }); | ||
| } | ||
| eachMapping(aCallback, aContext, aOrder) { | ||
| const context = aContext || null; | ||
| const order = aOrder || SourceMapConsumer.GENERATED_ORDER; | ||
| this._sections.forEach((section, index) => { | ||
| const nextSection = | ||
| index + 1 < this._sections.length ? this._sections[index + 1] : null; | ||
| const { generatedOffset } = section; | ||
| let mappings; | ||
| switch (order) { | ||
| case SourceMapConsumer.GENERATED_ORDER: | ||
| mappings = this._generatedMappings; | ||
| break; | ||
| case SourceMapConsumer.ORIGINAL_ORDER: | ||
| mappings = this._originalMappings; | ||
| break; | ||
| default: | ||
| throw new Error("Unknown order of iteration."); | ||
| } | ||
| const lineShift = generatedOffset.generatedLine - 1; | ||
| const columnShift = generatedOffset.generatedColumn - 1; | ||
| const sourceRoot = this.sourceRoot; | ||
| mappings.map(function(mapping) { | ||
| let source = null; | ||
| if (mapping.source !== null) { | ||
| source = this._sources.at(mapping.source); | ||
| source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL); | ||
| } | ||
| return { | ||
| source, | ||
| generatedLine: mapping.generatedLine, | ||
| generatedColumn: mapping.generatedColumn, | ||
| originalLine: mapping.originalLine, | ||
| originalColumn: mapping.originalColumn, | ||
| name: mapping.name === null ? null : this._names.at(mapping.name) | ||
| }; | ||
| }, this).forEach(aCallback, context); | ||
| } | ||
| section.consumer.eachMapping( | ||
| function (mapping) { | ||
| if (mapping.generatedLine === 1) { | ||
| mapping.generatedColumn += columnShift; | ||
| /** | ||
| * Find the mapping that best matches the hypothetical "needle" mapping that | ||
| * we are searching for in the given "haystack" of mappings. | ||
| */ | ||
| _findMapping(aNeedle, aMappings, aLineName, | ||
| aColumnName, aComparator, aBias) { | ||
| // To return the position we are searching for, we must first find the | ||
| // mapping for the given position and then return the opposite position it | ||
| // points to. Because the mappings are sorted, we can use binary search to | ||
| // find the best mapping. | ||
| if (typeof mapping.lastGeneratedColumn === "number") { | ||
| mapping.lastGeneratedColumn += columnShift; | ||
| } | ||
| } | ||
| if (aNeedle[aLineName] <= 0) { | ||
| throw new TypeError("Line must be greater than or equal to 1, got " | ||
| + aNeedle[aLineName]); | ||
| } | ||
| if (aNeedle[aColumnName] < 0) { | ||
| throw new TypeError("Column must be greater than or equal to 0, got " | ||
| + aNeedle[aColumnName]); | ||
| } | ||
| if ( | ||
| mapping.lastGeneratedColumn === Infinity && | ||
| nextSection && | ||
| mapping.generatedLine === nextSection.generatedOffset.generatedLine | ||
| ) { | ||
| mapping.lastGeneratedColumn = | ||
| nextSection.generatedOffset.generatedColumn - 2; | ||
| } | ||
| mapping.generatedLine += lineShift; | ||
| return binarySearch.search(aNeedle, aMappings, aComparator, aBias); | ||
| aCallback.call(this, mapping); | ||
| }, | ||
| aContext, | ||
| aOrder | ||
| ); | ||
| }); | ||
| } | ||
| allGeneratedPositionsFor(aArgs) { | ||
| const line = util.getArg(aArgs, "line"); | ||
| // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping | ||
| // returns the index of the closest mapping less than the needle. By | ||
| // setting needle.originalColumn to 0, we thus find the last mapping for | ||
| // the given line, provided such a mapping exists. | ||
| const needle = { | ||
| source: util.getArg(aArgs, "source"), | ||
| originalLine: line, | ||
| originalColumn: util.getArg(aArgs, "column", 0) | ||
| }; | ||
| needle.source = this._findSourceIndex(needle.source); | ||
| if (needle.source < 0) { | ||
| return []; | ||
| computeColumnSpans() { | ||
| for (let i = 0; i < this._sections.length; i++) { | ||
| this._sections[i].consumer.computeColumnSpans(); | ||
| } | ||
| if (needle.originalLine < 1) { | ||
| throw new Error("Line numbers must be >= 1"); | ||
| } | ||
| if (needle.originalColumn < 0) { | ||
| throw new Error("Column numbers must be >= 0"); | ||
| } | ||
| const mappings = []; | ||
| let index = this._findMapping(needle, | ||
| this._originalMappings, | ||
| "originalLine", | ||
| "originalColumn", | ||
| util.compareByOriginalPositions, | ||
| binarySearch.LEAST_UPPER_BOUND); | ||
| if (index >= 0) { | ||
| let mapping = this._originalMappings[index]; | ||
| if (aArgs.column === undefined) { | ||
| const originalLine = mapping.originalLine; | ||
| // Iterate until either we run out of mappings, or we run into | ||
| // a mapping for a different line than the one we found. Since | ||
| // mappings are sorted, this is guaranteed to find all mappings for | ||
| // the line we found. | ||
| while (mapping && mapping.originalLine === originalLine) { | ||
| let lastColumn = mapping.lastGeneratedColumn; | ||
| if (this._computedColumnSpans && lastColumn === null) { | ||
| lastColumn = Infinity; | ||
| } | ||
| mappings.push({ | ||
| line: util.getArg(mapping, "generatedLine", null), | ||
| column: util.getArg(mapping, "generatedColumn", null), | ||
| lastColumn, | ||
| }); | ||
| mapping = this._originalMappings[++index]; | ||
| } | ||
| } else { | ||
| const originalColumn = mapping.originalColumn; | ||
| // Iterate until either we run out of mappings, or we run into | ||
| // a mapping for a different line than the one we were searching for. | ||
| // Since mappings are sorted, this is guaranteed to find all mappings for | ||
| // the line we are searching for. | ||
| while (mapping && | ||
| mapping.originalLine === line && | ||
| mapping.originalColumn == originalColumn) { | ||
| let lastColumn = mapping.lastGeneratedColumn; | ||
| if (this._computedColumnSpans && lastColumn === null) { | ||
| lastColumn = Infinity; | ||
| } | ||
| mappings.push({ | ||
| line: util.getArg(mapping, "generatedLine", null), | ||
| column: util.getArg(mapping, "generatedColumn", null), | ||
| lastColumn, | ||
| }); | ||
| mapping = this._originalMappings[++index]; | ||
| } | ||
| } | ||
| } | ||
| return mappings; | ||
| } | ||
@@ -1269,3 +1112,4 @@ | ||
| const consumer = sourceMap.sections != null | ||
| const consumer = | ||
| sourceMap.sections != null | ||
| ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL) | ||
@@ -1272,0 +1116,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 @@ |
+70
-44
@@ -55,3 +55,7 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
| */ | ||
| static fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { | ||
| static fromStringWithSourceMap( | ||
| aGeneratedCode, | ||
| aSourceMapConsumer, | ||
| aRelativePath | ||
| ) { | ||
| // The SourceNode we want to fill with the generated code | ||
@@ -67,3 +71,3 @@ // and the SourceMap | ||
| let remainingLinesIndex = 0; | ||
| const shiftNextLine = function() { | ||
| const shiftNextLine = function () { | ||
| const lineContents = getNextLine(); | ||
@@ -75,4 +79,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; | ||
| } | ||
@@ -82,3 +87,4 @@ }; | ||
| // We need to remember the position of "remainingLines" | ||
| let lastGeneratedLine = 1, lastGeneratedColumn = 0; | ||
| let lastGeneratedLine = 1, | ||
| lastGeneratedColumn = 0; | ||
@@ -91,3 +97,3 @@ // The generate SourceNodes we need a code range. | ||
| aSourceMapConsumer.eachMapping(function(mapping) { | ||
| aSourceMapConsumer.eachMapping(function (mapping) { | ||
| if (lastMapping !== null) { | ||
@@ -107,6 +113,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; | ||
@@ -129,3 +138,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; | ||
@@ -146,3 +157,3 @@ } | ||
| // Copy sourcesContent into SourceNode | ||
| aSourceMapConsumer.sources.forEach(function(sourceFile) { | ||
| aSourceMapConsumer.sources.forEach(function (sourceFile) { | ||
| const content = aSourceMapConsumer.sourceContentFor(sourceFile); | ||
@@ -166,7 +177,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 | ||
| ) | ||
| ); | ||
| } | ||
@@ -184,3 +199,3 @@ } | ||
| if (Array.isArray(aChunk)) { | ||
| aChunk.forEach(function(chunk) { | ||
| aChunk.forEach(function (chunk) { | ||
| this.add(chunk); | ||
@@ -194,3 +209,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 | ||
| ); | ||
@@ -216,3 +232,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 | ||
| ); | ||
@@ -237,6 +254,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, | ||
| }); | ||
| } | ||
@@ -280,3 +299,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 { | ||
@@ -324,3 +346,3 @@ this.children.push("".replace(aPattern, aReplacement)); | ||
| let str = ""; | ||
| this.walk(function(chunk) { | ||
| this.walk(function (chunk) { | ||
| str += chunk; | ||
@@ -339,3 +361,3 @@ }); | ||
| line: 1, | ||
| column: 0 | ||
| column: 0, | ||
| }; | ||
@@ -348,11 +370,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({ | ||
@@ -362,9 +388,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, | ||
| }); | ||
@@ -381,4 +407,4 @@ } | ||
| line: generated.line, | ||
| column: generated.column | ||
| } | ||
| column: generated.column, | ||
| }, | ||
| }); | ||
@@ -401,9 +427,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, | ||
| }); | ||
@@ -416,3 +442,3 @@ } | ||
| }); | ||
| this.walkSourceContents(function(sourceFile, sourceContent) { | ||
| this.walkSourceContents(function (sourceFile, sourceContent) { | ||
| map.setSourceContent(sourceFile, sourceContent); | ||
@@ -419,0 +445,0 @@ }); |
+283
-385
@@ -8,2 +8,4 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
| const URL = require("./url"); | ||
| /** | ||
@@ -25,266 +27,10 @@ * This is a helper function for getting values from parameter/options | ||
| } | ||
| throw new Error('"' + aName + '" is a required argument.'); | ||
| throw new Error('"' + aName + '" is a required argument.'); | ||
| } | ||
| exports.getArg = getArg; | ||
| const urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/; | ||
| const dataUrlRegexp = /^data:.+\,.+$/; | ||
| function urlParse(aUrl) { | ||
| const match = aUrl.match(urlRegexp); | ||
| if (!match) { | ||
| return null; | ||
| } | ||
| return { | ||
| scheme: match[1], | ||
| auth: match[2], | ||
| host: match[3], | ||
| port: match[4], | ||
| path: match[5] | ||
| }; | ||
| } | ||
| exports.urlParse = urlParse; | ||
| function urlGenerate(aParsedUrl) { | ||
| let url = ""; | ||
| if (aParsedUrl.scheme) { | ||
| url += aParsedUrl.scheme + ":"; | ||
| } | ||
| url += "//"; | ||
| if (aParsedUrl.auth) { | ||
| url += aParsedUrl.auth + "@"; | ||
| } | ||
| if (aParsedUrl.host) { | ||
| url += aParsedUrl.host; | ||
| } | ||
| if (aParsedUrl.port) { | ||
| url += ":" + aParsedUrl.port; | ||
| } | ||
| if (aParsedUrl.path) { | ||
| url += aParsedUrl.path; | ||
| } | ||
| return url; | ||
| } | ||
| exports.urlGenerate = urlGenerate; | ||
| const MAX_CACHED_INPUTS = 32; | ||
| /** | ||
| * Takes some function `f(input) -> result` and returns a memoized version of | ||
| * `f`. | ||
| * | ||
| * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The | ||
| * memoization is a dumb-simple, linear least-recently-used cache. | ||
| */ | ||
| function lruMemoize(f) { | ||
| const cache = []; | ||
| return function(input) { | ||
| for (let i = 0; i < cache.length; i++) { | ||
| if (cache[i].input === input) { | ||
| const temp = cache[0]; | ||
| cache[0] = cache[i]; | ||
| cache[i] = temp; | ||
| return cache[0].result; | ||
| } | ||
| } | ||
| const result = f(input); | ||
| cache.unshift({ | ||
| input, | ||
| result, | ||
| }); | ||
| if (cache.length > MAX_CACHED_INPUTS) { | ||
| cache.pop(); | ||
| } | ||
| return result; | ||
| }; | ||
| } | ||
| /** | ||
| * Normalizes a path, or the path portion of a URL: | ||
| * | ||
| * - Replaces consecutive slashes with one slash. | ||
| * - Removes unnecessary '.' parts. | ||
| * - Removes unnecessary '<dir>/..' parts. | ||
| * | ||
| * Based on code in the Node.js 'path' core module. | ||
| * | ||
| * @param aPath The path or url to normalize. | ||
| */ | ||
| const normalize = lruMemoize(function normalize(aPath) { | ||
| let path = aPath; | ||
| const url = urlParse(aPath); | ||
| if (url) { | ||
| if (!url.path) { | ||
| return aPath; | ||
| } | ||
| path = url.path; | ||
| } | ||
| const isAbsolute = exports.isAbsolute(path); | ||
| // Split the path into parts between `/` characters. This is much faster than | ||
| // using `.split(/\/+/g)`. | ||
| const parts = []; | ||
| let start = 0; | ||
| let i = 0; | ||
| while (true) { | ||
| start = i; | ||
| i = path.indexOf("/", start); | ||
| if (i === -1) { | ||
| parts.push(path.slice(start)); | ||
| break; | ||
| } else { | ||
| parts.push(path.slice(start, i)); | ||
| while (i < path.length && path[i] === "/") { | ||
| i++; | ||
| } | ||
| } | ||
| } | ||
| let up = 0; | ||
| for (i = parts.length - 1; i >= 0; i--) { | ||
| const part = parts[i]; | ||
| if (part === ".") { | ||
| parts.splice(i, 1); | ||
| } else if (part === "..") { | ||
| up++; | ||
| } else if (up > 0) { | ||
| if (part === "") { | ||
| // The first part is blank if the path is absolute. Trying to go | ||
| // above the root is a no-op. Therefore we can remove all '..' parts | ||
| // directly after the root. | ||
| parts.splice(i + 1, up); | ||
| up = 0; | ||
| } else { | ||
| parts.splice(i, 2); | ||
| up--; | ||
| } | ||
| } | ||
| } | ||
| path = parts.join("/"); | ||
| if (path === "") { | ||
| path = isAbsolute ? "/" : "."; | ||
| } | ||
| if (url) { | ||
| url.path = path; | ||
| return urlGenerate(url); | ||
| } | ||
| return path; | ||
| }); | ||
| exports.normalize = normalize; | ||
| /** | ||
| * Joins two paths/URLs. | ||
| * | ||
| * @param aRoot The root path or URL. | ||
| * @param aPath The path or URL to be joined with the root. | ||
| * | ||
| * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a | ||
| * scheme-relative URL: Then the scheme of aRoot, if any, is prepended | ||
| * first. | ||
| * - Otherwise aPath is a path. If aRoot is a URL, then its path portion | ||
| * is updated with the result and aRoot is returned. Otherwise the result | ||
| * is returned. | ||
| * - If aPath is absolute, the result is aPath. | ||
| * - Otherwise the two paths are joined with a slash. | ||
| * - Joining for example 'http://' and 'www.example.com' is also supported. | ||
| */ | ||
| function join(aRoot, aPath) { | ||
| if (aRoot === "") { | ||
| aRoot = "."; | ||
| } | ||
| if (aPath === "") { | ||
| aPath = "."; | ||
| } | ||
| const aPathUrl = urlParse(aPath); | ||
| const aRootUrl = urlParse(aRoot); | ||
| if (aRootUrl) { | ||
| aRoot = aRootUrl.path || "/"; | ||
| } | ||
| // `join(foo, '//www.example.org')` | ||
| if (aPathUrl && !aPathUrl.scheme) { | ||
| if (aRootUrl) { | ||
| aPathUrl.scheme = aRootUrl.scheme; | ||
| } | ||
| return urlGenerate(aPathUrl); | ||
| } | ||
| if (aPathUrl || aPath.match(dataUrlRegexp)) { | ||
| return aPath; | ||
| } | ||
| // `join('http://', 'www.example.com')` | ||
| if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { | ||
| aRootUrl.host = aPath; | ||
| return urlGenerate(aRootUrl); | ||
| } | ||
| const joined = aPath.charAt(0) === "/" | ||
| ? aPath | ||
| : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath); | ||
| if (aRootUrl) { | ||
| aRootUrl.path = joined; | ||
| return urlGenerate(aRootUrl); | ||
| } | ||
| return joined; | ||
| } | ||
| exports.join = join; | ||
| exports.isAbsolute = function(aPath) { | ||
| return aPath.charAt(0) === "/" || urlRegexp.test(aPath); | ||
| }; | ||
| /** | ||
| * Make a path relative to a URL or another path. | ||
| * | ||
| * @param aRoot The root path or URL. | ||
| * @param aPath The path or URL to be made relative to aRoot. | ||
| */ | ||
| function relative(aRoot, aPath) { | ||
| if (aRoot === "") { | ||
| aRoot = "."; | ||
| } | ||
| aRoot = aRoot.replace(/\/$/, ""); | ||
| // It is possible for the path to be above the root. In this case, simply | ||
| // checking whether the root is a prefix of the path won't work. Instead, we | ||
| // need to remove components from the root one by one, until either we find | ||
| // a prefix that fits, or we run out of components to remove. | ||
| let level = 0; | ||
| while (aPath.indexOf(aRoot + "/") !== 0) { | ||
| const index = aRoot.lastIndexOf("/"); | ||
| if (index < 0) { | ||
| return aPath; | ||
| } | ||
| // If the only part of the root that is left is the scheme (i.e. http://, | ||
| // file:///, etc.), one or more slashes (/), or simply nothing at all, we | ||
| // have exhausted all components, so the path is not relative to the root. | ||
| aRoot = aRoot.slice(0, index); | ||
| if (aRoot.match(/^([^\/]+:\/)?\/*$/)) { | ||
| return aPath; | ||
| } | ||
| ++level; | ||
| } | ||
| // Make sure we add a "../" for each component we removed from the root. | ||
| return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1); | ||
| } | ||
| exports.relative = relative; | ||
| const supportsNullProto = (function() { | ||
| const supportsNullProto = (function () { | ||
| const obj = Object.create(null); | ||
| return !("__proto__" in obj); | ||
| }()); | ||
| })(); | ||
@@ -334,11 +80,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; | ||
@@ -357,50 +105,27 @@ } | ||
| /** | ||
| * Comparator between two mappings where the original positions are compared. | ||
| * | ||
| * Optionally pass in `true` as `onlyCompareGenerated` to consider two | ||
| * mappings with the same original source/line/column, but different generated | ||
| * line and column the same. Useful when searching for a mapping with a | ||
| * stubbed out mapping. | ||
| */ | ||
| function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { | ||
| let cmp = strcmp(mappingA.source, mappingB.source); | ||
| if (cmp !== 0) { | ||
| return cmp; | ||
| function strcmp(aStr1, aStr2) { | ||
| if (aStr1 === aStr2) { | ||
| return 0; | ||
| } | ||
| cmp = mappingA.originalLine - mappingB.originalLine; | ||
| if (cmp !== 0) { | ||
| return cmp; | ||
| if (aStr1 === null) { | ||
| return 1; // aStr2 !== null | ||
| } | ||
| cmp = mappingA.originalColumn - mappingB.originalColumn; | ||
| if (cmp !== 0 || onlyCompareOriginal) { | ||
| return cmp; | ||
| if (aStr2 === null) { | ||
| return -1; // aStr1 !== null | ||
| } | ||
| cmp = mappingA.generatedColumn - mappingB.generatedColumn; | ||
| if (cmp !== 0) { | ||
| return cmp; | ||
| if (aStr1 > aStr2) { | ||
| return 1; | ||
| } | ||
| cmp = mappingA.generatedLine - mappingB.generatedLine; | ||
| if (cmp !== 0) { | ||
| return cmp; | ||
| } | ||
| return strcmp(mappingA.name, mappingB.name); | ||
| return -1; | ||
| } | ||
| exports.compareByOriginalPositions = compareByOriginalPositions; | ||
| /** | ||
| * Comparator between two mappings with deflated source and name indices where | ||
| * Comparator between two mappings with inflated source and name strings where | ||
| * the generated positions are compared. | ||
| * | ||
| * Optionally pass in `true` as `onlyCompareGenerated` to consider two | ||
| * mappings with the same generated line and column, but different | ||
| * source/name/original line and column the same. Useful when searching for a | ||
| * mapping with a stubbed out mapping. | ||
| */ | ||
| function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) { | ||
| function compareByGeneratedPositionsInflated(mappingA, mappingB) { | ||
| let cmp = mappingA.generatedLine - mappingB.generatedLine; | ||
@@ -412,3 +137,3 @@ if (cmp !== 0) { | ||
| cmp = mappingA.generatedColumn - mappingB.generatedColumn; | ||
| if (cmp !== 0 || onlyCompareGenerated) { | ||
| if (cmp !== 0) { | ||
| return cmp; | ||
@@ -434,68 +159,257 @@ } | ||
| } | ||
| exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; | ||
| exports.compareByGeneratedPositionsInflated = | ||
| compareByGeneratedPositionsInflated; | ||
| function strcmp(aStr1, aStr2) { | ||
| if (aStr1 === aStr2) { | ||
| return 0; | ||
| } | ||
| /** | ||
| * Strip any JSON XSSI avoidance prefix from the string (as documented | ||
| * in the source maps specification), and then parse the string as | ||
| * JSON. | ||
| */ | ||
| function parseSourceMapInput(str) { | ||
| return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, "")); | ||
| } | ||
| exports.parseSourceMapInput = parseSourceMapInput; | ||
| if (aStr1 === null) { | ||
| return 1; // aStr2 !== null | ||
| } | ||
| // We use 'http' as the base here because we want URLs processed relative | ||
| // to the safe base to be treated as "special" URLs during parsing using | ||
| // the WHATWG URL parsing. This ensures that backslash normalization | ||
| // applies to the path and such. | ||
| const PROTOCOL = "http:"; | ||
| const PROTOCOL_AND_HOST = `${PROTOCOL}//host`; | ||
| if (aStr2 === null) { | ||
| return -1; // aStr1 !== null | ||
| /** | ||
| * Make it easy to create small utilities that tweak a URL's path. | ||
| */ | ||
| function createSafeHandler(cb) { | ||
| return input => { | ||
| const type = getURLType(input); | ||
| const base = buildSafeBase(input); | ||
| const url = new URL(input, base); | ||
| cb(url); | ||
| const result = url.toString(); | ||
| if (type === "absolute") { | ||
| return result; | ||
| } else if (type === "scheme-relative") { | ||
| return result.slice(PROTOCOL.length); | ||
| } else if (type === "path-absolute") { | ||
| return result.slice(PROTOCOL_AND_HOST.length); | ||
| } | ||
| // This assumes that the callback will only change | ||
| // the path, search and hash values. | ||
| return computeRelativeURL(base, result); | ||
| }; | ||
| } | ||
| function withBase(url, base) { | ||
| return new URL(url, base).toString(); | ||
| } | ||
| function buildUniqueSegment(prefix, str) { | ||
| let id = 0; | ||
| do { | ||
| const ident = prefix + id++; | ||
| if (str.indexOf(ident) === -1) return ident; | ||
| } while (true); | ||
| } | ||
| function buildSafeBase(str) { | ||
| const maxDotParts = str.split("..").length - 1; | ||
| // If we used a segment that also existed in `str`, then we would be unable | ||
| // to compute relative paths. For example, if `segment` were just "a": | ||
| // | ||
| // const url = "../../a/" | ||
| // const base = buildSafeBase(url); // http://host/a/a/ | ||
| // const joined = "http://host/a/"; | ||
| // const result = relative(base, joined); | ||
| // | ||
| // Expected: "../../a/"; | ||
| // Actual: "a/" | ||
| // | ||
| const segment = buildUniqueSegment("p", str); | ||
| let base = `${PROTOCOL_AND_HOST}/`; | ||
| for (let i = 0; i < maxDotParts; i++) { | ||
| base += `${segment}/`; | ||
| } | ||
| return base; | ||
| } | ||
| if (aStr1 > aStr2) { | ||
| return 1; | ||
| const ABSOLUTE_SCHEME = /^[A-Za-z0-9\+\-\.]+:/; | ||
| function getURLType(url) { | ||
| if (url[0] === "/") { | ||
| if (url[1] === "/") return "scheme-relative"; | ||
| return "path-absolute"; | ||
| } | ||
| return -1; | ||
| return ABSOLUTE_SCHEME.test(url) ? "absolute" : "path-relative"; | ||
| } | ||
| /** | ||
| * Comparator between two mappings with inflated source and name strings where | ||
| * the generated positions are compared. | ||
| * Given two URLs that are assumed to be on the same | ||
| * protocol/host/user/password build a relative URL from the | ||
| * path, params, and hash values. | ||
| * | ||
| * @param rootURL The root URL that the target will be relative to. | ||
| * @param targetURL The target that the relative URL points to. | ||
| * @return A rootURL-relative, normalized URL value. | ||
| */ | ||
| function compareByGeneratedPositionsInflated(mappingA, mappingB) { | ||
| let cmp = mappingA.generatedLine - mappingB.generatedLine; | ||
| if (cmp !== 0) { | ||
| return cmp; | ||
| function computeRelativeURL(rootURL, targetURL) { | ||
| if (typeof rootURL === "string") rootURL = new URL(rootURL); | ||
| if (typeof targetURL === "string") targetURL = new URL(targetURL); | ||
| const targetParts = targetURL.pathname.split("/"); | ||
| const rootParts = rootURL.pathname.split("/"); | ||
| // If we've got a URL path ending with a "/", we remove it since we'd | ||
| // otherwise be relative to the wrong location. | ||
| if (rootParts.length > 0 && !rootParts[rootParts.length - 1]) { | ||
| rootParts.pop(); | ||
| } | ||
| cmp = mappingA.generatedColumn - mappingB.generatedColumn; | ||
| if (cmp !== 0) { | ||
| return cmp; | ||
| while ( | ||
| targetParts.length > 0 && | ||
| rootParts.length > 0 && | ||
| targetParts[0] === rootParts[0] | ||
| ) { | ||
| targetParts.shift(); | ||
| rootParts.shift(); | ||
| } | ||
| cmp = strcmp(mappingA.source, mappingB.source); | ||
| if (cmp !== 0) { | ||
| return cmp; | ||
| const relativePath = rootParts | ||
| .map(() => "..") | ||
| .concat(targetParts) | ||
| .join("/"); | ||
| return relativePath + targetURL.search + targetURL.hash; | ||
| } | ||
| /** | ||
| * Given a URL, ensure that it is treated as a directory URL. | ||
| * | ||
| * @param url | ||
| * @return A normalized URL value. | ||
| */ | ||
| const ensureDirectory = createSafeHandler(url => { | ||
| url.pathname = url.pathname.replace(/\/?$/, "/"); | ||
| }); | ||
| /** | ||
| * Given a URL, strip off any filename if one is present. | ||
| * | ||
| * @param url | ||
| * @return A normalized URL value. | ||
| */ | ||
| const trimFilename = createSafeHandler(url => { | ||
| url.href = new URL(".", url.toString()).toString(); | ||
| }); | ||
| /** | ||
| * Normalize a given URL. | ||
| * * Convert backslashes. | ||
| * * Remove any ".." and "." segments. | ||
| * | ||
| * @param url | ||
| * @return A normalized URL value. | ||
| */ | ||
| const normalize = createSafeHandler(url => {}); | ||
| exports.normalize = normalize; | ||
| /** | ||
| * Joins two paths/URLs. | ||
| * | ||
| * All returned URLs will be normalized. | ||
| * | ||
| * @param aRoot The root path or URL. Assumed to reference a directory. | ||
| * @param aPath The path or URL to be joined with the root. | ||
| * @return A joined and normalized URL value. | ||
| */ | ||
| function join(aRoot, aPath) { | ||
| const pathType = getURLType(aPath); | ||
| const rootType = getURLType(aRoot); | ||
| aRoot = ensureDirectory(aRoot); | ||
| if (pathType === "absolute") { | ||
| return withBase(aPath, undefined); | ||
| } | ||
| if (rootType === "absolute") { | ||
| return withBase(aPath, aRoot); | ||
| } | ||
| cmp = mappingA.originalLine - mappingB.originalLine; | ||
| if (cmp !== 0) { | ||
| return cmp; | ||
| if (pathType === "scheme-relative") { | ||
| return normalize(aPath); | ||
| } | ||
| if (rootType === "scheme-relative") { | ||
| return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice( | ||
| PROTOCOL.length | ||
| ); | ||
| } | ||
| cmp = mappingA.originalColumn - mappingB.originalColumn; | ||
| if (cmp !== 0) { | ||
| return cmp; | ||
| if (pathType === "path-absolute") { | ||
| return normalize(aPath); | ||
| } | ||
| if (rootType === "path-absolute") { | ||
| return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice( | ||
| PROTOCOL_AND_HOST.length | ||
| ); | ||
| } | ||
| return strcmp(mappingA.name, mappingB.name); | ||
| const base = buildSafeBase(aPath + aRoot); | ||
| const newPath = withBase(aPath, withBase(aRoot, base)); | ||
| return computeRelativeURL(base, newPath); | ||
| } | ||
| exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; | ||
| exports.join = join; | ||
| /** | ||
| * Strip any JSON XSSI avoidance prefix from the string (as documented | ||
| * in the source maps specification), and then parse the string as | ||
| * JSON. | ||
| * Make a path relative to a URL or another path. If returning a | ||
| * relative URL is not possible, the original target will be returned. | ||
| * All returned URLs will be normalized. | ||
| * | ||
| * @param aRoot The root path or URL. | ||
| * @param aPath The path or URL to be made relative to aRoot. | ||
| * @return A rootURL-relative (if possible), normalized URL value. | ||
| */ | ||
| function parseSourceMapInput(str) { | ||
| return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, "")); | ||
| function relative(rootURL, targetURL) { | ||
| const result = relativeIfPossible(rootURL, targetURL); | ||
| return typeof result === "string" ? result : normalize(targetURL); | ||
| } | ||
| exports.parseSourceMapInput = parseSourceMapInput; | ||
| exports.relative = relative; | ||
| function relativeIfPossible(rootURL, targetURL) { | ||
| const urlType = getURLType(rootURL); | ||
| if (urlType !== getURLType(targetURL)) { | ||
| return null; | ||
| } | ||
| const base = buildSafeBase(rootURL + targetURL); | ||
| const root = new URL(rootURL, base); | ||
| const target = new URL(targetURL, base); | ||
| try { | ||
| new URL("", target.toString()); | ||
| } catch (err) { | ||
| // Bail if the URL doesn't support things being relative to it, | ||
| // For example, data: and blob: URLs. | ||
| return null; | ||
| } | ||
| if ( | ||
| target.protocol !== root.protocol || | ||
| target.user !== root.user || | ||
| target.password !== root.password || | ||
| target.hostname !== root.hostname || | ||
| target.port !== root.port | ||
| ) { | ||
| return null; | ||
| } | ||
| return computeRelativeURL(root, target); | ||
| } | ||
| /** | ||
@@ -506,48 +420,32 @@ * Compute the URL of a source given the the source root, the source's | ||
| function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) { | ||
| sourceURL = sourceURL || ""; | ||
| if (sourceRoot) { | ||
| // This follows what Chrome does. | ||
| if (sourceRoot[sourceRoot.length - 1] !== "/" && sourceURL[0] !== "/") { | ||
| sourceRoot += "/"; | ||
| } | ||
| // The spec says: | ||
| // Line 4: An optional source root, useful for relocating source | ||
| // files on a server or removing repeated values in the | ||
| // “sources” entry. This value is prepended to the individual | ||
| // entries in the “source” field. | ||
| sourceURL = sourceRoot + sourceURL; | ||
| } | ||
| // Historically, SourceMapConsumer did not take the sourceMapURL as | ||
| // a parameter. This mode is still somewhat supported, which is why | ||
| // this code block is conditional. However, it's preferable to pass | ||
| // the source map URL to SourceMapConsumer, so that this function | ||
| // can implement the source URL resolution algorithm as outlined in | ||
| // the spec. This block is basically the equivalent of: | ||
| // new URL(sourceURL, sourceMapURL).toString() | ||
| // ... except it avoids using URL, which wasn't available in the | ||
| // older releases of node still supported by this library. | ||
| // The source map spec states that "sourceRoot" and "sources" entries are to be appended. While | ||
| // that is a little vague, implementations have generally interpreted that as joining the | ||
| // URLs with a `/` between then, assuming the "sourceRoot" doesn't already end with one. | ||
| // For example, | ||
| // | ||
| // The spec says: | ||
| // If the sources are not absolute URLs after prepending of the | ||
| // “sourceRoot”, the sources are resolved relative to the | ||
| // SourceMap (like resolving script src in a html document). | ||
| if (sourceMapURL) { | ||
| const parsed = urlParse(sourceMapURL); | ||
| if (!parsed) { | ||
| throw new Error("sourceMapURL could not be parsed"); | ||
| } | ||
| if (parsed.path) { | ||
| // Strip the last path component, but keep the "/". | ||
| const index = parsed.path.lastIndexOf("/"); | ||
| if (index >= 0) { | ||
| parsed.path = parsed.path.substring(0, index + 1); | ||
| } | ||
| } | ||
| sourceURL = join(urlGenerate(parsed), sourceURL); | ||
| // sourceRoot: "some-dir", | ||
| // sources: ["/some-path.js"] | ||
| // | ||
| // and | ||
| // | ||
| // sourceRoot: "some-dir/", | ||
| // sources: ["/some-path.js"] | ||
| // | ||
| // must behave as "some-dir/some-path.js". | ||
| // | ||
| // With this library's the transition to a more URL-focused implementation, that behavior is | ||
| // preserved here. To acheive that, we trim the "/" from absolute-path when a sourceRoot value | ||
| // is present in order to make the sources entries behave as if they are relative to the | ||
| // "sourceRoot", as they would have if the two strings were simply concated. | ||
| if (sourceRoot && getURLType(sourceURL) === "path-absolute") { | ||
| sourceURL = sourceURL.replace(/^\//, ""); | ||
| } | ||
| return normalize(sourceURL); | ||
| let url = normalize(sourceURL || ""); | ||
| // Parsing URLs can be expensive, so we only perform these joins when needed. | ||
| if (sourceRoot) url = join(sourceRoot, url); | ||
| if (sourceMapURL) url = join(trimFilename(sourceMapURL), url); | ||
| return url; | ||
| } | ||
| exports.computeSourceURL = computeSourceURL; |
+63
-32
@@ -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; | ||
| }; |
+21
-30
| { | ||
| "name": "source-map", | ||
| "description": "Generates and consumes source maps", | ||
| "version": "0.7.4", | ||
| "version": "0.7.5", | ||
| "homepage": "https://github.com/mozilla/source-map", | ||
@@ -51,42 +51,33 @@ "author": "Nick Fitzgerald <nfitzgerald@mozilla.com>", | ||
| "types": "./source-map.d.ts", | ||
| "browser": { | ||
| "./lib/read-wasm.js": "./lib/read-wasm-browser.js" | ||
| }, | ||
| "files": [ | ||
| "source-map.js", | ||
| "source-map.d.ts", | ||
| "lib/", | ||
| "dist/source-map.js" | ||
| "lib/" | ||
| ], | ||
| "publishConfig": { | ||
| "tag": "next" | ||
| }, | ||
| "engines": { | ||
| "node": ">= 8" | ||
| "node": ">= 12" | ||
| }, | ||
| "license": "BSD-3-Clause", | ||
| "scripts": { | ||
| "lint": "eslint *.js lib/ test/", | ||
| "prebuild": "npm run lint", | ||
| "build": "webpack --color", | ||
| "pretest": "npm run build", | ||
| "test": "node test/run-tests.js", | ||
| "precoverage": "npm run build", | ||
| "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", | ||
| "webpack": "^4.9.1", | ||
| "webpack-cli": "^3.1" | ||
| "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": {} | ||
| } |
+174
-159
| # Source Map | ||
| [](https://travis-ci.org/mozilla/source-map) | ||
| [](https://coveralls.io/github/mozilla/source-map) | ||
| [](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] } | ||
| ``` |
+323
-269
@@ -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; | ||
| /** | ||
| * 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; | ||
| /** | ||
| * 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; | ||
| /** | ||
| * Compute the last column for each generated mapping. The last column is | ||
| * inclusive. | ||
| */ | ||
| computeColumnSpans(): void; | ||
| /** | ||
| * 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 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 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 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; | ||
| /** | ||
| * Return true if we have the source content for every source in the source | ||
| * map, false otherwise. | ||
| */ | ||
| hasContentsOfAllSources(): boolean; | ||
| /** | ||
| * 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 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; | ||
| /** | ||
| * Return true if we have the source content for every source in the source | ||
| * map, false otherwise. | ||
| */ | ||
| hasContentsOfAllSources(): boolean; | ||
| /** | ||
| * 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; | ||
| /** | ||
| * 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; | ||
| } | ||
| 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>; | ||
| /** | ||
| * 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>; | ||
| /** | ||
| * 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; | ||
| } |
+5
-3
| /* | ||
| * 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; |
| !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("fs"),require("path")):"function"==typeof define&&define.amd?define(["fs","path"],n):"object"==typeof exports?exports.sourceMap=n(require("fs"),require("path")):e.sourceMap=n(e.fs,e.path)}(window,(function(e,n){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=5)}([function(e,n){n.getArg=function(e,n,t){if(n in e)return e[n];if(3===arguments.length)return t;throw new Error('"'+n+'" is a required argument.')};const t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,r=/^data:.+\,.+$/;function o(e){const n=e.match(t);return n?{scheme:n[1],auth:n[2],host:n[3],port:n[4],path:n[5]}:null}function i(e){let n="";return e.scheme&&(n+=e.scheme+":"),n+="//",e.auth&&(n+=e.auth+"@"),e.host&&(n+=e.host),e.port&&(n+=":"+e.port),e.path&&(n+=e.path),n}n.urlParse=o,n.urlGenerate=i;const s=function(e){const n=[];return function(t){for(let e=0;e<n.length;e++)if(n[e].input===t){const t=n[0];return n[0]=n[e],n[e]=t,n[0].result}const r=e(t);return n.unshift({input:t,result:r}),n.length>32&&n.pop(),r}}((function(e){let t=e;const r=o(e);if(r){if(!r.path)return e;t=r.path}const s=n.isAbsolute(t),l=[];let a=0,u=0;for(;;){if(a=u,u=t.indexOf("/",a),-1===u){l.push(t.slice(a));break}for(l.push(t.slice(a,u));u<t.length&&"/"===t[u];)u++}let c=0;for(u=l.length-1;u>=0;u--){const e=l[u];"."===e?l.splice(u,1):".."===e?c++:c>0&&(""===e?(l.splice(u+1,c),c=0):(l.splice(u,2),c--))}return t=l.join("/"),""===t&&(t=s?"/":"."),r?(r.path=t,i(r)):t}));function l(e,n){""===e&&(e="."),""===n&&(n=".");const t=o(n),l=o(e);if(l&&(e=l.path||"/"),t&&!t.scheme)return l&&(t.scheme=l.scheme),i(t);if(t||n.match(r))return n;if(l&&!l.host&&!l.path)return l.host=n,i(l);const a="/"===n.charAt(0)?n:s(e.replace(/\/+$/,"")+"/"+n);return l?(l.path=a,i(l)):a}n.normalize=s,n.join=l,n.isAbsolute=function(e){return"/"===e.charAt(0)||t.test(e)},n.relative=function(e,n){""===e&&(e="."),e=e.replace(/\/$/,"");let t=0;for(;0!==n.indexOf(e+"/");){const r=e.lastIndexOf("/");if(r<0)return n;if((e=e.slice(0,r)).match(/^([^\/]+:\/)?\/*$/))return n;++t}return Array(t+1).join("../")+n.substr(e.length+1)};const a=!("__proto__"in Object.create(null));function u(e){return e}function c(e){if(!e)return!1;const n=e.length;if(n<9)return!1;if(95!==e.charCodeAt(n-1)||95!==e.charCodeAt(n-2)||111!==e.charCodeAt(n-3)||116!==e.charCodeAt(n-4)||111!==e.charCodeAt(n-5)||114!==e.charCodeAt(n-6)||112!==e.charCodeAt(n-7)||95!==e.charCodeAt(n-8)||95!==e.charCodeAt(n-9))return!1;for(let t=n-10;t>=0;t--)if(36!==e.charCodeAt(t))return!1;return!0}function g(e,n){return e===n?0:null===e?1:null===n?-1:e>n?1:-1}n.toSetString=a?u:function(e){return c(e)?"$"+e:e},n.fromSetString=a?u:function(e){return c(e)?e.slice(1):e},n.compareByOriginalPositions=function(e,n,t){let r=g(e.source,n.source);return 0!==r?r:(r=e.originalLine-n.originalLine,0!==r?r:(r=e.originalColumn-n.originalColumn,0!==r||t?r:(r=e.generatedColumn-n.generatedColumn,0!==r?r:(r=e.generatedLine-n.generatedLine,0!==r?r:g(e.name,n.name)))))},n.compareByGeneratedPositionsDeflated=function(e,n,t){let r=e.generatedLine-n.generatedLine;return 0!==r?r:(r=e.generatedColumn-n.generatedColumn,0!==r||t?r:(r=g(e.source,n.source),0!==r?r:(r=e.originalLine-n.originalLine,0!==r?r:(r=e.originalColumn-n.originalColumn,0!==r?r:g(e.name,n.name)))))},n.compareByGeneratedPositionsInflated=function(e,n){let t=e.generatedLine-n.generatedLine;return 0!==t?t:(t=e.generatedColumn-n.generatedColumn,0!==t?t:(t=g(e.source,n.source),0!==t?t:(t=e.originalLine-n.originalLine,0!==t?t:(t=e.originalColumn-n.originalColumn,0!==t?t:g(e.name,n.name)))))},n.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},n.computeSourceURL=function(e,n,t){if(n=n||"",e&&("/"!==e[e.length-1]&&"/"!==n[0]&&(e+="/"),n=e+n),t){const e=o(t);if(!e)throw new Error("sourceMapURL could not be parsed");if(e.path){const n=e.path.lastIndexOf("/");n>=0&&(e.path=e.path.substring(0,n+1))}n=l(i(e),n)}return s(n)}},function(e,n,t){const r=t(2),o=t(0),i=t(3).ArraySet,s=t(7).MappingList;class l{constructor(e){e||(e={}),this._file=o.getArg(e,"file",null),this._sourceRoot=o.getArg(e,"sourceRoot",null),this._skipValidation=o.getArg(e,"skipValidation",!1),this._sources=new i,this._names=new i,this._mappings=new s,this._sourcesContents=null}static fromSourceMap(e){const n=e.sourceRoot,t=new l({file:e.file,sourceRoot:n});return e.eachMapping((function(e){const r={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(r.source=e.source,null!=n&&(r.source=o.relative(n,r.source)),r.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(r.name=e.name)),t.addMapping(r)})),e.sources.forEach((function(r){let i=r;null!==n&&(i=o.relative(n,r)),t._sources.has(i)||t._sources.add(i);const s=e.sourceContentFor(r);null!=s&&t.setSourceContent(r,s)})),t}addMapping(e){const n=o.getArg(e,"generated"),t=o.getArg(e,"original",null);let r=o.getArg(e,"source",null),i=o.getArg(e,"name",null);this._skipValidation||this._validateMapping(n,t,r,i),null!=r&&(r=String(r),this._sources.has(r)||this._sources.add(r)),null!=i&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:n.line,generatedColumn:n.column,originalLine:null!=t&&t.line,originalColumn:null!=t&&t.column,source:r,name:i})}setSourceContent(e,n){let t=e;null!=this._sourceRoot&&(t=o.relative(this._sourceRoot,t)),null!=n?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[o.toSetString(t)]=n):this._sourcesContents&&(delete this._sourcesContents[o.toSetString(t)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))}applySourceMap(e,n,t){let r=n;if(null==n){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');r=e.file}const s=this._sourceRoot;null!=s&&(r=o.relative(s,r));const l=this._mappings.toArray().length>0?new i:this._sources,a=new i;this._mappings.unsortedForEach((function(n){if(n.source===r&&null!=n.originalLine){const r=e.originalPositionFor({line:n.originalLine,column:n.originalColumn});null!=r.source&&(n.source=r.source,null!=t&&(n.source=o.join(t,n.source)),null!=s&&(n.source=o.relative(s,n.source)),n.originalLine=r.line,n.originalColumn=r.column,null!=r.name&&(n.name=r.name))}const i=n.source;null==i||l.has(i)||l.add(i);const u=n.name;null==u||a.has(u)||a.add(u)}),this),this._sources=l,this._names=a,e.sources.forEach((function(n){const r=e.sourceContentFor(n);null!=r&&(null!=t&&(n=o.join(t,n)),null!=s&&(n=o.relative(s,n)),this.setSourceContent(n,r))}),this)}_validateMapping(e,n,t,r){if(n&&"number"!=typeof n.line&&"number"!=typeof n.column)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(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!n&&!t&&!r);else if(!(e&&"line"in e&&"column"in e&&n&&"line"in n&&"column"in n&&e.line>0&&e.column>=0&&n.line>0&&n.column>=0&&t))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:t,original:n,name:r}))}_serializeMappings(){let e,n,t,i,s=0,l=1,a=0,u=0,c=0,g=0,p="";const h=this._mappings.toArray();for(let m=0,d=h.length;m<d;m++){if(n=h[m],e="",n.generatedLine!==l)for(s=0;n.generatedLine!==l;)e+=";",l++;else if(m>0){if(!o.compareByGeneratedPositionsInflated(n,h[m-1]))continue;e+=","}e+=r.encode(n.generatedColumn-s),s=n.generatedColumn,null!=n.source&&(i=this._sources.indexOf(n.source),e+=r.encode(i-g),g=i,e+=r.encode(n.originalLine-1-u),u=n.originalLine-1,e+=r.encode(n.originalColumn-a),a=n.originalColumn,null!=n.name&&(t=this._names.indexOf(n.name),e+=r.encode(t-c),c=t)),p+=e}return p}_generateSourcesContent(e,n){return e.map((function(e){if(!this._sourcesContents)return null;null!=n&&(e=o.relative(n,e));const t=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,t)?this._sourcesContents[t]:null}),this)}toJSON(){const e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e}toString(){return JSON.stringify(this.toJSON())}}l.prototype._version=3,n.SourceMapGenerator=l},function(e,n,t){const r=t(6);n.encode=function(e){let n,t="",o=function(e){return e<0?1+(-e<<1):0+(e<<1)}(e);do{n=31&o,o>>>=5,o>0&&(n|=32),t+=r.encode(n)}while(o>0);return t}},function(e,n){class t{constructor(){this._array=[],this._set=new Map}static fromArray(e,n){const r=new t;for(let t=0,o=e.length;t<o;t++)r.add(e[t],n);return r}size(){return this._set.size}add(e,n){const t=this.has(e),r=this._array.length;t&&!n||this._array.push(e),t||this._set.set(e,r)}has(e){return this._set.has(e)}indexOf(e){const n=this._set.get(e);if(n>=0)return n;throw new Error('"'+e+'" is not in the set.')}at(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)}toArray(){return this._array.slice()}}n.ArraySet=t},function(e,n,t){(function(n){if(function(){return"undefined"!=typeof window&&this===window}.call()){let n=null;e.exports=function(){if("string"==typeof n)return fetch(n).then(e=>e.arrayBuffer());if(n instanceof ArrayBuffer)return Promise.resolve(n);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")},e.exports.initialize=e=>n=e}else{const r=t(10),o=t(11);e.exports=function(){return new Promise((e,t)=>{const i=o.join(n,"mappings.wasm");r.readFile(i,null,(n,r)=>{n?t(n):e(r.buffer)})})},e.exports.initialize=e=>{console.debug("SourceMapConsumer.initialize is a no-op when running in node.js")}}}).call(this,"/")},function(e,n,t){n.SourceMapGenerator=t(1).SourceMapGenerator,n.SourceMapConsumer=t(8).SourceMapConsumer,n.SourceNode=t(13).SourceNode},function(e,n){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");n.encode=function(e){if(0<=e&&e<t.length)return t[e];throw new TypeError("Must be between 0 and 63: "+e)}},function(e,n,t){const r=t(0);n.MappingList=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(e,n){this._array.forEach(e,n)}add(e){!function(e,n){const t=e.generatedLine,o=n.generatedLine,i=e.generatedColumn,s=n.generatedColumn;return o>t||o==t&&s>=i||r.compareByGeneratedPositionsInflated(e,n)<=0}(this._last,e)?(this._sorted=!1,this._array.push(e)):(this._last=e,this._array.push(e))}toArray(){return this._sorted||(this._array.sort(r.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}}},function(e,n,t){const r=t(0),o=t(9),i=t(3).ArraySet,s=(t(2),t(4)),l=t(12),a=Symbol("smcInternal");class u{constructor(e,n){return e==a?Promise.resolve(this):function(e,n){let t=e;"string"==typeof e&&(t=r.parseSourceMapInput(e));const o=null!=t.sections?new g(t,n):new c(t,n);return Promise.resolve(o)}(e,n)}static initialize(e){s.initialize(e["lib/mappings.wasm"])}static fromSourceMap(e,n){return function(e,n){return c.fromSourceMap(e,n)}(e,n)}static async with(e,n,t){const r=await new u(e,n);try{return await t(r)}finally{r.destroy()}}_parseMappings(e,n){throw new Error("Subclasses must implement _parseMappings")}eachMapping(e,n,t){throw new Error("Subclasses must implement eachMapping")}allGeneratedPositionsFor(e){throw new Error("Subclasses must implement allGeneratedPositionsFor")}destroy(){throw new Error("Subclasses must implement destroy")}}u.prototype._version=3,u.GENERATED_ORDER=1,u.ORIGINAL_ORDER=2,u.GREATEST_LOWER_BOUND=1,u.LEAST_UPPER_BOUND=2,n.SourceMapConsumer=u;class c extends u{constructor(e,n){return super(a).then(t=>{let o=e;"string"==typeof e&&(o=r.parseSourceMapInput(e));const s=r.getArg(o,"version");let a=r.getArg(o,"sources");const u=r.getArg(o,"names",[]);let c=r.getArg(o,"sourceRoot",null);const g=r.getArg(o,"sourcesContent",null),p=r.getArg(o,"mappings"),h=r.getArg(o,"file",null);if(s!=t._version)throw new Error("Unsupported version: "+s);return c&&(c=r.normalize(c)),a=a.map(String).map(r.normalize).map((function(e){return c&&r.isAbsolute(c)&&r.isAbsolute(e)?r.relative(c,e):e})),t._names=i.fromArray(u.map(String),!0),t._sources=i.fromArray(a,!0),t._absoluteSources=t._sources.toArray().map((function(e){return r.computeSourceURL(c,e,n)})),t.sourceRoot=c,t.sourcesContent=g,t._mappings=p,t._sourceMapURL=n,t.file=h,t._computedColumnSpans=!1,t._mappingsPtr=0,t._wasm=null,l().then(e=>(t._wasm=e,t))})}_findSourceIndex(e){let n=e;if(null!=this.sourceRoot&&(n=r.relative(this.sourceRoot,n)),this._sources.has(n))return this._sources.indexOf(n);for(let n=0;n<this._absoluteSources.length;++n)if(this._absoluteSources[n]==e)return n;return-1}static fromSourceMap(e,n){return new c(e.toString())}get sources(){return this._absoluteSources.slice()}_getMappingsPtr(){return 0===this._mappingsPtr&&this._parseMappings(this._mappings,this.sourceRoot),this._mappingsPtr}_parseMappings(e,n){const t=e.length,r=this._wasm.exports.allocate_mappings(t),o=new Uint8Array(this._wasm.exports.memory.buffer,r,t);for(let n=0;n<t;n++)o[n]=e.charCodeAt(n);const i=this._wasm.exports.parse_mappings(r);if(!i){const e=this._wasm.exports.get_last_error();let n=`Error parsing mappings (code ${e}): `;switch(e){case 1:n+="the mappings contained a negative line, column, source index, or name index";break;case 2:n+="the mappings contained a number larger than 2**32";break;case 3:n+="reached EOF while in the middle of parsing a VLQ";break;case 4:n+="invalid base 64 character while parsing a VLQ";break;default:n+="unknown error code"}throw new Error(n)}this._mappingsPtr=i}eachMapping(e,n,t){const o=n||null,i=t||u.GENERATED_ORDER,s=this.sourceRoot;this._wasm.withMappingCallback(n=>{null!==n.source&&(n.source=this._sources.at(n.source),n.source=r.computeSourceURL(s,n.source,this._sourceMapURL),null!==n.name&&(n.name=this._names.at(n.name))),e.call(o,n)},()=>{switch(i){case u.GENERATED_ORDER:this._wasm.exports.by_generated_location(this._getMappingsPtr());break;case u.ORIGINAL_ORDER:this._wasm.exports.by_original_location(this._getMappingsPtr());break;default:throw new Error("Unknown order of iteration.")}})}allGeneratedPositionsFor(e){let n=r.getArg(e,"source");const t=r.getArg(e,"line"),o=e.column||0;if(n=this._findSourceIndex(n),n<0)return[];if(t<1)throw new Error("Line numbers must be >= 1");if(o<0)throw new Error("Column numbers must be >= 0");const i=[];return this._wasm.withMappingCallback(e=>{let n=e.lastGeneratedColumn;this._computedColumnSpans&&null===n&&(n=1/0),i.push({line:e.generatedLine,column:e.generatedColumn,lastColumn:n})},()=>{this._wasm.exports.all_generated_locations_for(this._getMappingsPtr(),n,t-1,"column"in e,o)}),i}destroy(){0!==this._mappingsPtr&&(this._wasm.exports.free_mappings(this._mappingsPtr),this._mappingsPtr=0)}computeColumnSpans(){this._computedColumnSpans||(this._wasm.exports.compute_column_spans(this._getMappingsPtr()),this._computedColumnSpans=!0)}originalPositionFor(e){const n={generatedLine:r.getArg(e,"line"),generatedColumn:r.getArg(e,"column")};if(n.generatedLine<1)throw new Error("Line numbers must be >= 1");if(n.generatedColumn<0)throw new Error("Column numbers must be >= 0");let t,o=r.getArg(e,"bias",u.GREATEST_LOWER_BOUND);if(null==o&&(o=u.GREATEST_LOWER_BOUND),this._wasm.withMappingCallback(e=>t=e,()=>{this._wasm.exports.original_location_for(this._getMappingsPtr(),n.generatedLine-1,n.generatedColumn,o)}),t&&t.generatedLine===n.generatedLine){let e=r.getArg(t,"source",null);null!==e&&(e=this._sources.at(e),e=r.computeSourceURL(this.sourceRoot,e,this._sourceMapURL));let n=r.getArg(t,"name",null);return null!==n&&(n=this._names.at(n)),{source:e,line:r.getArg(t,"originalLine",null),column:r.getArg(t,"originalColumn",null),name:n}}return{source:null,line:null,column:null,name:null}}hasContentsOfAllSources(){return!!this.sourcesContent&&(this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some((function(e){return null==e})))}sourceContentFor(e,n){if(!this.sourcesContent)return null;const t=this._findSourceIndex(e);if(t>=0)return this.sourcesContent[t];let o,i=e;if(null!=this.sourceRoot&&(i=r.relative(this.sourceRoot,i)),null!=this.sourceRoot&&(o=r.urlParse(this.sourceRoot))){const e=i.replace(/^file:\/\//,"");if("file"==o.scheme&&this._sources.has(e))return this.sourcesContent[this._sources.indexOf(e)];if((!o.path||"/"==o.path)&&this._sources.has("/"+i))return this.sourcesContent[this._sources.indexOf("/"+i)]}if(n)return null;throw new Error('"'+i+'" is not in the SourceMap.')}generatedPositionFor(e){let n=r.getArg(e,"source");if(n=this._findSourceIndex(n),n<0)return{line:null,column:null,lastColumn:null};const t={source:n,originalLine:r.getArg(e,"line"),originalColumn:r.getArg(e,"column")};if(t.originalLine<1)throw new Error("Line numbers must be >= 1");if(t.originalColumn<0)throw new Error("Column numbers must be >= 0");let o,i=r.getArg(e,"bias",u.GREATEST_LOWER_BOUND);if(null==i&&(i=u.GREATEST_LOWER_BOUND),this._wasm.withMappingCallback(e=>o=e,()=>{this._wasm.exports.generated_location_for(this._getMappingsPtr(),t.source,t.originalLine-1,t.originalColumn,i)}),o&&o.source===t.source){let e=o.lastGeneratedColumn;return this._computedColumnSpans&&null===e&&(e=1/0),{line:r.getArg(o,"generatedLine",null),column:r.getArg(o,"generatedColumn",null),lastColumn:e}}return{line:null,column:null,lastColumn:null}}}c.prototype.consumer=u,n.BasicSourceMapConsumer=c;class g extends u{constructor(e,n){return super(a).then(t=>{let o=e;"string"==typeof e&&(o=r.parseSourceMapInput(e));const s=r.getArg(o,"version"),l=r.getArg(o,"sections");if(s!=t._version)throw new Error("Unsupported version: "+s);t._sources=new i,t._names=new i,t.__generatedMappings=null,t.__originalMappings=null,t.__generatedMappingsUnsorted=null,t.__originalMappingsUnsorted=null;let a={line:-1,column:0};return Promise.all(l.map(e=>{if(e.url)throw new Error("Support for url field in sections not implemented.");const t=r.getArg(e,"offset"),o=r.getArg(t,"line"),i=r.getArg(t,"column");if(o<a.line||o===a.line&&i<a.column)throw new Error("Section offsets must be ordered and non-overlapping.");a=t;return new u(r.getArg(e,"map"),n).then(e=>({generatedOffset:{generatedLine:o+1,generatedColumn:i+1},consumer:e}))})).then(e=>(t._sections=e,t))})}get _generatedMappings(){return this.__generatedMappings||this._sortGeneratedMappings(),this.__generatedMappings}get _originalMappings(){return this.__originalMappings||this._sortOriginalMappings(),this.__originalMappings}get _generatedMappingsUnsorted(){return this.__generatedMappingsUnsorted||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappingsUnsorted}get _originalMappingsUnsorted(){return this.__originalMappingsUnsorted||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappingsUnsorted}_sortGeneratedMappings(){const e=this._generatedMappingsUnsorted;e.sort(r.compareByGeneratedPositionsDeflated),this.__generatedMappings=e}_sortOriginalMappings(){const e=this._originalMappingsUnsorted;e.sort(r.compareByOriginalPositions),this.__originalMappings=e}get sources(){const e=[];for(let n=0;n<this._sections.length;n++)for(let t=0;t<this._sections[n].consumer.sources.length;t++)e.push(this._sections[n].consumer.sources[t]);return e}originalPositionFor(e){const n={generatedLine:r.getArg(e,"line"),generatedColumn:r.getArg(e,"column")},t=o.search(n,this._sections,(function(e,n){const t=e.generatedLine-n.generatedOffset.generatedLine;return t||e.generatedColumn-n.generatedOffset.generatedColumn})),i=this._sections[t];return i?i.consumer.originalPositionFor({line:n.generatedLine-(i.generatedOffset.generatedLine-1),column:n.generatedColumn-(i.generatedOffset.generatedLine===n.generatedLine?i.generatedOffset.generatedColumn-1:0),bias:e.bias}):{source:null,line:null,column:null,name:null}}hasContentsOfAllSources(){return this._sections.every((function(e){return e.consumer.hasContentsOfAllSources()}))}sourceContentFor(e,n){for(let n=0;n<this._sections.length;n++){const t=this._sections[n].consumer.sourceContentFor(e,!0);if(t)return t}if(n)return null;throw new Error('"'+e+'" is not in the SourceMap.')}generatedPositionFor(e){for(let n=0;n<this._sections.length;n++){const t=this._sections[n];if(-1===t.consumer._findSourceIndex(r.getArg(e,"source")))continue;const o=t.consumer.generatedPositionFor(e);if(o){return{line:o.line+(t.generatedOffset.generatedLine-1),column:o.column+(t.generatedOffset.generatedLine===o.line?t.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}}_parseMappings(e,n){const t=this.__generatedMappingsUnsorted=[],o=this.__originalMappingsUnsorted=[];for(let e=0;e<this._sections.length;e++){const n=this._sections[e],i=[];n.consumer.eachMapping(e=>i.push(e));for(let e=0;e<i.length;e++){const s=i[e];let l=r.computeSourceURL(n.consumer.sourceRoot,null,this._sourceMapURL);this._sources.add(l),l=this._sources.indexOf(l);let a=null;s.name&&(this._names.add(s.name),a=this._names.indexOf(s.name));const u={source:l,generatedLine:s.generatedLine+(n.generatedOffset.generatedLine-1),generatedColumn:s.generatedColumn+(n.generatedOffset.generatedLine===s.generatedLine?n.generatedOffset.generatedColumn-1:0),originalLine:s.originalLine,originalColumn:s.originalColumn,name:a};t.push(u),"number"==typeof u.originalLine&&o.push(u)}}}eachMapping(e,n,t){const o=n||null;let i;switch(t||u.GENERATED_ORDER){case u.GENERATED_ORDER:i=this._generatedMappings;break;case u.ORIGINAL_ORDER:i=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}const s=this.sourceRoot;i.map((function(e){let n=null;return null!==e.source&&(n=this._sources.at(e.source),n=r.computeSourceURL(s,n,this._sourceMapURL)),{source:n,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:null===e.name?null:this._names.at(e.name)}}),this).forEach(e,o)}_findMapping(e,n,t,r,i,s){if(e[t]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[t]);if(e[r]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[r]);return o.search(e,n,i,s)}allGeneratedPositionsFor(e){const n=r.getArg(e,"line"),t={source:r.getArg(e,"source"),originalLine:n,originalColumn:r.getArg(e,"column",0)};if(t.source=this._findSourceIndex(t.source),t.source<0)return[];if(t.originalLine<1)throw new Error("Line numbers must be >= 1");if(t.originalColumn<0)throw new Error("Column numbers must be >= 0");const i=[];let s=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",r.compareByOriginalPositions,o.LEAST_UPPER_BOUND);if(s>=0){let t=this._originalMappings[s];if(void 0===e.column){const e=t.originalLine;for(;t&&t.originalLine===e;){let e=t.lastGeneratedColumn;this._computedColumnSpans&&null===e&&(e=1/0),i.push({line:r.getArg(t,"generatedLine",null),column:r.getArg(t,"generatedColumn",null),lastColumn:e}),t=this._originalMappings[++s]}}else{const e=t.originalColumn;for(;t&&t.originalLine===n&&t.originalColumn==e;){let e=t.lastGeneratedColumn;this._computedColumnSpans&&null===e&&(e=1/0),i.push({line:r.getArg(t,"generatedLine",null),column:r.getArg(t,"generatedColumn",null),lastColumn:e}),t=this._originalMappings[++s]}}}return i}destroy(){for(let e=0;e<this._sections.length;e++)this._sections[e].consumer.destroy()}}n.IndexedSourceMapConsumer=g},function(e,n){n.GREATEST_LOWER_BOUND=1,n.LEAST_UPPER_BOUND=2,n.search=function(e,t,r,o){if(0===t.length)return-1;let i=function e(t,r,o,i,s,l){const a=Math.floor((r-t)/2)+t,u=s(o,i[a],!0);return 0===u?a:u>0?r-a>1?e(a,r,o,i,s,l):l==n.LEAST_UPPER_BOUND?r<i.length?r:-1:a:a-t>1?e(t,a,o,i,s,l):l==n.LEAST_UPPER_BOUND?a:t<0?-1:t}(-1,t.length,e,t,r,o||n.GREATEST_LOWER_BOUND);if(i<0)return-1;for(;i-1>=0&&0===r(t[i],t[i-1],!0);)--i;return i}},function(n,t){n.exports=e},function(e,t){e.exports=n},function(e,n,t){const r=t(4);function o(){this.generatedLine=0,this.generatedColumn=0,this.lastGeneratedColumn=null,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}let i=null;e.exports=function(){if(i)return i;const e=[];return i=r().then(n=>WebAssembly.instantiate(n,{env:{mapping_callback(n,t,r,i,s,l,a,u,c,g){const p=new o;p.generatedLine=n+1,p.generatedColumn=t,r&&(p.lastGeneratedColumn=i-1),s&&(p.source=l,p.originalLine=a+1,p.originalColumn=u,c&&(p.name=g)),e[e.length-1](p)},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_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_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_original_location(){console.time("sort_by_original_location")},end_sort_by_original_location(){console.timeEnd("sort_by_original_location")}}})).then(n=>({exports:n.instance.exports,withMappingCallback:(n,t)=>{e.push(n);try{t()}finally{e.pop()}}})).then(null,e=>{throw i=null,e}),i}},function(e,n,t){const r=t(1).SourceMapGenerator,o=t(0),i=/(\r?\n)/,s="$$$isSourceNode$$$";class l{constructor(e,n,t,r,o){this.children=[],this.sourceContents={},this.line=null==e?null:e,this.column=null==n?null:n,this.source=null==t?null:t,this.name=null==o?null:o,this[s]=!0,null!=r&&this.add(r)}static fromStringWithSourceMap(e,n,t){const r=new l,s=e.split(i);let a=0;const u=function(){return e()+(e()||"");function e(){return a<s.length?s[a++]:void 0}};let c,g=1,p=0,h=null;return n.eachMapping((function(e){if(null!==h){if(!(g<e.generatedLine)){c=s[a]||"";const n=c.substr(0,e.generatedColumn-p);return s[a]=c.substr(e.generatedColumn-p),p=e.generatedColumn,m(h,n),void(h=e)}m(h,u()),g++,p=0}for(;g<e.generatedLine;)r.add(u()),g++;p<e.generatedColumn&&(c=s[a]||"",r.add(c.substr(0,e.generatedColumn)),s[a]=c.substr(e.generatedColumn),p=e.generatedColumn),h=e}),this),a<s.length&&(h&&m(h,u()),r.add(s.splice(a).join(""))),n.sources.forEach((function(e){const i=n.sourceContentFor(e);null!=i&&(null!=t&&(e=o.join(t,e)),r.setSourceContent(e,i))})),r;function m(e,n){if(null===e||void 0===e.source)r.add(n);else{const i=t?o.join(t,e.source):e.source;r.add(new l(e.originalLine,e.originalColumn,i,n,e.name))}}}add(e){if(Array.isArray(e))e.forEach((function(e){this.add(e)}),this);else{if(!e[s]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);e&&this.children.push(e)}return this}prepend(e){if(Array.isArray(e))for(let n=e.length-1;n>=0;n--)this.prepend(e[n]);else{if(!e[s]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this}walk(e){let n;for(let t=0,r=this.children.length;t<r;t++)n=this.children[t],n[s]?n.walk(e):""!==n&&e(n,{source:this.source,line:this.line,column:this.column,name:this.name})}join(e){let n,t;const r=this.children.length;if(r>0){for(n=[],t=0;t<r-1;t++)n.push(this.children[t]),n.push(e);n.push(this.children[t]),this.children=n}return this}replaceRight(e,n){const t=this.children[this.children.length-1];return t[s]?t.replaceRight(e,n):"string"==typeof t?this.children[this.children.length-1]=t.replace(e,n):this.children.push("".replace(e,n)),this}setSourceContent(e,n){this.sourceContents[o.toSetString(e)]=n}walkSourceContents(e){for(let n=0,t=this.children.length;n<t;n++)this.children[n][s]&&this.children[n].walkSourceContents(e);const n=Object.keys(this.sourceContents);for(let t=0,r=n.length;t<r;t++)e(o.fromSetString(n[t]),this.sourceContents[n[t]])}toString(){let e="";return this.walk((function(n){e+=n})),e}toStringWithSourceMap(e){const n={code:"",line:1,column:0},t=new r(e);let o=!1,i=null,s=null,l=null,a=null;return this.walk((function(e,r){n.code+=e,null!==r.source&&null!==r.line&&null!==r.column?(i===r.source&&s===r.line&&l===r.column&&a===r.name||t.addMapping({source:r.source,original:{line:r.line,column:r.column},generated:{line:n.line,column:n.column},name:r.name}),i=r.source,s=r.line,l=r.column,a=r.name,o=!0):o&&(t.addMapping({generated:{line:n.line,column:n.column}}),i=null,o=!1);for(let s=0,l=e.length;s<l;s++)10===e.charCodeAt(s)?(n.line++,n.column=0,s+1===l?(i=null,o=!1):o&&t.addMapping({source:r.source,original:{line:r.line,column:r.column},generated:{line:n.line,column:n.column},name:r.name})):n.column++})),this.walkSourceContents((function(e,n){t.setSourceContent(e,n)})),{code:n.code,map:t}}}n.SourceNode=l}])})); |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
5
-37.5%19
5.56%1
-50%838
1.82%1
-66.67%2
-33.33%185672
-17.84%3074
-2.63%