import { type StorageClient } from "../storage/client.js"; import type { SyncOutbox } from "../sync/outbox.js"; import type { OutboxWorker } from "../sync/worker.js"; import type { SqliteSearchIndex } from "./sqliteIndex.js"; export interface WikiFileWatcher { /** Stop watching and release filesystem handles. */ close(): Promise; /** Resolves once chokidar's initial scan completes and events are live. */ whenReady(): Promise; /** Resolves once any pending or in-flight resync has settled (tests). */ whenIdle(): Promise; /** * Run one full reconcile pass immediately: enqueue every current page onto * the outbox, as a backstop for edits the watcher's debounced events * missed (e.g. made while the process was down). No-op if no outbox was * supplied (GH #642 AC6 — no cloud account configured). Exposed so tests * don't have to wait out `reconcileIntervalMs`. */ runReconcileNow(): Promise; } export interface WikiFileWatcherOptions { debounceMs?: number; /** Injectable for tests; defaults to console.warn. */ onError?: (err: unknown) => void; /** * Durable sync outbox to enqueue external edits onto (GH #642). Omit (or * pass null) when no cloud backup is configured — the watcher then only * maintains the search index, unchanged from before this feature. */ outbox?: SyncOutbox | null; worker?: OutboxWorker | null; /** How often to run the full-reconcile backstop; 0 disables the timer. */ reconcileIntervalMs?: number; } /** * Watches the local wiki directory for markdown changes made outside the app * (e.g. moves/renames in Obsidian) and reconciles the SQLite search index. * * Without this, an external move only surfaces on the next `search` call (which * triggers a throttled `ensureSynced`); the watcher closes that gap so the * index follows the filesystem in near real time. * * Only meaningful for the local storage backend — the Supabase backend has no * local source of truth to watch. Caller is responsible for that gate. */ export declare function startWikiFileWatcher(wikiDir: string, drive: StorageClient, index: SqliteSearchIndex, options?: WikiFileWatcherOptions): WikiFileWatcher; //# sourceMappingURL=fileWatcher.d.ts.map