UNPKG

next

Version:

The React Framework

1,571 lines (1,380 loc) • 94.1 kB
/******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 963: /***/ ((__unused_webpack_module, exports) => { /* -*- 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 */ /** * A data structure which is a combination of an array and a set. Adding a new * member is O(1), testing for membership is O(1), and finding the index of an * element is O(1). Removing elements from the set is not supported. Only * strings are supported for membership. */ class ArraySet { constructor() { this._array = []; this._set = new Map(); } /** * Static method for creating ArraySet instances from an existing array. */ static fromArray(aArray, aAllowDuplicates) { const set = new ArraySet(); for (let i = 0, len = aArray.length; i < len; i++) { set.add(aArray[i], aAllowDuplicates); } return set; } /** * Return how many unique items are in this ArraySet. If duplicates have been * added, than those do not count towards the size. * * @returns Number */ size() { return this._set.size; } /** * Add the given string to this set. * * @param String aStr */ add(aStr, aAllowDuplicates) { const isDuplicate = this.has(aStr); const idx = this._array.length; if (!isDuplicate || aAllowDuplicates) { this._array.push(aStr); } if (!isDuplicate) { this._set.set(aStr, idx); } } /** * Is the given string a member of this set? * * @param String aStr */ has(aStr) { return this._set.has(aStr); } /** * What is the index of the given string in the array? * * @param String aStr */ indexOf(aStr) { const idx = this._set.get(aStr); if (idx >= 0) { return idx; } throw new Error('"' + aStr + '" is not in the set.'); } /** * What is the element at the given index? * * @param Number aIdx */ at(aIdx) { if (aIdx >= 0 && aIdx < this._array.length) { return this._array[aIdx]; } throw new Error("No element indexed by " + aIdx); } /** * Returns the array representation of this set (which has the proper indices * indicated by indexOf). Note that this is a copy of the internal array used * for storing the members so that no one can mess with internal state. */ toArray() { return this._array.slice(); } } exports.I = ArraySet; /***/ }), /***/ 344: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { /* -*- 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 * * Based on the Base 64 VLQ implementation in Closure Compiler: * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java * * Copyright 2011 The Closure Compiler Authors. All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ const base64 = __nccwpck_require__(209); // A single base 64 digit can contain 6 bits of data. For the base 64 variable // length quantities we use in the source map spec, the first bit is the sign, // the next four bits are the actual value, and the 6th bit is the // continuation bit. The continuation bit tells us whether there are more // digits in this value following this digit. // // Continuation // | Sign // | | // V V // 101011 const VLQ_BASE_SHIFT = 5; // binary: 100000 const VLQ_BASE = 1 << VLQ_BASE_SHIFT; // binary: 011111 const VLQ_BASE_MASK = VLQ_BASE - 1; // binary: 100000 const VLQ_CONTINUATION_BIT = VLQ_BASE; /** * Converts from a two-complement value to a value where the sign bit is * placed in the least significant bit. For example, as decimals: * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) */ function toVLQSigned(aValue) { 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. */ exports.encode = function base64VLQ_encode(aValue) { let encoded = ""; let digit; let vlq = toVLQSigned(aValue); do { digit = vlq & VLQ_BASE_MASK; vlq >>>= VLQ_BASE_SHIFT; if (vlq > 0) { // There are still more digits in this value, so we must make sure the // continuation bit is marked. digit |= VLQ_CONTINUATION_BIT; } encoded += base64.encode(digit); } while (vlq > 0); return encoded; }; /***/ }), /***/ 209: /***/ ((__unused_webpack_module, exports) => { /* -*- 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 */ const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""); /** * Encode an integer in the range of 0 to 63 to a single base 64 digit. */ exports.encode = function(number) { if (0 <= number && number < intToCharMap.length) { return intToCharMap[number]; } throw new TypeError("Must be between 0 and 63: " + number); }; /***/ }), /***/ 700: /***/ ((__unused_webpack_module, exports) => { /* -*- 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 */ exports.GREATEST_LOWER_BOUND = 1; exports.LEAST_UPPER_BOUND = 2; /** * Recursive implementation of binary search. * * @param aLow Indices here and lower do not contain the needle. * @param aHigh Indices here and higher do not contain the needle. * @param aNeedle The element being searched for. * @param aHaystack The non-empty array being searched. * @param aCompare Function which takes two elements and returns -1, 0, or 1. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or * 'binarySearch.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. */ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) { // This function terminates when one of the following is true: // // 1. We find the exact element we are looking for. // // 2. We did not find the exact element, but we can return the index of // the next-closest element. // // 3. We did not find the exact element, and there is no next-closest // element than the one we are searching for, so we return -1. const mid = Math.floor((aHigh - aLow) / 2) + aLow; const cmp = aCompare(aNeedle, aHaystack[mid], true); if (cmp === 0) { // Found the element we are looking for. return mid; } else if (cmp > 0) { // Our needle is greater than aHaystack[mid]. if (aHigh - mid > 1) { // The element is in the upper half. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias); } // The exact needle element was not found in this haystack. Determine if // we are in termination case (3) or (2) and return the appropriate thing. if (aBias == exports.LEAST_UPPER_BOUND) { return aHigh < aHaystack.length ? aHigh : -1; } return mid; } // Our needle is less than aHaystack[mid]. if (mid - aLow > 1) { // The element is in the lower half. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias); } // we are in termination case (3) or (2) and return the appropriate thing. if (aBias == exports.LEAST_UPPER_BOUND) { return mid; } return aLow < 0 ? -1 : aLow; } /** * This is an implementation of binary search which will always try and return * the index of the closest element if there is no exact hit. This is because * mappings between original and generated line/col pairs are single points, * and there is an implicit region between each of them, so a miss just means * that you aren't on the very start of a region. * * @param aNeedle The element you are looking for. * @param aHaystack The array that is being searched. * @param aCompare A function which takes the needle and an element in the * array and returns -1, 0, or 1 depending on whether the needle is less * than, equal to, or greater than the element, respectively. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or * 'binarySearch.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 'binarySearch.GREATEST_LOWER_BOUND'. */ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { if (aHaystack.length === 0) { return -1; } let index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare, aBias || exports.GREATEST_LOWER_BOUND); if (index < 0) { return -1; } // We have found either the exact element, or the next-closest element than // the one we are searching for. However, there may be more than one such // element. Make sure we always return the smallest of these. while (index - 1 >= 0) { if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) { break; } --index; } return index; }; /***/ }), /***/ 371: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2014 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ const util = __nccwpck_require__(354); /** * Determine whether mappingB is after mappingA with respect to generated * position. */ function generatedPositionAfter(mappingA, mappingB) { // Optimized for most common case const lineA = mappingA.generatedLine; const lineB = mappingB.generatedLine; const columnA = mappingA.generatedColumn; const columnB = mappingB.generatedColumn; return lineB > lineA || lineB == lineA && columnB >= columnA || util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0; } /** * A data structure to provide a sorted view of accumulated mappings in a * performance conscious manner. It trades a negligible overhead in general * case for a large speedup in case of mappings being added in order. */ class MappingList { constructor() { this._array = []; this._sorted = true; // Serves as infimum this._last = {generatedLine: -1, generatedColumn: 0}; } /** * Iterate through internal items. This method takes the same arguments that * `Array.prototype.forEach` takes. * * NOTE: The order of the mappings is NOT guaranteed. */ unsortedForEach(aCallback, aThisArg) { this._array.forEach(aCallback, aThisArg); } /** * Add the given source mapping. * * @param Object aMapping */ add(aMapping) { if (generatedPositionAfter(this._last, aMapping)) { this._last = aMapping; this._array.push(aMapping); } else { this._sorted = false; this._array.push(aMapping); } } /** * Returns the flat, sorted array of mappings. The mappings are sorted by * generated position. * * WARNING: This method returns internal data without copying, for * performance. The return value must NOT be mutated, and should be treated as * an immutable borrow. If you want to take ownership, you must make your own * copy. */ toArray() { if (!this._sorted) { this._array.sort(util.compareByGeneratedPositionsInflated); this._sorted = true; } return this._array; } } exports.H = MappingList; /***/ }), /***/ 799: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; // 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. const fs = __nccwpck_require__(147); const path = __nccwpck_require__(17); module.exports = function readWasm() { return new Promise((resolve, reject) => { const wasmPath = __nccwpck_require__.ab + "mappings.wasm"; fs.readFile(__nccwpck_require__.ab + "mappings.wasm", null, (error, data) => { if (error) { reject(error); return; } resolve(data.buffer); }); }); }; module.exports.initialize = _ => { console.debug("SourceMapConsumer.initialize is a no-op when running in node.js"); }; /***/ }), /***/ 886: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { var __webpack_unused_export__; /* -*- 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 */ const util = __nccwpck_require__(354); const binarySearch = __nccwpck_require__(700); const ArraySet = (__nccwpck_require__(963)/* .ArraySet */ .I); const base64VLQ = __nccwpck_require__(344); // eslint-disable-line no-unused-vars const readWasm = __nccwpck_require__(799); const wasm = __nccwpck_require__(776); const INTERNAL = Symbol("smcInternal"); class SourceMapConsumer { constructor(aSourceMap, aSourceMapURL) { // If the constructor was called by super(), just return Promise<this>. // Yes, this is a hack to retain the pre-existing API of the base-class // constructor also being an async factory function. if (aSourceMap == INTERNAL) { return Promise.resolve(this); } return _factory(aSourceMap, aSourceMapURL); } static initialize(opts) { readWasm.initialize(opts["lib/mappings.wasm"]); } static fromSourceMap(aSourceMap, aSourceMapURL) { return _factoryBSM(aSourceMap, aSourceMapURL); } /** * 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); * ``` */ static async with(rawSourceMap, sourceMapUrl, f) { const consumer = await new SourceMapConsumer(rawSourceMap, sourceMapUrl); try { return await f(consumer); } finally { consumer.destroy(); } } /** * Iterate over each mapping between an original source/line/column and a * generated line/column in this source map. * * @param Function aCallback * The function that is called with each mapping. * @param Object aContext * Optional. If specified, this object will be the value of `this` every * time that `aCallback` is called. * @param aOrder * 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(aCallback, aContext, aOrder) { throw new Error("Subclasses must implement eachMapping"); } /** * 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. The line number is 1-based. * - column: Optional. the column number in the original source. * The column number is 0-based. * * and an array of objects is returned, each with the following properties: * * - 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 number is 0-based. */ allGeneratedPositionsFor(aArgs) { throw new Error("Subclasses must implement allGeneratedPositionsFor"); } destroy() { throw new Error("Subclasses must implement destroy"); } } /** * The version of the source mapping spec that we are consuming. */ SourceMapConsumer.prototype._version = 3; SourceMapConsumer.GENERATED_ORDER = 1; SourceMapConsumer.ORIGINAL_ORDER = 2; SourceMapConsumer.GREATEST_LOWER_BOUND = 1; SourceMapConsumer.LEAST_UPPER_BOUND = 2; exports.SourceMapConsumer = SourceMapConsumer; /** * A BasicSourceMapConsumer instance represents a parsed source map which we can * query for information about the original file positions by giving it a file * position in the generated source. * * The first parameter is the raw source map (either as a JSON string, or * already parsed to an object). According to the spec, source maps have the * following attributes: * * - version: Which version of the source map spec this map is following. * - sources: An array of URLs to the original source files. * - names: An array of identifiers which can be referenced by individual mappings. * - sourceRoot: Optional. The URL root from which all sources are relative. * - sourcesContent: Optional. An array of contents of the original source files. * - mappings: A string of base64 VLQs which contain the actual mappings. * - file: Optional. The generated file this source map is associated with. * * Here is an example source map, taken from the source map spec[0]: * * { * version : 3, * file: "out.js", * sourceRoot : "", * sources: ["foo.js", "bar.js"], * names: ["src", "maps", "are", "fun"], * mappings: "AA,AB;;ABCDE;" * } * * The second parameter, if given, is a string whose value is the URL * at which the source map was found. This URL is used to compute the * sources array. * * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# */ class BasicSourceMapConsumer extends SourceMapConsumer { constructor(aSourceMap, aSourceMapURL) { return super(INTERNAL).then(that => { let sourceMap = aSourceMap; if (typeof aSourceMap === "string") { sourceMap = util.parseSourceMapInput(aSourceMap); } const version = util.getArg(sourceMap, "version"); 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", []); 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); // Once again, Sass deviates from the spec and supplies the version as a // string rather than a number, so we use loose equality checking here. if (version != that._version) { throw new Error("Unsupported version: " + version); } that._sourceLookupCache = new Map(); // Pass `true` below to allow duplicate names and sources. While source maps // are intended to be compressed and deduplicated, the TypeScript compiler // sometimes generates source maps with duplicates in them. See Github issue // #72 and bugzil.la/889492. that._names = ArraySet.fromArray(names.map(String), true); that._sources = ArraySet.fromArray(sources, true); that._absoluteSources = ArraySet.fromArray(that._sources.toArray().map(function(s) { return util.computeSourceURL(sourceRoot, s, aSourceMapURL); }), true); that.sourceRoot = sourceRoot; that.sourcesContent = sourcesContent; that._mappings = mappings; that._sourceMapURL = aSourceMapURL; that.file = file; that._computedColumnSpans = false; that._mappingsPtr = 0; that._wasm = null; return wasm().then(w => { that._wasm = w; return that; }); }); } /** * Utility function to find the index of a source. Returns -1 if not * found. */ _findSourceIndex(aSource) { // 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; } // 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; } // 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; } /** * Create a BasicSourceMapConsumer from a SourceMapGenerator. * * @param SourceMapGenerator aSourceMap * The source map that will be consumed. * @param String aSourceMapURL * The URL at which the source map can be found (optional) * @returns BasicSourceMapConsumer */ static fromSourceMap(aSourceMap, aSourceMapURL) { return new BasicSourceMapConsumer(aSourceMap.toString()); } get sources() { return this._absoluteSources.toArray(); } _getMappingsPtr() { if (this._mappingsPtr === 0) { this._parseMappings(); } return this._mappingsPtr; } /** * 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() { 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); for (let i = 0; i < size; i++) { mappingsBuf[i] = aStr.charCodeAt(i); } const mappingsPtr = this._wasm.exports.parse_mappings(mappingsBufPtr); if (!mappingsPtr) { const error = this._wasm.exports.get_last_error(); let msg = `Error parsing mappings (code ${error}): `; // XXX: keep these error codes in sync with `fitzgen/source-map-mappings`. switch (error) { case 1: msg += "the mappings contained a negative line, column, source index, or name index"; break; case 2: msg += "the mappings contained a number larger than 2**32"; break; case 3: msg += "reached EOF while in the middle of parsing a VLQ"; break; case 4: msg += "invalid base 64 character while parsing a VLQ"; break; default: msg += "unknown error code"; break; } throw new Error(msg); } this._mappingsPtr = mappingsPtr; } eachMapping(aCallback, aContext, aOrder) { const context = aContext || null; const order = aOrder || SourceMapConsumer.GENERATED_ORDER; this._wasm.withMappingCallback( mapping => { if (mapping.source !== null) { mapping.source = this._absoluteSources.at(mapping.source); if (mapping.name !== null) { mapping.name = this._names.at(mapping.name); } } if (this._computedColumnSpans && mapping.lastGeneratedColumn === null) { mapping.lastGeneratedColumn = Infinity; } 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."); } } ); } allGeneratedPositionsFor(aArgs) { let source = util.getArg(aArgs, "source"); const originalLine = util.getArg(aArgs, "line"); const originalColumn = aArgs.column || 0; source = this._findSourceIndex(source); if (source < 0) { return []; } if (originalLine < 1) { throw new Error("Line numbers must be >= 1"); } if (originalColumn < 0) { throw new Error("Column numbers must be >= 0"); } const mappings = []; this._wasm.withMappingCallback( m => { let lastColumn = m.lastGeneratedColumn; if (this._computedColumnSpans && lastColumn === null) { lastColumn = Infinity; } mappings.push({ line: m.generatedLine, column: m.generatedColumn, lastColumn, }); }, () => { this._wasm.exports.all_generated_locations_for( this._getMappingsPtr(), source, originalLine - 1, "column" in aArgs, originalColumn ); } ); return mappings; } destroy() { if (this._mappingsPtr !== 0) { this._wasm.exports.free_mappings(this._mappingsPtr); this._mappingsPtr = 0; } } /** * Compute the last column for each generated mapping. The last column is * inclusive. */ computeColumnSpans() { if (this._computedColumnSpans) { return; } this._wasm.exports.compute_column_spans(this._getMappingsPtr()); this._computedColumnSpans = true; } /** * 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. The line number * is 1-based. * - column: The column number in the generated source. The column * number is 0-based. * - 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. The * line number is 1-based. * - column: The column number in the original source, or null. The * column number is 0-based. * - name: The original identifier, or null. */ originalPositionFor(aArgs) { const needle = { generatedLine: util.getArg(aArgs, "line"), generatedColumn: util.getArg(aArgs, "column") }; if (needle.generatedLine < 1) { throw new Error("Line numbers must be >= 1"); } if (needle.generatedColumn < 0) { throw new Error("Column numbers must be >= 0"); } let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND); if (bias == null) { 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 ); }); if (mapping) { if (mapping.generatedLine === needle.generatedLine) { let source = util.getArg(mapping, "source", null); if (source !== null) { source = this._absoluteSources.at(source); } let name = util.getArg(mapping, "name", null); if (name !== null) { name = this._names.at(name); } return { source, line: util.getArg(mapping, "originalLine", null), column: util.getArg(mapping, "originalColumn", null), name }; } } return { source: null, line: null, column: null, name: null }; } /** * Return true if we have the source content for every source in the source * map, false otherwise. */ hasContentsOfAllSources() { if (!this.sourcesContent) { return false; } return this.sourcesContent.length >= this._sources.size() && !this.sourcesContent.some(function(sc) { return sc == null; }); } /** * Returns the original source content. The only argument is the url of the * original source file. Returns null if no original source content is * available. */ sourceContentFor(aSource, nullOnMissing) { if (!this.sourcesContent) { return null; } const index = this._findSourceIndex(aSource); if (index >= 0) { return this.sourcesContent[index]; } // This function is used recursively from // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we // don't want to throw if we can't find the source - we just want to // return null, so we provide a flag to exit gracefully. if (nullOnMissing) { return null; } throw new Error('"' + aSource + '" is not in the SourceMap.'); } /** * 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. The line number * is 1-based. * - column: The column number in the original source. The column * number is 0-based. * - 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. The * line number is 1-based. * - column: The column number in the generated source, or null. * The column number is 0-based. */ generatedPositionFor(aArgs) { let source = util.getArg(aArgs, "source"); source = this._findSourceIndex(source); if (source < 0) { return { line: null, column: null, lastColumn: null }; } const needle = { source, originalLine: util.getArg(aArgs, "line"), originalColumn: util.getArg(aArgs, "column") }; if (needle.originalLine < 1) { throw new Error("Line numbers must be >= 1"); } if (needle.originalColumn < 0) { throw new Error("Column numbers must be >= 0"); } let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND); if (bias == null) { 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 ); }); if (mapping) { if (mapping.source === needle.source) { let lastColumn = mapping.lastGeneratedColumn; if (this._computedColumnSpans && lastColumn === null) { lastColumn = Infinity; } return { line: util.getArg(mapping, "generatedLine", null), column: util.getArg(mapping, "generatedColumn", null), lastColumn, }; } } return { line: null, column: null, lastColumn: null }; } } BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; __webpack_unused_export__ = BasicSourceMapConsumer; /** * An IndexedSourceMapConsumer instance represents a parsed source map which * we can query for information. It differs from BasicSourceMapConsumer in * that it takes "indexed" source maps (i.e. ones with a "sections" field) as * input. * * The first parameter is a raw source map (either as a JSON string, or already * parsed to an object). According to the spec for indexed source maps, they * have the following attributes: * * - version: Which version of the source map spec this map is following. * - file: Optional. The generated file this source map is associated with. * - sections: A list of section definitions. * * Each value under the "sections" field has two fields: * - offset: The offset into the original specified at which this section * begins to apply, defined as an object with a "line" and "column" * field. * - map: A source map definition. This source map could also be indexed, * but doesn't have to be. * * Instead of the "map" field, it's also possible to have a "url" field * specifying a URL to retrieve a source map from, but that's currently * unsupported. * * Here's an example source map, taken from the source map spec[0], but * modified to omit a section which uses the "url" field. * * { * version : 3, * file: "app.js", * sections: [{ * offset: {line:100, column:10}, * map: { * version : 3, * file: "section.js", * sources: ["foo.js", "bar.js"], * names: ["src", "maps", "are", "fun"], * mappings: "AAAA,E;;ABCDE;" * } * }], * } * * The second parameter, if given, is a string whose value is the URL * at which the source map was found. This URL is used to compute the * sources array. * * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt */ class IndexedSourceMapConsumer extends SourceMapConsumer { constructor(aSourceMap, aSourceMapURL) { return super(INTERNAL).then(that => { let sourceMap = aSourceMap; if (typeof aSourceMap === "string") { sourceMap = util.parseSourceMapInput(aSourceMap); } const version = util.getArg(sourceMap, "version"); const sections = util.getArg(sourceMap, "sections"); if (version != that._version) { throw new Error("Unsupported version: " + version); } let lastOffset = { line: -1, 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"); 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 => { that._sections = s; return that; }); }); } /** * The list of original sources. */ get sources() { const sources = []; for (let i = 0; i < this._sections.length; i++) { for (let j = 0; j < this._sections[i].consumer.sources.length; j++) { sources.push(this._sections[i].consumer.sources[j]); } } return sources; } /** * 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. The line number * is 1-based. * - column: The column number in the generated source. The column * number is 0-based. * * 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. The * line number is 1-based. * - column: The column number in the original source, or null. The * column number is 0-based. * - name: The original identifier, or null. */ originalPositionFor(aArgs) { const needle = { generatedLine: util.getArg(aArgs, "line"), generatedColumn: util.getArg(aArgs, "column") }; // Find the section containing the generated position we're trying to map // to an original position. const sectionIndex = binarySearch.search(needle, this._sections, function(aNeedle, section) { const cmp = aNeedle.generatedLine - section.generatedOffset.generatedLine; if (cmp) { return cmp; } return (aNeedle.generatedColumn - section.generatedOffset.generatedColumn); }); const section = this._sections[sectionIndex]; if (!section) { return { source: null, line: null, column: null, name: null }; } return section.consumer.originalPositionFor({ line: needle.generatedLine - (section.generatedOffset.generatedLine - 1), column: needle.generatedColumn - (section.generatedOffset.generatedLine === needle.generatedLine ? section.generatedOffset.generatedColumn - 1 : 0), bias: aArgs.bias }); } /** * Return true if we have the source content for every source in the source * map, false otherwise. */ hasContentsOfAllSources() { return this._sections.every(function(s) { return s.consumer.hasContentsOfAllSources(); }); } /** * 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(aSource, nullOnMissing) { for (let i = 0; i < this._sections.length; i++) { const section = this._sections[i]; const content = section.consumer.sourceContentFor(aSource, true); if (content) { return content; } } if (nullOnMissing) { return null; } throw new Error('"' + aSource + '" is not in the SourceMap.'); } _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; } /** * 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. The line number * is 1-based. * - column: The column number in the original source. The column * number is 0-based. * * and an object is returned with the following properties: * * - 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 number is 0-based. */ generatedPositionFor(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 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; } } if ( generatedPosition.lastColumn === Infinity && nextSection && generatedPosition.line === nextSection.generatedOffset.generatedLine ) { generatedPosition.lastColumn = nextSection.generatedOffset.generatedColumn - 2; } generatedPosition.line += lineShift; return generatedPosition; } return { line: null, column: null, lastColumn: null }; } 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; if (!section) return []; return section.consumer.allGeneratedPositionsFor(aArgs).map( generatedPosition => { 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; } } if ( generatedPosition.lastColumn === Infinity && nextSection && generatedPosition.line === nextSection.generatedOffset.generatedLine ) { generatedPosition.lastColumn = nextSection.generatedOffset.generatedColumn - 2; } generatedPosition.line += lineShift; return generatedPosition; } ); } eachMapping(aCallback, aContext, aOrder) { this._sections.forEach((section, index) => { const nextSection = index + 1 < this._sections.length ? this._sections[index + 1] : null; const { generatedOffset } = section; const lineShift = generatedOffset.generatedLine - 1; const columnShift = generatedOffset.generatedColumn - 1; section.consumer.eachMapping(function(mapping) { if (mapping.generatedLine === 1) { mapping.generatedColumn += columnShift; if (typeof mapping.lastGeneratedColumn === "number") { mapping.lastGeneratedColumn += columnShift; } } if ( mapping.lastGeneratedColumn === Infinity && nextSection && mapping.generatedLine === nextSection.generatedOffset.generatedLine ) { mapping.lastGeneratedColumn = nextSection.generatedOffset.generatedColumn - 2; } mapping.generatedLine += lineShift; aCallback.call(this, mapping); }, aContext, aOrder); }); } computeColumnSpans() { for (let i = 0; i < this._sections.length; i++) { this._sections[i].consumer.computeColumnSpans(); } } destroy() { for (let i = 0; i < this._sections.length; i++) { this._sections[i].consumer.destroy(); } } } __webpack_unused_export__ = IndexedSourceMapConsumer; /* * Cheat to get around inter-twingled classes. `factory()` can be at the end * where it has access to non-hoisted classes, but it gets hoisted itself. */ function _factory(aSourceMap, aSourceMapURL) { let sourceMap = aSourceMap; if (typeof aSourceMap === "string") { sourceMap = util.parseSourceMapInput(aSourceMap); } const consumer = sourceMap.sections != null ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL) : new BasicSourceMapConsumer(sourceMap, aSourceMapURL); return Promise.resolve(consumer); } function _factoryBSM(aSourceMap, aSourceMapURL) { return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL); } /***/ }), /***/ 87: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { /* -*- 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 */ const base64VLQ = __nccwpck_require__(344); const util = __nccwpck_require__(354); const ArraySet = (__nccwpck_require__(963)/* .ArraySet */ .I); const MappingList = (__nccwpck_require__(371)/* .MappingList */ .H); /** * An instance of the SourceMapGenerator represents a source map which is * being built incrementally. You may pass an object with the following * properties: * * - file: The filename of the generated source. * - sourceRoot: A root for all relative URLs in this source map. */ class SourceMapGenerator { constructor(aArgs) { if (!aArgs) { aArgs = {}; } this._file = util.getArg(aArgs, "file", null); this._sourceRoot = util.getArg(aArgs, "sourceRoot", null); this._skipValidation = util.getArg(aArgs, "skipValidation", false); this._sources = new ArraySet(); this._names = new ArraySet(); this._mappings = new MappingList(); this._sourcesContents = null; } /** * Creates a new SourceMapGenerator based on a SourceMapConsumer * * @param aSourceMapConsumer The SourceMap. */ static fromSourceMap(aSourceMapConsumer) { const sourceRoot = aSourceMapConsumer.sourceRoot; const generator = new SourceMapGenerator({ file: aSourceMapConsumer.file, sourceRoot }); aSourceMapConsumer.eachMapping(function(mapping) { const newMapping = { generated: { line: mapping.generatedLine, column: mapping.generatedColumn } }; if (mapping.source != null) { newMapping.source = mapping.source; if (sourceRoot != null) { newMap