refactor(main): move mpv IPC command composition into helper module

This commit is contained in:
2026-02-14 13:46:17 -08:00
parent 65d9f5d54d
commit 84c2bbcc0d
2 changed files with 62 additions and 31 deletions

View File

@@ -0,0 +1,40 @@
import type { RuntimeOptionApplyResult, RuntimeOptionId } from "../types";
import { handleMpvCommandFromIpcService } from "../core/services";
import { createMpvCommandRuntimeServiceDeps } from "./dependencies";
import { SPECIAL_COMMANDS } from "../config";
export interface MpvCommandFromIpcRuntimeDeps {
triggerSubsyncFromConfig: () => void;
openRuntimeOptionsPalette: () => void;
cycleRuntimeOption: (
id: RuntimeOptionId,
direction: 1 | -1,
) => RuntimeOptionApplyResult;
showMpvOsd: (text: string) => void;
replayCurrentSubtitle: () => void;
playNextSubtitle: () => void;
sendMpvCommand: (command: (string | number)[]) => void;
isMpvConnected: () => boolean;
hasRuntimeOptionsManager: () => boolean;
}
export function handleMpvCommandFromIpcRuntime(
command: (string | number)[],
deps: MpvCommandFromIpcRuntimeDeps,
): void {
handleMpvCommandFromIpcService(
command,
createMpvCommandRuntimeServiceDeps({
specialCommands: SPECIAL_COMMANDS,
triggerSubsyncFromConfig: deps.triggerSubsyncFromConfig,
openRuntimeOptionsPalette: deps.openRuntimeOptionsPalette,
runtimeOptionsCycle: deps.cycleRuntimeOption,
showMpvOsd: deps.showMpvOsd,
mpvReplaySubtitle: deps.replayCurrentSubtitle,
mpvPlayNextSubtitle: deps.playNextSubtitle,
mpvSendCommand: deps.sendMpvCommand,
isMpvConnected: deps.isMpvConnected,
hasRuntimeOptionsManager: deps.hasRuntimeOptionsManager,
}),
);
}