diff --git a/src/main.ts b/src/main.ts index 95eaed2..75fbb5c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -384,13 +384,12 @@ import { composeIpcRuntimeHandlers, composeJellyfinRuntimeHandlers, composeMpvRuntimeHandlers, - composeOverlayWindowHandlers, composeOverlayVisibilityRuntime, composeShortcutRuntimes, - composeStatsStartupRuntime, composeSubtitlePrefetchRuntime, composeStartupLifecycleHandlers, } from './main/runtime/composers'; +import { createOverlayWindowRuntimeHandlers } from './main/runtime/overlay-window-runtime-handlers'; import { createStartupBootstrapRuntimeDeps } from './main/startup'; import { createAppLifecycleRuntimeRunner } from './main/startup-lifecycle'; import { @@ -2955,7 +2954,7 @@ const ensureImmersionTrackerStarted = (): void => { hasAttemptedImmersionTrackerStartup = true; createImmersionTrackerStartup(); }; -const statsStartupRuntime = composeStatsStartupRuntime({ +const statsStartupRuntime = { ensureStatsServerStarted: () => ensureStatsServerStarted(), ensureBackgroundStatsServerStarted: () => ensureBackgroundStatsServerStarted(), stopBackgroundStatsServer: () => stopBackgroundStatsServer(), @@ -2967,7 +2966,7 @@ const statsStartupRuntime = composeStatsStartupRuntime({ appState.statsStartupInProgress = false; } }, -}); +} as const; const runStatsCliCommand = createRunStatsCliCommandHandler({ getResolvedConfig: () => getResolvedConfig(), @@ -4492,7 +4491,7 @@ if (isAnilistTrackingEnabled(getResolvedConfig())) { } void initializeDiscordPresenceService(); const { createMainWindow: createMainWindowHandler, createModalWindow: createModalWindowHandler } = - composeOverlayWindowHandlers({ + createOverlayWindowRuntimeHandlers({ createOverlayWindowDeps: { createOverlayWindowCore: (kind, options) => createOverlayWindowCore(kind, options), isDev, diff --git a/src/main/runtime/composers/index.ts b/src/main/runtime/composers/index.ts index 17ff9de..f39206e 100644 --- a/src/main/runtime/composers/index.ts +++ b/src/main/runtime/composers/index.ts @@ -8,9 +8,7 @@ export * from './ipc-runtime-composer'; export * from './jellyfin-remote-composer'; export * from './jellyfin-runtime-composer'; export * from './mpv-runtime-composer'; -export * from './overlay-window-composer'; export * from './overlay-visibility-runtime-composer'; export * from './shortcuts-runtime-composer'; -export * from './stats-startup-composer'; export * from './subtitle-prefetch-runtime-composer'; export * from './startup-lifecycle-composer'; diff --git a/src/main/runtime/composers/overlay-window-composer.test.ts b/src/main/runtime/composers/overlay-window-composer.test.ts deleted file mode 100644 index 2d5b006..0000000 --- a/src/main/runtime/composers/overlay-window-composer.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import assert from 'node:assert/strict'; -import test from 'node:test'; -import { composeOverlayWindowHandlers } from './overlay-window-composer'; - -test('composeOverlayWindowHandlers returns overlay window handlers', () => { - let mainWindow: { kind: string } | null = null; - let modalWindow: { kind: string } | null = null; - - const handlers = composeOverlayWindowHandlers<{ kind: string }>({ - createOverlayWindowDeps: { - createOverlayWindowCore: (kind) => ({ kind }), - isDev: false, - ensureOverlayWindowLevel: () => {}, - onRuntimeOptionsChanged: () => {}, - setOverlayDebugVisualizationEnabled: () => {}, - isOverlayVisible: (kind) => kind === 'visible', - tryHandleOverlayShortcutLocalFallback: () => false, - forwardTabToMpv: () => {}, - onWindowClosed: () => {}, - getYomitanSession: () => null, - }, - setMainWindow: (window) => { - mainWindow = window; - }, - setModalWindow: (window) => { - modalWindow = window; - }, - }); - - assert.deepEqual(handlers.createMainWindow(), { kind: 'visible' }); - assert.deepEqual(mainWindow, { kind: 'visible' }); - assert.deepEqual(handlers.createModalWindow(), { kind: 'modal' }); - assert.deepEqual(modalWindow, { kind: 'modal' }); -}); diff --git a/src/main/runtime/composers/overlay-window-composer.ts b/src/main/runtime/composers/overlay-window-composer.ts deleted file mode 100644 index 348a3eb..0000000 --- a/src/main/runtime/composers/overlay-window-composer.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { createOverlayWindowRuntimeHandlers } from '../overlay-window-runtime-handlers'; -import type { ComposerInputs, ComposerOutputs } from './contracts'; - -type OverlayWindowRuntimeDeps = - Parameters>[0]; -type OverlayWindowRuntimeHandlers = ReturnType< - typeof createOverlayWindowRuntimeHandlers ->; - -export type OverlayWindowComposerOptions = ComposerInputs>; -export type OverlayWindowComposerResult = - ComposerOutputs>; - -export function composeOverlayWindowHandlers( - options: OverlayWindowComposerOptions, -): OverlayWindowComposerResult { - return createOverlayWindowRuntimeHandlers(options); -} diff --git a/src/main/runtime/composers/stats-startup-composer.test.ts b/src/main/runtime/composers/stats-startup-composer.test.ts deleted file mode 100644 index 61ef5b1..0000000 --- a/src/main/runtime/composers/stats-startup-composer.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import assert from 'node:assert/strict'; -import test from 'node:test'; -import { composeStatsStartupRuntime } from './stats-startup-composer'; - -test('composeStatsStartupRuntime returns stats startup handlers', async () => { - const composed = composeStatsStartupRuntime({ - ensureStatsServerStarted: () => 'http://127.0.0.1:8766', - ensureBackgroundStatsServerStarted: () => ({ - url: 'http://127.0.0.1:8766', - runningInCurrentProcess: true, - }), - stopBackgroundStatsServer: async () => ({ ok: true, stale: false }), - ensureImmersionTrackerStarted: () => {}, - }); - - assert.equal(composed.ensureStatsServerStarted(), 'http://127.0.0.1:8766'); - assert.deepEqual(composed.ensureBackgroundStatsServerStarted(), { - url: 'http://127.0.0.1:8766', - runningInCurrentProcess: true, - }); - assert.deepEqual(await composed.stopBackgroundStatsServer(), { ok: true, stale: false }); - assert.equal(typeof composed.ensureImmersionTrackerStarted, 'function'); -}); diff --git a/src/main/runtime/composers/stats-startup-composer.ts b/src/main/runtime/composers/stats-startup-composer.ts deleted file mode 100644 index b0678ef..0000000 --- a/src/main/runtime/composers/stats-startup-composer.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { ComposerInputs, ComposerOutputs } from './contracts'; - -type BackgroundStatsStartResult = { - url: string; - runningInCurrentProcess: boolean; -}; - -type BackgroundStatsStopResult = { - ok: boolean; - stale: boolean; -}; - -export type StatsStartupComposerOptions = ComposerInputs<{ - ensureStatsServerStarted: () => string; - ensureBackgroundStatsServerStarted: () => BackgroundStatsStartResult; - stopBackgroundStatsServer: () => Promise | BackgroundStatsStopResult; - ensureImmersionTrackerStarted: () => void; -}>; - -export type StatsStartupComposerResult = ComposerOutputs; - -export function composeStatsStartupRuntime( - options: StatsStartupComposerOptions, -): StatsStartupComposerResult { - return options; -}