material-icon-theme 4.23.1 → 4.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/.eslintrc.json +51 -51
  2. package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +7 -0
  3. package/.github/workflows/build.yml +45 -45
  4. package/.github/workflows/color-check.yml +22 -22
  5. package/.github/workflows/release.yml +73 -73
  6. package/.vscodeignore +21 -21
  7. package/CHANGELOG.md +1325 -1292
  8. package/CONTRIBUTING.md +199 -29
  9. package/README.md +198 -199
  10. package/icons/bitbucket.svg +13 -1
  11. package/icons/bun.svg +2 -0
  12. package/icons/bun_light.svg +2 -0
  13. package/icons/craco.svg +45 -45
  14. package/icons/folder-changesets-open.svg +5 -5
  15. package/icons/folder-changesets.svg +2 -2
  16. package/icons/folder-decorators-open.svg +2 -2
  17. package/icons/folder-decorators.svg +5 -5
  18. package/icons/folder-gamemaker-open.svg +2 -0
  19. package/icons/folder-gamemaker.svg +2 -0
  20. package/icons/folder-supabase-open.svg +5 -5
  21. package/icons/folder-supabase.svg +2 -2
  22. package/icons/gamemaker.svg +4 -0
  23. package/icons/objective-c.svg +1 -0
  24. package/icons/objective-cpp.svg +1 -0
  25. package/icons/pascal.svg +6 -1
  26. package/icons/sonarcloud.svg +4 -4
  27. package/icons/stylable.svg +10 -10
  28. package/icons/supabase.svg +4 -4
  29. package/icons/tldraw.svg +4 -0
  30. package/icons/tldraw_light.svg +4 -0
  31. package/icons/vitest.svg +6 -6
  32. package/images/contributors.png +0 -0
  33. package/images/fileIcons.png +0 -0
  34. package/images/folderIcons.png +0 -0
  35. package/images/how-tos/folder-icon-parts.png +0 -0
  36. package/images/how-tos/pick-folder-colors.png +0 -0
  37. package/images/how-tos/pick-folder-colors.svg +301 -0
  38. package/images/how-tos/svg-folder-icon-with-correct-colors.png +0 -0
  39. package/images/how-tos/svg-folder-icon-with-wrong-colors.png +0 -0
  40. package/images/how-tos/svg-with-light-color.png +0 -0
  41. package/images/how-tos/svg-with-spacing.png +0 -0
  42. package/images/how-tos/svg-with-too-dark-color.png +0 -0
  43. package/images/how-tos/svg-with-wrong-color.png +0 -0
  44. package/images/how-tos/svg-without-spacing.png +0 -0
  45. package/package.json +252 -252
  46. package/package.nls.de.json +32 -32
  47. package/package.nls.es.json +29 -29
  48. package/package.nls.fr.json +29 -29
  49. package/package.nls.ja.json +32 -32
  50. package/package.nls.json +32 -32
  51. package/package.nls.nl.json +32 -32
  52. package/package.nls.pl.json +32 -32
  53. package/package.nls.pt-BR.json +29 -29
  54. package/package.nls.pt-PT.json +29 -29
  55. package/package.nls.ru.json +29 -29
  56. package/package.nls.zh-CN.json +29 -29
  57. package/package.nls.zh-TW.json +29 -29
  58. package/src/commands/activate.ts +28 -28
  59. package/src/commands/explorerArrows.ts +55 -55
  60. package/src/commands/folderColor.ts +96 -96
  61. package/src/commands/folders.ts +55 -55
  62. package/src/commands/grayscale.ts +55 -55
  63. package/src/commands/iconPacks.ts +64 -64
  64. package/src/commands/index.ts +30 -30
  65. package/src/commands/opacity.ts +46 -46
  66. package/src/commands/saturation.ts +46 -46
  67. package/src/extension.ts +37 -37
  68. package/src/helpers/customIcons.ts +8 -8
  69. package/src/helpers/index.ts +88 -88
  70. package/src/i18n/index.ts +78 -78
  71. package/src/i18n/lang-de.ts +43 -43
  72. package/src/i18n/lang-en.ts +43 -43
  73. package/src/i18n/lang-es.ts +43 -43
  74. package/src/i18n/lang-fr.ts +43 -43
  75. package/src/i18n/lang-ja.ts +43 -43
  76. package/src/i18n/lang-nl.ts +43 -43
  77. package/src/i18n/lang-pl.ts +43 -43
  78. package/src/i18n/lang-pt-br.ts +43 -43
  79. package/src/i18n/lang-pt-pt.ts +43 -43
  80. package/src/i18n/lang-ru.ts +43 -43
  81. package/src/i18n/lang-uk.ts +43 -43
  82. package/src/i18n/lang-zh-cn.ts +43 -43
  83. package/src/i18n/lang-zh-tw.ts +43 -43
  84. package/src/icons/fileIcons.ts +2240 -2197
  85. package/src/icons/folderIcons.ts +823 -806
  86. package/src/icons/generator/folderGenerator.ts +340 -340
  87. package/src/icons/generator/iconOpacity.ts +111 -111
  88. package/src/icons/generator/iconSaturation.ts +140 -140
  89. package/src/icons/generator/jsonGenerator.ts +191 -191
  90. package/src/icons/languageIcons.ts +144 -141
  91. package/src/models/i18n/translation.ts +41 -41
  92. package/src/models/iconConfiguration.ts +37 -37
  93. package/src/models/icons/iconJsonOptions.ts +21 -21
  94. package/src/models/index.ts +3 -3
  95. package/src/scripts/contributors/index.ts +138 -138
  96. package/src/scripts/helpers/screenshots.ts +32 -32
  97. package/src/scripts/icons/checks/checkIconAvailability.ts +215 -215
  98. package/src/scripts/icons/checks/checkIconConflicts.ts +152 -152
  99. package/src/scripts/icons/checks/checkIconUsage.ts +137 -137
  100. package/src/scripts/icons/checks/index.ts +7 -7
  101. package/src/scripts/preview/index.ts +40 -40
  102. package/src/scripts/preview/preview.ts +163 -163
  103. package/src/test/runTest.ts +26 -26
  104. package/src/test/spec/i18n/i18n.spec.ts +54 -54
  105. package/src/test/spec/icons/fileIcons.spec.ts +250 -250
  106. package/src/test/spec/icons/folderIcons.spec.ts +418 -418
  107. package/src/test/spec/icons/languageIcons.spec.ts +184 -184
  108. package/images/bloop.png +0 -0
