/** * Unified-diff hunks (RFC-0001 A13). Format, emitted by every generator and * accepted by every parser: * * @@ -A,B +C,D @@ * context * -removed * +added * \ No newline at end of file * * The marker follows the last line of a side that lacks a trailing newline; * lines are joined with "\n" and the string ends with "\n"; hunks are * ascending and non-overlapping. An empty file has zero lines: * `@@ -0,0 +1,N @@` fills one, `@@ -1,N +0,0 @@` empties one. The parser also * accepts the short `-A +C` header form (count 1). * * Apply is exact: every context and removed line must equal the old line at * the cursor, header counts must match, and the no-newline markers must agree * with the old text. Any violation is `SOURCE_PATCH_INVALID`. The rules are * mirrored line for line by the server's `api/canvas/textpatch.py`. */ export declare const NO_EOL = "\\ No newline at end of file"; export declare class TextPatchError extends Error { readonly code = "SOURCE_PATCH_INVALID"; constructor(message: string); } export interface Hunk { oldStart: number; oldLen: number; newStart: number; newLen: number; /** Each with its prefix: " ", "-", "+" or the no-newline marker. */ lines: string[]; } /** The hunks turning `oldText` into `newText`; `''` when they are equal. */ export declare const makeHunks: (oldText: string, newText: string, options?: { context?: number; }) => string; export declare const parseHunks: (hunks: string) => Hunk[]; /** Apply `hunks` to `oldText` exactly; `TextPatchError` on any mismatch. */ export declare const applyHunks: (oldText: string, hunks: string) => string; /** `{ added, removed }` line counts of a hunks string. */ export declare const countLines: (hunks: string) => { added: number; removed: number; }; /** Rewrite the body of every `+` line (cid resolution lives there). */ export declare const mapAddedLines: (hunks: string, fn: (line: string) => string) => string; //# sourceMappingURL=hunks.d.ts.map