This guide covers the internal architecture, local development setup, and debugging strategies for the core Mind Map SDK.
The SDK is split into several core components:
- Models:
models/NodeModel.tsdefines the logical structure of a mind map node. - Engine:
LayoutEngine.ts: Logic for calculating node positions (X, Y) and dimensions based on content.RenderEngine.ts: Converts the layout-calculated structure into SVG or Canvas paths.MindMapEngine.ts: Orchestrates the layout and rendering process.
- Utils: Helper functions for IDs, colors, and text measurement.
-
Install Dependencies:
npm install
-
Start Development (Watch Mode): This runs the TypeScript compiler in watch mode.
npm run dev
-
Run Examples: To see your changes in a browser:
npm run build:bundle npm run serve:examples
Then visit
http://localhost:8080/examples/index.html.
We provide pre-configured launch tasks in .vscode/launch.json:
- Open the "Run and Debug" view (
Ctrl+Shift+D). - Select a configuration:
- Debug Example: Basic Usage: Debugs the
examples/basic-usage.tsscript. - Debug All Tests: Runs all Vitest tests with the debugger attached.
- Debug Example: Basic Usage: Debugs the
- Press
F5to start debugging.
You can run and debug example scripts directly using tsx:
npx tsx examples/basic-usage.tsSource maps are enabled by default in tsconfig.json. This allows you to set breakpoints directly in the .ts files when debugging in VS Code or Chrome DevTools.
- Define Types: Update
types/if adding new node properties. - Update Model: Reflect type changes in
models/NodeModel.ts. - Adjust Layout: If the feature affects positioning, update
engine/LayoutEngine.ts. - Update Renderer: Implement the visual change in
engine/RenderEngine.ts. - Vaildate: Add a test or Update an example in the
examples/directory.
Before submitting a PR, please ensure:
npm run lint: Passes without errors.npm run format: All files are formatted.npm run type-check: No TypeScript errors.npm run build: The project builds successfully.
Powered by MindStage