Installation & Setup
Prerequisites
- Node.js 18+ (LTS recommended)
- npm 9+ or any compatible package manager
Install from npm
The Canvus SDK is published to npm as @canvus/core.
npm install @canvus/coreBasic Usage
Import the SDK in your project:
import { Workspace } from '@canvus/core'
const container = document.getElementById('editor-container')!
const ws = new Workspace(container, {
onHTMLCommit(id, html) {
console.log('Clean HTML:', html)
},
})Canvus is a zero-dependency SDK. It ships as pure ESM TypeScript with no runtime framework dependencies. You can integrate it into React, Vue, Svelte, or vanilla JavaScript projects.
Development Setup (Contributing)
If you want to contribute to the SDK or run the demos locally, clone the repository and build from source:
git clone https://github.com/balfaro01/canvus.git
cd canvus
npm install
npm run buildThis compiles the TypeScript source in src/ to the ESM distribution in dist/:
dist/index.jsβ ESM entrypoint moduledist/index.d.tsβ TypeScript type declarationsdist/*.jsβ Compiled utility modules
See the Development Setup guide for the full contributor workflow.
Launch the Dev Workbench
The demo workspace is an interactive playground for testing the SDK:
npm run demoOpen http://localhost:3000 to interact with:
- Multi-direction panning and cursor-anchored zooming
- Node resizing with flow reflow and alignment snapping
- Display style hot-swapping (Flexbox, CSS Grid, block layouts)
- Spacing adjusters for margins and paddings
- The Flat String Bridge output logs
Project Structure
canvus/
βββ demo/ # Dev Workbench (Interactive local testing site)
βββ dist/ # Compiled SDK ESM build and type declarations
βββ docs/ # Raw developer documentation & ADRs
βββ docs-site/ # This documentation site (Next.js + Nextra)
βββ src/ # SDK Core source code (TypeScript)
β βββ index.ts # Public API barrel exports
β βββ types.ts # Canonical data types & models
β βββ matrix.ts # Coordinate transform math
β βββ shadow-mount.ts # Shadow DOM projection layer
β βββ tree.ts # In-memory node hierarchy
β βββ layout.ts # CSS introspection & flow detection
β βββ renderer.ts # Canvas overlay painter
β βββ drop-zone.ts # Drag-and-drop slot calculations
β βββ importer.ts # HTML/CSS document importer
β βββ workspace.ts # Central interaction orchestrator
βββ skills/ # Custom AI/Agent skills
βββ package.json # Scripts, build rules, and dependencies