//#region src/runtime.d.ts interface FlockOpenOptions { readonly body?: string | Uint8Array; readonly fileMode?: number; /** False opens an existing file without creating parents or writing a diagnostic body. Defaults to true. */ readonly create?: boolean; readonly createParent?: boolean; readonly parentMode?: number; /** * Refuse to open through a symlink: the path's final component must be a real * file, so a symlink there fails the open (ELOOP) instead of locking — and a * body write truncating — whatever it points at. Opt in for a lock path an * attacker or an unrelated tool could replace with a symlink. */ readonly noFollow?: boolean; } interface FlockHandle { readonly path: string; readonly fd: number; /** Local handle state only; an inherited duplicate may still own the lock. */ readonly held: boolean; /** Complete and fsynced on success; failure closes this handle. */ replaceBody(body: string | Uint8Array): void; /** Close only. Never issues LOCK_UN because another process may own a duplicate fd. */ release(): void; [Symbol.dispose](): void; } //#endregion //#region src/index.d.ts /** Try one exclusive fd-held flock. Returns null only when another owner holds it. */ export declare function tryAcquireFlock(path: string, options?: FlockOpenOptions): FlockHandle | null; /** Block in the kernel until one exclusive fd-held flock is acquired. */ export declare function acquireFlockBlocking(path: string, options?: FlockOpenOptions): FlockHandle; /** Try until the monotonic timeout expires, parking this thread between attempts; null means still held. */ export declare function acquireFlockWithTimeout(path: string, timeoutMs: number, options?: FlockOpenOptions): FlockHandle | null; /** Adopt an inherited descriptor only when it names and owns this exact flock. */ export declare function adoptInheritedFlock(path: string, fd: number): FlockHandle | null; /** Observe flock liveness. Durable pathname/body presence is never authority. */ export declare function isFlockHeld(path: string): boolean; //#endregion export type { FlockHandle, FlockOpenOptions };