metro-source-map
Advanced tools
Comparing version 0.63.0 to 0.64.0
{ | ||
"name": "metro-source-map", | ||
"version": "0.63.0", | ||
"version": "0.64.0", | ||
"description": "🚇 Source map generator for Metro.", | ||
@@ -18,4 +18,5 @@ "main": "src/source-map.js", | ||
"invariant": "^2.2.4", | ||
"metro-symbolicate": "0.63.0", | ||
"ob1": "0.63.0", | ||
"metro-symbolicate": "0.64.0", | ||
"nullthrows": "^1.1.1", | ||
"ob1": "0.64.0", | ||
"source-map": "^0.5.6", | ||
@@ -22,0 +23,0 @@ "vlq": "^1.0.0" |
@@ -17,5 +17,4 @@ /** | ||
const _require = require("source-map"), | ||
SourceMapGenerator = _require.SourceMapGenerator; | ||
SourceMapGenerator = _require.SourceMapGenerator; // Originally based on https://github.com/jakobwesthoff/source-map-merger | ||
// Originally based on https://github.com/jakobwesthoff/source-map-merger | ||
function composeSourceMaps(maps) { | ||
@@ -22,0 +21,0 @@ // NOTE: require() here to break dependency cycle |
@@ -16,5 +16,4 @@ /** | ||
GENERATED_ORDER = _require.GENERATED_ORDER, | ||
iterationOrderToString = _require.iterationOrderToString; | ||
iterationOrderToString = _require.iterationOrderToString; // Implementation details shared between MappingsConsumer and SectionsConsumer | ||
// Implementation details shared between MappingsConsumer and SectionsConsumer | ||
class AbstractConsumer { | ||
@@ -21,0 +20,0 @@ constructor(sourceMap) { |
@@ -23,2 +23,3 @@ /** | ||
} | ||
return obj; | ||
@@ -34,3 +35,2 @@ } | ||
LEAST_UPPER_BOUND = _require.LEAST_UPPER_BOUND; | ||
/** | ||
@@ -41,2 +41,3 @@ * A source map consumer that supports both "basic" and "indexed" source maps. | ||
*/ | ||
class DelegatingConsumer { | ||
@@ -43,0 +44,0 @@ constructor(sourceMap) { |
@@ -63,3 +63,5 @@ /** | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
@@ -75,2 +77,3 @@ } | ||
var _e = undefined; | ||
try { | ||
@@ -83,2 +86,3 @@ for ( | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
@@ -96,2 +100,3 @@ } | ||
} | ||
return _arr; | ||
@@ -106,2 +111,3 @@ } | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
@@ -115,2 +121,3 @@ var symbols = Object.getOwnPropertySymbols(object); | ||
} | ||
return keys; | ||
@@ -122,2 +129,3 @@ } | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
@@ -139,2 +147,3 @@ ownKeys(Object(source), true).forEach(function(key) { | ||
} | ||
return target; | ||
@@ -154,2 +163,3 @@ } | ||
} | ||
return obj; | ||
@@ -183,3 +193,2 @@ } | ||
decodeVlq = _require4.decode; | ||
/** | ||
@@ -189,2 +198,3 @@ * A source map consumer that supports "basic" source maps (that have a | ||
*/ | ||
class MappingsConsumer extends AbstractConsumer { | ||
@@ -191,0 +201,0 @@ constructor(sourceMap) { |
@@ -14,2 +14,3 @@ /** | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
@@ -23,2 +24,3 @@ var symbols = Object.getOwnPropertySymbols(object); | ||
} | ||
return keys; | ||
@@ -30,2 +32,3 @@ } | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
@@ -47,2 +50,3 @@ ownKeys(Object(source), true).forEach(function(key) { | ||
} | ||
return target; | ||
@@ -62,2 +66,3 @@ } | ||
} | ||
return obj; | ||
@@ -64,0 +69,0 @@ } |
@@ -14,2 +14,3 @@ /** | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
@@ -23,2 +24,3 @@ var symbols = Object.getOwnPropertySymbols(object); | ||
} | ||
return keys; | ||
@@ -30,2 +32,3 @@ } | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
@@ -47,2 +50,3 @@ ownKeys(Object(source), true).forEach(function(key) { | ||
} | ||
return target; | ||
@@ -62,2 +66,3 @@ } | ||
} | ||
return obj; | ||
@@ -93,3 +98,5 @@ } | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
@@ -105,2 +112,3 @@ } | ||
var _e = undefined; | ||
try { | ||
@@ -113,2 +121,3 @@ for ( | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
@@ -126,2 +135,3 @@ } | ||
} | ||
return _arr; | ||
@@ -156,3 +166,2 @@ } | ||
sub = _require4.sub; | ||
/** | ||
@@ -162,2 +171,3 @@ * A source map consumer that supports "indexed" source maps (that have a | ||
*/ | ||
class SectionsConsumer extends AbstractConsumer { | ||
@@ -164,0 +174,0 @@ constructor(sourceMap) { |
@@ -10,5 +10,2 @@ /** | ||
*/ | ||
// NOTE: The linter and formatter are fighting over the following lint rule. | ||
/* eslint-disable flowtype/object-type-delimiter */ | ||
"use strict"; |
@@ -14,4 +14,10 @@ /** | ||
var _types = require("@babel/types"); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { default: obj }; | ||
return obj && obj.__esModule | ||
? obj | ||
: { | ||
default: obj | ||
}; | ||
} | ||
@@ -41,2 +47,3 @@ | ||
var _e = undefined; | ||
try { | ||
@@ -49,2 +56,3 @@ for ( | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
@@ -62,2 +70,3 @@ } | ||
} | ||
return _arr; | ||
@@ -106,3 +115,5 @@ } | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
@@ -115,4 +126,5 @@ } | ||
const nullthrows = require("nullthrows"); | ||
const t = require("@babel/types"); | ||
/** | ||
@@ -126,2 +138,3 @@ * Generate a map of source positions to function names. The names are meant to | ||
*/ | ||
function generateFunctionMap(ast, context) { | ||
@@ -203,18 +216,21 @@ const encoder = new MappingEncoder(); | ||
: null; | ||
(0, _traverse.default)(ast, { | ||
"Function|Program|Class": { | ||
enter(path) { | ||
let name = getNameForPath(path); | ||
const visitor = { | ||
enter(path) { | ||
let name = getNameForPath(path); | ||
if (basename) { | ||
name = removeNamePrefix(name, basename); | ||
} | ||
if (basename) { | ||
name = removeNamePrefix(name, basename); | ||
} | ||
pushFrame(name, path.node.loc); | ||
}, | ||
pushFrame(name, nullthrows(path.node.loc)); | ||
}, | ||
exit(path) { | ||
popFrame(); | ||
} | ||
exit(path) { | ||
popFrame(); | ||
} | ||
}; | ||
(0, _traverse.default)(ast, { | ||
Function: visitor, | ||
Program: visitor, | ||
Class: visitor | ||
}); | ||
@@ -235,9 +251,11 @@ } | ||
if (t.isProgram(node)) { | ||
if ((0, _types.isProgram)(node)) { | ||
return "<global>"; | ||
} | ||
let id = path.id; // has an `id` so we don't need to infer one | ||
let _ref = path, | ||
id = _ref.id; // 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; | ||
@@ -249,3 +267,3 @@ } | ||
if (t.isObjectMethod(node) || t.isClassMethod(node)) { | ||
if ((0, _types.isObjectMethod)(node) || (0, _types.isClassMethod)(node)) { | ||
id = node.key; | ||
@@ -258,26 +276,51 @@ | ||
propertyPath = path; | ||
} else if (t.isObjectProperty(parent) || t.isClassProperty(parent)) { | ||
} else if ( | ||
(0, _types.isObjectProperty)(parent) || | ||
(0, _types.isClassProperty)(parent) | ||
) { | ||
// { foo() {} }; | ||
id = parent.key; | ||
propertyPath = parentPath; | ||
} else if (t.isVariableDeclarator(parent)) { | ||
} else if ((0, _types.isVariableDeclarator)(parent)) { | ||
// let foo = function () {}; | ||
id = parent.id; | ||
} else if (t.isAssignmentExpression(parent)) { | ||
} else if ((0, _types.isAssignmentExpression)(parent)) { | ||
// foo = function () {}; | ||
id = parent.left; | ||
} else if (t.isJSXExpressionContainer(parent)) { | ||
if (t.isJSXElement(parentPath.parentPath.node)) { | ||
} else if ((0, _types.isJSXExpressionContainer)(parent)) { | ||
var _parentPath$parentPat; | ||
const grandParentNode = | ||
parentPath === null || parentPath === void 0 | ||
? void 0 | ||
: (_parentPath$parentPat = parentPath.parentPath) === null || | ||
_parentPath$parentPat === void 0 | ||
? void 0 | ||
: _parentPath$parentPat.node; | ||
if ((0, _types.isJSXElement)(grandParentNode)) { | ||
// <foo>{function () {}}</foo> | ||
const openingElement = parentPath.parentPath.node.openingElement; | ||
id = t.JSXMemberExpression( | ||
t.JSXMemberExpression(openingElement.name, t.JSXIdentifier("props")), | ||
t.JSXIdentifier("children") | ||
const openingElement = grandParentNode.openingElement; | ||
id = t.jsxMemberExpression( | ||
// $FlowFixMe Flow error uncovered by typing Babel more strictly | ||
t.jsxMemberExpression(openingElement.name, t.jsxIdentifier("props")), | ||
t.jsxIdentifier("children") | ||
); | ||
} else if (t.isJSXAttribute(parentPath.parentPath.node)) { | ||
// <foo bar={function () {}} /> | ||
const openingElement = parentPath.parentPath.parentPath.node; | ||
const prop = parentPath.parentPath.node; | ||
id = t.JSXMemberExpression( | ||
t.JSXMemberExpression(openingElement.name, t.JSXIdentifier("props")), | ||
} else if ((0, _types.isJSXAttribute)(grandParentNode)) { | ||
var _parentPath$parentPat2, _parentPath$parentPat3; // <foo bar={function () {}} /> | ||
const openingElement = | ||
parentPath === null || parentPath === void 0 | ||
? void 0 | ||
: (_parentPath$parentPat2 = parentPath.parentPath) === null || | ||
_parentPath$parentPat2 === void 0 | ||
? void 0 | ||
: (_parentPath$parentPat3 = _parentPath$parentPat2.parentPath) === | ||
null || _parentPath$parentPat3 === void 0 | ||
? void 0 | ||
: _parentPath$parentPat3.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 | ||
@@ -291,3 +334,6 @@ ); | ||
if (name == null) { | ||
if (t.isCallExpression(parent) || t.isNewExpression(parent)) { | ||
if ( | ||
(0, _types.isCallExpression)(parent) || | ||
(0, _types.isNewExpression)(parent) | ||
) { | ||
// foo(function () {}) | ||
@@ -300,3 +346,3 @@ const argIndex = parent.arguments.indexOf(node); | ||
if (CALLEES_TO_SKIP.indexOf(calleeName) !== -1) { | ||
return getNameForPath(parentPath); | ||
return getNameForPath(nullthrows(parentPath)); | ||
} | ||
@@ -310,2 +356,9 @@ | ||
if ( | ||
(0, _types.isTypeCastExpression)(parent) && | ||
parent.expression === node | ||
) { | ||
return getNameForPath(nullthrows(parentPath)); | ||
} | ||
return ANONYMOUS_NAME; | ||
@@ -319,11 +372,13 @@ } | ||
if (propertyPath) { | ||
if (t.isClassBody(propertyPath.parent)) { | ||
if ((0, _types.isClassBody)(propertyPath.parent)) { | ||
// $FlowFixMe Disvoered when typing babel-traverse | ||
const className = getNameForPath(propertyPath.parentPath.parentPath); | ||
if (className !== ANONYMOUS_NAME) { | ||
// $FlowFixMe Flow error uncovered by typing Babel more strictly | ||
const separator = propertyPath.node.static ? "." : "#"; | ||
name = className + separator + name; | ||
} | ||
} else if (t.isObjectExpression(propertyPath.parent)) { | ||
const objectName = getNameForPath(propertyPath.parentPath); | ||
} else if ((0, _types.isObjectExpression)(propertyPath.parent)) { | ||
const objectName = getNameForPath(nullthrows(propertyPath.parentPath)); | ||
@@ -340,7 +395,9 @@ if (objectName !== ANONYMOUS_NAME) { | ||
function isAnyMemberExpression(node) { | ||
return t.isMemberExpression(node) || t.isJSXMemberExpression(node); | ||
return ( | ||
node.type === "MemberExpression" || node.type === "JSXMemberExpression" | ||
); | ||
} | ||
function isAnyIdentifier(node) { | ||
return t.isIdentifier(node) || t.isJSXIdentifier(node); | ||
return (0, _types.isIdentifier)(node) || (0, _types.isJSXIdentifier)(node); | ||
} | ||
@@ -375,7 +432,7 @@ | ||
if (t.isCallExpression(id) || t.isNewExpression(id)) { | ||
if ((0, _types.isCallExpression)(id) || (0, _types.isNewExpression)(id)) { | ||
return getNamePartsFromId(id.callee); | ||
} | ||
if (t.isTypeCastExpression(id)) { | ||
if ((0, _types.isTypeCastExpression)(id)) { | ||
return getNamePartsFromId(id.expression); | ||
@@ -388,10 +445,14 @@ } | ||
name = id.name; | ||
} else if (t.isNullLiteral(id)) { | ||
} else if ((0, _types.isNullLiteral)(id)) { | ||
name = "null"; | ||
} else if (t.isRegExpLiteral(id)) { | ||
name = `_${id.pattern}_${id.flags}`; | ||
} else if (t.isTemplateLiteral(id)) { | ||
} else if ((0, _types.isRegExpLiteral)(id)) { | ||
var _id$flags; | ||
name = `_${id.pattern}_${ | ||
(_id$flags = id.flags) !== null && _id$flags !== void 0 ? _id$flags : "" | ||
}`; | ||
} else if ((0, _types.isTemplateLiteral)(id)) { | ||
name = id.quasis.map(quasi => quasi.value.raw).join(""); | ||
} else if (t.isLiteral(id) && id.value != null) { | ||
name = id.value + ""; | ||
} else if ((0, _types.isLiteral)(id) && id.value != null) { | ||
name = String(id.value); | ||
} | ||
@@ -403,3 +464,3 @@ | ||
if (t.isImport(id)) { | ||
if ((0, _types.isImport)(id)) { | ||
name = "import"; | ||
@@ -416,3 +477,3 @@ } | ||
id.object.name === "Symbol" && | ||
(isAnyIdentifier(id.property) || t.isLiteral(id.property)) | ||
(isAnyIdentifier(id.property) || (0, _types.isLiteral)(id.property)) | ||
) { | ||
@@ -459,5 +520,5 @@ const propertyName = getNameFromId(id.property); | ||
const _ref = shortenedName.match(DELIMITER_START_RE) || [], | ||
_ref2 = _slicedToArray(_ref, 1), | ||
delimiterMatch = _ref2[0]; | ||
const _ref2 = shortenedName.match(DELIMITER_START_RE) || [], | ||
_ref3 = _slicedToArray(_ref2, 1), | ||
delimiterMatch = _ref3[0]; | ||
@@ -512,5 +573,5 @@ if (delimiterMatch) { | ||
push(_ref3) { | ||
let name = _ref3.name, | ||
start = _ref3.start; | ||
push(_ref4) { | ||
let name = _ref4.name, | ||
start = _ref4.start; | ||
@@ -517,0 +578,0 @@ let nameIndex = this._namesMap.get(name); |
@@ -14,2 +14,3 @@ /** | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
@@ -23,2 +24,3 @@ var symbols = Object.getOwnPropertySymbols(object); | ||
} | ||
return keys; | ||
@@ -30,2 +32,3 @@ } | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
@@ -47,2 +50,3 @@ ownKeys(Object(source), true).forEach(function(key) { | ||
} | ||
return target; | ||
@@ -62,2 +66,3 @@ } | ||
} | ||
return obj; | ||
@@ -67,3 +72,2 @@ } | ||
const B64Builder = require("./B64Builder"); | ||
/** | ||
@@ -80,2 +84,3 @@ * Generates a source map from raw mappings. | ||
*/ | ||
class Generator { | ||
@@ -82,0 +87,0 @@ constructor() { |
@@ -20,2 +20,3 @@ /** | ||
} | ||
if (info.done) { | ||
@@ -34,8 +35,11 @@ resolve(value); | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
@@ -50,5 +54,4 @@ }); | ||
const SourceMap = require("source-map"); | ||
const SourceMap = require("source-map"); // We need to export this for `metro-symbolicate` | ||
// We need to export this for `metro-symbolicate` | ||
const normalizeSourcePath = require("./Consumer/normalizeSourcePath"); | ||
@@ -55,0 +58,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129010
2344
8
+ Addednullthrows@^1.1.1
+ Addedmetro-symbolicate@0.64.0(transitive)
+ Addednullthrows@1.1.1(transitive)
+ Addedob1@0.64.0(transitive)
- Removedmetro-symbolicate@0.63.0(transitive)
- Removedob1@0.63.0(transitive)
Updatedmetro-symbolicate@0.64.0
Updatedob1@0.64.0