import { IRawThemeSetting } from 'vscode-textmate'; import { Deferred, Event, IDisposable, IThemeColor, MaybePromise, URI } from '@opensumi/ide-core-common'; import { Color } from './color'; import { IconContribution, IconDefinition } from './icon-registry'; export declare const ThemeServicePath = "themeServicePath"; export declare const DEFAULT_THEME_ID = "ide-dark"; export declare const DEFAULT_PRODUCT_ICON_THEME_ID = "opensumi-icons"; export declare const DEFAULT_PRODUCT_ICON_THEME_LABEL = "OpenSumi Icons"; export declare const PRODUCT_ICON_STYLE_ID = "product-icon-style"; export declare const PRODUCT_ICON_CODICON_STYLE_ID = "codiconStyles"; export declare const colorIdPattern = "^\\w+[.\\w+]*$"; export declare const IIconService: unique symbol; export declare const IThemeService: unique symbol; export declare const IProductIconService: unique symbol; export interface IIconTheme { hasFileIcons: boolean; hasFolderIcons: boolean; hidesExplorerArrows: boolean; styleSheetContent: string; load(location?: URI): Promise; } export interface IProductIconTheme { /** * Resolves the definition for the given icon as defined by the theme. * * @param iconContribution The icon */ readonly id: string; readonly label: string; readonly extensionData?: ExtensionData; readonly description?: string; readonly settingsId: string | null; styleSheetContent?: string; getIcon(iconContribution: IconContribution): IconDefinition | undefined; } export interface ExtensionData { extensionId: string; extensionPublisher: string; extensionName: string; extensionIsBuiltin: boolean; } export declare enum IconType { Mask = "mask", Background = "background", Base64 = "base64" } export declare enum IconShape { Circle = 0, Square = 1 } export interface IIconService { currentThemeId: string; currentTheme: IIconTheme; iconThemeLoaded: Deferred; onThemeChange: Event; /** * 应用主题(外部需要改主题请直接修改preference) * @param themeId 主题ID * */ applyTheme(themeId: string): Promise; /** * 将 Base64 路径进行转义,便于在 `background: url("${iconPath}")` 结构中使用 * @param iconPath Base64 路径 */ encodeBase64Path(iconPath: string): string; /** * 将 codicon 的 id 转换为 codicon 的 class * @param str codicon id eg. $(add), $(add~sync) */ fromString(str: string): string | undefined; /** * 将一个url地址或插件主题url转换为icon的class * @param basePath 路径前缀 * @param icon iconUrl地址,可以是直接的字符串,或者和主题类型有关的 object 字符串对象 * @param type 选择采用Mask或者Background的方式渲染icon资源, 默认值为IconType.Mask * @returns icon的className */ fromIcon(basePath: string, icon?: { [index in IconThemeType]: string; } | string, type?: IconType, shape?: IconShape, fromExtension?: boolean): string | undefined; registerIconThemes(iconThemesContribution: IThemeContribution[], extPath: URI): void; getAvailableThemeInfos(): IconThemeInfo[]; } export declare const IThemeData: unique symbol; export interface IThemeData extends IStandaloneThemeData { name: string; id: string; colorMap: IColorMap; themeSettings: IRawThemeSetting[]; settings: IRawThemeSetting[]; initializeFromData(data: any): void; initializeThemeData(id: any, name: any, base: any, themeLocation: URI): Promise; loadCustomTokens(customTokenColors: ITokenColorizationRule[]): unknown; } export declare const IThemeStore: unique symbol; export interface IThemeStore { getThemeData(contribution?: IThemeContribution, basePath?: URI): Promise; getDefaultThemeID(): string; } export interface IThemeService { currentThemeId: string; colorThemeLoaded: Deferred; onThemeChange: Event; registerThemes(themeContributions: IThemeContribution[], extPath: URI): IDisposable; ensureValidTheme(defaultThemeId?: string): Promise; /** * 应用主题(外部需要改主题请直接修改preference) * @param id 主题ID */ applyTheme(id: string): Promise; getAvailableThemeInfos(): ThemeInfo[]; getCurrentTheme(): Promise; getCurrentThemeSync(): ITheme; getColor(id: string | IThemeColor | undefined): string | undefined; getColorVar(id: string | IThemeColor | undefined): string | undefined; /** * 获取指定 color token 的 className */ getColorClassNameByColorToken(colorId: string | IThemeColor | undefined): string | undefined; registerColor(contribution: ExtColorContribution): void; } export interface IProductIconService { currentThemeId: string; currentTheme: IProductIconTheme; productIconThemeLoaded: Deferred; updateProductIconThemes(): MaybePromise; onDidProductIconThemeChange: Event; applyTheme(themeId: string): Promise; registerProductIconThemes(productIconThemesContribution: IThemeContribution[], extPath: URI): void; getAvailableThemeInfos(): IconThemeInfo[]; } export interface ITokenColorizationRule { name?: string; scope?: string | string[]; settings: ITokenColorizationSetting; } export interface ITokenColorizationSetting { foreground?: string; background?: string; fontStyle?: string; } export interface ISemanticTokenColorizationSetting { foreground?: string; fontStyle?: string; bold?: boolean; underline?: boolean; italic?: boolean; } export interface IColorMap { [id: string]: Color; } /** * Color scheme used by the OS and by color themes. */ export declare enum ColorScheme { DARK = "dark", LIGHT = "light", HIGH_CONTRAST_DARK = "hcDark", HIGH_CONTRAST_LIGHT = "hcLight" } export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black' | 'hc-light'; export declare function getThemeTypeName(base: BuiltinTheme): string; export declare enum BuiltinThemeComparator { 'vs' = 0, 'vs-dark' = 1, 'hc-black' = 2, 'hc-light' = 3 } export interface IStandaloneThemeData { base: BuiltinTheme; inherit: boolean; rules: ITokenThemeRule[]; encodedTokensColors?: string[]; colors: IColors; } export interface IColors { [colorId: string]: string; } export interface ITokenThemeRule { token: string; foreground?: string; background?: string; fontStyle?: string; } export interface ITokenColorCustomizations { [groupIdOrThemeSettingsId: string]: string | ITokenColorizationSetting | ITokenColorCustomizations | undefined | ITokenColorizationRule[]; comments?: string | ITokenColorizationSetting; strings?: string | ITokenColorizationSetting; numbers?: string | ITokenColorizationSetting; keywords?: string | ITokenColorizationSetting; types?: string | ITokenColorizationSetting; functions?: string | ITokenColorizationSetting; variables?: string | ITokenColorizationSetting; textMateRules?: ITokenColorizationRule[]; } export declare const VS_LIGHT_THEME_NAME = "vs"; export declare const VS_DARK_THEME_NAME = "vs-dark"; export declare const HC_BLACK_THEME_NAME = "hc-black"; export declare const HC_LIGHT_THEME_NAME = "hc-light"; export interface IThemeContribution { id?: string; label: string; description?: string; uiTheme?: BuiltinTheme; path: string; extensionId: string; } export declare const DARK: ThemeType; export declare const LIGHT: ThemeType; export declare const HIGH_CONTRAST_DARK: ThemeType; export declare const HIGH_CONTRAST_LIGHT: ThemeType; export type ThemeType = 'light' | 'dark' | 'hcDark' | 'hcLight'; export type IconThemeType = 'light' | 'dark'; export declare function getBuiltinRules(builtinTheme: BuiltinTheme): IStandaloneThemeData; export declare function getThemeTypeSelector(type: ThemeType): string; export declare function getThemeType(base: BuiltinTheme): ThemeType; export type ColorIdentifier = string; export interface ITheme { readonly type: ThemeType; readonly themeData: IThemeData; /** * Resolves the color of the given color identifier. If the theme does not * specify the color, the default color is returned unless useDefault is set to false. * @param color the id of the color * @param useDefault specifies if the default color should be used. If not set, the default is used. */ getColor(color: ColorIdentifier, useDefault?: boolean): Color | undefined; /** * Returns whether the theme defines a value for the color. If not, that means the * default color will be used. */ defines(color: ColorIdentifier): boolean; } export interface IColorCustomizations { [colorIdOrThemeSettingsId: string]: string | IColorCustomizations; } export interface ColorContribution { readonly id: ColorIdentifier; readonly description: string; readonly defaults: ColorDefaults | null; readonly needsTransparency: boolean; readonly deprecationMessage: string | undefined; } export interface ExtColorContribution { id: string; description: string; defaults: { light: string; dark: string; highContrast: string; highContrastLight?: string; }; } export type ColorFunction = (theme: ITheme) => Color | undefined; export interface ColorDefaults { light: ColorValue | null; dark: ColorValue | null; hcDark: ColorValue | null; hcLight: ColorValue | null; } /** * A Color Value is either a color literal, a reference to other color or a derived color */ export type ColorValue = Color | string | ColorIdentifier | ColorFunction; export interface ThemeInfo { name: string; base: BuiltinTheme; themeId: string; extensionId: string; inherit?: boolean; } export interface IconThemeInfo { name: string; themeId: string; extensionId: string; } export declare function themeColorFromId(id: ColorIdentifier): { id: string; }; export declare function getThemeId(contribution: IThemeContribution): string; //# sourceMappingURL=theme.service.d.ts.map