mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-05 00:12:06 -07:00
56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
import type { RuntimeOptionApplyResult, RuntimeOptionId } from '../types';
|
|
import { handleMpvCommandFromIpc } from '../core/services';
|
|
import { createMpvCommandRuntimeServiceDeps } from './dependencies';
|
|
import { SPECIAL_COMMANDS } from '../config';
|
|
import { resolveProxyCommandOsdRuntime } from './runtime/mpv-proxy-osd';
|
|
|
|
type MpvPropertyClientLike = {
|
|
connected: boolean;
|
|
requestProperty: (name: string) => Promise<unknown>;
|
|
};
|
|
|
|
export interface MpvCommandFromIpcRuntimeDeps {
|
|
triggerSubsyncFromConfig: () => void;
|
|
openRuntimeOptionsPalette: () => void;
|
|
openJimaku: () => void;
|
|
openYoutubeTrackPicker: () => void | Promise<void>;
|
|
openPlaylistBrowser: () => void | Promise<void>;
|
|
cycleRuntimeOption: (id: RuntimeOptionId, direction: 1 | -1) => RuntimeOptionApplyResult;
|
|
showMpvOsd: (text: string) => void;
|
|
replayCurrentSubtitle: () => void;
|
|
playNextSubtitle: () => void;
|
|
shiftSubDelayToAdjacentSubtitle: (direction: 'next' | 'previous') => Promise<void>;
|
|
sendMpvCommand: (command: (string | number)[]) => void;
|
|
getMpvClient: () => MpvPropertyClientLike | null;
|
|
isMpvConnected: () => boolean;
|
|
hasRuntimeOptionsManager: () => boolean;
|
|
}
|
|
|
|
export function handleMpvCommandFromIpcRuntime(
|
|
command: (string | number)[],
|
|
deps: MpvCommandFromIpcRuntimeDeps,
|
|
): void {
|
|
handleMpvCommandFromIpc(
|
|
command,
|
|
createMpvCommandRuntimeServiceDeps({
|
|
specialCommands: SPECIAL_COMMANDS,
|
|
triggerSubsyncFromConfig: deps.triggerSubsyncFromConfig,
|
|
openRuntimeOptionsPalette: deps.openRuntimeOptionsPalette,
|
|
openJimaku: deps.openJimaku,
|
|
openYoutubeTrackPicker: deps.openYoutubeTrackPicker,
|
|
openPlaylistBrowser: deps.openPlaylistBrowser,
|
|
runtimeOptionsCycle: deps.cycleRuntimeOption,
|
|
showMpvOsd: deps.showMpvOsd,
|
|
mpvReplaySubtitle: deps.replayCurrentSubtitle,
|
|
mpvPlayNextSubtitle: deps.playNextSubtitle,
|
|
shiftSubDelayToAdjacentSubtitle: (direction) =>
|
|
deps.shiftSubDelayToAdjacentSubtitle(direction),
|
|
mpvSendCommand: deps.sendMpvCommand,
|
|
resolveProxyCommandOsd: (nextCommand) =>
|
|
resolveProxyCommandOsdRuntime(nextCommand, deps.getMpvClient),
|
|
isMpvConnected: deps.isMpvConnected,
|
|
hasRuntimeOptionsManager: deps.hasRuntimeOptionsManager,
|
|
}),
|
|
);
|
|
}
|