import type { RelativePath } from "../persistence/database"; export interface Cursor { id: number; characterPosition: number; } export interface TextWithCursors { text: string; cursors: Cursor[]; } export interface FileSystemOperations { // List all files that should be synced. listAllFiles: () => Promise; // Read the content of a file. read: (path: RelativePath) => Promise; // Create or overwrite a file with the given content. write: (path: RelativePath, content: Uint8Array) => Promise; // Atomically update the content of a text file. atomicUpdateText: ( path: RelativePath, updater: (current: TextWithCursors) => TextWithCursors ) => Promise; // Get the size of a file in bytes. getFileSize: (path: RelativePath) => Promise; // Check if a file exists. exists: (path: RelativePath) => Promise; // Create a directory at the specified path. All parent directories must already exist. createDirectory: (path: RelativePath) => Promise; // Delete a file. It is expected that the path points to an existing file. delete: (path: RelativePath) => Promise; // Rename a file. It is expected that the oldPath points to an existing file and the newPath does not exist. rename: (oldPath: RelativePath, newPath: RelativePath) => Promise; }