import type { PartialTheme, Theme } from './types/Theme.types'; import type { ResolvedThemeAppearance, ThemeAppearanceOptions, ThemeAppearanceSource } from '../types/appearance.types'; import type { LegacyThemeSource, OnThemeChange } from '../theming/themeSource'; export type { OnThemeChange } from '../theming/themeSource'; /** * A function that takes in a parent theme, then returns a partial set of changes to be merged with the parent theme to update * it. */ export type ThemeTransform = (parent: TTheme, appearance?: ResolvedThemeAppearance) => TPartial; /** * A theme recipe is either a partial theme to merge on top of a base theme, or a function that returns the same kind of * partial to merge. These are recipes because they are cached as distinct steps so that they can be reapplied if the * base theme changes */ export type ThemeRecipe = TPartial | ThemeTransform; export interface ThemeReferenceOptions { base: TTheme | ThemeReference; recipes?: readonly ThemeRecipe[]; appearance?: ThemeAppearanceOptions; getAppearance?: () => ThemeAppearanceOptions | undefined; fallbackAppearance?: Partial; getFallbackAppearance?: () => Partial | undefined; appearanceSource?: ThemeAppearanceSource; alwaysSubscribeToAppearanceSource?: boolean; } /** * Provides a wrapper around a theme object, allowing the ability to create a theme from another theme, to listen to theme * changes, and to update the theme. * * This is the object that is designed to be handed to a theme provider, such that it can listen for changes and set the * value into context again. */ export declare class ThemeReference implements LegacyThemeSource { readonly kind = "legacy"; readonly appearanceSource?: ThemeAppearanceSource; private revisionValue; private themeData; private themeDataAppearanceKey; private readonly themesByAppearance; private recipes; private readonly listeners; private getParent; private getParentForAppearance; private parentRef; private parentListener?; private parentRevision?; private legacyAppearanceUnsubscribe?; private readonly getAppearanceOptions; private readonly getFallbackAppearance; private readonly alwaysSubscribeToAppearanceSource; /** * Create the theme reference, either as a plain wrapper, or a wrapper with additional transforms and/or merging * @param base - can be either another ThemeReference object, or a fully specified theme * @param recipes - any number of recipes to be applied on top of the theme object */ constructor(base: TTheme | ThemeReference | ThemeReferenceOptions, ...recipes: ThemeRecipe[]); get appearanceOptions(): ThemeAppearanceOptions | undefined; get fallbackAppearance(): Partial | undefined; get revision(): number; /** * get the internal theme object, which will be created on-demand */ get theme(): TTheme; /** * Resolve the legacy Theme for one concrete appearance. Repeated resolutions * share identity until this reference is invalidated. A missing tone means * cool; transforms always receive a concrete tone. */ resolveTheme(requestedAppearance: ResolvedThemeAppearance): TTheme; /** * register a new listener for theme changes */ addOnThemeChanged(listener: OnThemeChange): void; /** * remove a previously registered listener */ removeOnThemeChanged(listener: OnThemeChange): void; /** * invalidate the theme, causing it to be regenerated. This can happen via notifications from the parent, but * can also be called directly if a functional transform needs to be re-run */ invalidate(): void; /** * update the recipes (but not the base) in the theme. This will also implicitly invalidate the theme * since the recipes changed. */ update(...recipes: ThemeRecipe[]): void; private syncParentRevision; private subscribeLegacyAppearance; } //# sourceMappingURL=themeReference.d.ts.map