import { useMemo } from 'react' import { CodeFrame } from '../../components/code-frame/code-frame' import { ErrorOverlayCallStack } from '../../components/errors/error-overlay-call-stack/error-overlay-call-stack' import { PSEUDO_HTML_DIFF_STYLES } from './component-stack-pseudo-html' import { useFrames, type ReadyRuntimeError, } from '../../utils/get-error-by-type' type RuntimeErrorProps = { error: ReadyRuntimeError dialogResizerRef: React.RefObject } export function RuntimeError({ error, dialogResizerRef }: RuntimeErrorProps) { const frames = useFrames(error) const firstFrame = useMemo(() => { const firstFirstPartyFrameIndex = frames.findIndex( (entry) => !entry.ignored && Boolean(entry.originalCodeFrame) && Boolean(entry.originalStackFrame) ) return frames[firstFirstPartyFrameIndex] ?? null }, [frames]) return ( <> {firstFrame && ( )} {frames.length > 0 && ( )} ) } export const styles = ` ${PSEUDO_HTML_DIFF_STYLES} `