@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.
@@ -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
- try {
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/zip', limit: 100000000 }) as any)
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>,