mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-21 00:11:27 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
18
src/main/runtime/mpv-subtitle-render-metrics.ts
Normal file
18
src/main/runtime/mpv-subtitle-render-metrics.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { MpvSubtitleRenderMetrics } from '../../types';
|
||||
|
||||
export function createUpdateMpvSubtitleRenderMetricsHandler(deps: {
|
||||
getCurrentMetrics: () => MpvSubtitleRenderMetrics;
|
||||
setCurrentMetrics: (metrics: MpvSubtitleRenderMetrics) => void;
|
||||
applyPatch: (
|
||||
current: MpvSubtitleRenderMetrics,
|
||||
patch: Partial<MpvSubtitleRenderMetrics>,
|
||||
) => { next: MpvSubtitleRenderMetrics; changed: boolean };
|
||||
broadcastMetrics: (metrics: MpvSubtitleRenderMetrics) => void;
|
||||
}) {
|
||||
return (patch: Partial<MpvSubtitleRenderMetrics>): void => {
|
||||
const { next, changed } = deps.applyPatch(deps.getCurrentMetrics(), patch);
|
||||
if (!changed) return;
|
||||
deps.setCurrentMetrics(next);
|
||||
deps.broadcastMetrics(next);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user