My App
BoardKitCore

Core Overview

Overview of the @hfu.digital/boardkit-core package — zero-dependency shared kernel

The @hfu.digital/boardkit-core package is the shared kernel of BoardKit. It has zero runtime dependencies and provides all types, data structures, algorithms, and protocol definitions used by both the backend and frontend packages.

What's Included

ModuleDescription
TypesBoard, Page, Element (7 types), Participant, styles, events
Scene GraphImmutable SceneState with pure mutation functions
ToolsAbstract Tool class, state machine, ToolRegistry with 8 built-in tools
OperationsLWW merge, undo/redo History, clipboard serialization
ProtocolTyped ClientMessage/ServerMessage for Socket.IO
DrawingPoint simplification, pressure mapping, stroke smoothing
Grid & AlignmentSnap-to-grid, alignment guides for element positioning
ValidationBoard limit checks, asset size validation
RendererAbstract BoardRenderer class and RenderContext interface
ConstantsTOOL_IDS, LIMITS, default styles
FixturesemptyBoard, simpleBoard, denseBoard for testing

Installation

bun add @hfu.digital/boardkit-core

This package is also installed automatically as a dependency of @hfu.digital/boardkit-nestjs and @hfu.digital/boardkit-react.

Usage

import {
    createScene,
    addElement,
    ToolRegistry,
    TOOL_IDS,
    LIMITS,
} from '@hfu.digital/boardkit-core';
import type { Board, Element, SceneState } from '@hfu.digital/boardkit-core';

// Create an empty scene
const scene: SceneState = createScene();

// Create the default tool registry (all 8 built-in tools)
const tools = ToolRegistry.createDefault();
const pen = tools.get(TOOL_IDS.PEN);

On this page