Files
OmniRoute/bin/cli/tray/index.mjs
diegosouzapw b3cfac3c14 feat(cli): fase 8.8 — system tray + autostart (omniroute serve --tray)
- bin/cli/tray/index.mjs: initTray/killTray/isTrayActive/isTraySupported
- bin/cli/tray/traySystray.mjs: systray2 para macOS/Linux (graceful fallback)
- bin/cli/tray/trayWindows.mjs: PowerShell NotifyIcon (sem binário extra)
- bin/cli/tray/autostart.mjs: launchd (macOS), reg (Windows), .desktop (Linux)
- bin/cli/commands/tray.mjs: subcomandos show/hide/quit
- bin/cli/commands/autostart.mjs: subcomandos enable/disable/status
- serve.mjs: flags --tray/--no-tray, integração após servidor iniciar
- i18n: chaves tray.*, autostart.*, serve.tray/no_tray em en.json e pt-BR.json
- check-env-doc-sync: DISPLAY e WAYLAND_DISPLAY adicionados ao allowlist (sinais do host OS)
- 8 testes unitários cobrindo autostart por plataforma e importação dos módulos
2026-05-15 04:07:20 -03:00

27 lines
723 B
JavaScript

import { isTraySupported, initSystrayUnix, killSystrayUnix } from "./traySystray.mjs";
import { initWinTray, killWinTray } from "./trayWindows.mjs";
let active = null;
export { isTraySupported };
export function initTray({ port, onQuit, onOpenDashboard, onShowLogs }) {
if (!isTraySupported()) return null;
const ctx = { port, onQuit, onOpenDashboard, onShowLogs };
active = process.platform === "win32" ? initWinTray(ctx) : initSystrayUnix(ctx);
return active;
}
export function killTray() {
if (!active) return;
try {
if (process.platform === "win32") killWinTray(active);
else killSystrayUnix(active);
} catch {}
active = null;
}
export function isTrayActive() {
return active !== null;
}