mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-27 00:55:16 -07:00
feat(config): unify mpv plugin options under main config and add CSS/Ani
- Replace subminer.conf plugin config with mpv.* fields in config.jsonc - Add socketPath, backend, autoStartSubMiner, pauseUntilOverlayReady, aniskipEnabled/buttonKey, subminerBinaryPath to mpv config - Add subtitleSidebar.css field; migrate legacy sidebar appearance fields - Add paintOrder and WebkitTextStroke to subtitle style options - Update default subtitle/sidebar fontFamily to CJK-first stack - Fix overlay visible state surviving mpv y-r restart - Fix live config saves applying subtitle CSS immediately to open overlays - Migrate legacy primary/secondary subtitle appearance into subtitleStyle.css on load - Switch AniSkip button key setting to click-to-learn key capture
This commit is contained in:
@@ -7,12 +7,16 @@ import {
|
||||
serializeSubtitleCssDeclarations,
|
||||
} from './subtitle-style-css';
|
||||
|
||||
test('serializeSubtitleCssDeclarations builds primary CSS from config minus default colors', () => {
|
||||
test('serializeSubtitleCssDeclarations builds primary CSS from all managed appearance config', () => {
|
||||
const css = serializeSubtitleCssDeclarations('primary', {
|
||||
'subtitleStyle.fontFamily': 'M PLUS 1, sans-serif',
|
||||
'subtitleStyle.fontSize': 35,
|
||||
'subtitleStyle.fontColor': '#cad3f5',
|
||||
'subtitleStyle.backgroundColor': 'transparent',
|
||||
'subtitleStyle.hoverTokenColor': '#f4dbd6',
|
||||
'subtitleStyle.hoverTokenBackgroundColor': 'rgba(54, 58, 79, 0.84)',
|
||||
'subtitleStyle.paintOrder': 'stroke fill',
|
||||
'subtitleStyle.WebkitTextStroke': '1.5px #000',
|
||||
'subtitleStyle.textShadow': '0 2px 6px rgba(0,0,0,0.9)',
|
||||
'subtitleStyle.css': {
|
||||
filter: 'drop-shadow(0 0 8px #000)',
|
||||
@@ -22,11 +26,21 @@ test('serializeSubtitleCssDeclarations builds primary CSS from config minus defa
|
||||
|
||||
assert.match(css, /font-family: M PLUS 1, sans-serif;/);
|
||||
assert.match(css, /font-size: 35px;/);
|
||||
assert.match(css, /color: #cad3f5;/);
|
||||
assert.match(css, /background-color: transparent;/);
|
||||
assert.match(css, /--subtitle-hover-token-color: #f4dbd6;/);
|
||||
assert.match(css, /--subtitle-hover-token-background-color: rgba\(54, 58, 79, 0.84\);/);
|
||||
assert.match(css, /paint-order: stroke fill;/);
|
||||
assert.match(css, /-webkit-text-stroke: 1.5px #000;/);
|
||||
assert.doesNotMatch(css, /--subtitle-known-word-color:/);
|
||||
assert.doesNotMatch(css, /--subtitle-n-plus-one-color:/);
|
||||
assert.doesNotMatch(css, /--subtitle-name-match-color:/);
|
||||
assert.doesNotMatch(css, /--subtitle-jlpt-n1-color:/);
|
||||
assert.doesNotMatch(css, /--subtitle-frequency-single-color:/);
|
||||
assert.doesNotMatch(css, /--subtitle-frequency-band-1-color:/);
|
||||
assert.match(css, /text-shadow: 0 2px 6px rgba\(0,0,0,0.9\);/);
|
||||
assert.match(css, /filter: drop-shadow\(0 0 8px #000\);/);
|
||||
assert.match(css, /--subtitle-outline: 1px;/);
|
||||
assert.doesNotMatch(css, /^color:/m);
|
||||
assert.doesNotMatch(css, /^background-color:/m);
|
||||
});
|
||||
|
||||
test('serializeSubtitleCssDeclarations builds secondary CSS from secondary config paths', () => {
|
||||
@@ -42,9 +56,40 @@ test('serializeSubtitleCssDeclarations builds secondary CSS from secondary confi
|
||||
|
||||
assert.match(css, /font-family: Noto Sans, sans-serif;/);
|
||||
assert.match(css, /font-size: 24px;/);
|
||||
assert.match(css, /color: #cad3f5;/);
|
||||
assert.match(css, /background-color: transparent;/);
|
||||
assert.match(css, /text-transform: uppercase;/);
|
||||
assert.doesNotMatch(css, /^color:/m);
|
||||
assert.doesNotMatch(css, /^background-color:/m);
|
||||
});
|
||||
|
||||
test('serializeSubtitleCssDeclarations builds sidebar CSS from subtitle sidebar config paths', () => {
|
||||
const css = serializeSubtitleCssDeclarations('sidebar', {
|
||||
'subtitleSidebar.fontFamily': 'M PLUS 1, sans-serif',
|
||||
'subtitleSidebar.fontSize': 16,
|
||||
'subtitleSidebar.textColor': '#cad3f5',
|
||||
'subtitleSidebar.backgroundColor': 'rgba(73, 77, 100, 0.9)',
|
||||
'subtitleSidebar.opacity': 0.95,
|
||||
'subtitleSidebar.maxWidth': 420,
|
||||
'subtitleSidebar.timestampColor': '#a5adcb',
|
||||
'subtitleSidebar.activeLineColor': '#f5bde6',
|
||||
'subtitleSidebar.activeLineBackgroundColor': 'rgba(138, 173, 244, 0.22)',
|
||||
'subtitleSidebar.hoverLineBackgroundColor': 'rgba(54, 58, 79, 0.84)',
|
||||
'subtitleSidebar.css': {
|
||||
'font-size': '18px',
|
||||
'text-wrap': 'pretty',
|
||||
},
|
||||
});
|
||||
|
||||
assert.match(css, /font-family: M PLUS 1, sans-serif;/);
|
||||
assert.match(css, /font-size: 18px;/);
|
||||
assert.match(css, /color: #cad3f5;/);
|
||||
assert.match(css, /background-color: rgba\(73, 77, 100, 0.9\);/);
|
||||
assert.match(css, /opacity: 0.95;/);
|
||||
assert.match(css, /--subtitle-sidebar-max-width: 420px;/);
|
||||
assert.match(css, /--subtitle-sidebar-timestamp-color: #a5adcb;/);
|
||||
assert.match(css, /--subtitle-sidebar-active-line-color: #f5bde6;/);
|
||||
assert.match(css, /--subtitle-sidebar-active-background-color: rgba\(138, 173, 244, 0.22\);/);
|
||||
assert.match(css, /--subtitle-sidebar-hover-background-color: rgba\(54, 58, 79, 0.84\);/);
|
||||
assert.match(css, /text-wrap: pretty;/);
|
||||
});
|
||||
|
||||
test('parseSubtitleCssDeclarations accepts arbitrary declaration properties', () => {
|
||||
@@ -72,17 +117,77 @@ test('parseSubtitleCssDeclarations rejects selectors and malformed declarations'
|
||||
assert.equal(parseSubtitleCssDeclarations('font-size 40px;').ok, false);
|
||||
});
|
||||
|
||||
test('getSubtitleCssManagedConfigPaths excludes color controls', () => {
|
||||
test('getSubtitleCssManagedConfigPaths includes all CSS-editor-owned appearance controls', () => {
|
||||
assert.ok(!getSubtitleCssManagedConfigPaths('primary').includes(''));
|
||||
assert.ok(!getSubtitleCssManagedConfigPaths('secondary').includes(''));
|
||||
assert.ok(!getSubtitleCssManagedConfigPaths('sidebar').includes(''));
|
||||
assert.ok(getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.fontSize'));
|
||||
assert.ok(
|
||||
getSubtitleCssManagedConfigPaths('secondary').includes('subtitleStyle.secondary.fontSize'),
|
||||
);
|
||||
assert.ok(getSubtitleCssManagedConfigPaths('sidebar').includes('subtitleSidebar.fontSize'));
|
||||
assert.ok(getSubtitleCssManagedConfigPaths('sidebar').includes('subtitleSidebar.textColor'));
|
||||
assert.ok(getSubtitleCssManagedConfigPaths('sidebar').includes('subtitleSidebar.maxWidth'));
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.fontColor'),
|
||||
false,
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('secondary').includes('subtitleStyle.secondary.fontColor'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.backgroundColor'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('secondary').includes(
|
||||
'subtitleStyle.secondary.backgroundColor',
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.hoverTokenColor'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.hoverTokenBackgroundColor'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.paintOrder'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.WebkitTextStroke'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.knownWordColor'),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.nPlusOneColor'),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.nameMatchColor'),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes('subtitleStyle.jlptColors.N1'),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes(
|
||||
'subtitleStyle.frequencyDictionary.singleColor',
|
||||
),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
getSubtitleCssManagedConfigPaths('primary').includes(
|
||||
'subtitleStyle.frequencyDictionary.bandedColors',
|
||||
),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user