export type ItemType = "dir" | "file" | null; export type DirEntries = string[]; export type SyncFileSystemAdapter = { async: false; getType: (path: string) => ItemType; mkdir: (path: string) => void; readdir: (path: string) => DirEntries; readFile: (path: string) => string; rename?: (previous: string, next: string) => void; rm: (path: string) => void; writeFile: (path: string, data: string) => void; }; export type AsyncFileSystemAdapter = { async: true; getType: (path: string) => Promise; mkdir: (path: string) => Promise; readdir: (path: string) => Promise; readFile: (path: string) => Promise; rename?: (previous: string, next: string) => Promise; rm: (path: string) => Promise; writeFile: (path: string, data: string) => Promise; }; export type FileSystemAdapter = SyncFileSystemAdapter | AsyncFileSystemAdapter; export type SyncFileSystem = { getType: (path: string, refresh?: true) => ItemType | undefined; mkdir: (path: string) => void; readdir: (path: string, refresh?: true) => DirEntries | undefined; readFile: (path: string, refresh?: true) => string | undefined; rename: (previous: string, next: string) => void; rm: (path: string) => void; writeFile: (path: string, data: string) => void; }; export type AsyncFileSystem = { getType: (path: string, refresh?: true) => ItemType | undefined; mkdir: (path: string) => Promise; readdir: (path: string, refresh?: true) => DirEntries | undefined; readFile: (path: string, refresh?: true) => string | undefined; rename: (previous: string, next: string) => Promise; rm: (path: string) => Promise; writeFile: (path: string, data: string) => Promise; }; export type Operation = "rm" | "writeFile" | "mkdir"; export type Watcher = (fn: (operation: Operation, path: string) => void) => void;