import { type FileEvent, type JsonValue, type PathSpec } from '@struktoai/mirage-core/types'; import type { DiskAccessor } from '../../../accessor/disk.ts'; /** * Map one local filesystem notification onto mount paths. * * Mirage runs no watcher of its own: the consumer owns the inotify / FSEvents * / ReadDirectoryChangesW loop (chokidar, `fs.watch`, or the raw syscall) and * forwards what it saw, which keeps the dependency out of the package and lets * a deployment pick its own mechanism. * * `eventType` is one of `created`, `modified`, `deleted` or `moved`, so a * consumer translates its library's spelling once (chokidar's `add`/`addDir` * are `created`, `unlink`/`unlinkDir` are `deleted`, `change` is `modified`). * Any other name maps to nothing, because a watcher reports events this mount * has no opinion about. * * `payload` carries the host absolute paths the event named: * `{src_path, dest_path, is_directory}`. Those are watchdog's own field names, * taken verbatim from `FileSystemEvent` so the two languages accept the same * body and a python consumer can forward an event as a dict without renaming. * * Mirrors Python `DiskEventHook` (`core/disk/watch/hook.py`). */ export declare class DiskEventHook { private readonly accessor; constructor(accessor: DiskAccessor); /** * Mount-relative form of a host path, or null if outside the mount. * * A watcher may be rooted above the mount, so an event for a sibling * directory is not this mount's to report. */ private relative; /** * Map a rename, which may cross the mount boundary either way. * * A watcher rooted above the mount sees renames that only half belong here, * and each half has to be reported on its own terms: a move out is a DELETE * of the vacated path, and a move in is a CREATE of the arrival. Reporting * neither (which discarding the event on an out-of-mount source does) leaves * a file sitting in the mount that no listing knows about. */ private moved; /** * Map one filesystem notification to the change it implies. * * A directory's own `modified` stays an UPDATE rather than becoming UNKNOWN: * inotify raises it whenever a child appears or vanishes, and it also * delivers that child's own event, so re-inventorying the subtree on every * write inside a directory would throw away the whole cache for nothing. */ toEvents(root: PathSpec, eventType: string, payload: JsonValue): Promise; } //# sourceMappingURL=hook.d.ts.map