+ {missingPlugins && missingPlugins.length > 0 && (
+
+ {({ onMouseLeave, onMouseEnter }) => (
+
+ )}
+
+ )}
{theme.vars && (
openModal(modalProps =>
diff --git a/src/utils/themes/usercss/index.ts b/src/utils/themes/usercss/index.ts
index a7d49a60..e4dbe234 100644
--- a/src/utils/themes/usercss/index.ts
+++ b/src/utils/themes/usercss/index.ts
@@ -10,16 +10,22 @@ import { parse as originalParse, UserstyleHeader } from "usercss-meta";
const UserCSSLogger = new Logger("UserCSS", "#d2acf5");
export async function usercssParse(text: string, fileName: string): Promise {
- var { metadata, errors } = originalParse(text.replace(/\r/g, ""), { allowErrors: true });
+ const { metadata, errors } = originalParse(text.replace(/\r/g, ""), {
+ allowErrors: true,
+ unknownKey: "assign"
+ });
if (errors.length) {
UserCSSLogger.warn("Parsed", fileName, "with errors:", errors);
}
+ const requiredPlugins = metadata["vc-requiredPlugins"]?.split(",").map(p => p.trim());
+
return {
...metadata,
fileName,
- id: await getUserCssId(metadata)
+ id: await getUserCssId(metadata),
+ requiredPlugins
};
}
diff --git a/src/utils/themes/usercss/usercss-meta.d.ts b/src/utils/themes/usercss/usercss-meta.d.ts
index 1a39bf6d..f4d29e63 100644
--- a/src/utils/themes/usercss/usercss-meta.d.ts
+++ b/src/utils/themes/usercss/usercss-meta.d.ts
@@ -55,6 +55,14 @@ declare module "usercss-meta" {
*/
fileName: string;
+ /**
+ * The required plugins for this style.
+ *
+ * @vencord Specific to Vencord, not part of the original module.
+ * @see {@link vc-requiredPlugins}
+ */
+ requiredPlugins?: string[];
+
/**
* The name of your style.
*
@@ -107,7 +115,20 @@ declare module "usercss-meta" {
* A list of variables the style defines.
*/
vars: Record;
+
+ /**
+ * Required plugins for this style to work. Comma-separated list of plugin names.
+ *
+ * @vencord This is a Vencord-specific extension, however we wish for this to become a standard for client mods
+ * to implement, hence the more generic namespaced name.
+ */
+ "vc-requiredPlugins"?: string;
}
- export function parse(text: string, options: { allowErrors: boolean; }): { metadata: UserstyleHeader; errors: { code: string; args: any; }[]; };
+ type UserCSSParseOptions = {
+ allowErrors: boolean;
+ unknownKey: "assign";
+ };
+
+ export function parse(text: string, options: UserCSSParseOptions): { metadata: UserstyleHeader; errors: { code: string; args: any; }[]; };
}