controlroom
API reference

controlroom/plugin

Every export of controlroom/plugin, with its signature and doc comment: validate, register, reset, registered, CONTRACT, PluginError, plus 4 types.

import { validate, register, reset, … } from 'controlroom/plugin';

Functions

register

Validate, then keep every keymap and pane. A later entry of the same name replaces an earlier one.

function register(plugin: unknown): void;
ParameterType
pluginunknown

Returns void

registered

Copies of what has been registered: the only way in is register().

function registered(): {
    keymaps: Map<string, Required<KeymapDef>>;
    panes: Map<string, PaneDef>;
};

Returns { keymaps: Map<string, Required<KeymapDef>>; panes: Map<string, PaneDef>; }

reset

Forget every registration, the built-ins included: they come back on the next use. For tests.

function reset(): void;

Returns void

validate

Refuse what the schema refuses, and say why.

function validate(plugin: unknown): asserts plugin is Plugin;
ParameterType
pluginunknown

Returns asserts plugin is Plugin

Classes

PluginError

A refused plugin says what is wrong, where, and what to do about it.

class PluginError extends Error {
    readonly code: PluginErrorCode;
    readonly fix: string;
    constructor(code: PluginErrorCode, message: string, fix: string);
}

Constants

CONTRACT

const CONTRACT = 1;

Interfaces

KeymapDef

A keymap: key spec → action name, and the label each action shows in the hint line.

interface KeymapDef {
    keys: Readonly<Record<string, string>>;
    labels?: Readonly<Record<string, string>>;
}

PaneDef

A pane as data: the flagstaff component that draws it, and the label a static projection prints.

interface PaneDef {
    component: string;
    label?: string;
}

Plugin

interface Plugin {
    name: string;
    contract?: number;
    keymaps?: Readonly<Record<string, KeymapDef>>;
    panes?: Readonly<Record<string, PaneDef>>;
}

Types

PluginErrorCode

The family's refusal vocabulary, the members this host can raise.

type PluginErrorCode = 'E_PLUGIN_SCHEMA' | 'E_PLUGIN_CONTRACT' | 'E_NO_CONTRIBUTION';

On this page