mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
28 lines
623 B
TypeScript
28 lines
623 B
TypeScript
import { AsyncCall } from 'async-call-rpc';
|
|
|
|
import { getExposedMeta } from './exposed';
|
|
|
|
const helperToMainServer: PeersAPIs.HelperToMain = {
|
|
getMeta: () => getExposedMeta(),
|
|
};
|
|
|
|
export const mainRPC = AsyncCall<PeersAPIs.MainToHelper>(helperToMainServer, {
|
|
strict: {
|
|
unknownMessage: false,
|
|
},
|
|
channel: {
|
|
on(listener) {
|
|
const f = (e: Electron.MessageEvent) => {
|
|
listener(e.data);
|
|
};
|
|
process.parentPort.on('message', f);
|
|
return () => {
|
|
process.parentPort.off('message', f);
|
|
};
|
|
},
|
|
send(data) {
|
|
process.parentPort.postMessage(data);
|
|
},
|
|
},
|
|
});
|