Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metro-source-map

Package Overview
Dependencies
Maintainers
2
Versions
158
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.66.2 to 0.67.0

6

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

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

"invariant": "^2.2.4",
"metro-symbolicate": "0.66.2",
"metro-symbolicate": "0.67.0",
"nullthrows": "^1.1.1",
"ob1": "0.66.2",
"ob1": "0.67.0",
"source-map": "^0.5.6",

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

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -4,0 +4,0 @@ * This source code is licensed under the MIT license found in the

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -16,3 +16,3 @@ * This source code is licensed under the MIT license found in the

names: [],
mappings: "A"
mappings: "A",
};

@@ -49,4 +49,4 @@ /**

column: this._column,
line: this._line
}
line: this._line,
},
});

@@ -117,3 +117,3 @@ }

lineBreaks,
lastLineColumns
lastLineColumns,
};

@@ -126,3 +126,3 @@ }

file,
sections
sections,
};

@@ -133,3 +133,3 @@ }

BundleBuilder,
createIndexMap
createIndexMap,
};
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -12,9 +12,8 @@ * This source code is licensed under the MIT license found in the

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

@@ -30,3 +29,3 @@ // NOTE: require() here to break dependency cycle

const consumers = maps
.map(function(map) {
.map(function (map) {
return new Consumer(map);

@@ -36,5 +35,5 @@ })

const generator = new SourceMapGenerator({
file: consumers[0].file
file: consumers[0].file,
});
consumers[0].eachMapping(mapping => {
consumers[0].eachMapping((mapping) => {
const original = findOriginalPosition(

@@ -48,3 +47,3 @@ consumers,

line: mapping.generatedLine,
column: mapping.generatedColumn
column: mapping.generatedColumn,
},

@@ -55,15 +54,15 @@ original:

line: original.line,
column: original.column
column: original.column,
}
: null,
source: original.source,
name: original.name
name: original.name,
});
});
const composedMap = generator.toJSON();
composedMap.sourcesContent = composedMap.sources.map(source =>
composedMap.sourcesContent = composedMap.sources.map((source) =>
consumers[consumers.length - 1].sourceContentFor(source, true)
);
if (composedMap.sourcesContent.every(content => content == null)) {
if (composedMap.sourcesContent.every((content) => content == null)) {
delete composedMap.sourcesContent;

@@ -92,3 +91,3 @@ }

source: null,
name: null
name: null,
};

@@ -102,3 +101,3 @@

source: null,
name: null
name: null,
};

@@ -109,3 +108,3 @@ }

line: currentLine,
column: currentColumn
column: currentColumn,
});

@@ -120,3 +119,3 @@ currentLine = original.line;

source: null,
name: null
name: null,
};

@@ -123,0 +122,0 @@ }

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -12,7 +12,6 @@ * This source code is licensed under the MIT license found in the

const invariant = require("invariant");
const { GENERATED_ORDER, iterationOrderToString } = require("./constants");
// Implementation details shared between MappingsConsumer and SectionsConsumer
const invariant = require("invariant"); // Implementation details shared between MappingsConsumer and SectionsConsumer
class AbstractConsumer {

@@ -19,0 +18,0 @@ constructor(sourceMap) {

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -24,3 +24,3 @@ * This source code is licensed under the MIT license found in the

line: null,
column: null
column: null,
});

@@ -45,3 +45,3 @@

iterationOrderToString,
lookupBiasToString
lookupBiasToString,
};
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -4,0 +4,0 @@ * This source code is licensed under the MIT license found in the

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -12,11 +12,10 @@ * This source code is licensed under the MIT license found in the

const createConsumer = require("./createConsumer");
const {
GENERATED_ORDER,
GREATEST_LOWER_BOUND,
LEAST_UPPER_BOUND,
ORIGINAL_ORDER,
GREATEST_LOWER_BOUND,
LEAST_UPPER_BOUND
} = require("./constants");
const createConsumer = require("./createConsumer");
/**

@@ -27,2 +26,3 @@ * A source map consumer that supports both "basic" and "indexed" source maps.

*/
class DelegatingConsumer {

@@ -29,0 +29,0 @@ static GENERATED_ORDER = GENERATED_ORDER;

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -4,0 +4,0 @@ * This source code is licensed under the MIT license found in the

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -14,20 +14,19 @@ * This source code is licensed under the MIT license found in the

const invariant = require("invariant");
const normalizeSourcePath = require("./normalizeSourcePath");
const {
EMPTY_POSITION,
FIRST_COLUMN,
FIRST_LINE,
GREATEST_LOWER_BOUND,
EMPTY_POSITION,
lookupBiasToString
lookupBiasToString,
} = require("./constants");
const normalizeSourcePath = require("./normalizeSourcePath");
const { greatestLowerBound } = require("./search");
const { add, get0, add0, sub, inc } = require("ob1");
const invariant = require("invariant");
const { add, add0, get0, inc, sub } = require("ob1");
const { decode: decodeVlq } = require("vlq");
/**

@@ -37,2 +36,3 @@ * A source map consumer that supports "basic" source maps (that have a

*/
class MappingsConsumer extends AbstractConsumer {

@@ -68,3 +68,3 @@ constructor(sourceMap) {

line,
column
column,
},

@@ -89,3 +89,3 @@ (position, mapping) => {

line: mapping.originalLine,
column: mapping.originalColumn
column: mapping.originalColumn,
};

@@ -150,3 +150,3 @@ }

originalColumnDelta,
nameIndexDelta
nameIndexDelta,
] = decodedVlqValues;

