@klad/engine
v1.11.1
Published
Klad — a canvas tree engine for tens of thousands of nodes. Tiered, file, radial and sunburst layouts, with a DOM overlay for your own node content. Frameworkless.
Maintainers
Readme
@klad/engine
The pure-logic layer of Klad: tree normalization, the layout registry (tidy, file, radial and sunburst), orientation/RTL mirroring, the viewport (pan/zoom/inertia) math, a quadtree for hit-testing, the Canvas2D renderer, and the typed worker protocol. No DOM dependency in the main entry, so it can run inside a Web Worker.
Most consumers don't need this package directly — use
@klad/core
(frameworkless) or
@klad/vue
instead. Depend on this package directly only if you're building a new
framework adapter; @klad/core's source is the reference
implementation to read.
npm install @klad/engineimport { normalize, layout } from '@klad/engine'
const tree = normalize([{ id: 'ceo' }, { id: 'cto', parentId: 'ceo' }])
const sizes = new Float64Array(tree.count * 2).fill(0)
for (let i = 0; i < tree.count; i++) {
sizes[i * 2] = 180
sizes[i * 2 + 1] = 64
}
const { boxes, bounds } = layout(tree, sizes, { spacingX: 16, spacingY: 48 })The one DOM-touching module, ChartHost, is exported from a separate
subpath — @klad/engine/host — rather than the main entry, so the
main entry stays importable inside the Web Worker it also ships
(worker/chart.worker.ts).
Full architecture notes live in the repository README and in the documentation.
Licence
Dual-licensed: GNU AGPL v3 or later, or a commercial licence for use the AGPL does not permit — see LICENSE-COMMERCIAL.md, or email [email protected].
