-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
127 lines (107 loc) · 5.6 KB
/
preload.js
File metadata and controls
127 lines (107 loc) · 5.6 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("api", {
// History
getHistory: () => ipcRenderer.invoke("get-history"),
getStats: () => ipcRenderer.invoke("get-stats"),
deleteHistoryItem: (id) => ipcRenderer.invoke("delete-history-item", id),
updateHistoryItem: (data) => ipcRenderer.invoke("update-history-item", data),
readAudioFile: (path) => ipcRenderer.invoke("read-audio-file", path),
// Input
sendBackspace: () => ipcRenderer.invoke("send-backspace"),
pasteString: (text) => ipcRenderer.invoke("paste-string", text),
autoType: (text) => ipcRenderer.invoke("auto-type", text),
// Overlay Processing States
processingStart: () => ipcRenderer.send("processing-start"),
processingEnd: () => ipcRenderer.send("processing-end"),
// Settings
saveSetting: (k, v) => ipcRenderer.send("save-setting", { key: k, value: v }),
onSettingsLoaded: (cb) => ipcRenderer.on("settings-loaded", cb),
// Startup
setStartupSettings: (settings) =>
ipcRenderer.send("set-startup-settings", settings),
getStartupSettings: () => ipcRenderer.send("get-startup-settings"),
onStartupSettingsLoaded: (cb) =>
ipcRenderer.on("startup-settings-loaded", cb),
// LLM
generateText: (data) => ipcRenderer.invoke("generate-text", data),
onActiveWindow: (cb) => ipcRenderer.on("active-window", cb),
// Hotkeys
saveHotkey: (keys) => ipcRenderer.send("save-hotkey", keys),
clearHotkey: () => ipcRenderer.send("clear-hotkey"),
getHotkey: () => ipcRenderer.send("get-hotkey"),
onHotkeyLoaded: (cb) => ipcRenderer.on("hotkey-loaded", cb),
onHotkeySaved: (cb) => ipcRenderer.on("hotkey-saved", cb),
onHotkeyCleared: (cb) => ipcRenderer.on("hotkey-cleared", cb),
saveAIHotkey: (keys) => ipcRenderer.send("save-ai-hotkey", keys),
clearAIHotkey: () => ipcRenderer.send("clear-ai-hotkey"),
getAIHotkey: () => ipcRenderer.send("get-ai-hotkey"),
onAIHotkeyLoaded: (cb) => ipcRenderer.on("ai-hotkey-loaded", cb),
onAIHotkeySaved: (cb) => ipcRenderer.on("ai-hotkey-saved", cb),
onAIHotkeyCleared: (cb) => ipcRenderer.on("ai-hotkey-cleared", cb),
saveChatHotkey: (keys) => ipcRenderer.send("save-chat-hotkey", keys),
clearChatHotkey: () => ipcRenderer.send("clear-chat-hotkey"),
getChatHotkey: () => ipcRenderer.send("get-chat-hotkey"),
onChatHotkeyLoaded: (cb) => ipcRenderer.on("chat-hotkey-loaded", cb),
onChatHotkeySaved: (cb) => ipcRenderer.on("chat-hotkey-saved", cb),
onChatHotkeyCleared: (cb) => ipcRenderer.on("chat-hotkey-cleared", cb),
// Recording events from main
onRecordStart: (cb) => ipcRenderer.on("record-start", cb),
onRecordStop: (cb) => ipcRenderer.on("record-stop", cb),
onRecordingCancelled: (cb) => ipcRenderer.on("recording-cancelled", cb),
onHotkeyPressed: (cb) => ipcRenderer.on("hotkey-pressed", cb),
onHotkeyReleased: (cb) => ipcRenderer.on("hotkey-released", cb),
// Saving audio
saveAudio: (buffer) => ipcRenderer.send("save-audio", buffer),
onSaveComplete: (cb) => ipcRenderer.on("save-complete", cb),
// Speech to text
transcribeAudio: (buffer, context) =>
ipcRenderer.invoke("transcribe-audio", buffer, context),
retranscribeAudio: (id) => ipcRenderer.invoke("retranscribe-audio", id),
// Real-time Whisper
startWhisper: () => ipcRenderer.invoke("start-transcription"),
stopWhisper: () => ipcRenderer.invoke("stop-transcription"),
onWhisperData: (cb) => ipcRenderer.on("transcription-data", (e, data) => cb(data)),
onWhisperStopped: (cb) => ipcRenderer.on("transcription-stopped", cb),
// Auto type
// System
openExternal: (url) => require("electron").shell.openExternal(url),
// Notes
getNotes: () => ipcRenderer.invoke("get-notes"),
saveNote: (note) => ipcRenderer.invoke("save-note", note),
deleteNote: (id) => ipcRenderer.invoke("delete-note", id),
getAIInfo: () => ipcRenderer.invoke("get-ai-info"),
getChatHistory: () => ipcRenderer.invoke("get-chat-history"),
// Window Controls
minimizeWindow: () => ipcRenderer.send("window-minimize"),
maximizeWindow: () => ipcRenderer.send("window-maximize"),
closeWindow: () => ipcRenderer.send("window-close"),
// Overlay Controls
showOverlay: (...args) => ipcRenderer.send("show-overlay", ...args),
showChat: () => ipcRenderer.send("show-chat"),
hideOverlay: () => ipcRenderer.send("hide-overlay"),
sendMicVolume: (vol) => ipcRenderer.send("mic-volume", vol),
cancelRecording: () => ipcRenderer.send("cancel-recording"),
confirmRecording: () => ipcRenderer.send("confirm-recording"),
// Copy Popup
showCopyPopup: (text) => ipcRenderer.send("show-copy-popup", text),
hideCopyPopup: () => ipcRenderer.send("hide-copy-popup"),
// Auth
login: (creds) => ipcRenderer.invoke("auth-login", creds),
authSync: (user) => ipcRenderer.invoke("auth-sync-user", user), // New Sync Method
signup: (creds) => ipcRenderer.invoke("auth-signup", creds),
logout: () => ipcRenderer.invoke("auth-logout"),
getCurrentUser: () => ipcRenderer.invoke("auth-get-current"),
onAuthStateChanged: (cb) => ipcRenderer.on("auth-state-changed", cb),
onAIInfoUpdate: (cb) =>
ipcRenderer.on("ai-info-update", (event, ...args) => cb(...args)),
onUpdateStatus: (cb) =>
ipcRenderer.on("update-status", (event, ...args) => cb(...args)),
onDevLog: (cb) => ipcRenderer.on("dev-log", (event, msg) => cb(msg)),
checkForUpdates: () => ipcRenderer.invoke("check-for-updates"),
quitAndInstall: () => ipcRenderer.send("restart-app"),
testUpdateUI: () => ipcRenderer.send("test-update-ui"),
// Screen Protection
setScreenProtection: (enabled) =>
ipcRenderer.send("set-screen-protection", enabled),
getAppVersion: () => ipcRenderer.invoke("get-app-version"),
});