mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-11 16:46:09 -08:00
feat(plugins): add JavaScript plugin system with overlay panel (#303)
This commit is contained in:
1 parent
90fc7cf940
commit
a9a4c4f083
110 files changed
+5897
-344
No files matched your search
@@ -340,6 +340,14 @@ test('hasExplicitCommand and shouldStartApp preserve command intent', () => {
|
||||
assert.equal(shouldStartApp(sessionAction), true);
|
||||
assert.equal(commandNeedsOverlayRuntime(sessionAction), true);
|
||||
|
||||
const pluginAction = parseArgs(['--plugin-action', 'anime/open']);
|
||||
assert.equal(pluginAction.pluginAction, 'anime/open');
|
||||
assert.equal(parseArgs(['--plugin-action=anime/open']).pluginAction, 'anime/open');
|
||||
assert.equal(hasExplicitCommand(pluginAction), true);
|
||||
assert.equal(shouldStartApp(pluginAction), true);
|
||||
// The plugin decides what it needs; a window-only action must not force the overlay up.
|
||||
assert.equal(commandNeedsOverlayRuntime(pluginAction), false);
|
||||
|
||||
const toggleStatsOverlayRuntime = parseArgs(['--toggle-stats-overlay']);
|
||||
assert.equal(commandNeedsOverlayRuntime(toggleStatsOverlayRuntime), true);
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ export interface CliArgs {
|
||||
cycleRuntimeOptionId?: string;
|
||||
cycleRuntimeOptionDirection?: 1 | -1;
|
||||
sessionAction?: SessionActionDispatchRequest;
|
||||
/** `<plugin id>/<action name>` to run, like a `__plugin-action:` keybinding. */
|
||||
pluginAction?: string;
|
||||
copySubtitleCount?: number;
|
||||
mineSentenceCount?: number;
|
||||
anilistStatus: boolean;
|
||||
@@ -338,6 +340,12 @@ export function parseArgs(argv: string[]): CliArgs {
|
||||
} else if (arg === '--session-action') {
|
||||
const parsed = parseSessionAction(readValue(argv[i + 1]));
|
||||
if (parsed) args.sessionAction = parsed;
|
||||
} else if (arg.startsWith('--plugin-action=')) {
|
||||
const value = arg.slice('--plugin-action='.length).trim();
|
||||
if (value) args.pluginAction = value;
|
||||
} else if (arg === '--plugin-action') {
|
||||
const value = readValue(argv[i + 1])?.trim();
|
||||
if (value) args.pluginAction = value;
|
||||
} else if (arg.startsWith('--copy-subtitle-count=')) {
|
||||
const value = Number(arg.split('=', 2)[1]);
|
||||
if (Number.isInteger(value) && value > 0) args.copySubtitleCount = value;
|
||||
@@ -601,6 +609,7 @@ export function hasExplicitCommand(args: CliArgs): boolean {
|
||||
args.playbackFeedback !== undefined ||
|
||||
args.cycleRuntimeOptionId !== undefined ||
|
||||
args.sessionAction !== undefined ||
|
||||
args.pluginAction !== undefined ||
|
||||
args.copySubtitleCount !== undefined ||
|
||||
args.mineSentenceCount !== undefined ||
|
||||
args.anilistStatus ||
|
||||
@@ -682,6 +691,7 @@ export function isStandaloneTexthookerCommand(args: CliArgs): boolean {
|
||||
args.playbackFeedback === undefined &&
|
||||
args.cycleRuntimeOptionId === undefined &&
|
||||
args.sessionAction === undefined &&
|
||||
args.pluginAction === undefined &&
|
||||
args.copySubtitleCount === undefined &&
|
||||
args.mineSentenceCount === undefined &&
|
||||
!args.anilistStatus &&
|
||||
@@ -752,6 +762,7 @@ export function shouldStartApp(args: CliArgs): boolean {
|
||||
args.playbackFeedback !== undefined ||
|
||||
args.cycleRuntimeOptionId !== undefined ||
|
||||
args.sessionAction !== undefined ||
|
||||
args.pluginAction !== undefined ||
|
||||
args.copySubtitleCount !== undefined ||
|
||||
args.mineSentenceCount !== undefined ||
|
||||
args.dictionary ||
|
||||
@@ -819,6 +830,7 @@ export function shouldRunDictionarySettingsOnlyStartup(args: CliArgs): boolean {
|
||||
args.playbackFeedback === undefined &&
|
||||
args.cycleRuntimeOptionId === undefined &&
|
||||
args.sessionAction === undefined &&
|
||||
args.pluginAction === undefined &&
|
||||
args.copySubtitleCount === undefined &&
|
||||
args.mineSentenceCount === undefined &&
|
||||
!args.anilistStatus &&
|
||||
|
||||
@@ -46,6 +46,7 @@ ${B}Mining${R}
|
||||
--open-session-help Open session help modal
|
||||
--open-controller-select Open controller select modal
|
||||
--open-controller-debug Open controller debug modal
|
||||
--plugin-action ${D}<id>/<name>${R} Run a plugin action
|
||||
|
||||
${B}AniList${R}
|
||||
--anilist-setup Open AniList authentication flow
|
||||
|
||||
Reference in new issue
Block a user