/** * @module line-diff-helper * * Native, zero-dependency Myers / LCS line-diffing engine for text files. * * Computes precise line-by-line diff chunks between text files without external libraries. */ export interface LineDiffChunk { /** * Line index in old text where the chunk starts (0-indexed) */ old_i: number; /** * Deleted lines from old text */ oldLines: string[]; /** * Inserted lines in new text */ newLines: string[]; } export interface LineDiffResult { /** * Array of line diff chunks */ chunks: LineDiffChunk[]; /** * Set if total lines exceed max limit and force flag was false */ tooBig?: boolean; /** * Set if binary data was detected and force flag was false */ treatedAsBinary?: boolean; } export interface LineDiffOpts { /** * Old file data buffer (optional if new file addition) */ oldData?: Uint8Array; /** * New file data buffer */ newData: Uint8Array; /** * File encoding (defaults to 'utf8') */ fileEncoding?: string; /** * Max line count limit before requiring force flag (defaults to 10000) */ maxLines?: number; /** * Force diff computation even if file is large or binary */ force?: boolean; } /** * Basic binary detection check. * Checks for null bytes (0x00) within the first 1024 bytes. */ export declare function isBinaryBuffer(data: Uint8Array): boolean; /** * Decodes Uint8Array buffer into array of text lines. */ export declare function decodeToLines(data?: Uint8Array, encoding?: string): string[]; /** * Computes Longest Common Subsequence (LCS) edit script between two arrays of lines. * Returns array of LineDiffChunk structures. * * Optimizations: * 1. Fast path: identical lines. * 2. Prefix & suffix trimming: strips common leading and trailing lines before * allocating the DP matrix (Myers diff pre-pass). * 3. Short-circuit for pure additions or deletions in the middle slice. * 4. Integer line interning: lines in the middle slice are interned to unique 32-bit * integers for single-cycle equality checks. * 5. Flat Int32Array matrix: avoids nested object allocations for LCS DP cells. */ export declare function computeLineLcsDiff(oldLines: string[], newLines: string[]): LineDiffChunk[]; /** * Main line diff helper function for text files. */ export declare function getLineDiffChunks(opts: LineDiffOpts): LineDiffResult; //# sourceMappingURL=line-diff-helpers.d.mts.map