refactor(core): normalize service naming across app runtime

This commit is contained in:
2026-02-17 19:00:27 -08:00
parent e38a1c945e
commit 1233e3630f
87 changed files with 2813 additions and 1636 deletions

View File

@@ -20,7 +20,9 @@ test("allows only AniList https URLs for external opens", () => {
test("allows only AniList https or data URLs for setup navigation", () => {
assert.equal(
isAllowedAnilistSetupNavigationUrl("https://anilist.co/api/v2/oauth/authorize"),
isAllowedAnilistSetupNavigationUrl(
"https://anilist.co/api/v2/oauth/authorize",
),
true,
);
assert.equal(
@@ -33,5 +35,8 @@ test("allows only AniList https or data URLs for setup navigation", () => {
isAllowedAnilistSetupNavigationUrl("https://example.com/redirect"),
false,
);
assert.equal(isAllowedAnilistSetupNavigationUrl("javascript:alert(1)"), false);
assert.equal(
isAllowedAnilistSetupNavigationUrl("javascript:alert(1)"),
false,
);
});

View File

@@ -36,6 +36,7 @@ export interface AppReadyRuntimeDepsFactoryInput {
createMecabTokenizerAndCheck: AppReadyRuntimeDeps["createMecabTokenizerAndCheck"];
createSubtitleTimingTracker: AppReadyRuntimeDeps["createSubtitleTimingTracker"];
createImmersionTracker?: AppReadyRuntimeDeps["createImmersionTracker"];
startJellyfinRemoteSession?: AppReadyRuntimeDeps["startJellyfinRemoteSession"];
loadYomitanExtension: AppReadyRuntimeDeps["loadYomitanExtension"];
texthookerOnlyMode: AppReadyRuntimeDeps["texthookerOnlyMode"];
shouldAutoInitializeOverlayRuntimeFromConfig: AppReadyRuntimeDeps["shouldAutoInitializeOverlayRuntimeFromConfig"];
@@ -83,6 +84,7 @@ export function createAppReadyRuntimeDeps(
createMecabTokenizerAndCheck: params.createMecabTokenizerAndCheck,
createSubtitleTimingTracker: params.createSubtitleTimingTracker,
createImmersionTracker: params.createImmersionTracker,
startJellyfinRemoteSession: params.startJellyfinRemoteSession,
loadYomitanExtension: params.loadYomitanExtension,
texthookerOnlyMode: params.texthookerOnlyMode,
shouldAutoInitializeOverlayRuntimeFromConfig:

View File

@@ -32,13 +32,17 @@ export function getFrequencyDictionarySearchPaths(
if (sourcePath && sourcePath.trim()) {
rawSearchPaths.push(sourcePath.trim());
rawSearchPaths.push(path.join(sourcePath.trim(), "frequency-dictionary"));
rawSearchPaths.push(path.join(sourcePath.trim(), "vendor", "frequency-dictionary"));
rawSearchPaths.push(
path.join(sourcePath.trim(), "vendor", "frequency-dictionary"),
);
}
for (const dictionaryRoot of dictionaryRoots) {
rawSearchPaths.push(dictionaryRoot);
rawSearchPaths.push(path.join(dictionaryRoot, "frequency-dictionary"));
rawSearchPaths.push(path.join(dictionaryRoot, "vendor", "frequency-dictionary"));
rawSearchPaths.push(
path.join(dictionaryRoot, "vendor", "frequency-dictionary"),
);
}
return [...new Set(rawSearchPaths)];
@@ -64,15 +68,18 @@ export async function ensureFrequencyDictionaryLookup(
return;
}
if (!frequencyDictionaryLookupInitialization) {
frequencyDictionaryLookupInitialization = initializeFrequencyDictionaryLookup(deps)
.then(() => {
frequencyDictionaryLookupInitialized = true;
})
.catch((error) => {
frequencyDictionaryLookupInitialized = true;
deps.log(`Failed to initialize frequency dictionary: ${String(error)}`);
deps.setFrequencyRankLookup(() => null);
});
frequencyDictionaryLookupInitialization =
initializeFrequencyDictionaryLookup(deps)
.then(() => {
frequencyDictionaryLookupInitialized = true;
})
.catch((error) => {
frequencyDictionaryLookupInitialized = true;
deps.log(
`Failed to initialize frequency dictionary: ${String(error)}`,
);
deps.setFrequencyRankLookup(() => null);
});
}
await frequencyDictionaryLookupInitialization;
}
@@ -81,6 +88,7 @@ export function createFrequencyDictionaryRuntimeService(
deps: FrequencyDictionaryRuntimeDeps,
): { ensureFrequencyDictionaryLookup: () => Promise<void> } {
return {
ensureFrequencyDictionaryLookup: () => ensureFrequencyDictionaryLookup(deps),
ensureFrequencyDictionaryLookup: () =>
ensureFrequencyDictionaryLookup(deps),
};
}

View File

@@ -62,7 +62,9 @@ export function createMediaRuntimeService(
},
resolveMediaPathForJimaku(mediaPath: string | null): string | null {
return mediaPath && deps.isRemoteMediaPath(mediaPath) && deps.getCurrentMediaTitle()
return mediaPath &&
deps.isRemoteMediaPath(mediaPath) &&
deps.getCurrentMediaTitle()
? deps.getCurrentMediaTitle()
: mediaPath;
},

View File

@@ -23,7 +23,10 @@ export function createOverlayModalRuntimeService(
deps: OverlayWindowResolver,
): OverlayModalRuntime {
const restoreVisibleOverlayOnModalClose = new Set<OverlayHostedModal>();
const overlayModalAutoShownLayer = new Map<OverlayHostedModal, OverlayHostLayer>();
const overlayModalAutoShownLayer = new Map<
OverlayHostedModal,
OverlayHostLayer
>();
const getTargetOverlayWindow = (): {
window: BrowserWindow;
@@ -43,7 +46,10 @@ export function createOverlayModalRuntimeService(
return null;
};
const showOverlayWindowForModal = (window: BrowserWindow, layer: OverlayHostLayer): void => {
const showOverlayWindowForModal = (
window: BrowserWindow,
layer: OverlayHostLayer,
): void => {
if (layer === "invisible" && typeof window.showInactive === "function") {
window.showInactive();
} else {
@@ -133,7 +139,8 @@ export function createOverlayModalRuntimeService(
sendToActiveOverlayWindow,
openRuntimeOptionsPalette,
handleOverlayModalClosed,
getRestoreVisibleOverlayOnModalClose: () => restoreVisibleOverlayOnModalClose,
getRestoreVisibleOverlayOnModalClose: () =>
restoreVisibleOverlayOnModalClose,
};
}

View File

@@ -90,7 +90,8 @@ export function createOverlayShortcutsRuntimeService(
};
};
const shouldOverlayShortcutsBeActive = () => input.isOverlayRuntimeInitialized();
const shouldOverlayShortcutsBeActive = () =>
input.isOverlayRuntimeInitialized();
return {
tryHandleOverlayShortcutLocalFallback: (inputEvent) =>

View File

@@ -1,5 +1,9 @@
import { SubsyncResolvedConfig } from "../subsync/utils";
import type { SubsyncManualPayload, SubsyncManualRunRequest, SubsyncResult } from "../types";
import type {
SubsyncManualPayload,
SubsyncManualRunRequest,
SubsyncResult,
} from "../types";
import type { SubsyncRuntimeDeps } from "../core/services/subsync-runner";
import { createSubsyncRuntimeDeps } from "./dependencies";
import {
@@ -54,7 +58,9 @@ export function createSubsyncRuntimeServiceDeps(
export function triggerSubsyncFromConfigRuntime(
params: SubsyncRuntimeServiceInput,
): Promise<void> {
return triggerSubsyncFromConfigRuntimeCore(createSubsyncRuntimeServiceDeps(params));
return triggerSubsyncFromConfigRuntimeCore(
createSubsyncRuntimeServiceDeps(params),
);
}
export async function runSubsyncManualFromIpcRuntime(