@scrypted/server 0.115.19 → 0.115.21
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/deferred.d.ts +7 -0
- package/dist/deferred.js +30 -0
- package/dist/deferred.js.map +1 -0
- package/dist/plugin/plugin-console.d.ts +3 -0
- package/dist/plugin/plugin-console.js +9 -0
- package/dist/plugin/plugin-console.js.map +1 -1
- package/dist/plugin/plugin-remote-worker.js +168 -16
- package/dist/plugin/plugin-remote-worker.js.map +1 -1
- package/dist/plugin/runtime/node-thread-worker.d.ts +5 -2
- package/dist/plugin/runtime/node-thread-worker.js +55 -9
- package/dist/plugin/runtime/node-thread-worker.js.map +1 -1
- package/dist/rpc-buffer-serializer.js +2 -0
- package/dist/rpc-buffer-serializer.js.map +1 -1
- package/dist/scrypted-plugin-main.js +3 -12
- package/dist/scrypted-plugin-main.js.map +1 -1
- package/dist/scrypted-server-main.js +1 -1
- package/dist/scrypted-server-main.js.map +1 -1
- package/package.json +1 -1
- package/src/deferred.ts +25 -0
- package/src/plugin/plugin-console.ts +12 -0
- package/src/plugin/plugin-remote-worker.ts +190 -18
- package/src/plugin/runtime/node-thread-worker.ts +69 -10
- package/src/rpc-buffer-serializer.ts +2 -0
- package/src/scrypted-plugin-main.ts +3 -12
- package/src/scrypted-server-main.ts +1 -1
@@ -1,10 +1,10 @@
|
|
1
1
|
import net from 'net';
|
2
|
-
import v8 from 'v8';
|
3
2
|
import worker_threads from "worker_threads";
|
4
3
|
import { getPluginNodePath } from "./plugin/plugin-npm-dependencies";
|
5
4
|
import { startPluginRemote } from "./plugin/plugin-remote-worker";
|
6
5
|
import { SidebandSocketSerializer } from "./plugin/socket-serializer";
|
7
6
|
import { RpcMessage } from "./rpc";
|
7
|
+
import { NodeThreadWorker } from './plugin/runtime/node-thread-worker';
|
8
8
|
|
9
9
|
function start(mainFilename: string) {
|
10
10
|
const pluginId = process.argv[3];
|
@@ -13,17 +13,8 @@ function start(mainFilename: string) {
|
|
13
13
|
if (process.argv[2] === 'child-thread') {
|
14
14
|
console.log('starting thread', pluginId);
|
15
15
|
const { port } = worker_threads.workerData as { port: worker_threads.MessagePort };
|
16
|
-
const peer = startPluginRemote(mainFilename, pluginId, (message, reject) =>
|
17
|
-
|
18
|
-
port.postMessage(v8.serialize(message));
|
19
|
-
}
|
20
|
-
catch (e) {
|
21
|
-
reject?.(e);
|
22
|
-
}
|
23
|
-
});
|
24
|
-
peer.transportSafeArgumentTypes.add(Buffer.name);
|
25
|
-
peer.transportSafeArgumentTypes.add(Uint8Array.name);
|
26
|
-
port.on('message', message => peer.handleMessage(v8.deserialize(message)));
|
16
|
+
const peer = startPluginRemote(mainFilename, pluginId, (message, reject, serializationContext) => NodeThreadWorker.send(message, port, reject, serializationContext));
|
17
|
+
NodeThreadWorker.setupRpcPeer(peer, port);
|
27
18
|
port.on('messageerror', e => {
|
28
19
|
console.error('message error', e);
|
29
20
|
process.exit(1);
|
@@ -108,7 +108,7 @@ app.use(bodyParser.urlencoded({ extended: false }) as any)
|
|
108
108
|
app.use(bodyParser.json())
|
109
109
|
|
110
110
|
// parse some custom thing into a Buffer
|
111
|
-
app.use(bodyParser.raw({ type: 'application
|
111
|
+
app.use(bodyParser.raw({ type: 'application/*', limit: 100000000 }) as any)
|
112
112
|
|
113
113
|
async function start(mainFilename: string, options?: {
|
114
114
|
onRuntimeCreated?: (runtime: ScryptedRuntime) => Promise<void>,
|