Files
Recordly/electron/ipc/handlers.ts
webadderall 673dfdadd3 refactor: extract registerIpcHandlers into 8 focused register/ modules
handlers.ts reduced from 2930 → 65 lines (pure delegation).

New files under electron/ipc/register/:
- sources.ts    — get-sources, select-source, show-source-highlight, open-source-selector
- recording.ts  — start/stop/pause native + ffmpeg, mux, store, set-recording-state, get-cursor-telemetry
- permissions.ts — accessibility/screen permissions, open-external-url
- assets.ts     — wallpaper thumbnails, asset-base-path, list-asset-dir, read-local-file
- export.ts     — native-video-export-*, save-exported-video
- captions.ts   — whisper model, file pickers, generate-auto-captions
- project.ts    — project files, recordings dir, video/session state, delete-recording
- settings.ts   — shortcuts, recording prefs, countdown, platform info

Also moved shared helpers:
- getMacPrivacySettingsUrl, approveUserPath → utils.ts
- isTrustedProjectPath → project/manager.ts
2026-04-17 20:13:47 +10:00

66 lines
2.2 KiB
TypeScript

import { BrowserWindow } from "electron";
import {
windowsCaptureProcess,
setWindowsCaptureProcess,
setWindowsCaptureTargetPath,
setWindowsNativeCaptureActive,
setNativeScreenRecordingActive,
setWindowsCaptureStopRequested,
setWindowsCapturePaused,
setWindowsSystemAudioPath,
setWindowsMicAudioPath,
setWindowsPendingVideoPath,
selectedSource,
} from "./state";
import { registerSourceHandlers } from "./register/sources";
import { registerRecordingHandlers } from "./register/recording";
import { registerPermissionHandlers } from "./register/permissions";
import { registerAssetHandlers } from "./register/assets";
import { registerExportHandlers } from "./register/export";
import { registerCaptionHandlers } from "./register/captions";
import { registerProjectHandlers } from "./register/project";
import { registerSettingsHandlers } from "./register/settings";
export { cleanupNativeVideoExportSessions } from "./export/native-video";
/** Returns the currently selected source ID for setDisplayMediaRequestHandler */
export function getSelectedSourceId(): string | null {
return (selectedSource?.id as string | null) ?? null;
}
export function killWindowsCaptureProcess() {
if (windowsCaptureProcess) {
try {
windowsCaptureProcess.kill();
} catch {
/* ignore */
}
setWindowsCaptureProcess(null);
setWindowsCaptureTargetPath(null);
setWindowsNativeCaptureActive(false);
setNativeScreenRecordingActive(false);
setWindowsCaptureStopRequested(false);
setWindowsCapturePaused(false);
setWindowsSystemAudioPath(null);
setWindowsMicAudioPath(null);
setWindowsPendingVideoPath(null);
}
}
export function registerIpcHandlers(
createEditorWindow: () => void,
createSourceSelectorWindow: () => BrowserWindow,
_getMainWindow: () => BrowserWindow | null,
getSourceSelectorWindow: () => BrowserWindow | null,
onRecordingStateChange?: (recording: boolean, sourceName: string) => void,
) {
registerSourceHandlers({ createEditorWindow, createSourceSelectorWindow, getSourceSelectorWindow });
registerRecordingHandlers(onRecordingStateChange);
registerPermissionHandlers();
registerAssetHandlers();
registerExportHandlers();
registerCaptionHandlers();
registerProjectHandlers();
registerSettingsHandlers();
}