@@ -162,3 +162,3 @@ decodeVlq(mappingRaw);

originalLine: null,
originalColumn: null
originalColumn: null,
};

@@ -188,3 +188,3 @@

if (!this._normalizedSources) {
this._normalizedSources = this._sourceMap.sources.map(source =>
this._normalizedSources = this._sourceMap.sources.map((source) =>
normalizeSourcePath(source, this._sourceMap)

@@ -191,0 +191,0 @@ );

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -4,0 +4,0 @@ * This source code is licensed under the MIT license found in the

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -12,3 +12,3 @@ * This source code is licensed under the MIT license found in the

const { add, neg, add0, add1 } = require("ob1");
const { add, add0, add1, neg } = require("ob1");

@@ -19,3 +19,3 @@ function shiftPositionByOffset(pos, offset) {

line: pos.line != null ? add(pos.line, offset.lines) : null,
column: pos.column != null ? add(pos.column, offset.columns) : null
column: pos.column != null ? add(pos.column, offset.columns) : null,
};

@@ -28,3 +28,3 @@ }

lines: neg(offset.lines),
columns: neg(offset.columns)
columns: neg(offset.columns),
});

@@ -35,3 +35,3 @@ }

lines: neg(offset.lines),
columns: add0(0)
columns: add0(0),
});

@@ -42,3 +42,3 @@ }

shiftPositionByOffset,
subtractOffsetFromPosition
subtractOffsetFromPosition,
};
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -35,3 +35,3 @@ * This source code is licensed under the MIT license found in the

module.exports = {
greatestLowerBound
greatestLowerBound,
};
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -14,6 +14,6 @@ * This source code is licensed under the MIT license found in the

const { EMPTY_POSITION, FIRST_COLUMN, FIRST_LINE } = require("./constants");
const createConsumer = require("./createConsumer");
const { FIRST_COLUMN, FIRST_LINE, EMPTY_POSITION } = require("./constants");
const { subtractOffsetFromPosition } = require("./positionMath");

@@ -23,4 +23,3 @@

const { add, get0, get1, add0, sub1, sub } = require("ob1");
const { add, add0, get0, get1, sub, sub1 } = require("ob1");
/**

@@ -30,2 +29,3 @@ * A source map consumer that supports "indexed" source maps (that have a

*/
class SectionsConsumer extends AbstractConsumer {

@@ -37,3 +37,3 @@ constructor(sourceMap) {

lines: add0(section.offset.line),
columns: add0(section.offset.column)
columns: add0(section.offset.column),
};

@@ -73,3 +73,3 @@ const consumer = createConsumer(section.map);

originalLine: null,
originalColumn: null
originalColumn: null,
};

@@ -82,3 +82,6 @@ }

generatedLine: add(mapping.generatedLine, generatedOffset.lines),
generatedColumn: add(mapping.generatedColumn, generatedOffset.columns)
generatedColumn: add(
mapping.generatedColumn,
generatedOffset.columns
),
};

