@lvce-editor/shared-process 0.0.27 → 0.0.30
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/builtinCommands.json +103 -87
- package/config/defaultKeyBindings.json +18 -18
- package/config/defaultSettings.json +3 -1
- package/index.js +2 -2
- package/package.json +13 -10
- package/src/parts/Assert/Assert.js +12 -5
- package/src/parts/ChildProcess/ChildProcessWithFork.js +19 -0
- package/src/parts/ClipBoard/ClipBoard.ipc.js +3 -4
- package/src/parts/Command/Command.js +30 -17
- package/src/parts/Credentials/Credentials.ipc.js +6 -7
- package/src/parts/Developer/Developer.ipc.js +10 -17
- package/src/parts/Electron/Electron.ipc.js +15 -16
- package/src/parts/Electron/Electron.js +43 -34
- package/src/parts/ExtensionHost/ExtensionHost.ipc.js +15 -72
- package/src/parts/ExtensionHost/ExtensionHost.js +59 -138
- package/src/parts/ExtensionHostIpc/ExtensionHostIpc.js +5 -0
- package/src/parts/ExtensionHostIpc/ExtensionHostIpcWithChildProcess.js +57 -0
- package/src/parts/ExtensionHostIpc/ExtensionHostIpcWithWorker.js +38 -0
- package/src/parts/ExtensionHostRpc/ExtensionHostRpc.js +82 -0
- package/src/parts/ExtensionManagement/ExtensionManagement.ipc.js +16 -8
- package/src/parts/ExtensionManagement/ExtensionManagement.js +5 -2
- package/src/parts/{ExtensionHost/ExtensionHostColorTheme.js → ExtensionManagement/ExtensionManagementColorTheme.js} +1 -1
- package/src/parts/{ExtensionHost/ExtensionHostIconTheme.js → ExtensionManagement/ExtensionManagementIconTheme.js} +1 -1
- package/src/parts/{ExtensionHost/ExtensionHostLanguages.js → ExtensionManagement/ExtensionManagementLanguages.js} +1 -1
- package/src/parts/FileSystem/FileSystem.ipc.js +14 -15
- package/src/parts/FileSystem/FileSystem.js +56 -1
- package/src/parts/JsonRpc/JsonRpc.js +2 -2
- package/src/parts/Native/Native.ipc.js +2 -3
- package/src/parts/OutputChannel/OutputChannel.ipc.js +16 -19
- package/src/parts/ParentIpc/ParentIpc.js +93 -44
- package/src/parts/Platform/Platform.ipc.js +15 -17
- package/src/parts/Platform/Platform.js +1 -1
- package/src/parts/Preferences/Preferences.ipc.js +2 -3
- package/src/parts/PrettyError/PrettyError.js +5 -2
- package/src/parts/Process/Process.ipc.js +3 -4
- package/src/parts/RequiresSocket/RequiresSocket.js +6 -5
- package/src/parts/Search/Search.ipc.js +2 -3
- package/src/parts/SearchFile/SearchFile.ipc.js +2 -3
- package/src/parts/Stats/Stats.js +5 -5
- package/src/parts/Terminal/Terminal.ipc.js +9 -9
- package/src/parts/Terminal/Terminal.js +1 -1
- package/src/parts/TextDocument/TextDocument.ipc.js +2 -3
- package/src/parts/Timeout/Timeout.js +7 -0
- package/src/parts/WebSocketServer/WebSocketServer.ipc.js +2 -3
- package/src/parts/Workspace/Workspace.ipc.js +3 -4
- package/src/sharedProcessMain.js +13 -9
- package/src/parts/Extension/Extension.js +0 -7
- package/src/parts/ExtensionHost/ExtensionHostBraceCompletion.js +0 -14
- package/src/parts/ExtensionHost/ExtensionHostClosingTag.js +0 -14
- package/src/parts/ExtensionHost/ExtensionHostCommand.js +0 -19
- package/src/parts/ExtensionHost/ExtensionHostCompletion.js +0 -12
- package/src/parts/ExtensionHost/ExtensionHostDefinition.js +0 -12
- package/src/parts/ExtensionHost/ExtensionHostDiagnostic.js +0 -7
- package/src/parts/ExtensionHost/ExtensionHostFileSystem.js +0 -23
- package/src/parts/ExtensionHost/ExtensionHostFormatting.js +0 -4
- package/src/parts/ExtensionHost/ExtensionHostHover.js +0 -12
- package/src/parts/ExtensionHost/ExtensionHostImplementation.js +0 -12
- package/src/parts/ExtensionHost/ExtensionHostManagement.js +0 -26
- package/src/parts/ExtensionHost/ExtensionHostOutput.js +0 -3
- package/src/parts/ExtensionHost/ExtensionHostQuickPick.js +0 -6
- package/src/parts/ExtensionHost/ExtensionHostReference.js +0 -12
- package/src/parts/ExtensionHost/ExtensionHostRename.js +0 -27
- package/src/parts/ExtensionHost/ExtensionHostSemanticTokens.js +0 -10
- package/src/parts/ExtensionHost/ExtensionHostSourceControl.js +0 -15
- package/src/parts/ExtensionHost/ExtensionHostStats.js +0 -3
- package/src/parts/ExtensionHost/ExtensionHostStatusBar.js +0 -7
- package/src/parts/ExtensionHost/ExtensionHostTabCompletion.js +0 -12
- package/src/parts/ExtensionHost/ExtensionHostTextDocument.js +0 -35
- package/src/parts/ExtensionHost/ExtensionHostTypeDefinition.js +0 -12
- package/src/parts/ExtensionHost/ExtensionHostWorkspace.js +0 -3
|
@@ -3,14 +3,14 @@ import * as Command from '../Command/Command.js'
|
|
|
3
3
|
import * as OutputChannel from './OutputChannel.js'
|
|
4
4
|
|
|
5
5
|
export const state = {
|
|
6
|
-
outputChannels: Object.create(null)
|
|
6
|
+
outputChannels: Object.create(null),
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const open = (socket, id, path) => {
|
|
10
|
-
console.log({path})
|
|
10
|
+
console.log({ path })
|
|
11
11
|
Assert.object(socket)
|
|
12
12
|
// Assert.string(id)
|
|
13
|
-
Assert.string(path
|
|
13
|
+
Assert.string(path)
|
|
14
14
|
if (!socket) {
|
|
15
15
|
console.warn('socket not available')
|
|
16
16
|
return
|
|
@@ -20,22 +20,19 @@ const open = (socket, id, path) => {
|
|
|
20
20
|
}
|
|
21
21
|
const onData = (data) => {
|
|
22
22
|
console.log('send data', data)
|
|
23
|
-
socket.send(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
)
|
|
23
|
+
socket.send({
|
|
24
|
+
jsonrpc: '2.0',
|
|
25
|
+
method: 2133,
|
|
26
|
+
params: ['Output', 'handleData', data],
|
|
27
|
+
})
|
|
30
28
|
}
|
|
31
29
|
const onError = (error) => {
|
|
32
30
|
console.info(`[shared process] output channel error: ${error}`)
|
|
33
|
-
socket.send(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
31
|
+
socket.send({
|
|
32
|
+
jsonrpc: '2.0',
|
|
33
|
+
method: 2133,
|
|
34
|
+
params: ['Output', 'handleError', error],
|
|
35
|
+
})
|
|
39
36
|
}
|
|
40
37
|
state.outputChannels[id] = OutputChannel.open(path, onData, onError)
|
|
41
38
|
}
|
|
@@ -45,7 +42,7 @@ const close = (socket, id) => {
|
|
|
45
42
|
delete state.outputChannels[id]
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
export const
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
export const Commands = {
|
|
46
|
+
'OutputChannel.open': open,
|
|
47
|
+
'OutputChannel.close': close,
|
|
51
48
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { MessagePort, parentPort } from 'node:worker_threads'
|
|
2
|
+
import VError from 'verror'
|
|
2
3
|
import * as Callback from '../Callback/Callback.js'
|
|
3
4
|
import * as Command from '../Command/Command.js'
|
|
4
5
|
import * as Debug from '../Debug/Debug.js'
|
|
5
6
|
import * as Error from '../Error/Error.js'
|
|
6
7
|
import { requiresSocket } from '../RequiresSocket/RequiresSocket.js'
|
|
7
|
-
|
|
8
|
+
import * as Platform from '../Platform/Platform.js'
|
|
9
|
+
import * as ExtensionHostIpc from '../ExtensionHostIpc/ExtensionHostIpc.js'
|
|
10
|
+
import * as ExtensionHostRpc from '../ExtensionHostRpc/ExtensionHostRpc.js'
|
|
8
11
|
// TODO add tests for this
|
|
9
12
|
|
|
10
13
|
// TODO handle structure: one shared process multiple extension hosts
|
|
@@ -30,53 +33,99 @@ export const electronSend = (message) => {
|
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
36
|
+
const handleWebSocketSharedProcess = (message, handle) => {
|
|
37
|
+
// TODO when it is an extension host websocket, spawn extension host
|
|
38
|
+
handle.on('error', (error) => {
|
|
39
|
+
if (error && error.code === 'ECONNRESET') {
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
console.info('[info shared process: handle error]', error)
|
|
43
|
+
})
|
|
44
|
+
Command.execute(
|
|
45
|
+
/* WebSocketServer.handleUpgrade */ 5621,
|
|
46
|
+
/* message */ message,
|
|
47
|
+
/* handle */ handle
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// TODO lazyload modules for spawning extension host, they are only needed later
|
|
52
|
+
const handleWebSocketExtensionHost = async (message, handle) => {
|
|
53
|
+
// console.log('[shared-process] received extension host websocket', message)
|
|
54
|
+
const ipc = ExtensionHostIpc.create()
|
|
55
|
+
console.info('[sharedprocess] creating extension ipc')
|
|
56
|
+
const rpc = await ExtensionHostRpc.create(ipc, handle)
|
|
57
|
+
console.info('[sharedprocess] created extension host rpc')
|
|
58
|
+
ipc._process.send(message, handle)
|
|
59
|
+
// rpc.send(message)
|
|
60
|
+
// console.log('spawned extension host')
|
|
61
|
+
// console.log(rpc)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const handleWebSocket = (message, handle) => {
|
|
65
|
+
const headers = message.headers
|
|
66
|
+
if (!headers) {
|
|
67
|
+
throw new VError('missing websocket headers')
|
|
68
|
+
}
|
|
69
|
+
const protocol = headers['sec-websocket-protocol']
|
|
70
|
+
if (!protocol) {
|
|
71
|
+
throw new VError('missing sec websocket protocol header')
|
|
72
|
+
}
|
|
73
|
+
switch (protocol) {
|
|
74
|
+
case 'lvce.shared-process':
|
|
75
|
+
return handleWebSocketSharedProcess(message, handle)
|
|
76
|
+
case 'lvce.extension-host':
|
|
77
|
+
return handleWebSocketExtensionHost(message, handle)
|
|
78
|
+
default:
|
|
79
|
+
throw new VError(`unsupported sec-websocket-procotol ${protocol}`)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const handleJsonRpcResult = (message) => {
|
|
84
|
+
Callback.resolve(message.id, message.result)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const handleJsonRpcMessage = async (message, handle) => {
|
|
88
|
+
if (message.id) {
|
|
89
|
+
try {
|
|
90
|
+
const result = requiresSocket(message.method)
|
|
91
|
+
? await Command.invoke(message.method, handle, ...message.params)
|
|
92
|
+
: await Command.invoke(message.method, ...message.params)
|
|
93
|
+
electronSend({
|
|
94
|
+
jsonrpc: '2.0',
|
|
95
|
+
id: message.id,
|
|
96
|
+
result: result ?? null,
|
|
97
|
+
})
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error('[shared process] command failed to execute')
|
|
100
|
+
console.error(error)
|
|
101
|
+
electronSend({
|
|
102
|
+
jsonrpc: '2.0',
|
|
103
|
+
code: /* ExpectedError */ -32000,
|
|
104
|
+
id: message.id,
|
|
105
|
+
error: 'ExpectedError',
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
data: error.toString(),
|
|
108
|
+
})
|
|
74
109
|
}
|
|
75
110
|
} else {
|
|
76
|
-
|
|
111
|
+
// TODO handle error
|
|
112
|
+
Command.execute(message.method, null, ...message.params)
|
|
77
113
|
}
|
|
78
114
|
}
|
|
79
115
|
|
|
116
|
+
const handleMessageFromParentProcess = async (message, handle) => {
|
|
117
|
+
if (handle) {
|
|
118
|
+
return handleWebSocket(message, handle)
|
|
119
|
+
}
|
|
120
|
+
if (message.result) {
|
|
121
|
+
return handleJsonRpcResult(message)
|
|
122
|
+
}
|
|
123
|
+
if (message.method) {
|
|
124
|
+
return handleJsonRpcMessage(message, handle)
|
|
125
|
+
}
|
|
126
|
+
console.warn('unknown message', message)
|
|
127
|
+
}
|
|
128
|
+
|
|
80
129
|
/**
|
|
81
130
|
*
|
|
82
131
|
* @param {{initialize:{port: MessagePort, folder:string}}} initializeMessage
|
|
@@ -160,7 +209,7 @@ const electronInitialize = (initializeMessage) => {
|
|
|
160
209
|
},
|
|
161
210
|
})
|
|
162
211
|
}
|
|
163
|
-
|
|
212
|
+
|
|
164
213
|
}
|
|
165
214
|
} else {
|
|
166
215
|
Command.execute(message.method, fakeSocket, ...message.params)
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import * as Command from '../Command/Command.js'
|
|
2
1
|
import * as Platform from '../Platform/Platform.js'
|
|
3
2
|
|
|
4
3
|
// prettier-ignore
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Command.register('Platform.setEnvironmentVariables', Platform.setEnvironmentVariables)
|
|
4
|
+
export const Commands = {
|
|
5
|
+
'Platform.getConfigDir': Platform.getConfigDir,
|
|
6
|
+
'Platform.getAppDir': Platform.getAppDir,
|
|
7
|
+
'Platform.getHomeDir': Platform.getHomeDir,
|
|
8
|
+
'Platform.getDataDir': Platform.getDataDir,
|
|
9
|
+
'Platform.getExtensionsPath': Platform.getExtensionsPath,
|
|
10
|
+
'Platform.getBuiltinExtensionsPath': Platform.getBuiltinExtensionsPath,
|
|
11
|
+
'Platform.getDisabledExtensionsPath': Platform.getDisabledExtensionsPath,
|
|
12
|
+
'Platform.getCachedExtensionsPath': Platform.getCachedExtensionsPath,
|
|
13
|
+
'Platform.getMarketplaceUrl': Platform.getMarketplaceUrl,
|
|
14
|
+
'Platform.getLogsDir': Platform.getLogsDir,
|
|
15
|
+
'Platform.getUserSettingsPath': Platform.getUserSettingsPath,
|
|
16
|
+
'Platform.getRecentlyOpenedPath': Platform.getRecentlyOpenedPath,
|
|
17
|
+
'Platform.getCacheDir': Platform.getCacheDir,
|
|
18
|
+
'Platform.setEnvironmentVariables': Platform.setEnvironmentVariables,
|
|
21
19
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { extensionHostPath } from '@lvce-editor/extension-host'
|
|
2
1
|
import { homedir, tmpdir } from 'node:os'
|
|
3
2
|
import { sep } from 'node:path'
|
|
3
|
+
import { extensionHostPath } from '@lvce-editor/extension-host'
|
|
4
4
|
import { xdgCache, xdgConfig, xdgData, xdgState } from 'xdg-basedir'
|
|
5
5
|
import * as Path from '../Path/Path.js'
|
|
6
6
|
import * as Root from '../Root/Root.js'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import * as Command from '../Command/Command.js'
|
|
2
1
|
import * as Preferences from '../Preferences/Preferences.js'
|
|
3
2
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
3
|
+
export const Commands = {
|
|
4
|
+
'Preferences.getAll': Preferences.getAll,
|
|
6
5
|
}
|
|
@@ -13,8 +13,11 @@ const getActualPath = (fileUri) => {
|
|
|
13
13
|
|
|
14
14
|
export const prepare = (error) => {
|
|
15
15
|
const message = error.message
|
|
16
|
-
if (error.cause) {
|
|
17
|
-
|
|
16
|
+
if (error && error.cause) {
|
|
17
|
+
const cause = error.cause()
|
|
18
|
+
if (cause) {
|
|
19
|
+
error = cause
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
const cleanedStack = cleanStack(error.stack)
|
|
20
23
|
const lines = cleanedStack.split('\n')
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import * as Command from '../Command/Command.js'
|
|
2
1
|
import * as Process from './Process.js'
|
|
3
2
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export const Commands = {
|
|
4
|
+
555: Process.crash,
|
|
5
|
+
556: Process.crashAsync,
|
|
7
6
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// TODO find a better way to do this
|
|
2
2
|
// most commands don't require sockets
|
|
3
3
|
// but output channel and terminal need to continuously send data through the socket
|
|
4
|
-
const METHODS_THAT_REQUIRE_SOCKET = [
|
|
5
|
-
'OutputChannel.open',
|
|
6
|
-
'ExtensionHost.start',
|
|
7
|
-
|
|
4
|
+
const METHODS_THAT_REQUIRE_SOCKET = new Set([
|
|
5
|
+
'OutputChannel.open',
|
|
6
|
+
'ExtensionHost.start',
|
|
7
|
+
'ExtensionHost.send',
|
|
8
|
+
])
|
|
8
9
|
|
|
9
10
|
export const requiresSocket = (method) => {
|
|
10
|
-
return METHODS_THAT_REQUIRE_SOCKET.
|
|
11
|
+
return METHODS_THAT_REQUIRE_SOCKET.has(method)
|
|
11
12
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import * as Command from '../Command/Command.js'
|
|
2
1
|
import * as SearchFile from './SearchFile.js'
|
|
3
2
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
3
|
+
export const Commands = {
|
|
4
|
+
'SearchFile.searchFile': SearchFile.searchFile,
|
|
6
5
|
}
|
package/src/parts/Stats/Stats.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
import * as Exec from '../Exec/Exec.js'
|
|
4
4
|
|
|
5
5
|
const PID_CMD =
|
|
6
|
-
/^\s*(
|
|
6
|
+
/^\s*(\d+)\s+(\d+)\s+(\d+\.\d+)\s+(\d+\.\d+)\s+(.+)$/
|
|
7
7
|
|
|
8
8
|
const parsePsOutputLine = (line) => {
|
|
9
9
|
const matches = PID_CMD.exec(line.trim())
|
|
10
10
|
if (matches && matches.length === 6) {
|
|
11
11
|
return {
|
|
12
|
-
pid: parseInt(matches[1]),
|
|
13
|
-
ppid: parseInt(matches[2]),
|
|
12
|
+
pid: Number.parseInt(matches[1]),
|
|
13
|
+
ppid: Number.parseInt(matches[2]),
|
|
14
14
|
cwd: matches[5],
|
|
15
|
-
load: parseInt(matches[3]),
|
|
16
|
-
mem: parseInt(matches[4]),
|
|
15
|
+
load: Number.parseInt(matches[3]),
|
|
16
|
+
mem: Number.parseInt(matches[4]),
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as Command from '../Command/Command.js'
|
|
2
|
-
import * as Terminal from './Terminal.js'
|
|
3
2
|
import * as Assert from '../Assert/Assert.js'
|
|
3
|
+
import * as Terminal from './Terminal.js'
|
|
4
4
|
|
|
5
5
|
const create = (socket, id, cwd) => {
|
|
6
6
|
Assert.object(socket)
|
|
7
7
|
if (!socket) {
|
|
8
|
-
console.log({socket, id, cwd})
|
|
8
|
+
console.log({ socket, id, cwd })
|
|
9
9
|
console.warn('socket not available')
|
|
10
10
|
return
|
|
11
11
|
}
|
|
@@ -24,8 +24,8 @@ const create = (socket, id, cwd) => {
|
|
|
24
24
|
Terminal.create(socket, id, cwd)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const write = (
|
|
28
|
-
console.log({ id, input})
|
|
27
|
+
const write = (id, input) => {
|
|
28
|
+
console.log({ id, input })
|
|
29
29
|
Terminal.write(id, input)
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -37,9 +37,9 @@ const dispose = (socket, id) => {
|
|
|
37
37
|
Terminal.dispose(id)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
export const Commands = {
|
|
41
|
+
'Terminal.create': create,
|
|
42
|
+
'Terminal.dispose': dispose,
|
|
43
|
+
'Terminal.write': write,
|
|
44
|
+
'Terminal.resize': resize,
|
|
45
45
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ChildProcess, fork } from 'node:child_process'
|
|
2
2
|
import exitHook from 'exit-hook'
|
|
3
|
+
import { ptyHostPath } from '@lvce-editor/pty-host'
|
|
3
4
|
import * as Debug from '../Debug/Debug.js'
|
|
4
5
|
import * as Path from '../Path/Path.js'
|
|
5
6
|
import * as Root from '../Root/Root.js'
|
|
6
7
|
import * as Assert from '../Assert/Assert.js'
|
|
7
|
-
import { ptyHostPath } from '@lvce-editor/pty-host'
|
|
8
8
|
|
|
9
9
|
export const state = {
|
|
10
10
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import * as Command from '../Command/Command.js'
|
|
2
1
|
import * as WebSocketServer from './WebSocketServer.js'
|
|
3
2
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
3
|
+
export const Commands = {
|
|
4
|
+
5621: WebSocketServer.handleUpgrade,
|
|
6
5
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import * as Command from '../Command/Command.js'
|
|
2
1
|
import * as Workspace from './Workspace.js'
|
|
3
2
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export const Commands = {
|
|
4
|
+
'Workspace.resolveRoot': Workspace.resolveRoot,
|
|
5
|
+
'Workspace.getHomeDir': Workspace.getHomeDir,
|
|
7
6
|
}
|
package/src/sharedProcessMain.js
CHANGED
|
@@ -5,9 +5,18 @@ import * as PrettyError from './parts/PrettyError/PrettyError.js'
|
|
|
5
5
|
|
|
6
6
|
// TODO use named functions here
|
|
7
7
|
|
|
8
|
+
const firstErrorLine = (error) => {
|
|
9
|
+
if (error.stack) {
|
|
10
|
+
return error.stack.slice(0, error.stack.indexOf('\n'))
|
|
11
|
+
}
|
|
12
|
+
if (error.message) {
|
|
13
|
+
return error.message
|
|
14
|
+
}
|
|
15
|
+
return `${error}`
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
const handleUncaughtExceptionMonitor = (error, origin) => {
|
|
9
|
-
console.info(`[shared process] uncaught exception: ${error
|
|
10
|
-
console.info('code', error.code)
|
|
19
|
+
console.info(`[shared process] uncaught exception: ${firstErrorLine(error)}`)
|
|
11
20
|
if (error && error.code === 'EPIPE' && !process.connected) {
|
|
12
21
|
// parent process is disposed, ignore
|
|
13
22
|
return
|
|
@@ -16,18 +25,14 @@ const handleUncaughtExceptionMonitor = (error, origin) => {
|
|
|
16
25
|
// parent process is disposed, ignore
|
|
17
26
|
return
|
|
18
27
|
}
|
|
19
|
-
console.log(error)
|
|
28
|
+
// console.log(error)
|
|
20
29
|
const prettyError = PrettyError.prepare(error)
|
|
21
|
-
console.error(prettyError.message)
|
|
30
|
+
// console.error(prettyError.message)
|
|
22
31
|
console.error(prettyError.codeFrame)
|
|
23
32
|
console.error(prettyError.stack)
|
|
24
33
|
process.exit(1)
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
const handleSigInt = () => {
|
|
28
|
-
console.info('[shared process] sigint')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
36
|
const handleDisconnect = () => {
|
|
32
37
|
console.info('[shared process] disconnected')
|
|
33
38
|
}
|
|
@@ -44,7 +49,6 @@ const main = () => {
|
|
|
44
49
|
console.log('[shared process] started')
|
|
45
50
|
process.on('beforeExit', handleBeforeExit)
|
|
46
51
|
process.on('disconnect', handleDisconnect)
|
|
47
|
-
process.on('SIGINT', handleSigInt)
|
|
48
52
|
process.on('SIGTERM', handleSigTerm)
|
|
49
53
|
|
|
50
54
|
process.on('uncaughtExceptionMonitor', handleUncaughtExceptionMonitor)
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const executeBraceCompletionProvider = async (
|
|
2
|
-
extensionHost,
|
|
3
|
-
documentId,
|
|
4
|
-
offset,
|
|
5
|
-
openingBrace
|
|
6
|
-
) => {
|
|
7
|
-
const completions = await extensionHost.invoke(
|
|
8
|
-
'BraceCompletion.execute',
|
|
9
|
-
documentId,
|
|
10
|
-
offset,
|
|
11
|
-
openingBrace
|
|
12
|
-
)
|
|
13
|
-
return completions
|
|
14
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const executeClosingTagProvider = async (
|
|
2
|
-
extensionHost,
|
|
3
|
-
documentId,
|
|
4
|
-
offset,
|
|
5
|
-
openingBrace
|
|
6
|
-
) => {
|
|
7
|
-
const completions = await extensionHost.invoke(
|
|
8
|
-
'ClosingTag.execute',
|
|
9
|
-
documentId,
|
|
10
|
-
offset,
|
|
11
|
-
openingBrace
|
|
12
|
-
)
|
|
13
|
-
return completions
|
|
14
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as ExtensionManagement from '../ExtensionManagement/ExtensionManagement.js'
|
|
2
|
-
|
|
3
|
-
export const executeCommand = async (extensionHost, commandId, ...args) => {
|
|
4
|
-
return extensionHost.invoke('executeCommand', commandId, ...args)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const getExtensionCommands = (extension) => {
|
|
8
|
-
return extension.commands || []
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const getCommands = async () => {
|
|
12
|
-
const extensions = await ExtensionManagement.getExtensions()
|
|
13
|
-
return extensions.flatMap(getExtensionCommands)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const getCommandsIpc = async () => {
|
|
17
|
-
const commands = await getCommands()
|
|
18
|
-
return commands
|
|
19
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export const readFile = (extensionHost, protocol, uri) => {
|
|
2
|
-
return extensionHost.invoke('FileSystem.readFile', protocol, uri)
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export const writeFile = (extensionHost, protocol, uri, content) => {
|
|
6
|
-
return extensionHost.invoke('FileSystem.writeFile', protocol, uri, content)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const readDirWithFileTypes = (extensionHost, protocol, uri) => {
|
|
10
|
-
return extensionHost.invoke('FileSystem.readDirWithFileTypes', protocol, uri)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const remove = (extensionHost, protocol, uri) => {
|
|
14
|
-
return extensionHost.invoke('FileSystem.remove', protocol, uri)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const rename = (extensionHost, protocol, oldUri, newUri) => {
|
|
18
|
-
return extensionHost.invoke('FileSystem.rename', protocol, oldUri, newUri)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const getPathSeparator = (extensionHost, protocol) => {
|
|
22
|
-
return extensionHost.invoke('FileSystem.getPathSeparator', protocol)
|
|
23
|
-
}
|