import { cloneFileDiffMetadata, type FileDiffContentsLoader, type FileDiffMetadata, } from "@pierre/diffs"; import { FileDiff } from "@pierre/diffs/react"; import { useRenderedAppearance } from "~/hooks/useTheme"; import { resolveDiffThemeName } from "~/lib/diffRendering"; import { PREFERRED_HIGHLIGHTER } from "~/lib/syntaxHighlighting"; import { DIFF_VIEW_UNSAFE_CSS } from "../../diffs/StyledDiffCodeView"; export function GuideFileDiff({ file, loadDiffFiles, }: { file: FileDiffMetadata; loadDiffFiles: FileDiffContentsLoader; }) { const resolvedTheme = useRenderedAppearance(); // Loading the unchanged lines rewrites the diff it is given; the excerpts read the same file // as a patch, so this view expands a copy of its own. const expandable = cloneFileDiffMetadata(file); const options = { diffStyle: "unified" as const, lineDiffType: "none" as const, overflow: "scroll" as const, disableFileHeader: true, theme: resolveDiffThemeName(resolvedTheme), themeType: resolvedTheme, preferredHighlighter: PREFERRED_HIGHLIGHTER, unsafeCSS: DIFF_VIEW_UNSAFE_CSS, loadDiffFiles, }; return (
); }