56 lines
3.2 KiB
TypeScript
56 lines
3.2 KiB
TypeScript
|
/// <reference types="node" resolution-mode="require"/>
|
||
|
/// <reference types="node" resolution-mode="require"/>
|
||
|
import { EventEmitter } from 'node:events';
|
||
|
import { TargetEvent } from './enums.js';
|
||
|
import WatcherHandler from './watcher_handler.js';
|
||
|
import WatcherLocker from './watcher_locker.js';
|
||
|
import WatcherPoller from './watcher_poller.js';
|
||
|
import type { Callback, Disposer, Handler, Ignore, Path, PollerConfig, SubwatcherConfig, WatcherOptions, WatcherConfig } from './types.js';
|
||
|
declare class Watcher extends EventEmitter {
|
||
|
_closed: boolean;
|
||
|
_ready: boolean;
|
||
|
_closeAborter: AbortController;
|
||
|
_closeSignal: {
|
||
|
aborted: boolean;
|
||
|
};
|
||
|
_closeWait: Promise<void>;
|
||
|
_readyWait: Promise<void>;
|
||
|
_locker: WatcherLocker;
|
||
|
_roots: Set<Path>;
|
||
|
_poller: WatcherPoller;
|
||
|
_pollers: Set<PollerConfig>;
|
||
|
_subwatchers: Set<SubwatcherConfig>;
|
||
|
_watchers: Record<Path, WatcherConfig[]>;
|
||
|
_watchersLock: Promise<void>;
|
||
|
_watchersRestorable: Record<Path, WatcherConfig>;
|
||
|
_watchersRestoreTimeout?: NodeJS.Timeout;
|
||
|
constructor(target?: Path[] | Path | Handler, options?: WatcherOptions | Handler, handler?: Handler);
|
||
|
isClosed(): boolean;
|
||
|
isIgnored(targetPath: Path, ignore?: Ignore): boolean;
|
||
|
isReady(): boolean;
|
||
|
close(): boolean;
|
||
|
error(exception: unknown): boolean;
|
||
|
event(event: TargetEvent, targetPath: Path, targetPathNext?: Path): boolean;
|
||
|
ready(): boolean;
|
||
|
pollerExists(targetPath: Path, options: WatcherOptions): boolean;
|
||
|
subwatcherExists(targetPath: Path, options: WatcherOptions): boolean;
|
||
|
watchersClose(folderPath?: Path, filePath?: Path, recursive?: boolean): void;
|
||
|
watchersLock(callback: Callback): Promise<void>;
|
||
|
watchersRestore(): void;
|
||
|
watcherAdd(config: WatcherConfig, baseWatcherHandler?: WatcherHandler): Promise<WatcherHandler>;
|
||
|
watcherClose(config: WatcherConfig): void;
|
||
|
watcherExists(folderPath: Path, options: WatcherOptions, handler: Handler, filePath?: Path): boolean;
|
||
|
watchDirectories(foldersPaths: Path[], options: WatcherOptions, handler: Handler, filePath?: Path, baseWatcherHandler?: WatcherHandler): Promise<WatcherHandler | undefined>;
|
||
|
watchDirectory(folderPath: Path, options: WatcherOptions, handler: Handler, filePath?: Path, baseWatcherHandler?: WatcherHandler): Promise<void>;
|
||
|
watchFileOnce(filePath: Path, options: WatcherOptions, callback: Callback): Promise<void>;
|
||
|
watchFile(filePath: Path, options: WatcherOptions, handler: Handler): Promise<void>;
|
||
|
watchPollingOnce(targetPath: Path, options: WatcherOptions, callback: Callback): Promise<void>;
|
||
|
watchPolling(targetPath: Path, options: WatcherOptions, callback: Callback): Promise<Disposer>;
|
||
|
watchUnknownChild(targetPath: Path, options: WatcherOptions, handler: Handler): Promise<void>;
|
||
|
watchUnknownTarget(targetPath: Path, options: WatcherOptions, handler: Handler): Promise<void>;
|
||
|
watchPaths(targetPaths: Path[], options: WatcherOptions, handler: Handler): Promise<void>;
|
||
|
watchPath(targetPath: Path, options: WatcherOptions, handler: Handler): Promise<void>;
|
||
|
watch(target?: Path[] | Path | Handler, options?: WatcherOptions | Handler, handler?: Handler): Promise<void>;
|
||
|
}
|
||
|
export default Watcher;
|