refactor(core): normalize core service naming

Standardize core service module and export names to reduce naming ambiguity and make imports predictable across runtime, tests, scripts, and docs.
This commit is contained in:
2026-02-17 01:18:10 -08:00
parent 02034e6dc7
commit a359e91b14
80 changed files with 793 additions and 771 deletions

View File

@@ -1,7 +1,7 @@
import type { CliArgs, CliCommandSource } from "../cli/args";
import { runAppReadyRuntimeService } from "../core/services/startup-service";
import type { AppReadyRuntimeDeps } from "../core/services/startup-service";
import type { AppLifecycleDepsRuntimeOptions } from "../core/services/app-lifecycle-service";
import { runAppReadyRuntime } from "../core/services/startup";
import type { AppReadyRuntimeDeps } from "../core/services/startup";
import type { AppLifecycleDepsRuntimeOptions } from "../core/services/app-lifecycle";
export interface AppLifecycleRuntimeDepsFactoryInput {
app: AppLifecycleDepsRuntimeOptions["app"];
@@ -96,6 +96,6 @@ export function createAppReadyRuntimeRunner(
params: AppReadyRuntimeDepsFactoryInput,
): () => Promise<void> {
return async () => {
await runAppReadyRuntimeService(createAppReadyRuntimeDeps(params));
await runAppReadyRuntime(createAppReadyRuntimeDeps(params));
};
}

View File

@@ -1,4 +1,4 @@
import { handleCliCommandService, createCliCommandDepsRuntimeService } from "../core/services";
import { handleCliCommand, createCliCommandDepsRuntime } from "../core/services";
import type { CliArgs, CliCommandSource } from "../cli/args";
import { createCliCommandRuntimeServiceDeps, CliCommandRuntimeServiceDepsParams } from "./dependencies";
@@ -102,10 +102,10 @@ export function handleCliCommandRuntimeService(
source: CliCommandSource,
params: CliCommandRuntimeServiceDepsParams,
): void {
const deps = createCliCommandDepsRuntimeService(
const deps = createCliCommandDepsRuntime(
createCliCommandRuntimeServiceDeps(params),
);
handleCliCommandService(args, source, deps);
handleCliCommand(args, source, deps);
}
export function handleCliCommandRuntimeServiceWithContext(

View File

@@ -4,15 +4,15 @@ import {
SubsyncManualPayload,
} from "../types";
import { SubsyncResolvedConfig } from "../subsync/utils";
import type { SubsyncRuntimeDeps } from "../core/services/subsync-runner-service";
import type { IpcDepsRuntimeOptions } from "../core/services/ipc-service";
import type { AnkiJimakuIpcRuntimeOptions } from "../core/services/anki-jimaku-service";
import type { CliCommandDepsRuntimeOptions } from "../core/services/cli-command-service";
import type { HandleMpvCommandFromIpcOptions } from "../core/services/ipc-command-service";
import type { SubsyncRuntimeDeps } from "../core/services/subsync-runner";
import type { IpcDepsRuntimeOptions } from "../core/services/ipc";
import type { AnkiJimakuIpcRuntimeOptions } from "../core/services/anki-jimaku";
import type { CliCommandDepsRuntimeOptions } from "../core/services/cli-command";
import type { HandleMpvCommandFromIpcOptions } from "../core/services/ipc-command";
import {
cycleRuntimeOptionFromIpcRuntimeService,
setRuntimeOptionFromIpcRuntimeService,
} from "../core/services/runtime-options-ipc-service";
cycleRuntimeOptionFromIpcRuntime,
setRuntimeOptionFromIpcRuntime,
} from "../core/services/runtime-options-ipc";
import { RuntimeOptionsManager } from "../runtime-options";
export interface RuntimeOptionsIpcDepsParams {
@@ -35,14 +35,14 @@ export function createRuntimeOptionsIpcDeps(params: RuntimeOptionsIpcDepsParams)
} {
return {
setRuntimeOption: (id, value) =>
setRuntimeOptionFromIpcRuntimeService(
setRuntimeOptionFromIpcRuntime(
params.getRuntimeOptionsManager(),
id as RuntimeOptionId,
value as RuntimeOptionValue,
(text) => params.showMpvOsd(text),
),
cycleRuntimeOption: (id, direction) =>
cycleRuntimeOptionFromIpcRuntimeService(
cycleRuntimeOptionFromIpcRuntime(
params.getRuntimeOptionsManager(),
id as RuntimeOptionId,
direction,

View File

@@ -1,6 +1,6 @@
import * as path from "path";
import type { FrequencyDictionaryLookup } from "../types";
import { createFrequencyDictionaryLookupService } from "../core/services";
import { createFrequencyDictionaryLookup } from "../core/services";
export interface FrequencyDictionarySearchPathDeps {
getDictionaryRoots: () => string[];
@@ -47,7 +47,7 @@ export function getFrequencyDictionarySearchPaths(
export async function initializeFrequencyDictionaryLookup(
deps: FrequencyDictionaryRuntimeDeps,
): Promise<void> {
const lookup = await createFrequencyDictionaryLookupService({
const lookup = await createFrequencyDictionaryLookup({
searchPaths: deps.getSearchPaths(),
log: deps.log,
});

View File

@@ -1,5 +1,5 @@
import type { RuntimeOptionApplyResult, RuntimeOptionId } from "../types";
import { handleMpvCommandFromIpcService } from "../core/services";
import { handleMpvCommandFromIpc } from "../core/services";
import { createMpvCommandRuntimeServiceDeps } from "./dependencies";
import { SPECIAL_COMMANDS } from "../config";
@@ -22,7 +22,7 @@ export function handleMpvCommandFromIpcRuntime(
command: (string | number)[],
deps: MpvCommandFromIpcRuntimeDeps,
): void {
handleMpvCommandFromIpcService(
handleMpvCommandFromIpc(
command,
createMpvCommandRuntimeServiceDeps({
specialCommands: SPECIAL_COMMANDS,

View File

@@ -1,9 +1,9 @@
import {
createIpcDepsRuntimeService,
registerAnkiJimakuIpcRuntimeService,
registerIpcHandlersService,
createIpcDepsRuntime,
registerAnkiJimakuIpcRuntime,
registerIpcHandlers,
} from "../core/services";
import { registerAnkiJimakuIpcHandlers } from "../core/services/anki-jimaku-ipc-service";
import { registerAnkiJimakuIpcHandlers } from "../core/services/anki-jimaku-ipc";
import {
createAnkiJimakuIpcRuntimeServiceDeps,
AnkiJimakuIpcRuntimeServiceDepsParams,
@@ -25,15 +25,15 @@ export interface RegisterIpcRuntimeServicesParams {
export function registerMainIpcRuntimeServices(
params: MainIpcRuntimeServiceDepsParams,
): void {
registerIpcHandlersService(
createIpcDepsRuntimeService(createMainIpcRuntimeServiceDeps(params)),
registerIpcHandlers(
createIpcDepsRuntime(createMainIpcRuntimeServiceDeps(params)),
);
}
export function registerAnkiJimakuIpcRuntimeServices(
params: AnkiJimakuIpcRuntimeServiceDepsParams,
): void {
registerAnkiJimakuIpcRuntimeService(
registerAnkiJimakuIpcRuntime(
createAnkiJimakuIpcRuntimeServiceDeps(params),
registerAnkiJimakuIpcHandlers,
);

View File

@@ -1,7 +1,7 @@
import * as path from "path";
import type { JlptLevel } from "../types";
import { createJlptVocabularyLookupService } from "../core/services";
import { createJlptVocabularyLookup } from "../core/services";
export interface JlptDictionarySearchPathDeps {
getDictionaryRoots: () => string[];
@@ -39,7 +39,7 @@ export async function initializeJlptDictionaryLookup(
deps: JlptDictionaryRuntimeDeps,
): Promise<void> {
deps.setJlptLevelLookup(
await createJlptVocabularyLookupService({
await createJlptVocabularyLookup({
searchPaths: deps.getSearchPaths(),
log: deps.log,
}),

View File

@@ -1,4 +1,4 @@
import { updateCurrentMediaPathService } from "../core/services";
import { updateCurrentMediaPath } from "../core/services";
import type { SubtitlePosition } from "../types";
@@ -31,7 +31,7 @@ export function createMediaRuntimeService(
deps.setCurrentMediaTitle(null);
}
updateCurrentMediaPathService({
updateCurrentMediaPath({
mediaPath,
currentMediaPath: deps.getCurrentMediaPath(),
pendingSubtitlePosition: deps.getPendingSubtitlePosition(),

View File

@@ -4,10 +4,10 @@ import {
shortcutMatchesInputForLocalFallback,
} from "../core/services";
import {
refreshOverlayShortcutsRuntimeService,
registerOverlayShortcutsService,
syncOverlayShortcutsRuntimeService,
unregisterOverlayShortcutsRuntimeService,
refreshOverlayShortcutsRuntime,
registerOverlayShortcuts,
syncOverlayShortcutsRuntime,
unregisterOverlayShortcutsRuntime,
} from "../core/services";
import { runOverlayShortcutLocalFallback } from "../core/services/overlay-shortcut-handler";
@@ -102,7 +102,7 @@ export function createOverlayShortcutsRuntimeService(
),
registerOverlayShortcuts: () => {
input.setShortcutsRegistered(
registerOverlayShortcutsService(
registerOverlayShortcuts(
input.getConfiguredShortcuts(),
handlers.overlayHandlers,
),
@@ -110,7 +110,7 @@ export function createOverlayShortcutsRuntimeService(
},
unregisterOverlayShortcuts: () => {
input.setShortcutsRegistered(
unregisterOverlayShortcutsRuntimeService(
unregisterOverlayShortcutsRuntime(
input.getShortcutsRegistered(),
getShortcutLifecycleDeps(),
),
@@ -118,7 +118,7 @@ export function createOverlayShortcutsRuntimeService(
},
syncOverlayShortcuts: () => {
input.setShortcutsRegistered(
syncOverlayShortcutsRuntimeService(
syncOverlayShortcutsRuntime(
shouldOverlayShortcutsBeActive(),
input.getShortcutsRegistered(),
getShortcutLifecycleDeps(),
@@ -127,7 +127,7 @@ export function createOverlayShortcutsRuntimeService(
},
refreshOverlayShortcuts: () => {
input.setShortcutsRegistered(
refreshOverlayShortcutsRuntimeService(
refreshOverlayShortcutsRuntime(
shouldOverlayShortcutsBeActive(),
input.getShortcutsRegistered(),
getShortcutLifecycleDeps(),

View File

@@ -3,9 +3,9 @@ import type { BrowserWindow } from "electron";
import type { BaseWindowTracker } from "../window-trackers";
import type { WindowGeometry } from "../types";
import {
syncInvisibleOverlayMousePassthroughService,
updateInvisibleOverlayVisibilityService,
updateVisibleOverlayVisibilityService,
syncInvisibleOverlayMousePassthrough,
updateInvisibleOverlayVisibility,
updateVisibleOverlayVisibility,
} from "../core/services";
export interface OverlayVisibilityRuntimeDeps {
@@ -48,7 +48,7 @@ export function createOverlayVisibilityRuntimeService(
return {
updateVisibleOverlayVisibility(): void {
updateVisibleOverlayVisibilityService({
updateVisibleOverlayVisibility({
visibleOverlayVisible: deps.getVisibleOverlayVisible(),
mainWindow: deps.getMainWindow(),
windowTracker: deps.getWindowTracker(),
@@ -66,7 +66,7 @@ export function createOverlayVisibilityRuntimeService(
},
updateInvisibleOverlayVisibility(): void {
updateInvisibleOverlayVisibilityService({
updateInvisibleOverlayVisibility({
invisibleWindow: deps.getInvisibleWindow(),
visibleOverlayVisible: deps.getVisibleOverlayVisible(),
invisibleOverlayVisible: deps.getInvisibleOverlayVisible(),
@@ -81,7 +81,7 @@ export function createOverlayVisibilityRuntimeService(
},
syncInvisibleOverlayMousePassthrough(): void {
syncInvisibleOverlayMousePassthroughService({
syncInvisibleOverlayMousePassthrough({
hasInvisibleWindow,
setIgnoreMouseEvents,
visibleOverlayVisible: deps.getVisibleOverlayVisible(),

View File

@@ -1,7 +1,7 @@
import { CliArgs, CliCommandSource } from "../cli/args";
import { createAppLifecycleDepsRuntimeService } from "../core/services";
import { startAppLifecycleService } from "../core/services/app-lifecycle-service";
import type { AppLifecycleDepsRuntimeOptions } from "../core/services/app-lifecycle-service";
import { createAppLifecycleDepsRuntime } from "../core/services";
import { startAppLifecycle } from "../core/services/app-lifecycle";
import type { AppLifecycleDepsRuntimeOptions } from "../core/services/app-lifecycle";
import { createAppLifecycleRuntimeDeps } from "./app-lifecycle";
export interface AppLifecycleRuntimeRunnerParams {
@@ -22,9 +22,9 @@ export function createAppLifecycleRuntimeRunner(
params: AppLifecycleRuntimeRunnerParams,
): (args: CliArgs) => void {
return (args: CliArgs): void => {
startAppLifecycleService(
startAppLifecycle(
args,
createAppLifecycleDepsRuntimeService(
createAppLifecycleDepsRuntime(
createAppLifecycleRuntimeDeps({
app: params.app,
platform: params.platform,

View File

@@ -1,6 +1,6 @@
import { CliArgs } from "../cli/args";
import type { ResolvedConfig } from "../types";
import type { StartupBootstrapRuntimeDeps } from "../core/services/startup-service";
import type { StartupBootstrapRuntimeDeps } from "../core/services/startup";
import type { LogLevelSource } from "../logger";
export interface StartupBootstrapRuntimeFactoryDeps {

View File

@@ -1,8 +1,11 @@
import { SubsyncResolvedConfig } from "../subsync/utils";
import type { SubsyncManualPayload, SubsyncManualRunRequest, SubsyncResult } from "../types";
import type { SubsyncRuntimeDeps } from "../core/services/subsync-runner-service";
import type { SubsyncRuntimeDeps } from "../core/services/subsync-runner";
import { createSubsyncRuntimeDeps } from "./dependencies";
import { runSubsyncManualFromIpcRuntimeService, triggerSubsyncFromConfigRuntimeService } from "../core/services";
import {
runSubsyncManualFromIpcRuntime as runSubsyncManualFromIpcRuntimeCore,
triggerSubsyncFromConfigRuntime as triggerSubsyncFromConfigRuntimeCore,
} from "../core/services";
export interface SubsyncRuntimeServiceInput {
getMpvClient: SubsyncRuntimeDeps["getMpvClient"];
@@ -51,14 +54,14 @@ export function createSubsyncRuntimeServiceDeps(
export function triggerSubsyncFromConfigRuntime(
params: SubsyncRuntimeServiceInput,
): Promise<void> {
return triggerSubsyncFromConfigRuntimeService(createSubsyncRuntimeServiceDeps(params));
return triggerSubsyncFromConfigRuntimeCore(createSubsyncRuntimeServiceDeps(params));
}
export async function runSubsyncManualFromIpcRuntime(
request: SubsyncManualRunRequest,
params: SubsyncRuntimeServiceInput,
): Promise<SubsyncResult> {
return runSubsyncManualFromIpcRuntimeService(
return runSubsyncManualFromIpcRuntimeCore(
request,
createSubsyncRuntimeServiceDeps(params),
);