2019-09-29 14:15:39 -07:00
|
|
|
// This file is a modified version of:
|
|
|
|
|
// https://cs.chromium.org/chromium/src/v8/tools/SourceMap.js?rcl=dd10454c1d
|
|
|
|
|
// from the V8 codebase. Logic specific to WebInspector is removed and linting
|
|
|
|
|
// is made to match the Node.js style guide.
|
|
|
|
|
|
|
|
|
|
// Copyright 2013 the V8 project 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.
|
|
|
|
|
|
|
|
|
|
// This is a copy from blink dev tools, see:
|
|
|
|
|
// http://src.chromium.org/viewvc/blink/trunk/Source/devtools/front_end/SourceMap.js
|
|
|
|
|
// revision: 153407
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2012 Google Inc. 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
2020-01-04 19:17:42 -08:00
|
|
|
const {
|
2020-12-31 13:32:35 +01:00
|
|
|
ArrayIsArray,
|
|
|
|
|
ArrayPrototypePush,
|
|
|
|
|
ArrayPrototypeSlice,
|
|
|
|
|
ArrayPrototypeSort,
|
|
|
|
|
ObjectPrototypeHasOwnProperty,
|
|
|
|
|
StringPrototypeCharAt,
|
2024-03-15 08:33:42 +02:00
|
|
|
Symbol,
|
2020-01-04 19:17:42 -08:00
|
|
|
} = primordials;
|
|
|
|
|
|
2022-02-06 16:39:08 +03:30
|
|
|
const { validateObject } = require('internal/validators');
|
2020-01-04 19:17:42 -08:00
|
|
|
|
2019-09-29 14:15:39 -07:00
|
|
|
let base64Map;
|
|
|
|
|
|
|
|
|
|
const VLQ_BASE_SHIFT = 5;
|
|
|
|
|
const VLQ_BASE_MASK = (1 << 5) - 1;
|
|
|
|
|
const VLQ_CONTINUATION_MASK = 1 << 5;
|
|
|
|
|
|
2024-03-15 08:33:42 +02:00
|
|
|
const kMappings = Symbol('kMappings');
|
|
|
|
|
|
2019-09-29 14:15:39 -07:00
|
|
|
class StringCharIterator {
|
|
|
|
|
/**
|
|
|
|
|
* @constructor
|
|
|
|
|
* @param {string} string
|
|
|
|
|
*/
|
|
|
|
|
constructor(string) {
|
|
|
|
|
this._string = string;
|
|
|
|
|
this._position = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return {string}
|
|
|
|
|
*/
|
|
|
|
|
next() {
|
2020-12-31 13:32:35 +01:00
|
|
|
return StringPrototypeCharAt(this._string, this._position++);
|
2019-09-29 14:15:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return {string}
|
|
|
|
|
*/
|
|
|
|
|
peek() {
|
2020-12-31 13:32:35 +01:00
|
|
|
return StringPrototypeCharAt(this._string, this._position);
|
2019-09-29 14:15:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*/
|
|
|
|
|
hasNext() {
|
|
|
|
|
return this._position < this._string.length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-06-29 23:58:19 +09:00
|
|
|
* Implements Source Map V3 model.
|
|
|
|
|
* See https://github.com/google/closure-compiler/wiki/Source-Maps
|
2019-09-29 14:15:39 -07:00
|
|
|
* for format description.
|
|
|
|
|
*/
|
|
|
|
|
class SourceMap {
|
2020-01-04 19:17:42 -08:00
|
|
|
#payload;
|
2019-09-29 14:15:39 -07:00
|
|
|
#mappings = [];
|
|
|
|
|
#sources = {};
|
|
|
|
|
#sourceContentByURL = {};
|
2023-07-12 11:37:32 -07:00
|
|
|
#lineLengths = undefined;
|
2019-09-29 14:15:39 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @constructor
|
|
|
|
|
* @param {SourceMapV3} payload
|
|
|
|
|
*/
|
2023-07-12 11:37:32 -07:00
|
|
|
constructor(payload, { lineLengths } = { __proto__: null }) {
|
2019-09-29 14:15:39 -07:00
|
|
|
if (!base64Map) {
|
|
|
|
|
const base64Digits =
|
|
|
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
|
|
|
base64Map = {};
|
|
|
|
|
for (let i = 0; i < base64Digits.length; ++i)
|
|
|
|
|
base64Map[base64Digits[i]] = i;
|
|
|
|
|
}
|
2020-01-04 19:17:42 -08:00
|
|
|
this.#payload = cloneSourceMapV3(payload);
|
|
|
|
|
this.#parseMappingPayload();
|
2023-07-12 11:37:32 -07:00
|
|
|
if (ArrayIsArray(lineLengths) && lineLengths.length) {
|
|
|
|
|
this.#lineLengths = lineLengths;
|
|
|
|
|
}
|
2020-01-04 19:17:42 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-11-28 22:48:00 -08:00
|
|
|
* @return {object} raw source map v3 payload.
|
2020-01-04 19:17:42 -08:00
|
|
|
*/
|
|
|
|
|
get payload() {
|
|
|
|
|
return cloneSourceMapV3(this.#payload);
|
2019-09-29 14:15:39 -07:00
|
|
|
}
|
|
|
|
|
|
2024-03-15 08:33:42 +02:00
|
|
|
get [kMappings]() {
|
|
|
|
|
return this.#mappings;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 11:37:32 -07:00
|
|
|
/**
|
|
|
|
|
* @return {number[] | undefined} line lengths of generated source code
|
|
|
|
|
*/
|
|
|
|
|
get lineLengths() {
|
|
|
|
|
if (this.#lineLengths) {
|
|
|
|
|
return ArrayPrototypeSlice(this.#lineLengths);
|
|
|
|
|
}
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-04 19:17:42 -08:00
|
|
|
#parseMappingPayload = () => {
|
2020-02-23 19:19:15 -08:00
|
|
|
if (this.#payload.sections) {
|
2020-01-04 19:17:42 -08:00
|
|
|
this.#parseSections(this.#payload.sections);
|
2020-02-23 19:19:15 -08:00
|
|
|
} else {
|
2020-01-04 19:17:42 -08:00
|
|
|
this.#parseMap(this.#payload, 0, 0);
|
2020-02-23 19:19:15 -08:00
|
|
|
}
|
2020-12-31 13:32:35 +01:00
|
|
|
ArrayPrototypeSort(this.#mappings, compareSourceMapEntry);
|
2021-11-04 06:18:10 -07:00
|
|
|
};
|
2019-09-29 14:15:39 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {Array.<SourceMapV3.Section>} sections
|
|
|
|
|
*/
|
|
|
|
|
#parseSections = (sections) => {
|
|
|
|
|
for (let i = 0; i < sections.length; ++i) {
|
|
|
|
|
const section = sections[i];
|
|
|
|
|
this.#parseMap(section.map, section.offset.line, section.offset.column);
|
|
|
|
|
}
|
2021-11-04 06:18:10 -07:00
|
|
|
};
|
2019-09-29 14:15:39 -07:00
|
|
|
|
|
|
|
|
/**
|
2023-06-23 12:17:14 -07:00
|
|
|
* @param {number} lineOffset 0-indexed line offset in compiled resource
|
|
|
|
|
* @param {number} columnOffset 0-indexed column offset in compiled resource
|
|
|
|
|
* @return {object} representing start of range if found, or empty object
|
2019-09-29 14:15:39 -07:00
|
|
|
*/
|
2023-06-23 12:17:14 -07:00
|
|
|
findEntry(lineOffset, columnOffset) {
|
2019-09-29 14:15:39 -07:00
|
|
|
let first = 0;
|
|
|
|
|
let count = this.#mappings.length;
|
|
|
|
|
while (count > 1) {
|
|
|
|
|
const step = count >> 1;
|
|
|
|
|
const middle = first + step;
|
|
|
|
|
const mapping = this.#mappings[middle];
|
2023-06-23 12:17:14 -07:00
|
|
|
if (lineOffset < mapping[0] ||
|
|
|
|
|
(lineOffset === mapping[0] && columnOffset < mapping[1])) {
|
2019-09-29 14:15:39 -07:00
|
|
|
count = step;
|
|
|
|
|
} else {
|
|
|
|
|
first = middle;
|
|
|
|
|
count -= step;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const entry = this.#mappings[first];
|
2023-06-23 12:17:14 -07:00
|
|
|
if (!first && entry && (lineOffset < entry[0] ||
|
|
|
|
|
(lineOffset === entry[0] && columnOffset < entry[1]))) {
|
2020-01-04 19:17:42 -08:00
|
|
|
return {};
|
|
|
|
|
} else if (!entry) {
|
|
|
|
|
return {};
|
2019-09-29 14:15:39 -07:00
|
|
|
}
|
2020-04-08 18:58:03 +02:00
|
|
|
return {
|
|
|
|
|
generatedLine: entry[0],
|
|
|
|
|
generatedColumn: entry[1],
|
|
|
|
|
originalSource: entry[2],
|
|
|
|
|
originalLine: entry[3],
|
2020-11-08 08:43:49 -08:00
|
|
|
originalColumn: entry[4],
|
|
|
|
|
name: entry[5],
|
2020-04-08 18:58:03 +02:00
|
|
|
};
|
2019-09-29 14:15:39 -07:00
|
|
|
}
|
|
|
|
|
|
2023-06-23 12:17:14 -07:00
|
|
|
/**
|
|
|
|
|
* @param {number} lineNumber 1-indexed line number in compiled resource call site
|
|
|
|
|
* @param {number} columnNumber 1-indexed column number in compiled resource call site
|
|
|
|
|
* @return {object} representing origin call site if found, or empty object
|
|
|
|
|
*/
|
|
|
|
|
findOrigin(lineNumber, columnNumber) {
|
|
|
|
|
const range = this.findEntry(lineNumber - 1, columnNumber - 1);
|
|
|
|
|
if (
|
|
|
|
|
range.originalSource === undefined ||
|
|
|
|
|
range.originalLine === undefined ||
|
|
|
|
|
range.originalColumn === undefined ||
|
|
|
|
|
range.generatedLine === undefined ||
|
|
|
|
|
range.generatedColumn === undefined
|
|
|
|
|
) {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
const lineOffset = lineNumber - range.generatedLine;
|
|
|
|
|
const columnOffset = columnNumber - range.generatedColumn;
|
|
|
|
|
return {
|
|
|
|
|
name: range.name,
|
|
|
|
|
fileName: range.originalSource,
|
|
|
|
|
lineNumber: range.originalLine + lineOffset,
|
|
|
|
|
columnNumber: range.originalColumn + columnOffset,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-29 14:15:39 -07:00
|
|
|
/**
|
|
|
|
|
* @override
|
|
|
|
|
*/
|
2020-12-31 13:32:35 +01:00
|
|
|
#parseMap(map, lineNumber, columnNumber) {
|
2019-09-29 14:15:39 -07:00
|
|
|
let sourceIndex = 0;
|
|
|
|
|
let sourceLineNumber = 0;
|
|
|
|
|
let sourceColumnNumber = 0;
|
2020-11-08 08:43:49 -08:00
|
|
|
let nameIndex = 0;
|
2019-09-29 14:15:39 -07:00
|
|
|
|
|
|
|
|
const sources = [];
|
|
|
|
|
const originalToCanonicalURLMap = {};
|
|
|
|
|
for (let i = 0; i < map.sources.length; ++i) {
|
|
|
|
|
const url = map.sources[i];
|
|
|
|
|
originalToCanonicalURLMap[url] = url;
|
2020-12-31 13:32:35 +01:00
|
|
|
ArrayPrototypePush(sources, url);
|
2019-09-29 14:15:39 -07:00
|
|
|
this.#sources[url] = true;
|
|
|
|
|
|
2024-09-24 15:48:15 -04:00
|
|
|
if (map.sourcesContent?.[i])
|
2019-09-29 14:15:39 -07:00
|
|
|
this.#sourceContentByURL[url] = map.sourcesContent[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const stringCharIterator = new StringCharIterator(map.mappings);
|
|
|
|
|
let sourceURL = sources[sourceIndex];
|
|
|
|
|
while (true) {
|
|
|
|
|
if (stringCharIterator.peek() === ',')
|
|
|
|
|
stringCharIterator.next();
|
|
|
|
|
else {
|
|
|
|
|
while (stringCharIterator.peek() === ';') {
|
|
|
|
|
lineNumber += 1;
|
|
|
|
|
columnNumber = 0;
|
|
|
|
|
stringCharIterator.next();
|
|
|
|
|
}
|
|
|
|
|
if (!stringCharIterator.hasNext())
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
columnNumber += decodeVLQ(stringCharIterator);
|
|
|
|
|
if (isSeparator(stringCharIterator.peek())) {
|
2020-12-31 13:32:35 +01:00
|
|
|
ArrayPrototypePush(this.#mappings, [lineNumber, columnNumber]);
|
2019-09-29 14:15:39 -07:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const sourceIndexDelta = decodeVLQ(stringCharIterator);
|
|
|
|
|
if (sourceIndexDelta) {
|
|
|
|
|
sourceIndex += sourceIndexDelta;
|
|
|
|
|
sourceURL = sources[sourceIndex];
|
|
|
|
|
}
|
|
|
|
|
sourceLineNumber += decodeVLQ(stringCharIterator);
|
|
|
|
|
sourceColumnNumber += decodeVLQ(stringCharIterator);
|
2020-11-08 08:43:49 -08:00
|
|
|
|
|
|
|
|
let name;
|
|
|
|
|
if (!isSeparator(stringCharIterator.peek())) {
|
|
|
|
|
nameIndex += decodeVLQ(stringCharIterator);
|
|
|
|
|
name = map.names?.[nameIndex];
|
|
|
|
|
}
|
2019-09-29 14:15:39 -07:00
|
|
|
|
2020-12-31 13:32:35 +01:00
|
|
|
ArrayPrototypePush(
|
|
|
|
|
this.#mappings,
|
|
|
|
|
[lineNumber, columnNumber, sourceURL, sourceLineNumber,
|
2023-02-14 18:45:16 +01:00
|
|
|
sourceColumnNumber, name],
|
2020-12-31 13:32:35 +01:00
|
|
|
);
|
2019-09-29 14:15:39 -07:00
|
|
|
}
|
2021-06-19 09:25:40 -07:00
|
|
|
}
|
2019-09-29 14:15:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {string} char
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*/
|
|
|
|
|
function isSeparator(char) {
|
|
|
|
|
return char === ',' || char === ';';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {SourceMap.StringCharIterator} stringCharIterator
|
|
|
|
|
* @return {number}
|
|
|
|
|
*/
|
|
|
|
|
function decodeVLQ(stringCharIterator) {
|
|
|
|
|
// Read unsigned value.
|
|
|
|
|
let result = 0;
|
|
|
|
|
let shift = 0;
|
|
|
|
|
let digit;
|
|
|
|
|
do {
|
|
|
|
|
digit = base64Map[stringCharIterator.next()];
|
|
|
|
|
result += (digit & VLQ_BASE_MASK) << shift;
|
|
|
|
|
shift += VLQ_BASE_SHIFT;
|
|
|
|
|
} while (digit & VLQ_CONTINUATION_MASK);
|
|
|
|
|
|
|
|
|
|
// Fix the sign.
|
|
|
|
|
const negative = result & 1;
|
process: fix two overflow cases in SourceMap VLQ decoding
These both have to do with extremely large numbers, so it's unlikely to
cause a problem in practice. Still, correctness.
First, encoding `-2147483648` in VLQ returns the value `"B"`. When
decoding, we get the value `1` after reading the base64. We then check
if the first bit is set (it is) to see if we should negate it, then we
shift all bits right once. Now, `value` will be `0` and `negate` will
be `true`. So, we'd return `-0`. Which is a bug! `-0` isn't
`-2147483648`, and we've broken a round trip.
Second, encoding any number with the 31st bit set, we'd return the
opposite sign. Let's use `1073741824`. Encoding, we get `"ggggggC"`.
When decoding, we get the value `-2147483648` after reading the base64.
Notice, it's already negative (the 32nd bit is set, because the 31st was
set and we shifted everything left once). We'd then check the first bit
(it's not) and shift right. But we used `>>`, which does not shift the
sign bit. We actually wanted `>>>`, which will. Because of that bug, we
get back `-1073741824` instead of the positive `1073741824`. It's even
worse if the 32nd and 31st bits are set, `-1610612736` becomes
`536870912` after a round trip.
I recently fixed the same two bugs in Closure Compiler:
https://github.com/google/closure-compiler/commit/584418eb
PR-URL: https://github.com/nodejs/node/pull/31490
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2020-01-24 02:49:41 -05:00
|
|
|
// Use unsigned right shift, so that the 32nd bit is properly shifted to the
|
|
|
|
|
// 31st, and the 32nd becomes unset.
|
|
|
|
|
result >>>= 1;
|
|
|
|
|
if (!negative) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We need to OR here to ensure the 32nd bit (the sign bit in an Int32) is
|
|
|
|
|
// always set for negative numbers. If `result` were 1, (meaning `negate` is
|
|
|
|
|
// true and all other bits were zeros), `result` would now be 0. But -0
|
|
|
|
|
// doesn't flip the 32nd bit as intended. All other numbers will successfully
|
|
|
|
|
// set the 32nd bit without issue, so doing this is a noop for them.
|
|
|
|
|
return -result | (1 << 31);
|
2019-09-29 14:15:39 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-04 19:17:42 -08:00
|
|
|
/**
|
|
|
|
|
* @param {SourceMapV3} payload
|
|
|
|
|
* @return {SourceMapV3}
|
|
|
|
|
*/
|
|
|
|
|
function cloneSourceMapV3(payload) {
|
2022-02-06 16:39:08 +03:30
|
|
|
validateObject(payload, 'payload');
|
2020-01-04 19:17:42 -08:00
|
|
|
payload = { ...payload };
|
|
|
|
|
for (const key in payload) {
|
2020-12-31 13:32:35 +01:00
|
|
|
if (ObjectPrototypeHasOwnProperty(payload, key) &&
|
|
|
|
|
ArrayIsArray(payload[key])) {
|
|
|
|
|
payload[key] = ArrayPrototypeSlice(payload[key]);
|
2020-01-04 19:17:42 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return payload;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-23 19:19:15 -08:00
|
|
|
/**
|
|
|
|
|
* @param {Array} entry1 source map entry [lineNumber, columnNumber, sourceURL,
|
|
|
|
|
* sourceLineNumber, sourceColumnNumber]
|
|
|
|
|
* @param {Array} entry2 source map entry.
|
|
|
|
|
* @return {number}
|
|
|
|
|
*/
|
|
|
|
|
function compareSourceMapEntry(entry1, entry2) {
|
2020-12-31 13:27:04 +01:00
|
|
|
const { 0: lineNumber1, 1: columnNumber1 } = entry1;
|
|
|
|
|
const { 0: lineNumber2, 1: columnNumber2 } = entry2;
|
2020-02-23 19:19:15 -08:00
|
|
|
if (lineNumber1 !== lineNumber2) {
|
|
|
|
|
return lineNumber1 - lineNumber2;
|
|
|
|
|
}
|
|
|
|
|
return columnNumber1 - columnNumber2;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-29 14:15:39 -07:00
|
|
|
module.exports = {
|
2024-03-15 08:33:42 +02:00
|
|
|
kMappings,
|
2023-02-26 11:34:02 +01:00
|
|
|
SourceMap,
|
2019-09-29 14:15:39 -07:00
|
|
|
};
|