/**
* Hand-authored declarations for the "./board" export of ardegazu-rooms-kit —
* the compiled dist/board/index.js (ClojureScript). Mirrors the v1.0.0
* TypeScript API surface exactly.
*/
import { EventEmitter } from "node:events";
import type { Identity } from "ardegazu-id-kit";
import type { Net, RoomLog, RelayConfig } from "../index.js";
export const BOARD_SALT: "board.ardegazu.ro/v1";
/** 32 random bytes, base64url unpadded (43 chars) — the room capability. */
export declare function newRoomSecret(): string;
/** Board element spec; `stroke` is what the pen tool (and the bot) produces. */
export interface StrokeSpec {
id: string;
k: "stroke";
x: number;
y: number;
/** Flat [dx0,dy0,…] fixed-point ints (world*100), delta-encoded from (x,y). */
pts: number[];
prs?: number[];
w: number;
c: number;
}
export type BoardElement = Record<string, unknown> & { id: string; k: string };
export interface BoardOptions {
roomSecret: string;
name: string;
dataDir: string;
identity?: Identity | null;
appSalt?: string;
origin?: string;
relay?: Partial<RelayConfig>;
}
export interface BoardEvents {
/**
* A logged `add` landed. A duplicate add for a live element id folds to the
* EARLIEST (clock, hash) — the same rule the browser applies — so an add
* that loses the fold changes nothing and does NOT emit.
*/
element: [el: BoardElement, from: string];
/**
* A logged `edit` landed. Racing edits fold per (element id, field), so a
* patch may be applied only in part; when every field of it loses the fold
* nothing is emitted at all. The patch reported is the one on the wire —
* `elements()` is the authority on what actually landed.
*/
edited: [id: string, patch: Record<string, unknown>];
deleted: [ids: string[]];
peer: [id: string, name: string | undefined];
peerGone: [id: string];
ready: [];
status: [up: boolean];
}
export declare class BoardClient extends EventEmitter<BoardEvents> {
readonly net: Net;
readonly log: RoomLog;
readonly roomId: string;
static join(opts: BoardOptions): Promise<BoardClient>;
elements(): BoardElement[];
/**
* Draw a stroke: stream live preview segments at the pen cadence, then commit
* the add op. `points` are absolute world coordinates.
*/
drawStroke(points: { x: number; y: number }[], style?: { width?: number; color?: number }): Promise<string>;
addText(x: number, y: number, text: string, opts?: { size?: number; color?: number }): Promise<string>;
erase(ids: string[]): Promise<void>;
close(): Promise<void>;
private constructor();
}