mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-10-27 11:35:23 -07:00
- Load plugins from <config dir>/plugins/<id>/ when enabled under `plugins` in config - Expose ctx with mpv events/commands, timers, subtitle context, actions, notify, exec, and panel - Bind plugin actions via `__plugin-action:<id>/<action>` keybindings (runPluginAction session action) - Add plugin-panel modal with markdown rendering; closing aborts the panel signal - Add ai-explain example plugin that queries `codex exec` for the current line - Add e2e harness `files` option and plugin e2e scenario; document plugins in docs-site and internal docs
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { ResolveContext } from './context';
|
|
import { isObject } from './shared';
|
|
|
|
/** Keeps well-formed `plugins.<id>` entries; ids are validated again when the plugin loads. */
|
|
export function applyPluginsConfig(context: ResolveContext): void {
|
|
const { src, resolved, warn } = context;
|
|
if (src.plugins === undefined) return;
|
|
if (!isObject(src.plugins)) {
|
|
warn('plugins', src.plugins, resolved.plugins, 'Expected object keyed by plugin id.');
|
|
return;
|
|
}
|
|
|
|
for (const [id, entry] of Object.entries(src.plugins)) {
|
|
const path = `plugins.${id}`;
|
|
if (!isObject(entry)) {
|
|
warn(path, entry, undefined, 'Expected { "enabled": boolean, "settings"?: object }.');
|
|
continue;
|
|
}
|
|
if (entry.enabled !== undefined && typeof entry.enabled !== 'boolean') {
|
|
warn(`${path}.enabled`, entry.enabled, false, 'Expected boolean.');
|
|
}
|
|
if (entry.settings !== undefined && !isObject(entry.settings)) {
|
|
warn(`${path}.settings`, entry.settings, {}, 'Expected object.');
|
|
}
|
|
resolved.plugins[id] = {
|
|
enabled: entry.enabled === true,
|
|
settings: isObject(entry.settings) ? { ...entry.settings } : {},
|
|
};
|
|
}
|
|
}
|