mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-30 06:12:06 -07:00
refactor: inline subtitle-prefetch-runtime-composer
The composer was a pure pass-through that destructured an object and reassembled it with the same fields. Inlined at the call site.
This commit is contained in:
12
src/main.ts
12
src/main.ts
@@ -386,7 +386,6 @@ import {
|
|||||||
composeMpvRuntimeHandlers,
|
composeMpvRuntimeHandlers,
|
||||||
composeOverlayVisibilityRuntime,
|
composeOverlayVisibilityRuntime,
|
||||||
composeShortcutRuntimes,
|
composeShortcutRuntimes,
|
||||||
composeSubtitlePrefetchRuntime,
|
|
||||||
composeStartupLifecycleHandlers,
|
composeStartupLifecycleHandlers,
|
||||||
} from './main/runtime/composers';
|
} from './main/runtime/composers';
|
||||||
import { createOverlayWindowRuntimeHandlers } from './main/runtime/overlay-window-runtime-handlers';
|
import { createOverlayWindowRuntimeHandlers } from './main/runtime/overlay-window-runtime-handlers';
|
||||||
@@ -1396,13 +1395,14 @@ function scheduleSubtitlePrefetchRefresh(delayMs = 0): void {
|
|||||||
void refreshSubtitlePrefetchFromActiveTrackHandler();
|
void refreshSubtitlePrefetchFromActiveTrackHandler();
|
||||||
}, delayMs);
|
}, delayMs);
|
||||||
}
|
}
|
||||||
const subtitlePrefetchRuntime = composeSubtitlePrefetchRuntime({
|
const subtitlePrefetchRuntime = {
|
||||||
subtitlePrefetchInitController,
|
cancelPendingInit: () => subtitlePrefetchInitController.cancelPendingInit(),
|
||||||
refreshSubtitleSidebarFromSource: (sourcePath) => refreshSubtitleSidebarFromSource(sourcePath),
|
initSubtitlePrefetch: subtitlePrefetchInitController.initSubtitlePrefetch,
|
||||||
|
refreshSubtitleSidebarFromSource: (sourcePath: string) => refreshSubtitleSidebarFromSource(sourcePath),
|
||||||
refreshSubtitlePrefetchFromActiveTrack: () => refreshSubtitlePrefetchFromActiveTrackHandler(),
|
refreshSubtitlePrefetchFromActiveTrack: () => refreshSubtitlePrefetchFromActiveTrackHandler(),
|
||||||
scheduleSubtitlePrefetchRefresh: (delayMs) => scheduleSubtitlePrefetchRefresh(delayMs),
|
scheduleSubtitlePrefetchRefresh: (delayMs?: number) => scheduleSubtitlePrefetchRefresh(delayMs),
|
||||||
clearScheduledSubtitlePrefetchRefresh: () => clearScheduledSubtitlePrefetchRefresh(),
|
clearScheduledSubtitlePrefetchRefresh: () => clearScheduledSubtitlePrefetchRefresh(),
|
||||||
});
|
} as const;
|
||||||
|
|
||||||
const overlayShortcutsRuntime = createOverlayShortcutsRuntimeService(
|
const overlayShortcutsRuntime = createOverlayShortcutsRuntimeService(
|
||||||
createBuildOverlayShortcutsRuntimeMainDepsHandler({
|
createBuildOverlayShortcutsRuntimeMainDepsHandler({
|
||||||
|
|||||||
@@ -10,5 +10,4 @@ export * from './jellyfin-runtime-composer';
|
|||||||
export * from './mpv-runtime-composer';
|
export * from './mpv-runtime-composer';
|
||||||
export * from './overlay-visibility-runtime-composer';
|
export * from './overlay-visibility-runtime-composer';
|
||||||
export * from './shortcuts-runtime-composer';
|
export * from './shortcuts-runtime-composer';
|
||||||
export * from './subtitle-prefetch-runtime-composer';
|
|
||||||
export * from './startup-lifecycle-composer';
|
export * from './startup-lifecycle-composer';
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
import assert from 'node:assert/strict';
|
|
||||||
import test from 'node:test';
|
|
||||||
import { composeSubtitlePrefetchRuntime } from './subtitle-prefetch-runtime-composer';
|
|
||||||
|
|
||||||
test('composeSubtitlePrefetchRuntime returns subtitle prefetch runtime helpers', () => {
|
|
||||||
const composed = composeSubtitlePrefetchRuntime({
|
|
||||||
subtitlePrefetchInitController: {
|
|
||||||
cancelPendingInit: () => {},
|
|
||||||
initSubtitlePrefetch: async () => {},
|
|
||||||
},
|
|
||||||
refreshSubtitleSidebarFromSource: async () => {},
|
|
||||||
refreshSubtitlePrefetchFromActiveTrack: async () => {},
|
|
||||||
scheduleSubtitlePrefetchRefresh: () => {},
|
|
||||||
clearScheduledSubtitlePrefetchRefresh: () => {},
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.equal(typeof composed.cancelPendingInit, 'function');
|
|
||||||
assert.equal(typeof composed.initSubtitlePrefetch, 'function');
|
|
||||||
assert.equal(typeof composed.refreshSubtitleSidebarFromSource, 'function');
|
|
||||||
assert.equal(typeof composed.refreshSubtitlePrefetchFromActiveTrack, 'function');
|
|
||||||
assert.equal(typeof composed.scheduleSubtitlePrefetchRefresh, 'function');
|
|
||||||
assert.equal(typeof composed.clearScheduledSubtitlePrefetchRefresh, 'function');
|
|
||||||
});
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import type { SubtitlePrefetchInitController } from '../subtitle-prefetch-init';
|
|
||||||
import type { ComposerInputs, ComposerOutputs } from './contracts';
|
|
||||||
|
|
||||||
export type SubtitlePrefetchRuntimeComposerOptions = ComposerInputs<{
|
|
||||||
subtitlePrefetchInitController: SubtitlePrefetchInitController;
|
|
||||||
refreshSubtitleSidebarFromSource: (sourcePath: string) => Promise<void>;
|
|
||||||
refreshSubtitlePrefetchFromActiveTrack: () => Promise<void>;
|
|
||||||
scheduleSubtitlePrefetchRefresh: (delayMs?: number) => void;
|
|
||||||
clearScheduledSubtitlePrefetchRefresh: () => void;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
export type SubtitlePrefetchRuntimeComposerResult = ComposerOutputs<{
|
|
||||||
cancelPendingInit: () => void;
|
|
||||||
initSubtitlePrefetch: SubtitlePrefetchInitController['initSubtitlePrefetch'];
|
|
||||||
refreshSubtitleSidebarFromSource: (sourcePath: string) => Promise<void>;
|
|
||||||
refreshSubtitlePrefetchFromActiveTrack: () => Promise<void>;
|
|
||||||
scheduleSubtitlePrefetchRefresh: (delayMs?: number) => void;
|
|
||||||
clearScheduledSubtitlePrefetchRefresh: () => void;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
export function composeSubtitlePrefetchRuntime(
|
|
||||||
options: SubtitlePrefetchRuntimeComposerOptions,
|
|
||||||
): SubtitlePrefetchRuntimeComposerResult {
|
|
||||||
return {
|
|
||||||
cancelPendingInit: () => options.subtitlePrefetchInitController.cancelPendingInit(),
|
|
||||||
initSubtitlePrefetch: options.subtitlePrefetchInitController.initSubtitlePrefetch,
|
|
||||||
refreshSubtitleSidebarFromSource: options.refreshSubtitleSidebarFromSource,
|
|
||||||
refreshSubtitlePrefetchFromActiveTrack: options.refreshSubtitlePrefetchFromActiveTrack,
|
|
||||||
scheduleSubtitlePrefetchRefresh: options.scheduleSubtitlePrefetchRefresh,
|
|
||||||
clearScheduledSubtitlePrefetchRefresh: options.clearScheduledSubtitlePrefetchRefresh,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user