Expand description
Design token loading, filtering, and CSS generation for WebUI.
Loads token values from JSON files, filters them against the protocol’s token
list, follows present transitive var(--x) dependencies for tokens in each
theme, and generates per-theme CSS declaration strings ready for state
injection. Theme token internals are trusted: unresolved or cyclic
dependencies remain browser CSS semantics rather than build failures.
§Token file format
Single multi-theme JSON:
{
"themes": {
"light": { "surface-page": "#ffffff", "text-primary": "#111827" },
"dark": { "surface-page": "#171717", "text-primary": "#fafafa" }
}
}Or flat single-theme JSON (treated as a single "default" theme):
{ "surface-page": "#ffffff", "text-primary": "#111827" }Structs§
- CssFallback
Chain - A CSS
var()fallback chain that needs theme or local CSS coverage. - Resolved
Tokens - Result of resolving tokens: per-theme CSS strings.
- Token
File - Loaded token themes — maps theme name → (token name → CSS value).
Enums§
- Token
Error - Errors that can occur during token loading, resolution, or CSS generation.
Functions§
- extract_
var_ references - Extract
var(--name)references from a CSS value string. - inject_
into_ state - Inject resolved token CSS into a JSON state value under
state.tokens. - inject_
token_ css - Inject pre-resolved per-theme CSS strings into a JSON state value.
- load_
token_ file - Load a multi-theme token file.
- parse_
token_ content - Parse token JSON content into a
TokenFile. - resolve_
theme_ path - Resolve a
--themevalue to a file path on disk. - resolve_
tokens - Resolve tokens for all themes against the protocol’s token candidate list.
- unthemed_
literal_ fallback_ tokens - CSS tokens used only with a literal
var()fallback and defined in no theme — likely typos. - validate_
chain_ tokens - Validate the tokens required by parser
var()fallback chains against a theme. - validate_
required_ tokens - Validate that every required token exists in every theme.
Type Aliases§
- Result
- Result type alias for token operations.