@abelfubu/dv 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ansi-html.d.ts +42 -0
- package/dist/ansi-html.d.ts.map +1 -0
- package/dist/ansi-html.js +327 -0
- package/dist/ansi-output.d.ts +22 -0
- package/dist/ansi-output.d.ts.map +1 -0
- package/dist/ansi-output.js +154 -0
- package/dist/balance-delimiters.d.ts +25 -0
- package/dist/balance-delimiters.d.ts.map +1 -0
- package/dist/balance-delimiters.js +539 -0
- package/dist/balance-delimiters.test.d.ts +2 -0
- package/dist/balance-delimiters.test.d.ts.map +1 -0
- package/dist/balance-delimiters.test.js +1029 -0
- package/dist/cli-copy-notification.test.d.ts +2 -0
- package/dist/cli-copy-notification.test.d.ts.map +1 -0
- package/dist/cli-copy-notification.test.js +80 -0
- package/dist/cli-scroll.test.d.ts +2 -0
- package/dist/cli-scroll.test.d.ts.map +1 -0
- package/dist/cli-scroll.test.js +283 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +976 -0
- package/dist/clipboard.d.ts +16 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +128 -0
- package/dist/components/diff-view.d.ts +32 -0
- package/dist/components/diff-view.d.ts.map +1 -0
- package/dist/components/diff-view.js +123 -0
- package/dist/components/diff-view.test.d.ts +5 -0
- package/dist/components/diff-view.test.d.ts.map +1 -0
- package/dist/components/diff-view.test.js +312 -0
- package/dist/components/directory-tree-view.d.ts +33 -0
- package/dist/components/directory-tree-view.d.ts.map +1 -0
- package/dist/components/directory-tree-view.js +262 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/components/toast.d.ts +21 -0
- package/dist/components/toast.d.ts.map +1 -0
- package/dist/components/toast.js +47 -0
- package/dist/diff-cursor-utils.d.ts +20 -0
- package/dist/diff-cursor-utils.d.ts.map +1 -0
- package/dist/diff-cursor-utils.js +105 -0
- package/dist/diff-cursor-utils.test.d.ts +2 -0
- package/dist/diff-cursor-utils.test.d.ts.map +1 -0
- package/dist/diff-cursor-utils.test.js +40 -0
- package/dist/diff-surface-copy.d.ts +23 -0
- package/dist/diff-surface-copy.d.ts.map +1 -0
- package/dist/diff-surface-copy.js +64 -0
- package/dist/diff-surface-copy.test.d.ts +5 -0
- package/dist/diff-surface-copy.test.d.ts.map +1 -0
- package/dist/diff-surface-copy.test.js +142 -0
- package/dist/diff-utils.d.ts +196 -0
- package/dist/diff-utils.d.ts.map +1 -0
- package/dist/diff-utils.js +682 -0
- package/dist/diff-utils.test.d.ts +2 -0
- package/dist/diff-utils.test.d.ts.map +1 -0
- package/dist/diff-utils.test.js +727 -0
- package/dist/directory-tree.d.ts +72 -0
- package/dist/directory-tree.d.ts.map +1 -0
- package/dist/directory-tree.js +161 -0
- package/dist/directory-tree.test.d.ts +2 -0
- package/dist/directory-tree.test.d.ts.map +1 -0
- package/dist/directory-tree.test.js +383 -0
- package/dist/dropdown.d.ts +26 -0
- package/dist/dropdown.d.ts.map +1 -0
- package/dist/dropdown.js +172 -0
- package/dist/dropdown.test.d.ts +2 -0
- package/dist/dropdown.test.d.ts.map +1 -0
- package/dist/dropdown.test.js +106 -0
- package/dist/filter-submodule.e2e.test.d.ts +2 -0
- package/dist/filter-submodule.e2e.test.d.ts.map +1 -0
- package/dist/filter-submodule.e2e.test.js +109 -0
- package/dist/hooks/use-copy-selection.d.ts +29 -0
- package/dist/hooks/use-copy-selection.d.ts.map +1 -0
- package/dist/hooks/use-copy-selection.js +46 -0
- package/dist/kv-codec.d.ts +16 -0
- package/dist/kv-codec.d.ts.map +1 -0
- package/dist/kv-codec.js +36 -0
- package/dist/license.d.ts +14 -0
- package/dist/license.d.ts.map +1 -0
- package/dist/license.js +63 -0
- package/dist/logger.d.ts +9 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +78 -0
- package/dist/monochrome.d.ts +34 -0
- package/dist/monochrome.d.ts.map +1 -0
- package/dist/monochrome.js +613 -0
- package/dist/monotone.d.ts +22 -0
- package/dist/monotone.d.ts.map +1 -0
- package/dist/monotone.js +185 -0
- package/dist/parsers-config.d.ts +19 -0
- package/dist/parsers-config.d.ts.map +1 -0
- package/dist/parsers-config.js +271 -0
- package/dist/patch-terminal-dimensions.d.ts +2 -0
- package/dist/patch-terminal-dimensions.d.ts.map +1 -0
- package/dist/patch-terminal-dimensions.js +45 -0
- package/dist/stdin-pager.test.d.ts +2 -0
- package/dist/stdin-pager.test.d.ts.map +1 -0
- package/dist/stdin-pager.test.js +497 -0
- package/dist/store.d.ts +16 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +48 -0
- package/dist/themes/github.json +247 -0
- package/dist/themes.d.ts +59 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +248 -0
- package/dist/tree-icons.d.ts +4 -0
- package/dist/tree-icons.d.ts.map +1 -0
- package/dist/tree-icons.js +18 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +13 -0
- package/dist/web-utils.d.ts +56 -0
- package/dist/web-utils.d.ts.map +1 -0
- package/dist/web-utils.js +363 -0
- package/package.json +37 -0
- package/public/jetbrains-mono-nerd.ttf +0 -0
- package/public/jetbrains-mono-nerd.woff2 +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@opentuah/react/jsx-runtime";
|
|
2
|
+
// Tests for captureSelectedDiffText — copying selected diff rows from the renderable surface.
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { afterEach, describe, expect, it } from "bun:test";
|
|
5
|
+
import { testRender } from "@opentuah/react/test-utils";
|
|
6
|
+
import { getDataPaths } from "@opentuah/core";
|
|
7
|
+
import { DiffView } from "./components/diff-view.js";
|
|
8
|
+
import { captureSelectedDiffText } from "./diff-surface-copy.js";
|
|
9
|
+
getDataPaths().setMaxListeners(50);
|
|
10
|
+
// Logical line order for this diff (matching DiffRenderable grouping):
|
|
11
|
+
// 0: context
|
|
12
|
+
// 1: remove "old"
|
|
13
|
+
// 2: remove "more"
|
|
14
|
+
// 3: add "new"
|
|
15
|
+
// 4: add "more-new"
|
|
16
|
+
// 5: context
|
|
17
|
+
const sampleDiff = `diff --git a/a.ts b/a.ts
|
|
18
|
+
index 1111111..2222222 100644
|
|
19
|
+
--- a/a.ts
|
|
20
|
+
+++ b/a.ts
|
|
21
|
+
@@ -1,4 +1,4 @@
|
|
22
|
+
context
|
|
23
|
+
-old
|
|
24
|
+
+new
|
|
25
|
+
-more
|
|
26
|
+
+more-new
|
|
27
|
+
keep
|
|
28
|
+
`;
|
|
29
|
+
async function setupTest(jsx, opts) {
|
|
30
|
+
const setup = await testRender(jsx, opts);
|
|
31
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = false;
|
|
32
|
+
return setup;
|
|
33
|
+
}
|
|
34
|
+
async function renderUntilStable(testSetup, times = 5) {
|
|
35
|
+
for (let index = 0; index < times; index++) {
|
|
36
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
37
|
+
await testSetup.renderOnce();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function renderDiffView(props) {
|
|
41
|
+
const ref = React.createRef();
|
|
42
|
+
const element = (_jsx(DiffView, { ref: ref, diff: props.diff, view: props.view, filetype: props.filetype, themeName: "github", focused: props.focused ?? true, cursorLine: props.selection?.start ?? 0, selection: props.selection ?? null }));
|
|
43
|
+
return { element, ref };
|
|
44
|
+
}
|
|
45
|
+
describe("captureSelectedDiffText", () => {
|
|
46
|
+
let testSetup;
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
if (testSetup) {
|
|
49
|
+
testSetup.renderer.destroy();
|
|
50
|
+
testSetup = undefined;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
it("returns null when no renderable is provided", () => {
|
|
54
|
+
const result = captureSelectedDiffText(undefined, { start: 0, end: 0 });
|
|
55
|
+
expect(result.text).toBeNull();
|
|
56
|
+
});
|
|
57
|
+
it("copies unified view rendered rows", async () => {
|
|
58
|
+
const { element, ref } = renderDiffView({
|
|
59
|
+
diff: sampleDiff,
|
|
60
|
+
view: "unified",
|
|
61
|
+
filetype: "ts",
|
|
62
|
+
selection: { start: 1, end: 3 },
|
|
63
|
+
});
|
|
64
|
+
testSetup = await setupTest(element, { width: 80, height: 12 });
|
|
65
|
+
await renderUntilStable(testSetup);
|
|
66
|
+
const diffRenderable = ref.current?.getDiffRenderable();
|
|
67
|
+
expect(diffRenderable).toBeDefined();
|
|
68
|
+
const result = captureSelectedDiffText(diffRenderable, { start: 1, end: 3 });
|
|
69
|
+
expect(result.text).toBe("old\nmore\nnew");
|
|
70
|
+
});
|
|
71
|
+
it("copies new-side rows in split view", async () => {
|
|
72
|
+
const { element, ref } = renderDiffView({
|
|
73
|
+
diff: sampleDiff,
|
|
74
|
+
view: "split",
|
|
75
|
+
filetype: "ts",
|
|
76
|
+
selection: { start: 1, end: 4 },
|
|
77
|
+
});
|
|
78
|
+
testSetup = await setupTest(element, { width: 160, height: 12 });
|
|
79
|
+
await renderUntilStable(testSetup);
|
|
80
|
+
const diffRenderable = ref.current?.getDiffRenderable();
|
|
81
|
+
expect(diffRenderable).toBeDefined();
|
|
82
|
+
const result = captureSelectedDiffText(diffRenderable, { start: 1, end: 4 });
|
|
83
|
+
// In split view we copy the right side. Removed-only logical rows are empty
|
|
84
|
+
// padding on the new side; added rows contain the new code.
|
|
85
|
+
expect(result.text).toBeDefined();
|
|
86
|
+
expect(result.text).toContain("new");
|
|
87
|
+
expect(result.text).toContain("more-new");
|
|
88
|
+
expect(result.text).not.toContain("old");
|
|
89
|
+
});
|
|
90
|
+
it("reports the first new line number in unified view", async () => {
|
|
91
|
+
const { element, ref } = renderDiffView({
|
|
92
|
+
diff: sampleDiff,
|
|
93
|
+
view: "unified",
|
|
94
|
+
filetype: "ts",
|
|
95
|
+
selection: { start: 2, end: 3 },
|
|
96
|
+
});
|
|
97
|
+
testSetup = await setupTest(element, { width: 80, height: 12 });
|
|
98
|
+
await renderUntilStable(testSetup);
|
|
99
|
+
const diffRenderable = ref.current?.getDiffRenderable();
|
|
100
|
+
const result = captureSelectedDiffText(diffRenderable, { start: 2, end: 3 });
|
|
101
|
+
expect(result.startLineNum).toBe(3);
|
|
102
|
+
});
|
|
103
|
+
it("reports the first new line number in split view", async () => {
|
|
104
|
+
const { element, ref } = renderDiffView({
|
|
105
|
+
diff: sampleDiff,
|
|
106
|
+
view: "split",
|
|
107
|
+
filetype: "ts",
|
|
108
|
+
selection: { start: 2, end: 4 },
|
|
109
|
+
});
|
|
110
|
+
testSetup = await setupTest(element, { width: 160, height: 12 });
|
|
111
|
+
await renderUntilStable(testSetup);
|
|
112
|
+
const diffRenderable = ref.current?.getDiffRenderable();
|
|
113
|
+
const result = captureSelectedDiffText(diffRenderable, { start: 2, end: 4 });
|
|
114
|
+
expect(result.startLineNum).toBe(3);
|
|
115
|
+
});
|
|
116
|
+
it("handles a single-line selection", async () => {
|
|
117
|
+
const { element, ref } = renderDiffView({
|
|
118
|
+
diff: sampleDiff,
|
|
119
|
+
view: "unified",
|
|
120
|
+
filetype: "ts",
|
|
121
|
+
selection: { start: 3, end: 3 },
|
|
122
|
+
});
|
|
123
|
+
testSetup = await setupTest(element, { width: 80, height: 12 });
|
|
124
|
+
await renderUntilStable(testSetup);
|
|
125
|
+
const diffRenderable = ref.current?.getDiffRenderable();
|
|
126
|
+
const result = captureSelectedDiffText(diffRenderable, { start: 3, end: 3 });
|
|
127
|
+
expect(result.text).toBe("new");
|
|
128
|
+
});
|
|
129
|
+
it("ignores out-of-bounds indices", async () => {
|
|
130
|
+
const { element, ref } = renderDiffView({
|
|
131
|
+
diff: sampleDiff,
|
|
132
|
+
view: "unified",
|
|
133
|
+
filetype: "ts",
|
|
134
|
+
selection: { start: 100, end: 105 },
|
|
135
|
+
});
|
|
136
|
+
testSetup = await setupTest(element, { width: 80, height: 12 });
|
|
137
|
+
await renderUntilStable(testSetup);
|
|
138
|
+
const diffRenderable = ref.current?.getDiffRenderable();
|
|
139
|
+
const result = captureSelectedDiffText(diffRenderable, { start: 100, end: 105 });
|
|
140
|
+
expect(result.text).toBe("");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the current directory is inside a git repository.
|
|
3
|
+
* If not, print a friendly error message and exit.
|
|
4
|
+
*/
|
|
5
|
+
export declare function ensureGitRepo(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Get the absolute path to the git repository root.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getGitRepoRoot(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Strip submodule status lines from git diff output.
|
|
12
|
+
* git diff --submodule=diff adds various status lines that the diff parser doesn't understand:
|
|
13
|
+
* - "Submodule name hash1..hash2:" (header before submodule diff)
|
|
14
|
+
* - "Submodule name contains modified content"
|
|
15
|
+
* - "Submodule name contains untracked content"
|
|
16
|
+
* - "Submodule name (new commits)"
|
|
17
|
+
* - "Submodule name (commits not present)"
|
|
18
|
+
*/
|
|
19
|
+
export declare function stripSubmoduleHeaders(diffOutput: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Metadata extracted from git diff rename/copy headers.
|
|
22
|
+
* git diff -M adds these headers which the `diff` npm package silently skips.
|
|
23
|
+
*/
|
|
24
|
+
export interface RenameInfo {
|
|
25
|
+
type: "rename" | "copy";
|
|
26
|
+
from: string;
|
|
27
|
+
to: string;
|
|
28
|
+
similarity: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Preprocess raw git diff output to handle rename/copy detection.
|
|
32
|
+
*
|
|
33
|
+
* The `diff` npm package's parsePatch does not understand git's rename/copy
|
|
34
|
+
* headers (similarity index, rename from/to, copy from/to). For pure renames
|
|
35
|
+
* (100% similarity, no content changes), it produces broken entries because
|
|
36
|
+
* there are no ---/+++ or @@ lines for it to parse.
|
|
37
|
+
*
|
|
38
|
+
* This function:
|
|
39
|
+
* 1. Injects synthetic --- and +++ headers for pure renames/copies so parsePatch
|
|
40
|
+
* creates proper entries with correct filenames
|
|
41
|
+
* 2. Extracts rename/copy metadata (type, from, to, similarity) for each file section
|
|
42
|
+
*
|
|
43
|
+
* @returns processedDiff: diff string safe for parsePatch, renameInfo: metadata per file index
|
|
44
|
+
*/
|
|
45
|
+
export declare function preprocessDiff(rawDiff: string): {
|
|
46
|
+
processedDiff: string;
|
|
47
|
+
renameInfo: Map<number, RenameInfo>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Parse git diff output with rename/copy detection support.
|
|
51
|
+
* Preprocesses the diff for pure renames, delegates to parsePatch from the `diff` package,
|
|
52
|
+
* and enriches results with rename metadata.
|
|
53
|
+
*
|
|
54
|
+
* Use this instead of calling parsePatch directly when processing git diff -M output.
|
|
55
|
+
*
|
|
56
|
+
* Generic to preserve the concrete type returned by parsePatch (e.g. StructuredPatch).
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseGitDiffFiles<T>(rawDiff: string, parsePatch: (diff: string) => T[]): (T & {
|
|
59
|
+
renameFrom?: string;
|
|
60
|
+
renameTo?: string;
|
|
61
|
+
similarity?: number;
|
|
62
|
+
})[];
|
|
63
|
+
export declare const IGNORED_FILES: string[];
|
|
64
|
+
export interface ParsedFile {
|
|
65
|
+
oldFileName?: string;
|
|
66
|
+
newFileName?: string;
|
|
67
|
+
oldHeader?: string;
|
|
68
|
+
newHeader?: string;
|
|
69
|
+
hunks: Array<{
|
|
70
|
+
lines: string[];
|
|
71
|
+
}>;
|
|
72
|
+
rawDiff?: string;
|
|
73
|
+
/** Set when this file was renamed (git diff -M) */
|
|
74
|
+
renameFrom?: string;
|
|
75
|
+
renameTo?: string;
|
|
76
|
+
/** Similarity percentage for renames/copies (0-100) */
|
|
77
|
+
similarity?: number;
|
|
78
|
+
}
|
|
79
|
+
/** Default number of context lines around each diff hunk */
|
|
80
|
+
export declare const DEFAULT_CONTEXT_LINES = 6;
|
|
81
|
+
export interface GitCommandOptions {
|
|
82
|
+
staged?: boolean;
|
|
83
|
+
commit?: string;
|
|
84
|
+
base?: string;
|
|
85
|
+
head?: string;
|
|
86
|
+
context?: string | number;
|
|
87
|
+
filter?: string | string[];
|
|
88
|
+
positionalFilters?: string[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Normalize file filter patterns from both --filter and positional args after --.
|
|
92
|
+
*/
|
|
93
|
+
export declare function getFilterPatterns(options: Pick<GitCommandOptions, "filter" | "positionalFilters">): string[];
|
|
94
|
+
/**
|
|
95
|
+
* Check whether a filepath matches any user-provided file filter glob.
|
|
96
|
+
* No patterns means "match everything".
|
|
97
|
+
*/
|
|
98
|
+
export declare function matchesFileFilters(filePath: string, patterns: string[]): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Apply critique --filter globs to already-parsed diff files.
|
|
101
|
+
* This is used after appending submodule diffs, where git pathspec filters are
|
|
102
|
+
* no longer sufficient.
|
|
103
|
+
*/
|
|
104
|
+
export declare function filterParsedFilesByPatterns<T extends ParsedFile>(files: T[], options: Pick<GitCommandOptions, "filter" | "positionalFilters">): T[];
|
|
105
|
+
/**
|
|
106
|
+
* Build git command string based on options
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildGitCommand(options: GitCommandOptions): string;
|
|
109
|
+
/**
|
|
110
|
+
* Get submodule paths that have dirty working trees (uncommitted changes).
|
|
111
|
+
* Returns only submodules with actual uncommitted modifications, not those
|
|
112
|
+
* that merely point to a different commit than what the parent repo recorded.
|
|
113
|
+
*
|
|
114
|
+
* Uses `git submodule status` which prefixes each line with:
|
|
115
|
+
* - ' ' (space): submodule matches recorded commit and is clean
|
|
116
|
+
* - '+': submodule is at a different commit than recorded
|
|
117
|
+
* - '-': submodule is not initialized
|
|
118
|
+
* - 'U': submodule has merge conflicts
|
|
119
|
+
*
|
|
120
|
+
* A submodule with '+' prefix AND a trailing dirty marker (e.g. " (modified content)")
|
|
121
|
+
* or one where `git status --porcelain` inside it is non-empty has dirty changes.
|
|
122
|
+
*/
|
|
123
|
+
export declare function getDirtySubmodulePaths(): string[];
|
|
124
|
+
/**
|
|
125
|
+
* Build a git diff command that only shows diffs for specific submodule paths.
|
|
126
|
+
* Used to get the actual file-level diffs inside dirty submodules.
|
|
127
|
+
*/
|
|
128
|
+
export declare function buildSubmoduleDiffCommand(submodulePaths: string[], options: Pick<GitCommandOptions, "context">): string;
|
|
129
|
+
/**
|
|
130
|
+
* Get paths of untracked files in the working tree.
|
|
131
|
+
*/
|
|
132
|
+
export declare function getUntrackedFilePaths(): string[];
|
|
133
|
+
/**
|
|
134
|
+
* Generate a synthetic git diff for an untracked file.
|
|
135
|
+
* Produces output equivalent to `git add -N <file> && git diff <file>`.
|
|
136
|
+
*/
|
|
137
|
+
export declare function buildUntrackedFileDiff(filePath: string): string;
|
|
138
|
+
/**
|
|
139
|
+
* Get file status from parsed diff file
|
|
140
|
+
* - added: oldFileName is /dev/null (new file)
|
|
141
|
+
* - deleted: newFileName is /dev/null (removed file)
|
|
142
|
+
* - renamed: file has renameFrom/renameTo metadata, or oldFileName !== newFileName
|
|
143
|
+
* (with --no-prefix, different filenames means rename since there's no a/ b/ prefix)
|
|
144
|
+
* - modified: both files exist with same name (changed file)
|
|
145
|
+
*/
|
|
146
|
+
export declare function getFileStatus(file: {
|
|
147
|
+
oldFileName?: string;
|
|
148
|
+
newFileName?: string;
|
|
149
|
+
renameFrom?: string;
|
|
150
|
+
renameTo?: string;
|
|
151
|
+
}): "added" | "modified" | "deleted" | "renamed";
|
|
152
|
+
/**
|
|
153
|
+
* Get filename from parsed diff file, handling /dev/null for new/deleted files.
|
|
154
|
+
* For renames, returns the new name (destination).
|
|
155
|
+
*/
|
|
156
|
+
export declare function getFileName(file: {
|
|
157
|
+
oldFileName?: string;
|
|
158
|
+
newFileName?: string;
|
|
159
|
+
renameTo?: string;
|
|
160
|
+
}): string;
|
|
161
|
+
/**
|
|
162
|
+
* Get the old filename for display purposes (e.g., "old-name.ts -> new-name.ts").
|
|
163
|
+
* Returns undefined if the file was not renamed.
|
|
164
|
+
*/
|
|
165
|
+
export declare function getOldFileName(file: {
|
|
166
|
+
oldFileName?: string;
|
|
167
|
+
newFileName?: string;
|
|
168
|
+
renameFrom?: string;
|
|
169
|
+
renameTo?: string;
|
|
170
|
+
}): string | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Count additions and deletions from hunks
|
|
173
|
+
*/
|
|
174
|
+
export declare function countChanges(hunks: Array<{
|
|
175
|
+
lines: string[];
|
|
176
|
+
}>): {
|
|
177
|
+
additions: number;
|
|
178
|
+
deletions: number;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Determine view mode based on changes and terminal width
|
|
182
|
+
* @param splitThreshold - minimum cols for split view (default 100 for TUI, 150 for web)
|
|
183
|
+
*/
|
|
184
|
+
export declare function getViewMode(additions: number, deletions: number, cols: number, splitThreshold?: number): "split" | "unified";
|
|
185
|
+
/**
|
|
186
|
+
* Filter and sort parsed diff files, add rawDiff
|
|
187
|
+
*/
|
|
188
|
+
export declare function processFiles<T extends ParsedFile>(files: T[], formatPatch: (file: T) => string): (T & {
|
|
189
|
+
rawDiff: string;
|
|
190
|
+
})[];
|
|
191
|
+
/**
|
|
192
|
+
* Detect filetype from filename for syntax highlighting
|
|
193
|
+
* Maps to tree-sitter parsers available in @opentuah/core and parsers-config.ts
|
|
194
|
+
*/
|
|
195
|
+
export declare function detectFiletype(filePath: string): string | undefined;
|
|
196
|
+
//# sourceMappingURL=diff-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-utils.d.ts","sourceRoot":"","sources":["../src/diff-utils.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,wBAAgB,aAAa,IAAI,IAAI,CASpC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAMvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAA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