diffs

Use when an app uses @pierre/diffs to render or edit code files, diffs, patches, merge conflicts, or CodeView review surfaces, including React, vanilla JavaScript, SSR, workers, annotations, selection, and custom Shiki languages or themes.

Install
npx skills add 'https://github.com/pierrecomputer/pierre/tree/main/skills/diffs'
Download bundle ↓
main · 1831817Scanned 2026-09-15

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗
View on GitHub
← Back to SKILL.md

Recipe: render with vanilla JavaScript

Select a surface

Input or layoutClass
One FileContents objectFile
Existing or parsed FileDiffMetadataFileDiff
One file with merge conflictsUnresolvedFile
One large fileVirtualizedFile
One large diffVirtualizedFileDiff
One scroll region with many files and diffsCodeView

Parse the files, create the view, and render it into a host:

import { FileDiff, parseDiffFromFile } from '@pierre/diffs';

const host = document.querySelector<HTMLElement>('#diff');
if (host == null) throw new Error('Missing diff host');

const fileDiff = parseDiffFromFile(
  { name: 'src/value.ts', contents: oldSource },
  { name: 'src/value.ts', contents: newSource }
);

const view = new FileDiff({
  diffStyle: 'split',
  theme: 'pierre-dark',
});

view.render({ fileContainer: host, fileDiff });

Keep the class instance while the host remains mounted. Call render again when the source data changes. Call setOptions, setThemeType, setLineAnnotations, or setSelectedLines for targeted updates.

Use a Virtualizer with VirtualizedFile or VirtualizedFileDiff for one large surface. Use CodeView for a list that shares one scroll region. Call cleanUp() when the host removes the surface.

Referenced from SKILL.md