mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-13 20:56:19 -08:00
* feat(ui): add custom title bar window controls for Windows and Linux Hide the native title bar on win32/linux (titleBarStyle: 'hidden', frame untouched so native resize borders and snapping keep working) and render minimize / maximize-restore / close buttons in the renderer, mirroring the existing macOS traffic-light setup. - New WINDOW:* IPC contract (minimize, toggle-maximize, close, get-state) handled in window.events.ts, resolved from the sender WebContents; close goes through win.close() so window-bounds persistence still runs. - WINDOW:STATE_CHANGED pushed on maximize/unmaximize/fullscreen so the maximize/restore glyph stays correct for OS-triggered changes; controls hide while fullscreen. - WindowControlsComponent mounts once in app-root as a manual popover so it stays in the browser top layer above CDK overlays (dialogs, multi-EPG) - same behavior as macOS traffic lights. - Theme-aware via CSS vars (--app-on-surface, --app-hover-overlay); Windows-red close hover. Drag regions get right padding through a body-level frameless-platform class. - Gated by RuntimeCapabilitiesService.usesCustomWindowControls; PWA and macOS never mount the controls. Includes unit specs for the component and IPC handlers, an Electron E2E suite (window-controls.e2e.ts), and a window-chrome section in docs/architecture/workspace-shell.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(linux): upgrade Electron to 41 for frameless window decorations on Wayland With the native title bar hidden, Linux windows lost the WM-drawn shadow and rounded corners. Electron draws client-side decorations only on native Wayland, and frameless-window CSD (GTK drop shadow + extended resize boundaries) landed in Electron 41 - before that, frameless windows render as plain rectangles. - electron ^39.8.5 -> ^41.7.2 (Wayland auto-detected since 38.2; X11 sessions remain undecorated, matching other frameless Electron apps; Windows keeps its DWM shadow and rounded corners). - better-sqlite3 pinned to exactly 12.9.0: the last release shipping prebuilt binaries for both Node 20 (ABI 115, Jest) and Electron 41 (ABI 145, runtime). 12.10.0 dropped the Node 20 prebuilds, forcing a from-source build that fails without a C++ toolchain. - pnpm override node-abi 3.85.0 -> 3.92.0 so electron-builder install-app-deps can map Electron 41 to ABI 145. Reviewed Electron 40/41 breaking changes: only the renderer clipboard deprecation, which this app does not use. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(e2e): address review feedback and window-managerless Linux CI - Skip the three window-manager-dependent E2E assertions (maximize toggle, main-process state sync, minimize) on Linux CI: GitHub's ubuntu runners drive Electron under xvfb without a window manager, so maximize/minimize state never materializes there. Windows CI and local Linux/macOS runs keep the coverage. - WINDOW:TOGGLE_MAXIMIZE now returns the requested state instead of re-reading isMaximized() right after the call, which races on Linux window managers where maximize()/unmaximize() complete asynchronously; the WINDOW:STATE_CHANGED push stays authoritative. - Skip attaching window-state push listeners on macOS, where the custom controls never mount and the IPC traffic had no subscriber. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(ui): gate custom window controls on the full bridge surface Include getWindowState and onWindowStateChange in the usesCustomWindowControls capability check — the controls rely on both for initial state and for keeping the maximize/restore glyph in sync with OS-triggered changes, so a partial bridge should not mount them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
156 lines
5.2 KiB
TypeScript
156 lines
5.2 KiB
TypeScript
import { app, BrowserWindow } from 'electron';
|
|
import { getElectronUserDataPath } from '@iptvnator/shared/database';
|
|
import fixPath from 'fix-path';
|
|
import App from './app/app';
|
|
import { initDatabase } from './app/database/connection';
|
|
import DatabaseEvents from './app/events/database.events';
|
|
import {
|
|
resetStaleDownloads,
|
|
setMainWindow as setDownloadsMainWindow,
|
|
} from './app/events/database/downloads.events';
|
|
import ElectronEvents from './app/events/electron.events';
|
|
import EmbeddedMpvEvents, {
|
|
shutdownEmbeddedMpv,
|
|
} from './app/events/embedded-mpv.events';
|
|
import EpgEvents from './app/events/epg.events';
|
|
import { shutdownMpvSession } from './app/events/mpv-session.service';
|
|
import PlayerEvents from './app/events/player.events';
|
|
import { shutdownVlcSession } from './app/events/vlc-session.service';
|
|
import PlaylistEvents from './app/events/playlist.events';
|
|
import RemoteControlEvents from './app/events/remote-control.events';
|
|
import SettingsEvents from './app/events/settings.events';
|
|
import SharedEvents from './app/events/shared.events';
|
|
import SquirrelEvents from './app/events/squirrel.events';
|
|
import StalkerEvents from './app/events/stalker.events';
|
|
import { isStartupTraceEnabled, trace } from './app/services/debug-trace';
|
|
import { databaseWorkerClient } from './app/services/database-worker-client';
|
|
import WindowEvents from './app/events/window.events';
|
|
import XtreamEvents from './app/events/xtream.events';
|
|
|
|
app.setName('iptvnator');
|
|
|
|
const electronUserDataPath = getElectronUserDataPath();
|
|
|
|
if (electronUserDataPath) {
|
|
app.setPath('userData', electronUserDataPath);
|
|
}
|
|
|
|
let fixPathScheduled = false;
|
|
|
|
/**
|
|
* Update process.env.PATH from the user's interactive login shell so that
|
|
* spawned external players (MPV/VLC) can be resolved by binary name.
|
|
*
|
|
* Runs after window creation + IPC handler registration so the 50-300 ms
|
|
* shell-spawn cost (bash/zsh -ilc env) doesn't block startup. Idempotent:
|
|
* subsequent calls are no-ops.
|
|
*/
|
|
function scheduleDeferredFixPath(): void {
|
|
if (fixPathScheduled || process.platform === 'win32') {
|
|
return;
|
|
}
|
|
|
|
fixPathScheduled = true;
|
|
setImmediate(() => {
|
|
try {
|
|
fixPath();
|
|
if (isStartupTraceEnabled()) {
|
|
trace('startup', 'fix-path:done');
|
|
}
|
|
} catch (error) {
|
|
console.warn('fix-path failed:', error);
|
|
}
|
|
});
|
|
}
|
|
|
|
export default class Main {
|
|
static initialize() {
|
|
if (SquirrelEvents.handleEvents()) {
|
|
// squirrel event handled (except first run event) and app will exit in 1000ms, so don't do anything else
|
|
app.quit();
|
|
}
|
|
}
|
|
|
|
static bootstrapApp() {
|
|
if (isStartupTraceEnabled()) {
|
|
trace('startup', 'bootstrap-app');
|
|
}
|
|
App.main(app, BrowserWindow);
|
|
}
|
|
|
|
static async bootstrapAppEvents() {
|
|
if (isStartupTraceEnabled()) {
|
|
trace('startup', 'bootstrap-events:start');
|
|
}
|
|
|
|
// Initialize database before other events
|
|
await initDatabase();
|
|
|
|
if (isStartupTraceEnabled()) {
|
|
trace('startup', 'init-database:done');
|
|
}
|
|
|
|
ElectronEvents.bootstrapElectronEvents();
|
|
WindowEvents.bootstrapWindowEvents();
|
|
EmbeddedMpvEvents.bootstrapEmbeddedMpvEvents();
|
|
PlaylistEvents.bootstrapPlaylistEvents();
|
|
SharedEvents.bootstrapSharedEvents();
|
|
PlayerEvents.bootstrapPlayerEvents();
|
|
SettingsEvents.bootstrapSettingsEvents();
|
|
StalkerEvents.bootstrapStalkerEvents();
|
|
XtreamEvents.bootstrapXtreamEvents();
|
|
DatabaseEvents.bootstrapDatabaseEvents();
|
|
EpgEvents.bootstrapEpgEvents();
|
|
RemoteControlEvents.bootstrapRemoteControlEvents();
|
|
|
|
// Set main window for downloads and reset stale downloads
|
|
if (App.mainWindow) {
|
|
setDownloadsMainWindow(App.mainWindow);
|
|
}
|
|
await resetStaleDownloads();
|
|
|
|
if (isStartupTraceEnabled()) {
|
|
trace('startup', 'reset-stale-downloads:done');
|
|
}
|
|
|
|
// initialize auto updater service
|
|
if (!App.isDevelopmentMode()) {
|
|
// UpdateEvents.initAutoUpdateService();
|
|
}
|
|
|
|
if (isStartupTraceEnabled()) {
|
|
trace('startup', 'bootstrap-events:done');
|
|
}
|
|
|
|
// Hydrate process.env.PATH from the user's login shell now — after
|
|
// the window has loaded and IPC handlers are live. Fire-and-forget
|
|
// (setImmediate) so it doesn't gate any user-visible work. Worst
|
|
// case: the user clicks an external player within the ~100 ms it
|
|
// takes to complete; the spawn would still find MPV/VLC at any of
|
|
// the well-known paths checked by getDefault*Path before falling
|
|
// back to bare-name PATH lookup.
|
|
scheduleDeferredFixPath();
|
|
}
|
|
}
|
|
|
|
// handle setup events as quickly as possible
|
|
Main.initialize();
|
|
|
|
// bootstrap app
|
|
Main.bootstrapApp();
|
|
|
|
// Bootstrap app events after Electron app is ready
|
|
app.whenReady().then(async () => {
|
|
if (isStartupTraceEnabled()) {
|
|
trace('startup', 'app.whenReady');
|
|
}
|
|
await Main.bootstrapAppEvents();
|
|
});
|
|
|
|
app.on('before-quit', () => {
|
|
shutdownEmbeddedMpv();
|
|
shutdownMpvSession();
|
|
shutdownVlcSession();
|
|
void databaseWorkerClient.shutdown();
|
|
});
|