mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 06:22:45 -08:00
refactor: split main runtime flows into focused modules
This commit is contained in:
39
src/main/runtime/initial-args-handler.ts
Normal file
39
src/main/runtime/initial-args-handler.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import type { CliArgs } from '../../cli/args';
|
||||
|
||||
type MpvClientLike = {
|
||||
connected: boolean;
|
||||
connect: () => void;
|
||||
};
|
||||
|
||||
export function createHandleInitialArgsHandler(deps: {
|
||||
getInitialArgs: () => CliArgs | null;
|
||||
isBackgroundMode: () => boolean;
|
||||
ensureTray: () => void;
|
||||
isTexthookerOnlyMode: () => boolean;
|
||||
hasImmersionTracker: () => boolean;
|
||||
getMpvClient: () => MpvClientLike | null;
|
||||
logInfo: (message: string) => void;
|
||||
handleCliCommand: (args: CliArgs, source: 'initial') => void;
|
||||
}) {
|
||||
return (): void => {
|
||||
const initialArgs = deps.getInitialArgs();
|
||||
if (!initialArgs) return;
|
||||
|
||||
if (deps.isBackgroundMode()) {
|
||||
deps.ensureTray();
|
||||
}
|
||||
|
||||
const mpvClient = deps.getMpvClient();
|
||||
if (
|
||||
!deps.isTexthookerOnlyMode() &&
|
||||
deps.hasImmersionTracker() &&
|
||||
mpvClient &&
|
||||
!mpvClient.connected
|
||||
) {
|
||||
deps.logInfo('Auto-connecting MPV client for immersion tracking');
|
||||
mpvClient.connect();
|
||||
}
|
||||
|
||||
deps.handleCliCommand(initialArgs, 'initial');
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user