Skip to content

Core Types

All types are exported from @witqq/spreadsheet.

import type { CellValue, CellData, CellStyle, ColumnDef, CellRange } from '@witqq/spreadsheet';
type CellValue = string | number | boolean | Date | null;
interface CellData {
readonly value: CellValue;
readonly displayValue?: string; // Override default formatting
readonly formula?: string; // Formula expression (e.g. "=SUM(A1:A10)")
readonly style?: CellStyleRef; // Reference to shared style
readonly type?: CellType; // Cell type for rendering
readonly metadata?: CellMetadata; // Status, links, comments
readonly custom?: Record<string, unknown>; // Extensible user data
}
interface CellMetadata {
readonly status?: 'changed' | 'error' | 'saving' | 'saved';
readonly errorMessage?: string;
readonly link?: { url: string; label?: string };
readonly comment?: string;
}
type CellType =
| 'string' | 'number' | 'boolean' | 'date' | 'datetime'
| 'select' | 'dynamicSelect' | 'formula'
| 'link' | 'image' | 'progressBar' | 'rating' | 'badge'
| 'custom';
interface CellStyle {
readonly bgColor?: string;
readonly textColor?: string;
readonly fontFamily?: string;
readonly fontSize?: number;
readonly fontWeight?: 'normal' | 'bold';
readonly fontStyle?: 'normal' | 'italic';
readonly textAlign?: 'left' | 'center' | 'right';
readonly verticalAlign?: 'top' | 'middle' | 'bottom';
readonly borderTop?: BorderStyle;
readonly borderRight?: BorderStyle;
readonly borderBottom?: BorderStyle;
readonly borderLeft?: BorderStyle;
readonly numberFormat?: string;
readonly textWrap?: boolean;
readonly indent?: number;
}
interface BorderStyle {
readonly width: number;
readonly color: string;
readonly style: 'solid' | 'dashed' | 'dotted';
}
interface CellStyleRef {
readonly ref: string; // Unique key in StylePool
readonly style: CellStyle; // Resolved style object
}
interface CellAddress {
readonly row: number;
readonly col: number;
}
interface CellRange {
readonly startRow: number;
readonly startCol: number;
readonly endRow: number;
readonly endCol: number;
}

Pixel-space rectangle for a cell on canvas:

interface CellRect {
readonly x: number;
readonly y: number;
readonly width: number;
readonly height: number;
}
interface ColumnDef {
readonly key: string; // Data binding key
readonly title: string; // Header display text
readonly width: number; // Width in pixels
readonly minWidth?: number; // Minimum resize width
readonly maxWidth?: number; // Maximum resize width
readonly type?: CellType; // Cell type for rendering
readonly frozen?: boolean; // Pin to frozen pane
readonly sortable?: boolean; // Enable header click sorting
readonly filterable?: boolean; // Enable filter panel
readonly editable?: boolean; // Allow inline editing
readonly resizable?: boolean; // Allow drag-to-resize
readonly hidden?: boolean; // Hide from display and print
readonly wrapText?: boolean; // Enable text wrapping
readonly validation?: SpreadsheetValidationRule[]; // Cell validation rules
}
interface Selection {
readonly type: SelectionType;
readonly ranges: readonly CellRange[];
readonly activeCell: CellAddress;
readonly anchorCell: CellAddress;
}
type SelectionType = 'cell' | 'range' | 'row' | 'column' | 'all';
interface MergedRegion {
readonly startRow: number;
readonly startCol: number;
readonly endRow: number; // inclusive
readonly endCol: number; // inclusive
}
interface ValidationRule {
readonly type: string;
readonly message?: string;
readonly severity?: 'error' | 'warning' | 'info';
}
interface ValidationResult {
readonly valid: boolean;
readonly message?: string;
readonly severity?: 'error' | 'warning' | 'info';
}
type SpreadsheetValidationRule = RequiredRule | RangeRule | RegexRule | CustomRule;

Union of all built-in validation rule types. Used in ColumnDef.validation and the validation engine API.

Theme controls all visual dimensions and colors. See Themes & Styling for details.

interface SpreadsheetTheme {
name: string;
colors: {
background: string;
cellText: string;
cellBorder: string;
headerBackground: string;
headerText: string;
selectionFill: string;
selectionBorder: string;
// ... additional color tokens
};
fonts: {
cell: string;
header: string;
cellSize: number;
headerSize: number;
};
dimensions: {
rowHeight: number;
headerHeight: number;
cellPadding: number;
rowNumberWidth: number;
minColumnWidth: number;
scrollbarWidth: number;
borderWidth: number;
};
borders: {
gridLineWidth: number;
selectionWidth: number;
activeCellWidth: number;
frozenPaneWidth: number;
};
}

