refactor(main): move IPC runtime deps build to shared dependency mapper

This commit is contained in:
2026-02-14 16:43:17 -08:00
parent 64dd5ecc3d
commit f9ef8b31b1

View File

@@ -149,6 +149,9 @@ import { handleMpvCommandFromIpcRuntime } from "./main/ipc-mpv-command";
import { import {
registerIpcRuntimeServices, registerIpcRuntimeServices,
} from "./main/ipc-runtime"; } from "./main/ipc-runtime";
import {
createAnkiJimakuIpcRuntimeServiceDeps,
} from "./main/dependencies";
import { import {
handleCliCommandRuntimeServiceWithContext, handleCliCommandRuntimeServiceWithContext,
} from "./main/cli-runtime"; } from "./main/cli-runtime";
@@ -1317,8 +1320,7 @@ async function runSubsyncManualFromIpc(
return runSubsyncManualFromIpcRuntime(request, getSubsyncRuntimeServiceParams()); return runSubsyncManualFromIpcRuntime(request, getSubsyncRuntimeServiceParams());
} }
function buildIpcRuntimeServicesParams() { registerIpcRuntimeServices({
return {
runtimeOptions: { runtimeOptions: {
getRuntimeOptionsManager: () => appState.runtimeOptionsManager, getRuntimeOptionsManager: () => appState.runtimeOptionsManager,
showMpvOsd: (text: string) => showMpvOsd(text), showMpvOsd: (text: string) => showMpvOsd(text),
@@ -1334,7 +1336,7 @@ function buildIpcRuntimeServicesParams() {
openYomitanSettings: () => openYomitanSettings(), openYomitanSettings: () => openYomitanSettings(),
quitApp: () => app.quit(), quitApp: () => app.quit(),
toggleVisibleOverlay: () => toggleVisibleOverlay(), toggleVisibleOverlay: () => toggleVisibleOverlay(),
tokenizeCurrentSubtitle: () => tokenizeSubtitle(appState.currentSubText), tokenizeCurrentSubtitle: () => tokenizeCurrentSubtitle(appState.currentSubText),
getCurrentSubtitleAss: () => appState.currentSubAssText, getCurrentSubtitleAss: () => appState.currentSubAssText,
getMpvSubtitleRenderMetrics: () => appState.mpvSubtitleRenderMetrics, getMpvSubtitleRenderMetrics: () => appState.mpvSubtitleRenderMetrics,
getSubtitlePosition: () => loadSubtitlePosition(), getSubtitlePosition: () => loadSubtitlePosition(),
@@ -1355,7 +1357,7 @@ function buildIpcRuntimeServicesParams() {
overlayContentMeasurementStore.report(payload); overlayContentMeasurementStore.report(payload);
}, },
}, },
ankiJimakuDeps: { ankiJimakuDeps: createAnkiJimakuIpcRuntimeServiceDeps({
patchAnkiConnectEnabled: (enabled: boolean) => { patchAnkiConnectEnabled: (enabled: boolean) => {
configService.patchRawConfig({ ankiConnect: { enabled } }); configService.patchRawConfig({ ankiConnect: { enabled } });
}, },
@@ -1380,8 +1382,7 @@ function buildIpcRuntimeServicesParams() {
jimakuFetchJson: <T>( jimakuFetchJson: <T>(
endpoint: string, endpoint: string,
query?: Record<string, string | number | boolean | null | undefined>, query?: Record<string, string | number | boolean | null | undefined>,
): Promise<JimakuApiResponse<T>> => ): Promise<JimakuApiResponse<T>> => jimakuFetchJson<T>(endpoint, query),
jimakuFetchJson<T>(endpoint, query),
getJimakuMaxEntryResults: () => getJimakuMaxEntryResults(), getJimakuMaxEntryResults: () => getJimakuMaxEntryResults(),
getJimakuLanguagePreference: () => getJimakuLanguagePreference(), getJimakuLanguagePreference: () => getJimakuLanguagePreference(),
resolveJimakuApiKey: () => resolveJimakuApiKey(), resolveJimakuApiKey: () => resolveJimakuApiKey(),
@@ -1391,8 +1392,5 @@ function buildIpcRuntimeServicesParams() {
destPath: string, destPath: string,
headers: Record<string, string>, headers: Record<string, string>,
) => downloadToFile(url, destPath, headers), ) => downloadToFile(url, destPath, headers),
}, }),
}; });
}
registerIpcRuntimeServices(buildIpcRuntimeServicesParams());