···22import type { ShapeRecord } from "./model";
33import type { EditorState } from "./reactivity";
4455+export type CommandKind = "doc" | "ui" | "camera";
66+77+export type HistoryOperation = "do" | "undo" | "redo";
88+99+export type HistoryAppliedEvent = {
1010+ op: HistoryOperation;
1111+ commandId: number;
1212+ command: Command;
1313+ kind: CommandKind;
1414+ beforeState: EditorState;
1515+ afterState: EditorState;
1616+};
1717+518/**
619 * Command interface for undo/redo operations
720 *
···1023export interface Command {
1124 /** Display name for this command (shown in history UI) */
1225 readonly name: string;
2626+ /** Command category, used for persistence decisions */
2727+ readonly kind: CommandKind;
13281429 /**
1530 * Execute the command and return the new state
···3146 */
3247export class CreateShapeCommand implements Command {
3348 readonly name: string;
4949+ readonly kind = "doc" as const;
34503551 constructor(private readonly shape: ShapeRecord, private readonly pageId: string) {
3652 this.name = `Create ${shape.type}`;
···7995 */
8096export class UpdateShapeCommand implements Command {
8197 readonly name: string;
9898+ readonly kind = "doc" as const;
829983100 constructor(
84101 private readonly shapeId: string,
···102119 */
103120export class DeleteShapesCommand implements Command {
104121 readonly name: string;
122122+ readonly kind = "doc" as const;
105123106124 constructor(private readonly shapes: ShapeRecord[], private readonly pageId: string) {
107125 this.name = shapes.length === 1 ? `Delete ${shapes[0].type}` : `Delete ${shapes.length} shapes`;
···162180 */
163181export class SetSelectionCommand implements Command {
164182 readonly name = "Change selection";
183183+ readonly kind = "ui" as const;
165184166185 constructor(private readonly before: string[], private readonly after: string[]) {}
167186···179198 */
180199export class SetCameraCommand implements Command {
181200 readonly name = "Move camera";
201201+ readonly kind = "camera" as const;
182202183203 constructor(private readonly before: Camera, private readonly after: Camera) {}
184204
+2
packages/core/src/index.ts
···44export * from "./history";
55export * from "./math";
66export * from "./model";
77+export * from "./persistence/db";
88+export * from "./persistence/web";
79export * from "./reactivity";
810export * from "./tools";