# Classes

Import these from `@grafloria/renderer`.

## Classes

### `ColorModeController`

Watches the OS preferences and calls back with the theme that should now be
active. Owns its listeners; `dispose()` removes every one of them.

It subscribes to the contrast/forced-colors queries even in explicit
light/dark mode — those are ACCESSIBILITY preferences, and a user who turns on
high contrast must be honoured whether or not the host let them choose a
colour scheme.

```ts
class ColorModeController
```

**Methods**

- `constructor(mode: ColorMode, themes: ThemeSet, onTheme: (theme: Theme) => void)`
- `resolve(): Theme` — The theme the current mode + OS preferences resolve to.
- `getMode(): ColorMode` — The mode this controller is following.
- `setMode(mode: ColorMode): void` — Switch modes. Emits immediately if the resolved theme actually changed.
- `setThemes(themes: ThemeSet): void` — Swap the theme SET (e.g. the host shipped its own light/dark pair).
- `emit(): void` — Push the current resolution to the callback. Deduped by identity: an OS
change that does not change the ANSWER (contrast toggled while a host
supplied no high-contrast theme) must not trigger a re-theme.
- `prime(theme: Theme): void` — Prime `current` without calling back — the renderer already has this theme.
- `dispose(): void`
