Overlay 2.0 (#12)

This commit is contained in:
2026-03-01 02:36:51 -08:00
committed by GitHub
parent 45df3c466b
commit 44c7761c7c
397 changed files with 15139 additions and 7127 deletions

View File

@@ -24,27 +24,70 @@ export function createStartBackgroundWarmupsHandler(deps: {
createMecabTokenizerAndCheck: () => Promise<void>;
ensureYomitanExtensionLoaded: () => Promise<void>;
prewarmSubtitleDictionaries: () => Promise<void>;
shouldWarmupMecab: () => boolean;
shouldWarmupYomitanExtension: () => boolean;
shouldWarmupSubtitleDictionaries: () => boolean;
shouldWarmupJellyfinRemoteSession: () => boolean;
shouldAutoConnectJellyfinRemote: () => boolean;
startJellyfinRemoteSession: () => Promise<void>;
logDebug?: (message: string) => void;
}) {
return (): void => {
if (deps.getStarted()) return;
if (deps.isTexthookerOnlyMode()) return;
const warmupMecab = deps.shouldWarmupMecab();
const warmupYomitanExtension = deps.shouldWarmupYomitanExtension();
const warmupSubtitleDictionaries = deps.shouldWarmupSubtitleDictionaries();
const warmupJellyfinRemoteSession = deps.shouldWarmupJellyfinRemoteSession();
const autoConnectJellyfinRemote = deps.shouldAutoConnectJellyfinRemote();
deps.setStarted(true);
deps.launchTask('mecab', async () => {
await deps.createMecabTokenizerAndCheck();
});
deps.launchTask('yomitan-extension', async () => {
await deps.ensureYomitanExtensionLoaded();
});
deps.launchTask('subtitle-dictionaries', async () => {
await deps.prewarmSubtitleDictionaries();
});
if (deps.shouldAutoConnectJellyfinRemote()) {
deps.launchTask('jellyfin-remote-session', async () => {
await deps.startJellyfinRemoteSession();
const shouldWarmupTokenization =
warmupMecab || warmupYomitanExtension || warmupSubtitleDictionaries;
if (shouldWarmupTokenization) {
deps.launchTask('subtitle-tokenization', async () => {
await Promise.all([
warmupYomitanExtension
? (async () => {
deps.logDebug?.('[startup-warmup] stage start: yomitan-extension');
await deps.ensureYomitanExtensionLoaded();
deps.logDebug?.('[startup-warmup] stage ready: yomitan-extension');
})()
: Promise.resolve().then(() => {
deps.logDebug?.('[startup-warmup] stage skipped: yomitan-extension');
}),
warmupMecab
? (async () => {
deps.logDebug?.('[startup-warmup] stage start: mecab');
await deps.createMecabTokenizerAndCheck();
deps.logDebug?.('[startup-warmup] stage ready: mecab');
})()
: Promise.resolve().then(() => {
deps.logDebug?.('[startup-warmup] stage skipped: mecab');
}),
warmupSubtitleDictionaries
? (async () => {
deps.logDebug?.('[startup-warmup] stage start: subtitle-dictionaries');
await deps.prewarmSubtitleDictionaries();
deps.logDebug?.('[startup-warmup] stage ready: subtitle-dictionaries');
})()
: Promise.resolve().then(() => {
deps.logDebug?.('[startup-warmup] stage skipped: subtitle-dictionaries');
}),
]);
});
}
if (warmupJellyfinRemoteSession && autoConnectJellyfinRemote) {
deps.launchTask('jellyfin-remote-session', async () => {
deps.logDebug?.('[startup-warmup] stage start: jellyfin-remote-session');
await deps.startJellyfinRemoteSession();
deps.logDebug?.('[startup-warmup] stage ready: jellyfin-remote-session');
});
} else if (!warmupJellyfinRemoteSession) {
deps.logDebug?.('[startup-warmup] stage skipped: jellyfin-remote-session (disabled)');
} else {
deps.logDebug?.('[startup-warmup] stage skipped: jellyfin-remote-session (auto-connect off)');
}
};
}