@lvce-editor/shared-process 0.28.4 → 0.29.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.28.4",
3
+ "version": "0.29.1",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -18,25 +18,26 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@lvce-editor/assert": "^1.2.0",
21
- "@lvce-editor/extension-host-helper-process": "0.28.4",
22
- "@lvce-editor/ipc": "^8.2.1",
21
+ "@lvce-editor/extension-host-helper-process": "0.29.1",
22
+ "@lvce-editor/ipc": "^9.0.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.28.4",
27
26
  "@lvce-editor/verror": "^1.2.0",
28
27
  "debug": "^4.3.4",
29
- "exit-hook": "^4.0.0",
30
28
  "is-object": "^1.0.2",
31
29
  "xdg-basedir": "^5.1.0"
32
30
  },
33
31
  "optionalDependencies": {
32
+ "@lvce-editor/network-process": "^1.1.0",
33
+ "@lvce-editor/preload": "^1.0.0",
34
+ "@lvce-editor/search-process": "^1.1.0",
35
+ "@lvce-editor/pty-host": "^1.1.0",
36
+ "@lvce-editor/embeds-process": "^1.1.0",
34
37
  "open": "^10.1.0",
35
38
  "tail": "^2.2.6",
36
39
  "tmp-promise": "^3.0.3",
37
40
  "trash": "^8.1.1",
38
- "@lvce-editor/network-process": "0.28.4",
39
- "@lvce-editor/search-process": "0.28.4",
40
- "@lvce-editor/typescript-compile-process": "0.28.4"
41
+ "@lvce-editor/typescript-compile-process": "0.29.1"
41
42
  }
42
43
  }
@@ -1,3 +1,3 @@
1
1
  import * as Path from '../Path/Path.js';
2
2
  import * as Root from '../Root/Root.js';
3
- export const embedsProcessPath = Path.join(Root.root, 'packages', 'embeds-process', 'dist', 'embedsProcessMain.js');
3
+ export const embedsProcessPath = Path.join(Root.root, 'packages', 'shared-process', 'node_modules', '@lvce-editor', 'embeds-process', 'dist', 'embedsProcessMain.js');
@@ -0,0 +1,6 @@
1
+ import * as ExitCode from '../ExitCode/ExitCode.js';
2
+ import * as Process from '../Process/Process.js';
3
+ export const handleDisconnect = () => {
4
+ console.info('[shared process] disconnected');
5
+ Process.exit(ExitCode.Success);
6
+ };
@@ -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 (request, socket) => {
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, socket) => {
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 (message, handle) => {
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,21 +1,8 @@
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
- const ptyHostPath = await PtyHostPath.getPtyHostPath();
5
+ const ptyHostPath = await PtyHostPath.ptyHostPath;
19
6
  const ptyHost = await IpcParent.create({
20
7
  method,
21
8
  path: ptyHostPath,
@@ -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', ProcessListeners.handleDisconnect);
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);
@@ -1 +1,2 @@
1
- export { networkProcessPath } from '@lvce-editor/network-process';
1
+ import * as ResolveBin from '../ResolveBin/ResolveBin.js';
2
+ export const networkProcessPath = ResolveBin.resolveBin('@lvce-editor/network-process');
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
41
41
  export const getSetupName = () => {
42
42
  return 'Lvce-Setup';
43
43
  };
44
- export const version = '0.28.4';
45
- export const commit = '00ff408';
46
- export const date = '2024-05-05T09:02:33.000Z';
44
+ export const version = '0.29.1';
45
+ export const commit = 'a725526';
46
+ export const date = '2024-05-12T10:43:00.000Z';
47
47
  export const getVersion = () => {
48
48
  return version;
49
49
  };
@@ -1,3 +1,3 @@
1
1
  import { join } from 'node:path';
2
2
  import * as Root from '../Root/Root.js';
3
- export const preloadUrl = join(Root.root, 'packages', 'preload', 'src', 'index.js');
3
+ export const preloadUrl = join(Root.root, 'packages', 'shared-process', 'node_modules', '@lvce-editor', 'preload', 'src', 'index.js');
@@ -1,3 +1,3 @@
1
1
  import * as Path from '../Path/Path.js';
2
2
  import * as Root from '../Root/Root.js';
3
- export const processExplorerPath = Path.join(Root.root, 'packages', 'process-explorer', 'src', 'processExplorerMain.js');
3
+ export const processExplorerPath = Path.join(Root.root, 'packages', 'shared-process', 'node_modules', '@lvce-editor', 'process-explorer', 'dist', 'index.js');
@@ -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,11 +1,2 @@
1
- import * as Root from '../Root/Root.js';
2
- import * as Path from '../Path/Path.js';
3
- export const getPtyHostPath = async () => {
4
- try {
5
- const { ptyHostPath } = await import('@lvce-editor/pty-host');
6
- return ptyHostPath;
7
- }
8
- catch {
9
- return Path.join(Root.root, 'packages', 'pty-host', 'src', 'ptyHostMain.js');
10
- }
11
- };
1
+ import * as ResolveBin from '../ResolveBin/ResolveBin.js';
2
+ export const ptyHostPath = ResolveBin.resolveBin('@lvce-editor/pty-host');
@@ -0,0 +1,11 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ export const resolveBin = (name) => {
3
+ try {
4
+ const uri = import.meta.resolve(name);
5
+ const path = fileURLToPath(uri);
6
+ return path;
7
+ }
8
+ catch {
9
+ return '';
10
+ }
11
+ };
@@ -1 +1,2 @@
1
- export { searchProcessPath } from '@lvce-editor/search-process';
1
+ import * as ResolveBin from '../ResolveBin/ResolveBin.js';
2
+ export const searchProcessPath = ResolveBin.resolveBin('@lvce-editor/search-process');
@@ -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
- };