feat(captions): extend data model with font, shadow, dimmed color, bg toggle fields
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,14 +3,56 @@ import type { CookieSource } from '$lib/bindings/dependencies';
|
||||
|
||||
export type { CookieSource };
|
||||
|
||||
export interface CaptionSettings {
|
||||
fontFamily: string;
|
||||
fontSize: number;
|
||||
textColor: string;
|
||||
bold: boolean;
|
||||
outlineColor: string;
|
||||
backgroundEnabled: boolean;
|
||||
backgroundOpacity: number;
|
||||
backgroundColor: string;
|
||||
textOutline: boolean;
|
||||
shadowEnabled: boolean;
|
||||
shadowDepth: number;
|
||||
shadowColor: string;
|
||||
dimmedColorMode: 'auto' | 'custom';
|
||||
dimmedOpacity: number;
|
||||
dimmedColor: string;
|
||||
position: 'bottom' | 'top';
|
||||
wordHighlight: boolean;
|
||||
}
|
||||
|
||||
export const DEFAULT_CAPTION_SETTINGS: CaptionSettings = {
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 18,
|
||||
textColor: '#ffffff',
|
||||
bold: true,
|
||||
outlineColor: '#000000',
|
||||
backgroundEnabled: true,
|
||||
backgroundOpacity: 0.75,
|
||||
backgroundColor: '#000000',
|
||||
textOutline: true,
|
||||
shadowEnabled: false,
|
||||
shadowDepth: 2,
|
||||
shadowColor: '#000000',
|
||||
dimmedColorMode: 'auto',
|
||||
dimmedOpacity: 0.4,
|
||||
dimmedColor: '#999999',
|
||||
position: 'bottom',
|
||||
wordHighlight: true,
|
||||
};
|
||||
|
||||
export interface Preferences {
|
||||
outputDirectory: string;
|
||||
cookieSource: CookieSource;
|
||||
captionSettings: CaptionSettings;
|
||||
}
|
||||
|
||||
const DEFAULT_PREFERENCES: Preferences = {
|
||||
outputDirectory: '~/',
|
||||
cookieSource: { type: 'browser', browser: 'firefox' },
|
||||
captionSettings: { ...DEFAULT_CAPTION_SETTINGS },
|
||||
};
|
||||
|
||||
let store: Store | null = null;
|
||||
@@ -27,8 +69,10 @@ export async function loadPreferences(): Promise<void> {
|
||||
store = await load('preferences.json', { autoSave: true });
|
||||
const savedDir = await store.get<string>('outputDirectory');
|
||||
const savedCookie = await store.get<CookieSource>('cookieSource');
|
||||
const savedCaptions = await store.get<CaptionSettings>('captionSettings');
|
||||
if (savedDir) preferences.outputDirectory = savedDir;
|
||||
if (savedCookie) preferences.cookieSource = savedCookie;
|
||||
if (savedCaptions) preferences.captionSettings = { ...DEFAULT_CAPTION_SETTINGS, ...savedCaptions };
|
||||
})();
|
||||
await loadPromise;
|
||||
}
|
||||
@@ -40,6 +84,7 @@ export async function savePreferences(): Promise<void> {
|
||||
if (!store) return;
|
||||
await store.set('outputDirectory', preferences.outputDirectory);
|
||||
await store.set('cookieSource', preferences.cookieSource);
|
||||
await store.set('captionSettings', preferences.captionSettings);
|
||||
await store.save();
|
||||
}
|
||||
|
||||
@@ -52,3 +97,8 @@ export async function setCookieSource(source: CookieSource): Promise<void> {
|
||||
preferences.cookieSource = source;
|
||||
await savePreferences();
|
||||
}
|
||||
|
||||
export async function setCaptionSettings(settings: Partial<CaptionSettings>): Promise<void> {
|
||||
Object.assign(preferences.captionSettings, settings);
|
||||
await savePreferences();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user