feat(app): add composition root
This commit is contained in:
7
app/AGENTS.md
Normal file
7
app/AGENTS.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# App Composition Rules
|
||||
|
||||
- `app/` is the composition root for runtime wiring.
|
||||
- Create registries, stores, command sets, input adapters, and renderer/view adapters here.
|
||||
- Do not implement domain rules, command behavior, rendering backend logic, or React UI here.
|
||||
- App composition may import from all layers, but lower layers must not import from `app/`.
|
||||
- Keep factories testable; avoid module-level mutable singleton state unless explicitly required by the runtime entrypoint.
|
||||
16
app/app.ts
Normal file
16
app/app.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { createCommandRegistry } from "@commands/registry";
|
||||
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 }) {
|
||||
const registry = createCommandRegistry([...viewportCommands]);
|
||||
const store = createAppStore(createInitialAppState(options?.documentName), registry);
|
||||
|
||||
return {
|
||||
registry,
|
||||
store,
|
||||
};
|
||||
}
|
||||
2
app/index.ts
Normal file
2
app/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export type { ImageStudioApp } from "./app";
|
||||
export { createImageStudioApp } from "./app";
|
||||
Reference in New Issue
Block a user