mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 18:22:42 -08:00
refactor: extract subsync deps runtime service
This commit is contained in:
44
src/core/services/subsync-deps-runtime-service.ts
Normal file
44
src/core/services/subsync-deps-runtime-service.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import {
|
||||
SubsyncManualPayload,
|
||||
} from "../../types";
|
||||
import {
|
||||
SubsyncRuntimeDeps,
|
||||
} from "./subsync-runtime-service";
|
||||
import { SubsyncResolvedConfig } from "../../subsync/utils";
|
||||
|
||||
interface MpvClientLike {
|
||||
connected: boolean;
|
||||
currentAudioStreamIndex: number | null;
|
||||
send: (payload: { command: (string | number)[] }) => void;
|
||||
requestProperty: (name: string) => Promise<unknown>;
|
||||
}
|
||||
|
||||
export interface SubsyncDepsRuntimeOptions {
|
||||
getMpvClient: () => MpvClientLike | null;
|
||||
getResolvedSubsyncConfig: () => SubsyncResolvedConfig;
|
||||
isSubsyncInProgress: () => boolean;
|
||||
setSubsyncInProgress: (inProgress: boolean) => void;
|
||||
showMpvOsd: (text: string) => void;
|
||||
sendToVisibleOverlay: (
|
||||
channel: string,
|
||||
payload?: unknown,
|
||||
options?: { restoreOnModalClose?: "runtime-options" | "subsync" },
|
||||
) => boolean;
|
||||
}
|
||||
|
||||
export function createSubsyncRuntimeDepsService(
|
||||
options: SubsyncDepsRuntimeOptions,
|
||||
): SubsyncRuntimeDeps {
|
||||
return {
|
||||
getMpvClient: options.getMpvClient,
|
||||
getResolvedSubsyncConfig: options.getResolvedSubsyncConfig,
|
||||
isSubsyncInProgress: options.isSubsyncInProgress,
|
||||
setSubsyncInProgress: options.setSubsyncInProgress,
|
||||
showMpvOsd: options.showMpvOsd,
|
||||
openManualPicker: (payload: SubsyncManualPayload) => {
|
||||
options.sendToVisibleOverlay("subsync:open-manual", payload, {
|
||||
restoreOnModalClose: "subsync",
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user