/** * UndoManager — Per-Layer Slice-Snapshot Undo/Redo * * Phase 6: Replaces the old HTMLImageElement-based undo system. * * Design: * - Each layer has an independent undo and redo stack. * - Each entry (MaskDelta) stores a full 2D slice snapshot before and after * the operation (cheaper than full volume, sufficient for single-stroke ops). * - maxStackSize: 50 entries per layer. * - Undo/redo operations also trigger backend sync via getMask callback. */ export interface MaskDelta { layerId: string; axis: "x" | "y" | "z"; sliceIndex: number; /** Full slice data captured before the drawing operation. */ oldSlice: Uint8Array; /** Full slice data captured after the drawing operation. */ newSlice: Uint8Array; } /** A single delta or a group of deltas treated as one undo unit. */ export type UndoEntry = MaskDelta[]; export declare class UndoManager { private undoStacks; private redoStacks; private activeLayer; constructor(); /** Set the currently active layer (determines which stack undo/redo operates on). */ setActiveLayer(layer: string): void; /** Push a single delta onto the active layer's undo stack and clear the redo stack. */ push(delta: MaskDelta): void; /** Push a group of deltas as a single undo unit (e.g. 3D sphere spanning multiple slices). */ pushGroup(deltas: MaskDelta[]): void; /** * Undo the last operation on the active layer. * @returns The delta(s) that were undone, or undefined if nothing to undo. */ undo(): UndoEntry | undefined; /** * Redo the last undone operation on the active layer. * @returns The delta(s) that were redone, or undefined if nothing to redo. */ redo(): UndoEntry | undefined; canUndo(): boolean; canRedo(): boolean; /** Clear undo and redo stacks for a specific layer (called on clearActiveLayer). */ clearLayer(layer: string): void; /** Clear all stacks for all layers (called on full dataset reload). */ clearAll(): void; }