@finos/legend-lego 0.1.13 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/{src/code-editor/CodeEditorConfig.ts → lib/application/ActivityBar.d.ts} +7 -16
- package/lib/application/ActivityBar.d.ts.map +1 -0
- package/lib/application/ActivityBar.js +19 -0
- package/lib/application/ActivityBar.js.map +1 -0
- package/lib/application/index.d.ts +1 -0
- package/lib/application/index.d.ts.map +1 -1
- package/lib/application/index.js +1 -0
- package/lib/application/index.js.map +1 -1
- package/lib/code-editor/CodeDiffView.d.ts +1 -1
- package/lib/code-editor/CodeDiffView.d.ts.map +1 -1
- package/lib/code-editor/CodeDiffView.js +4 -11
- package/lib/code-editor/CodeDiffView.js.map +1 -1
- package/lib/code-editor/CodeEditor.d.ts +5 -2
- package/lib/code-editor/CodeEditor.d.ts.map +1 -1
- package/lib/code-editor/CodeEditor.js +15 -17
- package/lib/code-editor/CodeEditor.js.map +1 -1
- package/lib/code-editor/CodeEditorTheme.d.ts +39 -0
- package/lib/code-editor/CodeEditorTheme.d.ts.map +1 -0
- package/lib/code-editor/CodeEditorTheme.js +72 -0
- package/lib/code-editor/CodeEditorTheme.js.map +1 -0
- package/lib/code-editor/CodeEditorUtils.d.ts +11 -0
- package/lib/code-editor/CodeEditorUtils.d.ts.map +1 -1
- package/lib/code-editor/CodeEditorUtils.js +23 -0
- package/lib/code-editor/CodeEditorUtils.js.map +1 -1
- package/lib/code-editor/PureLanguage.d.ts +38 -0
- package/lib/code-editor/PureLanguage.d.ts.map +1 -0
- package/lib/code-editor/PureLanguage.js +39 -0
- package/lib/code-editor/PureLanguage.js.map +1 -0
- package/lib/code-editor/PureLanguageService.d.ts +0 -22
- package/lib/code-editor/PureLanguageService.d.ts.map +1 -1
- package/lib/code-editor/PureLanguageService.js +3 -48
- package/lib/code-editor/PureLanguageService.js.map +1 -1
- package/lib/code-editor/index.d.ts +3 -2
- package/lib/code-editor/index.d.ts.map +1 -1
- package/lib/code-editor/index.js +3 -2
- package/lib/code-editor/index.js.map +1 -1
- package/lib/code-editor/themes/Github-Theme-dark-dimmed.json +613 -0
- package/lib/code-editor/themes/Github-Theme-dark.json +513 -0
- package/lib/code-editor/themes/Material-Theme-Darker.json +816 -0
- package/lib/code-editor/themes/Material-Theme-Default.json +816 -0
- package/lib/code-editor/themes/MonacoEditorThemeUtils.d.ts +31 -0
- package/lib/code-editor/themes/MonacoEditorThemeUtils.d.ts.map +1 -0
- package/lib/code-editor/themes/MonacoEditorThemeUtils.js +88 -0
- package/lib/code-editor/themes/MonacoEditorThemeUtils.js.map +1 -0
- package/lib/code-editor/themes/OneDark-Pro-darker.json +2061 -0
- package/lib/code-editor/themes/OneDark-Pro.json +2090 -0
- package/lib/code-editor/themes/solarized-dark-color-theme.json +398 -0
- package/lib/data-grid/DataGrid.d.ts.map +1 -1
- package/lib/data-grid/DataGrid.js +13 -1
- package/lib/data-grid/DataGrid.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/package.json +7 -7
- package/{lib/code-editor/CodeEditorConfig.d.ts → src/application/ActivityBar.tsx} +16 -15
- package/src/application/index.ts +1 -0
- package/src/code-editor/CodeDiffView.tsx +4 -12
- package/src/code-editor/CodeEditor.tsx +25 -22
- package/src/code-editor/CodeEditorTheme.ts +118 -0
- package/src/code-editor/CodeEditorUtils.ts +55 -0
- package/src/code-editor/PureLanguage.ts +42 -0
- package/src/code-editor/PureLanguageService.ts +3 -56
- package/src/code-editor/index.ts +3 -5
- package/src/code-editor/themes/Github-Theme-dark-dimmed.json +613 -0
- package/src/code-editor/themes/Github-Theme-dark.json +513 -0
- package/src/code-editor/themes/Material-Theme-Darker.json +816 -0
- package/src/code-editor/themes/Material-Theme-Default.json +816 -0
- package/src/code-editor/themes/MonacoEditorThemeUtils.ts +128 -0
- package/src/code-editor/themes/OneDark-Pro-darker.json +2061 -0
- package/src/code-editor/themes/OneDark-Pro.json +2090 -0
- package/src/code-editor/themes/README.md +8 -0
- package/src/code-editor/themes/solarized-dark-color-theme.json +423 -0
- package/src/data-grid/DataGrid.tsx +12 -1
- package/tsconfig.json +12 -2
- package/lib/code-editor/CodeEditorConfig.d.ts.map +0 -1
- package/lib/code-editor/CodeEditorConfig.js +0 -33
- package/lib/code-editor/CodeEditorConfig.js.map +0 -1
@@ -0,0 +1,128 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
import {
|
18
|
+
getNonNullableEntry,
|
19
|
+
isNonNullable,
|
20
|
+
isString,
|
21
|
+
} from '@finos/legend-shared';
|
22
|
+
import type { editor as monacoEditorAPI } from 'monaco-editor';
|
23
|
+
|
24
|
+
type VSCodeThemeData = {
|
25
|
+
colors: Record<string, string | string[]>;
|
26
|
+
tokenColors: {
|
27
|
+
name?: string;
|
28
|
+
scope?: string[] | string;
|
29
|
+
settings?: {
|
30
|
+
foreground?: string;
|
31
|
+
background?: string;
|
32
|
+
fontStyle?: string;
|
33
|
+
};
|
34
|
+
}[];
|
35
|
+
};
|
36
|
+
|
37
|
+
const parseVSCodeTheme = (
|
38
|
+
rawData: VSCodeThemeData,
|
39
|
+
): monacoEditorAPI.IStandaloneThemeData => {
|
40
|
+
const rules: monacoEditorAPI.ITokenThemeRule[] = [];
|
41
|
+
|
42
|
+
rawData.tokenColors.forEach((tokenColor) => {
|
43
|
+
if (!tokenColor.settings) {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
|
47
|
+
let scopes: string[] = [];
|
48
|
+
|
49
|
+
if (isString(tokenColor.scope)) {
|
50
|
+
scopes = tokenColor.scope
|
51
|
+
.replace(/^[,]+/, '')
|
52
|
+
.replace(/[,]+$/, '')
|
53
|
+
.split(',')
|
54
|
+
.map((scope) => scope.trim());
|
55
|
+
} else if (Array.isArray(tokenColor.scope)) {
|
56
|
+
scopes = tokenColor.scope;
|
57
|
+
} else {
|
58
|
+
scopes = [''];
|
59
|
+
}
|
60
|
+
|
61
|
+
const baseRule: Omit<monacoEditorAPI.ITokenThemeRule, 'token'> = {};
|
62
|
+
|
63
|
+
if (
|
64
|
+
tokenColor.settings.foreground &&
|
65
|
+
isString(tokenColor.settings.foreground)
|
66
|
+
) {
|
67
|
+
baseRule.foreground = tokenColor.settings.foreground;
|
68
|
+
}
|
69
|
+
|
70
|
+
if (
|
71
|
+
tokenColor.settings.background &&
|
72
|
+
isString(tokenColor.settings.background)
|
73
|
+
) {
|
74
|
+
baseRule.background = tokenColor.settings.background;
|
75
|
+
}
|
76
|
+
|
77
|
+
if (
|
78
|
+
tokenColor.settings.fontStyle &&
|
79
|
+
isString(tokenColor.settings.fontStyle)
|
80
|
+
) {
|
81
|
+
baseRule.fontStyle = tokenColor.settings.fontStyle;
|
82
|
+
}
|
83
|
+
|
84
|
+
scopes.forEach((scope) => {
|
85
|
+
if (isNonNullable(scope) || !Object.keys(baseRule).length) {
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
const rule = {
|
89
|
+
...baseRule,
|
90
|
+
token: scope,
|
91
|
+
};
|
92
|
+
rules.push(rule);
|
93
|
+
});
|
94
|
+
});
|
95
|
+
|
96
|
+
const colors: monacoEditorAPI.IColors = {};
|
97
|
+
Object.entries(rawData.colors).forEach(([key, value]) => {
|
98
|
+
if (Array.isArray(value)) {
|
99
|
+
if (value.length) {
|
100
|
+
colors[key] = getNonNullableEntry(value, 0);
|
101
|
+
}
|
102
|
+
} else {
|
103
|
+
colors[key] = value;
|
104
|
+
}
|
105
|
+
});
|
106
|
+
|
107
|
+
return {
|
108
|
+
base: 'vs-dark',
|
109
|
+
inherit: true,
|
110
|
+
rules: rules,
|
111
|
+
colors,
|
112
|
+
};
|
113
|
+
};
|
114
|
+
|
115
|
+
export const buildCodeEditorTheme = (
|
116
|
+
vscodeThemeData: VSCodeThemeData,
|
117
|
+
baseTheme: monacoEditorAPI.BuiltinTheme,
|
118
|
+
colorsOverride: Record<string, string>,
|
119
|
+
rulesOverride: monacoEditorAPI.ITokenThemeRule[],
|
120
|
+
): monacoEditorAPI.IStandaloneThemeData => {
|
121
|
+
const baseThemeData = parseVSCodeTheme(vscodeThemeData);
|
122
|
+
return {
|
123
|
+
...baseThemeData,
|
124
|
+
base: baseTheme,
|
125
|
+
colors: { ...baseThemeData.colors, ...colorsOverride },
|
126
|
+
rules: [...baseThemeData.rules, ...rulesOverride],
|
127
|
+
};
|
128
|
+
};
|