/** * dsh-widgets — the preference WRITE path. * * Every write is one transaction with two sinks: * 1. localStorage, the fast per-origin cache, written immediately; and * 2. the host file (`/api/widgets-state`), written through a 400 ms debounce * and flushed with `sendBeacon` when the page is being torn down. * * The localStorage mirror lives in this module (rather than in * `runtime/prefs.ts`) because it shares the SAME timestamp as the host write: * whichever sink is newer decides the winner at boot, so the two writes cannot be * separated without splitting that decision. */ import { type Prefs } from './prefs'; /** Same-origin host route holding the authoritative state file. */ export declare const STORE_API = "/api/widgets-state"; export declare function putState(s: Prefs, at: number): Promise; export declare function saveState(s: Prefs): void; /** * Flush any state that has not yet reached the host store when the page is * being torn down (window/tab close, navigation, desktop-app quit). The * 400 ms debounce means the last edit before a quick close is usually still * pending here; a normal fetch would be cancelled with the page, but * `sendBeacon` is delivered by the browser even as the page is destroyed — * which is what keeps the write inside desktop shells that spawn a fresh * random loopback origin on every launch (their localStorage is a new realm * each boot, so the host file is the only channel that survives). */ export declare function flushPendingState(): void;