18 lines
626 B
TypeScript
18 lines
626 B
TypeScript
import { contextBridge, ipcRenderer } from 'electron'
|
|
|
|
import type { RecordingCursorPayload } from '../main/recording-core'
|
|
|
|
contextBridge.exposeInMainWorld('planetRecordingCursor', {
|
|
onUpdate: (callback: (payload: RecordingCursorPayload) => void) => {
|
|
const listener = (_event: Electron.IpcRendererEvent, payload: unknown) => {
|
|
if (payload && typeof payload === 'object') {
|
|
callback(payload as RecordingCursorPayload)
|
|
}
|
|
}
|
|
ipcRenderer.on('planet:recording-cursor-update', listener)
|
|
return () => {
|
|
ipcRenderer.removeListener('planet:recording-cursor-update', listener)
|
|
}
|
|
},
|
|
})
|