ssap_app/node_modules/@expo/metro/metro-file-map/watchers/NativeWatcher.d.ts

43 lines
1.6 KiB
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
import { AbstractWatcher } from "./AbstractWatcher";
/**
* NativeWatcher uses Node's native fs.watch API with recursive: true.
*
* Supported on macOS (and potentially Windows), because both natively have a
* concept of recurisve watching, via FSEvents and ReadDirectoryChangesW
* respectively. Notably Linux lacks this capability at the OS level.
*
* Node.js has at times supported the `recursive` option to fs.watch on Linux
* by walking the directory tree and creating a watcher on each directory, but
* this fits poorly with the synchronous `watch` API - either it must block for
* arbitrarily large IO, or it may drop changes after `watch` returns. See:
* https://github.com/nodejs/node/issues/48437
*
* Therefore, we retain a fallback to our own application-level recursive
* FallbackWatcher for Linux, which has async `startWatching`.
*
* On Windows, this watcher could be used in principle, but needs work around
* some Windows-specific edge cases handled in FallbackWatcher, like
* deduping file change events, ignoring directory changes, and handling EPERM.
*/
declare class NativeWatcher extends AbstractWatcher {
static isSupported(): boolean;
constructor(dir: string, opts: {
readonly ignored?: null | RegExp;
readonly globs: ReadonlyArray<string>;
readonly dot: boolean;
});
startWatching(): Promise<void>;
stopWatching(): Promise<void>;
_handleEvent(relativePath: string): Promise<void>;
}
export default NativeWatcher;