Socket
Socket
Sign inDemoInstall

metro-symbolicate

Package Overview
Dependencies
Maintainers
2
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro-symbolicate - npm Package Compare versions

Comparing version 0.53.0 to 0.53.1

src.real/__tests__/__fixtures__/testfile.ram.js.map

2

package.json
{
"name": "metro-symbolicate",
"version": "0.53.0",
"version": "0.53.1",
"description": "A tool to find the source location from JS bundles and stack traces.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -58,2 +58,3 @@ /**

const WITH_FUNCTION_MAP_MAP = resolve('with-function-map.js.map');
const TESTFILE_RAM_MAP = resolve('testfile.ram.js.map');

@@ -106,1 +107,14 @@ test('symbolicating a stack trace', async () =>

).resolves.toMatchSnapshot());
test('symbolicating a stack trace with a segmented RAM bundle map', async () =>
await expect(
execute([TESTFILE_RAM_MAP], read('testfile.ram.stack')),
).resolves.toMatchSnapshot());
test('symbolicating a stack trace ignoring a function map', async () =>
await expect(
execute(
['--no-function-names', WITH_FUNCTION_MAP_MAP],
read('with-function-map.stack'),
),
).resolves.toMatchSnapshot());

@@ -30,2 +30,14 @@ #!/usr/bin/env node

const argv = process.argv.slice(2);
function checkAndRemoveArg(arg) {
let value = false;
for (let idx = argv.indexOf(arg); idx !== -1; idx = argv.indexOf(arg)) {
argv.splice(idx, 1);
value = true;
}
return value;
}
const noFunctionNames = checkAndRemoveArg('--no-function-names');
if (argv.length < 1 || argv.length > 4) {

@@ -35,9 +47,16 @@ /* eslint no-path-concat: "off" */

const usages = [
'Usage: ' + __filename + ' <source-map-file>',
' ' + __filename + ' <source-map-file> <line> [column]',
' ' + __filename + ' <source-map-file> <moduleId>.js <line> [column]',
' ' + __filename + ' <source-map-file> <mapfile>.profmap',
'Usage: ' + __filename + ' <source-map-file> [--no-function-names]',
' ' +
__filename +
' <source-map-file> --attribution < attribution.jsonl > symbolicated.jsonl',
' <source-map-file> <line> [column] [--no-function-names]',
' ' +
__filename +
' <source-map-file> <moduleId>.js <line> [column] [--no-function-names]',
' ' +
__filename +
' <source-map-file> <mapfile>.profmap [--no-function-names]',
' ' +
__filename +
' <source-map-file> --attribution [--no-function-names] < attribution.jsonl ' +
' > symbolicated.jsonl',
' ' + __filename + ' <source-map-file> <tracefile>.cpuprofile',

@@ -52,3 +71,5 @@ ];

const content = fs.readFileSync(sourceMapFileName, 'utf8');
const context = Symbolication.createContext(SourceMapConsumer, content);
const context = Symbolication.createContext(SourceMapConsumer, content, {
nameSource: noFunctionNames ? 'identifier_names' : 'function_names',
});

@@ -55,0 +76,0 @@ if (argv.length === 0) {

@@ -84,3 +84,12 @@ /**

function createContext(SourceMapConsumer, sourceMapContent) {
function createContext(
SourceMapConsumer,
sourceMapContent,
options /*: {nameSource?: 'function_names' | 'identifier_names'} */ = {},
) {
const useFunctionNames =
!options ||
!('nameSource' in options) ||
!options.nameSource ||
options.nameSource === 'function_names';
var sourceMapJson = JSON.parse(sourceMapContent.replace(/^\)\]\}'/, ''));

@@ -93,3 +102,5 @@ return {

moduleOffsets: map.x_facebook_offsets || {},
sourceFunctionsConsumer: new SourceMetadataMapConsumer(map),
sourceFunctionsConsumer: useFunctionNames
? new SourceMetadataMapConsumer(map)
: null,
};

@@ -102,3 +113,5 @@ return acc;

moduleOffsets: sourceMapJson.x_facebook_offsets || {},
sourceFunctionsConsumer: new SourceMetadataMapConsumer(sourceMapJson),
sourceFunctionsConsumer: useFunctionNames
? new SourceMetadataMapConsumer(sourceMapJson)
: null,
},

