48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
|
|
import type * as fs from 'fs';
|
||
|
|
import type * as smartrx from '@push.rocks/smartrx';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* File system event types that the watcher emits
|
||
|
|
*/
|
||
|
|
export type TWatchEventType = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir' | 'ready' | 'error';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Data structure for watch events
|
||
|
|
*/
|
||
|
|
export interface IWatchEvent {
|
||
|
|
type: TWatchEventType;
|
||
|
|
path: string;
|
||
|
|
stats?: fs.Stats;
|
||
|
|
error?: Error;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Options for creating a watcher
|
||
|
|
*/
|
||
|
|
export interface IWatcherOptions {
|
||
|
|
/** Base paths to watch (extracted from glob patterns) */
|
||
|
|
basePaths: string[];
|
||
|
|
/** Maximum directory depth to watch */
|
||
|
|
depth: number;
|
||
|
|
/** Whether to follow symbolic links */
|
||
|
|
followSymlinks: boolean;
|
||
|
|
/** Stability threshold for write detection (ms) */
|
||
|
|
stabilityThreshold: number;
|
||
|
|
/** Poll interval for write detection (ms) */
|
||
|
|
pollInterval: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Common interface for file watchers across runtimes
|
||
|
|
*/
|
||
|
|
export interface IWatcher {
|
||
|
|
/** Start watching files */
|
||
|
|
start(): Promise<void>;
|
||
|
|
/** Stop watching and clean up */
|
||
|
|
stop(): Promise<void>;
|
||
|
|
/** Whether the watcher is currently active */
|
||
|
|
readonly isWatching: boolean;
|
||
|
|
/** Subject that emits watch events */
|
||
|
|
readonly events$: smartrx.rxjs.Subject<IWatchEvent>;
|
||
|
|
}
|