| 1 |
declare type FilePath = string; |
| 2 |
declare type GlobPattern = string; |
| 3 |
|
| 4 |
declare namespace ParcelWatcher { |
| 5 |
export type BackendType = |
| 6 |
| 'fs-events' |
| 7 |
| 'watchman' |
| 8 |
| 'inotify' |
| 9 |
| 'windows' |
| 10 |
| 'brute-force'; |
| 11 |
export type EventType = 'create' | 'update' | 'delete'; |
| 12 |
export interface Options { |
| 13 |
ignore?: (FilePath | GlobPattern | RegExp)[]; |
| 14 |
backend?: BackendType; |
| 15 |
} |
| 16 |
export type SubscribeCallback = ( |
| 17 |
err: Error | null, |
| 18 |
events: Event[], |
| 19 |
) => unknown; |
| 20 |
export interface AsyncSubscription { |
| 21 |
unsubscribe(): Promise<void>; |
| 22 |
} |
| 23 |
export interface Event { |
| 24 |
path: FilePath; |
| 25 |
type: EventType; |
| 26 |
} |
| 27 |
export function getEventsSince( |
| 28 |
dir: FilePath, |
| 29 |
snapshot: FilePath, |
| 30 |
opts?: Options, |
| 31 |
): Promise<Event[]>; |
| 32 |
export function subscribe( |
| 33 |
dir: FilePath, |
| 34 |
fn: SubscribeCallback, |
| 35 |
opts?: Options, |
| 36 |
): Promise<AsyncSubscription>; |
| 37 |
export function unsubscribe( |
| 38 |
dir: FilePath, |
| 39 |
fn: SubscribeCallback, |
| 40 |
opts?: Options, |
| 41 |
): Promise<void>; |
| 42 |
export function writeSnapshot( |
| 43 |
dir: FilePath, |
| 44 |
snapshot: FilePath, |
| 45 |
opts?: Options, |
| 46 |
): Promise<FilePath>; |
| 47 |
} |
| 48 |
|
| 49 |
export = ParcelWatcher; |