feat(core): add Electron runtime, services, and app composition

This commit is contained in:
2026-02-22 21:43:43 -08:00
parent 448ce03fd4
commit d3fd47f0ec
562 changed files with 69719 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import type { Config } from '../../types';
export type MpvClientRuntimeServiceOptions = {
getResolvedConfig: () => Config;
autoStartOverlay: boolean;
setOverlayVisible: (visible: boolean) => void;
shouldBindVisibleOverlayToMpvSubVisibility: () => boolean;
isVisibleOverlayVisible: () => boolean;
getReconnectTimer: () => ReturnType<typeof setTimeout> | null;
setReconnectTimer: (timer: ReturnType<typeof setTimeout> | null) => void;
};
type MpvClientLike = {
connect: () => void;
};
type MpvClientCtor<
TClient extends MpvClientLike,
TOptions extends MpvClientRuntimeServiceOptions,
> = new (socketPath: string, options: TOptions) => TClient;
export function createMpvClientRuntimeServiceFactory<
TClient extends MpvClientLike,
TOptions extends MpvClientRuntimeServiceOptions,
>(deps: {
createClient: MpvClientCtor<TClient, TOptions>;
socketPath: string;
options: TOptions;
bindEventHandlers: (client: TClient) => void;
}) {
return (): TClient => {
const mpvClient = new deps.createClient(deps.socketPath, deps.options);
deps.bindEventHandlers(mpvClient);
mpvClient.connect();
return mpvClient;
};
}