Merge branch 'dev' into immediate-finds

This commit is contained in:
Nuckyz 2024-09-18 14:16:35 -03:00
commit 4722851172
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
16 changed files with 48 additions and 24 deletions

View file

@ -292,10 +292,10 @@ export default function PluginSettings() {
if (!pluginFilter(p)) continue; if (!pluginFilter(p)) continue;
const isRequired = p.required || depMap[p.name]?.some(d => settings.plugins[d].enabled); const isRequired = p.required || p.isDependency || depMap[p.name]?.some(d => settings.plugins[d].enabled);
if (isRequired) { if (isRequired) {
const tooltipText = p.required const tooltipText = p.required || !depMap[p.name]
? "This plugin is required for Vencord to function." ? "This plugin is required for Vencord to function."
: makeDependencyList(depMap[p.name]?.filter(d => settings.plugins[d].enabled)); : makeDependencyList(depMap[p.name]?.filter(d => settings.plugins[d].enabled));

View file

@ -142,7 +142,7 @@ export default definePlugin({
required: true, required: true,
description: "Helps us provide support to you", description: "Helps us provide support to you",
authors: [Devs.Ven], authors: [Devs.Ven],
dependencies: ["CommandsAPI", "UserSettingsAPI", "MessageAccessoriesAPI"], dependencies: ["UserSettingsAPI", "MessageAccessoriesAPI"],
settings, settings,

View file

@ -27,7 +27,6 @@ export default definePlugin({
name: "FriendInvites", name: "FriendInvites",
description: "Create and manage friend invite links via slash commands (/create friend invite, /view friend invites, /revoke friend invites).", description: "Create and manage friend invite links via slash commands (/create friend invite, /view friend invites, /revoke friend invites).",
authors: [Devs.afn, Devs.Dziurwa], authors: [Devs.afn, Devs.Dziurwa],
dependencies: ["CommandsAPI"],
commands: [ commands: [
{ {
name: "create friend invite", name: "create friend invite",

View file

@ -107,6 +107,11 @@ for (const p of pluginsValues) if (isPluginEnabled(p.name)) {
settings[d].enabled = true; settings[d].enabled = true;
dep.isDependency = true; dep.isDependency = true;
}); });
if (p.commands?.length) {
Plugins.CommandsAPI.isDependency = true;
settings.CommandsAPI.enabled = true;
}
} }
for (const p of pluginsValues) { for (const p of pluginsValues) {

View file

@ -84,8 +84,6 @@ export default definePlugin({
authors: [Devs.Luna], authors: [Devs.Luna],
settings, settings,
dependencies: ["CommandsAPI"],
async start() { async start() {
for (const tag of await getTags()) createTagCommand(tag); for (const tag of await getTags()) createTagCommand(tag);
}, },

View file

@ -33,7 +33,6 @@ export default definePlugin({
name: "MoreCommands", name: "MoreCommands",
description: "echo, lenny, mock", description: "echo, lenny, mock",
authors: [Devs.Arjix, Devs.echo, Devs.Samu], authors: [Devs.Arjix, Devs.echo, Devs.Samu],
dependencies: ["CommandsAPI"],
commands: [ commands: [
{ {
name: "echo", name: "echo",

View file

@ -24,7 +24,6 @@ export default definePlugin({
name: "MoreKaomoji", name: "MoreKaomoji",
description: "Adds more Kaomoji to discord. ヽ(´▽`)/", description: "Adds more Kaomoji to discord. ヽ(´▽`)/",
authors: [Devs.JacobTm], authors: [Devs.JacobTm],
dependencies: ["CommandsAPI"],
commands: [ commands: [
{ name: "dissatisfaction", description: " " }, { name: "dissatisfaction", description: " " },
{ name: "smug", description: "ಠ_ಠ" }, { name: "smug", description: "ಠ_ಠ" },

View file

@ -88,7 +88,6 @@ export default definePlugin({
name: "petpet", name: "petpet",
description: "Adds a /petpet slash command to create headpet gifs from any image", description: "Adds a /petpet slash command to create headpet gifs from any image",
authors: [Devs.Ven], authors: [Devs.Ven],
dependencies: ["CommandsAPI"],
commands: [ commands: [
{ {
inputType: ApplicationCommandInputType.BUILT_IN, inputType: ApplicationCommandInputType.BUILT_IN,

View file

@ -88,7 +88,7 @@ export default definePlugin({
name: "SilentTyping", name: "SilentTyping",
authors: [Devs.Ven, Devs.Rini, Devs.ImBanana], authors: [Devs.Ven, Devs.Rini, Devs.ImBanana],
description: "Hide that you are typing", description: "Hide that you are typing",
dependencies: ["CommandsAPI", "ChatInputButtonAPI"], dependencies: ["ChatInputButtonAPI"],
settings, settings,
contextMenus: { contextMenus: {
"textarea-context": ChatBarContextCheckbox "textarea-context": ChatBarContextCheckbox

View file

@ -76,7 +76,6 @@ export default definePlugin({
name: "SpotifyShareCommands", name: "SpotifyShareCommands",
description: "Share your current Spotify track, album or artist via slash command (/track, /album, /artist)", description: "Share your current Spotify track, album or artist via slash command (/track, /album, /artist)",
authors: [Devs.katlyn], authors: [Devs.katlyn],
dependencies: ["CommandsAPI"],
commands: [ commands: [
{ {
name: "track", name: "track",

View file

@ -19,7 +19,7 @@ export type LazyComponentType<P extends AnyRecord> = React.FunctionComponent<P>
* @param attempts How many times to try to get the component before giving up * @param attempts How many times to try to get the component before giving up
* @returns Result of factory function * @returns Result of factory function
*/ */
export function LazyComponent<P extends AnyRecord>(factory: () => AnyComponentType<P>, attempts = 5, err: string | (() => string) = `LazyComponent factory failed:\n${factory}`): LazyComponentType<P> { export function LazyComponent<P extends AnyRecord>(factory: () => React.ComponentType<P>, attempts = 5, err: string | (() => string) = `LazyComponent factory failed:\n${factory}`): LazyComponentType<P> {
const get = makeLazy(factory, attempts, { isIndirect: true }); const get = makeLazy(factory, attempts, { isIndirect: true });
let InnerComponent = null as AnyComponentType<P> | null; let InnerComponent = null as AnyComponentType<P> | null;

View file

@ -72,13 +72,13 @@ export interface PluginDef {
stop?(): void; stop?(): void;
patches?: Omit<Patch, "plugin">[]; patches?: Omit<Patch, "plugin">[];
/** /**
* List of commands. If you specify these, you must add CommandsAPI to dependencies * List of commands that your plugin wants to register
*/ */
commands?: Command[]; commands?: Command[];
/** /**
* A list of other plugins that your plugin depends on. * A list of other plugins that your plugin depends on.
* These will automatically be enabled and loaded before your plugin * These will automatically be enabled and loaded before your plugin
* Common examples are CommandsAPI, MessageEventsAPI... * Generally these will be API plugins
*/ */
dependencies?: string[], dependencies?: string[],
/** /**

View file

@ -171,7 +171,7 @@ function printFilter(filter: FilterFn) {
return String(filter); return String(filter);
} }
function wrapWebpackComponent<P extends AnyRecord>(err: string | (() => string)): [WrapperComponent: LazyComponentType<P>, setInnerComponent: (rawComponent: any, parsedComponent: AnyComponentType<P>) => void] { function wrapWebpackComponent<P extends AnyRecord>(err: string | (() => string)): [WrapperComponent: LazyComponentType<P>, setInnerComponent: (rawComponent: any, parsedComponent: React.ComponentType<P>) => void] {
let InnerComponent = null as AnyComponentType<P> | null; let InnerComponent = null as AnyComponentType<P> | null;
let findFailedLogged = false; let findFailedLogged = false;
@ -186,7 +186,7 @@ function wrapWebpackComponent<P extends AnyRecord>(err: string | (() => string))
WrapperComponent[SYM_LAZY_COMPONENT_INNER] = () => InnerComponent; WrapperComponent[SYM_LAZY_COMPONENT_INNER] = () => InnerComponent;
function setInnerComponent(RawComponent: any, ParsedComponent: AnyComponentType<P>) { function setInnerComponent(RawComponent: any, ParsedComponent: React.ComponentType<P>) {
InnerComponent = ParsedComponent; InnerComponent = ParsedComponent;
Object.assign(WrapperComponent, RawComponent); Object.assign(WrapperComponent, RawComponent);
} }
@ -281,7 +281,7 @@ export function find<T = any>(filter: FilterFn, parse: (module: ModuleExports) =
* @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component * @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component
* @returns The component if found, or a noop component * @returns The component if found, or a noop component
*/ */
export function findComponent<P extends AnyRecord>(filter: FilterFn, parse: (component: ModuleExports) => AnyComponentType<P> = m => m, { isIndirect = false }: { isIndirect?: boolean; } = {}) { export function findComponent<P extends AnyRecord>(filter: FilterFn, parse: (component: ModuleExports) => React.ComponentType<P> = m => m, { isIndirect = false }: { isIndirect?: boolean; } = {}) {
if (typeof filter !== "function") { if (typeof filter !== "function") {
throw new Error("Invalid filter. Expected a function got " + typeof filter); throw new Error("Invalid filter. Expected a function got " + typeof filter);
} }
@ -311,8 +311,8 @@ export function findComponent<P extends AnyRecord>(filter: FilterFn, parse: (com
* @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component * @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component
* @returns The component if found, or a noop component * @returns The component if found, or a noop component
*/ */
export function findExportedComponent<P extends AnyRecord>(...props: PropsFilter | [...PropsFilter, (component: ModuleExports) => AnyComponentType<P>]) { export function findExportedComponent<P extends AnyRecord>(...props: PropsFilter | [...PropsFilter, (component: ModuleExports) => React.ComponentType<P>]) {
const parse = (typeof props.at(-1) === "function" ? props.pop() : m => m) as (component: ModuleExports) => AnyComponentType<P>; const parse = (typeof props.at(-1) === "function" ? props.pop() : m => m) as (component: ModuleExports) => React.ComponentType<P>;
const newProps = props as PropsFilter; const newProps = props as PropsFilter;
const filter = filters.byProps(...newProps); const filter = filters.byProps(...newProps);
@ -339,8 +339,8 @@ export function findExportedComponent<P extends AnyRecord>(...props: PropsFilter
* @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component * @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component
* @returns The component if found, or a noop component * @returns The component if found, or a noop component
*/ */
export function findComponentByCode<P extends AnyRecord>(...code: CodeFilter | [...CodeFilter, (component: ModuleExports) => AnyComponentType<P>]) { export function findComponentByCode<P extends AnyRecord>(...code: CodeFilter | [...CodeFilter, (component: ModuleExports) => React.ComponentType<P>]) {
const parse = (typeof code.at(-1) === "function" ? code.pop() : m => m) as (component: ModuleExports) => AnyComponentType<P>; const parse = (typeof code.at(-1) === "function" ? code.pop() : m => m) as (component: ModuleExports) => React.ComponentType<P>;
const newCode = code as CodeFilter; const newCode = code as CodeFilter;
const ComponentResult = findComponent<P>(filters.componentByCode(...newCode), parse, { isIndirect: true }); const ComponentResult = findComponent<P>(filters.componentByCode(...newCode), parse, { isIndirect: true });
@ -362,8 +362,8 @@ export function findComponentByCode<P extends AnyRecord>(...code: CodeFilter | [
* @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component * @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component
* @returns The component if found, or a noop component * @returns The component if found, or a noop component
*/ */
export function findComponentByFields<P extends AnyRecord>(...fields: PropsFilter | [...PropsFilter, (component: ModuleExports) => AnyComponentType<P>]) { export function findComponentByFields<P extends AnyRecord>(...fields: PropsFilter | [...PropsFilter, (component: ModuleExports) => React.ComponentType<P>]) {
const parse = (typeof fields.at(-1) === "function" ? fields.pop() : m => m) as (component: ModuleExports) => AnyComponentType<P>; const parse = (typeof fields.at(-1) === "function" ? fields.pop() : m => m) as (component: ModuleExports) => React.ComponentType<P>;
const newFields = fields as PropsFilter; const newFields = fields as PropsFilter;
const ComponentResult = findComponent<P>(filters.componentByFields(...newFields), parse, { isIndirect: true }); const ComponentResult = findComponent<P>(filters.componentByFields(...newFields), parse, { isIndirect: true });

View file

@ -44,6 +44,8 @@ export let Avatar: t.Avatar = NoopComponent;
export let FocusLock: t.FocusLock = NoopComponent; export let FocusLock: t.FocusLock = NoopComponent;
export let useToken: t.useToken; export let useToken: t.useToken;
export let Icons = {} as t.Icons;
export const MaskedLink = findComponentByCode<t.MaskedLinkProps>("MASKED_LINK)"); export const MaskedLink = findComponentByCode<t.MaskedLinkProps>("MASKED_LINK)");
export const Timestamp = findComponentByCode<t.TimestampProps>(".Messages.MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format"); export const Timestamp = findComponentByCode<t.TimestampProps>(".Messages.MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format");
export const Flex = findComponent(filters.byProps("Justify", "Align", "Wrap")) as t.Flex; export const Flex = findComponent(filters.byProps("Justify", "Align", "Wrap")) as t.Flex;
@ -76,5 +78,6 @@ export const Forms = findByProps<t.Forms>("FormItem", "Button", m => {
Heading Heading
} = m); } = m);
Icons = m;
return m; return m;
}); });

View file

@ -18,6 +18,8 @@
import type { ComponentType, CSSProperties, FunctionComponent, HtmlHTMLAttributes, HTMLProps, KeyboardEvent, MouseEvent, PropsWithChildren, PropsWithRef, ReactNode, Ref } from "react"; import type { ComponentType, CSSProperties, FunctionComponent, HtmlHTMLAttributes, HTMLProps, KeyboardEvent, MouseEvent, PropsWithChildren, PropsWithRef, ReactNode, Ref } from "react";
import { IconNames } from "./iconNames";
export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/semibold" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/semibold" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/semibold" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-sm" | "display-md" | "display-lg" | "code"; export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/semibold" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/semibold" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/semibold" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-sm" | "display-md" | "display-lg" | "code";
export type FormTextTypes = Record<"DEFAULT" | "INPUT_PLACEHOLDER" | "DESCRIPTION" | "LABEL_BOLD" | "LABEL_SELECTED" | "LABEL_DESCRIPTOR" | "ERROR" | "SUCCESS", string>; export type FormTextTypes = Record<"DEFAULT" | "INPUT_PLACEHOLDER" | "DESCRIPTION" | "LABEL_BOLD" | "LABEL_SELECTED" | "LABEL_DESCRIPTOR" | "ERROR" | "SUCCESS", string>;
export type HeadingTag = `h${1 | 2 | 3 | 4 | 5 | 6}`; export type HeadingTag = `h${1 | 2 | 3 | 4 | 5 | 6}`;
@ -76,7 +78,7 @@ export type Forms = {
}; };
export type Tooltip = ComponentType<{ export type Tooltip = ComponentType<{
text: ReactNode; text: ReactNode | ComponentType;
children: FunctionComponent<{ children: FunctionComponent<{
onClick(): void; onClick(): void;
onMouseEnter(): void; onMouseEnter(): void;
@ -516,3 +518,10 @@ export type Avatar = ComponentType<PropsWithChildren<{
type FocusLock = ComponentType<PropsWithChildren<{ type FocusLock = ComponentType<PropsWithChildren<{
containerRef: RefObject<HTMLElement>; containerRef: RefObject<HTMLElement>;
}>>; }>>;
export type Icon = AnyComponentType<React.ComponentPropsWithoutRef<"svg"> & {
size?: string;
colorClass?: string;
}>;
export type Icons = Record<IconNames, Icon>;

14
src/webpack/common/types/iconNames.d.ts vendored Normal file

File diff suppressed because one or more lines are too long