|
1 |
| -import { IColorTheme } from "mo/model/colorTheme"; |
2 |
| -import { IExtension, IExtensionType } from "mo/model/extension"; |
3 |
| - |
4 |
| -const colorThemesExtension: IExtension = require('./package.json'); |
5 |
| - |
6 |
| -function initColorTheme() { |
7 |
| - |
8 |
| - try { |
9 |
| - |
10 |
| - if (!colorThemesExtension || !colorThemesExtension.categories?.includes(IExtensionType.Theme)) { |
11 |
| - console.error('This is invalid colorTheme extension package!', colorThemesExtension); |
12 |
| - } |
13 |
| - |
14 |
| - const themes = colorThemesExtension.contributes?.themes?.map((theme: IColorTheme) => { |
15 |
| - if (theme.path) { |
16 |
| - const themeDetail = {}; // require(theme.path); |
17 |
| - return Object.assign({}, theme, themeDetail) |
18 |
| - } |
19 |
| - return theme; |
20 |
| - }); |
21 |
| - |
22 |
| - if (!colorThemesExtension.contributes) { |
23 |
| - colorThemesExtension.contributes = { themes: [] }; |
24 |
| - } |
25 |
| - |
26 |
| - colorThemesExtension.contributes.themes = themes; |
27 |
| - } catch (e) { |
28 |
| - throw new Error('Load color theme exception:' + e); |
29 |
| - } |
30 |
| -} |
31 |
| - |
32 |
| -initColorTheme(); |
33 |
| - |
34 |
| -export { |
35 |
| - colorThemesExtension |
36 |
| -} |
| 1 | +import { IColorTheme } from 'mo/model/colorTheme'; |
| 2 | +import { IExtension } from 'mo/model/extension'; |
| 3 | + |
| 4 | +const defaultColorThemeExtension: IExtension = require('./package.json'); |
| 5 | + |
| 6 | +// The below handle for theme extension is temporary, |
| 7 | +// we will automatic load the extension package. |
| 8 | + |
| 9 | +// Default |
| 10 | +const defaultDark: IColorTheme = require('./themes/dark_defaults.json'); |
| 11 | +const defaultLight: IColorTheme = require('./themes/light_defaults.json'); |
| 12 | +const defaultHC: IColorTheme = require('./themes/hc_black_defaults.json'); |
| 13 | + |
| 14 | +// Theme |
| 15 | +const darkPlus: IColorTheme = require('./themes/dark_plus.json'); |
| 16 | +Object.assign(darkPlus, defaultDark); |
| 17 | +const darkVS: IColorTheme = require('./themes/dark_vs.json'); |
| 18 | +Object.assign(darkVS, defaultDark); |
| 19 | + |
| 20 | +const lightPlus: IColorTheme = require('./themes/light_plus.json'); |
| 21 | +Object.assign(lightPlus, defaultLight); |
| 22 | +const lightVS: IColorTheme = require('./themes/light_vs.json'); |
| 23 | +Object.assign(lightVS, defaultLight); |
| 24 | + |
| 25 | +const hcBlack: IColorTheme = require('./themes/hc_black.json'); |
| 26 | +Object.assign(hcBlack, defaultHC); |
| 27 | + |
| 28 | +const themes = defaultColorThemeExtension.contributes?.themes || []; |
| 29 | + |
| 30 | +const themeDarkPlus = themes[0]; |
| 31 | +const themeLightPlus = themes[1]; |
| 32 | +const themeVSDark = themes[2]; |
| 33 | +const themeVSLight = themes[3]; |
| 34 | +const themeHCBlack = themes[4]; |
| 35 | + |
| 36 | +themes[0] = Object.assign({}, themeDarkPlus, darkPlus); |
| 37 | +themes[1] = Object.assign({}, themeLightPlus, lightPlus); |
| 38 | +themes[2] = Object.assign({}, themeVSDark, darkVS); |
| 39 | +themes[3] = Object.assign({}, themeVSLight, lightVS); |
| 40 | +themes[4] = Object.assign({}, themeHCBlack, hcBlack); |
| 41 | + |
| 42 | +export { defaultColorThemeExtension }; |
0 commit comments