@scrypted/server 0.115.27 → 0.115.28
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/dist/plugin/runtime/electron-worker.d.ts +5 -1
- package/dist/plugin/runtime/electron-worker.js +22 -2
- package/dist/plugin/runtime/electron-worker.js.map +1 -1
- package/dist/plugin/runtime/runtime-host.js +1 -1
- package/dist/plugin/runtime/runtime-host.js.map +1 -1
- package/package.json +1 -1
- package/src/plugin/runtime/electron-worker.ts +28 -3
- package/src/plugin/runtime/runtime-host.ts +1 -1
@@ -1,8 +1,12 @@
|
|
1
1
|
import { RpcMessage, RpcPeer } from "../../rpc";
|
2
2
|
import { ChildProcessWorker } from "./child-process-worker";
|
3
3
|
import { RuntimeWorkerOptions } from "./runtime-worker";
|
4
|
+
import type { ScryptedRuntime } from '../../runtime';
|
4
5
|
export declare class ElectronForkWorker extends ChildProcessWorker {
|
5
|
-
|
6
|
+
static allocatedDisplays: Set<number>;
|
7
|
+
allocatedDisplay: number;
|
8
|
+
constructor(mainFilename: string, pluginId: string, options: RuntimeWorkerOptions, runtime: ScryptedRuntime);
|
9
|
+
kill(): void;
|
6
10
|
setupRpcPeer(peer: RpcPeer): void;
|
7
11
|
send(message: RpcMessage, reject?: (e: Error) => void, serializationContext?: any): void;
|
8
12
|
get pid(): number;
|
@@ -10,7 +10,9 @@ const net_1 = __importDefault(require("net"));
|
|
10
10
|
const socket_serializer_1 = require("../socket-serializer");
|
11
11
|
const child_process_worker_1 = require("./child-process-worker");
|
12
12
|
class ElectronForkWorker extends child_process_worker_1.ChildProcessWorker {
|
13
|
-
|
13
|
+
static allocatedDisplays = new Set();
|
14
|
+
allocatedDisplay;
|
15
|
+
constructor(mainFilename, pluginId, options, runtime) {
|
14
16
|
super(pluginId, options);
|
15
17
|
const { env, pluginDebug } = options;
|
16
18
|
const execArgv = process.execArgv.slice();
|
@@ -21,8 +23,19 @@ class ElectronForkWorker extends child_process_worker_1.ChildProcessWorker {
|
|
21
23
|
const electronBin = require('electron');
|
22
24
|
const args = [electronBin];
|
23
25
|
if (process.platform === 'linux') {
|
26
|
+
// crappy but should work.
|
27
|
+
for (let i = 50; i < 100; i++) {
|
28
|
+
if (!ElectronForkWorker.allocatedDisplays.has(i)) {
|
29
|
+
this.allocatedDisplay = i;
|
30
|
+
break;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
if (!this.allocatedDisplay)
|
34
|
+
throw new Error('unable to allocate DISPLAY for xvfb-run');
|
35
|
+
ElectronForkWorker.allocatedDisplays.add(this.allocatedDisplay);
|
24
36
|
// requires xvfb-run as electron does not support the chrome --headless flag.
|
25
|
-
|
37
|
+
// dummy up a DISPLAY env variable. this value numerical because of the way it is.
|
38
|
+
args.unshift('xvfb-run', '-n', this.allocatedDisplay.toString());
|
26
39
|
// https://github.com/gpuweb/gpuweb/wiki/Implementation-Status#chromium-chrome-edge-etc
|
27
40
|
args.push('--no-sandbox', '--enable-unsafe-webgpu', '--ignore-gpu-blocklist', '--enable-features=Vulkan', '--disable-vulkan-surface');
|
28
41
|
}
|
@@ -39,12 +52,19 @@ class ElectronForkWorker extends child_process_worker_1.ChildProcessWorker {
|
|
39
52
|
serialization: 'advanced',
|
40
53
|
// execArgv,
|
41
54
|
});
|
55
|
+
this.worker.on('exit', () => {
|
56
|
+
});
|
42
57
|
this.worker.send({
|
43
58
|
pluginId,
|
44
59
|
options,
|
45
60
|
});
|
46
61
|
this.setupWorker();
|
47
62
|
}
|
63
|
+
kill() {
|
64
|
+
super.kill();
|
65
|
+
if (this.worker)
|
66
|
+
ElectronForkWorker.allocatedDisplays.delete(this.allocatedDisplay);
|
67
|
+
}
|
48
68
|
setupRpcPeer(peer) {
|
49
69
|
this.worker.on('message', (message, sendHandle) => {
|
50
70
|
if (message.type && sendHandle) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"electron-worker.js","sourceRoot":"","sources":["../../../src/plugin/runtime/electron-worker.ts"],"names":[],"mappings":";;;;;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AE,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACL,CAAC;IAED,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;IAC5B,CAAC;;AA5GL,gDA6GC"}
|
@@ -10,7 +10,7 @@ function getBuiltinRuntimeHosts() {
|
|
10
10
|
pluginHosts.set('custom', (_, pluginId, options, runtime) => new custom_worker_1.CustomRuntimeWorker(pluginId, options, runtime));
|
11
11
|
pluginHosts.set('python', (_, pluginId, options) => new python_worker_1.PythonRuntimeWorker(pluginId, options));
|
12
12
|
pluginHosts.set('node', (mainFilename, pluginId, options) => new node_fork_worker_1.NodeForkWorker(mainFilename, pluginId, options));
|
13
|
-
pluginHosts.set('electron', (mainFilename, pluginId, options) => new electron_worker_1.ElectronForkWorker(mainFilename, pluginId, options));
|
13
|
+
pluginHosts.set('electron', (mainFilename, pluginId, options, runtime) => new electron_worker_1.ElectronForkWorker(mainFilename, pluginId, options, runtime));
|
14
14
|
return pluginHosts;
|
15
15
|
}
|
16
16
|
//# sourceMappingURL=runtime-host.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"runtime-host.js","sourceRoot":"","sources":["../../../src/plugin/runtime/runtime-host.ts"],"names":[],"mappings":";;AASA,wDASC;AAjBD,mDAAsD;AACtD,uDAAuD;AACvD,yDAAoD;AACpD,mDAAsD;AAKtD,SAAgB,sBAAsB;IAClC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEnD,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,mCAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAClH,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,mCAAmB,CAAC,QAAQ,EAAE,O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E,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAE5I,OAAO,WAAW,CAAC;AACvB,CAAC"}
|
package/package.json
CHANGED
@@ -5,15 +5,17 @@ import { RpcMessage, RpcPeer } from "../../rpc";
|
|
5
5
|
import { SidebandSocketSerializer } from "../socket-serializer";
|
6
6
|
import { ChildProcessWorker } from "./child-process-worker";
|
7
7
|
import { RuntimeWorkerOptions } from "./runtime-worker";
|
8
|
+
import type { ScryptedRuntime } from '../../runtime';
|
8
9
|
|
9
10
|
export class ElectronForkWorker extends ChildProcessWorker {
|
11
|
+
static allocatedDisplays = new Set<number>();
|
12
|
+
allocatedDisplay: number;
|
10
13
|
|
11
|
-
constructor(mainFilename: string, pluginId: string, options: RuntimeWorkerOptions) {
|
14
|
+
constructor(mainFilename: string, pluginId: string, options: RuntimeWorkerOptions, runtime: ScryptedRuntime) {
|
12
15
|
super(pluginId, options);
|
13
16
|
|
14
17
|
const { env, pluginDebug } = options;
|
15
18
|
|
16
|
-
|
17
19
|
const execArgv: string[] = process.execArgv.slice();
|
18
20
|
if (pluginDebug) {
|
19
21
|
// execArgv.push(`--inspect=0.0.0.0:${pluginDebug.inspectPort}`);
|
@@ -23,8 +25,22 @@ export class ElectronForkWorker extends ChildProcessWorker {
|
|
23
25
|
const electronBin: string = require('electron');
|
24
26
|
const args = [electronBin];
|
25
27
|
if (process.platform === 'linux') {
|
28
|
+
// crappy but should work.
|
29
|
+
for (let i = 50; i < 100; i++) {
|
30
|
+
if (!ElectronForkWorker.allocatedDisplays.has(i)) {
|
31
|
+
this.allocatedDisplay = i;
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
if (!this.allocatedDisplay)
|
37
|
+
throw new Error('unable to allocate DISPLAY for xvfb-run');
|
38
|
+
|
39
|
+
ElectronForkWorker.allocatedDisplays.add(this.allocatedDisplay);
|
40
|
+
|
26
41
|
// requires xvfb-run as electron does not support the chrome --headless flag.
|
27
|
-
|
42
|
+
// dummy up a DISPLAY env variable. this value numerical because of the way it is.
|
43
|
+
args.unshift('xvfb-run', '-n', this.allocatedDisplay.toString());
|
28
44
|
// https://github.com/gpuweb/gpuweb/wiki/Implementation-Status#chromium-chrome-edge-etc
|
29
45
|
args.push('--no-sandbox', '--enable-unsafe-webgpu', '--ignore-gpu-blocklist', '--enable-features=Vulkan', '--disable-vulkan-surface');
|
30
46
|
}
|
@@ -47,6 +63,9 @@ export class ElectronForkWorker extends ChildProcessWorker {
|
|
47
63
|
// execArgv,
|
48
64
|
});
|
49
65
|
|
66
|
+
this.worker.on('exit', () => {
|
67
|
+
});
|
68
|
+
|
50
69
|
this.worker.send({
|
51
70
|
pluginId,
|
52
71
|
options,
|
@@ -55,6 +74,12 @@ export class ElectronForkWorker extends ChildProcessWorker {
|
|
55
74
|
this.setupWorker();
|
56
75
|
}
|
57
76
|
|
77
|
+
kill(): void {
|
78
|
+
super.kill();
|
79
|
+
if (this.worker)
|
80
|
+
ElectronForkWorker.allocatedDisplays.delete(this.allocatedDisplay);
|
81
|
+
}
|
82
|
+
|
58
83
|
setupRpcPeer(peer: RpcPeer): void {
|
59
84
|
this.worker.on('message', (message, sendHandle) => {
|
60
85
|
if ((message as any).type && sendHandle) {
|
@@ -13,7 +13,7 @@ export function getBuiltinRuntimeHosts() {
|
|
13
13
|
pluginHosts.set('custom', (_, pluginId, options, runtime) => new CustomRuntimeWorker(pluginId, options, runtime));
|
14
14
|
pluginHosts.set('python', (_, pluginId, options) => new PythonRuntimeWorker(pluginId, options));
|
15
15
|
pluginHosts.set('node', (mainFilename, pluginId, options) => new NodeForkWorker(mainFilename, pluginId, options));
|
16
|
-
pluginHosts.set('electron', (mainFilename, pluginId, options) => new ElectronForkWorker(mainFilename, pluginId, options));
|
16
|
+
pluginHosts.set('electron', (mainFilename, pluginId, options, runtime) => new ElectronForkWorker(mainFilename, pluginId, options, runtime));
|
17
17
|
|
18
18
|
return pluginHosts;
|
19
19
|
}
|