import fsExtra from "fs-extra"; import FastGlob from "fast-glob"; import { type SyncDirTreeFetcher } from "./filesystems/dirTree"; /** * The subset of the fs-extra promise API that the sync engine awaits directly. * The real implementation is fs-extra; tests inject an in-memory equivalent. */ export type SyncFS = Pick; /** * Filesystem adapter handed to fast-glob (callback/sync API). fs-extra satisfies this; tests * pass an in-memory equivalent backed by the same storage as {@link SyncFS}. */ export type SyncGlobFS = Partial; /** * Atomic file writer. Matches the single call shape the engine uses. */ export type SyncWriteFileAtomic = (filename: string, data: string, options: { encoding: BufferEncoding; }) => Promise; export type SyncWatcher = { close: () => Promise; }; /** * Creates a recursive directory watcher that invokes `onChange` whenever something under `path` * changes. The default uses the native recursive `fs.watch`; tests inject a controllable no-op. */ export type SyncWatcherFactory = (path: string, onChange: () => void) => Promise; /** * All external, side-effecting dependencies of the sync engine, gathered behind one injectable * object. {@link defaultEnvironment} wires the real implementations; tests pass fakes. Time is NOT * here on purpose — tests control it with fake timers. */ export type SyncEnvironment = { fs: SyncFS; globFs: SyncGlobFS; writeFileAtomic: SyncWriteFileAtomic; createWatcher: SyncWatcherFactory; /** * Fetches the remote directory tree. Production uses a msgpack reimplementation of `/v3/dir/tree`; * tests inject a fetcher backed by the fake cloud. Swappable so the wire format is not baked in. */ fetchDirTree: SyncDirTreeFetcher; }; /** * The production environment: real fs-extra, native recursive fs.watch, real write-file-atomic. */ export declare function defaultEnvironment(): SyncEnvironment;