37 lines · 1.5 KB · JavaScript
RawDownload
'use strict';// window.lilt bridge for the hub and the bar. See README.md for the contract.const { contextBridge, ipcRenderer } = require('electron'); const inv = (ch, ...a) => ipcRenderer.invoke(ch, ...a);const on = (ch, cb) => ipcRenderer.on(ch, (_, v) => cb(v)); contextBridge.exposeInMainWorld('lilt', {  state: () => inv('state'),  onState: cb => on('state', cb),  onNavigate: cb => on('navigate', cb),  set: (path, value) => inv('set', path, value),  upsert: (coll, item) => inv('upsert', coll, item),  remove: (coll, id) => inv('remove', coll, id),  historyAction: (id, action) => inv('historyAction', id, action),  copy: text => inv('copy', text),  audioUrl: id => inv('audioUrl', id),  toggleRecording: () => inv('toggleRecording'),  cancelRecording: () => inv('cancelRecording'),  notetaker: onOff => inv('notetaker', onOff),  downloadModel: id => inv('downloadModel', id),  captureHotkey: target => inv('captureHotkey', target),  assistant: text => inv('assistant', text),  stopAssistant: () => inv('stopAssistant'),  transform: (id, text) => inv('transform', id, text),  mcpAdd: client => inv('mcpAdd', client),  open: target => inv('open', target),  exportData: () => inv('exportData'),  deleteData: () => inv('deleteData'),  win: action => inv('win', action),  bar: {    onCommand: cb => on('bar', cb),    audio: (buf, ms) => ipcRenderer.send('bar:audio', buf, ms),    action: name => ipcRenderer.send('bar:action', name),    resize: (w, h) => ipcRenderer.send('bar:resize', w, h),  },});