metro-symbolicate
Advanced tools
Comparing version 0.53.0 to 0.53.1
{ | ||
"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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
120806
22
1611
1