// This IPC adapter exists only for the browser UI smoke test. import { app } from 'electron'; import { createEngine } from '../src/engine.mjs'; app.enableSandbox(); app.setPath('userData', process.env.RS_INTERACTION_ROOT); app.on('window-all-closed', () => {}); app.whenReady().then(async () => { let framePending = false; const engine = await createEngine({ directory: process.env.RS_INTERACTION_ROOT, canEmitFrame: () => !framePending, emit: value => { if (value.event === 'frame') framePending = true; process.send?.({ event: value }, () => { if (value.event === 'frame') framePending = false; }); } }); process.on('message', async ({ id, command, args }) => { try { let result; if (command === 'testEvaluate') result = await engine.tabs.get(args.tabId).view.webContents.executeJavaScript(args.code); else if (command === 'shutdown') { await engine.shutdown(); process.send?.({ id, result: null }); app.exit(0); return; } else result = await engine.command(command, args); process.send?.({ id, result }); } catch (error) { process.send?.({ id, error: String(error) }); } }); process.on('disconnect', () => { void engine.shutdown().finally(() => app.exit(0)); }); process.send?.({ ready: true }); });