refactor: extract main runtime dependency builders

This commit is contained in:
2026-02-19 23:11:20 -08:00
parent 8c2d82e361
commit 0d7b65ec88
25 changed files with 1490 additions and 262 deletions

View File

@@ -193,6 +193,28 @@
- `src/main/runtime/initial-args-main-deps.test.ts`
- `src/main/runtime/mpv-main-event-main-deps.ts`
- `src/main/runtime/mpv-main-event-main-deps.test.ts`
- `src/main/runtime/subtitle-tokenization-main-deps.ts`
- `src/main/runtime/subtitle-tokenization-main-deps.test.ts`
- `src/main/runtime/secondary-sub-mode-main-deps.ts`
- `src/main/runtime/secondary-sub-mode-main-deps.test.ts`
- `src/main/runtime/overlay-runtime-main-actions.ts`
- `src/main/runtime/overlay-runtime-main-actions.test.ts`
- `src/main/runtime/jellyfin-client-info.ts`
- `src/main/runtime/jellyfin-client-info.test.ts`
- `src/main/runtime/startup-config-main-deps.ts`
- `src/main/runtime/startup-config-main-deps.test.ts`
- `src/main/runtime/app-ready-main-deps.ts`
- `src/main/runtime/app-ready-main-deps.test.ts`
- `src/main/runtime/startup-lifecycle-main-deps.ts`
- `src/main/runtime/startup-lifecycle-main-deps.test.ts`
- `src/main/runtime/startup-bootstrap-main-deps.ts`
- `src/main/runtime/startup-bootstrap-main-deps.test.ts`
- `src/main/runtime/cli-command-prechecks-main-deps.ts`
- `src/main/runtime/cli-command-prechecks-main-deps.test.ts`
- `src/main/runtime/field-grouping-resolver.ts`
- `src/main/runtime/field-grouping-resolver.test.ts`
- `src/main/runtime/mpv-jellyfin-defaults.ts`
- `src/main/runtime/mpv-jellyfin-defaults.test.ts`
## Open Questions / Blockers
@@ -244,3 +266,27 @@
- [2026-02-20T05:15:40Z] progress: extracted MPV main-event deps assembly into `src/main/runtime/mpv-main-event-main-deps.ts` (`createBuildBindMpvMainEventHandlersMainDepsHandler`) and rewired `bindMpvClientEventHandlers` setup in `src/main.ts`.
- [2026-02-20T05:15:40Z] progress: `src/main.ts` currently 2653 LOC after this slice.
- [2026-02-20T05:15:40Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/app-lifecycle-main-activate.test.js dist/main/runtime/initial-args-main-deps.test.js dist/main/runtime/app-lifecycle-actions.test.js dist/main/runtime/initial-args-handler.test.js dist/main/runtime/app-runtime-main-deps.test.js dist/main/runtime/mpv-main-event-main-deps.test.js dist/main/runtime/mpv-main-event-bindings.test.js dist/main/runtime/mpv-main-event-actions.test.js dist/main/runtime/mpv-client-event-bindings.test.js` pass (27/27).
- [2026-02-20T05:31:05Z] progress: extracted subtitle tokenization/mecab-warmup deps assembly into `src/main/runtime/subtitle-tokenization-main-deps.ts` (`createBuildTokenizerDepsMainHandler`, `createCreateMecabTokenizerAndCheckMainHandler`, `createPrewarmSubtitleDictionariesMainHandler`) and rewired `tokenizeSubtitle`, `createMecabTokenizerAndCheck`, and `prewarmSubtitleDictionaries` in `src/main.ts`.
- [2026-02-20T05:31:05Z] progress: extracted `cycleSecondarySubMode` deps assembly into `src/main/runtime/secondary-sub-mode-main-deps.ts` (`createBuildCycleSecondarySubModeMainDepsHandler`) and rewired `cycleSecondarySubMode` in `src/main.ts`.
- [2026-02-20T05:31:05Z] progress: while implementing subtitle-tokenization deps, fixed strict typing to align parser promise shapes (`Promise<void>` ready + `Promise<boolean>` init) and Mecab availability return type.
- [2026-02-20T05:31:05Z] progress: `src/main.ts` currently 2664 LOC after this slice.
- [2026-02-20T05:31:05Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/subtitle-tokenization-main-deps.test.js dist/main/runtime/secondary-sub-mode-main-deps.test.js dist/main/runtime/startup-warmups.test.js` pass (7/7).
- [2026-02-20T05:49:13Z] progress: extracted overlay runtime state/action wrappers into `src/main/runtime/overlay-runtime-main-actions.ts` (`createGetRuntimeOptionsStateHandler`, `createRestorePreviousSecondarySubVisibilityHandler`, `createBroadcastRuntimeOptionsChangedHandler`, `createSendToActiveOverlayWindowHandler`, `createSetOverlayDebugVisualizationEnabledHandler`, `createOpenRuntimeOptionsPaletteHandler`), and rewired corresponding `main.ts` functions to thin delegations.
- [2026-02-20T05:49:13Z] progress: while adding tests, corrected strict typing to import `OverlayHostedModal` from `src/main/overlay-runtime.ts` and aligned `RuntimeOptionState` fixture shape.
- [2026-02-20T05:49:13Z] progress: `src/main.ts` currently 2696 LOC after this slice.
- [2026-02-20T05:49:13Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/overlay-runtime-main-actions.test.js dist/main/runtime/subtitle-tokenization-main-deps.test.js dist/main/runtime/secondary-sub-mode-main-deps.test.js` pass (12/12).
- [2026-02-20T05:50:43Z] progress: extracted Jellyfin config/client info wrappers into `src/main/runtime/jellyfin-client-info.ts` (`createGetResolvedJellyfinConfigHandler`, `createGetJellyfinClientInfoHandler`) and rewired `getResolvedJellyfinConfig` + `getJellyfinClientInfo` in `src/main.ts`.
- [2026-02-20T05:50:43Z] progress: fixed strict typing regressions by loosening helper input types to preserve call-site inference while keeping client-info output normalized to strings.
- [2026-02-20T05:50:43Z] progress: `src/main.ts` currently 2702 LOC after this slice.
- [2026-02-20T05:50:43Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/jellyfin-client-info.test.js dist/main/runtime/overlay-runtime-main-actions.test.js dist/main/runtime/subtitle-tokenization-main-deps.test.js` pass (14/14).
- [2026-02-20T06:52:54Z] progress: extracted startup config handler deps assembly into `src/main/runtime/startup-config-main-deps.ts` and rewired `reloadConfigHandler` + `criticalConfigErrorHandler` setup in `src/main.ts`.
- [2026-02-20T06:52:54Z] progress: extracted app-ready runner deps assembly into `src/main/runtime/app-ready-main-deps.ts` and lifted nested `createAppReadyRuntimeRunner(...)` input block to `appReadyRuntimeRunner` constant in `src/main.ts`.
- [2026-02-20T06:52:54Z] progress: extracted app-lifecycle runner deps assembly into `src/main/runtime/startup-lifecycle-main-deps.ts` and lifted lifecycle runner wiring to `appLifecycleRuntimeRunner` constant in `src/main.ts`.
- [2026-02-20T06:52:54Z] progress: extracted startup bootstrap deps assembly into `src/main/runtime/startup-bootstrap-main-deps.ts` and rewired `buildStartupBootstrapRuntimeFactoryDepsHandler` to compose through the new builder.
- [2026-02-20T06:52:54Z] progress: `src/main.ts` currently 2723 LOC after this slice.
- [2026-02-20T06:52:54Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/startup-bootstrap-main-deps.test.js dist/main/runtime/startup-bootstrap-deps-builder.test.js dist/main/runtime/startup-lifecycle-main-deps.test.js dist/main/runtime/app-ready-main-deps.test.js dist/main/runtime/startup-config-main-deps.test.js dist/core/services/startup-bootstrap.test.js dist/core/services/app-ready.test.js` pass (21/21).
- [2026-02-20T06:56:20Z] progress: extracted CLI precheck deps assembly into `src/main/runtime/cli-command-prechecks-main-deps.ts` and rewired `handleCliCommand` to use a prebuilt `handleTexthookerOnlyModeTransitionHandler`.
- [2026-02-20T06:56:20Z] progress: extracted field-grouping resolver state wrappers into `src/main/runtime/field-grouping-resolver.ts` and rewired `getFieldGroupingResolver` + `setFieldGroupingResolver` in `src/main.ts`.
- [2026-02-20T06:56:20Z] progress: extracted `applyJellyfinMpvDefaults` and `getDefaultSocketPath` wrappers into `src/main/runtime/mpv-jellyfin-defaults.ts`; rewired both `main.ts` helper functions to thin handler delegates.
- [2026-02-20T06:56:20Z] progress: `src/main.ts` currently 2742 LOC after this slice.
- [2026-02-20T06:56:20Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/cli-command-prechecks-main-deps.test.js dist/main/runtime/cli-command-prechecks.test.js dist/main/runtime/field-grouping-resolver.test.js dist/main/runtime/mpv-jellyfin-defaults.test.js dist/main/runtime/startup-bootstrap-main-deps.test.js` pass (11/11).