@stacksjs/dtsx
Version:
A modern, fast .d.ts generation tool, powered by Bun.
83 lines (82 loc) • 2.08 kB
TypeScript
/**
* Compute diff between two strings
*/
export declare function computeDiff(oldContent: string, newContent: string, filePath: string, options?: DiffOptions): DiffResult;
/**
* Format diff result as unified diff string
*/
export declare function formatUnifiedDiff(result: DiffResult): string;
/**
* Format diff with colors for terminal output
*/
export declare function formatColoredDiff(result: DiffResult): string;
/**
* Format diff as simple summary
*/
export declare function formatDiffSummary(result: DiffResult): string;
/**
* Compare a file against new content
*/
export declare function diffFile(filePath: string, newContent: string, options?: DiffOptions): Promise<DiffResult>;
/**
* Compare multiple files
*/
export declare function diffFiles(files: Map<string, string>, options?: DiffOptions): Promise<Map<string, DiffResult>>;
/**
* Generate a summary of all diffs
*/
export declare function summarizeDiffs(results: Map<string, DiffResult>): {
totalFiles: number
changedFiles: number
unchangedFiles: number
totalAdditions: number
totalDeletions: number
newFiles: number
};
/**
* Print colored diff to console
*/
export declare function printDiff(result: DiffResult): void;
/**
* Print all diffs to console
*/
export declare function printDiffs(results: Map<string, DiffResult>, showUnchanged?: boolean): void;
/**
* A single diff hunk (change)
*/
export declare interface DiffHunk {
operation: DiffOperation
lines: string[]
oldStart: number
oldCount: number
newStart: number
newCount: number
}
/**
* Complete diff result
*/
export declare interface DiffResult {
filePath: string
identical: boolean
hunks: DiffHunk[]
stats: {
additions: number
deletions: number
unchanged: number
}
oldContent?: string
newContent: string
}
/**
* Options for diff generation
*/
export declare interface DiffOptions {
context?: number
ignoreWhitespace?: boolean
ignoreBlankLines?: boolean
treatMissingAsEmpty?: boolean
}
/**
* Diff operation type
*/
export type DiffOperation = 'add' | 'remove' | 'equal';