@lvce-editor/shared-process 0.10.7 → 0.11.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/defaultKeyBindings.json +12 -22
- package/config/defaultSettings.json +4 -2
- package/extensions/builtin.language-basics-html/src/tokenizeHtml.js +14 -4
- package/extensions/builtin.language-basics-javascript/src/tokenizeJavaScript.js +13 -5
- package/extensions/builtin.language-basics-json/extension.json +3 -1
- package/extensions/builtin.language-basics-json/src/tokenizeJson.js +4 -1
- package/extensions/builtin.language-basics-typescript/src/tokenizeTypeScript.js +65 -9
- package/extensions/builtin.theme-gruvbox/extension.json +1 -1
- package/extensions/builtin.theme-noctis-uva/extension.json +1 -1
- package/package.json +5 -5
- package/src/parts/ChromeExtension/ChromeExtension.ipc.js +4 -2
- package/src/parts/CliLink/CliLink.js +13 -3
- package/src/parts/ClipBoard/ClipBoard.ipc.js +4 -2
- package/src/parts/Command/Command.js +6 -1
- package/src/parts/Developer/Developer.ipc.js +10 -8
- package/src/parts/Download/Download.ipc.js +8 -0
- package/src/parts/EncodingType/EncodingType.js +1 -0
- package/src/parts/ExportStatic/ExportStatic.js +8 -2
- package/src/parts/ExtensionInstallFromUrl/ExtensionInstallFromUrl.js +2 -1
- package/src/parts/FileSystem/FileSystem.ipc.js +16 -14
- package/src/parts/FileSystem/FileSystem.js +17 -5
- package/src/parts/Module/Module.js +2 -0
- package/src/parts/ModuleId/ModuleId.js +1 -0
- package/src/parts/ModuleMap/ModuleMap.js +6 -3
- package/src/parts/Native/Native.ipc.js +3 -1
- package/src/parts/OutputChannel/OutputChannel.ipc.js +4 -2
- package/src/parts/Platform/Platform.ipc.js +20 -17
- package/src/parts/Platform/Platform.js +24 -19
- package/src/parts/Preferences/Preferences.ipc.js +3 -1
- package/src/parts/PtyHostPath/PtyHostPath.js +11 -0
- package/src/parts/RecentlyOpened/RecentlyOpened.ipc.js +3 -1
- package/src/parts/Search/Search.ipc.js +3 -1
- package/src/parts/Search/Search.js +18 -10
- package/src/parts/SearchFile/SearchFile.ipc.js +3 -1
- package/src/parts/Terminal/Terminal.ipc.js +6 -4
- package/src/parts/Terminal/Terminal.js +7 -9
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
{
|
|
23
23
|
"key": "Escape",
|
|
24
24
|
"command": "Viewlet.closeWidget",
|
|
25
|
-
"when": "focus.
|
|
26
|
-
"args": ["
|
|
25
|
+
"when": "focus.FindWidget",
|
|
26
|
+
"args": ["FindWidget"]
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"key": "ctrl+ArrowRight",
|
|
@@ -329,23 +329,13 @@
|
|
|
329
329
|
},
|
|
330
330
|
{
|
|
331
331
|
"key": "Escape",
|
|
332
|
-
"command": "Explorer.
|
|
333
|
-
"when": "focus.
|
|
332
|
+
"command": "Explorer.cancelEdit",
|
|
333
|
+
"when": "focus.ExplorerEditBox"
|
|
334
334
|
},
|
|
335
335
|
{
|
|
336
336
|
"key": "Enter",
|
|
337
|
-
"command": "Explorer.
|
|
338
|
-
"when": "focus.
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
"key": "Escape",
|
|
342
|
-
"command": "Explorer.cancelNewFile",
|
|
343
|
-
"when": "focus.ExplorerCreateFile"
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
"key": "Enter",
|
|
347
|
-
"command": "Explorer.acceptNewFile",
|
|
348
|
-
"when": "focus.ExplorerCreateFile"
|
|
337
|
+
"command": "Explorer.acceptEdit",
|
|
338
|
+
"when": "focus.ExplorerEditBox"
|
|
349
339
|
},
|
|
350
340
|
{
|
|
351
341
|
"key": "Delete",
|
|
@@ -687,18 +677,18 @@
|
|
|
687
677
|
},
|
|
688
678
|
{
|
|
689
679
|
"key": "Enter",
|
|
690
|
-
"command": "
|
|
691
|
-
"when": "focus.
|
|
680
|
+
"command": "FindWidget.focusNext",
|
|
681
|
+
"when": "focus.FindWidget"
|
|
692
682
|
},
|
|
693
683
|
{
|
|
694
684
|
"key": "shift+F4",
|
|
695
|
-
"command": "
|
|
696
|
-
"when": "focus.
|
|
685
|
+
"command": "FindWidget.focusPrevious",
|
|
686
|
+
"when": "focus.FindWidget"
|
|
697
687
|
},
|
|
698
688
|
{
|
|
699
689
|
"key": "F4",
|
|
700
|
-
"command": "
|
|
701
|
-
"when": "focus.
|
|
690
|
+
"command": "FindWidget.focusNext",
|
|
691
|
+
"when": "focus.FindWidget"
|
|
702
692
|
},
|
|
703
693
|
{
|
|
704
694
|
"key": "ctrl+=",
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"editor.fontSize": 15,
|
|
7
7
|
"editor.fontFamily": "'Fira Code'",
|
|
8
8
|
"editor.lineHeight": 20,
|
|
9
|
+
"editor.formatOnSave": false,
|
|
9
10
|
|
|
10
11
|
"extensions.autoUpdate": true,
|
|
11
12
|
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
"Thumbs.db": true
|
|
18
19
|
},
|
|
19
20
|
|
|
20
|
-
"sessionReplay.enabled":
|
|
21
|
+
"sessionReplay.enabled": false,
|
|
21
22
|
|
|
22
23
|
"serviceWorker.enabled": false,
|
|
23
24
|
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
"ctrl+p",
|
|
39
40
|
"ctrl+shift+p",
|
|
40
41
|
"ctrl+b",
|
|
41
|
-
"ctrl+m"
|
|
42
|
+
"ctrl+m",
|
|
43
|
+
"ctrl+Tab"
|
|
42
44
|
]
|
|
43
45
|
}
|
|
@@ -84,7 +84,7 @@ const RE_TAGNAME = /^[!\w]+/
|
|
|
84
84
|
const RE_TEXT = /^[^<>\n]+/
|
|
85
85
|
const RE_WHITESPACE = /^\s+/
|
|
86
86
|
const RE_WORD = /^[^\s]+/
|
|
87
|
-
const RE_ATTRIBUTE_VALUE_UNQUOTED
|
|
87
|
+
const RE_ATTRIBUTE_VALUE_UNQUOTED = /^[^<>]+/
|
|
88
88
|
|
|
89
89
|
export const initialLineState = {
|
|
90
90
|
state: State.TopLevelContent,
|
|
@@ -145,6 +145,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
145
145
|
} else if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
|
|
146
146
|
token = TokenType.PunctuationTag
|
|
147
147
|
state = State.TopLevelContent
|
|
148
|
+
} else if ((next = part.match(RE_ANGLE_BRACKET_OPEN))) {
|
|
149
|
+
token = TokenType.PunctuationTag
|
|
150
|
+
state = State.AfterOpeningAngleBracket
|
|
148
151
|
} else if ((next = part.match(RE_ANY_TEXT))) {
|
|
149
152
|
token = TokenType.Text
|
|
150
153
|
state = State.TopLevelContent
|
|
@@ -178,6 +181,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
178
181
|
if ((next = part.match(RE_TAGNAME))) {
|
|
179
182
|
token = TokenType.TagName
|
|
180
183
|
state = State.AfterClosingTagName
|
|
184
|
+
} else if ((next = part.match(RE_WHITESPACE))) {
|
|
185
|
+
token = TokenType.Whitespace
|
|
186
|
+
state = State.TopLevelContent
|
|
181
187
|
} else if ((next = part.match(RE_ANY_TEXT))) {
|
|
182
188
|
token = TokenType.Text
|
|
183
189
|
state = State.TopLevelContent
|
|
@@ -250,9 +256,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
250
256
|
} else if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
|
|
251
257
|
token = TokenType.PunctuationTag
|
|
252
258
|
state = State.TopLevelContent
|
|
253
|
-
}else if((next=part.match(RE_ATTRIBUTE_VALUE_UNQUOTED))){
|
|
254
|
-
token=TokenType.String
|
|
255
|
-
state=State.InsideOpeningTag
|
|
259
|
+
} else if ((next = part.match(RE_ATTRIBUTE_VALUE_UNQUOTED))) {
|
|
260
|
+
token = TokenType.String
|
|
261
|
+
state = State.InsideOpeningTag
|
|
256
262
|
} else {
|
|
257
263
|
part
|
|
258
264
|
throw new Error('no')
|
|
@@ -299,10 +305,14 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
299
305
|
state
|
|
300
306
|
throw new Error('no')
|
|
301
307
|
}
|
|
308
|
+
|
|
302
309
|
const tokenLength = next[0].length
|
|
303
310
|
index += tokenLength
|
|
304
311
|
tokens.push(token, tokenLength)
|
|
305
312
|
}
|
|
313
|
+
if (state === State.AfterClosingTagAngleBrackets) {
|
|
314
|
+
state = State.TopLevelContent
|
|
315
|
+
}
|
|
306
316
|
return {
|
|
307
317
|
state,
|
|
308
318
|
tokens,
|
|
@@ -49,6 +49,7 @@ export const TokenType = {
|
|
|
49
49
|
KeywordReturn: 883,
|
|
50
50
|
KeywordNew: 884,
|
|
51
51
|
FunctionName: 885,
|
|
52
|
+
KeywordThis: 886,
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
export const TokenMap = {
|
|
@@ -75,6 +76,7 @@ export const TokenMap = {
|
|
|
75
76
|
[TokenType.KeywordReturn]: 'KeywordReturn',
|
|
76
77
|
[TokenType.KeywordNew]: 'KeywordNew',
|
|
77
78
|
[TokenType.FunctionName]: 'Function',
|
|
79
|
+
[TokenType.KeywordThis]: 'KeywordThis',
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
const RE_KEYWORD =
|
|
@@ -113,7 +115,7 @@ const RE_QUOTE_DOUBLE = /^"/
|
|
|
113
115
|
const RE_QUOTE_BACKTICK = /^`/
|
|
114
116
|
const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^'\\]+/
|
|
115
117
|
const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"\\]+/
|
|
116
|
-
const RE_STRING_BACKTICK_QUOTE_CONTENT = /^[
|
|
118
|
+
const RE_STRING_BACKTICK_QUOTE_CONTENT = /^[^`\\]+/
|
|
117
119
|
const RE_STRING_ESCAPE = /^\\./
|
|
118
120
|
const RE_SHEBANG = /^#!.*/
|
|
119
121
|
const RE_FUNCTION_CALL_NAME = /^[\w]+(?=\s*(\(|\=\s*function|\=\s*\())/
|
|
@@ -179,6 +181,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
179
181
|
case 'new':
|
|
180
182
|
token = TokenType.KeywordNew
|
|
181
183
|
break
|
|
184
|
+
case 'this':
|
|
185
|
+
token = TokenType.KeywordThis
|
|
186
|
+
break
|
|
182
187
|
default:
|
|
183
188
|
token = TokenType.Keyword
|
|
184
189
|
break
|
|
@@ -251,12 +256,12 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
251
256
|
}
|
|
252
257
|
break
|
|
253
258
|
case State.InsideBlockComment:
|
|
254
|
-
if ((next = part.match(
|
|
255
|
-
token = TokenType.Comment
|
|
256
|
-
state = State.InsideBlockComment
|
|
257
|
-
} else if ((next = part.match(RE_BLOCK_COMMENT_END))) {
|
|
259
|
+
if ((next = part.match(RE_BLOCK_COMMENT_END))) {
|
|
258
260
|
token = TokenType.Comment
|
|
259
261
|
state = State.TopLevelContent
|
|
262
|
+
} else if ((next = part.match(RE_BLOCK_COMMENT_CONTENT))) {
|
|
263
|
+
token = TokenType.Comment
|
|
264
|
+
state = State.InsideBlockComment
|
|
260
265
|
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
261
266
|
token = TokenType.Comment
|
|
262
267
|
state = State.InsideBlockComment
|
|
@@ -299,6 +304,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
299
304
|
} else if ((next = part.match(RE_STRING_BACKTICK_QUOTE_CONTENT))) {
|
|
300
305
|
token = TokenType.String
|
|
301
306
|
state = State.InsideBacktickString
|
|
307
|
+
} else if ((next = part.match(RE_STRING_ESCAPE))) {
|
|
308
|
+
token = TokenType.String
|
|
309
|
+
state = State.InsideBacktickString
|
|
302
310
|
} else {
|
|
303
311
|
throw new Error('no')
|
|
304
312
|
}
|
|
@@ -255,7 +255,7 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
255
255
|
state = State.AfterPropertyValue
|
|
256
256
|
} else if ((next = part.match(RE_TEXT))) {
|
|
257
257
|
token = TokenType.Text
|
|
258
|
-
state = State.
|
|
258
|
+
state = State.AfterCurlyOpen
|
|
259
259
|
} else if ((next = part.match(RE_CURLY_OPEN))) {
|
|
260
260
|
token = TokenType.Punctuation
|
|
261
261
|
state = State.AfterCurlyOpen
|
|
@@ -311,6 +311,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
311
311
|
if (state === State.InsideLineComment) {
|
|
312
312
|
state = State.TopLevelContent
|
|
313
313
|
}
|
|
314
|
+
if (state === State.AfterPropertyValue) {
|
|
315
|
+
state = State.AfterCurlyOpen
|
|
316
|
+
}
|
|
314
317
|
return {
|
|
315
318
|
state,
|
|
316
319
|
stack,
|
|
@@ -21,6 +21,10 @@ const State = {
|
|
|
21
21
|
AfterTypeExpression: 18,
|
|
22
22
|
AfterVariableName: 19,
|
|
23
23
|
BeforePropertyAccess: 20,
|
|
24
|
+
AfterKeywordEnum: 21,
|
|
25
|
+
AfterKeywordEnumAfterVariableName: 22,
|
|
26
|
+
InsideEnum: 23,
|
|
27
|
+
InsideEnumAfterVariableName: 24,
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
/**
|
|
@@ -78,6 +82,9 @@ export const TokenMap = {
|
|
|
78
82
|
|
|
79
83
|
export const initialLineState = {
|
|
80
84
|
state: State.TopLevelContent,
|
|
85
|
+
/**
|
|
86
|
+
* @type {any[]}
|
|
87
|
+
*/
|
|
81
88
|
stack: [],
|
|
82
89
|
}
|
|
83
90
|
|
|
@@ -125,10 +132,12 @@ const RE_DOT = /^\./
|
|
|
125
132
|
const RE_SQUARE_OPEN = /^\[/
|
|
126
133
|
const RE_SQUARE_CLOSE = /^\]/
|
|
127
134
|
|
|
135
|
+
export const hasArrayReturn = true
|
|
136
|
+
|
|
128
137
|
/**
|
|
129
138
|
*
|
|
130
139
|
* @param {string} line
|
|
131
|
-
* @param {
|
|
140
|
+
* @param {any} lineState
|
|
132
141
|
* @returns
|
|
133
142
|
*/
|
|
134
143
|
export const tokenizeLine = (line, lineState) => {
|
|
@@ -140,13 +149,14 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
140
149
|
let stack = lineState.stack
|
|
141
150
|
while (index < line.length) {
|
|
142
151
|
const part = line.slice(index)
|
|
152
|
+
part
|
|
153
|
+
state
|
|
143
154
|
switch (state) {
|
|
144
155
|
case State.TopLevelContent:
|
|
145
156
|
if ((next = part.match(RE_WHITESPACE))) {
|
|
146
157
|
token = TokenType.Whitespace
|
|
147
158
|
state = State.TopLevelContent
|
|
148
159
|
} else if ((next = part.match(RE_KEYWORD))) {
|
|
149
|
-
next[0] //?
|
|
150
160
|
switch (next[0]) {
|
|
151
161
|
case 'true':
|
|
152
162
|
case 'false':
|
|
@@ -273,6 +283,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
273
283
|
} else if ((next = part.match(RE_COLON))) {
|
|
274
284
|
token = TokenType.Punctuation
|
|
275
285
|
state = State.BeforeType
|
|
286
|
+
} else if ((next = part.match(RE_KEYWORD_ENUM))) {
|
|
287
|
+
token = TokenType.Keyword
|
|
288
|
+
state = State.AfterKeywordEnum
|
|
276
289
|
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
277
290
|
token = TokenType.VariableName
|
|
278
291
|
state = State.AfterKeywordDeclaration
|
|
@@ -280,6 +293,7 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
280
293
|
token = TokenType.Punctuation
|
|
281
294
|
state = State.TopLevelContent
|
|
282
295
|
} else {
|
|
296
|
+
line
|
|
283
297
|
part
|
|
284
298
|
throw new Error('no')
|
|
285
299
|
}
|
|
@@ -429,7 +443,6 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
429
443
|
}
|
|
430
444
|
break
|
|
431
445
|
case State.AfterKeywordDeclare:
|
|
432
|
-
part
|
|
433
446
|
if ((next = part.match(RE_WHITESPACE))) {
|
|
434
447
|
token = TokenType.Whitespace
|
|
435
448
|
state = State.AfterKeywordDeclare
|
|
@@ -441,7 +454,7 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
441
454
|
state = State.AfterKeywordDeclare
|
|
442
455
|
} else if ((next = part.match(RE_KEYWORD_ENUM))) {
|
|
443
456
|
token = TokenType.Keyword
|
|
444
|
-
state = State.
|
|
457
|
+
state = State.AfterKeywordEnum
|
|
445
458
|
} else if ((next = part.match(RE_KEYWORD_CLASS))) {
|
|
446
459
|
token = TokenType.Keyword
|
|
447
460
|
state = State.AfterKeywordClass
|
|
@@ -453,6 +466,51 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
453
466
|
throw new Error('no')
|
|
454
467
|
}
|
|
455
468
|
break
|
|
469
|
+
|
|
470
|
+
case State.AfterKeywordEnum:
|
|
471
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
472
|
+
token = TokenType.Whitespace
|
|
473
|
+
state = State.AfterKeywordEnum
|
|
474
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
475
|
+
token = TokenType.Type
|
|
476
|
+
state = State.AfterKeywordEnumAfterVariableName
|
|
477
|
+
} else {
|
|
478
|
+
throw new Error('no')
|
|
479
|
+
}
|
|
480
|
+
break
|
|
481
|
+
case State.AfterKeywordEnumAfterVariableName:
|
|
482
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
483
|
+
token = TokenType.Whitespace
|
|
484
|
+
state = State.AfterKeywordEnumAfterVariableName
|
|
485
|
+
} else if ((next = part.match(RE_CURLY_OPEN))) {
|
|
486
|
+
token = TokenType.Punctuation
|
|
487
|
+
state = State.InsideEnum
|
|
488
|
+
} else {
|
|
489
|
+
throw new Error('no')
|
|
490
|
+
}
|
|
491
|
+
break
|
|
492
|
+
case State.InsideEnum:
|
|
493
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
494
|
+
token = TokenType.Whitespace
|
|
495
|
+
state = State.InsideEnum
|
|
496
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
497
|
+
token = TokenType.VariableName
|
|
498
|
+
state = State.InsideEnumAfterVariableName
|
|
499
|
+
} else {
|
|
500
|
+
throw new Error('no')
|
|
501
|
+
}
|
|
502
|
+
break
|
|
503
|
+
case State.InsideEnumAfterVariableName:
|
|
504
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
505
|
+
token = TokenType.Whitespace
|
|
506
|
+
state = State.InsideEnumAfterVariableName
|
|
507
|
+
} else if ((next = part.match(RE_EQUAL))) {
|
|
508
|
+
token = TokenType.Punctuation
|
|
509
|
+
state = State.TopLevelContent
|
|
510
|
+
} else {
|
|
511
|
+
throw new Error('no')
|
|
512
|
+
}
|
|
513
|
+
break
|
|
456
514
|
case State.InsideLineComment:
|
|
457
515
|
if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
458
516
|
token = TokenType.Comment
|
|
@@ -533,11 +591,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
533
591
|
state
|
|
534
592
|
throw new Error('no')
|
|
535
593
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
length: next[0].length,
|
|
540
|
-
})
|
|
594
|
+
const tokenLength = next[0].length
|
|
595
|
+
index += tokenLength
|
|
596
|
+
tokens.push(token, tokenLength)
|
|
541
597
|
}
|
|
542
598
|
if (state === State.AfterType && stack[0] === State.InsideClass) {
|
|
543
599
|
state = State.InsideClass
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Utility package for @lvce-editor/server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,11 +20,11 @@
|
|
|
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.11.0",
|
|
24
|
+
"@lvce-editor/pty-host": "0.11.0",
|
|
25
25
|
"debug": "^4.3.4",
|
|
26
26
|
"execa": "^6.1.0",
|
|
27
|
-
"exit-hook": "^3.1.
|
|
27
|
+
"exit-hook": "^3.1.2",
|
|
28
28
|
"got": "^12.5.2",
|
|
29
29
|
"is-object": "^1.0.2",
|
|
30
30
|
"lines-and-columns": "^2.0.3",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"tmp-promise": "^3.0.3",
|
|
37
37
|
"trash": "^8.1.0",
|
|
38
38
|
"verror": "^1.10.1",
|
|
39
|
-
"ws": "^8.
|
|
39
|
+
"ws": "^8.11.0",
|
|
40
40
|
"xdg-basedir": "^5.1.0"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as ChromeExtension from './ChromeExtension.js'
|
|
2
2
|
|
|
3
|
+
export const name = 'ChromeExtension'
|
|
4
|
+
|
|
3
5
|
export const Commands = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
install: ChromeExtension.install,
|
|
7
|
+
uninstall: ChromeExtension.uninstall,
|
|
6
8
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import * as ExtensionLink from '../ExtensionLink/ExtensionLink.js'
|
|
2
|
+
import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
|
|
2
3
|
|
|
3
|
-
export const handleCliArgs = async (argv
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export const handleCliArgs = async (argv) => {
|
|
5
|
+
try {
|
|
6
|
+
const path = argv.length > 1 ? argv[1] : process.cwd()
|
|
7
|
+
await ExtensionLink.link(path)
|
|
8
|
+
} catch (error) {
|
|
9
|
+
if (error && error.code === FileSystemErrorCodes.E_MANIFEST_NOT_FOUND) {
|
|
10
|
+
console.error(error.message)
|
|
11
|
+
process.exitCode = 128
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
throw error
|
|
15
|
+
}
|
|
6
16
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as ClipBoard from './ClipBoard.js'
|
|
2
2
|
|
|
3
|
+
export const name = 'ClipBoard'
|
|
4
|
+
|
|
3
5
|
export const Commands = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
readFiles: ClipBoard.readFiles,
|
|
7
|
+
writeFiles: ClipBoard.writeFiles,
|
|
6
8
|
}
|
|
@@ -8,7 +8,12 @@ const pendingModules = Object.create(null)
|
|
|
8
8
|
const initializeModule = (module) => {
|
|
9
9
|
if (module.Commands) {
|
|
10
10
|
for (const [key, value] of Object.entries(module.Commands)) {
|
|
11
|
-
|
|
11
|
+
if (module.name) {
|
|
12
|
+
const actualKey = `${module.name}.${key}`
|
|
13
|
+
register(actualKey, value)
|
|
14
|
+
} else {
|
|
15
|
+
register(key, value)
|
|
16
|
+
}
|
|
12
17
|
}
|
|
13
18
|
return
|
|
14
19
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as Developer from './Developer.js'
|
|
2
2
|
|
|
3
|
+
export const name = 'Developer'
|
|
4
|
+
|
|
3
5
|
// prettier-ignore
|
|
4
6
|
export const Commands = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
allocateMemory: Developer.allocateMemory,
|
|
8
|
+
crashSharedProcess: Developer.crashSharedProcess,
|
|
9
|
+
createHeapSnapshot: Developer.createHeapSnapshot,
|
|
10
|
+
createProfile: Developer.createProfile,
|
|
11
|
+
getNodeStartupTime: Developer.getNodeStartupTiming,
|
|
12
|
+
getNodeStartupTiming: Developer.getNodeStartupTiming,
|
|
13
|
+
sharedProcessMemoryUsage: Developer.sharedProcessMemoryUsage,
|
|
14
|
+
sharedProcessStartupPerformance: Developer.sharedProcessStartupPerformance,
|
|
13
15
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const Utf8 = 'utf8'
|
|
@@ -358,9 +358,15 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
|
|
|
358
358
|
`/${commitHash}`,
|
|
359
359
|
`${pathPrefix}/${commitHash}`
|
|
360
360
|
)
|
|
361
|
-
|
|
362
361
|
await replace(
|
|
363
|
-
Path.join(
|
|
362
|
+
Path.join(
|
|
363
|
+
root,
|
|
364
|
+
'dist',
|
|
365
|
+
commitHash,
|
|
366
|
+
'css',
|
|
367
|
+
'parts',
|
|
368
|
+
'ViewletTitleBarButtons.css'
|
|
369
|
+
),
|
|
364
370
|
`/${commitHash}`,
|
|
365
371
|
`${pathPrefix}/${commitHash}`
|
|
366
372
|
)
|
|
@@ -5,6 +5,7 @@ import * as Download from '../Download/Download.js'
|
|
|
5
5
|
import * as Extract from '../Extract/Extract.js'
|
|
6
6
|
import * as Platform from '../Platform/Platform.js'
|
|
7
7
|
import * as TmpFile from '../TmpFile/TmpFile.js'
|
|
8
|
+
import * as EncodingType from '../EncodingType/EncodingType.js'
|
|
8
9
|
|
|
9
10
|
export const install = async ({ url }) => {
|
|
10
11
|
try {
|
|
@@ -17,7 +18,7 @@ export const install = async ({ url }) => {
|
|
|
17
18
|
const tmpDir = await TmpFile.getTmpDir()
|
|
18
19
|
await Extract.extractTarBr(tmpFile, tmpDir)
|
|
19
20
|
const manifestPath = join(tmpDir, 'extension.json')
|
|
20
|
-
const manifestContent = await readFile(manifestPath,
|
|
21
|
+
const manifestContent = await readFile(manifestPath, EncodingType.Utf8)
|
|
21
22
|
const manifestJson = JSON.parse(manifestContent)
|
|
22
23
|
const id = manifestJson.id
|
|
23
24
|
if (!id) {
|
|
@@ -13,20 +13,22 @@ const fileSystemWatch = (socket, id, path) => {
|
|
|
13
13
|
// })
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
export const name = 'FileSystem'
|
|
17
|
+
|
|
16
18
|
// TODO separate ipc from code like in renderer worker
|
|
17
19
|
export const Commands = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
chmod: FileSystem.chmod,
|
|
21
|
+
copy: FileSystem.copy,
|
|
22
|
+
createFile: FileSystem.createFile,
|
|
23
|
+
createFolder: FileSystem.createFolder,
|
|
24
|
+
ensureFile: FileSystem.ensureFile,
|
|
25
|
+
getPathSeparator: FileSystem.getPathSeparator,
|
|
26
|
+
getRealPath: FileSystem.getRealPath,
|
|
27
|
+
mkdir: FileSystem.mkdir,
|
|
28
|
+
readDirWithFileTypes: FileSystem.readDirWithFileTypes,
|
|
29
|
+
readFile: FileSystem.readFile,
|
|
30
|
+
remove: FileSystem.remove,
|
|
31
|
+
rename: FileSystem.rename,
|
|
32
|
+
stat: FileSystem.stat,
|
|
33
|
+
writeFile: FileSystem.writeFile,
|
|
32
34
|
}
|
|
@@ -3,11 +3,12 @@ import * as fs from 'node:fs/promises'
|
|
|
3
3
|
import * as os from 'node:os'
|
|
4
4
|
import VError from 'verror'
|
|
5
5
|
import * as DirentType from '../DirentType/DirentType.js'
|
|
6
|
+
import { FileNotFoundError } from '../Error/FileNotFoundError.js'
|
|
7
|
+
import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
|
|
6
8
|
import * as Path from '../Path/Path.js'
|
|
7
9
|
import * as Platform from '../Platform/Platform.js'
|
|
8
10
|
import * as Trash from '../Trash/Trash.js'
|
|
9
|
-
import * as
|
|
10
|
-
import { FileNotFoundError } from '../Error/FileNotFoundError.js'
|
|
11
|
+
import * as EncodingType from '../EncodingType/EncodingType.js'
|
|
11
12
|
|
|
12
13
|
export const state = {
|
|
13
14
|
watcherMap: Object.create(null),
|
|
@@ -33,12 +34,19 @@ export const copy = async (source, target) => {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
// TODO extensions should only be accessed once on startup
|
|
36
|
-
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param {string} path
|
|
41
|
+
* @param {BufferEncoding} encoding
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
export const readFile = async (path, encoding = EncodingType.Utf8) => {
|
|
37
45
|
// console.info('[shared-process] read file', path)
|
|
38
46
|
try {
|
|
39
47
|
// const start = performance.now()
|
|
40
48
|
// console.time(`read ${path}`)
|
|
41
|
-
const content = await fs.readFile(path,
|
|
49
|
+
const content = await fs.readFile(path, encoding)
|
|
42
50
|
// const end = performance.now()
|
|
43
51
|
// console.log('read', path, 'took', (end - start).toFixed(2), 'ms')
|
|
44
52
|
// console.timeEnd(`read ${path}`)
|
|
@@ -57,7 +65,11 @@ export const readFile = async (path) => {
|
|
|
57
65
|
* @param {string} content
|
|
58
66
|
* @param {BufferEncoding} encoding
|
|
59
67
|
*/
|
|
60
|
-
export const writeFile = async (
|
|
68
|
+
export const writeFile = async (
|
|
69
|
+
path,
|
|
70
|
+
content,
|
|
71
|
+
encoding = EncodingType.Utf8
|
|
72
|
+
) => {
|
|
61
73
|
try {
|
|
62
74
|
// queue would be more correct for concurrent writes but also slower
|
|
63
75
|
// Queue.add(`writeFile/${path}`, () =>
|
|
@@ -8,6 +8,8 @@ export const load = (moduleId) => {
|
|
|
8
8
|
return import('../ClipBoard/ClipBoard.ipc.js')
|
|
9
9
|
case ModuleId.Developer:
|
|
10
10
|
return import('../Developer/Developer.ipc.js')
|
|
11
|
+
case ModuleId.Download:
|
|
12
|
+
return import('../Download/Download.ipc.js')
|
|
11
13
|
case ModuleId.ExtensionHost:
|
|
12
14
|
return import('../ExtensionHost/ExtensionHost.ipc.js')
|
|
13
15
|
case ModuleId.ExtensionManagement:
|
|
@@ -17,7 +17,8 @@ export const getModuleId = (commandId) => {
|
|
|
17
17
|
case 'Developer.sharedProcessMemoryUsage':
|
|
18
18
|
case 'Developer.sharedProcessStartupPerformance':
|
|
19
19
|
return ModuleId.Developer
|
|
20
|
-
case '
|
|
20
|
+
case 'Download.download':
|
|
21
|
+
return ModuleId.Download
|
|
21
22
|
case 'ExtensionHost.dispose':
|
|
22
23
|
case 'ExtensionHost.enableExtension':
|
|
23
24
|
case 'ExtensionHost.executeCommand':
|
|
@@ -52,14 +53,15 @@ export const getModuleId = (commandId) => {
|
|
|
52
53
|
case 'ExtensionHostOutput.getOutputChannels':
|
|
53
54
|
case 'ExtensionHostQuickPick.handleQuickPickResult':
|
|
54
55
|
case 'ExtensionHostReferences.executeReferenceProvider':
|
|
56
|
+
case 'EXtensionHostRename.executePrepareRename':
|
|
55
57
|
case 'ExtensionHostRename.executeRename':
|
|
56
58
|
case 'ExtensionHostSemanticTokens.executeSemanticTokenProvider':
|
|
57
59
|
case 'ExtensionHostSourceControl.acceptInput':
|
|
58
|
-
case 'ExtensionHostTextDocument':
|
|
59
60
|
case 'ExtensionHostTextDocument.setLanguageId':
|
|
60
61
|
case 'ExtensionHostTextDocument.syncFull':
|
|
61
62
|
case 'ExtensionHostTextDocument.syncIncremental':
|
|
62
63
|
case 'ExtensionHostTextDocument.syncInitial':
|
|
64
|
+
case 'ExtensionHostTextDocument':
|
|
63
65
|
case 'ExtensionHostWorkspace.setWorkspacePath':
|
|
64
66
|
return ModuleId.ExtensionHost
|
|
65
67
|
case 'ExtensionHost.getColorThemeJson':
|
|
@@ -97,11 +99,12 @@ export const getModuleId = (commandId) => {
|
|
|
97
99
|
return ModuleId.OutputChannel
|
|
98
100
|
case 'Platform.getAppDir':
|
|
99
101
|
case 'Platform.getBuiltinExtensionsPath':
|
|
100
|
-
case 'Platform.getCacheDir':
|
|
101
102
|
case 'Platform.getCachedExtensionsPath':
|
|
103
|
+
case 'Platform.getCacheDir':
|
|
102
104
|
case 'Platform.getConfigDir':
|
|
103
105
|
case 'Platform.getDataDir':
|
|
104
106
|
case 'Platform.getDisabledExtensionsPath':
|
|
107
|
+
case 'Platform.getDownloadDir':
|
|
105
108
|
case 'Platform.getExtensionsPath':
|
|
106
109
|
case 'Platform.getHomeDir':
|
|
107
110
|
case 'Platform.getLogsDir':
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import * as Platform from '../Platform/Platform.js'
|
|
2
2
|
|
|
3
|
+
export const name = 'Platform'
|
|
4
|
+
|
|
3
5
|
// prettier-ignore
|
|
4
6
|
export const Commands = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
getAppDir: Platform.getAppDir,
|
|
8
|
+
getBuiltinExtensionsPath: Platform.getBuiltinExtensionsPath,
|
|
9
|
+
getCachedExtensionsPath: Platform.getCachedExtensionsPath,
|
|
10
|
+
getCacheDir: Platform.getCacheDir,
|
|
11
|
+
getConfigDir: Platform.getConfigDir,
|
|
12
|
+
getDataDir: Platform.getDataDir,
|
|
13
|
+
getDisabledExtensionsPath: Platform.getDisabledExtensionsPath,
|
|
14
|
+
getDownloadDir: Platform.getDownloadDir,
|
|
15
|
+
getExtensionsPath: Platform.getExtensionsPath,
|
|
16
|
+
getHomeDir: Platform.getHomeDir,
|
|
17
|
+
getLogsDir: Platform.getLogsDir,
|
|
18
|
+
getMarketplaceUrl: Platform.getMarketplaceUrl,
|
|
19
|
+
getNodePath: Platform.getNodePath,
|
|
20
|
+
getRecentlyOpenedPath: Platform.getRecentlyOpenedPath,
|
|
21
|
+
getTestPath: Platform.getTestPath,
|
|
22
|
+
getTmpDir: Platform.getTmpDir,
|
|
23
|
+
getUserSettingsPath: Platform.getUserSettingsPath,
|
|
24
|
+
setEnvironmentVariables: Platform.setEnvironmentVariables,
|
|
22
25
|
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { extensionHostPath } from '@lvce-editor/extension-host'
|
|
2
2
|
import { homedir, tmpdir } from 'node:os'
|
|
3
|
-
import { resolve, sep } from 'node:path'
|
|
3
|
+
import { join, resolve, sep } from 'node:path'
|
|
4
4
|
import { pathToFileURL } from 'node:url'
|
|
5
5
|
import { xdgCache, xdgConfig, xdgData, xdgState } from 'xdg-basedir'
|
|
6
6
|
import * as Path from '../Path/Path.js'
|
|
7
7
|
import * as Root from '../Root/Root.js'
|
|
8
8
|
|
|
9
|
+
const { env, platform } = process
|
|
10
|
+
|
|
9
11
|
export const applicationName = 'lvce-oss'
|
|
10
12
|
|
|
11
|
-
export const isWindows =
|
|
13
|
+
export const isWindows = platform === 'win32'
|
|
12
14
|
|
|
13
|
-
export const isMacOs =
|
|
15
|
+
export const isMacOs = platform === 'darwin'
|
|
14
16
|
|
|
15
17
|
export const dataDir = Path.join(xdgData || tmpdir(), applicationName)
|
|
16
18
|
|
|
@@ -52,28 +54,28 @@ export const getChromeExtensionsPath = () => {
|
|
|
52
54
|
|
|
53
55
|
export const getMarketplaceUrl = () => {
|
|
54
56
|
return (
|
|
55
|
-
|
|
56
|
-
'https://marketplace.22e924c84de072d4b25b.com'
|
|
57
|
+
env.LVCE_MARKETPLACE_URL || 'https://marketplace.22e924c84de072d4b25b.com'
|
|
57
58
|
)
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
export const getDesktop = () => {
|
|
62
|
+
const { ORIGINAL_XDG_CURRENT_DESKTOP, XDG_CURRENT_DESKTOP } = env
|
|
61
63
|
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
ORIGINAL_XDG_CURRENT_DESKTOP &&
|
|
65
|
+
ORIGINAL_XDG_CURRENT_DESKTOP !== 'undefined'
|
|
64
66
|
) {
|
|
65
|
-
if (
|
|
67
|
+
if (ORIGINAL_XDG_CURRENT_DESKTOP === 'ubuntu:GNOME') {
|
|
66
68
|
return 'gnome'
|
|
67
69
|
}
|
|
68
|
-
return
|
|
70
|
+
return ORIGINAL_XDG_CURRENT_DESKTOP
|
|
69
71
|
}
|
|
70
|
-
if (
|
|
71
|
-
if (
|
|
72
|
+
if (XDG_CURRENT_DESKTOP) {
|
|
73
|
+
if (XDG_CURRENT_DESKTOP === 'ubuntu:GNOME') {
|
|
72
74
|
return 'gnome'
|
|
73
75
|
}
|
|
74
|
-
return
|
|
76
|
+
return XDG_CURRENT_DESKTOP
|
|
75
77
|
}
|
|
76
|
-
if (
|
|
78
|
+
if (isWindows) {
|
|
77
79
|
return 'windows'
|
|
78
80
|
}
|
|
79
81
|
return ''
|
|
@@ -108,17 +110,15 @@ export const getDefaultSettingsPath = () => {
|
|
|
108
110
|
}
|
|
109
111
|
export const setEnvironmentVariables = (variables) => {
|
|
110
112
|
for (const [key, value] of Object.entries(variables)) {
|
|
111
|
-
|
|
113
|
+
env[key] = value
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
export const getTestPath = () => {
|
|
116
|
-
if (
|
|
118
|
+
if (env.TEST_PATH) {
|
|
117
119
|
const testPath =
|
|
118
120
|
'/remote' +
|
|
119
|
-
pathToFileURL(Path.join(process.cwd(),
|
|
120
|
-
.toString()
|
|
121
|
-
.slice(7)
|
|
121
|
+
pathToFileURL(Path.join(process.cwd(), env.TEST_PATH)).toString().slice(7)
|
|
122
122
|
return testPath
|
|
123
123
|
}
|
|
124
124
|
return '/packages/extension-host-worker-tests'
|
|
@@ -133,7 +133,7 @@ export const getTmpDir = () => {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
export const getOnlyExtensionPath = () => {
|
|
136
|
-
const onlyExtensionPath =
|
|
136
|
+
const onlyExtensionPath = env.ONLY_EXTENSION
|
|
137
137
|
if (onlyExtensionPath) {
|
|
138
138
|
return resolve(onlyExtensionPath)
|
|
139
139
|
}
|
|
@@ -159,3 +159,8 @@ export const getDataDir = () => {
|
|
|
159
159
|
export const getHomeDir = () => {
|
|
160
160
|
return homeDir
|
|
161
161
|
}
|
|
162
|
+
|
|
163
|
+
export const getDownloadDir = () => {
|
|
164
|
+
const { XDG_DOWNLOAD_DIR } = env
|
|
165
|
+
return XDG_DOWNLOAD_DIR || join(homeDir, 'Downloads')
|
|
166
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Root from '../Root/Root.js'
|
|
2
|
+
import * as Path from '../Path/Path.js'
|
|
3
|
+
|
|
4
|
+
export const getPtyHostPath = async () => {
|
|
5
|
+
try {
|
|
6
|
+
const { ptyHostPath } = await import('@lvce-editor/pty-host')
|
|
7
|
+
return ptyHostPath
|
|
8
|
+
} catch {
|
|
9
|
+
return Path.join(Root.root, 'packages', 'pty-host', 'src', 'ptyHostMain.js')
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -4,10 +4,13 @@ import * as Platform from '../Platform/Platform.js'
|
|
|
4
4
|
|
|
5
5
|
const MAX_SEARCH_RESULTS = 300
|
|
6
6
|
|
|
7
|
-
const toSearchResult = (parsedLine) =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const toSearchResult = (parsedLine) => {
|
|
8
|
+
return {
|
|
9
|
+
preview: parsedLine.data.lines.text,
|
|
10
|
+
absoluteOffset: parsedLine.data.absolute_offset,
|
|
11
|
+
lineNumber: parsedLine.data.line_number - 1,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
11
14
|
|
|
12
15
|
// TODO update vscode-ripgrep when https://github.com/mhinz/vim-grepper/issues/244, https://github.com/BurntSushi/ripgrep/issues/1892 is fixed
|
|
13
16
|
|
|
@@ -59,7 +62,8 @@ export const search = async (searchDir, searchString) => {
|
|
|
59
62
|
let stats = {}
|
|
60
63
|
let numberOfResults = 0
|
|
61
64
|
// TODO use pipeline / transform stream maybe
|
|
62
|
-
|
|
65
|
+
|
|
66
|
+
const handleData = (chunk) => {
|
|
63
67
|
buffer += chunk
|
|
64
68
|
const lines = buffer.split('\n')
|
|
65
69
|
// @ts-ignore
|
|
@@ -88,20 +92,24 @@ export const search = async (searchDir, searchString) => {
|
|
|
88
92
|
if (numberOfResults > MAX_SEARCH_RESULTS) {
|
|
89
93
|
childProcess.kill()
|
|
90
94
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const handleClose = () => {
|
|
93
98
|
resolve({
|
|
94
99
|
results: Object.entries(allSearchResults),
|
|
95
100
|
stats,
|
|
96
101
|
})
|
|
97
|
-
}
|
|
98
|
-
|
|
102
|
+
}
|
|
103
|
+
const handleError = (error) => {
|
|
99
104
|
// TODO check type of error
|
|
100
105
|
console.error(error)
|
|
101
106
|
resolve({
|
|
102
107
|
results: [],
|
|
103
108
|
stats,
|
|
104
109
|
})
|
|
105
|
-
}
|
|
110
|
+
}
|
|
111
|
+
childProcess.stdout.on('data', handleData)
|
|
112
|
+
childProcess.once('close', handleClose)
|
|
113
|
+
childProcess.once('error', handleError)
|
|
106
114
|
})
|
|
107
115
|
}
|
|
@@ -37,9 +37,11 @@ const dispose = (socket, id) => {
|
|
|
37
37
|
Terminal.dispose(id)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export const name = 'Terminal'
|
|
41
|
+
|
|
40
42
|
export const Commands = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
create: create,
|
|
44
|
+
dispose: dispose,
|
|
45
|
+
resize: resize,
|
|
46
|
+
write: write,
|
|
45
47
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { ChildProcess, fork } from 'node:child_process'
|
|
2
1
|
import exitHook from 'exit-hook'
|
|
3
|
-
import {
|
|
4
|
-
import * as Debug from '../Debug/Debug.js'
|
|
5
|
-
import * as Path from '../Path/Path.js'
|
|
6
|
-
import * as Root from '../Root/Root.js'
|
|
2
|
+
import { ChildProcess, fork } from 'node:child_process'
|
|
7
3
|
import * as Assert from '../Assert/Assert.js'
|
|
4
|
+
import * as Debug from '../Debug/Debug.js'
|
|
5
|
+
import * as PtyHostPath from '../PtyHostPath/PtyHostPath.js'
|
|
8
6
|
|
|
9
7
|
export const state = {
|
|
10
8
|
/**
|
|
@@ -45,8 +43,9 @@ const handleProcessExit = () => {
|
|
|
45
43
|
cleanUpAll()
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
const createPtyHost = () => {
|
|
46
|
+
const createPtyHost = async () => {
|
|
49
47
|
exitHook(handleProcessExit)
|
|
48
|
+
const ptyHostPath = await PtyHostPath.getPtyHostPath()
|
|
50
49
|
const ptyHost = fork(ptyHostPath, { stdio: 'inherit' })
|
|
51
50
|
return ptyHost
|
|
52
51
|
}
|
|
@@ -60,17 +59,16 @@ const createPtyHost = () => {
|
|
|
60
59
|
// })
|
|
61
60
|
// }
|
|
62
61
|
|
|
63
|
-
export const create = (socket, id, cwd) => {
|
|
62
|
+
export const create = async (socket, id, cwd) => {
|
|
64
63
|
Assert.object(socket)
|
|
65
64
|
Assert.number(id)
|
|
66
65
|
Assert.string(cwd)
|
|
67
66
|
|
|
68
|
-
console.log('create terminal')
|
|
69
67
|
Debug.debug('creating pty host')
|
|
70
68
|
switch (state.ptyHostState) {
|
|
71
69
|
case /* None */ 0: {
|
|
72
70
|
state.ptyHostState = /* Creating */ 1
|
|
73
|
-
const ptyHost = createPtyHost()
|
|
71
|
+
const ptyHost = await createPtyHost()
|
|
74
72
|
const handleFirstMessage = () => {
|
|
75
73
|
Debug.debug('pty host ready')
|
|
76
74
|
state.ptyHostState = /* Ready */ 2
|