export working

This commit is contained in:
Siddharth
2025-11-16 16:02:21 -07:00
parent 75388e1218
commit 34e9efdb73
18 changed files with 1336 additions and 4 deletions
+1
View File
@@ -37,6 +37,7 @@ interface Window {
setRecordingState: (recording: boolean) => Promise<void>
onStopRecordingFromTray: (callback: () => void) => () => void
openExternalUrl: (url: string) => Promise<{ success: boolean; error?: string }>
saveExportedVideo: (videoData: ArrayBuffer, fileName: string) => Promise<{ success: boolean; path?: string; message?: string }>
}
}
+22 -1
View File
@@ -1,4 +1,4 @@
import { ipcMain, desktopCapturer, BrowserWindow, shell } from 'electron'
import { ipcMain, desktopCapturer, BrowserWindow, shell, app } from 'electron'
import { startMouseTracking, stopMouseTracking, getTrackingData } from './mouseTracking'
import fs from 'node:fs/promises'
import path from 'node:path'
@@ -144,4 +144,25 @@ export function registerIpcHandlers(
return { success: false, error: String(error) }
}
})
ipcMain.handle('save-exported-video', async (_, videoData: ArrayBuffer, fileName: string) => {
try {
const downloadsPath = app.getPath('downloads')
const videoPath = path.join(downloadsPath, fileName)
await fs.writeFile(videoPath, Buffer.from(videoData))
return {
success: true,
path: videoPath,
message: 'Video exported successfully'
}
} catch (error) {
console.error('Failed to save exported video:', error)
return {
success: false,
message: 'Failed to save exported video',
error: String(error)
}
}
})
}
+4 -1
View File
@@ -41,5 +41,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
},
openExternalUrl: (url: string) => {
return ipcRenderer.invoke('open-external-url', url)
}
},
saveExportedVideo: (videoData: ArrayBuffer, fileName: string) => {
return ipcRenderer.invoke('save-exported-video', videoData, fileName)
},
})