@@ -1,64 +1,64 @@
1
- import { QuickPickItem, window as codeWindow } from 'vscode';
2
- import { getMaterialIconsJSON, setThemeConfig, toTitleCase } from '../helpers';
3
- import { translate } from '../i18n';
4
- import { IconPack } from '../models';
5
-
6
- /** Command to toggle the icons packs */
7
- export const toggleIconPacks = async () => {
8
- try {
9
- const activeIconPack = getActiveIconPack();
10
- const response = await showQuickPickItems(activeIconPack);
11
- if (response) {
12
- handleQuickPickActions(response);
13
- }
14
- } catch (error) {
15
- console.error(error);
16
- }
17
- };
18
-
19
- /** Show QuickPick items to select preferred configuration for the icon packs. */
20
- const showQuickPickItems = (activePack: string) => {
21
- const packs = [...getAllIconPacks().sort(), 'none'];
22
- const options = packs.map((pack): QuickPickItem => {
23
- const packLabel = toTitleCase(pack.replace('_', ' + '));
24
- const active = isPackActive(activePack, pack);
25
- const iconPacksDeactivated = pack === 'none' && activePack === '';
26
-
27
- return {
28
- description: packLabel,
29
- detail: translate(
30
- `iconPacks.${pack === 'none' ? 'disabled' : 'description'}`,
31
- packLabel
32
- ),
33
- label: iconPacksDeactivated ? '\u2714' : active ? '\u2714' : '\u25FB',
34
- };
35
- });
36
-
37
- return codeWindow.showQuickPick(options, {
38
- placeHolder: translate('iconPacks.selectPack'),
39
- ignoreFocusOut: false,
40
- matchOnDescription: true,
41
- matchOnDetail: true,
42
- });
43
- };
44
-
45
- /** Handle the actions from the QuickPick. */
46
- const handleQuickPickActions = (value: QuickPickItem) => {
47
- if (!value || !value.description) return;
48
- const decision = value.description.replace(' + ', '_').toLowerCase();
49
-
50
- setThemeConfig('activeIconPack', decision === 'none' ? '' : decision, true);
51
- };
52
-
53
- const getActiveIconPack = (): string => {
54
- return getMaterialIconsJSON()?.options?.activeIconPack ?? '';
55
- };
56
-
57
- /** Get all packs that can be used in this icon theme. */
58
- export const getAllIconPacks = (): string[] => {
59
- return Object.values(IconPack).map((p) => p.toLowerCase());
60
- };
61
-
62
- const isPackActive = (activePack: string, pack: string) => {
63
- return activePack.toLowerCase() === pack.toLowerCase();
64
- };
1
+ import { QuickPickItem, window as codeWindow } from 'vscode';
2
+ import { getMaterialIconsJSON, setThemeConfig, toTitleCase } from '../helpers';
3
+ import { translate } from '../i18n';
4
+ import { IconPack } from '../models';
5
+
6
+ /** Command to toggle the icons packs */
7
+ export const toggleIconPacks = async () => {
8
+ try {
9
+ const activeIconPack = getActiveIconPack();
10
+ const response = await showQuickPickItems(activeIconPack);
11
+ if (response) {
12
+ handleQuickPickActions(response);
13
+ }
14
+ } catch (error) {
15
+ console.error(error);
16
+ }
17
+ };
18
+
19
+ /** Show QuickPick items to select preferred configuration for the icon packs. */
20
+ const showQuickPickItems = (activePack: string) => {
21
+ const packs = [...getAllIconPacks().sort(), 'none'];
22
+ const options = packs.map((pack): QuickPickItem => {
23
+ const packLabel = toTitleCase(pack.replace('_', ' + '));
24
+ const active = isPackActive(activePack, pack);
25
+ const iconPacksDeactivated = pack === 'none' && activePack === '';
26
+
27
+ return {
28
+ description: packLabel,
29
+ detail: translate(
30
+ `iconPacks.${pack === 'none' ? 'disabled' : 'description'}`,
31
+ packLabel
32
+ ),
33
+ label: iconPacksDeactivated ? '\u2714' : active ? '\u2714' : '\u25FB',
34
+ };
35
+ });
36
+
37
+ return codeWindow.showQuickPick(options, {
38
+ placeHolder: translate('iconPacks.selectPack'),
39
+ ignoreFocusOut: false,
40
+ matchOnDescription: true,
41
+ matchOnDetail: true,
42
+ });
43
+ };
44
+
45
+ /** Handle the actions from the QuickPick. */
46
+ const handleQuickPickActions = (value: QuickPickItem) => {
47
+ if (!value || !value.description) return;
48
+ const decision = value.description.replace(' + ', '_').toLowerCase();
49
+
50
+ setThemeConfig('activeIconPack', decision === 'none' ? '' : decision, true);
51
+ };
52
+
53
+ const getActiveIconPack = (): string => {
54
+ return getMaterialIconsJSON()?.options?.activeIconPack ?? '';
55
+ };
56
+
57
+ /** Get all packs that can be used in this icon theme. */
58
+ export const getAllIconPacks = (): string[] => {
59
+ return Object.values(IconPack).map((p) => p.toLowerCase());
60
+ };
61
+
62
+ const isPackActive = (activePack: string, pack: string) => {
63
+ return activePack.toLowerCase() === pack.toLowerCase();
64
+ };
@@ -1,30 +1,30 @@
1
- import { commands } from 'vscode';
2
- import { activateIcons } from './activate';
3
- import { toggleExplorerArrows } from './explorerArrows';
4
- import { changeFolderColor } from './folderColor';
5
- import { changeFolderTheme } from './folders';
6
- import { toggleGrayscale } from './grayscale';
7
- import { toggleIconPacks } from './iconPacks';
8
- import { changeOpacity } from './opacity';
9
- import { restoreDefaultConfig } from './restoreConfig';
10
- import { changeSaturation } from './saturation';
11
-
12
- const extensionCommands: { [commmand: string]: () => Promise<void> } = {
13
- activateIcons,
14
- toggleIconPacks,
15
- changeFolderTheme,
16
- changeFolderColor,
17
- restoreDefaultConfig,
18
- toggleExplorerArrows,
19
- changeOpacity,
20
- toggleGrayscale,
21
- changeSaturation,
22
- };
23
-
24
- export const registered = Object.keys(extensionCommands).map((commandName) => {
25
- const callCommand = () => extensionCommands[commandName]();
26
- return commands.registerCommand(
27
- `material-icon-theme.${commandName}`,
28
- callCommand
29
- );
30
- });
1
+ import { commands } from 'vscode';
2
+ import { activateIcons } from './activate';
3
+ import { toggleExplorerArrows } from './explorerArrows';
4
+ import { changeFolderColor } from './folderColor';
5
+ import { changeFolderTheme } from './folders';
6
+ import { toggleGrayscale } from './grayscale';
7
+ import { toggleIconPacks } from './iconPacks';
8
+ import { changeOpacity } from './opacity';
9
+ import { restoreDefaultConfig } from './restoreConfig';
10
+ import { changeSaturation } from './saturation';
11
+
12
+ const extensionCommands: { [commmand: string]: () => Promise<void> } = {
13
+ activateIcons,
14
+ toggleIconPacks,
15
+ changeFolderTheme,
16
+ changeFolderColor,
17
+ restoreDefaultConfig,
18
+ toggleExplorerArrows,
19
+ changeOpacity,
20
+ toggleGrayscale,
21
+ changeSaturation,
22
+ };
23
+
24
+ export const registered = Object.keys(extensionCommands).map((commandName) => {
25
+ const callCommand = () => extensionCommands[commandName]();
26
+ return commands.registerCommand(
27
+ `material-icon-theme.${commandName}`,
28
+ callCommand
29
+ );
30
+ });
@@ -1,46 +1,46 @@
1
- import { window as codeWindow } from 'vscode';
2
- import { getMaterialIconsJSON, setThemeConfig } from '../helpers';
3
- import { translate } from '../i18n';
4
- import { getDefaultIconOptions, validateOpacityValue } from '../icons';
5
-
6
- /** Command to toggle the folder icons. */
7
- export const changeOpacity = async () => {
8
- try {
9
- const currentOpacityValue = getCurrentOpacityValue();
10
- const response = await showInput(currentOpacityValue);
11
- if (response) {
12
- await setOpacityConfig(+response);
13
- }
14
- } catch (error) {
15
- console.error(error);
16
- }
17
- };
18
-
19
- /** Show input to enter the opacity value. */
20
- const showInput = (opacity: number) => {
21
- return codeWindow.showInputBox({
22
- placeHolder: translate('opacity.inputPlaceholder'),
23
- ignoreFocusOut: true,
24
- value: opacity.toString(),
25
- validateInput: validateOpacityInput,
26
- });
27
- };
28
-
29
- /** Validate the opacity value which was inserted by the user. */
30
- const validateOpacityInput = (opacityInput: string) => {
31
- if (!validateOpacityValue(+opacityInput)) {
32
- return translate('opacity.wrongValue');
33
- }
34
- return undefined;
35
- };
36
-
37
- /** Get the current value of the opacity of the icons. */
38
- export const getCurrentOpacityValue = (): number => {
39
- const defaultOptions = getDefaultIconOptions();
40
- const config = getMaterialIconsJSON();
41
- return config?.options?.opacity ?? defaultOptions.opacity;
42
- };
43
-
44
- const setOpacityConfig = (opacity: number) => {
45
- return setThemeConfig('opacity', opacity, true);
46
- };
1
+ import { window as codeWindow } from 'vscode';
2
+ import { getMaterialIconsJSON, setThemeConfig } from '../helpers';
3
+ import { translate } from '../i18n';
4
+ import { getDefaultIconOptions, validateOpacityValue } from '../icons';
5
+
6
+ /** Command to toggle the folder icons. */
7
+ export const changeOpacity = async () => {
8
+ try {
9
+ const currentOpacityValue = getCurrentOpacityValue();
10
+ const response = await showInput(currentOpacityValue);
11
+ if (response) {
12
+ await setOpacityConfig(+response);
13
+ }
14
+ } catch (error) {
15
+ console.error(error);
16
+ }
17
+ };
18
+
19
+ /** Show input to enter the opacity value. */
20
+ const showInput = (opacity: number) => {
21
+ return codeWindow.showInputBox({
22
+ placeHolder: translate('opacity.inputPlaceholder'),
23
+ ignoreFocusOut: true,
24
+ value: opacity.toString(),
25
+ validateInput: validateOpacityInput,
26
+ });
27
+ };
28
+
29
+ /** Validate the opacity value which was inserted by the user. */
30
+ const validateOpacityInput = (opacityInput: string) => {
31
+ if (!validateOpacityValue(+opacityInput)) {
32
+ return translate('opacity.wrongValue');
33
+ }
34
+ return undefined;
35
+ };
36
+
37
+ /** Get the current value of the opacity of the icons. */
38
+ export const getCurrentOpacityValue = (): number => {
39
+ const defaultOptions = getDefaultIconOptions();
40
+ const config = getMaterialIconsJSON();
41
+ return config?.options?.opacity ?? defaultOptions.opacity;
42
+ };
43
+
44
+ const setOpacityConfig = (opacity: number) => {
45
+ return setThemeConfig('opacity', opacity, true);
46
+ };
@@ -1,46 +1,46 @@
1
- import { window as codeWindow } from 'vscode';
2
- import { getMaterialIconsJSON, setThemeConfig } from '../helpers';
3
- import { translate } from '../i18n';
4
- import { getDefaultIconOptions, validateSaturationValue } from '../icons';
5
-
6
- /** Command to toggle the folder icons. */
7
- export const changeSaturation = async () => {
8
- try {
9
- const currentSaturationValue = getCurrentSaturationValue();
10
- const response = await showInput(currentSaturationValue);
11
- if (response) {
12
- await setSaturationConfig(+response);
13
- }
14
- } catch (error) {
15
- console.error(error);
16
- }
17
- };
18
-
19
- /** Show input to enter the saturation value. */
20
- const showInput = (saturation: number) => {
21
- return codeWindow.showInputBox({
22
- placeHolder: translate('saturation.inputPlaceholder'),
23
- ignoreFocusOut: true,
24
- value: saturation.toString(),
25
- validateInput: validateSaturationInput,
26
- });
27
- };
28
-
29
- /** Validate the saturation value which was inserted by the user. */
30
- const validateSaturationInput = (saturationInput: string) => {
31
- if (!validateSaturationValue(+saturationInput)) {
32
- return translate('saturation.wrongValue');
33
- }
34
- return undefined;
35
- };
36
-
37
- /** Get the current value of the saturation of the icons. */
38
- export const getCurrentSaturationValue = (): number => {
39
- const defaultOptions = getDefaultIconOptions();
40
- const config = getMaterialIconsJSON();
41
- return config?.options?.saturation ?? defaultOptions.saturation;
42
- };
43
-
44
- const setSaturationConfig = (saturation: number) => {
45
- return setThemeConfig('saturation', saturation, true);
46
- };
1
+ import { window as codeWindow } from 'vscode';
2
+ import { getMaterialIconsJSON, setThemeConfig } from '../helpers';
3
+ import { translate } from '../i18n';
4
+ import { getDefaultIconOptions, validateSaturationValue } from '../icons';
5
+
6
+ /** Command to toggle the folder icons. */
7
+ export const changeSaturation = async () => {
8
+ try {
9
+ const currentSaturationValue = getCurrentSaturationValue();
10
+ const response = await showInput(currentSaturationValue);
11
+ if (response) {
12
+ await setSaturationConfig(+response);
13
+ }
14
+ } catch (error) {
15
+ console.error(error);
16
+ }
17
+ };
18
+
19
+ /** Show input to enter the saturation value. */
20
+ const showInput = (saturation: number) => {
21
+ return codeWindow.showInputBox({
22
+ placeHolder: translate('saturation.inputPlaceholder'),
23
+ ignoreFocusOut: true,
24
+ value: saturation.toString(),
25
+ validateInput: validateSaturationInput,
26
+ });
27
+ };
28
+
29
+ /** Validate the saturation value which was inserted by the user. */
30
+ const validateSaturationInput = (saturationInput: string) => {
31
+ if (!validateSaturationValue(+saturationInput)) {
32
+ return translate('saturation.wrongValue');
33
+ }
34
+ return undefined;
35
+ };
36
+
37
+ /** Get the current value of the saturation of the icons. */
38
+ export const getCurrentSaturationValue = (): number => {
39
+ const defaultOptions = getDefaultIconOptions();
40
+ const config = getMaterialIconsJSON();
41
+ return config?.options?.saturation ?? defaultOptions.saturation;
42
+ };
43
+
44
+ const setSaturationConfig = (saturation: number) => {
45
+ return setThemeConfig('saturation', saturation, true);
46
+ };
package/src/extension.ts CHANGED
@@ -1,37 +1,37 @@
1
- 'use strict';
2
-
3
- import { ExtensionContext, window as codeWindow, workspace } from 'vscode';
4
- import { registered } from './commands';
5
- import { detectConfigChanges } from './helpers/changeDetection';
6
- import { initTranslations } from './i18n';
7
-
8
- /**
9
- * This method is called when the extension is activated.
10
- * It initializes the core functionality of the extension.
11
- */
12
- export const activate = async (context: ExtensionContext) => {
13
- try {
14
- await initTranslations();
15
-
16
- // Subscribe to the extension commands
17
- context.subscriptions.push(...registered);
18
-
19
- // Initially trigger the config change detection
20
- detectConfigChanges();
21
-
22
- // Observe changes in the config
23
- workspace.onDidChangeConfiguration(detectConfigChanges);
24
-
25
- // Observe if the window got focused to trigger config changes
26
- codeWindow.onDidChangeWindowState((state) => {
27
- if (state.focused) {
28
- detectConfigChanges();
29
- }
30
- });
31
- } catch (error) {
32
- console.error(error);
33
- }
34
- };
35
-
36
- /** This method is called when the extension is deactivated */
37
- export const deactivate = () => {};
1
+ 'use strict';
2
+
3
+ import { ExtensionContext, window as codeWindow, workspace } from 'vscode';
4
+ import { registered } from './commands';
5
+ import { detectConfigChanges } from './helpers/changeDetection';
6
+ import { initTranslations } from './i18n';
7
+
8
+ /**
9
+ * This method is called when the extension is activated.
10
+ * It initializes the core functionality of the extension.
11
+ */
12
+ export const activate = async (context: ExtensionContext) => {
13
+ try {
14
+ await initTranslations();
15
+
16
+ // Subscribe to the extension commands
17
+ context.subscriptions.push(...registered);
18
+
19
+ // Initially trigger the config change detection
20
+ detectConfigChanges();
21
+
22
+ // Observe changes in the config
23
+ workspace.onDidChangeConfiguration(detectConfigChanges);
24
+
25
+ // Observe if the window got focused to trigger config changes
26
+ codeWindow.onDidChangeWindowState((state) => {
27
+ if (state.focused) {
28
+ detectConfigChanges();
29
+ }
30
+ });
31
+ } catch (error) {
32
+ console.error(error);
33
+ }
34
+ };
35
+
36
+ /** This method is called when the extension is deactivated */
37
+ export const deactivate = () => {};
@@ -1,8 +1,8 @@
1
- import { dirname, join } from 'path';
2
- import { IconJsonOptions } from '../models';
3
-
4
- export const getCustomIconPaths = (options: IconJsonOptions) => {
5
- return Object.values(options?.files?.associations ?? {})
6
- .filter((v) => v.match(/^[.\/]+/)) // <- custom dirs have a relative path to the dist folder
7
- .map((v) => dirname(join(__dirname, v)));
8
- };
1
+ import { dirname, join } from 'path';
2
+ import { IconJsonOptions } from '../models';
3
+
4
+ export const getCustomIconPaths = (options: IconJsonOptions) => {
5
+ return Object.values(options?.files?.associations ?? {})
6
+ .filter((v) => v.match(/^[.\/]+/)) // <- custom dirs have a relative path to the dist folder
7
+ .map((v) => dirname(join(__dirname, v)));
8
+ };
@@ -1,88 +1,88 @@
1
- import { readFileSync } from 'fs';
2
- import { join } from 'path';
3
- import { extensions, workspace } from 'vscode';
4
- import { iconJsonName } from '../icons/index';
5
- import { IconConfiguration } from '../models/index';
6
-
7
- /** Get configuration of vs code. */
8
- export const getConfig = (section?: string) => {
9
- return workspace.getConfiguration(section);
10
- };
11
-
12
- /** Get list of configuration entries of package.json */
13
- export const getConfigProperties = (): { [config: string]: unknown } => {
14
- return extensions.getExtension('PKief.material-icon-theme')?.packageJSON
15
- ?.contributes?.configuration?.properties;
16
- };
17
-
18
- /** Update configuration of vs code. */
19
- export const setConfig = (
20
- section: string,
21
- value: any,
22
- global: boolean = false
23
- ) => {
24
- return getConfig().update(section, value, global);
25
- };
26
-
27
- export const getThemeConfig = (section: string) => {
28
- return getConfig('material-icon-theme').inspect(section);
29
- };
30
-
31
- /** Set the config of the theme. */
32
- export const setThemeConfig = (
33
- section: string,
34
- value: any,
35
- global: boolean = false
36
- ) => {
37
- return getConfig('material-icon-theme').update(section, value, global);
38
- };
39
-
40
- /**
41
- * Checks if the theme is the active icon theme
42
- * @param{boolean} global false by default
43
- */
44
- export const isThemeActivated = (global: boolean = false): boolean => {
45
- return global
46
- ? getConfig().inspect('workbench.iconTheme')?.globalValue ===
47
- 'material-icon-theme'
48
- : getConfig().inspect('workbench.iconTheme')?.workspaceValue ===
49
- 'material-icon-theme';
50
- };
51
-
52
- /** Checks if the theme is not the active icon theme */
53
- export const isThemeNotVisible = (): boolean => {
54
- const config = getConfig().inspect('workbench.iconTheme');
55
- return (
56
- (!isThemeActivated(true) && !config?.workspaceValue) || // no workspace and not global
57
- (!isThemeActivated() && !!config?.workspaceValue)
58
- );
59
- };
60
-
61
- /** Return the path of the extension in the file system. */
62
- const getExtensionPath = () =>
63
- extensions.getExtension('PKief.material-icon-theme')?.extensionPath ?? '';
64
-
65
- /** Get the configuration of the icons as JSON Object */
66
- export const getMaterialIconsJSON = (): IconConfiguration => {
67
- const iconJSONPath = join(getExtensionPath(), 'dist', iconJsonName);
68
-
69
- try {
70
- const data = readFileSync(iconJSONPath, 'utf8');
71
- return JSON.parse(data);
72
- } catch (error) {
73
- console.error(error);
74
- return {};
75
- }
76
- };
77
-
78
- /** Capitalize the first letter of a string */
79
- export const capitalizeFirstLetter = (name: string): string =>
80
- name.charAt(0).toUpperCase() + name.slice(1);
81
-
82
- /** TitleCase all words in a string */
83
- export const toTitleCase = (value: string) => {
84
- return value.replace(
85
- /\w\S*/g,
86
- (text) => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase()
87
- );
88
- };
1
+ import { readFileSync } from 'fs';
2
+ import { join } from 'path';
3
+ import { extensions, workspace } from 'vscode';
4
+ import { iconJsonName } from '../icons/index';
5
+ import { IconConfiguration } from '../models/index';
6
+
7
+ /** Get configuration of vs code. */
8
+ export const getConfig = (section?: string) => {
9
+ return workspace.getConfiguration(section);
10
+ };
11
+
12
+ /** Get list of configuration entries of package.json */
13
+ export const getConfigProperties = (): { [config: string]: unknown } => {
14
+ return extensions.getExtension('PKief.material-icon-theme')?.packageJSON
15
+ ?.contributes?.configuration?.properties;
16
+ };
17
+
18
+ /** Update configuration of vs code. */
19
+ export const setConfig = (
20
+ section: string,
21
+ value: any,
22
+ global: boolean = false
23
+ ) => {
24
+ return getConfig().update(section, value, global);
25
+ };
26
+
27
+ export const getThemeConfig = (section: string) => {
28
+ return getConfig('material-icon-theme').inspect(section);
29
+ };
30
+
31
+ /** Set the config of the theme. */
32
+ export const setThemeConfig = (
33
+ section: string,
34
+ value: any,
35
+ global: boolean = false
36
+ ) => {
37
+ return getConfig('material-icon-theme').update(section, value, global);
38
+ };
39
+
40
+ /**
41
+ * Checks if the theme is the active icon theme
42
+ * @param{boolean} global false by default
43
+ */
44
+ export const isThemeActivated = (global: boolean = false): boolean => {
45
+ return global
46
+ ? getConfig().inspect('workbench.iconTheme')?.globalValue ===
47
+ 'material-icon-theme'
48
+ : getConfig().inspect('workbench.iconTheme')?.workspaceValue ===
49
+ 'material-icon-theme';
50
+ };
51
+
52
+ /** Checks if the theme is not the active icon theme */
53
+ export const isThemeNotVisible = (): boolean => {
54
+ const config = getConfig().inspect('workbench.iconTheme');
55
+ return (
56
+ (!isThemeActivated(true) && !config?.workspaceValue) || // no workspace and not global
57
+ (!isThemeActivated() && !!config?.workspaceValue)
58
+ );
59
+ };
60
+
61
+ /** Return the path of the extension in the file system. */
62
+ const getExtensionPath = () =>
63
+ extensions.getExtension('PKief.material-icon-theme')?.extensionPath ?? '';
64
+
65
+ /** Get the configuration of the icons as JSON Object */
66
+ export const getMaterialIconsJSON = (): IconConfiguration => {
67
+ const iconJSONPath = join(getExtensionPath(), 'dist', iconJsonName);
68
+
69
+ try {
70
+ const data = readFileSync(iconJSONPath, 'utf8');
71
+ return JSON.parse(data);
72
+ } catch (error) {
73
+ console.error(error);
74
+ return {};
75
+ }
76
+ };
77
+
78
+ /** Capitalize the first letter of a string */
79
+ export const capitalizeFirstLetter = (name: string): string =>
80
+ name.charAt(0).toUpperCase() + name.slice(1);
81
+
82
+ /** TitleCase all words in a string */
83
+ export const toTitleCase = (value: string) => {
84
+ return value.replace(
85
+ /\w\S*/g,
86
+ (text) => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase()
87
+ );
88
+ };