diff --git a/src/components/VencordSettings/ThemesTab.tsx b/src/components/VencordSettings/ThemesTab.tsx index 7b45f33f3..95dcc60f0 100644 --- a/src/components/VencordSettings/ThemesTab.tsx +++ b/src/components/VencordSettings/ThemesTab.tsx @@ -114,7 +114,7 @@ interface UserCSSCardProps { function UserCSSThemeCard({ theme, enabled, onChange, onDelete }: UserCSSCardProps) { return ( 0 ? "uso" : "default"); + const { vars = {}, preprocessor = Object.keys(vars).length > 0 ? "uso" : "default" } = usercssParse(themeData, fileName); - const preprocessorFn = preprocessors[usedPreprocessor]; + const preprocessorFn = preprocessors[preprocessor]; if (!preprocessorFn) { - UserCSSLogger.error("File", fileName, "requires preprocessor", usedPreprocessor, "which isn't known to Vencord"); + UserCSSLogger.error("File", fileName, "requires preprocessor", preprocessor, "which isn't known to Vencord"); return null; } @@ -82,7 +80,7 @@ export async function compileUsercss(fileName: string) { try { return await preprocessorFn(themeData, varsToPass); } catch (error) { - UserCSSLogger.error("File", fileName, "failed to compile with preprocessor", usedPreprocessor, error); + UserCSSLogger.error("File", fileName, "failed to compile with preprocessor", preprocessor, error); return null; } } diff --git a/src/utils/themes/usercss/index.ts b/src/utils/themes/usercss/index.ts index a5151e75c..d5d2f3896 100644 --- a/src/utils/themes/usercss/index.ts +++ b/src/utils/themes/usercss/index.ts @@ -10,7 +10,7 @@ import { parse as originalParse, UserstyleHeader } from "usercss-meta"; const UserCSSLogger = new Logger("UserCSS", "#d2acf5"); export function parse(text: string, fileName: string): UserstyleHeader { - const { metadata, errors } = originalParse(text.replace(/\r/g, "")); + var { metadata, errors } = originalParse(text.replace(/\r/g, ""), { allowErrors: true }); if (errors.length) { UserCSSLogger.warn("Parsed", fileName, "with errors:", errors); diff --git a/src/utils/themes/usercss/usercss-meta.d.ts b/src/utils/themes/usercss/usercss-meta.d.ts index 7248cbbb9..d51304591 100644 --- a/src/utils/themes/usercss/usercss-meta.d.ts +++ b/src/utils/themes/usercss/usercss-meta.d.ts @@ -102,5 +102,5 @@ declare module "usercss-meta" { vars: Record; } - export function parse(text: string): { metadata: UserstyleHeader; errors: { code: string; args: any; }[] }; + export function parse(text: string, options: { allowErrors: boolean; }): { metadata: UserstyleHeader; errors: { code: string; args: any; }[]; }; }