Skip to content

Commit

Permalink
Revert "server: add hook for getting runtime"
Browse files Browse the repository at this point in the history
This reverts commit e169d15.
  • Loading branch information
koush committed Apr 29, 2023
1 parent e169d15 commit 02d5b42
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
4 changes: 2 additions & 2 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions server/src/plugin/plugin-remote-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function startPluginRemote(mainFilename: string, pluginId: string, peerSe

let postInstallSourceMapSupport: (scrypted: ScryptedStatic) => void;

const scrypted = attachPluginRemote(peer, {
attachPluginRemote(peer, {
createMediaManager: async (sm, dm) => {
systemManager = sm;
deviceManager = dm
Expand Down Expand Up @@ -394,11 +394,7 @@ export function startPluginRemote(mainFilename: string, pluginId: string, peerSe
}).then(scrypted => {
systemManager = scrypted.systemManager;
deviceManager = scrypted.deviceManager as DeviceManagerImpl;
return scrypted;
});

return {
peer,
scryptedPromise: scrypted,
};
return peer;
}
8 changes: 2 additions & 6 deletions server/src/scrypted-plugin-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,25 @@ import { SidebandSocketSerializer } from "./plugin/socket-serializer";

function start(mainFilename: string) {
if (process.argv[2] === 'child-thread') {
const ret = startPluginRemote(mainFilename, process.argv[3], (message, reject) => {
const peer = startPluginRemote(mainFilename, process.argv[3], (message, reject) => {
try {
worker_threads.parentPort.postMessage(v8.serialize(message));
}
catch (e) {
reject?.(e);
}
});
const { peer } = ret;
peer.transportSafeArgumentTypes.add(Buffer.name);
peer.transportSafeArgumentTypes.add(Uint8Array.name);
worker_threads.parentPort.on('message', message => peer.handleMessage(v8.deserialize(message)));
return ret;
}
else {
const ret = startPluginRemote(mainFilename, process.argv[3], (message, reject, serializationContext) => process.send(message, serializationContext?.sendHandle, {
const peer = startPluginRemote(mainFilename, process.argv[3], (message, reject, serializationContext) => process.send(message, serializationContext?.sendHandle, {
swallowErrors: !reject,
}, e => {
if (e)
reject?.(e);
}));
const { peer } = ret;

peer.transportSafeArgumentTypes.add(Buffer.name);
peer.transportSafeArgumentTypes.add(Uint8Array.name);
Expand All @@ -38,7 +35,6 @@ function start(mainFilename: string) {
console.error('peer host disconnected, exiting.');
process.exit(1);
});
return ret;
}
}

Expand Down

0 comments on commit 02d5b42

Please sign in to comment.