Restructure the Electron application by separating concerns into new modules (windows, ipc, sentinel), introduce TypeScript types for IPC, and update build configurations and entry points for desktop applications. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9203795e-937a-4306-b81d-b4d5c78c240e Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: 714c0a0f-ae39-4276-a53a-1f68eb5443fa Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7c94b7a0-29c7-4f2e-94ef-44b2153872b7/9203795e-937a-4306-b81d-b4d5c78c240e/CdxgfN4 Replit-Helium-Checkpoint-Created: true
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
import { ipcMain } from "electron";
|
|
import { getMainWindow } from "./windows.js";
|
|
import { startWatcher, stopWatcher } from "../services/watcher.js";
|
|
|
|
let pinned = false;
|
|
|
|
export function registerIpcHandlers() {
|
|
ipcMain.handle("watcher:start", async (_event, dir) => {
|
|
if (!dir || typeof dir !== "string") {
|
|
throw new Error("Invalid directory path");
|
|
}
|
|
await startWatcher(dir);
|
|
return true;
|
|
});
|
|
|
|
ipcMain.handle("watcher:stop", async () => {
|
|
await stopWatcher();
|
|
return true;
|
|
});
|
|
|
|
ipcMain.handle("window:toggle-pin", () => {
|
|
const mainWindow = getMainWindow();
|
|
pinned = !pinned;
|
|
mainWindow?.setAlwaysOnTop(pinned, "floating");
|
|
return pinned;
|
|
});
|
|
|
|
ipcMain.handle("window:close", () => {
|
|
const mainWindow = getMainWindow();
|
|
mainWindow?.close();
|
|
});
|
|
|
|
ipcMain.handle("window:minimize", () => {
|
|
const mainWindow = getMainWindow();
|
|
mainWindow?.minimize();
|
|
});
|
|
|
|
ipcMain.handle("window:maximize", () => {
|
|
const mainWindow = getMainWindow();
|
|
if (!mainWindow) return false;
|
|
if (mainWindow.isMaximized()) {
|
|
mainWindow.unmaximize();
|
|
} else {
|
|
mainWindow.maximize();
|
|
}
|
|
return mainWindow.isMaximized();
|
|
});
|
|
|
|
ipcMain.handle("window:is-pinned", () => {
|
|
return pinned;
|
|
});
|
|
}
|