refactor(ipc): remove dead preload methods and the ASS line broadcast (#293)

Drop 16 overlay preload methods with no caller (onSubtitleAss,
getCurrentSubtitleAss, onVisibility, getOverlayVisibility,
openYomitanSettings, quitApp, toggleOverlay, getMecabStatus,
setMecabEnabled, getKeybindings, saveControllerPreference,
getAnkiConnectStatus, setAnkiConnectEnabled, clearAnkiConnectHistory,
cycleRuntimeOption, appendClipboardVideoToQueue) along with their
IPC_CHANNELS keys, handlers, validators and dep plumbing.

With both ASS consumers gone, stop observing sub-text/ass in mpv and
remove the subtitle-ass-change event chain and appState.currentSubAssText.
The main-process functions these wrapped stay; tray, CLI, shortcuts and
session actions still use them.
This commit is contained in:
sudacode authored and GitHub committed 2026-10-12 22:11:17 -07:00
1 parent 8fc20b2499
commit 7909fcd2cf
32 files changed
+8 -876

No files matched your search

-59
View File
@@ -22,8 +22,6 @@ import { createIpcListenerFactories } from './preload-ipc-listeners';
import type {
SubtitleData,
SubtitlePosition,
MecabStatus,
Keybinding,
ElectronAPI,
SecondarySubMode,
SubtitleStyleConfig,
@@ -45,7 +43,6 @@ import type {
SubsyncManualPayload,
SubsyncManualRunRequest,
SubsyncResult,
ClipboardAppendResult,
PlaylistBrowserMutationResult,
PlaylistBrowserSnapshot,
KikuFieldGroupingRequestData,
@@ -60,7 +57,6 @@ import type {
ShortcutsConfig,
ConfigHotReloadPayload,
ControllerConfigUpdate,
ControllerPreferenceUpdate,
ResolvedControllerConfig,
SessionHelpOpenPayload,
SessionNumericSelectionStartPayload,
@@ -176,10 +172,6 @@ const onOverlayNotificationEvent =
const onNotificationHistoryToggleEvent = createQueuedIpcListener(
IPC_CHANNELS.event.notificationHistoryToggle,
);
const onSubtitleVisibilityEvent = createLatestValueIpcListenerWithPayload<boolean>(
IPC_CHANNELS.event.subtitleVisibility,
(payload) => payload === true,
);
const onSubtitlePositionSetEvent = createLatestValueIpcListenerWithPayload<SubtitlePosition | null>(
IPC_CHANNELS.event.subtitlePositionSet,
(payload) => payload as SubtitlePosition | null,
@@ -236,22 +228,14 @@ const electronAPI: ElectronAPI = {
},
onNotificationHistoryToggle: onNotificationHistoryToggleEvent,
onVisibility: (callback: (visible: boolean) => void) => {
onSubtitleVisibilityEvent(callback);
},
onSubtitlePosition: (callback: (position: SubtitlePosition | null) => void) => {
onSubtitlePositionSetEvent(callback);
},
getOverlayVisibility: (): Promise<boolean> =>
ipcRenderer.invoke(IPC_CHANNELS.request.getVisibleOverlayVisibility),
getCurrentSubtitle: (): Promise<SubtitleData> =>
ipcRenderer.invoke(IPC_CHANNELS.request.getCurrentSubtitle),
getCurrentSubtitleRaw: (): Promise<string> =>
ipcRenderer.invoke(IPC_CHANNELS.request.getCurrentSubtitleRaw),
getCurrentSubtitleAss: (): Promise<string> =>
ipcRenderer.invoke(IPC_CHANNELS.request.getCurrentSubtitleAss),
getSubtitleSidebarOpen: (): Promise<boolean> =>
ipcRenderer.invoke(IPC_CHANNELS.request.getSubtitleSidebarOpen),
getSubtitleSidebarSnapshot: () =>
@@ -264,14 +248,6 @@ const electronAPI: ElectronAPI = {
},
getPlaybackPaused: (): Promise<boolean | null> =>
ipcRenderer.invoke(IPC_CHANNELS.request.getPlaybackPaused),
onSubtitleAss: (callback: (assText: string) => void) => {
ipcRenderer.on(
IPC_CHANNELS.event.subtitleAssSet,
(_event: IpcRendererEvent, assText: string) => {
callback(assText);
},
);
},
setIgnoreMouseEvents: (ignore: boolean, options?: { forward?: boolean }) => {
ipcRenderer.send(IPC_CHANNELS.command.setIgnoreMouseEvents, ignore, options);
@@ -281,10 +257,6 @@ const electronAPI: ElectronAPI = {
ipcRenderer.send(IPC_CHANNELS.command.reportOverlayInteractive, interactive);
},
openYomitanSettings: () => {
ipcRenderer.send(IPC_CHANNELS.command.openYomitanSettings);
},
recordYomitanLookup: (context?: SubtitleMiningContext | null) => {
ipcRenderer.send(IPC_CHANNELS.command.recordYomitanLookup, context ?? null);
},
@@ -295,18 +267,10 @@ const electronAPI: ElectronAPI = {
ipcRenderer.send(IPC_CHANNELS.command.saveSubtitlePosition, position);
},
getMecabStatus: (): Promise<MecabStatus> =>
ipcRenderer.invoke(IPC_CHANNELS.request.getMecabStatus),
setMecabEnabled: (enabled: boolean) => {
ipcRenderer.send(IPC_CHANNELS.command.setMecabEnabled, enabled);
},
sendMpvCommand: (command: (string | number)[]) => {
ipcRenderer.send(IPC_CHANNELS.command.mpvCommand, command);
},
getKeybindings: (): Promise<Keybinding[]> =>
ipcRenderer.invoke(IPC_CHANNELS.request.getKeybindings),
getMpvInputBindings: () => ipcRenderer.invoke(IPC_CHANNELS.request.getMpvInputBindings),
getSessionBindings: () => ipcRenderer.invoke(IPC_CHANNELS.request.getSessionBindings),
getConfiguredShortcuts: (): Promise<Required<ShortcutsConfig>> =>
@@ -325,8 +289,6 @@ const electronAPI: ElectronAPI = {
ipcRenderer.invoke(IPC_CHANNELS.request.getControllerConfig),
saveControllerConfig: (update: ControllerConfigUpdate): Promise<void> =>
ipcRenderer.invoke(IPC_CHANNELS.command.saveControllerConfig, update),
saveControllerPreference: (update: ControllerPreferenceUpdate): Promise<void> =>
ipcRenderer.invoke(IPC_CHANNELS.command.saveControllerPreference, update),
getJimakuMediaInfo: (): Promise<JimakuMediaInfo> =>
ipcRenderer.invoke(IPC_CHANNELS.request.jimakuGetMediaInfo),
@@ -350,31 +312,14 @@ const electronAPI: ElectronAPI = {
tsukihimeGetSecondaryLanguages: (): Promise<string[]> =>
ipcRenderer.invoke(IPC_CHANNELS.request.tsukihimeGetSecondaryLanguages),
quitApp: () => {
ipcRenderer.send(IPC_CHANNELS.command.quitApp);
},
toggleDevTools: () => {
ipcRenderer.send(IPC_CHANNELS.command.toggleDevTools);
},
toggleOverlay: () => {
ipcRenderer.send(IPC_CHANNELS.command.toggleOverlay);
},
toggleStatsOverlay: () => {
ipcRenderer.send(IPC_CHANNELS.command.toggleStatsOverlay);
},
getAnkiConnectStatus: (): Promise<boolean> =>
ipcRenderer.invoke(IPC_CHANNELS.request.getAnkiConnectStatus),
setAnkiConnectEnabled: (enabled: boolean) => {
ipcRenderer.send(IPC_CHANNELS.command.setAnkiConnectEnabled, enabled);
},
clearAnkiConnectHistory: () => {
ipcRenderer.send(IPC_CHANNELS.command.clearAnkiConnectHistory);
},
onSecondarySub: (callback: (text: string) => void) => {
onSecondarySubtitleSetEvent(callback);
},
@@ -419,8 +364,6 @@ const electronAPI: ElectronAPI = {
value: RuntimeOptionValue,
): Promise<RuntimeOptionApplyResult> =>
ipcRenderer.invoke(IPC_CHANNELS.request.setRuntimeOption, id, value),
cycleRuntimeOption: (id: RuntimeOptionId, direction: 1 | -1): Promise<RuntimeOptionApplyResult> =>
ipcRenderer.invoke(IPC_CHANNELS.request.cycleRuntimeOption, id, direction),
onRuntimeOptionsChanged: (callback: (options: RuntimeOptionState[]) => void) => {
ipcRenderer.on(
IPC_CHANNELS.event.runtimeOptionsChanged,
@@ -485,8 +428,6 @@ const electronAPI: ElectronAPI = {
onSessionNumericSelectionStart: onSessionNumericSelectionStartEvent,
onKeyboardModeToggleRequested: onKeyboardModeToggleRequestedEvent,
onLookupWindowToggleRequested: onLookupWindowToggleRequestedEvent,
appendClipboardVideoToQueue: (): Promise<ClipboardAppendResult> =>
ipcRenderer.invoke(IPC_CHANNELS.request.appendClipboardVideoToQueue),
getPlaylistBrowserSnapshot: (): Promise<PlaylistBrowserSnapshot> =>
ipcRenderer.invoke(IPC_CHANNELS.request.getPlaylistBrowserSnapshot),
appendPlaylistBrowserFile: (pathValue: string): Promise<PlaylistBrowserMutationResult> =>