@lvce-editor/extension-host-helper-process 0.53.4 → 0.53.5
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/package.json +2 -1
- package/src/parts/Exit/Exit.js +3 -0
- package/src/parts/HandleElectronMessagePort/HandleElectronMessagePort.js +6 -13
- package/src/parts/HandleIpcClosed/HandleIpcClosed.js +5 -0
- package/src/parts/HandleWebSocket/HandleWebSocket.js +4 -3
- package/src/parts/IpcChild/IpcChild.js +3 -8
- package/src/parts/IpcChildModule/IpcChildModule.js +14 -11
- package/src/parts/IpcChildType/IpcChildType.js +14 -34
- package/src/parts/Listen/Listen.js +10 -0
- package/src/parts/Main/Main.js +2 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/extension-host-helper-process",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@lvce-editor/assert": "^1.3.0",
|
|
20
20
|
"@lvce-editor/ipc": "^14.2.0",
|
|
21
21
|
"@lvce-editor/json-rpc": "^6.2.0",
|
|
22
|
+
"@lvce-editor/rpc": "^4.1.0",
|
|
22
23
|
"@lvce-editor/verror": "^1.7.0",
|
|
23
24
|
"execa": "^9.5.3",
|
|
24
25
|
"got": "^14.4.7",
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import * as HandleIpc from '../HandleIpc/HandleIpc.js'
|
|
3
2
|
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
3
|
+
import * as HandleIpcClosed from '../HandleIpcClosed/HandleIpcClosed.js'
|
|
4
4
|
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
5
|
-
import * as IpcId from '../IpcId/IpcId.js'
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
process
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const handleElectronMessagePort = async (messagePort, ipcId) => {
|
|
6
|
+
export const handleElectronMessagePort = async (messagePort) => {
|
|
7
|
+
// TODO make it so when messageport closes, the process exits
|
|
12
8
|
Assert.object(messagePort)
|
|
13
|
-
const
|
|
9
|
+
const rpc = await IpcChild.listen({
|
|
14
10
|
method: IpcChildType.ElectronMessagePort,
|
|
15
11
|
messagePort,
|
|
16
12
|
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// @ts-ignore
|
|
20
|
-
ipc.addEventListener('close', handleClose)
|
|
21
|
-
}
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
rpc.ipc.addEventListener('close', HandleIpcClosed.handleIpcClosed)
|
|
22
15
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import * as HandleIpc from '../HandleIpc/HandleIpc.js'
|
|
3
2
|
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
4
3
|
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
4
|
+
import * as HandleIpcClosed from '../HandleIpcClosed/HandleIpcClosed.js'
|
|
5
5
|
|
|
6
6
|
export const handleWebSocket = async (handle, request) => {
|
|
7
|
+
// TODO make it so when websocket closes, the process exits
|
|
7
8
|
Assert.object(handle)
|
|
8
9
|
Assert.object(request)
|
|
9
|
-
|
|
10
|
+
handle.on('close', HandleIpcClosed.handleIpcClosed)
|
|
11
|
+
await IpcChild.listen({
|
|
10
12
|
method: IpcChildType.WebSocket,
|
|
11
13
|
request,
|
|
12
14
|
handle,
|
|
13
15
|
})
|
|
14
|
-
HandleIpc.handleIpc(ipc)
|
|
15
16
|
}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import * as IpcChildModule from '../IpcChildModule/IpcChildModule.js'
|
|
2
2
|
|
|
3
3
|
export const listen = async ({ method, ...params }) => {
|
|
4
|
-
const
|
|
5
|
-
const rawIpc = await module.listen(params)
|
|
4
|
+
const create = IpcChildModule.getModule(method)
|
|
6
5
|
// @ts-ignore
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
module.signal(rawIpc)
|
|
10
|
-
}
|
|
11
|
-
const ipc = module.wrap(rawIpc)
|
|
12
|
-
return ipc
|
|
6
|
+
const rpc = await create(params)
|
|
7
|
+
return rpc
|
|
13
8
|
}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
ElectronMessagePortRpcClient,
|
|
3
|
+
ElectronUtilityProcessRpcClient,
|
|
4
|
+
NodeForkedProcessRpcClient,
|
|
5
|
+
NodeWebSocketRpcClient,
|
|
6
|
+
NodeWorkerRpcClient,
|
|
7
|
+
} from '@lvce-editor/rpc'
|
|
7
8
|
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
8
9
|
|
|
9
10
|
export const getModule = (method) => {
|
|
10
11
|
switch (method) {
|
|
11
|
-
case IpcChildType.WebSocket:
|
|
12
|
-
return IpcChildWithWebSocket
|
|
13
12
|
case IpcChildType.NodeForkedProcess:
|
|
14
|
-
return
|
|
15
|
-
case IpcChildType.
|
|
16
|
-
return
|
|
13
|
+
return NodeForkedProcessRpcClient.create
|
|
14
|
+
case IpcChildType.NodeWorker:
|
|
15
|
+
return NodeWorkerRpcClient.create
|
|
17
16
|
case IpcChildType.ElectronUtilityProcess:
|
|
18
|
-
return
|
|
17
|
+
return ElectronUtilityProcessRpcClient.create
|
|
18
|
+
case IpcChildType.ElectronMessagePort:
|
|
19
|
+
return ElectronMessagePortRpcClient.create
|
|
20
|
+
case IpcChildType.WebSocket:
|
|
21
|
+
return NodeWebSocketRpcClient.create
|
|
19
22
|
default:
|
|
20
23
|
throw new Error('unexpected ipc type')
|
|
21
24
|
}
|
|
@@ -1,38 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const
|
|
4
|
-
export const MessagePort = 2
|
|
5
|
-
export const Parent = 3
|
|
1
|
+
export const NodeWorker = 1
|
|
2
|
+
export const NodeForkedProcess = 2
|
|
3
|
+
export const ElectronUtilityProcess = 3
|
|
6
4
|
export const ElectronMessagePort = 4
|
|
7
|
-
export const
|
|
8
|
-
export const ElectronUtilityProcessMessagePort = 6
|
|
9
|
-
export const NodeForkedProcess = 7
|
|
10
|
-
|
|
11
|
-
const getRawIpcType = () => {
|
|
12
|
-
const { argv } = process
|
|
13
|
-
const parsedArgs = ParseCliArgs.parseCliArgs(argv.slice(2))
|
|
14
|
-
const ipcType = parsedArgs['ipc-type']
|
|
15
|
-
return ipcType
|
|
16
|
-
}
|
|
5
|
+
export const WebSocket = 6
|
|
17
6
|
|
|
18
|
-
export const Auto = () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
case 'electron-message-port':
|
|
28
|
-
return ElectronMessagePort
|
|
29
|
-
case 'electron-utility-process':
|
|
30
|
-
return ElectronUtilityProcess
|
|
31
|
-
case 'electron-utility-process-message-port':
|
|
32
|
-
return ElectronUtilityProcessMessagePort
|
|
33
|
-
case 'node-forked-process':
|
|
34
|
-
return NodeForkedProcess
|
|
35
|
-
default:
|
|
36
|
-
throw new Error(`[extension-host-helper-process] unknown ipc type ${ipcType}`)
|
|
7
|
+
export const Auto = (argv) => {
|
|
8
|
+
if (argv.includes('--ipc-type=node-worker')) {
|
|
9
|
+
return NodeWorker
|
|
10
|
+
}
|
|
11
|
+
if (argv.includes('--ipc-type=node-forked-process')) {
|
|
12
|
+
return NodeForkedProcess
|
|
13
|
+
}
|
|
14
|
+
if (argv.includes('--ipc-type=electron-utility-process')) {
|
|
15
|
+
return ElectronUtilityProcess
|
|
37
16
|
}
|
|
17
|
+
throw new Error(`[file-system-process] unknown ipc type`)
|
|
38
18
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as CommandMap from '../CommandMap/CommandMap.js'
|
|
2
|
+
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
3
|
+
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
4
|
+
|
|
5
|
+
export const listen = async (argv) => {
|
|
6
|
+
await IpcChild.listen({
|
|
7
|
+
method: IpcChildType.Auto(argv),
|
|
8
|
+
commandMap: CommandMap.commandMap,
|
|
9
|
+
})
|
|
10
|
+
}
|
package/src/parts/Main/Main.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import * as CommandMap from '../CommandMap/CommandMap.js'
|
|
2
|
-
import * as CommandState from '../CommandState/CommandState.js'
|
|
3
|
-
import * as HandleIpc from '../HandleIpc/HandleIpc.js'
|
|
4
|
-
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
5
|
-
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
6
1
|
import * as ProcessListeners from '../ProcessListeners/ProcessListeners.js'
|
|
2
|
+
import * as Listen from '../Listen/Listen.js'
|
|
7
3
|
|
|
8
4
|
export const main = async () => {
|
|
9
5
|
process.on('disconnect', ProcessListeners.handleDisconnect)
|
|
10
|
-
|
|
11
|
-
const ipc = await IpcChild.listen({ method: IpcChildType.Auto() })
|
|
12
|
-
HandleIpc.handleIpc(ipc)
|
|
6
|
+
await Listen.listen(process.argv)
|
|
13
7
|
}
|