fix showConnections & better webpack errors

This commit is contained in:
V 2023-11-23 02:20:02 +01:00
parent 93a95b6d56
commit a2560ede1c
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905
2 changed files with 9 additions and 4 deletions

View file

@ -31,7 +31,7 @@ import { User } from "discord-types/general";
import { VerifiedIcon } from "./VerifiedIcon"; import { VerifiedIcon } from "./VerifiedIcon";
const Section = findComponentByCodeLazy(".lastSection]: "); const Section = findComponentByCodeLazy(".lastSection", "children:");
const ThemeStore = findStoreLazy("ThemeStore"); const ThemeStore = findStoreLazy("ThemeStore");
const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl"); const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl");
const getTheme: (user: User, displayProfile: any) => any = findByCodeLazy(',"--profile-gradient-primary-color"'); const getTheme: (user: User, displayProfile: any) => any = findByCodeLazy(',"--profile-gradient-primary-color"');

View file

@ -18,7 +18,7 @@
import { proxyLazy } from "@utils/lazy"; import { proxyLazy } from "@utils/lazy";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { LazyComponent, NoopComponent } from "@utils/react"; import { LazyComponent } from "@utils/react";
import type { WebpackInstance } from "discord-types/other"; import type { WebpackInstance } from "discord-types/other";
import { traceFunction } from "../debug/Tracer"; import { traceFunction } from "../debug/Tracer";
@ -398,13 +398,18 @@ export function findStoreLazy(name: string) {
*/ */
export function findComponentByCode(...code: string[]) { export function findComponentByCode(...code: string[]) {
const filter = filters.byCode(...code); const filter = filters.byCode(...code);
return find(m => { const res = find(m => {
if (filter(m)) return true; if (filter(m)) return true;
if (!m.$$typeof) return false; if (!m.$$typeof) return false;
if (m.type) return filter(m.type); // memos if (m.type) return filter(m.type); // memos
if (m.render) return filter(m.render); // forwardRefs if (m.render) return filter(m.render); // forwardRefs
return false; return false;
}) ?? NoopComponent; }, { isIndirect: true });
if (!res)
handleModuleNotFound("findComponentByCode", ...code);
return res;
} }
/** /**