(clientId, category, action, options = {})
| 316 | |
| 317 | const DEBUG = false; // Set to true for development/debugging |
| 318 | const PING_INTERVAL = 30000; // 30 seconds |
| 319 | |
| 320 | function debugLog(...args) { |
| 321 | if (DEBUG) { |
| 322 | console.log(...args); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | // Server mode detection |
| 327 | const isServerMode = process.argv.includes('--server'); |
| 328 | let httpServer = null; |
| 329 | let httpServerEpoch = 0; |
| 330 | let http80Server = null; |
| 331 | let electronUiServer = null; |
| 332 | let electronUiPort = null; |
| 333 | let wss = null; // WebSocket server |
| 334 | let wsClients = null; // WebSocket clients Set |
| 335 | let letsEncryptRenewInFlight = false; |
| 336 | |
| 337 | // Store pending context menu actions for server mode (browser access) |
| 338 | const pendingContextMenus = new Map(); |
| 339 | let contextMenuRequestIdCounter = 0; |
| 340 | |
| 341 | // Handler registry for WebSocket IPC calls in server mode |
| 342 | // This allows us to directly invoke handlers without going through the renderer |
| 343 | const ipcHandlerRegistry = new Map(); |
| 344 | |
| 345 | // Auto-register every ipcMain.handle into the WebSocket registry. |
| 346 | // Without this, Docker/server-mode falls back to executeJavaScript on the hidden |
| 347 | // window for unregistered channels (e.g. getThumbnail) — which hangs/times out. |
| 348 | const _ipcMainHandle = ipcMain.handle.bind(ipcMain); |
| 349 | ipcMain.handle = (channel, handler) => { |
| 350 | ipcHandlerRegistry.set(channel, handler); |
| 351 | return _ipcMainHandle(channel, handler); |
| 352 | }; |
| 353 | |
| 354 | // Helper function to register IPC handlers and add them to the registry |
| 355 | function registerIpcHandler(channel, handler) { |
| 356 | ipcMain.handle(channel, handler); |
| 357 | } |
nothing calls this directly
no outgoing calls
no test coverage detected