@lvce-editor/shared-process 0.7.12 → 0.8.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/config/defaultSettings.json +2 -0
- package/extensions/builtin.language-basics-elm/src/tokenizeElm.js +276 -6
- package/extensions/builtin.theme-cobalt2/README.md +18 -0
- package/extensions/builtin.theme-cobalt2/color-theme.json +135 -0
- package/extensions/builtin.theme-cobalt2/extension.json +12 -0
- package/extensions/builtin.theme-slime/README.md +1 -1
- package/package.json +3 -3
- package/src/parts/ExtensionManagement/ExtensionManagement.ipc.js +1 -0
- package/src/parts/ExtensionManagement/ExtensionManagementColorTheme.js +38 -12
- package/src/parts/FileSystemWatch/FileSystemWatch.js +6 -0
- package/src/parts/ModuleMap/ModuleMap.js +1 -0
- package/src/parts/RequiresSocket/RequiresSocket.js +1 -0
|
@@ -1,28 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @enum number
|
|
3
|
+
*/
|
|
4
|
+
export const State = {
|
|
5
|
+
TopLevelContent: 1,
|
|
6
|
+
Keyword: 2,
|
|
7
|
+
AfterKeyword: 3,
|
|
8
|
+
InsideBlockComment: 4,
|
|
9
|
+
AfterKeywordImport: 5,
|
|
10
|
+
AfterKeywordImportAfterWhitespace: 6,
|
|
11
|
+
AfterTypeColon: 7,
|
|
12
|
+
AfterKeywordType: 8,
|
|
13
|
+
AfterKeywordTypeAfterWhitespace: 9,
|
|
14
|
+
InsideTypeRightHandSide: 10,
|
|
15
|
+
AfterTypeName: 11,
|
|
16
|
+
AfterTypeNameAfterWhitespace: 12,
|
|
17
|
+
InsideLineComment: 13,
|
|
18
|
+
AfterKeywordModule: 14,
|
|
19
|
+
AfterModuleName: 15,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const StateMap = {
|
|
23
|
+
[State.TopLevelContent]: 'TopLevelContent',
|
|
24
|
+
}
|
|
25
|
+
|
|
1
26
|
/**
|
|
2
27
|
* @enum number
|
|
3
28
|
*/
|
|
4
29
|
export const TokenType = {
|
|
5
|
-
|
|
30
|
+
None: 1,
|
|
31
|
+
Whitespace: 2,
|
|
32
|
+
PunctuationString: 3,
|
|
33
|
+
String: 4,
|
|
34
|
+
Keyword: 5,
|
|
35
|
+
Numeric: 6,
|
|
36
|
+
Punctuation: 7,
|
|
37
|
+
VariableName: 8,
|
|
38
|
+
Comment: 885,
|
|
39
|
+
Text: 9,
|
|
40
|
+
LanguageConstantBoolean: 10,
|
|
41
|
+
Definition: 11,
|
|
42
|
+
Type: 12,
|
|
43
|
+
KeywordImport: 14,
|
|
6
44
|
}
|
|
7
45
|
|
|
8
46
|
export const TokenMap = {
|
|
47
|
+
[TokenType.None]: 'None',
|
|
48
|
+
[TokenType.Whitespace]: 'Whitespace',
|
|
49
|
+
[TokenType.PunctuationString]: 'PunctuationString',
|
|
50
|
+
[TokenType.String]: 'String',
|
|
51
|
+
[TokenType.Keyword]: 'Keyword',
|
|
52
|
+
[TokenType.Numeric]: 'Numeric',
|
|
53
|
+
[TokenType.Punctuation]: 'Punctuation',
|
|
54
|
+
[TokenType.VariableName]: 'VariableName',
|
|
55
|
+
[TokenType.Comment]: 'Comment',
|
|
9
56
|
[TokenType.Text]: 'Text',
|
|
57
|
+
[TokenType.LanguageConstantBoolean]: 'LanguageConstantBoolean',
|
|
58
|
+
[TokenType.Definition]: 'Type',
|
|
59
|
+
[TokenType.Type]: 'TypeName',
|
|
60
|
+
[TokenType.Type]: 'Type',
|
|
61
|
+
[TokenType.KeywordImport]: 'KeywordImport',
|
|
10
62
|
}
|
|
11
63
|
|
|
12
64
|
export const initialLineState = {
|
|
13
|
-
state:
|
|
14
|
-
tokens: [],
|
|
65
|
+
state: State.TopLevelContent,
|
|
15
66
|
}
|
|
16
67
|
|
|
68
|
+
const RE_WHITESPACE = /^\s+/
|
|
69
|
+
const RE_WHITESPACE_SINGLE_LINE = /^( |\t)+/
|
|
70
|
+
const RE_WHITESPACE_NEWLINE = /^\n/
|
|
71
|
+
const RE_CONSTANT = /^(true|false|null)/
|
|
72
|
+
const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"\n]+/
|
|
73
|
+
const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^'\n]+/
|
|
74
|
+
const RE_DOUBLE_QUOTE = /^"/
|
|
75
|
+
const RE_CURLY_OPEN = /^\{/
|
|
76
|
+
const RE_CURLY_CLOSE = /^\}/
|
|
77
|
+
const RE_SQUARE_OPEN = /^\[/
|
|
78
|
+
const RE_SQUARE_CLOSE = /^\]/
|
|
79
|
+
const RE_COMMA = /^,/
|
|
80
|
+
const RE_COLON = /^:/
|
|
81
|
+
const RE_NUMERIC =
|
|
82
|
+
/^((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b/
|
|
83
|
+
|
|
84
|
+
const RE_KEYWORD =
|
|
85
|
+
/^(?:where|type|True|then|port|of|module|let|in|import|if|False|exposing|else|case|as)\b/
|
|
86
|
+
const RE_LANGUAGE_CONSTANT = /^(?:True|False)\b/
|
|
87
|
+
const RE_IMPORT = /^[a-zA-Z\.]+/
|
|
88
|
+
const RE_SEMICOLON = /^;/
|
|
89
|
+
const RE_VARIABLE_NAME = /^[a-zA-Z][a-zA-Z\d\_\-]*/
|
|
90
|
+
const RE_ROUND_OPEN = /^\(/
|
|
91
|
+
const RE_ROUND_CLOSE = /^\)/
|
|
92
|
+
const RE_DOT = /^\./
|
|
93
|
+
const RE_EQUAL_SIGN = /^=/
|
|
94
|
+
const RE_SINGLE_QUOTE = /^'/
|
|
95
|
+
const RE_LINE_COMMENT = /^\-\-[^\n]*/
|
|
96
|
+
const RE_BLOCK_COMMENT_START = /^\{\-/
|
|
97
|
+
const RE_BLOCK_COMMENT_END = /^\-\}/
|
|
98
|
+
const RE_BLOCK_COMMENT_CONTENT = /^.+(?=\-\})/s
|
|
99
|
+
const RE_PUNCTUATION = /^(?:\(|\)|\[|\]|\||\->)/
|
|
100
|
+
const RE_WORD_ALIAS = /^alias/
|
|
101
|
+
const RE_ANYTHING_UNTIL_END = /^.+/s
|
|
102
|
+
|
|
17
103
|
export const hasArrayReturn = true
|
|
18
104
|
|
|
19
105
|
/**
|
|
20
106
|
* @param {string} line
|
|
107
|
+
* @param {any} lineState
|
|
21
108
|
*/
|
|
22
|
-
export const tokenizeLine = (line) => {
|
|
23
|
-
|
|
109
|
+
export const tokenizeLine = (line, lineState) => {
|
|
110
|
+
let next = null
|
|
111
|
+
let index = 0
|
|
112
|
+
let tokens = []
|
|
113
|
+
let token = TokenType.None
|
|
114
|
+
let state = lineState.state
|
|
115
|
+
while (index < line.length) {
|
|
116
|
+
const part = line.slice(index)
|
|
117
|
+
switch (state) {
|
|
118
|
+
case State.TopLevelContent:
|
|
119
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
120
|
+
token = TokenType.Whitespace
|
|
121
|
+
state = State.TopLevelContent
|
|
122
|
+
} else if ((next = part.match(RE_KEYWORD))) {
|
|
123
|
+
state = State.Keyword
|
|
124
|
+
continue
|
|
125
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
126
|
+
token = TokenType.VariableName
|
|
127
|
+
state = State.TopLevelContent
|
|
128
|
+
} else if ((next = part.match(RE_LINE_COMMENT))) {
|
|
129
|
+
token = TokenType.Comment
|
|
130
|
+
state = State.TopLevelContent
|
|
131
|
+
} else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
|
|
132
|
+
token = TokenType.Comment
|
|
133
|
+
state = State.InsideBlockComment
|
|
134
|
+
} else if ((next = part.match(RE_COLON))) {
|
|
135
|
+
token = TokenType.Punctuation
|
|
136
|
+
state = State.AfterTypeColon
|
|
137
|
+
} else if ((next = part.match(RE_PUNCTUATION))) {
|
|
138
|
+
token = TokenType.Punctuation
|
|
139
|
+
state = State.TopLevelContent
|
|
140
|
+
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
141
|
+
token = TokenType.Text
|
|
142
|
+
state = State.TopLevelContent
|
|
143
|
+
} else {
|
|
144
|
+
part.startsWith('Bool') //?
|
|
145
|
+
throw new Error('no')
|
|
146
|
+
}
|
|
147
|
+
break
|
|
148
|
+
case State.InsideBlockComment:
|
|
149
|
+
if ((next = part.match(RE_BLOCK_COMMENT_END))) {
|
|
150
|
+
token = TokenType.Comment
|
|
151
|
+
state = State.TopLevelContent
|
|
152
|
+
} else if ((next = part.match(RE_BLOCK_COMMENT_CONTENT))) {
|
|
153
|
+
token = TokenType.Comment
|
|
154
|
+
state = State.InsideBlockComment
|
|
155
|
+
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
156
|
+
token = TokenType.Comment
|
|
157
|
+
state = State.InsideBlockComment
|
|
158
|
+
} else {
|
|
159
|
+
part //?
|
|
160
|
+
throw new Error('no')
|
|
161
|
+
}
|
|
162
|
+
break
|
|
163
|
+
case State.Keyword:
|
|
164
|
+
const keyword = next[0]
|
|
165
|
+
switch (keyword) {
|
|
166
|
+
case 'import':
|
|
167
|
+
case 'exposing':
|
|
168
|
+
token = TokenType.Keyword
|
|
169
|
+
state = State.TopLevelContent
|
|
170
|
+
break
|
|
171
|
+
case 'False':
|
|
172
|
+
case 'True':
|
|
173
|
+
token = TokenType.LanguageConstantBoolean
|
|
174
|
+
state = State.TopLevelContent
|
|
175
|
+
break
|
|
176
|
+
case 'type':
|
|
177
|
+
token = TokenType.Keyword
|
|
178
|
+
state = State.AfterKeywordType
|
|
179
|
+
break
|
|
180
|
+
case 'module':
|
|
181
|
+
token = TokenType.KeywordImport
|
|
182
|
+
state = State.AfterKeywordModule
|
|
183
|
+
break
|
|
184
|
+
case 'port':
|
|
185
|
+
token = TokenType.Keyword
|
|
186
|
+
state = State.TopLevelContent
|
|
187
|
+
break
|
|
188
|
+
default:
|
|
189
|
+
throw new Error('no')
|
|
190
|
+
}
|
|
191
|
+
break
|
|
192
|
+
case State.AfterKeywordType:
|
|
193
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
194
|
+
token = TokenType.Whitespace
|
|
195
|
+
state = State.AfterKeywordTypeAfterWhitespace
|
|
196
|
+
} else {
|
|
197
|
+
throw new Error('no')
|
|
198
|
+
}
|
|
199
|
+
break
|
|
200
|
+
case State.AfterKeywordTypeAfterWhitespace:
|
|
201
|
+
if ((next = part.match(RE_WORD_ALIAS))) {
|
|
202
|
+
token = TokenType.Keyword
|
|
203
|
+
state = State.AfterKeywordType
|
|
204
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
205
|
+
token = TokenType.Type
|
|
206
|
+
state = State.AfterTypeName
|
|
207
|
+
} else {
|
|
208
|
+
part //?
|
|
209
|
+
throw new Error('no')
|
|
210
|
+
}
|
|
211
|
+
break
|
|
212
|
+
case State.AfterTypeName:
|
|
213
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
214
|
+
token = TokenType.Whitespace
|
|
215
|
+
state = State.AfterTypeNameAfterWhitespace
|
|
216
|
+
} else {
|
|
217
|
+
throw new Error('no')
|
|
218
|
+
}
|
|
219
|
+
break
|
|
220
|
+
case State.AfterTypeNameAfterWhitespace:
|
|
221
|
+
if ((next = part.match(RE_EQUAL_SIGN))) {
|
|
222
|
+
token = TokenType.Punctuation
|
|
223
|
+
state = State.InsideTypeRightHandSide
|
|
224
|
+
} else {
|
|
225
|
+
part //?
|
|
226
|
+
part.startsWith('M') //?
|
|
227
|
+
throw new Error('no')
|
|
228
|
+
}
|
|
229
|
+
break
|
|
230
|
+
case State.InsideTypeRightHandSide:
|
|
231
|
+
if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
232
|
+
token = TokenType.Type
|
|
233
|
+
state = State.InsideTypeRightHandSide
|
|
234
|
+
} else if ((next = part.match(RE_WHITESPACE))) {
|
|
235
|
+
token = TokenType.Whitespace
|
|
236
|
+
state = State.InsideTypeRightHandSide
|
|
237
|
+
} else if ((next = part.match(RE_PUNCTUATION))) {
|
|
238
|
+
token = TokenType.Punctuation
|
|
239
|
+
state = State.InsideTypeRightHandSide
|
|
240
|
+
} else {
|
|
241
|
+
part //?
|
|
242
|
+
throw new Error('no')
|
|
243
|
+
}
|
|
244
|
+
break
|
|
245
|
+
case State.AfterTypeColon:
|
|
246
|
+
if ((next = part.match(RE_WHITESPACE_SINGLE_LINE))) {
|
|
247
|
+
token = TokenType.Whitespace
|
|
248
|
+
state = State.AfterTypeColon
|
|
249
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
250
|
+
token = TokenType.Type
|
|
251
|
+
state = State.AfterTypeColon
|
|
252
|
+
} else if ((next = part.match(RE_WHITESPACE_NEWLINE))) {
|
|
253
|
+
token = TokenType.Whitespace
|
|
254
|
+
state = State.TopLevelContent
|
|
255
|
+
} else if ((next = part.match(RE_PUNCTUATION))) {
|
|
256
|
+
token = TokenType.Punctuation
|
|
257
|
+
state = State.AfterTypeColon
|
|
258
|
+
} else {
|
|
259
|
+
part //?
|
|
260
|
+
throw new Error('no')
|
|
261
|
+
}
|
|
262
|
+
break
|
|
263
|
+
case State.AfterKeywordModule:
|
|
264
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
265
|
+
token = TokenType.Whitespace
|
|
266
|
+
state = State.AfterKeywordModule
|
|
267
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
268
|
+
token = TokenType.VariableName
|
|
269
|
+
state = State.AfterModuleName
|
|
270
|
+
} else {
|
|
271
|
+
throw new Error('no')
|
|
272
|
+
}
|
|
273
|
+
break
|
|
274
|
+
case State.AfterModuleName:
|
|
275
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
276
|
+
token = TokenType.Whitespace
|
|
277
|
+
state = State.TopLevelContent
|
|
278
|
+
} else {
|
|
279
|
+
throw new Error('no')
|
|
280
|
+
}
|
|
281
|
+
break
|
|
282
|
+
default:
|
|
283
|
+
throw new Error('no')
|
|
284
|
+
}
|
|
285
|
+
const tokenLength = next[0].length
|
|
286
|
+
index += tokenLength
|
|
287
|
+
tokens.push(token, tokenLength)
|
|
288
|
+
}
|
|
289
|
+
if (state === State.InsideLineComment) {
|
|
290
|
+
state = State.TopLevelContent
|
|
291
|
+
}
|
|
24
292
|
return {
|
|
25
|
-
state
|
|
293
|
+
state,
|
|
26
294
|
tokens,
|
|
27
295
|
}
|
|
28
296
|
}
|
|
297
|
+
|
|
298
|
+
tokenizeLine(`port module Main exposing (..)`, initialLineState)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Theme Cobalt2
|
|
2
|
+
|
|
3
|
+
## Contributing
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
git clone git@github.com:lvce-editor/theme-cobalt2.git &&
|
|
7
|
+
cd theme-cobalt2 &&
|
|
8
|
+
npm ci &&
|
|
9
|
+
npm run dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Gitpod
|
|
13
|
+
|
|
14
|
+
[](https://gitpod.io/#https://github.com/lvce-editor/theme-cobalt2)
|
|
15
|
+
|
|
16
|
+
## Credits
|
|
17
|
+
|
|
18
|
+
Extension is based on https://github.com/wesbos/cobalt2-vscode by @wesbos (License MIT)
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "dark",
|
|
3
|
+
"colors": {
|
|
4
|
+
"ActivityBarBackground": "#122738",
|
|
5
|
+
"ActivityBarActiveForeground": "rgb(255, 255, 255)",
|
|
6
|
+
"ActivityBarForeground": "rgba(255, 255, 255, 0.4)",
|
|
7
|
+
|
|
8
|
+
"BadgeBackground": "#ffc600",
|
|
9
|
+
"BadgeForeground": "#000",
|
|
10
|
+
|
|
11
|
+
"ContextMenuBackground": "#122738",
|
|
12
|
+
"ContextMenuForeground": "rgb(255, 255, 255)",
|
|
13
|
+
|
|
14
|
+
"EditorBackGround": "",
|
|
15
|
+
"EditorScrollBarBackground": "rgba(64, 97, 121, 0.8)",
|
|
16
|
+
"EditorCursorBackground": "#ffc600",
|
|
17
|
+
"EditorSelectionBackground": "#0050a4",
|
|
18
|
+
|
|
19
|
+
"FocusOutline": "#0d3a58",
|
|
20
|
+
|
|
21
|
+
"InputBoxBackground": "#193549",
|
|
22
|
+
"InputBoxForeground": "#ffc600",
|
|
23
|
+
|
|
24
|
+
"ListActiveSelectionBackground": "#193549",
|
|
25
|
+
"ListActiveSelectionForeground": "#aaa",
|
|
26
|
+
"ListHoverBackground": "#193549",
|
|
27
|
+
"ListHoverForeground": "#aaa",
|
|
28
|
+
"ListInactiveSelectionBackground": "",
|
|
29
|
+
"ListForeground": "rgb(170, 170, 170)",
|
|
30
|
+
|
|
31
|
+
"MainBackground": "#193549",
|
|
32
|
+
|
|
33
|
+
"MenuBackground": "rgb(18, 39, 56)",
|
|
34
|
+
"MenuItemHoverBackground": "rgb(25, 53, 73)",
|
|
35
|
+
|
|
36
|
+
"PanelBackground": "#122738",
|
|
37
|
+
"PanelBorderTopColor": "#ffc600",
|
|
38
|
+
"PanelTabHoverForeground": "rgb(255, 198, 0)",
|
|
39
|
+
"PanelTabForeground": "rgb(170, 170, 170)",
|
|
40
|
+
|
|
41
|
+
"QuickPickBackground": "rgb(21, 35, 45)",
|
|
42
|
+
"QuickPickInputBackground": "",
|
|
43
|
+
|
|
44
|
+
"SideBarBackground": "#15232d",
|
|
45
|
+
|
|
46
|
+
"StatusBarBackground": "#15232d",
|
|
47
|
+
"StatusBarBorderTopColor": "#0d3a58",
|
|
48
|
+
|
|
49
|
+
"TabActiveForeground": "rgb(255, 255, 255)",
|
|
50
|
+
"TabForeground": "rgb(170, 170, 170)",
|
|
51
|
+
"TabActiveBackground": "rgb(25, 53, 73)",
|
|
52
|
+
"TabInactiveBackground": "",
|
|
53
|
+
|
|
54
|
+
"TabsBackground": "rgb(18, 39, 56)",
|
|
55
|
+
|
|
56
|
+
"TitleBarBackground": "#15232D",
|
|
57
|
+
"TitleBarBorderBottomColor": "",
|
|
58
|
+
"TitleBarColor": "",
|
|
59
|
+
"TitleBarColorInactive": "rgba(204, 204, 204, 0.6)"
|
|
60
|
+
},
|
|
61
|
+
"tokenColors": [
|
|
62
|
+
{
|
|
63
|
+
"name": "CssSelector",
|
|
64
|
+
"foreground": "#3AD900"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "CssPropertyName",
|
|
68
|
+
"foreground": "#A5FF90"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "CssPropertyValue",
|
|
72
|
+
"foreground": "#FFEE80"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "TagName",
|
|
76
|
+
"foreground": "#9EFFFF"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "AttributeName",
|
|
80
|
+
"foreground": "#FFC600"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "String",
|
|
84
|
+
"foreground": "#A5FF90"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "PunctuationString",
|
|
88
|
+
"foreground": "#92FC79"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "JsonPropertyName",
|
|
92
|
+
"foreground": "#FFC600"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "LanguageConstant",
|
|
96
|
+
"foreground": "#FF628C"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "Keyword",
|
|
100
|
+
"foreground": "#FFC600"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "Numeric",
|
|
104
|
+
"foreground": "#FF628C"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "KeywordImport",
|
|
108
|
+
"foreground": "#FF9D00"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "Type",
|
|
112
|
+
"foreground": "#80FFBB"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "Macro",
|
|
116
|
+
"foreground": "#FF9D00"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "KeywordControl",
|
|
120
|
+
"foreground": "#FF9D00"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "Regex",
|
|
124
|
+
"foreground": "#9EFFFF"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "Function",
|
|
128
|
+
"foreground": "#ffc600"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "Comment",
|
|
132
|
+
"foreground": "#0088FF"
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"node": ">=16"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@lvce-editor/extension-host": "0.
|
|
24
|
-
"@lvce-editor/pty-host": "0.
|
|
23
|
+
"@lvce-editor/extension-host": "0.8.0",
|
|
24
|
+
"@lvce-editor/pty-host": "0.8.0",
|
|
25
25
|
"chokidar": "^3.5.3",
|
|
26
26
|
"debug": "^4.3.4",
|
|
27
27
|
"execa": "^6.1.0",
|
|
@@ -10,6 +10,7 @@ export const Commands = {
|
|
|
10
10
|
'ExtensionHost.getIconThemeJson': ExtensionHostIconTheme.getIconTheme,
|
|
11
11
|
'ExtensionHost.getLanguageConfiguration': ExtensionHostLanguages.getLanguageConfiguration,
|
|
12
12
|
'ExtensionHost.getLanguages': ExtensionHostLanguages.getLanguages,
|
|
13
|
+
'ExtensionHost.watchColorTheme':ExtensionHostColorTheme.watch,
|
|
13
14
|
'ExtensionManagement.disable': ExtensionManagement.disable,
|
|
14
15
|
'ExtensionManagement.enable': ExtensionManagement.enable,
|
|
15
16
|
'ExtensionManagement.getAllExtensions': ExtensionManagement.getAllExtensions,
|
|
@@ -3,11 +3,12 @@ import * as Error from '../Error/Error.js'
|
|
|
3
3
|
import * as ReadJson from '../JsonFile/JsonFile.js'
|
|
4
4
|
import * as Path from '../Path/Path.js'
|
|
5
5
|
import * as ExtensionManagement from './ExtensionManagement.js'
|
|
6
|
+
import * as FileSystemWatch from '../FileSystemWatch/FileSystemWatch.js'
|
|
6
7
|
|
|
7
8
|
// TODO test this function
|
|
8
9
|
// TODO very similar with getIconTheme
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
const getColorThemePath = async (extensions, colorThemeId) => {
|
|
11
12
|
for (const extension of extensions) {
|
|
12
13
|
if (!extension.colorThemes) {
|
|
13
14
|
continue
|
|
@@ -17,18 +18,27 @@ export const getColorThemeJson = async (colorThemeId) => {
|
|
|
17
18
|
continue
|
|
18
19
|
}
|
|
19
20
|
const absolutePath = Path.join(extension.path, colorTheme.path)
|
|
20
|
-
|
|
21
|
-
const json = await ReadJson.readJson(absolutePath)
|
|
22
|
-
return json
|
|
23
|
-
} catch (error) {
|
|
24
|
-
throw new VError(error, `Failed to load color theme "${colorThemeId}"`)
|
|
25
|
-
}
|
|
21
|
+
return absolutePath
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
return ''
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const getColorThemeJson = async (colorThemeId) => {
|
|
28
|
+
const extensions = await ExtensionManagement.getExtensions()
|
|
29
|
+
const colorThemePath = await getColorThemePath(extensions, colorThemeId)
|
|
30
|
+
if (!colorThemePath) {
|
|
31
|
+
throw new Error.OperationalError({
|
|
32
|
+
code: 'E_COLOR_THEME_NOT_FOUND',
|
|
33
|
+
message: `Color theme "${colorThemeId}" not found in extensions folder`,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const json = await ReadJson.readJson(colorThemePath)
|
|
38
|
+
return json
|
|
39
|
+
} catch (error) {
|
|
40
|
+
throw new VError(error, `Failed to load color theme "${colorThemeId}"`)
|
|
41
|
+
}
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
const getColorThemeInfo = (extension) => {
|
|
@@ -56,3 +66,19 @@ export const getColorThemes = async () => {
|
|
|
56
66
|
const colorThemes = extensions.flatMap(getColorThemeInfo)
|
|
57
67
|
return colorThemes
|
|
58
68
|
}
|
|
69
|
+
|
|
70
|
+
export const watch = async (socket, colorThemeId) => {
|
|
71
|
+
// console.log({ socket, colorThemeId })
|
|
72
|
+
const extensions = await ExtensionManagement.getExtensions()
|
|
73
|
+
const colorThemePath = await getColorThemePath(extensions, colorThemeId)
|
|
74
|
+
const verbose = process.argv.includes('--verbose')
|
|
75
|
+
if (verbose) {
|
|
76
|
+
console.info(
|
|
77
|
+
`[shared-process] starting to watch color theme ${colorThemeId} at ${colorThemePath}`
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
const watcher = FileSystemWatch.watchFile(colorThemePath)
|
|
81
|
+
for await (const event of watcher) {
|
|
82
|
+
socket.send({ jsonrpc: '2.0', method: 'ColorTheme.reload', params: [] })
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -66,6 +66,7 @@ export const getModuleId = (commandId) => {
|
|
|
66
66
|
case 'ExtensionHost.getIconThemeJson':
|
|
67
67
|
case 'ExtensionHost.getLanguageConfiguration':
|
|
68
68
|
case 'ExtensionHost.getLanguages':
|
|
69
|
+
case 'ExtensionHost.watchColorTheme':
|
|
69
70
|
case 'ExtensionManagement.disable':
|
|
70
71
|
case 'ExtensionManagement.enable':
|
|
71
72
|
case 'ExtensionManagement.getAllExtensions':
|