You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`hunkdiff/opentui` exports `HunkDiffView`, a reusable terminal diff component built from the same renderer as the Hunk CLI.
3
+
`hunkdiff/opentui` exports reusable terminal diff components built from the same renderer as the Hunk CLI.
4
4
5
-
Use it when you want Hunk's split or stack diff view inside your own OpenTUI app.
5
+
Use `HunkDiffView` when you want a batteries-included single-file diff, or compose the lower-level primitives when you want to build your own Hunk-like review UI without Hunk's sidebar, menus, global keyboard shortcuts, or session behavior.
6
6
7
7
## Install
8
8
@@ -17,7 +17,7 @@ npm i hunkdiff @opentui/core @opentui/react react
`HunkDiffBody` renders only the diff body for one file. It does not create a scrollbox, file nav, keyboard shortcuts, menus, or session bridge behavior:
`HunkReviewStream` renders a top-to-bottom multi-file review stream without Hunk's app shell, chrome, keybindings, or scroll owner:
96
+
97
+
```tsx
98
+
<scrollboxwidth="100%"height="100%"scrollY>
99
+
<HunkReviewStream
100
+
files={files}
101
+
width={terminal.width}
102
+
layout="split"
103
+
selection={{ fileId, hunkIndex }}
104
+
onSelectionChange={({ fileId, hunkIndex }) => {
105
+
setFileId(fileId);
106
+
setHunkIndex(hunkIndex);
107
+
}}
108
+
/>
109
+
</scrollbox>
110
+
```
111
+
112
+
Use it when you want Hunk's main review stream but your own navigation, chrome, scrolling, and keybindings.
113
+
114
+
### `HunkFileNav`
62
115
63
-
`HunkDiffView` renders one file at a time. Pass a `diff` object shaped like this:
116
+
`HunkFileNav` renders Hunk's file navigation list as an optional primitive. It does not render borders, outer padding, or a scrollbox; host apps own surrounding chrome and scrolling.
Components accept `HunkDiffFileInput` directly. Use `createHunkDiffFile(...)` when you want a normalized `HunkDiffFile` with paths and stats filled in once:
|`selectedHunkIndex`|`number`|`0`| Highlights one hunk as the active target for single-file components. |
205
+
|`scrollable`|`boolean`|`true`|`HunkDiffView` only; primitives should be wrapped in OpenTUI scrollbox when needed. |
115
206
116
207
## Other exports
117
208
118
209
-`parseDiffFromFile`
119
210
-`parsePatchFiles`
120
211
-`FileDiffMetadata`
212
+
-`createHunkDiffFile`
213
+
-`createHunkDiffFilesFromPatch`
214
+
-`countHunkDiffStats`
121
215
-`HUNK_DIFF_THEME_NAMES`
122
216
-`HunkDiffThemeName`
123
217
-`HunkDiffLayout`
124
218
-`HunkDiffFile`
125
-
-`HunkDiffViewProps`
219
+
-`HunkDiffFileInput`
220
+
-`HunkDiffStats`
221
+
-`HunkDiffSelection`
222
+
- component prop types
126
223
127
-
`parseDiffFromFile`, `parsePatchFiles`, and `FileDiffMetadata` are re-exported from `@pierre/diffs` so you can build `metadata` without adding a second diff dependency.
224
+
`parseDiffFromFile`, `parsePatchFiles`, and `FileDiffMetadata` are re-exported from `@pierre/diffs` so you can build metadata without adding a second diff dependency.
0 commit comments