mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
## Critical Fixes - #1: Server readiness — waitForServer() polls before loading window - #2: Restart timeout — 5s + SIGKILL prevents IPC handler from hanging - #3: changePort — now stops/restarts server on new port ## Important Fixes - #4: Tray cleanup — destroy old Tray before recreating - #5: IPC emission — server-status & port-changed events - #6: Disposer pattern — replaces removeAllListeners - #7: useSyncExternalStore — eliminates 5x re-renders ## Minor: #8-#16 (dead code, CSP, platform titlebar, types, errors, version) Tests: 76 / 15 suites (was 64/9)
OmniRoute Electron Desktop App
This directory contains the Electron desktop application wrapper for OmniRoute.
Structure
electron/
├── main.js # Main process (window management, IPC)
├── preload.js # Preload script (secure bridge to renderer)
├── package.json # Electron-specific dependencies
├── types.d.ts # TypeScript definitions
└── assets/ # Application icons and resources
Development
Prerequisites
- Build the Next.js app first:
npm run build
- Install Electron dependencies:
cd electron
npm install
Running in Development
- Start the Next.js development server:
npm run dev
- In another terminal, start Electron:
cd electron
npm run dev
Running in Production Mode
- Build Next.js in standalone mode:
npm run build
- Start Electron:
cd electron
npm start
Building
Build for Current Platform
cd electron
npm run build
Build for Specific Platforms
# Windows
npm run build:win
# macOS
npm run build:mac
# Linux
npm run build:linux
Output
Built applications are placed in dist-electron/:
- Windows:
.exeinstaller (NSIS) - macOS:
.dmginstaller - Linux:
.AppImage
Features
- System Tray Integration: Minimize to tray, quick actions
- Native Notifications: Desktop notifications
- Window Management: Minimize, maximize, close
- Auto-start: Option to launch on system startup
- Offline Support: Local server bundled with the app
Configuration
Environment Variables
The Electron app respects these environment variables:
OMNIROUTE_PORT: Server port (default: 20128)NODE_ENV: Set to 'production' for production builds
Custom Icon
Place your icons in assets/:
icon.ico- Windows icon (256x256)icon.icns- macOS icon bundleicon.png- Linux/general use (512x512)tray-icon.png- System tray icon (16x16 or 32x32)
IPC Channels
| Channel | Direction | Description |
|---|---|---|
get-app-info |
Renderer → Main | Get app name, version, platform |
open-external |
Renderer → Main | Open URL in default browser |
get-data-dir |
Renderer → Main | Get data directory path |
restart-server |
Renderer → Main | Restart the internal server |
server-status |
Main → Renderer | Server status updates |
port-changed |
Main → Renderer | Port change notifications |
Security
contextIsolation: true- Isolates renderer from Node.jsnodeIntegration: false- No direct Node.js access in renderer- Preload script validates IPC channels
- No remote code execution
Troubleshooting
App Won't Start
- Check if port 20128 is available
- Check logs in the console
- Verify the build output exists
White Screen
- Verify Next.js build exists
- Check the server URL in main.js
- Check for console errors
Build Fails
- Ensure you have build tools installed:
- Windows: Visual Studio Build Tools
- macOS: Xcode Command Line Tools
- Linux: build-essential, libsecret-1-dev
License
MIT