mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 17:38:10 +00:00
The user critique on the original HistoryManager design was sharp: adding a new action kind required edits to four places (HistoryContext interface, deps wiring in editor.ts, entry factory, recorder method). Anything shared between kinds becomes a chokepoint that grows. Introduce the proper Command pattern: - UndoableAction interface — single shape every action class implements. HistoryManager's external API becomes record(action) + undo/redo. Future kinds add a new class file under engine/editor/actions/; HistoryManager itself never grows. - isReplaying flag — record() no-ops while undo/redo is mid-flight, so any side-effect chain inside an action's apply/revert (e.g. delete-undo reaching editor.deleteObject which calls history.recordDelete) can't poison the stack. Belt-and-suspenders with the per-kind silent-setter routes the action classes will use. - engine/editor/actions/snapshots.ts — shared ObjectSnap / TransformSnap types, snapshot helpers, transformsEqual, writeTransform, and recreateFromSnapshot. Used by the action classes added in the next commit. Legacy recordCreate / recordDelete / begin+endTransform / recordSetColor / recordSetLocked / recordSetVisible methods stay as thin wrappers that bind the current HistoryContext into an UndoableAction via wrap(). Call sites compile unchanged. They're removed once all sites migrate to record(new XAction(...)).
Frontend
This is an nx monorepo that can contain multiple apps and shared libraries.
All commands to run these projects are performed from this directory.
Install dependencies
npm install
Editor2d
Run dev server:
nx dev editor2d
artcraft
Run dev server:
nx dev artcraft
call when starting on main or a new branch:
./clean_modules
The names for @frontend and @storyteller come from the package.json file in the libs folder.
import { Login } from "@frontend/login";
import { api } from "@storyteller/api";
For shared UI components, import from @storyteller/ui-[componentname].
import { Button } from "@storyteller/ui-button";
import { Modal } from "@storyteller/ui-modal";
building:
npx nx build artcraft
npx nx build editor2d
dev:
npx nx dev artcraft
npx nx dev editor2d
# component build
1.
npx nx g @nx/react:library libs/components/toaster --import-path=@storyteller/ui-toaster --bundler=vite
npm install
2.import it first in code
3.nx sync
4.nx build
or
# frontend build
in frontend folder
% nx build -project type
% nx build artcraft
% nx dev artcraft