78 lines
2.5 KiB
TypeScript
78 lines
2.5 KiB
TypeScript
/// <reference types="node" resolution-mode="require"/>
|
|
import type { FSWatcher, BigIntStats } from 'node:fs';
|
|
import type { FSTargetEvent, TargetEvent } from './enums.js';
|
|
import type WatcherStats from './watcher_stats.js';
|
|
type ResultDirectory = {
|
|
directories: string[];
|
|
directoriesNames: Set<string>;
|
|
directoriesNamesToPaths: Record<string, string[]>;
|
|
files: string[];
|
|
filesNames: Set<string>;
|
|
filesNamesToPaths: Record<string, string[]>;
|
|
symlinks: string[];
|
|
symlinksNames: Set<string>;
|
|
symlinksNamesToPaths: Record<string, string[]>;
|
|
};
|
|
type ResultDirectories = {
|
|
[path: string]: ResultDirectory;
|
|
};
|
|
type Callback = () => void;
|
|
type Disposer = () => void;
|
|
type Event = [TargetEvent, Path, Path?];
|
|
type FSHandler = (event?: FSTargetEvent, targetName?: string) => void;
|
|
type Handler = (event: TargetEvent, targetPath: Path, targetPathNext?: Path) => void;
|
|
type HandlerBatched = (event?: FSTargetEvent, targetPath?: Path, isInitial?: boolean) => Promise<void>;
|
|
type Ignore = ((targetPath: Path) => boolean) | RegExp;
|
|
type INO = bigint | number;
|
|
type Path = string;
|
|
type ReaddirMap = ResultDirectories;
|
|
type Stats = BigIntStats;
|
|
type LocksAdd = Map<INO, () => void>;
|
|
type LocksUnlink = Map<INO, () => Path>;
|
|
type LocksPair = {
|
|
add: LocksAdd;
|
|
unlink: LocksUnlink;
|
|
};
|
|
type LockConfig = {
|
|
ino?: INO;
|
|
targetPath: Path;
|
|
locks: LocksPair;
|
|
events: {
|
|
add: TargetEvent.ADD | TargetEvent.ADD_DIR;
|
|
change?: TargetEvent.CHANGE;
|
|
rename: TargetEvent.RENAME | TargetEvent.RENAME_DIR;
|
|
unlink: TargetEvent.UNLINK | TargetEvent.UNLINK_DIR;
|
|
};
|
|
};
|
|
type PollerConfig = {
|
|
options: WatcherOptions;
|
|
targetPath: Path;
|
|
};
|
|
type SubwatcherConfig = {
|
|
options: WatcherOptions;
|
|
targetPath: Path;
|
|
};
|
|
type WatcherConfig = {
|
|
handler: Handler;
|
|
watcher: FSWatcher;
|
|
options: WatcherOptions;
|
|
folderPath: Path;
|
|
filePath?: Path;
|
|
};
|
|
type WatcherOptions = {
|
|
debounce?: number;
|
|
depth?: number;
|
|
limit?: number;
|
|
ignore?: Ignore;
|
|
ignoreInitial?: boolean;
|
|
native?: boolean;
|
|
persistent?: boolean;
|
|
pollingInterval?: number;
|
|
pollingTimeout?: number;
|
|
readdirMap?: ReaddirMap;
|
|
recursive?: boolean;
|
|
renameDetection?: boolean;
|
|
renameTimeout?: number;
|
|
};
|
|
export type { Callback, Disposer, Event, FSHandler, FSWatcher, Handler, HandlerBatched, Ignore, INO, Path, ReaddirMap, Stats, LocksAdd, LocksUnlink, LocksPair, LockConfig, PollerConfig, SubwatcherConfig, WatcherConfig, WatcherOptions, WatcherStats };
|