react-native-macos/Libraries/Core/Devtools/parseErrorStack.js

60 строки
1.5 KiB
JavaScript
Исходник Обычный вид История

2015-01-30 04:10:49 +03:00
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
2015-01-30 04:10:49 +03:00
*
* @format
* @flow strict
2015-01-30 04:10:49 +03:00
*/
2015-01-30 04:10:49 +03:00
'use strict';
import type {StackFrame} from '../NativeExceptionsManager';
import type {HermesParsedStack} from './parseHermesStack';
const parseHermesStack = require('./parseHermesStack');
2015-01-30 04:10:49 +03:00
function convertHermesStack(stack: HermesParsedStack): Array<StackFrame> {
const frames = [];
for (const entry of stack.entries) {
if (entry.type !== 'FRAME') {
continue;
}
const {location, functionName} = entry;
if (location.type === 'NATIVE') {
continue;
}
frames.push({
methodName: functionName,
file: location.sourceUrl,
lineNumber: location.line1Based,
column:
location.type === 'SOURCE'
? location.column1Based - 1
: location.virtualOffset0Based,
});
}
return frames;
}
function parseErrorStack(errorStack?: string): Array<StackFrame> {
if (errorStack == null) {
return [];
}
const stacktraceParser = require('stacktrace-parser');
const parsedStack = Array.isArray(errorStack)
? errorStack
: global.HermesInternal
? convertHermesStack(parseHermesStack(errorStack))
: stacktraceParser.parse(errorStack).map(frame => ({
...frame,
column: frame.column != null ? frame.column - 1 : null,
}));
2015-01-30 04:10:49 +03:00
return parsedStack;
2015-01-30 04:10:49 +03:00
}
Updates from Thu 19 Mar - [ReactNative] Add root package.json name back | Tadeu Zagallo - [react-packager] Make sure projectRoots is converted to an array | Amjad Masad - [ReactNative] Init script that bootstraps new Xcode project | Alex Kotliarskyi - [ReactNative] New SampleApp | Alex Kotliarskyi - [ReactNative] Touchable invoke press on longPress when longPress handler missing | Eric Vicenti - [ReactNative] Commit missing RCTWebSocketDebugger.xcodeproj | Alex Kotliarskyi - [ReactNative] Add Custom Components folder | Christopher Chedeau - [react-packager] Hash cache file name information to avoid long names | Amjad Masad - [ReactNative] Put all iOS-related files in a subfolder | Alex Kotliarskyi - [react-packager] Fix OOM | Amjad Masad - [ReactNative] Bring Chrome debugger to OSS. Part 2 | Alex Kotliarskyi - [ReactNative] Add search to UIExplorer | Tadeu Zagallo - [ReactNative][RFC] Bring Chrome debugger to OSS. Part 1 | Alex Kotliarskyi - [ReactNative] Return the appropriate status code from XHR | Tadeu Zagallo - [ReactNative] Make JS stack traces in Xcode prettier | Alex Kotliarskyi - [ReactNative] Remove duplicate package.json with the same name | Christopher Chedeau - [ReactNative] Remove invariant from require('react-native') | Christopher Chedeau - [ReactNative] Remove ListViewDataSource from require('react-native') | Christopher Chedeau - [react-packager] Add assetRoots option | Amjad Masad - Convert UIExplorer to ListView | Christopher Chedeau - purge rni | Basil Hosmer - [ReactNative] s/render*View/render/ in <WebView> | Christopher Chedeau
2015-03-20 18:43:51 +03:00
module.exports = parseErrorStack;