mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-10 03:13:32 -07:00
cf16587547
- Show mpv OSD spinner from start-file until subminer-overlay-loading-ready; force-shown for visible-overlay startup regardless of osd_messages setting - Gate non-macOS overlay visibility on content-ready so first subtitle line is immediately hoverable and clickable - Queue startup notifications in main process until overlay window finishes loading; upsert progress cards by id to avoid cold-start floods - Defer background warmups until after overlay runtime init so queued notifications can deliver promptly - Preserve character dictionary checking/building/importing/ready phases as distinct history entries; route building and importing to system notifications when notificationType is both
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
import type { MpvBackend } from '../types/config';
|
|
import type { LogRotation } from './log-files';
|
|
|
|
export interface SubminerPluginRuntimeScriptOptConfig {
|
|
socketPath: string;
|
|
binaryPath?: string;
|
|
backend: MpvBackend;
|
|
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
logRotation?: LogRotation;
|
|
autoStart: boolean;
|
|
autoStartVisibleOverlay: boolean;
|
|
autoStartPauseUntilReady: boolean;
|
|
overlayLoadingOsd?: boolean;
|
|
osdMessages: boolean;
|
|
texthookerEnabled: boolean;
|
|
}
|
|
|
|
const AUTO_START_PAUSE_UNTIL_READY_TIMEOUT_SECONDS = 30;
|
|
|
|
function boolScriptOpt(value: boolean): 'yes' | 'no' {
|
|
return value ? 'yes' : 'no';
|
|
}
|
|
|
|
function sanitizeScriptOptValue(value: string): string {
|
|
return value
|
|
.replace(/,/g, ' ')
|
|
.replace(/[\r\n]/g, ' ')
|
|
.replace(/\s+/g, ' ')
|
|
.trim();
|
|
}
|
|
|
|
export function buildSubminerPluginRuntimeScriptOptParts(
|
|
runtimeConfig: SubminerPluginRuntimeScriptOptConfig,
|
|
fallbackAppPath: string,
|
|
): string[] {
|
|
const binaryPath = sanitizeScriptOptValue(runtimeConfig.binaryPath?.trim() || fallbackAppPath);
|
|
const socketPath = sanitizeScriptOptValue(runtimeConfig.socketPath);
|
|
const backend = sanitizeScriptOptValue(runtimeConfig.backend);
|
|
const overlayLoadingOsd =
|
|
runtimeConfig.overlayLoadingOsd ??
|
|
(runtimeConfig.autoStart && runtimeConfig.autoStartVisibleOverlay);
|
|
return [
|
|
`subminer-binary_path=${binaryPath}`,
|
|
`subminer-socket_path=${socketPath}`,
|
|
`subminer-backend=${backend}`,
|
|
`subminer-auto_start=${boolScriptOpt(runtimeConfig.autoStart)}`,
|
|
`subminer-auto_start_visible_overlay=${boolScriptOpt(runtimeConfig.autoStartVisibleOverlay)}`,
|
|
`subminer-overlay_loading_osd=${boolScriptOpt(overlayLoadingOsd)}`,
|
|
`subminer-auto_start_pause_until_ready=${boolScriptOpt(
|
|
runtimeConfig.autoStartPauseUntilReady,
|
|
)}`,
|
|
`subminer-auto_start_pause_until_ready_timeout_seconds=${AUTO_START_PAUSE_UNTIL_READY_TIMEOUT_SECONDS}`,
|
|
`subminer-osd_messages=${boolScriptOpt(runtimeConfig.osdMessages)}`,
|
|
`subminer-texthooker_enabled=${boolScriptOpt(runtimeConfig.texthookerEnabled)}`,
|
|
];
|
|
}
|