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';
const isFF = navigator.userAgent.indexOf('Firefox') !== -1;
const isFF = navigator.userAgent.includes('Firefox');
function openResource(
fileName: string,

View File

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

View File

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

View File

@ -88,7 +88,9 @@ export function extractSourceMapUrl(
match = next;
}
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());
}

View File

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

View File

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

View File

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

View File

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