Built-in themes: lightTheme, darkTheme.

Options objects passed when constructing core subsystems.

interface CommandManagerConfig {
historyLimit?: number;
onAfterExecute?: CommandCallback;
onAfterUndo?: CommandCallback;
onAfterRedo?: CommandCallback;
}

Undo/redo stack options and lifecycle callbacks.

interface ClipboardManagerConfig {
cellStore: CellStore;
dataView: DataView;
selectionManager: SelectionManager;
commandManager: CommandManager;
eventBus: EventBus;
isEditing: () => boolean;
onDataChange: () => void;
}

Dependencies for copy/cut/paste with TSV and HTML table format support.

interface FilterEngineConfig {
cellStore: CellStore;
totalRowCount: number;
}

Cell store and row count for evaluating filter conditions.

interface SortEngineConfig {
cellStore: CellStore;
totalRowCount: number;
}

Cell store and row count for multi-column stable sorting.

interface SelectionManagerConfig {
rowCount: number;
colCount: number;
onChange?: (selection: Selection, previousSelection: Selection) => void;
}

Grid dimensions and optional selection change callback.

interface InlineEditorConfig {
container: HTMLElement;
scrollContainer: HTMLElement;
layoutEngine: LayoutEngine;
scrollManager: ScrollManager;
cellStore: CellStore;
dataView: DataView;
theme: SpreadsheetTheme;
onCommit: (row: number, col: number, oldValue: CellValue, newValue: CellValue) => void;
onClose: (reason: EditorCloseReason) => void;
frozenRows?: number;
frozenColumns?: number;
}

Textarea overlay editor positioning, commit/close callbacks, and frozen pane offsets.

interface KeyboardNavigatorConfig {
selectionManager: SelectionManager;
getVisibleRowCount: () => number;
}

Selection manager and viewport row count for PageUp/PageDown navigation.

interface LayoutEngineConfig {
columns: ColumnDef[];
rowCount: number;
rowHeight: number;
headerHeight: number;
rowNumberWidth: number;
rowStore?: RowStore;
}

Column definitions and dimension constants for cumulative position arrays.

interface ViewportConfig {
rowBuffer?: number; // Default: 10
colBuffer?: number; // Default: 5
}

Extra rows/columns to pre-render outside the visible area.

interface ScrollManagerConfig {
container: HTMLElement;
totalWidth: number;
totalHeight: number;
onScroll: (scrollX: number, scrollY: number) => void;
}

Scroll container setup and scroll position change callback.

interface ValidationEngineConfig {
cellStore: CellStore;
eventBus: EventBus;
}

Cell store and event bus for validation rule evaluation and error events.

interface AutofillManagerConfig {
cellStore: CellStore;
dataView: DataView;
selectionManager: SelectionManager;
layoutEngine: LayoutEngine;
scrollManager: ScrollManager;
commandManager: CommandManager;
eventBus: EventBus;
dirtyTracker: DirtyTracker;
renderScheduler: RenderScheduler;
container: HTMLElement;
rowCount: number;
colCount: number;
mergeManager?: MergeManager;
}

Dependencies for drag-to-fill handle, pattern detection, and merge-aware autofill.

interface ColumnResizeManagerConfig {
layoutEngine: LayoutEngine;
gridGeometry: GridGeometry;
scrollManager: ScrollManager;
commandManager: CommandManager;
eventBus: EventBus;
columns: ColumnDef[];
container: HTMLElement;
onResize: () => void;
}

Dependencies for header border drag-to-resize with undo support.

interface RowResizeManagerConfig {
layoutEngine: LayoutEngine;
scrollManager: ScrollManager;
commandManager: CommandManager;
eventBus: EventBus;
container: HTMLElement;
onResize: () => void;
}

Dependencies for row-number border drag-to-resize with undo support.

interface ContextMenuManagerConfig {
container: HTMLElement;
engine: SpreadsheetEngine;
eventBus: EventBus;
theme: SpreadsheetTheme;
}

Container, engine reference, and theme for the right-click context menu overlay.

interface AriaManagerConfig {
container: HTMLElement;
scrollContainer: HTMLElement;
eventBus: EventBus;
cellStore: CellStore;
dataView: DataView;
columns: ColumnDef[];
rowCount: number;
}