@@ -85,0 +88,0 @@ }

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -4,0 +4,0 @@ * This source code is licensed under the MIT license found in the

/**
* Portions Copyright (c) Facebook, Inc. and its affiliates.
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -53,66 +53,7 @@ * This source code is licensed under the MIT license found in the

const CHAR_MAP = [
0x41,
0x42,
0x43,
0x44,
0x45,
0x46,
0x47,
0x48,
0x49,
0x4a,
0x4b,
0x4c,
0x4d,
0x4e,
0x4f,
0x50,
0x51,
0x52,
0x53,
0x54,
0x55,
0x56,
0x57,
0x58,
0x59,
0x5a,
0x61,
0x62,
0x63,
0x64,
0x65,
0x66,
0x67,
0x68,
0x69,
0x6a,
0x6b,
0x6c,
0x6d,
0x6e,
0x6f,
0x70,
0x71,
0x72,
0x73,
0x74,
0x75,
0x76,
0x77,
0x78,
0x79,
0x7a,
0x30,
0x31,
0x32,
0x33,
0x34,
0x35,
0x36,
0x37,
0x38,
0x39,
0x2b,
0x2f
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f,
]; // A single base 64 digit can contain 6 bits of data. For the base 64 variable

@@ -119,0 +60,0 @@ // length quantities we use in the source map spec, the first bit is the sign,

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -22,7 +22,7 @@ * This source code is licensed under the MIT license found in the

const fsPath = require("path");
const t = require("@babel/types");
const nullthrows = require("nullthrows");
const t = require("@babel/types");
const fsPath = require("path");

@@ -39,3 +39,3 @@ /**

const encoder = new MappingEncoder();
forEachMapping(ast, context, mapping => encoder.push(mapping));
forEachMapping(ast, context, (mapping) => encoder.push(mapping));
return encoder.getResult();

@@ -52,3 +52,3 @@ }

const mappings = [];
forEachMapping(ast, context, mapping => {
forEachMapping(ast, context, (mapping) => {
mappings.push(mapping);

@@ -67,3 +67,3 @@ });

line: 1,
column: 0
column: 0,
};

@@ -81,4 +81,4 @@ let tailName = null;

line: tailPos.line,
column: tailPos.column
}
column: tailPos.column,
},
});

@@ -96,3 +96,3 @@ tailName = name;

name,
loc
loc,
});

@@ -131,3 +131,3 @@ }

popFrame();
}
},
};

@@ -137,3 +137,3 @@ (0, _traverse.default)(ast, {

Program: visitor,
Class: visitor
Class: visitor,
});

@@ -143,3 +143,2 @@ }

const ANONYMOUS_NAME = "<anonymous>";
const CALLEES_TO_SKIP = ["Object.freeze"];
/**

@@ -239,6 +238,3 @@ * Derive a contextual name for the given AST node (Function, Program, Class or

// We couldn't find a name directly. Try the parent in certain cases.
if (
(0, _types.isCallExpression)(parent) ||
(0, _types.isNewExpression)(parent)
) {
if (isAnyCallExpression(parent)) {
// foo(function () {})

@@ -250,4 +246,11 @@ const argIndex = parent.arguments.indexOf(node);

if (CALLEES_TO_SKIP.indexOf(calleeName) !== -1) {
if (argIndex === 0 && calleeName === "Object.freeze") {
return getNameForPath(nullthrows(parentPath));
} // var f = useCallback(function () {})
if (
argIndex === 0 &&
(calleeName === "useCallback" || calleeName === "React.useCallback")
) {
return getNameForPath(nullthrows(parentPath));
}

@@ -290,3 +293,2 @@

} else if ((0, _types.isObjectExpression)(propertyPath.parent)) {
// $FlowFixMe[incompatible-use]
const objectName = getNameForPath(nullthrows(propertyPath.parentPath));

@@ -303,5 +305,15 @@

function isAnyCallExpression(node) {
return (
node.type === "CallExpression" ||
node.type === "NewExpression" ||
node.type === "OptionalCallExpression"
);
}
function isAnyMemberExpression(node) {
return (
node.type === "MemberExpression" || node.type === "JSXMemberExpression"
node.type === "MemberExpression" ||
node.type === "JSXMemberExpression" ||
node.type === "OptionalMemberExpression"
);

@@ -341,3 +353,3 @@ }

if ((0, _types.isCallExpression)(id) || (0, _types.isNewExpression)(id)) {
if (isAnyCallExpression(id)) {
return getNamePartsFromId(id.callee);

@@ -363,3 +375,3 @@ }

} else if ((0, _types.isTemplateLiteral)(id)) {
name = id.quasis.map(quasi => quasi.value.raw).join("");
name = id.quasis.map((quasi) => quasi.value.raw).join("");
} else if ((0, _types.isLiteral)(id) && id.value != null) {

@@ -469,3 +481,3 @@ name = String(id.value);

names: this._names,
mappings: this._mappings.toString()
mappings: this._mappings.toString(),
};

@@ -527,3 +539,3 @@ }

generateFunctionMap,
generateFunctionMappingsArray
generateFunctionMappingsArray,
};
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -13,3 +13,2 @@ * This source code is licensed under the MIT license found in the

const B64Builder = require("./B64Builder");
/**

@@ -26,2 +25,3 @@ * Generates a source map from raw mappings.

*/
class Generator {

@@ -37,3 +37,3 @@ constructor() {

sourceColumn: 0,
sourceLine: 1
sourceLine: 1,
};

@@ -139,3 +139,3 @@ this.names = new IndexedSet();

content = {
sourcesContent: this.sourcesContent.slice()
sourcesContent: this.sourcesContent.slice(),
};

@@ -146,3 +146,3 @@ }

