From 7a50c89728681d702eaa5b66151691e702267a18 Mon Sep 17 00:00:00 2001 From: jj Date: Wed, 30 Oct 2024 11:40:53 +0000 Subject: [PATCH] web/settings: split settings into versions --- web/src/lib/types/settings.ts | 62 ++------------------------------ web/src/lib/types/settings/v2.ts | 60 +++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 59 deletions(-) create mode 100644 web/src/lib/types/settings/v2.ts diff --git a/web/src/lib/types/settings.ts b/web/src/lib/types/settings.ts index 3531f88e..fcd04f7e 100644 --- a/web/src/lib/types/settings.ts +++ b/web/src/lib/types/settings.ts @@ -1,65 +1,9 @@ -import languages from "$i18n/languages.json"; -import { youtubeLanguages } from "$lib/settings/youtube-lang"; import type { RecursivePartial } from "$lib/types/generic"; +import type { CobaltSettingsV2 } from "./settings/v2"; -export const themeOptions = ["auto", "light", "dark"] as const; -export const audioBitrateOptions = ["320", "256", "128", "96", "64", "8"] as const; -export const audioFormatOptions = ["best", "mp3", "ogg", "wav", "opus"] as const; -export const downloadModeOptions = ["auto", "audio", "mute"] as const; -export const filenameStyleOptions = ["classic", "basic", "pretty", "nerdy"] as const; -export const videoQualityOptions = ["max", "2160", "1440", "1080", "720", "480", "360", "240", "144"] as const; -export const youtubeVideoCodecOptions = ["h264", "av1", "vp9"] as const; -export const savingMethodOptions = ["ask", "download", "share", "copy"] as const; +export * from "./settings/v2"; -type CobaltSettingsAppearance = { - theme: typeof themeOptions[number], - language: keyof typeof languages, - autoLanguage: boolean, - reduceMotion: boolean, - reduceTransparency: boolean, -}; - -type CobaltSettingsAdvanced = { - debug: boolean, -}; - -type CobaltSettingsPrivacy = { - alwaysProxy: boolean, - disableAnalytics: boolean, -}; - -type CobaltSettingsProcessing = { - allowDefaultOverride: boolean, - customInstanceURL: string, - enableCustomInstances: boolean, - seenCustomWarning: boolean, - seenOverrideWarning: boolean, -} - -type CobaltSettingsSave = { - audioFormat: typeof audioFormatOptions[number], - audioBitrate: typeof audioBitrateOptions[number], - disableMetadata: boolean, - downloadMode: typeof downloadModeOptions[number], - filenameStyle: typeof filenameStyleOptions[number], - savingMethod: typeof savingMethodOptions[number], - tiktokH265: boolean, - tiktokFullAudio: boolean, - twitterGif: boolean, - videoQuality: typeof videoQualityOptions[number], - youtubeVideoCodec: typeof youtubeVideoCodecOptions[number], - youtubeDubLang: typeof youtubeLanguages[number], - youtubeHLS: boolean, -}; - -export type CurrentCobaltSettings = { - schemaVersion: 2, - advanced: CobaltSettingsAdvanced, - appearance: CobaltSettingsAppearance, - save: CobaltSettingsSave, - privacy: CobaltSettingsPrivacy, - processing: CobaltSettingsProcessing, -}; +export type CurrentCobaltSettings = CobaltSettingsV2; export type CobaltSettings = CurrentCobaltSettings; diff --git a/web/src/lib/types/settings/v2.ts b/web/src/lib/types/settings/v2.ts new file mode 100644 index 00000000..bed04cf1 --- /dev/null +++ b/web/src/lib/types/settings/v2.ts @@ -0,0 +1,60 @@ +import languages from "$i18n/languages.json"; + +export const themeOptions = ["auto", "light", "dark"] as const; +export const audioBitrateOptions = ["320", "256", "128", "96", "64", "8"] as const; +export const audioFormatOptions = ["best", "mp3", "ogg", "wav", "opus"] as const; +export const downloadModeOptions = ["auto", "audio", "mute"] as const; +export const filenameStyleOptions = ["classic", "basic", "pretty", "nerdy"] as const; +export const videoQualityOptions = ["max", "2160", "1440", "1080", "720", "480", "360", "240", "144"] as const; +export const youtubeVideoCodecOptions = ["h264", "av1", "vp9"] as const; +export const savingMethodOptions = ["ask", "download", "share", "copy"] as const; + +type CobaltSettingsAppearance = { + theme: typeof themeOptions[number], + language: keyof typeof languages, + autoLanguage: boolean, + reduceMotion: boolean, + reduceTransparency: boolean, +}; + +type CobaltSettingsAdvanced = { + debug: boolean, +}; + +type CobaltSettingsPrivacy = { + alwaysProxy: boolean, + disableAnalytics: boolean, +}; + +type CobaltSettingsProcessing = { + allowDefaultOverride: boolean, + customInstanceURL: string, + enableCustomInstances: boolean, + seenCustomWarning: boolean, + seenOverrideWarning: boolean, +} + +type CobaltSettingsSaveV2 = { + audioFormat: typeof audioFormatOptions[number], + audioBitrate: typeof audioBitrateOptions[number], + disableMetadata: boolean, + downloadMode: typeof downloadModeOptions[number], + filenameStyle: typeof filenameStyleOptions[number], + savingMethod: typeof savingMethodOptions[number], + tiktokH265: boolean, + tiktokFullAudio: boolean, + twitterGif: boolean, + videoQuality: typeof videoQualityOptions[number], + youtubeVideoCodec: typeof youtubeVideoCodecOptions[number], + youtubeDubBrowserLang: boolean, + youtubeHLS: boolean, +}; + +export type CobaltSettingsV2 = { + schemaVersion: 2, + advanced: CobaltSettingsAdvanced, + appearance: CobaltSettingsAppearance, + save: CobaltSettingsSaveV2, + privacy: CobaltSettingsPrivacy, + processing: CobaltSettingsProcessing, +};