'use client' import type { CSSProperties } from 'react' import type { DiffFileModel, RenderHunk, RenderLine } from './build-model' import type { TokenLines } from './use-diff-tokens' import { cn } from '../../lib/utils' import { Skeleton } from '../ui/skeleton' import { buildSegments } from './render-segments' import { useDiffTokens } from './use-diff-tokens' const NUMBER_CELL = 'w-10 shrink-0 select-none px-1.5 text-right tabular-nums color-faint' /** A line's content, split into syntax-colored segments with intra-line emphasis. */ function LineContent({ line, tokens }: { line: RenderLine, tokens: TokenLines | null }) { const segments = buildSegments(tokens?.[line.tokenLine], line.content, line.wordRanges) const changedBg = line.type === 'add' ? 'bg-success/25' : 'bg-error/25' return ( <> {segments.map((segment, i) => ( {segment.text} ))} > ) } /** One diff row: old/new line-number gutters, the +/- marker, and the code. */ function DiffLine({ line, tokens }: { line: RenderLine, tokens: TokenLines | null }) { const bg = line.type === 'add' ? 'bg-success/10' : line.type === 'del' ? 'bg-error/10' : '' const marker = line.type === 'add' ? '+' : line.type === 'del' ? '−' : ' ' const markerColor = line.type === 'add' ? 'text-success' : line.type === 'del' ? 'text-error' : 'color-faint' return (
No textual diff (binary or metadata-only change).
if (loading && !unavailable) return