@lvce-editor/shared-process 0.10.8 → 0.11.1
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-css/src/tokenizeCss.js +3 -0
- 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-shellscript/src/tokenizeShellScript.js +1 -1
- package/extensions/builtin.theme-gruvbox/extension.json +1 -1
- package/extensions/builtin.theme-noctis-uva/extension.json +1 -1
- package/extensions/builtin.theme-slime/color-theme.json +4 -0
- package/package.json +6 -6
- 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/DirentType/DirentType.js +11 -13
- package/src/parts/Download/Download.ipc.js +8 -0
- package/src/parts/EncodingType/EncodingType.js +1 -0
- package/src/parts/Error/FileNotFoundError.js +2 -2
- package/src/parts/{FileSystemErrorCodes/FileSystemErrorCodes.js → ErrorCodes/ErrorCodes.js} +0 -0
- package/src/parts/ExportStatic/ExportStatic.js +8 -2
- package/src/parts/ExtensionHostHelperProcessIpc/ExtensionHostHelperProcessIpc.js +51 -0
- package/src/parts/ExtensionInstallFromUrl/ExtensionInstallFromUrl.js +2 -1
- package/src/parts/ExtensionLink/ExtensionLink.js +2 -2
- package/src/parts/ExtensionManifest/ExtensionManifest.js +3 -3
- package/src/parts/ExtensionManifests/ExtensionManifestsFromFolder.js +2 -2
- package/src/parts/FileSystem/FileSystem.ipc.js +16 -14
- package/src/parts/FileSystem/FileSystem.js +23 -11
- 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/ParentIpc/ParentIpc.js +8 -1
- package/src/parts/Platform/Platform.ipc.js +20 -17
- package/src/parts/Platform/Platform.js +34 -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
|
}
|
|
@@ -190,6 +190,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
190
190
|
} else if ((next = part.match(RE_SELECTOR))) {
|
|
191
191
|
token = TokenType.CssSelector
|
|
192
192
|
state = State.AfterSelector
|
|
193
|
+
} else if ((next = part.match(RE_SELECTOR_ID))) {
|
|
194
|
+
token = TokenType.CssSelectorId
|
|
195
|
+
state = State.AfterSelector
|
|
193
196
|
} else if ((next = part.match(RE_COMMA))) {
|
|
194
197
|
token = TokenType.Punctuation
|
|
195
198
|
state = State.AfterSelector
|
|
@@ -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,
|
|
@@ -57,7 +57,7 @@ const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"]+/
|
|
|
57
57
|
const RE_KEYWORD =
|
|
58
58
|
/^(?:alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|dirs|disown|echo|enable|eval|exec|exit|false|fc|fg|getopts|hash|help|history|jobs|kill|let|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|times|trap|true|type|ulimit|umask|unalias|unset|wait)\b/
|
|
59
59
|
|
|
60
|
-
const RE_VARIABLE_NAME = /^[a-zA-Z\_]+/
|
|
60
|
+
const RE_VARIABLE_NAME = /^[a-zA-Z\_\/\-]+/
|
|
61
61
|
const RE_PUNCTUATION = /^[:,;\{\}\[\]\.=\(\)<>]/
|
|
62
62
|
const RE_NUMERIC = /^\d+/
|
|
63
63
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Utility package for @lvce-editor/server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,12 +20,12 @@
|
|
|
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.1",
|
|
24
|
+
"@lvce-editor/pty-host": "0.11.1",
|
|
25
25
|
"debug": "^4.3.4",
|
|
26
26
|
"execa": "^6.1.0",
|
|
27
27
|
"exit-hook": "^3.1.2",
|
|
28
|
-
"got": "^12.5.
|
|
28
|
+
"got": "^12.5.3",
|
|
29
29
|
"is-object": "^1.0.2",
|
|
30
30
|
"lines-and-columns": "^2.0.3",
|
|
31
31
|
"open": "^8.4.0",
|
|
@@ -36,13 +36,13 @@
|
|
|
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": {
|
|
43
43
|
"electron-clipboard-ex": "^1.3.3",
|
|
44
44
|
"keytar": "^7.9.0",
|
|
45
|
-
"vscode-ripgrep-with-github-api-error-fix": "^2.
|
|
45
|
+
"vscode-ripgrep-with-github-api-error-fix": "^2.6.0",
|
|
46
46
|
"extract-zip": "^2.0.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -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 ErrorCodes from '../ErrorCodes/ErrorCodes.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 === ErrorCodes.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
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
export const Socket =
|
|
8
|
-
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
export const Unknown = 'unknown'
|
|
1
|
+
export const BlockDevice = 1
|
|
2
|
+
export const CharacterDevice = 2
|
|
3
|
+
export const Directory = 3
|
|
4
|
+
export const DirectoryExpanded = 4
|
|
5
|
+
export const DirectoryExpanding = 5
|
|
6
|
+
export const File = 6
|
|
7
|
+
export const Socket = 7
|
|
8
|
+
export const Symlink = 8
|
|
9
|
+
export const SymLinkFile = 9
|
|
10
|
+
export const SymLinkFolder = 10
|
|
11
|
+
export const Unknown = 11
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const Utf8 = 'utf8'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import VError from 'verror'
|
|
2
|
-
import * as
|
|
2
|
+
import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
|
|
3
3
|
|
|
4
4
|
export class FileNotFoundError extends VError {
|
|
5
5
|
constructor(path) {
|
|
6
6
|
super(`File not found '${path}'`)
|
|
7
7
|
this.name = 'FileNotFoundError'
|
|
8
|
-
this.code =
|
|
8
|
+
this.code = ErrorCodes.ENOENT
|
|
9
9
|
}
|
|
10
10
|
}
|
|
File without changes
|
|
@@ -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
|
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as ChildProcess from '../ChildProcess/ChildProcess.js'
|
|
2
|
+
import * as Platform from '../Platform/Platform.js'
|
|
3
|
+
|
|
4
|
+
export const create = () => {
|
|
5
|
+
const extensionHostHelperProcessPath =
|
|
6
|
+
Platform.getExtensionHostHelperProcessPath()
|
|
7
|
+
const childProcess = ChildProcess.fork(
|
|
8
|
+
extensionHostHelperProcessPath,
|
|
9
|
+
['--ipc-type=websocket', '--max-old-space-size=60', '--enable-source-maps'],
|
|
10
|
+
{}
|
|
11
|
+
)
|
|
12
|
+
return {
|
|
13
|
+
on(event, listener) {
|
|
14
|
+
switch (event) {
|
|
15
|
+
case 'message':
|
|
16
|
+
childProcess.on('message', listener)
|
|
17
|
+
break
|
|
18
|
+
case 'error':
|
|
19
|
+
childProcess.on('error', listener)
|
|
20
|
+
break
|
|
21
|
+
case 'exit':
|
|
22
|
+
childProcess.on('exit', listener)
|
|
23
|
+
break
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(`unsupported event type ${event}`)
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
off(event, listener) {
|
|
29
|
+
switch (event) {
|
|
30
|
+
case 'message':
|
|
31
|
+
childProcess.off('message', listener)
|
|
32
|
+
break
|
|
33
|
+
case 'error':
|
|
34
|
+
childProcess.off('error', listener)
|
|
35
|
+
break
|
|
36
|
+
case 'exit':
|
|
37
|
+
childProcess.off('exit', listener)
|
|
38
|
+
break
|
|
39
|
+
default:
|
|
40
|
+
throw new Error(`unsupported event type ${event}`)
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
send(message) {
|
|
44
|
+
childProcess.send(message)
|
|
45
|
+
},
|
|
46
|
+
dispose() {
|
|
47
|
+
childProcess.kill()
|
|
48
|
+
},
|
|
49
|
+
_process: childProcess,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -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) {
|
|
@@ -2,7 +2,7 @@ import VError from 'verror'
|
|
|
2
2
|
import * as ExtensionManifest from '../ExtensionManifest/ExtensionManifest.js'
|
|
3
3
|
import * as ExtensionManifestStatus from '../ExtensionManifestStatus/ExtensionManifestStatus.js'
|
|
4
4
|
import * as FileSystem from '../FileSystem/FileSystem.js'
|
|
5
|
-
import * as
|
|
5
|
+
import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
|
|
6
6
|
import * as Path from '../Path/Path.js'
|
|
7
7
|
import * as Platform from '../Platform/Platform.js'
|
|
8
8
|
import * as SymLink from '../SymLink/SymLink.js'
|
|
@@ -35,7 +35,7 @@ export const link = async (path) => {
|
|
|
35
35
|
const to = Path.join(linkedExtensionsPath, manifest.id)
|
|
36
36
|
await SymLink.createSymLink(path, to)
|
|
37
37
|
} catch (error) {
|
|
38
|
-
if (error && error.code ===
|
|
38
|
+
if (error && error.code === ErrorCodes.EEXIST) {
|
|
39
39
|
return linkFallBack(path)
|
|
40
40
|
}
|
|
41
41
|
throw new VError(error, `Failed to link extension`)
|
|
@@ -3,7 +3,7 @@ import VError from 'verror'
|
|
|
3
3
|
import * as ExtensionManifestStatus from '../ExtensionManifestStatus/ExtensionManifestStatus.js'
|
|
4
4
|
import * as ReadJson from '../JsonFile/JsonFile.js'
|
|
5
5
|
import * as Path from '../Path/Path.js'
|
|
6
|
-
import * as
|
|
6
|
+
import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
|
|
7
7
|
|
|
8
8
|
const RE_EXTENSION_FRAGMENT = /.+(\/|\\)(.+)$/
|
|
9
9
|
|
|
@@ -35,9 +35,9 @@ export const get = async (path) => {
|
|
|
35
35
|
error,
|
|
36
36
|
`Failed to load extension manifest for ${id}`
|
|
37
37
|
)
|
|
38
|
-
if (error.code ===
|
|
38
|
+
if (error.code === ErrorCodes.ENOENT) {
|
|
39
39
|
// @ts-ignore
|
|
40
|
-
enhancedError.code =
|
|
40
|
+
enhancedError.code = ErrorCodes.E_MANIFEST_NOT_FOUND
|
|
41
41
|
} else {
|
|
42
42
|
// @ts-ignore
|
|
43
43
|
enhancedError.code = error.code
|
|
@@ -2,7 +2,7 @@ import VError from 'verror'
|
|
|
2
2
|
import * as ExtensionManifest from '../ExtensionManifest/ExtensionManifest.js'
|
|
3
3
|
import * as FileSystem from '../FileSystem/FileSystem.js'
|
|
4
4
|
import * as Path from '../Path/Path.js'
|
|
5
|
-
import * as
|
|
5
|
+
import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
|
|
6
6
|
|
|
7
7
|
const toAbsolutePaths = (path, dirents) => {
|
|
8
8
|
const absolutePaths = []
|
|
@@ -26,7 +26,7 @@ export const getExtensionManifests = async (path) => {
|
|
|
26
26
|
} catch (error) {
|
|
27
27
|
// TODO how to make typescript happy?
|
|
28
28
|
// @ts-ignore
|
|
29
|
-
if (error.code ===
|
|
29
|
+
if (error.code === ErrorCodes.ENOENT) {
|
|
30
30
|
return []
|
|
31
31
|
}
|
|
32
32
|
throw new VError(error, 'Failed to get extension manifests')
|
|
@@ -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 ErrorCodes from '../ErrorCodes/ErrorCodes.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,18 +34,25 @@ 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}`)
|
|
45
53
|
return content
|
|
46
54
|
} catch (error) {
|
|
47
|
-
if (error && error.code ===
|
|
55
|
+
if (error && error.code === ErrorCodes.ENOENT) {
|
|
48
56
|
throw new FileNotFoundError(path)
|
|
49
57
|
}
|
|
50
58
|
throw new VError(error, `Failed to read file "${path}"`)
|
|
@@ -57,13 +65,17 @@ 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}`, () =>
|
|
64
76
|
await fs.writeFile(path, content, encoding)
|
|
65
77
|
} catch (error) {
|
|
66
|
-
if (error && error.code ===
|
|
78
|
+
if (error && error.code === ErrorCodes.ENOENT) {
|
|
67
79
|
throw new FileNotFoundError(path)
|
|
68
80
|
}
|
|
69
81
|
throw new VError(error, `Failed to write to file "${path}"`)
|
|
@@ -140,7 +152,7 @@ const getType = (dirent) => {
|
|
|
140
152
|
return DirentType.File
|
|
141
153
|
}
|
|
142
154
|
if (dirent.isDirectory()) {
|
|
143
|
-
return DirentType.
|
|
155
|
+
return DirentType.Directory
|
|
144
156
|
}
|
|
145
157
|
if (dirent.isSymbolicLink()) {
|
|
146
158
|
return DirentType.Symlink
|
|
@@ -182,7 +194,7 @@ export const readDir = async (path) => {
|
|
|
182
194
|
const dirents = await fs.readdir(path)
|
|
183
195
|
return dirents
|
|
184
196
|
} catch (error) {
|
|
185
|
-
if (error && error.code ===
|
|
197
|
+
if (error && error.code === ErrorCodes.ENOENT) {
|
|
186
198
|
throw new FileNotFoundError(path)
|
|
187
199
|
}
|
|
188
200
|
throw new VError(error, `Failed to read directory "${path}"`)
|
|
@@ -210,7 +222,7 @@ export const rename = async (oldPath, newPath) => {
|
|
|
210
222
|
try {
|
|
211
223
|
await fs.rename(oldPath, newPath)
|
|
212
224
|
} catch (error) {
|
|
213
|
-
if (error && error.code ===
|
|
225
|
+
if (error && error.code === ErrorCodes.EXDEV) {
|
|
214
226
|
return fallbackRename(oldPath, newPath)
|
|
215
227
|
}
|
|
216
228
|
throw new VError(error, `Failed to rename "${oldPath}" to "${newPath}"`)
|
|
@@ -246,7 +258,7 @@ export const getRealPath = async (path) => {
|
|
|
246
258
|
error &&
|
|
247
259
|
error instanceof globalThis.Error &&
|
|
248
260
|
// @ts-ignore
|
|
249
|
-
error.code ===
|
|
261
|
+
error.code === ErrorCodes.ENOENT
|
|
250
262
|
) {
|
|
251
263
|
let content
|
|
252
264
|
try {
|
|
@@ -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':
|
|
@@ -8,6 +8,7 @@ import { requiresSocket } from '../RequiresSocket/RequiresSocket.js'
|
|
|
8
8
|
import * as Platform from '../Platform/Platform.js'
|
|
9
9
|
import * as ExtensionHostIpc from '../ExtensionHostIpc/ExtensionHostIpc.js'
|
|
10
10
|
import * as ExtensionHostRpc from '../ExtensionHostRpc/ExtensionHostRpc.js'
|
|
11
|
+
import * as ExtensionHostHelperProcessIpc from '../ExtensionHostHelperProcessIpc/ExtensionHostHelperProcessIpc.js'
|
|
11
12
|
// TODO add tests for this
|
|
12
13
|
|
|
13
14
|
// TODO handle structure: one shared process multiple extension hosts
|
|
@@ -61,6 +62,11 @@ const handleWebSocketExtensionHost = async (message, handle) => {
|
|
|
61
62
|
// console.log(rpc)
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
const handleWebSocketExtensionHostHelperProcess = (message, handle) => {
|
|
66
|
+
const ipc = ExtensionHostHelperProcessIpc.create()
|
|
67
|
+
ipc._process.send(message, handle)
|
|
68
|
+
}
|
|
69
|
+
|
|
64
70
|
const handleWebSocket = (message, handle) => {
|
|
65
71
|
const headers = message.headers
|
|
66
72
|
if (!headers) {
|
|
@@ -75,6 +81,8 @@ const handleWebSocket = (message, handle) => {
|
|
|
75
81
|
return handleWebSocketSharedProcess(message, handle)
|
|
76
82
|
case 'lvce.extension-host':
|
|
77
83
|
return handleWebSocketExtensionHost(message, handle)
|
|
84
|
+
case 'lvce.extension-host-helper-process':
|
|
85
|
+
return handleWebSocketExtensionHostHelperProcess(message, handle)
|
|
78
86
|
default:
|
|
79
87
|
throw new VError(`unsupported sec-websocket-procotol ${protocol}`)
|
|
80
88
|
}
|
|
@@ -209,7 +217,6 @@ const electronInitialize = (initializeMessage) => {
|
|
|
209
217
|
},
|
|
210
218
|
})
|
|
211
219
|
}
|
|
212
|
-
|
|
213
220
|
}
|
|
214
221
|
} else {
|
|
215
222
|
Command.execute(message.method, fakeSocket, ...message.params)
|
|
@@ -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 ''
|
|
@@ -99,6 +101,16 @@ export const getExtensionHostPath = () => {
|
|
|
99
101
|
return extensionHostPath
|
|
100
102
|
}
|
|
101
103
|
|
|
104
|
+
export const getExtensionHostHelperProcessPath = () => {
|
|
105
|
+
return Path.join(
|
|
106
|
+
Root.root,
|
|
107
|
+
'packages',
|
|
108
|
+
'extension-host-helper-process',
|
|
109
|
+
'src',
|
|
110
|
+
'extensionHostHelperProcessMain.js'
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
102
114
|
export const getRecentlyOpenedPath = () => {
|
|
103
115
|
return Path.join(cacheDir, 'recently-opened.json')
|
|
104
116
|
}
|
|
@@ -108,17 +120,15 @@ export const getDefaultSettingsPath = () => {
|
|
|
108
120
|
}
|
|
109
121
|
export const setEnvironmentVariables = (variables) => {
|
|
110
122
|
for (const [key, value] of Object.entries(variables)) {
|
|
111
|
-
|
|
123
|
+
env[key] = value
|
|
112
124
|
}
|
|
113
125
|
}
|
|
114
126
|
|
|
115
127
|
export const getTestPath = () => {
|
|
116
|
-
if (
|
|
128
|
+
if (env.TEST_PATH) {
|
|
117
129
|
const testPath =
|
|
118
130
|
'/remote' +
|
|
119
|
-
pathToFileURL(Path.join(process.cwd(),
|
|
120
|
-
.toString()
|
|
121
|
-
.slice(7)
|
|
131
|
+
pathToFileURL(Path.join(process.cwd(), env.TEST_PATH)).toString().slice(7)
|
|
122
132
|
return testPath
|
|
123
133
|
}
|
|
124
134
|
return '/packages/extension-host-worker-tests'
|
|
@@ -133,7 +143,7 @@ export const getTmpDir = () => {
|
|
|
133
143
|
}
|
|
134
144
|
|
|
135
145
|
export const getOnlyExtensionPath = () => {
|
|
136
|
-
const onlyExtensionPath =
|
|
146
|
+
const onlyExtensionPath = env.ONLY_EXTENSION
|
|
137
147
|
if (onlyExtensionPath) {
|
|
138
148
|
return resolve(onlyExtensionPath)
|
|
139
149
|
}
|
|
@@ -159,3 +169,8 @@ export const getDataDir = () => {
|
|
|
159
169
|
export const getHomeDir = () => {
|
|
160
170
|
return homeDir
|
|
161
171
|
}
|
|
172
|
+
|
|
173
|
+
export const getDownloadDir = () => {
|
|
174
|
+
const { XDG_DOWNLOAD_DIR } = env
|
|
175
|
+
return XDG_DOWNLOAD_DIR || join(homeDir, 'Downloads')
|
|
176
|
+
}
|
|
@@ -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
|