web/settings: split settings into versions

This commit is contained in:
jj 2024-10-30 11:40:53 +00:00
parent edb340dc66
commit 7a50c89728
No known key found for this signature in database
2 changed files with 63 additions and 59 deletions

View file

@ -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;

View file

@ -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,
};