import type { DesignChangeHandler } from '../core/hostBindings.js'; import type { EditorDeclarations } from './declarations.js'; import type { EditorStore } from './store.js'; type SyncStatus = 'idle' | 'saving' | 'saved' | 'error'; declare class DesignSyncState { status: SyncStatus; pending: number; message: string; constructor(); setPending(pending: number): void; setStatus(status: SyncStatus, message: string): void; } export interface DocumentSyncOptions { /** Exact checkout identity attached to every batch from this session. */ sourceRevision?: string; /** Pin this session to its host callback instead of reading a later one. */ onDesignChange?: DesignChangeHandler | null; } /** What document sync reads from the host: the callback a batch is delivered to. */ export interface DocumentSyncHost { readonly onDesignChange: DesignChangeHandler | null; } export interface DocumentSyncDeps { host: DocumentSyncHost; /** The declarations code generation reads (registry, connections). */ declarations: EditorDeclarations; } /** * One editor's code autosave: the baseline of syncable documents, the pending * element changes, the debounce timer, the retirement epoch, and the status * the panels show. `host.onDesignChange` is read when a batch is sent unless * `startDocumentSync` pinned a handler. Every runtime owns one. */ export declare function createDocumentSync(deps: DocumentSyncDeps): { designSyncState: DesignSyncState; resetDocumentSync: () => void; startDocumentSync: (editor: EditorStore, options?: DocumentSyncOptions) => () => void; queueTokenDesignChange: (tokens: { name: string; value: string; }[]) => void; flushDesignChanges: () => Promise; }; export type DocumentSync = ReturnType; export {};