mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-30 06:12:06 -07:00
refactor: inline identity composers (stats-startup, overlay-window)
composeStatsStartupRuntime was a no-op that returned its input. composeOverlayWindowHandlers was a 1-line delegation. Both removed in favor of direct usage.
This commit is contained in:
@@ -384,13 +384,12 @@ import {
|
|||||||
composeIpcRuntimeHandlers,
|
composeIpcRuntimeHandlers,
|
||||||
composeJellyfinRuntimeHandlers,
|
composeJellyfinRuntimeHandlers,
|
||||||
composeMpvRuntimeHandlers,
|
composeMpvRuntimeHandlers,
|
||||||
composeOverlayWindowHandlers,
|
|
||||||
composeOverlayVisibilityRuntime,
|
composeOverlayVisibilityRuntime,
|
||||||
composeShortcutRuntimes,
|
composeShortcutRuntimes,
|
||||||
composeStatsStartupRuntime,
|
|
||||||
composeSubtitlePrefetchRuntime,
|
composeSubtitlePrefetchRuntime,
|
||||||
composeStartupLifecycleHandlers,
|
composeStartupLifecycleHandlers,
|
||||||
} from './main/runtime/composers';
|
} from './main/runtime/composers';
|
||||||
|
import { createOverlayWindowRuntimeHandlers } from './main/runtime/overlay-window-runtime-handlers';
|
||||||
import { createStartupBootstrapRuntimeDeps } from './main/startup';
|
import { createStartupBootstrapRuntimeDeps } from './main/startup';
|
||||||
import { createAppLifecycleRuntimeRunner } from './main/startup-lifecycle';
|
import { createAppLifecycleRuntimeRunner } from './main/startup-lifecycle';
|
||||||
import {
|
import {
|
||||||
@@ -2955,7 +2954,7 @@ const ensureImmersionTrackerStarted = (): void => {
|
|||||||
hasAttemptedImmersionTrackerStartup = true;
|
hasAttemptedImmersionTrackerStartup = true;
|
||||||
createImmersionTrackerStartup();
|
createImmersionTrackerStartup();
|
||||||
};
|
};
|
||||||
const statsStartupRuntime = composeStatsStartupRuntime({
|
const statsStartupRuntime = {
|
||||||
ensureStatsServerStarted: () => ensureStatsServerStarted(),
|
ensureStatsServerStarted: () => ensureStatsServerStarted(),
|
||||||
ensureBackgroundStatsServerStarted: () => ensureBackgroundStatsServerStarted(),
|
ensureBackgroundStatsServerStarted: () => ensureBackgroundStatsServerStarted(),
|
||||||
stopBackgroundStatsServer: () => stopBackgroundStatsServer(),
|
stopBackgroundStatsServer: () => stopBackgroundStatsServer(),
|
||||||
@@ -2967,7 +2966,7 @@ const statsStartupRuntime = composeStatsStartupRuntime({
|
|||||||
appState.statsStartupInProgress = false;
|
appState.statsStartupInProgress = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
} as const;
|
||||||
|
|
||||||
const runStatsCliCommand = createRunStatsCliCommandHandler({
|
const runStatsCliCommand = createRunStatsCliCommandHandler({
|
||||||
getResolvedConfig: () => getResolvedConfig(),
|
getResolvedConfig: () => getResolvedConfig(),
|
||||||
@@ -4492,7 +4491,7 @@ if (isAnilistTrackingEnabled(getResolvedConfig())) {
|
|||||||
}
|
}
|
||||||
void initializeDiscordPresenceService();
|
void initializeDiscordPresenceService();
|
||||||
const { createMainWindow: createMainWindowHandler, createModalWindow: createModalWindowHandler } =
|
const { createMainWindow: createMainWindowHandler, createModalWindow: createModalWindowHandler } =
|
||||||
composeOverlayWindowHandlers<BrowserWindow>({
|
createOverlayWindowRuntimeHandlers<BrowserWindow>({
|
||||||
createOverlayWindowDeps: {
|
createOverlayWindowDeps: {
|
||||||
createOverlayWindowCore: (kind, options) => createOverlayWindowCore(kind, options),
|
createOverlayWindowCore: (kind, options) => createOverlayWindowCore(kind, options),
|
||||||
isDev,
|
isDev,
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ export * from './ipc-runtime-composer';
|
|||||||
export * from './jellyfin-remote-composer';
|
export * from './jellyfin-remote-composer';
|
||||||
export * from './jellyfin-runtime-composer';
|
export * from './jellyfin-runtime-composer';
|
||||||
export * from './mpv-runtime-composer';
|
export * from './mpv-runtime-composer';
|
||||||
export * from './overlay-window-composer';
|
|
||||||
export * from './overlay-visibility-runtime-composer';
|
export * from './overlay-visibility-runtime-composer';
|
||||||
export * from './shortcuts-runtime-composer';
|
export * from './shortcuts-runtime-composer';
|
||||||
export * from './stats-startup-composer';
|
|
||||||
export * from './subtitle-prefetch-runtime-composer';
|
export * from './subtitle-prefetch-runtime-composer';
|
||||||
export * from './startup-lifecycle-composer';
|
export * from './startup-lifecycle-composer';
|
||||||
|
|||||||
@@ -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' });
|
|
||||||
});
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { createOverlayWindowRuntimeHandlers } from '../overlay-window-runtime-handlers';
|
|
||||||
import type { ComposerInputs, ComposerOutputs } from './contracts';
|
|
||||||
|
|
||||||
type OverlayWindowRuntimeDeps<TWindow> =
|
|
||||||
Parameters<typeof createOverlayWindowRuntimeHandlers<TWindow>>[0];
|
|
||||||
type OverlayWindowRuntimeHandlers<TWindow> = ReturnType<
|
|
||||||
typeof createOverlayWindowRuntimeHandlers<TWindow>
|
|
||||||
>;
|
|
||||||
|
|
||||||
export type OverlayWindowComposerOptions<TWindow> = ComposerInputs<OverlayWindowRuntimeDeps<TWindow>>;
|
|
||||||
export type OverlayWindowComposerResult<TWindow> =
|
|
||||||
ComposerOutputs<OverlayWindowRuntimeHandlers<TWindow>>;
|
|
||||||
|
|
||||||
export function composeOverlayWindowHandlers<TWindow>(
|
|
||||||
options: OverlayWindowComposerOptions<TWindow>,
|
|
||||||
): OverlayWindowComposerResult<TWindow> {
|
|
||||||
return createOverlayWindowRuntimeHandlers<TWindow>(options);
|
|
||||||
}
|
|
||||||
@@ -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');
|
|
||||||
});
|
|
||||||
@@ -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> | BackgroundStatsStopResult;
|
|
||||||
ensureImmersionTrackerStarted: () => void;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
export type StatsStartupComposerResult = ComposerOutputs<StatsStartupComposerOptions>;
|
|
||||||
|
|
||||||
export function composeStatsStartupRuntime(
|
|
||||||
options: StatsStartupComposerOptions,
|
|
||||||
): StatsStartupComposerResult {
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user