@lvce-editor/shared-process 0.33.1 → 0.33.2
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 +8 -8
- package/src/parts/ConnectIpcToElectron/ConnectIpcToElectron.js +2 -2
- package/src/parts/FixElectronParameters/FixElectronParameters.js +13 -0
- package/src/parts/GetTransferrables/GetTransferrables.js +7 -0
- package/src/parts/HandleElectronMessagePort/HandleElectronMessagePort.js +2 -0
- package/src/parts/HandleIncomingIpc/HandleIncomingIpc.js +5 -1
- package/src/parts/HandleIpcEmbedsProcess/HandleIpcEmbedsProcess.js +1 -2
- package/src/parts/HandleIpcExtensionHostHelperProcess/HandleIpcExtensionHostHelperProcess.js +1 -2
- package/src/parts/HandleIpcFileWatcher/HandleIpcFileWatcher.js +1 -2
- package/src/parts/HandleIpcProcessExplorer/HandleIpcProcessExplorer.js +1 -2
- package/src/parts/HandleIpcSearchProcess/HandleIpcSearchProcess.js +1 -2
- package/src/parts/HandleIpcTerminalProcess/HandleIpcTerminalProcess.js +1 -2
- package/src/parts/HandleMessagePortForProcessExplorer/HandleMessagePortForProcessExplorer.js +3 -0
- package/src/parts/HandleMessagePortForTerminalProcess/HandleMessagePortForTerminalProcess.js +2 -0
- package/src/parts/IpcParentWithElectronUtilityProcess/IpcParentWithElectronUtilityProcess.js +15 -3
- package/src/parts/IsSocket/IsSocket.js +4 -0
- package/src/parts/IsTransferrable/IsTransferrable.js +9 -0
- package/src/parts/LaunchProcessExplorer/LaunchProcessExplorer.js +2 -0
- package/src/parts/Main/Main.js +1 -0
- package/src/parts/ParentIpc/ParentIpc.js +2 -2
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/RemoveValues/RemoveValues.js +24 -0
- package/src/parts/SendIncomingIpc/SendIncomingIpc.js +1 -1
- package/src/parts/TemporaryMessagePort/TemporaryMessagePort.js +1 -1
- package/src/parts/Transferrables/Transferrables.js +4 -0
- package/src/parts/WalkValue/WalkValue.js +21 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -18,22 +18,22 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lvce-editor/assert": "^1.2.0",
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.33.
|
|
22
|
-
"@lvce-editor/ipc": "^
|
|
23
|
-
"@lvce-editor/json-rpc": "^
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.33.2",
|
|
22
|
+
"@lvce-editor/ipc": "^10.0.4",
|
|
23
|
+
"@lvce-editor/json-rpc": "^3.0.0",
|
|
24
24
|
"@lvce-editor/jsonc-parser": "^1.4.0",
|
|
25
|
-
"@lvce-editor/pretty-error": "^1.
|
|
25
|
+
"@lvce-editor/pretty-error": "^1.6.0",
|
|
26
26
|
"@lvce-editor/verror": "^1.4.0",
|
|
27
27
|
"debug": "^4.3.6",
|
|
28
28
|
"is-object": "^1.0.2",
|
|
29
29
|
"xdg-basedir": "^5.1.0"
|
|
30
30
|
},
|
|
31
31
|
"optionalDependencies": {
|
|
32
|
-
"@lvce-editor/network-process": "^
|
|
32
|
+
"@lvce-editor/network-process": "^2.0.0",
|
|
33
33
|
"@lvce-editor/preload": "^1.4.0",
|
|
34
|
-
"@lvce-editor/search-process": "^
|
|
34
|
+
"@lvce-editor/search-process": "^2.0.0",
|
|
35
35
|
"@lvce-editor/typescript-compile-process": "^1.2.0",
|
|
36
|
-
"@lvce-editor/pty-host": "^
|
|
36
|
+
"@lvce-editor/pty-host": "^2.0.0",
|
|
37
37
|
"@lvce-editor/embeds-process": "^1.5.0",
|
|
38
38
|
"open": "^10.1.0",
|
|
39
39
|
"tail": "^2.2.6",
|
|
@@ -5,7 +5,7 @@ import * as ParentIpc from '../ParentIpc/ParentIpc.js';
|
|
|
5
5
|
export const connectIpcToElectron = async (ipc, ipcId = IpcId.Unknown) => {
|
|
6
6
|
const { port1, port2 } = await GetPortTuple.getPortTuple();
|
|
7
7
|
await Promise.all([
|
|
8
|
-
JsonRpc.invokeAndTransfer(ipc,
|
|
9
|
-
ParentIpc.invokeAndTransfer('HandleElectronMessagePort.handleElectronMessagePort',
|
|
8
|
+
JsonRpc.invokeAndTransfer(ipc, 'HandleElectronMessagePort.handleElectronMessagePort', port1, IpcId.MainProcess),
|
|
9
|
+
ParentIpc.invokeAndTransfer('HandleElectronMessagePort.handleElectronMessagePort', port2, ipcId),
|
|
10
10
|
]);
|
|
11
11
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as GetTransferrables from '../GetTransferrables/GetTransferrables.js';
|
|
2
|
+
import * as RemoveValues from '../RemoveValues/RemoveValues.js';
|
|
3
|
+
// workaround for electron not supporting transferrable objects
|
|
4
|
+
// as parameters. If the transferrable object is a parameter, in electron
|
|
5
|
+
// only an empty objected is received in the main process
|
|
6
|
+
export const fixElectronParameters = (value) => {
|
|
7
|
+
const transfer = GetTransferrables.getTransferrables(value);
|
|
8
|
+
const newValue = RemoveValues.removeValues(value, transfer);
|
|
9
|
+
return {
|
|
10
|
+
newValue,
|
|
11
|
+
transfer,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as WalkValue from '../WalkValue/WalkValue.js';
|
|
2
|
+
import * as IsTransferrable from '../IsTransferrable/IsTransferrable.js';
|
|
3
|
+
export const getTransferrables = (value) => {
|
|
4
|
+
const transferrables = [];
|
|
5
|
+
WalkValue.walkValue(value, transferrables, IsTransferrable.isTransferrable);
|
|
6
|
+
return transferrables;
|
|
7
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as HandleIncomingIpc from '../HandleIncomingIpc/HandleIncomingIpc.js';
|
|
2
2
|
import * as IpcId from '../IpcId/IpcId.js';
|
|
3
|
+
import * as Assert from '../Assert/Assert.js';
|
|
3
4
|
export const handleElectronMessagePort = (messagePort, ipcId) => {
|
|
5
|
+
Assert.object(messagePort);
|
|
4
6
|
const message = {
|
|
5
7
|
ipcId,
|
|
6
8
|
};
|
|
@@ -4,11 +4,15 @@ import * as HandleIncomingIpcMessagePort from '../HandleIncomingIpcMessagePort/H
|
|
|
4
4
|
import * as HandleIncomingIpcWebSocket from '../HandleIncomingIpcWebSocket/HandleIncomingIpcWebSocket.js';
|
|
5
5
|
import * as HandleIpcModule from '../HandleIpcModule/HandleIpcModule.js';
|
|
6
6
|
import * as IsMessagePortMain from '../IsMessagePortMain/IsMessagePortMain.js';
|
|
7
|
+
import * as IsSocket from '../IsSocket/IsSocket.js';
|
|
7
8
|
const getIpcAndResponse = (module, handle, message) => {
|
|
8
9
|
if (IsMessagePortMain.isMessagePortMain(handle)) {
|
|
9
10
|
return HandleIncomingIpcMessagePort.handleIncomingIpcMessagePort(module, handle, message);
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
if (IsSocket.isSocket(handle)) {
|
|
13
|
+
return HandleIncomingIpcWebSocket.handleIncomingIpcWebSocket(module, handle, message);
|
|
14
|
+
}
|
|
15
|
+
throw new Error(`Unexpected ipc handle`);
|
|
12
16
|
};
|
|
13
17
|
export const handleIncomingIpc = async (ipcId, handle, message) => {
|
|
14
18
|
Assert.number(ipcId);
|
package/src/parts/HandleMessagePortForProcessExplorer/HandleMessagePortForProcessExplorer.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import * as Assert from '../Assert/Assert.js';
|
|
1
2
|
import * as HandleIncomingIpc from '../HandleIncomingIpc/HandleIncomingIpc.js';
|
|
2
3
|
import * as IpcId from '../IpcId/IpcId.js';
|
|
3
4
|
export const handleMessagePortForProcessExplorer = (port) => {
|
|
5
|
+
Assert.object(port);
|
|
6
|
+
console.log('got port', port);
|
|
4
7
|
return HandleIncomingIpc.handleIncomingIpc(IpcId.ProcessExplorer, port, {});
|
|
5
8
|
};
|
package/src/parts/HandleMessagePortForTerminalProcess/HandleMessagePortForTerminalProcess.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as HandleIncomingIpc from '../HandleIncomingIpc/HandleIncomingIpc.js';
|
|
2
2
|
import * as IpcId from '../IpcId/IpcId.js';
|
|
3
|
+
import * as Assert from '../Assert/Assert.js';
|
|
3
4
|
export const handleMessagePortForTerminalProcess = (port) => {
|
|
5
|
+
Assert.object(port);
|
|
4
6
|
return HandleIncomingIpc.handleIncomingIpc(IpcId.TerminalProcess, port, {});
|
|
5
7
|
};
|
package/src/parts/IpcParentWithElectronUtilityProcess/IpcParentWithElectronUtilityProcess.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as FixElectronParameters from '../FixElectronParameters/FixElectronParameters.js';
|
|
1
2
|
import * as GetPortTuple from '../GetPortTuple/GetPortTuple.js';
|
|
2
3
|
import * as ParentIpc from '../ParentIpc/ParentIpc.js';
|
|
3
4
|
import * as TemporaryMessagePort from '../TemporaryMessagePort/TemporaryMessagePort.js';
|
|
@@ -19,6 +20,16 @@ export const create = async (options) => {
|
|
|
19
20
|
export const signal = (port) => {
|
|
20
21
|
port.start();
|
|
21
22
|
};
|
|
23
|
+
const getActualData = (event) => {
|
|
24
|
+
const { data, ports } = event;
|
|
25
|
+
if (ports.length > 0) {
|
|
26
|
+
return {
|
|
27
|
+
...data,
|
|
28
|
+
params: [...ports, ...data.params],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
22
33
|
export const wrap = (port) => {
|
|
23
34
|
return {
|
|
24
35
|
port,
|
|
@@ -26,8 +37,9 @@ export const wrap = (port) => {
|
|
|
26
37
|
send(message) {
|
|
27
38
|
this.port.postMessage(message);
|
|
28
39
|
},
|
|
29
|
-
async sendAndTransfer(message
|
|
30
|
-
|
|
40
|
+
async sendAndTransfer(message) {
|
|
41
|
+
const { newValue, transfer } = FixElectronParameters.fixElectronParameters(message);
|
|
42
|
+
this.port.postMessage(newValue, transfer);
|
|
31
43
|
},
|
|
32
44
|
on(event, listener) {
|
|
33
45
|
switch (event) {
|
|
@@ -38,7 +50,7 @@ export const wrap = (port) => {
|
|
|
38
50
|
// @ts-ignore
|
|
39
51
|
this.wrappedListener = (event) => {
|
|
40
52
|
const syntheticEvent = {
|
|
41
|
-
data: event
|
|
53
|
+
data: getActualData(event),
|
|
42
54
|
target: this,
|
|
43
55
|
};
|
|
44
56
|
listener(syntheticEvent);
|
|
@@ -5,6 +5,7 @@ import * as IpcParent from '../IpcParent/IpcParent.js';
|
|
|
5
5
|
import * as IpcParentType from '../IpcParentType/IpcParentType.js';
|
|
6
6
|
import * as ProcessExplorerPath from '../ProcessExplorerPath/ProcessExplorerPath.js';
|
|
7
7
|
export const launchProcessExplorer = async () => {
|
|
8
|
+
console.log('will start process explorer');
|
|
8
9
|
const ipc = await IpcParent.create({
|
|
9
10
|
method: IpcParentType.ElectronUtilityProcess,
|
|
10
11
|
path: ProcessExplorerPath.processExplorerPath,
|
|
@@ -15,5 +16,6 @@ export const launchProcessExplorer = async () => {
|
|
|
15
16
|
HandleIpc.handleIpc(ipc);
|
|
16
17
|
await ConnectIpcToElectron.connectIpcToElectron(ipc, IpcId.ProcessExplorerRenderer);
|
|
17
18
|
HandleIpc.unhandleIpc(ipc);
|
|
19
|
+
console.log('did start process explorer');
|
|
18
20
|
return ipc;
|
|
19
21
|
};
|
package/src/parts/Main/Main.js
CHANGED
|
@@ -6,6 +6,7 @@ import * as ParentIpc from '../ParentIpc/ParentIpc.js';
|
|
|
6
6
|
import * as ProcessListeners from '../ProcessListeners/ProcessListeners.js';
|
|
7
7
|
import * as Signal from '../Signal/Signal.js';
|
|
8
8
|
export const main = async () => {
|
|
9
|
+
Error.stackTraceLimit = 999;
|
|
9
10
|
Command.setLoad(Module.load);
|
|
10
11
|
process.on('disconnect', HandleDisconnect.handleDisconnect);
|
|
11
12
|
process.on(Signal.SIGTERM, ProcessListeners.handleSigTerm);
|
|
@@ -22,6 +22,6 @@ export const listen = async () => {
|
|
|
22
22
|
export const invoke = (method, ...params) => {
|
|
23
23
|
return JsonRpc.invoke(state.ipc, method, ...params);
|
|
24
24
|
};
|
|
25
|
-
export const invokeAndTransfer = (method,
|
|
26
|
-
return JsonRpc.invokeAndTransfer(state.ipc,
|
|
25
|
+
export const invokeAndTransfer = (method, ...params) => {
|
|
26
|
+
return JsonRpc.invokeAndTransfer(state.ipc, method, ...params);
|
|
27
27
|
};
|
|
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
|
|
|
41
41
|
export const getSetupName = () => {
|
|
42
42
|
return 'Lvce-Setup';
|
|
43
43
|
};
|
|
44
|
-
export const version = '0.33.
|
|
45
|
-
export const commit = '
|
|
46
|
-
export const date = '2024-08-
|
|
44
|
+
export const version = '0.33.2';
|
|
45
|
+
export const commit = 'fa60d57';
|
|
46
|
+
export const date = '2024-08-25T16:12:04.000Z';
|
|
47
47
|
export const getVersion = () => {
|
|
48
48
|
return version;
|
|
49
49
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const removeValues = (value, toRemove) => {
|
|
2
|
+
if (!value) {
|
|
3
|
+
return value;
|
|
4
|
+
}
|
|
5
|
+
if (Array.isArray(value)) {
|
|
6
|
+
const newItems = [];
|
|
7
|
+
for (const item of value) {
|
|
8
|
+
if (!toRemove.includes(item)) {
|
|
9
|
+
newItems.push(removeValues(item, toRemove));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return newItems;
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === 'object') {
|
|
15
|
+
const newObject = Object.create(null);
|
|
16
|
+
for (const [key, property] of Object.entries(value)) {
|
|
17
|
+
if (!toRemove.includes(property)) {
|
|
18
|
+
newObject[key] = removeValues(property, toRemove);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return newObject;
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
@@ -38,7 +38,7 @@ export const sendIncomingIpc = async (target, response, ipcId) => {
|
|
|
38
38
|
HandleIpc.handleIpc(target);
|
|
39
39
|
}
|
|
40
40
|
addState(ipcId);
|
|
41
|
-
await JsonRpc.invokeAndTransfer(target, response.
|
|
41
|
+
await JsonRpc.invokeAndTransfer(target, response.method, ...response.params);
|
|
42
42
|
removeState(ipcId);
|
|
43
43
|
if (!hasState(ipcId) && supportsPartialIpcHandling(ipcId)) {
|
|
44
44
|
HandleIpc.unhandleIpc(target);
|
|
@@ -20,7 +20,7 @@ export const getPortTuple = async () => {
|
|
|
20
20
|
export const sendTo = async (name, port, ipcId) => {
|
|
21
21
|
Assert.string(name);
|
|
22
22
|
Assert.object(port);
|
|
23
|
-
await ParentIpc.invokeAndTransfer('TemporaryMessagePort.sendTo',
|
|
23
|
+
await ParentIpc.invokeAndTransfer('TemporaryMessagePort.sendTo', port, name, ipcId);
|
|
24
24
|
};
|
|
25
25
|
export const handlePorts = (port1, port2, id1, id2) => {
|
|
26
26
|
Assert.number(id1);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as IsMessagePort from '../IsMessagePort/IsMessagePort.js';
|
|
2
|
+
import * as IsMessagePortMain from '../IsMessagePortMain/IsMessagePortMain.js';
|
|
3
|
+
import * as IsSocket from '../IsSocket/IsSocket.js';
|
|
4
|
+
export const transferrables = [IsMessagePort.isMessagePort, IsMessagePortMain.isMessagePortMain, IsSocket.isSocket];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const walkValue = (value, transferrables, isTransferrable) => {
|
|
2
|
+
if (!value) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
if (isTransferrable(value)) {
|
|
6
|
+
transferrables.push(value);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
for (const item of value) {
|
|
11
|
+
walkValue(item, transferrables, isTransferrable);
|
|
12
|
+
}
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (typeof value === 'object') {
|
|
16
|
+
for (const property of Object.values(value)) {
|
|
17
|
+
walkValue(property, transferrables, isTransferrable);
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
};
|