This commit is contained in:
Manav Rathi 2024-07-30 11:23:32 +05:30
parent 1a9170632e
commit 1e720b4b7d
No known key found for this signature in database
3 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,10 @@
console.log("in utility process");
process.parentPort.once("message", (e) => {
console.log("got message in utility process", e);
const [port] = e.ports;
port?.on("message", (e2) => {
console.log("got message on port in utility process", e2);
});
});

View File

@ -62,7 +62,7 @@ import { utilityProcess } from "electron/main";
export const createMLSession = () => {
const { port1, port2 } = new MessageChannelMain();
const child = utilityProcess.fork("./ml-utility");
const child = utilityProcess.fork("./ml-util-test");
child.postMessage(/* unused */ "", [port1]);
ipcRenderer.postMessage("ml-session-port", /* unused */ "", [port2]);

View File

@ -334,6 +334,17 @@ export interface Electron {
// - ML
/**
* Create a new ML session.
*
* This creates a new Node.js utility process, and sets things up so that we
* can communicate directly with that utility process using a
* {@link MessagePort} we get back.
*
* For more details about the IPC flow, see: [Note: ML IPC].
*/
createMLSession: () => Promise<MessagePort>;
/**
* Return a CLIP embedding of the given image.
*