trace-tab

This commit is contained in:
Nathan Bierema 2024-08-04 20:01:19 -04:00
parent d099ed4809
commit 9321b91552
8 changed files with 13 additions and 12 deletions

View File

@ -1,6 +1,6 @@
import StackFrame from './react-error-overlay/utils/stack-frame'; import StackFrame from './react-error-overlay/utils/stack-frame';
const isFF = navigator.userAgent.indexOf('Firefox') !== -1; const isFF = navigator.userAgent.includes('Firefox');
function openResource( function openResource(
fileName: string, fileName: string,

View File

@ -76,7 +76,7 @@ class StackFrame extends Component<Props, State> {
return null; return null;
} }
// e.g. "/path-to-my-app/webpack/bootstrap eaddeb46b67d75e4dfc1" // e.g. "/path-to-my-app/webpack/bootstrap eaddeb46b67d75e4dfc1"
const isInternalWebpackBootstrapCode = fileName.trim().indexOf(' ') !== -1; const isInternalWebpackBootstrapCode = fileName.trim().includes(' ');
if (isInternalWebpackBootstrapCode) { if (isInternalWebpackBootstrapCode) {
return null; return null;
} }

View File

@ -83,7 +83,7 @@ function StackFrameCodeBlock(props: StackFrameCodeBlockPropsType) {
if (text == null) { if (text == null) {
continue; continue;
} }
if (text.indexOf(` ${lineNum} |`) === -1) { if (!text.includes(` ${lineNum} |`)) {
continue; continue;
} }
// $FlowFixMe // $FlowFixMe

View File

@ -88,7 +88,9 @@ export function extractSourceMapUrl(
match = next; match = next;
} }
if (!(match && match[1])) { if (!(match && match[1])) {
return Promise.reject(`Cannot find a source map directive for ${fileUri}.`); return Promise.reject(
new Error(`Cannot find a source map directive for ${fileUri}.`),
);
} }
return Promise.resolve(match[1].toString()); return Promise.resolve(match[1].toString());
} }

View File

@ -51,8 +51,7 @@ function getStackFrames(
return enhancedFrames.filter( return enhancedFrames.filter(
({ functionName, fileName }) => ({ functionName, fileName }) =>
(functionName == null || (functionName == null ||
functionName.indexOf('__stack_frame_overlay_proxy_console__') === !functionName.includes('__stack_frame_overlay_proxy_console__')) &&
-1) &&
!toExclude.test(fileName!), !toExclude.test(fileName!),
); );
}); });

View File

@ -12,9 +12,9 @@ function isInternalFile(
return ( return (
sourceFileName == null || sourceFileName == null ||
sourceFileName === '' || sourceFileName === '' ||
sourceFileName.indexOf('/~/') !== -1 || sourceFileName.includes('/~/') ||
sourceFileName.indexOf('/node_modules/') !== -1 || sourceFileName.includes('/node_modules/') ||
sourceFileName.trim().indexOf(' ') !== -1 || sourceFileName.trim().includes(' ') ||
fileName == null || fileName == null ||
fileName === '' fileName === ''
); );

View File

@ -30,7 +30,7 @@ async function map(
if (fileName == null) { if (fileName == null) {
return; return;
} }
if (files.indexOf(fileName) !== -1) { if (files.includes(fileName)) {
return; return;
} }
files.push(fileName); files.push(fileName);

View File

@ -50,10 +50,10 @@ function parseStack(stack: string[]): StackFrame[] {
); );
} else { } else {
// Strip eval, we don't care about it // Strip eval, we don't care about it
if (e.indexOf('(eval ') !== -1) { if (e.includes('(eval ')) {
e = e.replace(/(\(eval at [^()]*)|(\),.*$)/g, ''); e = e.replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
} }
if (e.indexOf('(at ') !== -1) { if (e.includes('(at ')) {
e = e.replace(/\(at /, '('); e = e.replace(/\(at /, '(');
} }
const data = e.trim().split(/\s+/g).slice(1); const data = e.trim().split(/\s+/g).slice(1);