mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-01 06:22:44 -08:00
refactor: normalize additional main dependency construction
This commit is contained in:
@@ -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: 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] 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: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`.
|
||||||
|
|||||||
62
src/main.ts
62
src/main.ts
@@ -2189,7 +2189,7 @@ function handleInitialArgs(): void {
|
|||||||
handleInitialArgsRuntimeHandler();
|
handleInitialArgsRuntimeHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
const bindMpvClientEventHandlers = createBindMpvMainEventHandlersHandler(
|
const buildBindMpvMainEventHandlersMainDepsHandler =
|
||||||
createBuildBindMpvMainEventHandlersMainDepsHandler({
|
createBuildBindMpvMainEventHandlersMainDepsHandler({
|
||||||
appState,
|
appState,
|
||||||
getQuitOnDisconnectArmed: () => jellyfinPlayQuitOnDisconnectArmed,
|
getQuitOnDisconnectArmed: () => jellyfinPlayQuitOnDisconnectArmed,
|
||||||
@@ -2236,27 +2236,30 @@ const bindMpvClientEventHandlers = createBindMpvMainEventHandlersHandler(
|
|||||||
updateSubtitleRenderMetrics: (patch) => {
|
updateSubtitleRenderMetrics: (patch) => {
|
||||||
updateMpvSubtitleRenderMetrics(patch as Partial<MpvSubtitleRenderMetrics>);
|
updateMpvSubtitleRenderMetrics(patch as Partial<MpvSubtitleRenderMetrics>);
|
||||||
},
|
},
|
||||||
})(),
|
});
|
||||||
|
const bindMpvClientEventHandlers = createBindMpvMainEventHandlersHandler(
|
||||||
|
buildBindMpvMainEventHandlersMainDepsHandler(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const buildMpvClientRuntimeServiceFactoryMainDepsHandler =
|
||||||
|
createBuildMpvClientRuntimeServiceFactoryDepsHandler({
|
||||||
|
createClient: MpvIpcClient,
|
||||||
|
getSocketPath: () => appState.mpvSocketPath,
|
||||||
|
getResolvedConfig: () => getResolvedConfig(),
|
||||||
|
isAutoStartOverlayEnabled: () => appState.autoStartOverlay,
|
||||||
|
setOverlayVisible: (visible: boolean) => setOverlayVisible(visible),
|
||||||
|
shouldBindVisibleOverlayToMpvSubVisibility: () =>
|
||||||
|
configDerivedRuntime.shouldBindVisibleOverlayToMpvSubVisibility(),
|
||||||
|
isVisibleOverlayVisible: () => overlayManager.getVisibleOverlayVisible(),
|
||||||
|
getReconnectTimer: () => appState.reconnectTimer,
|
||||||
|
setReconnectTimer: (timer: ReturnType<typeof setTimeout> | null) => {
|
||||||
|
appState.reconnectTimer = timer;
|
||||||
|
},
|
||||||
|
bindEventHandlers: (client) => bindMpvClientEventHandlers(client),
|
||||||
|
});
|
||||||
|
|
||||||
function createMpvClientRuntimeService(): MpvIpcClient {
|
function createMpvClientRuntimeService(): MpvIpcClient {
|
||||||
return createMpvClientRuntimeServiceFactory(
|
return createMpvClientRuntimeServiceFactory(buildMpvClientRuntimeServiceFactoryMainDepsHandler())();
|
||||||
createBuildMpvClientRuntimeServiceFactoryDepsHandler({
|
|
||||||
createClient: MpvIpcClient,
|
|
||||||
getSocketPath: () => appState.mpvSocketPath,
|
|
||||||
getResolvedConfig: () => getResolvedConfig(),
|
|
||||||
isAutoStartOverlayEnabled: () => appState.autoStartOverlay,
|
|
||||||
setOverlayVisible: (visible: boolean) => setOverlayVisible(visible),
|
|
||||||
shouldBindVisibleOverlayToMpvSubVisibility: () =>
|
|
||||||
configDerivedRuntime.shouldBindVisibleOverlayToMpvSubVisibility(),
|
|
||||||
isVisibleOverlayVisible: () => overlayManager.getVisibleOverlayVisible(),
|
|
||||||
getReconnectTimer: () => appState.reconnectTimer,
|
|
||||||
setReconnectTimer: (timer: ReturnType<typeof setTimeout> | null) => {
|
|
||||||
appState.reconnectTimer = timer;
|
|
||||||
},
|
|
||||||
bindEventHandlers: (client) => bindMpvClientEventHandlers(client),
|
|
||||||
})(),
|
|
||||||
)();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildUpdateMpvSubtitleRenderMetricsMainDepsHandler =
|
const buildUpdateMpvSubtitleRenderMetricsMainDepsHandler =
|
||||||
@@ -2308,19 +2311,25 @@ const buildTokenizerDepsHandler = createBuildTokenizerDepsMainHandler({
|
|||||||
getMecabTokenizer: () => appState.mecabTokenizer,
|
getMecabTokenizer: () => appState.mecabTokenizer,
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMecabTokenizerAndCheckHandler = createCreateMecabTokenizerAndCheckMainHandler({
|
const buildCreateMecabTokenizerAndCheckMainDepsHandler = createCreateMecabTokenizerAndCheckMainHandler(
|
||||||
|
{
|
||||||
getMecabTokenizer: () => appState.mecabTokenizer,
|
getMecabTokenizer: () => appState.mecabTokenizer,
|
||||||
setMecabTokenizer: (tokenizer) => {
|
setMecabTokenizer: (tokenizer) => {
|
||||||
appState.mecabTokenizer = tokenizer;
|
appState.mecabTokenizer = tokenizer;
|
||||||
},
|
},
|
||||||
createMecabTokenizer: () => new MecabTokenizer(),
|
createMecabTokenizer: () => new MecabTokenizer(),
|
||||||
checkAvailability: async (tokenizer) => tokenizer.checkAvailability(),
|
checkAvailability: async (tokenizer) => tokenizer.checkAvailability(),
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
const createMecabTokenizerAndCheckHandler = buildCreateMecabTokenizerAndCheckMainDepsHandler;
|
||||||
|
|
||||||
const prewarmSubtitleDictionariesHandler = createPrewarmSubtitleDictionariesMainHandler({
|
const buildPrewarmSubtitleDictionariesMainDepsHandler = createPrewarmSubtitleDictionariesMainHandler(
|
||||||
|
{
|
||||||
ensureJlptDictionaryLookup: () => jlptDictionaryRuntime.ensureJlptDictionaryLookup(),
|
ensureJlptDictionaryLookup: () => jlptDictionaryRuntime.ensureJlptDictionaryLookup(),
|
||||||
ensureFrequencyDictionaryLookup: () => frequencyDictionaryRuntime.ensureFrequencyDictionaryLookup(),
|
ensureFrequencyDictionaryLookup: () => frequencyDictionaryRuntime.ensureFrequencyDictionaryLookup(),
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
const prewarmSubtitleDictionariesHandler = buildPrewarmSubtitleDictionariesMainDepsHandler;
|
||||||
|
|
||||||
async function tokenizeSubtitle(text: string): Promise<SubtitleData> {
|
async function tokenizeSubtitle(text: string): Promise<SubtitleData> {
|
||||||
await jlptDictionaryRuntime.ensureJlptDictionaryLookup();
|
await jlptDictionaryRuntime.ensureJlptDictionaryLookup();
|
||||||
@@ -2864,8 +2873,7 @@ const buildRunSubsyncManualFromIpcMainDepsHandler =
|
|||||||
const runSubsyncManualFromIpcHandler = createRunSubsyncManualFromIpcHandler(
|
const runSubsyncManualFromIpcHandler = createRunSubsyncManualFromIpcHandler(
|
||||||
buildRunSubsyncManualFromIpcMainDepsHandler(),
|
buildRunSubsyncManualFromIpcMainDepsHandler(),
|
||||||
);
|
);
|
||||||
const buildCliCommandContextDepsHandler = createBuildCliCommandContextDepsHandler(
|
const buildCliCommandContextMainDepsHandler = createBuildCliCommandContextMainDepsHandler({
|
||||||
createBuildCliCommandContextMainDepsHandler({
|
|
||||||
appState,
|
appState,
|
||||||
texthookerService,
|
texthookerService,
|
||||||
getResolvedConfig: () => getResolvedConfig(),
|
getResolvedConfig: () => getResolvedConfig(),
|
||||||
@@ -2906,7 +2914,9 @@ const buildCliCommandContextDepsHandler = createBuildCliCommandContextDepsHandle
|
|||||||
logInfo: (message: string) => logger.info(message),
|
logInfo: (message: string) => logger.info(message),
|
||||||
logWarn: (message: string) => logger.warn(message),
|
logWarn: (message: string) => logger.warn(message),
|
||||||
logError: (message: string, err: unknown) => logger.error(message, err),
|
logError: (message: string, err: unknown) => logger.error(message, err),
|
||||||
})(),
|
});
|
||||||
|
const buildCliCommandContextDepsHandler = createBuildCliCommandContextDepsHandler(
|
||||||
|
buildCliCommandContextMainDepsHandler(),
|
||||||
);
|
);
|
||||||
const createOverlayWindowHandler = createCreateOverlayWindowHandler<BrowserWindow>(
|
const createOverlayWindowHandler = createCreateOverlayWindowHandler<BrowserWindow>(
|
||||||
createBuildCreateOverlayWindowMainDepsHandler<BrowserWindow>({
|
createBuildCreateOverlayWindowMainDepsHandler<BrowserWindow>({
|
||||||
|
|||||||
Reference in New Issue
Block a user