Socket
Socket
Sign inDemoInstall

metro-source-map

Package Overview
Dependencies
Maintainers
2
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro-source-map - npm Package Compare versions

Comparing version 0.80.5 to 0.80.6

6

package.json
{
"name": "metro-source-map",
"version": "0.80.5",
"version": "0.80.6",
"description": "🚇 Source map generator for Metro.",

@@ -18,5 +18,5 @@ "main": "src/source-map.js",

"invariant": "^2.2.4",
"metro-symbolicate": "0.80.5",
"metro-symbolicate": "0.80.6",
"nullthrows": "^1.1.1",
"ob1": "0.80.5",
"ob1": "0.80.6",
"source-map": "^0.5.6",

@@ -23,0 +23,0 @@ "vlq": "^1.0.0"

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -19,15 +8,2 @@

const SEMICOLON = 0x3b;
/**
* Efficient builder for base64 VLQ mappings strings.
*
* This class uses a buffer that is preallocated with one megabyte and is
* reallocated dynamically as needed, doubling its size.
*
* Encoding never creates any complex value types (strings, objects), and only
* writes character values to the buffer.
*
* For details about source map terminology and specification, check
* https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
*/
class B64Builder {

@@ -39,6 +15,2 @@ constructor() {

}
/**
* Adds `n` markers for generated lines to the mappings.
*/
markLines(n) {

@@ -57,6 +29,2 @@ if (n < 1) {

}
/**
* Starts a segment at the specified column offset in the current line.
*/
startSegment(column) {

@@ -71,6 +39,2 @@ if (this.hasSegment) {

}
/**
* Appends a single number to the mappings.
*/
append(value) {

@@ -83,6 +47,2 @@ if (this.pos + MAX_SEGMENT_LENGTH >= this.buffer.length) {

}
/**
* Returns the string representation of the mappings.
*/
toString() {

@@ -89,0 +49,0 @@ return this.buffer.toString("ascii", 0, this.pos);

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -20,17 +9,2 @@

};
/**
* Builds a source-mapped bundle by concatenating strings and their
* corresponding source maps (if any).
*
* Usage:
*
* const builder = new BundleBuilder('bundle.js');
* builder
* .append('foo\n', fooMap)
* .append('bar\n')
* // ...
* const code = builder.getCode();
* const map = builder.getMap();
*/
class BundleBuilder {

@@ -37,0 +11,0 @@ constructor(file) {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -16,9 +5,4 @@

const { SourceMapGenerator } = require("source-map");
// TODO(t67648443): Bypass the `sort-requires` rule for this file because of a dependency cycle.
Consumer;
// Originally based on https://github.com/jakobwesthoff/source-map-merger
function composeSourceMaps(maps) {
// NOTE: require() here to break dependency cycle
const SourceMetadataMapConsumer = require("metro-symbolicate/src/SourceMetadataMapConsumer");

@@ -115,5 +99,4 @@ const GoogleIgnoreListConsumer = require("metro-symbolicate/src/GoogleIgnoreListConsumer");

}
// $FlowFixMe[incompatible-return] `Number0`, `Number1` is incompatible with number
return original;
}
module.exports = composeSourceMaps;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -16,4 +5,2 @@

const invariant = require("invariant");
// Implementation details shared between MappingsConsumer and SectionsConsumer
class AbstractConsumer {

@@ -38,4 +25,2 @@ constructor(sourceMap) {

}
// flowlint-next-line unsafe-getters-setters:off
get file() {

@@ -42,0 +27,0 @@ return this._sourceMap.file;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -22,4 +11,2 @@

const SectionsConsumer = require("./SectionsConsumer");
// eslint-disable-next-line lint/strictly-null
if (sourceMap.mappings === undefined) {

@@ -26,0 +13,0 @@ return new SectionsConsumer(sourceMap);

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -21,8 +10,2 @@

const createConsumer = require("./createConsumer");
/**
* A source map consumer that supports both "basic" and "indexed" source maps.
* Uses `MappingsConsumer` and `SectionsConsumer` under the hood (via
* `createConsumer`).
*/
class DelegatingConsumer {

@@ -33,3 +16,2 @@ static GENERATED_ORDER = GENERATED_ORDER;

static LEAST_UPPER_BOUND = LEAST_UPPER_BOUND;
// $FlowFixMe[incompatible-return]
constructor(sourceMap) {

@@ -48,4 +30,2 @@ this._rootConsumer = createConsumer(sourceMap);

}
// flowlint-next-line unsafe-getters-setters:off
get file() {

@@ -52,0 +32,0 @@ return this._rootConsumer.file;

@@ -1,16 +0,4 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
// Implements an API-compatible subset of source-map's `SourceMapConsumer`.
const DelegatingConsumer = require("./DelegatingConsumer");
module.exports = DelegatingConsumer;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -27,7 +16,2 @@

const { decode: decodeVlq } = require("vlq");
/**
* A source map consumer that supports "basic" source maps (that have a
* `mappings` field and no sections).
*/
class MappingsConsumer extends AbstractConsumer {

@@ -51,3 +35,2 @@ constructor(sourceMap) {

`Unimplemented lookup bias: ${lookupBiasToString(
// $FlowFixMe[incompatible-call]
generatedPosition.bias

@@ -103,3 +86,2 @@ )}`

generatedColumn = FIRST_COLUMN;
/* falls through */
case ",":

@@ -112,3 +94,2 @@ next = i + 1;

case ";":
/* falls through */
case ",":

@@ -115,0 +96,0 @@ break findNext;

@@ -1,18 +0,4 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
// flowlint-next-line untyped-import:off
const util = require("source-map/lib/util");
// Extracted from source-map@0.5.6's SourceMapConsumer
function normalizeSourcePath(sourceInput, map) {

@@ -22,10 +8,3 @@ const { sourceRoot } = map;

source = String(source);
// 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.
source = util.normalize(source);
// 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.
source =

@@ -32,0 +11,0 @@ sourceRoot != null && util.isAbsolute(sourceRoot) && util.isAbsolute(source)

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -20,7 +9,2 @@

const { add, add0, get0, get1, sub, sub1 } = require("ob1");
/**
* A source map consumer that supports "indexed" source maps (that have a
* `sections` field and no top-level mappings).
*/
class SectionsConsumer extends AbstractConsumer {

@@ -27,0 +11,0 @@ constructor(sourceMap) {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -1,55 +0,3 @@

/**
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
/**
* 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://git.io/vymuA
*
* 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.
*
* @copyright
*/
/* eslint-disable no-bitwise */
"use strict";
// A map of values to characters for the b64 encoding
const CHAR_MAP = [

@@ -62,45 +10,9 @@ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,

];
// 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(value) {
return value < 0 ? (-value << 1) + 1 : (value << 1) + 0;
}
/**
* Encodes a number to base64 VLQ format and appends it to the passed-in buffer
*
* DON'T USE COMPOUND OPERATORS (eg `>>>=`) ON `let`-DECLARED VARIABLES!
* V8 WILL DEOPTIMIZE THIS FUNCTION AND MAP CREATION WILL BE 25% SLOWER!
*
* DON'T ADD MORE COMMENTS TO THIS FUNCTION TO KEEP ITS LENGTH SHORT ENOUGH FOR
* V8 OPTIMIZATION!
*/
function encode(value, buffer, position) {

@@ -113,4 +25,2 @@ let vlq = toVLQSigned(value);

if (vlq > 0) {
// There are still more digits in this value, so we must make sure the
// continuation bit is marked.
digit = digit | VLQ_CONTINUATION_BIT;

@@ -117,0 +27,0 @@ }

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -24,10 +13,2 @@

const fsPath = require("path");
/**
* Generate a map of source positions to function names. The names are meant to
* describe the stack frame in an error trace and may contain more contextual
* information than just the actual name of the function.
*
* The output is encoded for use in a source map. For details about the format,
* see MappingEncoder below.
*/
function generateFunctionMap(ast, context) {

@@ -38,9 +19,2 @@ const encoder = new MappingEncoder();

}
/**
* Same as generateFunctionMap, but returns the raw array of mappings instead
* of encoding it for use in a source map.
*
* Lines are 1-based and columns are 0-based.
*/
function generateFunctionMappingsArray(ast, context) {

@@ -55,5 +29,2 @@ const mappings = [];

return {
// Eagerly traverse the tree on `pre`, before any visitors have run, so
// that regardless of plugin order we're dealing with the AST before any
// mutations.
visitor: {},

@@ -73,4 +44,2 @@ pre: ({ path, metadata, opts }) => {

);
// $FlowFixMe[prop-missing] checked above
// $FlowFixMe[incompatible-type-arg] checked above
const programPath = path;

@@ -83,8 +52,4 @@ visitor.enter(programPath);

visitor.exit(programPath);
// $FlowFixMe[prop-missing] Babel `File` is not generically typed
const metroMetadata = metadata;
const functionMap = encoder.getResult();
// Set the result on a metadata property
if (!metroMetadata.metro) {

@@ -109,3 +74,3 @@ metroMetadata.metro = {

if (tailPos && positionGreater(pos, tailPos)) {
const name = nameStack[0].name; // We always have at least Program
const name = nameStack[0].name;
if (name !== tailName) {

@@ -158,18 +123,7 @@ pushMapping({

}
/**
* Traverses a Babel AST and calls the supplied callback with function name
* mappings, one at a time.
*/
function forEachMapping(ast, context, pushMapping) {
const visitor = getFunctionMapVisitor(context, pushMapping);
// Traversing populates/pollutes the path cache (`traverse.cache.path`) with
// values missing the `hub` property needed by Babel transformation, so we
// save, clear, and restore the cache around our traversal.
// See: https://github.com/facebook/metro/pull/854#issuecomment-1336499395
const previousCache = _traverse.default.cache.path;
_traverse.default.cache.clearPath();
(0, _traverse.default)(ast, {
// Our visitor doesn't care about scope
noScope: true,

@@ -183,7 +137,2 @@ Function: visitor,

const ANONYMOUS_NAME = "<anonymous>";
/**
* Derive a contextual name for the given AST node (Function, Program, Class or
* ObjectExpression).
*/
function getNameForPath(path) {

@@ -195,5 +144,3 @@ const { node, parent, parentPath } = path;

let { id } = path;
// has an `id` so we don't need to infer one
if (node.id) {
// $FlowFixMe Flow error uncovered by typing Babel more strictly
return node.id.name;

@@ -203,13 +150,7 @@ }

let kind;
// Find or construct an AST node that names the current node.
if ((0, _types.isObjectMethod)(node) || (0, _types.isClassMethod)(node)) {
// ({ foo() {} });
id = node.key;
if (node.kind !== "method" && node.kind !== "constructor") {
// Store the method's kind so we can add it to the final name.
kind = node.kind;
}
// Also store the path to the property so we can find its context
// (object/class) later and add _its_ name to the result.
propertyPath = path;

@@ -220,12 +161,7 @@ } else if (

) {
// ({ foo: function() {} });
id = parent.key;
// Also store the path to the property so we can find its context
// (object/class) later and add _its_ name to the result.
propertyPath = parentPath;
} else if ((0, _types.isVariableDeclarator)(parent)) {
// let foo = function () {};
id = parent.id;
} else if ((0, _types.isAssignmentExpression)(parent)) {
// foo = function () {};
id = parent.left;

@@ -235,6 +171,4 @@ } else if ((0, _types.isJSXExpressionContainer)(parent)) {

if ((0, _types.isJSXElement)(grandParentNode)) {
// <foo>{function () {}}</foo>
const openingElement = grandParentNode.openingElement;
id = t.jsxMemberExpression(
// $FlowFixMe Flow error uncovered by typing Babel more strictly
t.jsxMemberExpression(openingElement.name, t.jsxIdentifier("props")),

@@ -244,9 +178,6 @@ t.jsxIdentifier("children")

} else if ((0, _types.isJSXAttribute)(grandParentNode)) {
// <foo bar={function () {}} />
const openingElement = parentPath?.parentPath?.parentPath?.node;
const prop = grandParentNode;
id = t.jsxMemberExpression(
// $FlowFixMe Flow error uncovered by typing Babel more strictly
t.jsxMemberExpression(openingElement.name, t.jsxIdentifier("props")),
// $FlowFixMe Flow error uncovered by typing Babel more strictly
prop.name

@@ -256,17 +187,11 @@ );

}
// Collapse the name AST, if any, into a string.
let name = getNameFromId(id);
if (name == null) {
// We couldn't find a name directly. Try the parent in certain cases.
if (isAnyCallExpression(parent)) {
// foo(function () {})
const argIndex = parent.arguments.indexOf(node);
if (argIndex !== -1) {
const calleeName = getNameFromId(parent.callee);
// var f = Object.freeze(function () {})
if (argIndex === 0 && calleeName === "Object.freeze") {
return getNameForPath(nullthrows(parentPath));
}
// var f = useCallback(function () {})
if (

@@ -292,15 +217,9 @@ argIndex === 0 &&

}
// We couldn't infer a name at all.
return ANONYMOUS_NAME;
}
// Annotate getters and setters.
if (kind != null) {
name = kind + "__" + name;
}
// Annotate members with the name of their containing object/class.
if (propertyPath) {
if ((0, _types.isClassBody)(propertyPath.parent)) {
// $FlowFixMe Discovered when typing babel-traverse
const className = getNameForPath(propertyPath.parentPath.parentPath);

@@ -320,4 +239,2 @@ if (className !== ANONYMOUS_NAME) {

}
// $FlowFixMe[deprecated-type]
function isAnyCallExpression(node) {

@@ -330,4 +247,2 @@ return (

}
// $FlowFixMe[deprecated-type]
function isAnyMemberExpression(node) {

@@ -340,4 +255,2 @@ return (

}
// $FlowFixMe[deprecated-type]
function isAnyIdentifier(node) {

@@ -420,8 +333,2 @@ return (0, _types.isIdentifier)(node) || (0, _types.isJSXIdentifier)(node);

const DELIMITER_START_RE = /^[^A-Za-z0-9_$@]+/;
/**
* Strip the given prefix from `name`, if it occurs there, plus any delimiter
* characters that follow (of which at least one is required). If an empty
* string would be returned, return the original name instead.
*/
function removeNamePrefix(name, namePrefix) {

@@ -438,27 +345,2 @@ if (!namePrefix.length || !name.startsWith(namePrefix)) {

}
/**
* Encodes function name mappings as deltas in a Base64 VLQ format inspired by
* the standard source map format.
*
* Mappings on different lines are separated with a single `;` (even if there
* are multiple intervening lines).
* Mappings on the same line are separated with `,`.
*
* The first mapping of a line has the fields:
* [column delta, name delta, line delta]
*
* where the column delta is relative to the beginning of the line, the name
* delta is relative to the previously occurring name, and the line delta is
* relative to the previously occurring line.
*
* The 2...nth other mappings of a line have the fields:
* [column delta, name delta]
*
* where both fields are relative to their previous running values. The line
* delta is omitted since it is always 0 by definition.
*
* Lines and columns are both 0-based in the serialised format. In memory,
* lines are 1-based while columns are 0-based.
*/
class MappingEncoder {

@@ -489,3 +371,2 @@ constructor() {

if (lineDelta > 0) {
// The next entry will have the line offset, so emit just one semicolon.
this._mappings.markLines(1);

@@ -492,0 +373,0 @@ this._column.reset(0);

@@ -1,29 +0,5 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
const B64Builder = require("./B64Builder");
/**
* Generates a source map from raw mappings.
*
* Raw mappings are a set of 2, 4, or five elements:
*
* - line and column number in the generated source
* - line and column number in the original source
* - symbol name in the original source
*
* Mappings have to be passed in the order appearance in the generated source.
*/
class Generator {
// https://developer.chrome.com/blog/devtools-better-angular-debugging/#the-x_google_ignorelist-source-map-extension
constructor() {

@@ -34,3 +10,2 @@ this.builder = new B64Builder();

generatedLine: 1,
// lines are passed in 1-indexed
name: 0,

@@ -48,6 +23,2 @@ source: 0,

}
/**
* Mark the beginning of a new source file.
*/
startFile(file, code, functionMap, flags) {

@@ -63,13 +34,5 @@ const { addToIgnoreList = false } = flags ?? {};

}
/**
* Mark the end of the current source file
*/
endFile() {
this.source = -1;
}
/**
* Adds a mapping for generated code without a corresponding source location.
*/
addSimpleMapping(generatedLine, generatedColumn) {

@@ -97,6 +60,2 @@ const last = this.last;

}
/**
* Adds a mapping for generated code with a corresponding source location.
*/
addSourceMapping(generatedLine, generatedColumn, sourceLine, sourceColumn) {

@@ -113,6 +72,2 @@ this.addSimpleMapping(generatedLine, generatedColumn);

}
/**
* Adds a mapping for code with a corresponding source location + symbol name.
*/
addNamedSourceMapping(

@@ -136,6 +91,2 @@ generatedLine,

}
/**
* Return the source map as object.
*/
toMap(file, options) {

@@ -171,8 +122,2 @@ const content =

}
/**
* Return the source map as string.
*
* This is ~2.5x faster than calling `JSON.stringify(generator.toMap())`
*/
toString(file, options) {

@@ -214,7 +159,2 @@ let content;

}
/**
* Determine whether we need to write the `x_facebook_sources` field.
* If the metadata is all `null`s, we can omit the field entirely.
*/
hasSourcesMetadata() {

@@ -221,0 +161,0 @@ return this.x_facebook_sources.some(

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -17,3 +6,2 @@

const Consumer = require("./Consumer");
// We need to export this for `metro-symbolicate`
const normalizeSourcePath = require("./Consumer/normalizeSourcePath");

@@ -25,3 +13,2 @@ const {

const Generator = require("./Generator");
// $FlowFixMe[untyped-import] - source-map
const SourceMap = require("source-map");

@@ -57,10 +44,5 @@ function fromRawMappingsImpl(isBlocking, onDone, modules, offsetLines) {

if (!isBlocking) {
// Keep the loop running but try to avoid blocking
// for too long because this is not in a worker yet.
const diff = process.hrtime(time);
const NS_IN_MS = 1000000;
if (diff[1] > 50 * NS_IN_MS) {
// We've blocked for more than 50ms.
// This code currently runs on the main thread,
// so let's give Metro an opportunity to handle requests.
setImmediate(workLoop);

@@ -74,10 +56,2 @@ break;

}
/**
* Creates a source map from modules with "raw mappings", i.e. an array of
* tuples with either 2, 4, or 5 elements:
* generated line, generated column, source line, source line, symbol name.
* Accepts an `offsetLines` argument in case modules' code is to be offset in
* the resulting bundle, e.g. by some prefix code.
*/
function fromRawMappings(modules, offsetLines = 0) {

@@ -103,7 +77,2 @@ let generator;

}
/**
* Transforms a standard source map object into a Raw Mappings object, to be
* used across the bundler.
*/
function toBabelSegments(sourceMap) {

@@ -160,3 +129,2 @@ const rawMappings = [];

const line = mapping[0] + carryOver;
// lines start at 1, columns start at 0
const column = mapping[1];

@@ -163,0 +131,0 @@ switch (mapping.length) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc