mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 04:46:07 -08:00
* refactor(main): build overlay geometry and pointer interaction in the overlay assembly Inject Electron's screen (and the stats-window promotion) into the overlay geometry and visible-overlay interaction runtimes so they load under bun test, then construct both in createOverlayAssembly together with the overlay visibility composer and the mpv subtitle suppression handlers. Replace the three regex tests that pinned the moved Linux input and shape code with behaviour tests on the runtimes. * refactor(main): move the autoplay-ready gate into the playback assembly The autoplay-ready gate, its post-warm subtitle prime, the current-media tokenization gate and managed local subtitle selection all read playback state, and playback signals through the gate, so createPlaybackAssembly now builds them. The overlay reaches the gate through a getter. Replace the last four regex guards with behaviour tests: the gate holds the release until the visible overlay has measured the line and ignores untokenized lines during warmup (playback), cached autoplay priming never paints raw first and the sidebar media path is tagged only after prefetch loads (priming runtime), and dashboard mining overrides the Hachidori Anki server only when the proxy is on (stats server runtime). main-wiring.test.ts is now empty and removed. * refactor(main): move the plugin host, panel and windows into a plugins assembly * refactor(main): move session action dispatch and renderer mpv commands into an assembly createSessionActionsAssembly owns the session action dispatcher, the secondary-subtitle mode cycle, queueing the clipboard's video, and the mpv commands the overlay renderer sends. The runtime option cycle both paths used is now one function. * refactor(main): move Whisper subtitle generation into an assembly * refactor(main): resolve subtitle annotation options in a runtime module The runtime-option-over-config resolution that the texthooker page and the MeCab startup decision share moves out of main.ts into createAnnotationOptions. * test(main): cover a non-boolean runtime annotation option value * docs: describe the plugins, session actions and subtitle generation assemblies Update ownership for overlay geometry and pointer interaction, the autoplay-ready gate, and annotation options; point the overlay priming entry points at their new modules; the main-wiring regex debt is gone. * build: export MpvClientEvents so declaration emit can name the plugins assembly's return type
57 lines
2.4 KiB
TypeScript
57 lines
2.4 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { DEFAULT_CONFIG } from '../../config/definitions';
|
|
import type { ResolvedConfig } from '../../types';
|
|
import type { RuntimeOptionValue } from '../../types/runtime-options';
|
|
import { createAnnotationOptions, type AnnotationRuntimeOptionId } from './annotation-options';
|
|
|
|
/** Every annotation off in config; `runtime` holds the options the user has cycled. */
|
|
function setup(runtime: Partial<Record<AnnotationRuntimeOptionId, RuntimeOptionValue>> = {}) {
|
|
const config: ResolvedConfig = {
|
|
...DEFAULT_CONFIG,
|
|
ankiConnect: {
|
|
...DEFAULT_CONFIG.ankiConnect,
|
|
knownWords: { ...DEFAULT_CONFIG.ankiConnect.knownWords, highlightEnabled: false },
|
|
nPlusOne: { ...DEFAULT_CONFIG.ankiConnect.nPlusOne, enabled: false },
|
|
},
|
|
subtitleStyle: {
|
|
...DEFAULT_CONFIG.subtitleStyle,
|
|
enableJlpt: false,
|
|
nameMatchEnabled: true,
|
|
frequencyDictionary: { ...DEFAULT_CONFIG.subtitleStyle.frequencyDictionary, enabled: false },
|
|
},
|
|
};
|
|
return createAnnotationOptions({
|
|
getConfig: () => config,
|
|
getRuntimeOptionValue: (id) => runtime[id],
|
|
isCharacterDictionaryEnabled: () => false,
|
|
});
|
|
}
|
|
|
|
test('MeCab starts only when some annotation, from config or a runtime option, needs tokens', () => {
|
|
assert.equal(setup().shouldInitializeMecabForAnnotations(), false);
|
|
assert.equal(
|
|
setup({ 'subtitle.annotation.jlpt': true }).shouldInitializeMecabForAnnotations(),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test('a runtime option overrides config only when it holds a boolean', () => {
|
|
const options = setup({ 'subtitle.annotation.nPlusOne': true, 'subtitle.annotation.jlpt': 'on' });
|
|
|
|
assert.equal(options.getRuntimeBooleanOption('subtitle.annotation.nPlusOne', false), true);
|
|
assert.equal(options.getRuntimeBooleanOption('subtitle.annotation.jlpt', false), false);
|
|
assert.equal(options.getRuntimeBooleanOption('subtitle.annotation.frequency', true), true);
|
|
});
|
|
|
|
test('the texthooker colors names only while the character dictionary is enabled', () => {
|
|
const settings = setup({
|
|
'subtitle.annotation.knownWords.highlightEnabled': true,
|
|
}).getTexthookerBootstrapSettings();
|
|
|
|
assert.equal(settings.enableKnownWordColoring, true);
|
|
assert.equal(settings.enableNPlusOneColoring, false);
|
|
assert.equal(settings.characterDictionaryEnabled, false);
|
|
assert.equal(settings.enableNameMatchColoring, false);
|
|
});
|