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