Skip to content

AdapterConfig type

Home > @rimitive/view > AdapterConfig

AdapterConfig defines the type-level contract for a tree adapter: - props: Maps tag names to their prop types for el() autocomplete - elements: Maps tag names to their node types for RefSpec<T> (e.g., ‘div’ -> HTMLDivElement) - events: Maps event names to their event object types (e.g., ‘click’ -> MouseEvent) - baseElement: Base node type for this adapter (e.g., Node for DOM)

Separating props from elements allows adapters to have clean prop autocomplete without exposing internal node properties (like canvas’s bounds, dirty, etc).

Note: Text is just another node type created via createNode(‘text’, { value: ’…’ })

Signature:

export type AdapterConfig = {
props: object;
elements: object;
events: object;
baseElement: object;
};
import type { AdapterConfig } from '@rimitive/view/adapter';
// DOM adapter config
type DOMAdapterConfig = AdapterConfig & {
props: {
div: { className?: string; id?: string };
button: { disabled?: boolean; textContent?: string };
};
elements: {
div: HTMLDivElement;
button: HTMLButtonElement;
};
events: {
click: MouseEvent;
input: InputEvent;
};
baseElement: HTMLElement;
};