DOM elements and data sources for WCAG 2.1 AA role=grid and aria-live announcements.

interface PrintManagerConfig {
container: HTMLElement;
cellStore: CellStore;
dataView: DataView;
columns: ColumnDef[];
rowStore: RowStore;
theme: SpreadsheetTheme;
maxPrintRows?: number; // Default: 10000
}

Data sources and row cap for @media print DOM table generation.

interface CanvasManagerConfig {
container: HTMLElement;
dpr?: number; // Defaults to window.devicePixelRatio
}

Container element and optional device pixel ratio override for canvas setup.

interface GridGeometryConfig {
columns: ColumnDef[];
theme: SpreadsheetTheme;
showRowNumbers: boolean;
rowPositions?: Float64Array;
rowHeights?: Float64Array;
}

Column definitions, theme, and shared layout arrays for coordinate computation.

interface EventTranslatorConfig {
scrollContainer: HTMLElement;
layoutEngine: LayoutEngine;
scrollManager: ScrollManager;
eventBus: EventBus;
cellStore: CellStore;
dataView: DataView;
columns: ColumnDef[];
rowGroupManager?: RowGroupManager;
}

DOM-to-cell hit-testing pipeline dependencies and optional row group toggle detection.

Types used by the render pipeline, viewport management, and dirty tracking.

interface GridRenderConfig {
columns: ColumnDef[];
cellStore: CellStore;
dataView: DataView;
rowCount: number;
theme: SpreadsheetTheme;
showRowNumbers: boolean;
showGridLines: boolean;
selectionManager?: SelectionManager;
cellTypeRegistry?: CellTypeRegistry;
rowPositions?: Float64Array;
rowHeights?: Float64Array;
}

Top-level configuration for creating the GridRenderer render pipeline.

type RenderMode = 'full' | 'light' | 'placeholder';

Rendering fidelity level. Currently always 'full'. The union type exists for future optimization.

type PaneRegion = 'corner' | 'frozenRow' | 'frozenCol' | 'main' | 'full';

Identifies which frozen pane region a render pass targets.

interface ViewportRange {
readonly startRow: number;
readonly endRow: number;
readonly startCol: number;
readonly endCol: number;
readonly visibleRowCount: number;
readonly visibleColCount: number;
}

Inclusive row/column range of visible cells including buffer zone.

interface FrozenViewportRanges {
corner: ViewportRange;
frozenRow: ViewportRange;
frozenCol: ViewportRange;
main: ViewportRange;
}

Viewport ranges for all four frozen pane regions.

type DirtyRegion = 'full' | 'viewport-change' | 'cell-update';

Invalidation scope — full redraws everything, cell-update redraws only changed cells.

interface DirtyCell {
row: number;
col: number;
}

Logical row/column address of a cell that needs re-rendering.

interface DirtyRect {
x: number;
y: number;
width: number;
height: number;
}

Pixel-space rectangle for partial canvas invalidation.

Utility types, enums, and interfaces used across multiple subsystems.

type CellAlignment = 'left' | 'center' | 'right';

Horizontal text alignment within a cell, used by CellTypeRenderer.

type ComparisonOperator =
| 'greaterThan' | 'lessThan'
| 'greaterThanOrEqual' | 'lessThanOrEqual'
| 'equal' | 'notEqual'
| 'between' | 'notBetween';

Comparison operators for conditional formatting value conditions.

type EditorCloseReason =
| 'enter' | 'shift-enter' | 'tab' | 'shift-tab'
| 'escape' | 'blur' | 'scroll' | 'programmatic';

Reason the inline editor was closed, determines next-cell navigation direction.

type FillDirection = 'down' | 'up' | 'right' | 'left';

Direction of an autofill drag operation.

type PatternType = 'number-sequence' | 'number-increment' | 'date-sequence' | 'text-repeat';

Type of pattern detected by the autofill PatternDetector.

interface DetectedPattern {
readonly type: PatternType;
readonly step: number;
readonly sourceValues: readonly CellValue[];
}

Result of autofill pattern detection with step increment and source values.

type HitRegion =
| 'cell' | 'header' | 'header-sort-icon' | 'header-filter-icon'
| 'row-number' | 'row-group-toggle' | 'corner' | 'outside';

Region of the grid where a mouse event occurred.