@@ -116,2 +129,4 @@ },

// IOS: foo@123.js:4:18131, Android: bar:123.js:4:18063
// sample stack trace without function name:
// 123.js:4:18131
// sample result:

@@ -123,2 +138,6 @@ // IOS: foo.js:57:foo, Android: bar.js:75:bar

function(match, func, delimiter, fileName, line, column) {
if (delimiter === ':' && func && !fileName) {
fileName = func;
func = null;
}
var original = getOriginalPositionFor(

@@ -125,0 +144,0 @@ line,

@@ -65,12 +65,32 @@ #!/usr/bin/env node

function checkAndRemoveArg(arg) {
let value = false;
for (let idx = argv.indexOf(arg); idx !== -1; idx = argv.indexOf(arg)) {
argv.splice(idx, 1);
value = true;
}
return value;
}
const noFunctionNames = checkAndRemoveArg("--no-function-names");
if (argv.length < 1 || argv.length > 4) {
/* eslint no-path-concat: "off" */
const usages = [
"Usage: " + __filename + " <source-map-file>",
" " + __filename + " <source-map-file> <line> [column]",
" " + __filename + " <source-map-file> <moduleId>.js <line> [column]",
" " + __filename + " <source-map-file> <mapfile>.profmap",
"Usage: " + __filename + " <source-map-file> [--no-function-names]",
" " +
__filename +
" <source-map-file> --attribution < attribution.jsonl > symbolicated.jsonl",
" <source-map-file> <line> [column] [--no-function-names]",
" " +
__filename +
" <source-map-file> <moduleId>.js <line> [column] [--no-function-names]",
" " +
__filename +
" <source-map-file> <mapfile>.profmap [--no-function-names]",
" " +
__filename +
" <source-map-file> --attribution [--no-function-names] < attribution.jsonl " +
" > symbolicated.jsonl",
" " + __filename + " <source-map-file> <tracefile>.cpuprofile"

@@ -84,3 +104,5 @@ ];

const content = fs.readFileSync(sourceMapFileName, "utf8");
const context = Symbolication.createContext(SourceMapConsumer, content);
const context = Symbolication.createContext(SourceMapConsumer, content, {
nameSource: noFunctionNames ? "identifier_names" : "function_names"
});

@@ -87,0 +109,0 @@ if (argv.length === 0) {

@@ -173,2 +173,10 @@ /**

function createContext(SourceMapConsumer, sourceMapContent) {
let options =
/*: {nameSource?: 'function_names' | 'identifier_names'} */
arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
const useFunctionNames =
!options ||
!("nameSource" in options) ||
!options.nameSource ||
options.nameSource === "function_names";
var sourceMapJson = JSON.parse(sourceMapContent.replace(/^\)\]\}'/, ""));

@@ -185,3 +193,5 @@ return {

moduleOffsets: map.x_facebook_offsets || {},
sourceFunctionsConsumer: new SourceMetadataMapConsumer(map)
sourceFunctionsConsumer: useFunctionNames
? new SourceMetadataMapConsumer(map)
: null
};

@@ -194,3 +204,5 @@ return acc;

moduleOffsets: sourceMapJson.x_facebook_offsets || {},
sourceFunctionsConsumer: new SourceMetadataMapConsumer(sourceMapJson)
sourceFunctionsConsumer: useFunctionNames
? new SourceMetadataMapConsumer(sourceMapJson)
: null
}

@@ -206,2 +218,4 @@ }

// IOS: foo@123.js:4:18131, Android: bar:123.js:4:18063
// sample stack trace without function name:
// 123.js:4:18131
// sample result:

@@ -214,2 +228,7 @@ // IOS: foo.js:57:foo, Android: bar.js:75:bar

function(match, func, delimiter, fileName, line, column) {
if (delimiter === ":" && func && !fileName) {
fileName = func;
func = null;
}
var original = getOriginalPositionFor(

@@ -216,0 +235,0 @@ line,

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