import { Smartenv } from '@push.rocks/smartenv'; import type { IWatcher, IWatcherOptions, IWatchEvent, TWatchEventType } from './interfaces.js'; export type { IWatcher, IWatcherOptions, IWatchEvent, TWatchEventType }; /** * Creates a platform-appropriate file watcher based on the current runtime * Uses @push.rocks/smartenv for runtime detection */ export async function createWatcher(options: IWatcherOptions): Promise { const env = new Smartenv(); if (env.isDeno) { // Deno runtime - use Deno.watchFs const { DenoWatcher } = await import('./watcher.deno.js'); return new DenoWatcher(options); } else { // Node.js or Bun - both use fs.watch (Bun has Node.js compatibility) const { NodeWatcher } = await import('./watcher.node.js'); return new NodeWatcher(options); } } /** * Default watcher options */ export const defaultWatcherOptions: IWatcherOptions = { basePaths: [], depth: 4, followSymlinks: false, stabilityThreshold: 300, pollInterval: 100 };