roundel
API reference

roundel/plugin

Every export of roundel/plugin, with its signature and doc comment: validate, register, reset, theme, contributions, registered and 2 more, plus 3 types.

The plugin host for roundel's half of the contract (plugin-contract R1, R4, R6, R8).

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

Functions

contributions

Every token a plugin contributed, with who won it and who it shadowed.

function contributions(): Contribution[];

Returns Contribution[]

register

Register a plugin. Later wins, like ESLint flat config: the array is ordered, a caller reads it top to bottom, and the last word on a token is the one nearest the program.

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

Returns void

registered

The plugins registered, in registration order.

function registered(): readonly Plugin[];

Returns readonly Plugin[]

reset

Forget every registered plugin. For tests, and for a program that re-themes at runtime.

function reset(): void;

Returns void

theme

The theme every registered plugin adds up to, ready for fly().

function theme(): Theme;

Returns Theme

validate

Refuse a plugin that cannot contribute a theme, at the door.

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

Returns asserts plugin is Plugin

Classes

PluginError

A refused plugin says what is wrong and what to do about it — the family's one vocabulary.

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

Constants

CONTRACT

The plugin contract version. One number for the family — the same 1 flagstaff declares, written out rather than imported for the reason in the file comment above.

const CONTRACT = 1;

Interfaces

Contribution

Which plugin last contributed each token — the shadowing a plugin check prints.

interface Contribution {
    token: string;
    value: Hex;
    from: string;
    /** Plugins that contributed this token earlier and were overridden, in order. */
    shadowed: string[];
}

Plugin

The keys roundel reads. Declared structurally: any object with these fields is a plugin here, whatever else it carries.

interface Plugin {
    name: string;
    contract?: number;
    tokens?: Record<string, string>;
}

Types

PluginErrorCode

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

On this page