@opensumi/ide-theme 2.21.13 → 2.22.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.
- package/lib/browser/icon-theme-data.js.map +1 -1
- package/lib/browser/icon-theme-store.js.map +1 -1
- package/lib/browser/icon.service.d.ts +3 -1
- package/lib/browser/icon.service.d.ts.map +1 -1
- package/lib/browser/icon.service.js +56 -24
- package/lib/browser/icon.service.js.map +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/semantic-tokens-registry.js.map +1 -1
- package/lib/browser/style.service.js.map +1 -1
- package/lib/browser/theme-data.js +7 -7
- package/lib/browser/theme-data.js.map +1 -1
- package/lib/browser/theme-store.js.map +1 -1
- package/lib/browser/theme.contribution.js +3 -3
- package/lib/browser/theme.contribution.js.map +1 -1
- package/lib/browser/workbench.theme.service.js +2 -2
- package/lib/browser/workbench.theme.service.js.map +1 -1
- package/lib/common/color-tokens/basic-color.d.ts +1 -1
- package/lib/common/color-tokens/basic-color.d.ts.map +1 -1
- package/lib/common/color-tokens/editor.d.ts +13 -0
- package/lib/common/color-tokens/editor.d.ts.map +1 -1
- package/lib/common/color-tokens/editor.js +35 -1
- package/lib/common/color-tokens/editor.js.map +1 -1
- package/lib/common/color.js +40 -40
- package/lib/common/color.js.map +1 -1
- package/lib/common/mocks/theme.service.js.map +1 -1
- package/lib/common/plistParser.js +40 -40
- package/lib/common/plistParser.js.map +1 -1
- package/lib/common/semantic-tokens-registry.d.ts +7 -7
- package/lib/common/semantic-tokens-registry.d.ts.map +1 -1
- package/lib/common/theme.service.d.ts +26 -6
- package/lib/common/theme.service.d.ts.map +1 -1
- package/lib/common/theme.service.js.map +1 -1
- package/package.json +11 -10
- package/src/browser/default-theme.ts +547 -0
- package/src/browser/icon-theme-data.ts +294 -0
- package/src/browser/icon-theme-store.ts +38 -0
- package/src/browser/icon.less +15 -0
- package/src/browser/icon.service.ts +457 -0
- package/src/browser/index.ts +45 -0
- package/src/browser/semantic-tokens-registry.ts +217 -0
- package/src/browser/style.service.ts +51 -0
- package/src/browser/theme-data.ts +719 -0
- package/src/browser/theme-store.ts +95 -0
- package/src/browser/theme.contribution.ts +343 -0
- package/src/browser/workbench.theme.service.ts +703 -0
- package/src/common/color-registry.ts +52 -0
- package/src/common/color-tokens/activity-bar.ts +122 -0
- package/src/common/color-tokens/badge.ts +31 -0
- package/src/common/color-tokens/base.ts +90 -0
- package/src/common/color-tokens/basic-color.ts +9 -0
- package/src/common/color-tokens/breadcrumb.ts +60 -0
- package/src/common/color-tokens/button.ts +69 -0
- package/src/common/color-tokens/charts.ts +68 -0
- package/src/common/color-tokens/checkbox.ts +23 -0
- package/src/common/color-tokens/custom/actionbar.ts +51 -0
- package/src/common/color-tokens/custom/activity-bar.ts +16 -0
- package/src/common/color-tokens/custom/badge.ts +30 -0
- package/src/common/color-tokens/custom/base.ts +111 -0
- package/src/common/color-tokens/custom/button.ts +359 -0
- package/src/common/color-tokens/custom/checkbox.ts +36 -0
- package/src/common/color-tokens/custom/decoration.ts +71 -0
- package/src/common/color-tokens/custom/editor.ts +27 -0
- package/src/common/color-tokens/custom/extension.ts +9 -0
- package/src/common/color-tokens/custom/icon.ts +30 -0
- package/src/common/color-tokens/custom/index.ts +26 -0
- package/src/common/color-tokens/custom/input.ts +48 -0
- package/src/common/color-tokens/custom/menu.ts +61 -0
- package/src/common/color-tokens/custom/modal.ts +57 -0
- package/src/common/color-tokens/custom/notification.ts +16 -0
- package/src/common/color-tokens/custom/panel.ts +112 -0
- package/src/common/color-tokens/custom/popover.ts +28 -0
- package/src/common/color-tokens/custom/select.ts +155 -0
- package/src/common/color-tokens/custom/settings.ts +32 -0
- package/src/common/color-tokens/custom/statusbar.ts +16 -0
- package/src/common/color-tokens/custom/tab.ts +31 -0
- package/src/common/color-tokens/custom/tooltip.ts +55 -0
- package/src/common/color-tokens/custom/tree.ts +106 -0
- package/src/common/color-tokens/debug.ts +103 -0
- package/src/common/color-tokens/debugToolbar.ts +134 -0
- package/src/common/color-tokens/dropdown.ts +27 -0
- package/src/common/color-tokens/editor.ts +945 -0
- package/src/common/color-tokens/index.ts +35 -0
- package/src/common/color-tokens/input.ts +105 -0
- package/src/common/color-tokens/list-tree.ts +205 -0
- package/src/common/color-tokens/menu-bar.ts +43 -0
- package/src/common/color-tokens/menu.ts +53 -0
- package/src/common/color-tokens/merge-conflict.ts +145 -0
- package/src/common/color-tokens/minimap.ts +99 -0
- package/src/common/color-tokens/notification.ts +169 -0
- package/src/common/color-tokens/panel.ts +177 -0
- package/src/common/color-tokens/pick-view.ts +96 -0
- package/src/common/color-tokens/picker.ts +15 -0
- package/src/common/color-tokens/progress-bar.ts +12 -0
- package/src/common/color-tokens/quick-input.ts +57 -0
- package/src/common/color-tokens/scrollbar.ts +42 -0
- package/src/common/color-tokens/settings.ts +126 -0
- package/src/common/color-tokens/sidebar.ts +121 -0
- package/src/common/color-tokens/snippet.ts +33 -0
- package/src/common/color-tokens/status-bar.ts +350 -0
- package/src/common/color-tokens/tab.ts +346 -0
- package/src/common/color-tokens/testing.ts +105 -0
- package/src/common/color-tokens/text.ts +41 -0
- package/src/common/color-tokens/title-bar.ts +62 -0
- package/src/common/color-tokens/toolbar.ts +28 -0
- package/src/common/color-tokens/welcome-page.ts +27 -0
- package/src/common/color.ts +647 -0
- package/src/common/default-themes.ts +273 -0
- package/src/common/event.ts +9 -0
- package/src/common/index.ts +8 -0
- package/src/common/mocks/theme.service.ts +55 -0
- package/src/common/plistParser.ts +525 -0
- package/src/common/semantic-tokens-registry.ts +439 -0
- package/src/common/style.ts +9 -0
- package/src/common/theme.service.ts +363 -0
- package/src/common/themeCompatibility.ts +95 -0
- package/src/common/utils.ts +195 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { Injectable } from '@opensumi/di';
|
|
2
|
+
import { IJSONSchema, IJSONSchemaMap } from '@opensumi/ide-core-common/lib/json-schema';
|
|
3
|
+
import { localize } from '@opensumi/ide-core-common/lib/localize';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
fontStylePattern,
|
|
7
|
+
getStylingSchemeEntry,
|
|
8
|
+
ISemanticTokenRegistry,
|
|
9
|
+
parseClassifierString,
|
|
10
|
+
selectorPattern,
|
|
11
|
+
SemanticTokenDefaultRule,
|
|
12
|
+
TokenSelector,
|
|
13
|
+
TokenStyleDefaults,
|
|
14
|
+
TokenTypeOrModifierContribution,
|
|
15
|
+
TOKEN_TYPE_WILDCARD,
|
|
16
|
+
typeAndModifierIdPattern,
|
|
17
|
+
} from '../common/semantic-tokens-registry';
|
|
18
|
+
|
|
19
|
+
@Injectable()
|
|
20
|
+
export class SemanticTokenRegistryImpl implements ISemanticTokenRegistry {
|
|
21
|
+
private typeHierarchy: { [id: string]: string[] } = Object.create(null);
|
|
22
|
+
|
|
23
|
+
private tokenTypeById: { [key: string]: TokenTypeOrModifierContribution } = Object.create(null);
|
|
24
|
+
private tokenModifierById: { [key: string]: TokenTypeOrModifierContribution } = Object.create(null);
|
|
25
|
+
|
|
26
|
+
private currentTypeNumber = 0;
|
|
27
|
+
private currentModifierBit = 1;
|
|
28
|
+
|
|
29
|
+
private tokenStylingDefaultRules: SemanticTokenDefaultRule[] = [];
|
|
30
|
+
|
|
31
|
+
private tokenStylingSchema: IJSONSchema & {
|
|
32
|
+
properties: IJSONSchemaMap;
|
|
33
|
+
patternProperties: IJSONSchemaMap;
|
|
34
|
+
} = {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {},
|
|
37
|
+
patternProperties: {
|
|
38
|
+
[selectorPattern]: getStylingSchemeEntry(),
|
|
39
|
+
},
|
|
40
|
+
additionalProperties: false,
|
|
41
|
+
definitions: {
|
|
42
|
+
style: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
description: localize('schema.token.settings', 'Colors and styles for the token.'),
|
|
45
|
+
properties: {
|
|
46
|
+
foreground: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: localize('schema.token.foreground', 'Foreground color for the token.'),
|
|
49
|
+
format: 'color-hex',
|
|
50
|
+
default: '#ff0000',
|
|
51
|
+
},
|
|
52
|
+
background: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
deprecationMessage: localize(
|
|
55
|
+
'schema.token.background.warning',
|
|
56
|
+
'Token background colors are currently not supported.',
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
fontStyle: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: localize(
|
|
62
|
+
'schema.token.fontStyle',
|
|
63
|
+
"Sets the all font styles of the rule: 'italic', 'bold' or 'underline' or a combination. All styles that are not listed are unset. The empty string unsets all styles.",
|
|
64
|
+
),
|
|
65
|
+
pattern: fontStylePattern,
|
|
66
|
+
patternErrorMessage: localize(
|
|
67
|
+
'schema.fontStyle.error',
|
|
68
|
+
"Font style must be 'italic', 'bold' or 'underline' or a combination. The empty string unsets all styles.",
|
|
69
|
+
),
|
|
70
|
+
defaultSnippets: [
|
|
71
|
+
{
|
|
72
|
+
label: localize('schema.token.fontStyle.none', 'None (clear inherited style)'),
|
|
73
|
+
bodyText: '""',
|
|
74
|
+
},
|
|
75
|
+
{ body: 'italic' },
|
|
76
|
+
{ body: 'bold' },
|
|
77
|
+
{ body: 'underline' },
|
|
78
|
+
{ body: 'italic underline' },
|
|
79
|
+
{ body: 'bold underline' },
|
|
80
|
+
{ body: 'italic bold underline' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
bold: {
|
|
84
|
+
type: 'boolean',
|
|
85
|
+
description: localize(
|
|
86
|
+
'schema.token.bold',
|
|
87
|
+
"Sets or unsets the font style to bold. Note, the presence of 'fontStyle' overrides this setting.",
|
|
88
|
+
),
|
|
89
|
+
},
|
|
90
|
+
italic: {
|
|
91
|
+
type: 'boolean',
|
|
92
|
+
description: localize(
|
|
93
|
+
'schema.token.italic',
|
|
94
|
+
"Sets or unsets the font style to italic. Note, the presence of 'fontStyle' overrides this setting.",
|
|
95
|
+
),
|
|
96
|
+
},
|
|
97
|
+
underline: {
|
|
98
|
+
type: 'boolean',
|
|
99
|
+
description: localize(
|
|
100
|
+
'schema.token.underline',
|
|
101
|
+
"Sets or unsets the font style to underline. Note, the presence of 'fontStyle' overrides this setting.",
|
|
102
|
+
),
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
defaultSnippets: [{ body: { foreground: '${1:#FF0000}', fontStyle: '${2:bold}' } }],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
parseTokenSelector(selectorString: string, language?: string): TokenSelector {
|
|
111
|
+
const selector = parseClassifierString(selectorString, language);
|
|
112
|
+
|
|
113
|
+
if (!selector.type) {
|
|
114
|
+
return {
|
|
115
|
+
match: () => -1,
|
|
116
|
+
id: '$invalid',
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
match: (type: string, modifiers: string[], language: string) => {
|
|
122
|
+
let score = 0;
|
|
123
|
+
if (selector.language !== undefined) {
|
|
124
|
+
if (selector.language !== language) {
|
|
125
|
+
return -1;
|
|
126
|
+
}
|
|
127
|
+
score += 10;
|
|
128
|
+
}
|
|
129
|
+
if (selector.type !== TOKEN_TYPE_WILDCARD) {
|
|
130
|
+
const hierarchy = this.getTypeHierarchy(type);
|
|
131
|
+
const level = hierarchy.indexOf(selector.type);
|
|
132
|
+
if (level === -1) {
|
|
133
|
+
return -1;
|
|
134
|
+
}
|
|
135
|
+
score += 100 - level;
|
|
136
|
+
}
|
|
137
|
+
// all selector modifiers must be present
|
|
138
|
+
for (const selectorModifier of selector.modifiers) {
|
|
139
|
+
if (modifiers.indexOf(selectorModifier) === -1) {
|
|
140
|
+
return -1;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return score + selector.modifiers.length * 100;
|
|
144
|
+
},
|
|
145
|
+
id: `${[selector.type, ...selector.modifiers.sort()].join('.')}${
|
|
146
|
+
selector.language !== undefined ? ':' + selector.language : ''
|
|
147
|
+
}`,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
registerTokenStyleDefault(selector: TokenSelector, defaults: TokenStyleDefaults): void {
|
|
152
|
+
this.tokenStylingDefaultRules.push({ selector, defaults });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
deregisterTokenStyleDefault(selector: TokenSelector): void {
|
|
156
|
+
const selectorString = selector.id;
|
|
157
|
+
this.tokenStylingDefaultRules = this.tokenStylingDefaultRules.filter((r) => r.selector.id !== selectorString);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
getTokenStylingDefaultRules() {
|
|
161
|
+
return this.tokenStylingDefaultRules;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
registerTokenModifier(id: string, description: string, deprecationMessage?: string): void {
|
|
165
|
+
if (!id.match(typeAndModifierIdPattern)) {
|
|
166
|
+
throw new Error('Invalid token modifier id.');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const num = this.currentModifierBit;
|
|
170
|
+
this.currentModifierBit = this.currentModifierBit * 2;
|
|
171
|
+
const tokenStyleContribution: TokenTypeOrModifierContribution = {
|
|
172
|
+
num,
|
|
173
|
+
id,
|
|
174
|
+
description,
|
|
175
|
+
deprecationMessage,
|
|
176
|
+
};
|
|
177
|
+
this.tokenModifierById[id] = tokenStyleContribution;
|
|
178
|
+
|
|
179
|
+
this.tokenStylingSchema.properties[`*.${id}`] = getStylingSchemeEntry(description, deprecationMessage);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
registerTokenType(id: string, description: string, superType?: string, deprecationMessage?: string): void {
|
|
183
|
+
if (!id.match(typeAndModifierIdPattern)) {
|
|
184
|
+
throw new Error('Invalid token type id.');
|
|
185
|
+
}
|
|
186
|
+
if (superType && !superType.match(typeAndModifierIdPattern)) {
|
|
187
|
+
throw new Error('Invalid token super type id.');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const num = this.currentTypeNumber++;
|
|
191
|
+
const tokenStyleContribution: TokenTypeOrModifierContribution = {
|
|
192
|
+
num,
|
|
193
|
+
id,
|
|
194
|
+
superType,
|
|
195
|
+
description,
|
|
196
|
+
deprecationMessage,
|
|
197
|
+
};
|
|
198
|
+
this.tokenTypeById[id] = tokenStyleContribution;
|
|
199
|
+
|
|
200
|
+
const stylingSchemeEntry = getStylingSchemeEntry(description, deprecationMessage);
|
|
201
|
+
this.tokenStylingSchema.properties[id] = stylingSchemeEntry;
|
|
202
|
+
this.typeHierarchy = Object.create(null);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
private getTypeHierarchy(typeId: string): string[] {
|
|
206
|
+
let hierarchy = this.typeHierarchy[typeId];
|
|
207
|
+
if (!hierarchy) {
|
|
208
|
+
this.typeHierarchy[typeId] = hierarchy = [typeId];
|
|
209
|
+
let type = this.tokenTypeById[typeId];
|
|
210
|
+
while (type && type.superType) {
|
|
211
|
+
hierarchy.push(type.superType);
|
|
212
|
+
type = this.tokenTypeById[type.superType];
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return hierarchy;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Injectable } from '@opensumi/di';
|
|
2
|
+
|
|
3
|
+
import { ICSSStyleService } from '../common/style';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class CSSStyleService implements ICSSStyleService {
|
|
7
|
+
private styleSheet: CSSStyleSheet;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
const style = document.createElement('style');
|
|
11
|
+
document.body.appendChild(style);
|
|
12
|
+
this.styleSheet = style.sheet as CSSStyleSheet;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
addClass(classname: string, style: Partial<CSSStyleDeclaration>) {
|
|
16
|
+
const ruleContent = [`.${classname} {`, createStyleCssText(style as any), '}'].join(' ');
|
|
17
|
+
this.styleSheet.insertRule(ruleContent);
|
|
18
|
+
return {
|
|
19
|
+
dispose: () => {
|
|
20
|
+
this.removeClass(classname);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
removeClass(classname: string) {
|
|
26
|
+
for (let i = this.styleSheet.rules.length - 1; i >= 0; i--) {
|
|
27
|
+
if ((this.styleSheet.rules[i] as any).selectorText === '.' + classname) {
|
|
28
|
+
this.styleSheet.removeRule(i);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function createStyleCssText(styles: { [key: string]: string | undefined }): string {
|
|
35
|
+
const texts: string[] = [];
|
|
36
|
+
Object.keys(styles).forEach((key) => {
|
|
37
|
+
if (styles[key]) {
|
|
38
|
+
texts.push(toDashSplitForm(key) + ':' + styles[key]);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return texts.join(';');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function toDashSplitForm(key: string) {
|
|
46
|
+
return key
|
|
47
|
+
.trim()
|
|
48
|
+
.split(/(?=[A-Z])/)
|
|
49
|
+
.join('-')
|
|
50
|
+
.toLowerCase();
|
|
51
|
+
}
|