sourcesMetadata = {
x_facebook_sources: JSON.parse(JSON.stringify(this.x_facebook_sources))
x_facebook_sources: JSON.parse(JSON.stringify(this.x_facebook_sources)),
};

@@ -167,3 +167,3 @@ } else {

names: this.names.items(),
mappings: this.builder.toString()
mappings: this.builder.toString(),
};

@@ -213,3 +213,3 @@ }

return this.x_facebook_sources.some(
metadata => metadata != null && metadata.some(value => value != null)
(metadata) => metadata != null && metadata.some((value) => value != null)
);

@@ -216,0 +216,0 @@ }

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -12,16 +12,15 @@ * This source code is licensed under the MIT license found in the

const Consumer = require("./Consumer");
const { BundleBuilder, createIndexMap } = require("./BundleBuilder");
const Generator = require("./Generator");
const composeSourceMaps = require("./composeSourceMaps");
const SourceMap = require("source-map");
const Consumer = require("./Consumer"); // We need to export this for `metro-symbolicate`
// We need to export this for `metro-symbolicate`
const normalizeSourcePath = require("./Consumer/normalizeSourcePath");
const composeSourceMaps = require("./composeSourceMaps");
const { generateFunctionMap } = require("./generateFunctionMap");
const { createIndexMap, BundleBuilder } = require("./BundleBuilder");
const Generator = require("./Generator");
const { generateFunctionMap } = require("./generateFunctionMap");
const SourceMap = require("source-map");

@@ -95,3 +94,3 @@ function fromRawMappingsImpl(isBlocking, onDone, modules, offsetLines) {

true,
g => {
(g) => {
generator = g;

@@ -111,3 +110,3 @@ },

async function fromRawMappingsNonBlocking(modules, offsetLines = 0) {
return new Promise(resolve => {
return new Promise((resolve) => {
fromRawMappingsImpl(false, resolve, modules, offsetLines);

@@ -123,14 +122,14 @@ });

const rawMappings = [];
new SourceMap.SourceMapConsumer(sourceMap).eachMapping(map => {
new SourceMap.SourceMapConsumer(sourceMap).eachMapping((map) => {
rawMappings.push({
generated: {
line: map.generatedLine,
column: map.generatedColumn
column: map.generatedColumn,
},
original: {
line: map.originalLine,
column: map.originalColumn
column: map.originalColumn,
},
source: map.source,
name: map.name
name: map.name,
});

@@ -191,6 +190,6 @@ });

function countLines(string) {
return string.split("\n").length;
}
const newline = /\r\n?|\n|\u2028|\u2029/g;
const countLines = (string) => (string.match(newline) || []).length + 1;
module.exports = {

@@ -206,3 +205,3 @@ BundleBuilder,

toBabelSegments,
toSegmentTuple
toSegmentTuple,
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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