import { BoardOp } from './history.js'; import { BoardScene } from './types.js'; /** * BoardStore — a framework-free state container over a BoardScene. * * Holds an immutable scene snapshot, an undo/redo history of * (forward, inverse) op pairs, and a plain set of subscribers. Hosts wrap * this in their own reactivity (e.g. Svelte `$state`); the store never * imports a UI framework. * * Subscribers receive the changed element ids so a host can re-render only * what moved instead of diffing the whole scene. */ type Subscriber = (scene: BoardScene, changedIds: string[]) => void; interface ApplyOptions { /** * Coalesce with the previous entry if it shares this key and sits at the * top of the undo stack — so a 60fps drag collapses to one undo step. */ mergeKey?: string; } declare class BoardStore { private scene; private undoStack; private redoStack; private subscribers; private txn; constructor(initial?: BoardScene); /** Current immutable scene snapshot. */ getScene(): BoardScene; subscribe(fn: Subscriber): () => void; private emit; /** * Apply an op. Inside `transact`, ops accumulate into one history entry; * otherwise each apply is its own entry (subject to mergeKey coalescing). */ apply(op: BoardOp, options?: ApplyOptions): void; /** Group every apply inside `fn` into a single, atomic history entry. */ transact(fn: () => void): void; private push; canUndo(): boolean; canRedo(): boolean; undo(): void; redo(): void; /** Replace the whole scene (e.g. opening a file); clears history. */ reset(scene: BoardScene): void; } export { type ApplyOptions, BoardStore };