interface HitZone {
readonly id: string;
readonly x: number;
readonly y: number;
readonly width: number;
readonly height: number;
readonly cursor?: string;
}

Declares a rectangular interactive zone within a cell for sub-cell hit testing. Coordinates are relative to the cell content area. Returned by CellTypeRenderer.getHitZones().

type CellDecoratorPosition = 'left' | 'right' | 'overlay' | 'underlay';

Where a cell decorator renders relative to cell content. left/right reserve horizontal space, shifting text inward. overlay renders on top of text, underlay renders behind.

interface CellDecorator {
readonly id: string;
readonly position: CellDecoratorPosition;
getWidth?(cellData: CellData, cellHeight: number, ctx?: CanvasRenderingContext2D, theme?: SpreadsheetTheme, row?: number, col?: number): number;
render(ctx: CanvasRenderingContext2D, cellData: CellData, x: number, y: number, width: number, height: number, theme: SpreadsheetTheme, row?: number, col?: number): void;
getHitZones?(width: number, height: number, cellData: CellData, row?: number, col?: number): HitZone[];
}

Composable rendering addon for cells. Decorators augment the default text rendering pipeline without replacing it. Register via CellTypeRegistry.addDecorator().

  • getWidth — compute reserved width for left/right decorators. Ignored for overlay/underlay. Optional row/col identify the cell being rendered.
  • render — draw the decorator in its allocated area. Optional row/col identify the cell being rendered.
  • getHitZones — optional interactive zones within the decorator’s area. Optional row/col identify the cell being hit-tested.
interface CellDecoratorRegistration {
decorator: CellDecorator;
appliesTo: (row: number, col: number, cellData: CellData) => boolean;
}

Links a decorator to a predicate that controls which cells it applies to. The appliesTo function receives the cell’s row, column, and full CellData.

import type { CellDecoratorRegistration } from '@witqq/spreadsheet';
// Status indicator: colored dot on the left side of cells
const statusDecorator: CellDecoratorRegistration = {
decorator: {
id: 'status-indicator',
position: 'left',
getWidth: () => 16,
render: (ctx, cellData, x, y, width, height) => {
const val = String(cellData.value ?? '');
const color = val === 'Active' ? '#63be7b'
: val === 'Remote' ? '#5b9bd5' : '#f8696b';
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(x + width / 2, y + height / 2, 4, 0, Math.PI * 2);
ctx.fill();
},
},
appliesTo: (_row, col) => col === 15, // Status column
};
engine.getCellTypeRegistry().addDecorator(statusDecorator);
// Remove decorator later:
engine.getCellTypeRegistry().removeDecorator('status-indicator');

Render order: underlay → left → right → text/custom → overlay. Left/right decorators shift text inward by their reserved width.

interface HitTestResult {
readonly region: HitRegion;
readonly row: number; // -1 if not applicable
readonly col: number; // -1 if not applicable
readonly hitZone?: string; // Hit zone ID if point is inside a declared zone
readonly hitZoneCursor?: string; // Cursor style from the matched hit zone
}

Result of coordinate-to-cell hit testing. When a cell type renderer declares hit zones via getHitZones(), hitZone contains the matched zone ID and hitZoneCursor the zone’s cursor style.

interface Command {
execute(): void;
undo(): void;
readonly description: string;
}

Interface for undoable operations in the command stack.

type CommandCallback = (command: Command) => void;

Callback invoked after command execution, undo, or redo.

interface CellEdit {
readonly row: number;
readonly col: number;
readonly oldValue: CellValue;
readonly newValue: CellValue;
}

Single cell value change, used by BatchCellEditCommand for bulk operations.

interface RowCommandDeps {
cellStore: CellStore;
mergeManager: MergeManager | null;
setRowCount: (count: number) => void;
getRowCount: () => number;
}

Dependencies for insert/delete row commands.

interface ColumnAggregate {
col: number;
fn: AggregateFunction;
}

Column index and aggregate function for row group summary calculations.

type MenuContext = 'cell' | 'header' | 'row-number' | 'corner';

Grid region where the context menu was triggered.

interface MenuActionContext {
readonly row: number;
readonly col: number;
readonly region: string;
readonly engine: SpreadsheetEngine;
}

Context passed to context menu item action and visibility callbacks.

interface RequiredRule {
readonly type: 'required';
readonly message?: string;
readonly severity?: 'error' | 'warning' | 'info';
}

Validation rule that rejects empty, null, or undefined values.

