-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
62 lines (52 loc) · 2.88 KB
/
preload.js
File metadata and controls
62 lines (52 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
platform: process.platform,
// Settings
getSettings: () => ipcRenderer.invoke('get-settings'),
saveSettings: (settings) => ipcRenderer.invoke('save-settings', settings),
// Text typing into other apps
typeText: (text) => ipcRenderer.invoke('type-text', text),
openAccessibilitySettings: () => ipcRenderer.invoke('open-accessibility-settings'),
// Local Whisper transcription (runs in main process)
transcribeLocal: (audioData, language) => ipcRenderer.invoke('transcribe-local', Array.from(audioData), language),
// Whisper progress events
onWhisperProgress: (callback) => {
ipcRenderer.on('whisper-progress', (event, message, percent) => callback(message, percent));
},
// Window controls
minimizeWindow: () => ipcRenderer.invoke('minimize-window'),
closeWindow: () => ipcRenderer.invoke('close-window'),
setRecordingState: (state) => ipcRenderer.invoke('set-recording-state', state),
setProcessingState: (state) => ipcRenderer.invoke('set-processing-state', state),
getProcessingState: () => ipcRenderer.invoke('get-processing-state'),
captureSelection: () => ipcRenderer.invoke('capture-selection'),
/** Full-screen region snip → OpenAI vision OCR → resolves when done or cancelled */
startRegionOcr: () => ipcRenderer.invoke('region-ocr'),
openWritingAssistant: () => ipcRenderer.invoke('open-writing-assistant'),
resizeWindow: (width, height) => ipcRenderer.send('resize-window', { width, height }),
enterMiniMode: () => ipcRenderer.invoke('enter-mini-mode'),
exitMiniMode: () => ipcRenderer.invoke('exit-mini-mode'),
toggleRecordingMain: () => ipcRenderer.invoke('toggle-recording-main'),
getRecordingState: () => ipcRenderer.invoke('get-recording-state'),
/** macOS packaged: null or { shortStatus, toast } when Intel build is running on Apple Silicon (Rosetta). */
getMacosBinaryInstallIssue: () => ipcRenderer.invoke('get-macos-binary-install-issue'),
disableGlobalShortcuts: () => ipcRenderer.invoke('disable-global-shortcuts'),
enableGlobalShortcuts: () => ipcRenderer.invoke('enable-global-shortcuts'),
// Events from main process
onToggleRecording: (callback) => {
ipcRenderer.on('toggle-recording', (event, isRecording) => callback(isRecording));
},
onProcessingState: (callback) => {
ipcRenderer.on('processing-state', (_event, isProcessing) => callback(isProcessing));
},
onTriggerAnalyze: (callback) => {
ipcRenderer.on('trigger-analyze', () => callback());
},
onAppToast: (callback) => {
ipcRenderer.on('app-toast', (_event, payload) => callback(payload));
},
// Custom Window Dragging (for cursor support on Windows)
startDrag: (offset) => ipcRenderer.send('window-drag-start', offset),
moveDrag: () => ipcRenderer.send('window-drag-move'),
endDrag: () => ipcRenderer.send('window-drag-end')
});