@lvce-editor/shared-process 0.25.7 → 0.25.9
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 +4 -4
- package/src/parts/IpcChildModule/IpcChildModule.js +10 -4
- package/src/parts/IpcParentModule/IpcParentModule.js +3 -2
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/IpcChildWithNodeForkedProcess/IpcChildWithNodeForkedProcess.js +0 -46
- package/src/parts/IpcChildWithNodeWorker/IpcChildWithNodeWorker.js +0 -45
- package/src/parts/IpcParentWithNodeForkedProcess/IpcParentWithNodeForkedProcess.js +0 -5
- package/src/parts/IpcParentWithNodeWorker/IpcParentWithNodeWorker.js +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.9",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lvce-editor/assert": "^1.2.0",
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.25.
|
|
22
|
-
"@lvce-editor/ipc": "^3.
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.25.9",
|
|
22
|
+
"@lvce-editor/ipc": "^3.6.0",
|
|
23
23
|
"@lvce-editor/json-rpc": "^1.3.0",
|
|
24
24
|
"@lvce-editor/jsonc-parser": "^1.2.0",
|
|
25
25
|
"@lvce-editor/pretty-error": "^1.5.0",
|
|
26
|
-
"@lvce-editor/pty-host": "0.25.
|
|
26
|
+
"@lvce-editor/pty-host": "0.25.9",
|
|
27
27
|
"@lvce-editor/verror": "^1.2.0",
|
|
28
28
|
"@lvce-editor/web-socket-server": "^1.1.0",
|
|
29
29
|
"debug": "^4.3.4",
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IpcChildWithElectronMessagePort,
|
|
3
|
+
IpcChildWithElectronUtilityProcess,
|
|
4
|
+
IpcChildWithNodeForkedProcess,
|
|
5
|
+
IpcChildWithNodeWorker,
|
|
6
|
+
IpcChildWithWebSocket,
|
|
7
|
+
} from '@lvce-editor/ipc'
|
|
1
8
|
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
2
|
-
import { IpcChildWithElectronUtilityProcess, IpcChildWithWebSocket } from '@lvce-editor/ipc'
|
|
3
9
|
|
|
4
10
|
export const getModule = (method) => {
|
|
5
11
|
switch (method) {
|
|
6
12
|
case IpcChildType.NodeForkedProcess:
|
|
7
|
-
return
|
|
13
|
+
return IpcChildWithNodeForkedProcess
|
|
8
14
|
case IpcChildType.NodeWorker:
|
|
9
|
-
return
|
|
15
|
+
return IpcChildWithNodeWorker
|
|
10
16
|
case IpcChildType.ElectronUtilityProcess:
|
|
11
17
|
return IpcChildWithElectronUtilityProcess
|
|
12
18
|
case IpcChildType.ElectronMessagePort:
|
|
13
|
-
return
|
|
19
|
+
return IpcChildWithElectronMessagePort
|
|
14
20
|
case IpcChildType.NodeMessagePort:
|
|
15
21
|
return import('../IpcChildWithNodeMessagePort/IpcChildWithNodeMessagePort.js')
|
|
16
22
|
case IpcChildType.WebSocket:
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker } from '@lvce-editor/ipc'
|
|
1
2
|
import * as IpcParentType from '../IpcParentType/IpcParentType.js'
|
|
2
3
|
|
|
3
4
|
export const getModule = (method) => {
|
|
4
5
|
switch (method) {
|
|
5
6
|
case IpcParentType.NodeWorker:
|
|
6
|
-
return
|
|
7
|
+
return IpcParentWithNodeWorker
|
|
7
8
|
case IpcParentType.NodeForkedProcess:
|
|
8
|
-
return
|
|
9
|
+
return IpcParentWithNodeForkedProcess
|
|
9
10
|
case IpcParentType.ElectronUtilityProcess:
|
|
10
11
|
return import('../IpcParentWithElectronUtilityProcess/IpcParentWithElectronUtilityProcess.js')
|
|
11
12
|
default:
|
|
@@ -61,11 +61,11 @@ export const getSetupName = () => {
|
|
|
61
61
|
return 'Lvce-Setup'
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export const version = '0.25.
|
|
64
|
+
export const version = '0.25.9'
|
|
65
65
|
|
|
66
|
-
export const commit = '
|
|
66
|
+
export const commit = '5d646c0'
|
|
67
67
|
|
|
68
|
-
export const date = '2024-04-
|
|
68
|
+
export const date = '2024-04-13T13:55:08.000Z'
|
|
69
69
|
|
|
70
70
|
export const getVersion = () => {
|
|
71
71
|
return version
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export const listen = async () => {
|
|
2
|
-
if (!process.send) {
|
|
3
|
-
throw new Error('process.send must be defined')
|
|
4
|
-
}
|
|
5
|
-
return process
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const signal = (process) => {
|
|
9
|
-
process.send('ready')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const getActualData = (message, handle) => {
|
|
13
|
-
if (handle) {
|
|
14
|
-
return {
|
|
15
|
-
...message,
|
|
16
|
-
params: [...message.params, handle],
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return message
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const wrap = (process) => {
|
|
23
|
-
return {
|
|
24
|
-
process,
|
|
25
|
-
on(event, listener) {
|
|
26
|
-
if (event === 'message') {
|
|
27
|
-
const wrappedListener = (event, handle) => {
|
|
28
|
-
const actualData = getActualData(event, handle)
|
|
29
|
-
listener(actualData)
|
|
30
|
-
}
|
|
31
|
-
this.process.on(event, wrappedListener)
|
|
32
|
-
} else if (event === 'close') {
|
|
33
|
-
this.process.on('close', listener)
|
|
34
|
-
} else {
|
|
35
|
-
throw new Error('unsupported event type')
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
off(event, listener) {
|
|
39
|
-
this.process.off(event, listener)
|
|
40
|
-
},
|
|
41
|
-
send(message) {
|
|
42
|
-
this.process.send(message)
|
|
43
|
-
},
|
|
44
|
-
dispose() {},
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { parentPort } from 'node:worker_threads'
|
|
2
|
-
import * as IsElectron from '../IsElectron/IsElectron.js'
|
|
3
|
-
|
|
4
|
-
export const listen = async () => {
|
|
5
|
-
if (!parentPort) {
|
|
6
|
-
throw new Error('parentPort is required')
|
|
7
|
-
}
|
|
8
|
-
return parentPort
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const signal = (parentPort) => {
|
|
12
|
-
parentPort.postMessage('ready')
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const getActualData = (message) => {
|
|
16
|
-
return message
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const wrap = (parentPort) => {
|
|
20
|
-
return {
|
|
21
|
-
parentPort,
|
|
22
|
-
on(event, listener) {
|
|
23
|
-
if (event === 'message') {
|
|
24
|
-
const wrappedListener = (event) => {
|
|
25
|
-
const actualData = getActualData(event)
|
|
26
|
-
listener(actualData)
|
|
27
|
-
}
|
|
28
|
-
this.parentPort.on(event, wrappedListener)
|
|
29
|
-
} else if (event === 'close') {
|
|
30
|
-
this.parentPort.on('close', listener)
|
|
31
|
-
} else {
|
|
32
|
-
throw new Error('unsupported event type')
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
off(event, listener) {
|
|
36
|
-
this.parentPort.off(event, listener)
|
|
37
|
-
},
|
|
38
|
-
send(message) {
|
|
39
|
-
this.parentPort.postMessage(message)
|
|
40
|
-
},
|
|
41
|
-
dispose() {
|
|
42
|
-
this.parentPort.close()
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Worker } from 'node:worker_threads'
|
|
2
|
-
import * as Assert from '../Assert/Assert.js'
|
|
3
|
-
import * as FirstNodeWorkerEventType from '../FirstNodeWorkerEventType/FirstNodeWorkerEventType.js'
|
|
4
|
-
import * as GetFirstNodeWorkerEvent from '../GetFirstNodeWorkerEvent/GetFirstNodeWorkerEvent.js'
|
|
5
|
-
|
|
6
|
-
export const create = async ({ path, argv, env, execArgv }) => {
|
|
7
|
-
Assert.string(path)
|
|
8
|
-
const worker = new Worker(path, {
|
|
9
|
-
argv,
|
|
10
|
-
env,
|
|
11
|
-
execArgv,
|
|
12
|
-
})
|
|
13
|
-
const { type, event } = await GetFirstNodeWorkerEvent.getFirstNodeWorkerEvent(worker)
|
|
14
|
-
if (type === FirstNodeWorkerEventType.Error) {
|
|
15
|
-
throw event
|
|
16
|
-
}
|
|
17
|
-
return worker
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const wrap = (worker) => {
|
|
21
|
-
return {
|
|
22
|
-
worker,
|
|
23
|
-
on(event, listener) {
|
|
24
|
-
this.worker.on(event, listener)
|
|
25
|
-
},
|
|
26
|
-
send(message) {
|
|
27
|
-
this.worker.postMessage(message)
|
|
28
|
-
},
|
|
29
|
-
sendAndTransfer(message, transfer) {
|
|
30
|
-
this.worker.postMessage(message, transfer)
|
|
31
|
-
},
|
|
32
|
-
dispose() {
|
|
33
|
-
this.worker.terminate()
|
|
34
|
-
},
|
|
35
|
-
}
|
|
36
|
-
}
|