import { documentCommands } from "@commands/document"; import { historyCommands } from "@commands/history"; import { commandIds } from "@commands/ids"; import { createCommandRegistry } from "@commands/registry"; import { selectionCommands } from "@commands/selection"; import { toolCommands } from "@commands/tool"; import { transformCommands } from "@commands/transform"; import { viewportCommands } from "@commands/viewport"; import { createInitialAppState } from "@editor/initial-state"; import { createAppStore } from "@editor/store"; export type ImageStudioApp = ReturnType; export function createImageStudioApp(options?: { documentName?: string; createDefaultArtboard?: boolean }) { const registry = createCommandRegistry([...viewportCommands, ...selectionCommands, ...documentCommands, ...toolCommands, ...transformCommands, ...historyCommands]); const store = createAppStore(createInitialAppState(options?.documentName), registry); if (options?.createDefaultArtboard !== false) { const artboardId = crypto.randomUUID(); store.dispatch(commandIds.documentAddArtboard, { id: artboardId, name: "Artboard 1", bounds: { x: -400, y: -300, w: 800, h: 600 }, }); store.dispatch(commandIds.viewportFitArtboard, { artboardId }); } return { registry, store, }; }