MCPcopy Create free account
hub / github.com/anus-dev/ANUS / loadCustomThemes

Method loadCustomThemes

packages/cli/src/ui/themes/theme-manager.ts:68–108  ·  view source on GitHub ↗

* Loads custom themes from settings. * @param customThemesSettings Custom themes from settings.

(customThemesSettings?: Record<string, CustomTheme>)

Source from the content-addressed store, hash-verified

66 * @param customThemesSettings Custom themes from settings.
67 */
68 loadCustomThemes(customThemesSettings?: Record<string, CustomTheme>): void {
69 this.customThemes.clear();
70
71 if (!customThemesSettings) {
72 return;
73 }
74
75 for (const [name, customThemeConfig] of Object.entries(
76 customThemesSettings,
77 )) {
78 const validation = validateCustomTheme(customThemeConfig);
79 if (validation.isValid) {
80 if (validation.warning) {
81 console.warn(`Theme "${name}": ${validation.warning}`);
82 }
83 const themeWithDefaults: CustomTheme = {
84 ...DEFAULT_THEME.colors,
85 ...customThemeConfig,
86 name: customThemeConfig.name || name,
87 type: 'custom',
88 };
89
90 try {
91 const theme = createCustomTheme(themeWithDefaults);
92 this.customThemes.set(name, theme);
93 } catch (error) {
94 console.warn(`Failed to load custom theme "${name}":`, error);
95 }
96 } else {
97 console.warn(`Invalid custom theme "${name}": ${validation.error}`);
98 }
99 }
100 // If the current active theme is a custom theme, keep it if still valid
101 if (
102 this.activeTheme &&
103 this.activeTheme.type === 'custom' &&
104 this.customThemes.has(this.activeTheme.name)
105 ) {
106 this.activeTheme = this.customThemes.get(this.activeTheme.name)!;
107 }
108 }
109
110 /**
111 * Sets the active theme.

Callers 4

mainFunction · 0.80
theme.test.tsFile · 0.80
useThemeCommandFunction · 0.80

Calls 5

validateCustomThemeFunction · 0.85
createCustomThemeFunction · 0.85
clearMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected