Diff engine
Line diffs with histogram (default, git's most readable for code) or linear-space Myers with a cost cut, git's slider placement, hunks with context and the enclosing-definition heading, whitespace options, binary and size guards; changed words or characters within a line; and diffTextAsync, which runs in a Web Worker past 200k characters. The unified-diff parser and printer is the diff-patch item. No dependencies.
Example
Installation
The example also uses the diff-patch adapters:
Adapters
Each adapter is an item of its own that brings diff along. Install only the ones your backend needs.
Diff Patch
diff-patchCopy code
Usage
The diff engine on its own: diffText for line hunks (histogram or Myers, matching git's output), intraline for changed words and diffTextAsync to diff off the main thread. Add the diff-patch adapter for parsePatch, which reads git patches, and formatHunks, which prints hunks back.
API reference
This item exports functions and types rather than components.
Other exports
createSequenceDiffsequenceDiffcreateLineDiffdiffFilediffTextlineDiffsplitLinestoFileDiffintralinepairLinesdiffsInWorkerdiffTextAsyncWORKER_THRESHOLDtype DiffAlgorithmtype DiffHunktype DiffLinetype DiffLineKindtype DiffOptionstype DiffStatustype FileDifftype FileStatustype IgnoreWhitespacetype IntralineModetype IntralineRangestype TextDifftype SequenceAlgorithmtype SequenceDifftype FilePathstype LineDifftype Intralinetype IntralineOptionstype AsyncDiffOptionsAccessibility
- No interface: render its output with DiffView, TextDiff or GitDiff, or a CodeBlock in diff language.
Agent actions
Not a component; agents act on the views that render it.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.