import { UserConfig } from '@unocss/core'; import { CssAdapter } from 'domeleon'; type ShortcutDef> = { prefix?: string; def: T; }; type StickyMode = "always" | "explicit"; interface UnoCssAdapterOptions { /** Unique identifier; also used for style-element IDs */ id: string; /** Configuration passed verbatim to UnoCSS */ unoCssConfig?: UserConfig; /** Sticky-class generation mode (default: "always"). */ stickyMode?: StickyMode; /** When true, generated selectors will be wrapped with `#${id}` to isolate them from the rest of the page. Defaults to false. */ isolateSelectors?: boolean; } declare class UnoCssAdapter implements CssAdapter { private _id; private _generatorPromise; private _styleEl?; private _stickyClasses; private _stickyMode; private _shortcuts; private _isolateSelectors; constructor(options: UnoCssAdapterOptions); /** Sticky-class generation mode. */ get stickyMode(): StickyMode; generate(classes: Set, stickyClasses: Set): Promise; clearStickyClasses(): void; shortcut>(spec: ShortcutDef): { [K in keyof T]: string; }; } /** * A leaf theme value: a CSS-ready string. Numbers are disallowed to * avoid unit-omission bugs; numeric quantities must be converted to * strings with appropriate units by the theme author. */ type UnoCssValue = string; /** * Recursively defines a set of CSS values: nested property groups. * Example: * { * colors: { * primary: "#ff0000", * shades: { * light: "#ffcccc", * dark: "#cc0000" * } * }, * spacing: { * small: "4px", * medium: "8px" * } * } */ interface UnoCssSet { [key: string]: UnoCssValue | UnoCssSet; } /** * A complete theme: maps top‑level groups (e.g., "colors", "spacing") * to their nested CSS sets. */ type Theme = Record; /** * Maps theme names (e.g., "light", "dark") to their definitions. */ type ThemeSet = Record; /** * Generic CSS variable managed by the theme system. * Holds semantic name, original value, and CSS custom property name. */ declare class CssVar { /** The unocss name, e.g.: `textPrimary` */ readonly name: string; /** Returns the raw value defined in a specific theme, e.g.: `rgb(0, 187, 0)` */ readonly rawValue: string; /** REturns the css variables name, e.g.: `--app-colors-text-primary` */ readonly cssVarName: string; constructor( /** The unocss name, e.g.: `textPrimary` */ name: string, /** Returns the raw value defined in a specific theme, e.g.: `rgb(0, 187, 0)` */ rawValue: string, /** REturns the css variables name, e.g.: `--app-colors-text-primary` */ cssVarName: string); /** Returns the name, e.g. `textPrimary` */ toString(): string; /*** Returns the var, wrapped in rgb when a color, e.g.: `rgb(var(--app-colors-text-primary))` */ get css(): string; /** Returns a formatted value, raw value, e.g.: `0 187 0` */ format(): string; /** * Applies a CssVar with an alpha value from 0 to 1 to a color. * * Useful when themes diverge in transparency values. * ``` * `bg-${backgroundPrimary.alpha(panelAlpha)}` * ``` * To hard code a transparency value, simply use standard unocss syntax: * ``` * `bg-${backgroundPrimary}/50` * ``` */ alpha(alpha: CssVar): string; } /** * Recursively mirrors a theme or CSS set, replacing each leaf value * with a CssVar, and preserving nested structure. */ type ThemeProxy = { [K in keyof T]: T[K] extends UnoCssValue ? CssVar : T[K] extends Record ? ThemeProxy : never; }; interface UnoThemeManagerOptions { id: string; themes: ThemeSet; initialTheme?: keyof ThemeSet; unoCssConfig?: UserConfig; globalUnoCss?: (theme: ThemeProxy) => Record; globalRawCss?: (theme: ThemeProxy) => string; /** * When true, all theme output is isolated to the element with `id` (CSS variables * live on `#id` and generated selectors are wrapped with `#id`). * When false (default), variables go to `:root` and selectors are global. */ isolate?: boolean; } declare class UnoThemeManager { readonly unoCssAdapter: UnoCssAdapter; private _theme; private _unoStyleEl; private _rawCssStyleEl; private _globalRawCss?; private _themeName; private _id; private _themes; private _host; private _isolate; constructor(options: UnoThemeManagerOptions); get theme(): ThemeProxy; /** Current root selector. Either `#${id}` when scoped, or `:root` when global. */ get rootSelector(): string; set themeName(name: string); get themeName(): string; private getInitialTheme; private createHostElement; private buildProxyTheme; private buildUnoTheme; private proxyLeaf; private unoLeaf; private cssVar; private cssVars; private renderUnoCss; private renderRawCss; private ensureSheet; /** * Creates a set of css styles, optionally prefixed. Internally translates * to `unoCssAdapter.shortcut`. * * Example: * ```ts * const styles = themeMgr.styles("todo", theme => ({ * item: `text-${theme.colors.textPrimary}`, * done: `text-${theme.colors.textSecondary} line-through`, * })) * ``` */ styles>(prefixOrFactory: string | ((theme: ThemeProxy) => Defs), factory?: (theme: ThemeProxy) => Defs): { [K in keyof Defs]: string; }; } declare class ColorVar extends CssVar { constructor(name: string, rawColorString: string, cssVarName: string); get css(): string; alpha(alpha: CssVar): string; format(): string; } export { ColorVar, CssVar, UnoCssAdapter, UnoThemeManager }; export type { StickyMode, Theme, ThemeProxy, ThemeSet, UnoCssSet, UnoCssValue, UnoThemeManagerOptions };