refactor: normalize additional main dependency construction

This commit is contained in:
2026-02-20 01:32:37 -08:00
parent c6fa197d0d
commit 4010fc1b04
2 changed files with 38 additions and 26 deletions

View File

@@ -407,3 +407,5 @@
- [2026-02-20T09:30:02Z] progress: applied 5-block safe normalization in `main.ts` by prebuilding deps handlers for global shortcuts (`getConfiguredShortcuts`, `registerGlobalShortcuts`, `refreshGlobalAndOverlayShortcuts`) and MPV logging/OSD (`appendToMpvLog`, `showMpvOsd`).
- [2026-02-20T09:30:02Z] progress: earlier in this batch also extracted `jellyfin-playback-launch-main-deps`, `immersion-startup-main-deps`, `numeric-shortcut-runtime-main-deps`, and `mpv-subtitle-render-metrics-main-deps`; extended `config-hot-reload-main-deps` with watcher/message builders.
- [2026-02-20T09:30:02Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + targeted suites pass for `global-shortcuts*`, `mpv-osd-log*`, `jellyfin-playback-launch*`, `immersion-startup*`, `config-hot-reload-main-deps*`, `mpv-subtitle-render-metrics*`, `numeric-shortcut-runtime-main-deps*`, `initial-args*`.
- [2026-02-20T09:32:11Z] progress: completed 5-block safe normalization in `main.ts`: prebuilt deps handlers for CLI context main deps, MPV main-event bind deps, MPV runtime service factory deps, MeCab initializer deps, and subtitle dictionary prewarm deps.
- [2026-02-20T09:32:11Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + targeted suites pass: `cli-command-context-main-deps`, `mpv-main-event-main-deps`, `mpv-main-event-bindings`, `mpv-client-runtime-service-main-deps`, `subtitle-tokenization-main-deps`.

View File

@@ -2189,7 +2189,7 @@ function handleInitialArgs(): void {
handleInitialArgsRuntimeHandler();
}
const bindMpvClientEventHandlers = createBindMpvMainEventHandlersHandler(
const buildBindMpvMainEventHandlersMainDepsHandler =
createBuildBindMpvMainEventHandlersMainDepsHandler({
appState,
getQuitOnDisconnectArmed: () => jellyfinPlayQuitOnDisconnectArmed,
@@ -2236,11 +2236,12 @@ const bindMpvClientEventHandlers = createBindMpvMainEventHandlersHandler(
updateSubtitleRenderMetrics: (patch) => {
updateMpvSubtitleRenderMetrics(patch as Partial<MpvSubtitleRenderMetrics>);
},
})(),
});
const bindMpvClientEventHandlers = createBindMpvMainEventHandlersHandler(
buildBindMpvMainEventHandlersMainDepsHandler(),
);
function createMpvClientRuntimeService(): MpvIpcClient {
return createMpvClientRuntimeServiceFactory(
const buildMpvClientRuntimeServiceFactoryMainDepsHandler =
createBuildMpvClientRuntimeServiceFactoryDepsHandler({
createClient: MpvIpcClient,
getSocketPath: () => appState.mpvSocketPath,
@@ -2255,8 +2256,10 @@ function createMpvClientRuntimeService(): MpvIpcClient {
appState.reconnectTimer = timer;
},
bindEventHandlers: (client) => bindMpvClientEventHandlers(client),
})(),
)();
});
function createMpvClientRuntimeService(): MpvIpcClient {
return createMpvClientRuntimeServiceFactory(buildMpvClientRuntimeServiceFactoryMainDepsHandler())();
}
const buildUpdateMpvSubtitleRenderMetricsMainDepsHandler =
@@ -2308,19 +2311,25 @@ const buildTokenizerDepsHandler = createBuildTokenizerDepsMainHandler({
getMecabTokenizer: () => appState.mecabTokenizer,
});
const createMecabTokenizerAndCheckHandler = createCreateMecabTokenizerAndCheckMainHandler({
const buildCreateMecabTokenizerAndCheckMainDepsHandler = createCreateMecabTokenizerAndCheckMainHandler(
{
getMecabTokenizer: () => appState.mecabTokenizer,
setMecabTokenizer: (tokenizer) => {
appState.mecabTokenizer = tokenizer;
},
createMecabTokenizer: () => new MecabTokenizer(),
checkAvailability: async (tokenizer) => tokenizer.checkAvailability(),
});
},
);
const createMecabTokenizerAndCheckHandler = buildCreateMecabTokenizerAndCheckMainDepsHandler;
const prewarmSubtitleDictionariesHandler = createPrewarmSubtitleDictionariesMainHandler({
const buildPrewarmSubtitleDictionariesMainDepsHandler = createPrewarmSubtitleDictionariesMainHandler(
{
ensureJlptDictionaryLookup: () => jlptDictionaryRuntime.ensureJlptDictionaryLookup(),
ensureFrequencyDictionaryLookup: () => frequencyDictionaryRuntime.ensureFrequencyDictionaryLookup(),
});
},
);
const prewarmSubtitleDictionariesHandler = buildPrewarmSubtitleDictionariesMainDepsHandler;
async function tokenizeSubtitle(text: string): Promise<SubtitleData> {
await jlptDictionaryRuntime.ensureJlptDictionaryLookup();
@@ -2864,8 +2873,7 @@ const buildRunSubsyncManualFromIpcMainDepsHandler =
const runSubsyncManualFromIpcHandler = createRunSubsyncManualFromIpcHandler(
buildRunSubsyncManualFromIpcMainDepsHandler(),
);
const buildCliCommandContextDepsHandler = createBuildCliCommandContextDepsHandler(
createBuildCliCommandContextMainDepsHandler({
const buildCliCommandContextMainDepsHandler = createBuildCliCommandContextMainDepsHandler({
appState,
texthookerService,
getResolvedConfig: () => getResolvedConfig(),
@@ -2906,7 +2914,9 @@ const buildCliCommandContextDepsHandler = createBuildCliCommandContextDepsHandle
logInfo: (message: string) => logger.info(message),
logWarn: (message: string) => logger.warn(message),
logError: (message: string, err: unknown) => logger.error(message, err),
})(),
});
const buildCliCommandContextDepsHandler = createBuildCliCommandContextDepsHandler(
buildCliCommandContextMainDepsHandler(),
);
const createOverlayWindowHandler = createCreateOverlayWindowHandler<BrowserWindow>(
createBuildCreateOverlayWindowMainDepsHandler<BrowserWindow>({