/** * A cross-process advisory lock. * * Every Raycast command is a separate OS process with no shared memory, so two * commands can perform a read-modify-write on the same download id at the same * moment. An in-process mutex (a promise chain, a boolean) cannot see the other * process at all; it makes the code LOOK synchronized while the data still * gets lost. * * The only synchronization primitive available to both processes is the * filesystem they already share, so this is built from `open(path, "wx")` — * the same atomic create-or-fail that `uniquePath({reserve:true})` uses. It is * the lowest-dependency lock that actually crosses a process boundary, which * matters because `dist/runner.bundle.js` has to bundle standalone. * * Two properties are non-negotiable, both learned from lock files that outlive * their owner: * * - **Recoverable.** A runner SIGKILLed mid-write leaves the lock file * behind. A lock that is never stealable would wedge every later download * forever, so a lock whose owner is gone (identified by both pid and * start time when available) and whose mtime is older than `staleMs` is * stolen. When process identity cannot be verified, mtime alone remains * the recovery signal; async holders keep it fresh with a heartbeat. * - **Never fatal.** If the lock cannot be taken within `waitMs` (a wedged * filesystem, a permission problem), the critical section runs ANYWAY, * unsynchronized. Losing a history row is bad; refusing to download is * worse. Callers get correctness in every reachable case and degrade to * the pre-lock behaviour in the unreachable ones. */ export interface FileLockOptions { /** Steal a lock whose file is older than this. Default 10s. */ staleMs?: number; /** Give up waiting and run unsynchronized after this long. Default 5s. */ waitMs?: number; /** Poll interval while waiting. Default 15ms. */ pollMs?: number; } /** Run `fn` while holding `lockPath`. Synchronous, for the status-file writers. */ export declare function withFileLockSync(lockPath: string, fn: () => T, options?: FileLockOptions): T; /** * Run `fn` while holding `lockPath`, without blocking the event loop. * * History mutations are async (Raycast's LocalStorage is a promise API), so * they must not spin the thread the way `withFileLockSync` does. */ export declare function withFileLock(lockPath: string, fn: () => Promise, options?: FileLockOptions): Promise; //# sourceMappingURL=lock.d.ts.map