import { Extension, StateField } from '@codemirror/state'; import { diffChars, diffWords } from 'diff'; import { LineMapping } from '../types'; /** Word diff data for a line */ export interface WordDiffData { lineNumber: number; ranges: WordDiffRange[]; } /** A range within a line that was changed */ export interface WordDiffRange { from: number; to: number; type: "added" | "removed"; } /** Effect to set word diff data (replaces all) */ export declare const setWordDiffDataEffect: import('@codemirror/state').StateEffectType; /** Effect to extend word diff data (appends new entries) */ export declare const extendWordDiffDataEffect: import('@codemirror/state').StateEffectType; /** State field for word diff data */ export declare const wordDiffDataField: StateField; /** * Compute word-level diff between two strings. * Returns ranges of changes within each string. * * Strips common leading whitespace before diffing so that * `diffWords` doesn't treat the indent as part of a changed token * when only a single word follows (e.g. " photoUrl:" vs " imageUrl:"). */ export declare function computeWordDiff(before: string, after: string, mode?: "word" | "char"): { beforeRanges: WordDiffRange[]; afterRanges: WordDiffRange[]; }; /** * Build word diff data for modified lines. * * Handles two cases: * 1. Lines with type 'modified' (both sides on the same row) * 2. Paired remove+add lines linked by pairId (split rows for height alignment) * * When fromLine/toLine are provided, only processes lines within that range * (for lazy/viewport-based loading). * * @param lineMap - Line mappings with before/after correspondence * @param beforeLines - Content of before lines * @param afterLines - Content of after lines * @param side - Which side to generate data for * @param mode - Diff mode ('word' or 'char') * @param fromLine - Start line number (1-indexed, inclusive). Default: 1 * @param toLine - End line number (1-indexed, inclusive). Default: all lines */ export declare function buildWordDiffData(lineMap: LineMapping[], beforeLines: string[], afterLines: string[], side: "before" | "after", mode?: "word" | "char", fromLine?: number, toLine?: number): WordDiffData[]; /** * Build word diff data from before/after content strings for modified lines. * Uses a simpler approach when we have line-by-line content. */ export declare function buildWordDiffDataFromContent(lineMap: LineMapping[], beforeContent: string, afterContent: string, side: "before" | "after", mode?: "word" | "char"): WordDiffData[]; /** * Build word diff data for inline/unified view where modified lines * show inline changes. Uses beforeContentMap from generateUnifiedContentFromDiff. * * @param lines - The unified content lines * @param lineMap - Line mappings * @param beforeContentMap - Map of line index to before content for modified lines * @param mode - Diff mode ('word' or 'char') */ export declare function buildInlineWordDiffData(lines: string[], lineMap: LineMapping[], beforeContentMap: Map, mode?: "word" | "char"): WordDiffData[]; /** Theme for word-level diff highlighting */ export declare const wordDiffTheme: Extension; /** * Create just the word diff state field (for base extensions). * Use this when the state field needs to persist across compartment reconfigurations. */ export declare function wordDiffStateField(): Extension; /** * Create just the word diff plugin and theme (for compartments). * Use this with wordDiffStateField() when dynamic reconfiguration is needed. */ export declare function wordDiffPluginOnly(): Extension; export { diffWords, diffChars };