UNPKG

@todesktop/plugin-recall

Version:

ToDesktop plugin for Recall.ai Desktop Recording SDK - Plugin package

235 lines (230 loc) 8 kB
'use strict'; var electron = require('electron'); /** * Shared types and constants for Recall Desktop SDK integration */ // IPC channel names - use unique namespace to avoid conflicts const IPC_CHANNELS = { // SDK lifecycle INIT_SDK: "recall-desktop:init-sdk", SHUTDOWN_SDK: "recall-desktop:shutdown-sdk", GET_STATUS: "recall-desktop:get-status", // Recording management START_RECORDING: "recall-desktop:start-recording", STOP_RECORDING: "recall-desktop:stop-recording", PAUSE_RECORDING: "recall-desktop:pause-recording", RESUME_RECORDING: "recall-desktop:resume-recording", UPLOAD_RECORDING: "recall-desktop:upload-recording", // Desktop audio recording PREPARE_DESKTOP_AUDIO: "recall-desktop:prepare-desktop-audio", // Permission management REQUEST_PERMISSION: "recall-desktop:request-permission", // Configuration SET_CONFIG: "recall-desktop:set-config", GET_CONFIG: "recall-desktop:get-config", // Event subscription SUBSCRIBE_EVENTS: "recall-desktop:subscribe-events", UNSUBSCRIBE_EVENTS: "recall-desktop:unsubscribe-events", }; /** * ToDesktop Recall Desktop SDK Plugin - Preload Script * * This file runs in the renderer process with Node.js access. * * ToDesktop plugins should export functions; the ToDesktop runtime will * attach them under `window.todesktop.recallDesktop` automatically. */ /** * Initialize the Recall SDK * @returns Promise resolving to initialization result */ async function initSdk() { return electron.ipcRenderer.invoke(IPC_CHANNELS.INIT_SDK); } /** * Shutdown the Recall SDK * @returns Promise resolving to shutdown result */ async function shutdownSdk() { return electron.ipcRenderer.invoke(IPC_CHANNELS.SHUTDOWN_SDK); } /** * Get current plugin and SDK status * @returns Promise resolving to plugin status */ async function getStatus() { return electron.ipcRenderer.invoke(IPC_CHANNELS.GET_STATUS); } /** * Start recording a meeting * @param windowId The meeting window ID * @param uploadToken Upload token from your backend * @returns Promise resolving to recording start result */ async function startRecording(windowId, uploadToken) { const request = { windowId, uploadToken }; return electron.ipcRenderer.invoke(IPC_CHANNELS.START_RECORDING, request); } /** * Stop recording a meeting * @param windowId The meeting window ID * @returns Promise resolving to recording stop result */ async function stopRecording(windowId) { const request = { windowId }; return electron.ipcRenderer.invoke(IPC_CHANNELS.STOP_RECORDING, request); } /** * Pause recording a meeting * @param windowId The meeting window ID * @returns Promise resolving to recording pause result */ async function pauseRecording(windowId) { const request = { windowId }; return electron.ipcRenderer.invoke(IPC_CHANNELS.PAUSE_RECORDING, request); } /** * Resume recording a meeting * @param windowId The meeting window ID * @returns Promise resolving to recording resume result */ async function resumeRecording(windowId) { const request = { windowId }; return electron.ipcRenderer.invoke(IPC_CHANNELS.RESUME_RECORDING, request); } /** * Upload a completed recording * @param windowId The meeting window ID * @returns Promise resolving to upload start result */ async function uploadRecording(windowId) { const request = { windowId }; return electron.ipcRenderer.invoke(IPC_CHANNELS.UPLOAD_RECORDING, request); } /** * Prepare desktop audio recording for non-meeting audio capture * @returns Promise resolving to desktop audio preparation result */ async function prepareDesktopAudioRecording() { return electron.ipcRenderer.invoke(IPC_CHANNELS.PREPARE_DESKTOP_AUDIO); } /** * Request a specific permission from the user * @param permission The permission to request * @returns Promise resolving to permission request result */ async function requestPermission(permission) { return electron.ipcRenderer.invoke(IPC_CHANNELS.REQUEST_PERMISSION, permission); } /** * Update plugin configuration * @param config Configuration updates * @returns Promise resolving to update result */ async function setConfig(config) { return electron.ipcRenderer.invoke(IPC_CHANNELS.SET_CONFIG, config); } /** * Get current plugin configuration * @returns Promise resolving to current configuration */ async function getConfig() { return electron.ipcRenderer.invoke(IPC_CHANNELS.GET_CONFIG); } /** * Subscribe to SDK events * @param eventType The type of event to listen for * @param callback Function to call when event occurs * @returns Function to unsubscribe from the event */ function addEventListener(eventType, callback) { const channel = `recall-desktop:event:${eventType}`; // Fire-and-forget subscribe to main electron.ipcRenderer.invoke(IPC_CHANNELS.SUBSCRIBE_EVENTS, eventType).catch(console.error); const listener = (_event, data) => { callback(data); }; electron.ipcRenderer.on(channel, listener); // Return unsubscribe function return () => { electron.ipcRenderer.removeListener(channel, listener); electron.ipcRenderer.invoke(IPC_CHANNELS.UNSUBSCRIBE_EVENTS, eventType).catch(console.error); }; } /** * Get plugin version * @returns Plugin version string */ function getVersion() { return '1.0.0'; } /** * Convenience method for handling meeting detection events * @param callback Function to call when a meeting is detected * @returns Function to unsubscribe from the event */ function onMeetingDetected(callback) { return addEventListener('meeting-detected', callback); } /** * Convenience method for handling recording state changes * @param callback Function to call when recording state changes * @returns Function to unsubscribe from the event */ function onRecordingStateChange(callback) { return addEventListener('sdk-state-change', callback); } /** * Convenience method for handling upload progress updates * @param callback Function to call when upload progress updates * @returns Function to unsubscribe from the event */ function onUploadProgress(callback) { return addEventListener('upload-progress', callback); } /** * Convenience method for handling permission status updates * @param callback Function to call when permission status changes * @returns Function to unsubscribe from the event */ function onPermissionStatusChange(callback) { return addEventListener('permission-status', callback); } /** * Convenience method for handling SDK errors * @param callback Function to call when SDK errors occur * @returns Function to unsubscribe from the event */ function onError(callback) { return addEventListener('error', callback); } /** * Convenience method for handling real-time events (transcription, participants, etc.) * @param callback Function to call when real-time events occur * @returns Function to unsubscribe from the event */ function onRealtimeEvent(callback) { return addEventListener('realtime-event', callback); } console.log('RecallDesktop: Preload script loaded successfully'); exports.addEventListener = addEventListener; exports.getConfig = getConfig; exports.getStatus = getStatus; exports.getVersion = getVersion; exports.initSdk = initSdk; exports.onError = onError; exports.onMeetingDetected = onMeetingDetected; exports.onPermissionStatusChange = onPermissionStatusChange; exports.onRealtimeEvent = onRealtimeEvent; exports.onRecordingStateChange = onRecordingStateChange; exports.onUploadProgress = onUploadProgress; exports.pauseRecording = pauseRecording; exports.prepareDesktopAudioRecording = prepareDesktopAudioRecording; exports.requestPermission = requestPermission; exports.resumeRecording = resumeRecording; exports.setConfig = setConfig; exports.shutdownSdk = shutdownSdk; exports.startRecording = startRecording; exports.stopRecording = stopRecording; exports.uploadRecording = uploadRecording; //# sourceMappingURL=preload.js.map