UNPKG

recoder-code

Version:

Complete AI-powered development platform with ML model training, plugin registry, real-time collaboration, monitoring, infrastructure automation, and enterprise deployment capabilities

124 lines (123 loc) 3.38 kB
/** * Operational Transform Engine * Implements conflict resolution for concurrent operations */ import { Delta } from './Operation'; export interface TransformResult { op1Prime: Delta; op2Prime: Delta; } export declare class OperationalTransform { /** * Transform two concurrent operations against each other * @param op1 First operation * @param op2 Second operation (concurrent with op1) * @param priority Priority for breaking ties (true = op1 has priority) * @returns Transformed operations */ static transform(op1: Delta, op2: Delta, priority?: boolean): TransformResult; /** * Transform two operations of equal length */ private static transformEqualLength; /** * Split an operation at the given position */ private static splitOperation; /** * Merge attributes from two operations */ private static mergeAttributes; /** * Compose a sequence of operations */ static compose(ops: Delta[]): Delta; /** * Transform an operation against a sequence of operations */ static transformAgainstSequence(operation: Delta, sequence: Delta[], ownOperation?: boolean): Delta; /** * Check if two operations can be applied in any order (commutative) */ static areCommutative(op1: Delta, op2: Delta): boolean; /** * Rebase an operation against a newer base */ static rebase(operation: Delta, newBase: Delta[]): Delta; } /** * Document state manager using OT */ export declare class DocumentState { private content; private operations; private revision; constructor(initialContent?: string); /** * Apply an operation to the document */ applyOperation(operation: Delta): { success: boolean; newRevision: number; error?: string; }; /** * Transform and apply a concurrent operation */ applyConcurrentOperation(operation: Delta, baseRevision: number, author: string): { success: boolean; transformedOperation?: Delta; newRevision: number; error?: string; }; /** * Get operations since a specific revision */ getOperationsSince(revision: number): Delta[]; /** * Get the current document content */ getContent(): string; /** * Get the current revision number */ getRevision(): number; /** * Get the current document length */ getLength(): number; /** * Create a snapshot at current state */ createSnapshot(): DocumentSnapshot; /** * Restore from a snapshot */ restoreFromSnapshot(snapshot: DocumentSnapshot): void; } export interface DocumentSnapshot { content: string; revision: number; timestamp: number; } /** * Selection and cursor tracking */ export interface SelectionRange { start: number; end: number; author: string; timestamp: number; } export declare class SelectionManager { private selections; updateSelection(author: string, range: SelectionRange): void; removeSelection(author: string): void; getSelections(): SelectionRange[]; getSelection(author: string): SelectionRange | undefined; /** * Transform selections based on an operation */ transformSelections(operation: Delta): void; private transformSelection; }