Settings 2.0 (#107)

Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
megumin 2022-10-17 20:18:25 +01:00 committed by GitHub
parent ae730e8398
commit 5625d63e46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 945 additions and 192 deletions

View file

@ -1,9 +1,11 @@
import { waitFor, filters, _resolveReady } from "./webpack";
import { User } from "discord-types/general";
import { lazyWebpack } from "../utils/misc";
import { _resolveReady, filters, waitFor } from "./webpack";
import type Components from "discord-types/components";
import type Stores from "discord-types/stores";
import type Other from "discord-types/other";
import { lazyWebpack } from "../utils/misc";
export const Margins = lazyWebpack(filters.byProps(["marginTop20"]));
export let FluxDispatcher: Other.FluxDispatcher;
@ -25,6 +27,10 @@ export let Button: any;
export let Switch: any;
export let Tooltip: Components.Tooltip;
export let Router: any;
export let TextInput: any;
export let Text: (props: TextProps) => JSX.Element;
export const Select = lazyWebpack(filters.byCode("optionClassName", "popoutPosition", "autoFocus", "maxVisibleItems"));
export let Parser: any;
export let Alerts: {
@ -82,6 +88,10 @@ export const Toasts = {
}
};
export const UserUtils = {
fetchUser: lazyWebpack(filters.byCode(".USER(", "getUser")) as (id: string) => Promise<User>,
};
waitFor("useState", m => React = m);
waitFor(["dispatch", "subscribe"], m => {
FluxDispatcher = m;
@ -120,3 +130,23 @@ waitFor(["show", "close"], m => Alerts = m);
waitFor("parseTopic", m => Parser = m);
waitFor(["open", "saveAccountChanges"], m => Router = m);
waitFor(["defaultProps", "Sizes", "contextType"], m => TextInput = m);
waitFor(m => {
if (typeof m !== "function") return false;
const s = m.toString();
return (s.length < 1500 && s.includes("data-text-variant") && s.includes("always-white"));
}, m => Text = m);
export type TextProps = React.PropsWithChildren & {
variant: TextVariant;
style?: React.CSSProperties;
color?: string;
tag?: "div" | "span" | "p" | "strong";
selectable?: boolean;
lineClamp?: number;
id?: string;
className?: string;
};
export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "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-md" | "display-lg" | "code";

View file

@ -100,6 +100,7 @@ function patchPush() {
for (let i = 0; i < patches.length; i++) {
const patch = patches[i];
if (patch.predicate && !patch.predicate()) continue;
if (code.includes(patch.find)) {
patchedBy.add(patch.plugin);
// @ts-ignore we change all patch.replacement to array in plugins/index