Release Highlights
-
Shared incremental DOM rendering. Diff viewing and editing now use the same renderer, patching only affected rows. It matches or beats the previous renderers' performance across viewing and editing.
-
Faster diffing with WebAssembly.
@pierre/patchesis an optional, significantly faster replacement forjsdiff, with the same diff output. Enable it throughFileDifforCodeViewoptions:<CodeView items={items} options={{ parseDiffOptions: { preferredDiffLib: '@pierre/patches' } }} />
With a worker pool, also set
highlighterOptions.preferredDiffLibto'@pierre/patches'for inline highlights. -
Find and replace in CodeView. Cmd/Ctrl+F searches across all items and opens collapsed files or context when it lands on a match. Focus an editor to search and replace within that file, with highlights that stay in sync as you type. Drive it from code with
openSearch,closeSearch,navigateSearch, andisSearchOpenonCodeViewor its React ref.searchOptionssets the default toggles or turns off the shortcuts, andonSearchStateChangereports the panel state. -
Deferred highlighter on hydrate. With
deferHydrationHighlight: true, hydrated prerendered HTML doesn't load the highlighter until a render needs it, so prerendered code that never changes never downloads Shiki. -
Long lines are cut. A line longer than
tokenizeMaxLineLength(default 1000 characters) now renders its first 1000 characters with a "Show full line" button instead of the whole unhighlighted line, so a minified bundle or a data file no longer stalls layout. Edit sessions always show the full line, and find still searches the hidden part: a match there lands on the button. Set the option to0to disable the cut together with the highlight limit. -
Translations. Every string the diff renders, from the collapsed-context separators to the search panel, now comes from one package-level
i18nstore. Calli18n.set({ locale, messages })once at boot; messages are ICU MessageFormat strings with{name}arguments and one plural block, andlocalealso sets number formatting. Components on screen re-render when it is called again. Keys you leave out keep their English defaults.import { i18n } from '@pierre/diffs'; i18n.set({ locale: 'de', messages: { expandAll: 'Alle erweitern' }, });
Breaking changes
Renderer results
HunksRenderResult and FileRenderResult no longer expose *GutterAST, *ContentAST, gutterAST, contentAST, or css. Use the renderer to generate code nodes:
const diffNodes = diffRenderer.renderCodeAST('additions', diffResult);
const fileNodes = fileRenderer.renderCodeAST(fileResult);Diff columns accept 'unified', 'deletions', or 'additions'. For separate raw gutter/content cells, use columnCells(fileResult.column) or columnCells(diffResult.columns[type]) when that column exists. Remove reads of css; it was always empty.
FileRenderer.renderPartialHTML was also removed. Replace it with:
import { hastToHtml } from '@pierre/diffs';
const html = hastToHtml(fileRenderer.renderCodeAST(result));Editor callbacks
Calling edit, applyEdits, undo, redo, or cleanUp inside onChange or onEditChange now throws, as does rendering a new file or diff there. Defer follow-up mutations until the callback returns:
onEditChange({ file }) {
queueMicrotask(() => editor.applyEdits(formatOn(file)));
}These callbacks report the updated document synchronously; the rendered DOM may still be behind.
Vanilla editor attach
editor.edit() now throws until the component is ready: a file is set, a partial diff has loaded its full files, and no worker pool highlight for the input is in flight. React and CodeView wait on their own. Vanilla code awaits prepareForEditing(), which now exists on File as well as FileDiff, before attaching:
fileInstance.render({ file, containerWrapper });
if (!fileInstance.isReadyToEdit()) {
await fileInstance.prepareForEditing();
}
const dispose = editor.edit(fileInstance);Word diff marks in custom rendering
renderDiffWithHighlighter no longer adds data-diff-span marks or applies lineDiffType / maxLineDiffLength. If you consume its rows directly, add the marks yourself using your previous settings (defaults: 'word-alt', 1000):
import {
DiffModel,
LineDiffRangeCache,
lineDiffRangesFor,
markRow,
} from '@pierre/diffs';
const model = DiffModel.fromDiff(diff);
const ranges = new LineDiffRangeCache('word-alt', 1000);
const additionLines = code.additionLines.map((row, line) =>
row.type === 'element'
? markRow(row, lineDiffRangesFor(model, 'additions', line, ranges))
: row
);Here, code is the helper's returned code. Repeat for code.deletionLines with 'deletions'. Built-in components apply these marks automatically.
Custom CodeView editor factories
createEditor now receives onFocus, onBlur, onRender, and searchPanel: 'host' alongside onChange. Pass the full options object to new Editor(type, options, editStateKey) so the new options reach the editor.
Search styling
Replace [data-match-range] selectors with ::highlight(diffs-search-match) and ::highlight(diffs-search-current). --diffs-editor-match-bg and --diffs-editor-match-highlight-bg were removed; set these variables on the host instead:
| Appearance | Variable |
|---|---|
| Match text | --diffs-fg-search-match-override
|
| Match background | --diffs-bg-search-match-override
|
| Current match text | --diffs-fg-search-match-current-override
|
| Current match background | --diffs-bg-search-match-current-override
|
A theme's editor.findMatch* colors now apply only when it sets both the background and the foreground.
Match painting requires CSS.highlights; navigation and replacement still work without it.
The find panel now has its own shadow root. Existing panel hooks still work through unsafeCSS, but :host now targets the panel. Remove selectors that depend on file-container ancestors; position the panel with --diffs-search-panel-inset-top and --diffs-search-panel-inset-right. Close and reopen an existing panel to apply changed unsafeCSS.
Other component selectors were flattened (gutter numbers, [data-indicators], conflict markers, selected lines). If an override stops winning, adjust its specificity; place panel overrides in @layer unsafe to override @layer base.
TextDocument line endings
normalizeEol(text) now returns \n-normalized text. Use getText() or getLineText(line, true) when you need the file's original line endings.