BREAKING CHANGE(smartwatch): Introduce Smartwatch: cross-runtime native file watching for Node.js, Deno and Bun; rename smartchok to smartwatch and bump major version to 2.0.0
This commit is contained in:
47
ts/watchers/interfaces.ts
Normal file
47
ts/watchers/interfaces.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
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>;
|
||||
}
|
||||
Reference in New Issue
Block a user