/** * Observable write-queue. * * Tracks outstanding in-flight *logical* writes (a full Collection.put / * delete, including ledger + cache + derivation + MV dispatch — not just * the adapter call). The hub holds one tracker per instance; it is * framework-agnostic (no Vue/React dependency). UI layers subscribe via * onChange(); the migration drain (Slice 2) quiesces via onFlush(). */ /** Public, read-only view of the hub's write-queue. */ export interface WriteQueue { /** True while one or more writes are in flight (`depth > 0`). */ readonly pending: boolean; /** Count of outstanding write operations. */ readonly depth: number; /** * Subscribe to depth changes (fires on every begin and settle). * Returns an unsubscribe function. Intended for reactive wrappers * (e.g. `@noy-db/in-vue` turns this into a `ref`). */ onChange(handler: () => void): () => void; /** * Resolves once `depth` reaches 0. If a write settled with an error * while this flush was waiting, the returned promise REJECTS with that * error instead — so a drain caller surfaces the failure rather than * hanging. Resolves immediately when already idle and error-free. */ onFlush(): Promise; } export declare class WriteQueueTracker implements WriteQueue { #private; get pending(): boolean; get depth(): number; /** Mark one write as started. */ begin(): void; /** Mark one write as finished. Pass the error if it failed. */ settle(error?: Error): void; onChange(handler: () => void): () => void; onFlush(): Promise; /** * Run `fn` as a tracked write: depth++ on entry, depth-- on settle * (success or failure). The fn's resolved value is returned; a thrown * error is re-thrown after the queue is decremented. */ track(fn: () => Promise): Promise; }