interface RangeRule {
readonly type: 'range';
readonly min?: number;
readonly max?: number;
readonly message?: string;
readonly severity?: 'error' | 'warning' | 'info';
}

Validation rule that enforces numeric min/max bounds.

interface RegexRule {
readonly type: 'regex';
readonly pattern: string;
readonly flags?: string;
readonly message?: string;
readonly severity?: 'error' | 'warning' | 'info';
}

Validation rule that tests cell value against a regular expression.

interface CustomRule {
readonly type: 'custom';
readonly validate: (value: CellValue) => ValidationResult;
readonly message?: string;
readonly severity?: 'error' | 'warning' | 'info';
}

Validation rule with a user-supplied validation function.

type CellEditorClose = (reason: EditorCloseReason) => void;

Callback to close an active cell editor with a specified reason.

type CellEditorMatcher = (column: ColumnDef, value: CellValue) => boolean;

Predicate that determines whether a custom cell editor applies to a given column and value.

interface CellEditorRegistration {
editor: CellEditor;
matcher: CellEditorMatcher;
priority: number;
}

Links a CellEditor to a matcher predicate. Higher priority values take precedence when multiple editors match.

interface DatePickerConfig {
container: HTMLElement;
scrollContainer: HTMLElement;
layoutEngine: LayoutEngine;
scrollManager: ScrollManager;
theme: SpreadsheetTheme;
onCommit: (row: number, col: number, oldValue: CellValue, newValue: CellValue) => void;
onClose: (reason: EditorCloseReason) => void;
frozenRows?: number;
frozenColumns?: number;
}

Configuration for DatePickerOverlay. Requires DOM containers, layout references, and commit/close callbacks.

type ConditionalFormatCondition =
| ValueCondition
| GradientScaleCondition
| DataBarCondition
| IconSetCondition;

Union of all supported conditional format condition types.

interface ConditionalFormatRule {
readonly id: string;
readonly priority: number;
readonly range: CellRange;
readonly condition: ConditionalFormatCondition;
readonly style?: Partial<CellStyle>;
readonly stopIfTrue?: boolean;
}

A conditional formatting rule applied to a cell range. Rules are evaluated in priority order. When stopIfTrue is set, lower-priority rules are skipped if this rule matches.

type SortDirection = 'asc' | 'desc';

Sort order for column sorting.

type StretchMode = 'all' | 'last';

Column stretch strategy: all distributes extra width across all columns; last assigns it to the last column.

interface ChangeTrackerConfig {
cellStore: CellStore;
eventBus: EventBus;
}

Configuration for ChangeTracker. Requires access to cell store and event bus.

interface CellChange {
readonly row: number;
readonly col: number;
readonly oldValue: CellValue;
readonly newValue: CellValue;
readonly timestamp: number;
readonly userId?: string;
readonly source: string;
}

Record of a single cell value change. Used by ChangeTracker for audit trails and collaboration conflict resolution.

interface ColumnStretchConfig {
mode: StretchMode;
}

Configuration for column stretch behavior.

interface FilterPanelConfig {
container: HTMLElement;
scrollContainer: HTMLElement;
layoutEngine: LayoutEngine;
scrollManager: ScrollManager;
theme: SpreadsheetTheme;
onApply: (col: number, operator: FilterOperator, value: string, valueTo?: string) => void;
onClear: (col: number) => void;
}

Configuration for the filter panel overlay.

interface FrozenPaneConfig {
frozenRows: number;
frozenColumns: number;
layoutEngine: LayoutEngine;
frozenRanges: FrozenViewportRanges;
}

Configuration for frozen pane rendering regions.

interface TooltipManagerConfig {
container: HTMLElement;
eventBus: EventBus;
cellStore: CellStore;
dataView: DataView;
layoutEngine: LayoutEngine;
scrollManager: ScrollManager;
theme: SpreadsheetTheme;
}

Configuration for the tooltip manager.

class AutoRowSizeManager {
constructor(config: AutoRowSizeConfig, applyHeights: ApplyHeightsCallback);
setLayers(layers: RenderLayer[]): void;
markDirtyRows(rows: Iterable<number>): void;
markAllDirty(): void;
clearDirty(): void;
}

Measures cell content height and applies automatic row sizing. Operates on dirty rows and delegates height updates through ApplyHeightsCallback.

type ApplyHeightsCallback = (updates: Map<number, number>) => void;

Callback receiving a map of row index → computed height for automatic row sizing.

class FillHandleLayer implements RenderLayer {
render(rc: RenderContext): void;
}

