UNPKG

react-monaco-json-merge

Version:

A powerful React component for 3-way JSON merging with semantic comparison, built on Monaco Editor. Features schema-aware conflict detection, interactive resolution, and real-time validation.

74 lines 3.02 kB
import { ConflictType, type JSONSchema, type ModifiedBaseRange } from "../types"; /** * Compute conflict type for a single line by comparing base, input1, and input2 */ export declare function computeLineConflictType(baseLine: string, input1Line: string, input2Line: string): { conflictType: ConflictType; input1Changed: boolean; input2Changed: boolean; }; /** * Compute diffs between base, input1, and input2 documents * Returns an array of conflict ranges with their types */ export declare function computeDiffs(baseLines: string[], input1Lines: string[], input2Lines: string[]): ModifiedBaseRange[]; /** * Compute diffs in sequential mode: base→input1→input2 * In this mode, we compare base with input1, and input1 with input2 */ export declare function computeDiffsSequential(baseLines: string[], input1Lines: string[], input2Lines: string[]): ModifiedBaseRange[]; /** * Information about a conflict resolution issue */ export interface ConflictIssue { conflictId: string; conflictPath: string; type: "error" | "warning" | "smart-merge"; message: string; startLine: number; endLine: number; } /** * Result of building merged content with validation */ export interface BuildResultContentResult { content: string; isValid: boolean; validationError?: string; warnings?: string[]; conflictIssues?: ConflictIssue[]; } /** * Set a value at a given JSON Pointer path in an object * @param obj - The object to modify * @param path - JSON Pointer path (e.g., "/items/0/name") * @param value - Value to set * @throws Error if path is invalid or types don't match */ export declare function setValueAtPath(obj: unknown, path: string, value: unknown): void; /** * Find line numbers for a JSON path in formatted JSON text * @param jsonContent - Formatted JSON string * @param path - JSON Pointer path * @returns Line number range or null if path not found */ export declare function findLinesForPath(jsonContent: string, path: string): { startLine: number; endLine: number; } | null; /** * Attempt to smart-merge two JSON values based on their types and schema * Returns the merged value or null if merge is not possible */ export declare function smartMergeValues(value1: unknown, value2: unknown, schema?: JSONSchema, path?: string): unknown | null; /** * Build result content from conflict ranges based on their states * Legacy version without validation - kept for backward compatibility */ export declare function buildResultContent(baseLines: string[], input1Lines: string[], input2Lines: string[], conflicts: ModifiedBaseRange[]): string; /** * Build result content from conflict ranges based on their states * Returns validation information along with the merged content */ export declare function buildResultContentWithValidation(baseLines: string[], input1Lines: string[], input2Lines: string[], conflicts: ModifiedBaseRange[], schema?: JSONSchema): BuildResultContentResult; //# sourceMappingURL=diffMerge.d.ts.map