faust-core-ui defines the minimal base class for Faust UI components.
Goals:
- explicit inheritance model
- minimal API surface
- no optional/generalized abstractions unless required
type Path = string;
type ParamValue = number;abstract class FaustUICore<TState> {
protected readonly root: HTMLElement;
protected readonly paramChangeByUI: (path: Path, value: ParamValue) => void;
constructor(
root: HTMLElement,
paramChangeByUI: (path: Path, value: ParamValue) => void
);
// Host -> UI sync
abstract setParamValue(path: Path, value: ParamValue): void;
abstract setParams(values: Record<Path, ParamValue>): void;
// State
abstract getState(): TState;
abstract setState(state: TState): void;
// Layout
abstract resize(): void;
// Atomic updates
beginUpdate(): void;
endUpdate(): void;
transaction(fn: () => void): void;
// Lifecycle
destroy(): void;
}- UI -> host: UI invokes the host callback
paramChangeByUI(path, value)on effective user-driven parameter change. - host -> UI: host calls
setParamValue/setParamsfor external updates.
beginUpdate()starts (or nests) an atomic update section.endUpdate()ends one section; when depth reaches 0, a single visual/state flush is performed.transaction(fn)is equivalent tobeginUpdate(); try { fn(); } finally { endUpdate(); }.
- missing
root=> throw in constructor - missing
paramChangeByUI=> throw in constructor - invalid state passed to
setState=> ignore and warn (console.warnby default)