@lvce-editor/shared-process 0.29.0 → 0.29.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 +5 -5
- package/src/parts/EmbedsProcessState/EmbedsProcessState.js +2 -2
- package/src/parts/HandleDisconnect/HandleDisconnect.js +6 -0
- package/src/parts/HandleMessagePortForEmbedsProcess/HandleMessagePortForEmbedsProcess.js +6 -5
- package/src/parts/HandleRemoteRequest/HandleRemoteRequest.js +2 -2
- package/src/parts/HandleRequestTest/HandleRequestTest.js +2 -2
- package/src/parts/HandleWebSocket/HandleWebSocket.js +2 -2
- package/src/parts/LaunchPtyHost/LaunchPtyHost.js +0 -13
- package/src/parts/Main/Main.js +2 -1
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/ProcessListeners/ProcessListeners.js +0 -4
- package/src/parts/ChildProcess/ChildProcess.js +0 -83
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -18,14 +18,13 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lvce-editor/assert": "^1.2.0",
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.29.
|
|
22
|
-
"@lvce-editor/ipc": "^
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.29.2",
|
|
22
|
+
"@lvce-editor/ipc": "^9.1.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
26
|
"@lvce-editor/verror": "^1.2.0",
|
|
27
27
|
"debug": "^4.3.4",
|
|
28
|
-
"exit-hook": "^4.0.0",
|
|
29
28
|
"is-object": "^1.0.2",
|
|
30
29
|
"xdg-basedir": "^5.1.0"
|
|
31
30
|
},
|
|
@@ -34,10 +33,11 @@
|
|
|
34
33
|
"@lvce-editor/preload": "^1.0.0",
|
|
35
34
|
"@lvce-editor/search-process": "^1.1.0",
|
|
36
35
|
"@lvce-editor/pty-host": "^1.1.0",
|
|
36
|
+
"@lvce-editor/embeds-process": "^1.4.0",
|
|
37
37
|
"open": "^10.1.0",
|
|
38
38
|
"tail": "^2.2.6",
|
|
39
39
|
"tmp-promise": "^3.0.3",
|
|
40
40
|
"trash": "^8.1.1",
|
|
41
|
-
"@lvce-editor/typescript-compile-process": "0.29.
|
|
41
|
+
"@lvce-editor/typescript-compile-process": "0.29.2"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -10,10 +10,11 @@ export const handleMessagePortForEmbedsProcess = (port, ipcId) => {
|
|
|
10
10
|
};
|
|
11
11
|
export const handleEmbedsProcessIpcClosed = async () => {
|
|
12
12
|
EmbedsProcessState.decrement();
|
|
13
|
-
if (EmbedsProcessState.
|
|
14
|
-
|
|
15
|
-
EmbedsProcess.state.ipc = undefined;
|
|
16
|
-
const ipc = await promise;
|
|
17
|
-
ipc.dispose();
|
|
13
|
+
if (EmbedsProcessState.hasRef()) {
|
|
14
|
+
return;
|
|
18
15
|
}
|
|
16
|
+
const promise = EmbedsProcess.state.ipc;
|
|
17
|
+
EmbedsProcess.state.ipc = undefined;
|
|
18
|
+
const ipc = await promise;
|
|
19
|
+
ipc.dispose();
|
|
19
20
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as Assert from '../Assert/Assert.js';
|
|
2
2
|
import * as GetElectronFileResponse from '../GetElectronFileResponse/GetElectronFileResponse.js';
|
|
3
3
|
import * as HttpServerResponse from '../HttpServerResponse/HttpServerResponse.js';
|
|
4
|
-
export const handleRemoteRequest = async (
|
|
5
|
-
Assert.object(request);
|
|
4
|
+
export const handleRemoteRequest = async (socket, request) => {
|
|
6
5
|
Assert.object(socket);
|
|
6
|
+
Assert.object(request);
|
|
7
7
|
const result = await GetElectronFileResponse.getElectronFileResponse(request.url, request);
|
|
8
8
|
HttpServerResponse.send(request, socket, result);
|
|
9
9
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as Assert from '../Assert/Assert.js';
|
|
2
2
|
import * as GetTestRequestResponse from '../GetTestRequestResponse/GetTestRequestResponse.js';
|
|
3
3
|
import * as HttpServerResponse from '../HttpServerResponse/HttpServerResponse.js';
|
|
4
|
-
export const handleRequestTest = async (request, indexHtmlPath
|
|
4
|
+
export const handleRequestTest = async (socket, request, indexHtmlPath) => {
|
|
5
|
+
Assert.object(socket);
|
|
5
6
|
Assert.object(request);
|
|
6
7
|
Assert.string(indexHtmlPath);
|
|
7
|
-
Assert.object(socket);
|
|
8
8
|
const result = await GetTestRequestResponse.getTestRequestResponse(request, indexHtmlPath);
|
|
9
9
|
HttpServerResponse.send(request, socket, result);
|
|
10
10
|
};
|
|
@@ -3,10 +3,10 @@ import * as DestroyWebSocket from '../DestroySocket/DestroySocket.js';
|
|
|
3
3
|
import * as HandleWebSocketModule from '../HandleWebSocketModule/HandleWebSocketModule.js';
|
|
4
4
|
import * as GetTypeFromUrl from '../GetTypeFromUrl/GetTypeFromUrl.js';
|
|
5
5
|
import { VError } from '../VError/VError.js';
|
|
6
|
-
export const handleWebSocket = async (
|
|
6
|
+
export const handleWebSocket = async (handle, message) => {
|
|
7
7
|
try {
|
|
8
|
-
Assert.object(message);
|
|
9
8
|
Assert.object(handle);
|
|
9
|
+
Assert.object(message);
|
|
10
10
|
const { url } = message;
|
|
11
11
|
const type = GetTypeFromUrl.getTypeFromUrl(url);
|
|
12
12
|
handle.pause();
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import exitHook from 'exit-hook';
|
|
2
|
-
import * as Debug from '../Debug/Debug.js';
|
|
3
1
|
import * as IpcParent from '../IpcParent/IpcParent.js';
|
|
4
2
|
import * as PtyHostPath from '../PtyHostPath/PtyHostPath.js';
|
|
5
3
|
import * as PtyHostState from '../PtyHostState/PtyHostState.js';
|
|
6
|
-
const cleanUpAll = () => {
|
|
7
|
-
if (PtyHostState.state.ipc) {
|
|
8
|
-
PtyHostState.state.ipc.dispose();
|
|
9
|
-
PtyHostState.state.ipc = undefined;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
const handleProcessExit = () => {
|
|
13
|
-
Debug.debug('shared process exit, clean terminals');
|
|
14
|
-
cleanUpAll();
|
|
15
|
-
};
|
|
16
4
|
export const launchPtyHost = async (method) => {
|
|
17
|
-
exitHook(handleProcessExit);
|
|
18
5
|
const ptyHostPath = await PtyHostPath.ptyHostPath;
|
|
19
6
|
const ptyHost = await IpcParent.create({
|
|
20
7
|
method,
|
package/src/parts/Main/Main.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Command from '../Command/Command.js';
|
|
2
|
+
import * as HandleDisconnect from '../HandleDisconnect/HandleDisconnect.js';
|
|
2
3
|
import * as HandleUncaughtExceptionMonitor from '../HandleUncaughtExceptionMonitor/HandleUncaughtExceptionMonitor.js';
|
|
3
4
|
import * as Module from '../Module/Module.js';
|
|
4
5
|
import * as ParentIpc from '../ParentIpc/ParentIpc.js';
|
|
@@ -6,7 +7,7 @@ import * as ProcessListeners from '../ProcessListeners/ProcessListeners.js';
|
|
|
6
7
|
import * as Signal from '../Signal/Signal.js';
|
|
7
8
|
export const main = async () => {
|
|
8
9
|
Command.setLoad(Module.load);
|
|
9
|
-
process.on('disconnect',
|
|
10
|
+
process.on('disconnect', HandleDisconnect.handleDisconnect);
|
|
10
11
|
process.on(Signal.SIGTERM, ProcessListeners.handleSigTerm);
|
|
11
12
|
process.on('uncaughtException', HandleUncaughtExceptionMonitor.handleUncaughtException);
|
|
12
13
|
process.on('unhandledRejection', HandleUncaughtExceptionMonitor.handleUnhandledRejection);
|
|
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
|
|
|
41
41
|
export const getSetupName = () => {
|
|
42
42
|
return 'Lvce-Setup';
|
|
43
43
|
};
|
|
44
|
-
export const version = '0.29.
|
|
45
|
-
export const commit = '
|
|
46
|
-
export const date = '2024-05-
|
|
44
|
+
export const version = '0.29.2';
|
|
45
|
+
export const commit = '1a41c20';
|
|
46
|
+
export const date = '2024-05-14T20:51:40.000Z';
|
|
47
47
|
export const getVersion = () => {
|
|
48
48
|
return version;
|
|
49
49
|
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import * as ErrorHandling from '../ErrorHandling/ErrorHandling.js';
|
|
2
2
|
import * as ExitCode from '../ExitCode/ExitCode.js';
|
|
3
3
|
import * as Process from '../Process/Process.js';
|
|
4
|
-
export const handleDisconnect = () => {
|
|
5
|
-
console.info('[shared process] disconnected');
|
|
6
|
-
Process.exit(ExitCode.Success);
|
|
7
|
-
};
|
|
8
4
|
export const handleSigTerm = () => {
|
|
9
5
|
console.info('[shared-process] sigterm');
|
|
10
6
|
Process.exit(ExitCode.Success);
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import * as NodeChildProcess from 'node:child_process';
|
|
2
|
-
import { Worker } from 'node:worker_threads';
|
|
3
|
-
import exitHook from 'exit-hook';
|
|
4
|
-
import * as Debug from '../Debug/Debug.js';
|
|
5
|
-
export const state = {
|
|
6
|
-
/** @type{NodeChildProcess.ChildProcess[]} */
|
|
7
|
-
childProcesses: [],
|
|
8
|
-
};
|
|
9
|
-
const cleanUpAll = () => {
|
|
10
|
-
for (const childProcess of state.childProcesses) {
|
|
11
|
-
childProcess.kill();
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const handleProcessExit = () => {
|
|
15
|
-
Debug.debug('exiting');
|
|
16
|
-
console.info('[shared process] exiting');
|
|
17
|
-
cleanUpAll();
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {string} path
|
|
22
|
-
* @param {NodeChildProcess.ForkOptions } options
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
export const fork = (path, argv, options) => {
|
|
26
|
-
exitHook(handleProcessExit);
|
|
27
|
-
const childProcess = NodeChildProcess.fork(path, argv, options);
|
|
28
|
-
// childProcess.on('error', (error) => {
|
|
29
|
-
// onError(error)
|
|
30
|
-
// })
|
|
31
|
-
// childProcess.on('exit', (exitCode) => {
|
|
32
|
-
// onExit(exitCode)
|
|
33
|
-
// })
|
|
34
|
-
// childProcess.once('message', (message) => {
|
|
35
|
-
// if (message === 'ready') {
|
|
36
|
-
// onReady()
|
|
37
|
-
// childProcess.on('message', onMessage)
|
|
38
|
-
// // TODO remove jsonrpc part from here
|
|
39
|
-
// // childProcess.on('message', (message) => {
|
|
40
|
-
// // // @ts-ignore
|
|
41
|
-
// // if ('result' in message) {
|
|
42
|
-
// // // @ts-ignore
|
|
43
|
-
// // callbacks[message.id](message.result)
|
|
44
|
-
// // // @ts-ignore
|
|
45
|
-
// // delete callbacks[message.id]
|
|
46
|
-
// // } else {
|
|
47
|
-
// // onMessage(message)
|
|
48
|
-
// // }
|
|
49
|
-
// // })
|
|
50
|
-
// }
|
|
51
|
-
// })
|
|
52
|
-
state.childProcesses.push(childProcess);
|
|
53
|
-
return childProcess;
|
|
54
|
-
};
|
|
55
|
-
export const disposeFork = (childProcess) => {
|
|
56
|
-
childProcess.kill();
|
|
57
|
-
};
|
|
58
|
-
export const createWorker = (path, { onError, onExit, onMessage }) => {
|
|
59
|
-
const worker = new Worker(path, {
|
|
60
|
-
resourceLimits: {
|
|
61
|
-
maxOldGenerationSizeMb: 10,
|
|
62
|
-
maxYoungGenerationSizeMb: 10,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
worker.on('error', (error) => {
|
|
66
|
-
onError(error);
|
|
67
|
-
});
|
|
68
|
-
worker.on('exit', (exitCode) => {
|
|
69
|
-
onExit(exitCode);
|
|
70
|
-
});
|
|
71
|
-
worker.on('message', (message) => {
|
|
72
|
-
onMessage(message);
|
|
73
|
-
});
|
|
74
|
-
return {
|
|
75
|
-
dispose() {
|
|
76
|
-
worker.terminate();
|
|
77
|
-
},
|
|
78
|
-
send(message) {
|
|
79
|
-
worker.postMessage(message);
|
|
80
|
-
},
|
|
81
|
-
async invoke(commandId, ...args) { },
|
|
82
|
-
};
|
|
83
|
-
};
|