import { watch as fsWatch } from "fs"; import fs from "fs/promises"; import Logger from "../logger.js"; /** * Development-only file watcher that asks the HTTP server to recycle workers * when application source files change. */ export default class VelociousHttpServerDevelopmentReloader { configuration: import("../configuration.js").default; debounceMs: number; logger: Logger; onReload: (args: { changedPath: string; }) => Promise; readdir: typeof fs.readdir; stat: typeof fs.stat; watchFactory: typeof fsWatch; /** * Narrows the runtime value to the documented type. * @type {ReturnType | undefined} */ reloadTimer: ReturnType | undefined; /** * Narrows the runtime value to the documented type. * @type {string | undefined} */ pendingChangedPath: string | undefined; /** * Narrows the runtime value to the documented type. * @type {Map} */ watchers: Map; /** * Runs constructor. * @param {object} args - Options object. * @param {import("../configuration.js").default} args.configuration - Configuration instance. * @param {(args: {changedPath: string}) => Promise} args.onReload - Reload callback. * @param {number} [args.debounceMs] - Debounce window for grouped changes. * @param {typeof fsWatch} [args.watchFactory] - File watch factory. * @param {typeof fs.readdir} [args.readdir] - Directory reader. * @param {typeof fs.stat} [args.stat] - Stat reader. */ constructor({ configuration, onReload, debounceMs, watchFactory, readdir, stat }: { configuration: import("../configuration.js").default; onReload: (args: { changedPath: string; }) => Promise; debounceMs?: number; watchFactory?: typeof fsWatch; readdir?: typeof fs.readdir; stat?: typeof fs.stat; }); /** * Runs start. * @returns {Promise} - Resolves when watching has started. */ start(): Promise; /** * Runs watch root paths. * @returns {string[]} - Source directories to watch. */ watchRootPaths(): string[]; /** * Runs watch directory recursive. * @param {string} directoryPath - Directory path. * @returns {Promise} - Resolves when child directories are watched. */ watchDirectoryRecursive(directoryPath: string): Promise; /** * Runs on watcher event. * @param {object} args - Options object. * @param {string} args.directoryPath - Watched directory path. * @param {string} args.eventType - Watch event type. * @param {string | Buffer | null} args.fileName - Relative changed filename. * @returns {Promise} - Resolves when complete. */ onWatcherEvent({ directoryPath, eventType, fileName }: { directoryPath: string; eventType: string; fileName: string | Buffer | null; }): Promise; /** * Runs should reload path. * @param {object} args - Options object. * @param {string} args.changedPath - Changed path. * @param {string | Buffer | null} args.fileName - Raw filename from fs.watch. * @returns {boolean} - Whether the path should trigger reload. */ shouldReloadPath({ changedPath, fileName }: { changedPath: string; fileName: string | Buffer | null; }): boolean; /** * Runs watch potential directory. * @param {string} changedPath - Candidate directory path. * @returns {Promise} - Resolves when any new directory watchers are added. */ watchPotentialDirectory(changedPath: string): Promise; /** * Runs schedule reload. * @param {string} changedPath - Changed path. * @returns {void} - No return value. */ scheduleReload(changedPath: string): void; /** * Runs flush reload. * @returns {Promise} - Resolves when the queued reload is handled. */ flushReload(): Promise; /** * On watcher error. * @param {Error} error - Watcher error. * @returns {void} - No return value. */ onWatcherError: (error: Error) => void; /** * Runs stop. * @returns {Promise} - Resolves when watchers are closed. */ stop(): Promise; } //# sourceMappingURL=development-reloader.d.ts.map