Render layer that draws the autofill drag handle at the bottom-right corner of the selection.

class RowGroupToggleLayer implements RenderLayer {
render(rc: RenderContext): void;
}

Render layer that draws expand/collapse toggle icons in the row number area for grouped rows.

class DatePickerOverlay {
constructor(config: DatePickerConfig);
get isOpen(): boolean;
get editingRow(): number;
get editingCol(): number;
}

Calendar overlay for date cell editing. Positioned over the active cell and commits values through the configured callback.

const LINE_HEIGHT_MULTIPLIER = 1.2;

Default multiplier applied to font size when computing line height for text rendering.

interface SpreadsheetEvents {
cellClick: (event: CellEvent) => void;
cellDoubleClick: (event: CellEvent) => void;
cellHover: (event: CellEvent) => void;
cellChange: (event: CellChangeEvent) => void;
selectionChange: (event: SelectionChangeEvent) => void;
scroll: (event: ScrollEvent) => void;
ready: () => void;
destroy: () => void;
commandExecute: (event: CommandEvent) => void;
commandUndo: (event: CommandEvent) => void;
commandRedo: (event: CommandEvent) => void;
clipboardCopy: (event: ClipboardDataEvent) => void;
clipboardCut: (event: ClipboardDataEvent) => void;
clipboardPaste: (event: ClipboardDataEvent) => void;
columnResize: (event: ColumnResizeEvent) => void;
columnResizeStart: (event: { colIndex: number }) => void;
columnResizeEnd: (event: ColumnResizeEvent) => void;
rowResize: (event: RowResizeEvent) => void;
rowResizeStart: (event: { rowIndex: number }) => void;
rowResizeEnd: (event: RowResizeEvent) => void;
cellStatusChange: (event: CellStatusChangeEvent) => void;
cellValidation: (event: CellValidationEvent) => void;
autofillStart: (event: AutofillStartEvent) => void;
autofillPreview: (event: AutofillPreviewEvent) => void;
autofillComplete: (event: AutofillCompleteEvent) => void;
sortChange: (event: SortChangeEvent) => void;
sortRejected: (event: SortRejectedEvent) => void;
filterChange: (event: FilterChangeEvent) => void;
rowGroupToggle: (event: RowGroupToggleEvent) => void;
rowGroupChange: (event: RowGroupChangeEvent) => void;
themeChange: (event: { theme: SpreadsheetTheme }) => void;
}

Map of all public events emitted by SpreadsheetEngine. Use engine.on(eventName, handler) to subscribe.

class BenchmarkRunner {
record(name: string, dataset: string, stats: RunStats, unit?: string): void;
toJSON(): BenchmarkSuiteResult;
reset(): void;
}

Collects benchmark metrics and serializes results.

interface BenchmarkMetric {
name: string;
dataset: string;
stats: RunStats;
unit: string;
}

A single benchmark measurement with statistical summary.

interface BenchmarkResult {
initTimeMs: number;
memoryMB?: number;
rowCount: number;
columnCount: number;
}

Initialization benchmark result capturing startup time and optional memory usage.

interface BenchmarkSuiteResult {
timestamp: string;
metrics: BenchmarkMetric[];
}

Complete benchmark suite output with timestamp and all collected metrics.

interface RunStats {
medianMs: number;
meanMs: number;
minMs: number;
maxMs: number;
cv: number;
runs: number[];
}

Statistical summary of multiple benchmark runs. cv is the coefficient of variation.

interface TimingResult {
timeMs: number;
}

Single timing measurement result.

function computeStats(times: number[]): RunStats;

Computes statistical summary from an array of timing measurements.

function measureMultiRun(fn: () => void, runs?: number): RunStats;

Executes a function multiple times and returns aggregated statistics. Defaults to 3 runs.

function measureThroughput(
fn: () => void,
iterations: number,
): { opsPerSec: number; totalMs: number };

Measures operations per second by running a function for the specified number of iterations.

function measureInitTime(factory: () => void): TimingResult;

Measures the time to execute a factory function once and returns a TimingResult.

class FPSCounter {
start(): void;
tick(): void;
stop(): FPSResult;
}

Measures rendering frame rate. Call start() before the loop, tick() on each frame, and stop() to get the result.

interface FPSResult {
avgFPS: number;
minFPS: number;
maxFPS: number;
frameCount: number;
durationMs: number;
}

Frame rate measurement result from FPSCounter.stop().