fix plugins with lazy loaded finds (#4146)

Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
This commit is contained in:
sadan4 2026-04-24 13:52:53 -04:00 • committed by GitHub
parent 3f0cedc501
commit f571784231
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 31 additions and 28 deletions

View file

@ -204,13 +204,6 @@ export async function loadLazyChunks() {
}
})));
// Manually require all modules to make sure all lazily required modules are patched
for (const moduleId of Object.keys(wreq.m)) {
try {
wreq(moduleId);
} catch { }
}
LazyChunkLoaderLogger.log("Finished loading all chunks!");
} catch (e) {
LazyChunkLoaderLogger.log("A fatal error occurred:", e);

View file

@ -21,13 +21,19 @@ import { Auth } from "@plugins/reviewDB/auth";
import { ReviewType } from "@plugins/reviewDB/entities";
import { REVIEWS_PER_PAGE, UserReviewsData } from "@plugins/reviewDB/reviewDbApi";
import { cl } from "@plugins/reviewDB/utils";
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModalLazy } from "@utils/modal";
import { useForceUpdater } from "@utils/react";
import { Paginator, Text, useRef, useState } from "@webpack/common";
import * as t from "@vencord/discord-types";
import { DefaultExtractAndLoadChunksRegex, extractAndLoadChunksLazy, findComponentByCodeLazy } from "@webpack";
import { Text, useRef, useState } from "@webpack/common";
import { ComponentProps } from "react";
import ReviewComponent from "./ReviewComponent";
import ReviewsView, { ReviewsInputComponent } from "./ReviewsView";
const Paginator = findComponentByCodeLazy<ComponentProps<t.Paginator>>('rel:"prev",children:');
const requirePaginator = extractAndLoadChunksLazy(['name:"SearchResults"'], new RegExp(`${DefaultExtractAndLoadChunksRegex.source}.{0,30}?name:"SearchResults"`));
function Modal({ modalProps, modalKey, discordId, name, type }: { modalProps: any; modalKey: string, discordId: string; name: string; type: ReviewType; }) {
const [data, setData] = useState<UserReviewsData>();
const [signal, refetch] = useForceUpdater(true);
@ -100,13 +106,15 @@ function Modal({ modalProps, modalKey, discordId, name, type }: { modalProps: an
export function openReviewsModal(discordId: string, name: string, type: ReviewType) {
const modalKey = "vc-rdb-modal-" + Date.now();
openModal(props => (
<Modal
modalKey={modalKey}
modalProps={props}
discordId={discordId}
name={name}
type={type}
/>
), { modalKey });
openModalLazy(async () => {
await requirePaginator();
return props => (
<Modal
modalKey={modalKey}
modalProps={props}
discordId={discordId}
name={name}
type={type} />
);
}, { modalKey });
}

View file

@ -16,9 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { cl } from "@plugins/shikiCodeblocks.desktop/utils/misc";
import { cl, hljs } from "@plugins/shikiCodeblocks.desktop/utils/misc";
import type { IThemedToken } from "@vap/shiki";
import { hljs } from "@webpack/common";
import { JSX } from "react";
import { ThemeBase } from "./Highlighter";

View file

@ -22,9 +22,9 @@ import { shiki } from "@plugins/shikiCodeblocks.desktop/api/shiki";
import { useShikiSettings } from "@plugins/shikiCodeblocks.desktop/hooks/useShikiSettings";
import { useTheme } from "@plugins/shikiCodeblocks.desktop/hooks/useTheme";
import { hex2Rgb } from "@plugins/shikiCodeblocks.desktop/utils/color";
import { cl, shouldUseHljs } from "@plugins/shikiCodeblocks.desktop/utils/misc";
import { cl, hljs, shouldUseHljs } from "@plugins/shikiCodeblocks.desktop/utils/misc";
import { useAwaiter, useIntersection } from "@utils/react";
import { hljs, React } from "@webpack/common";
import { React } from "@webpack/common";
import { ButtonRow } from "./ButtonRow";
import { Code } from "./Code";

View file

@ -29,6 +29,7 @@ import deviconStyle from "./devicon.css?managed";
import { settings } from "./settings";
import { DeviconSetting } from "./types";
import { clearStyles } from "./utils/createStyle";
import { requireHljs } from "./utils/misc";
export default definePlugin({
name: "ShikiCodeblocks",
@ -74,6 +75,7 @@ export default definePlugin({
shiki,
createHighlighter,
renderHighlighter: ({ lang, content }: { lang: string; content: string; }) => {
requireHljs();
return createHighlighter({
lang: lang?.toLowerCase(),
content,

View file

@ -20,10 +20,13 @@ import { resolveLang } from "@plugins/shikiCodeblocks.desktop/api/languages";
import { HighlighterProps } from "@plugins/shikiCodeblocks.desktop/components/Highlighter";
import { HljsSetting } from "@plugins/shikiCodeblocks.desktop/types";
import { classNameFactory } from "@utils/css";
import { hljs } from "@webpack/common";
import { DefaultExtractAndLoadChunksRegex, extractAndLoadChunksLazy, findByPropsLazy } from "@webpack";
export const cl = classNameFactory("vc-shiki-");
export const hljs: typeof import("highlight.js").default = findByPropsLazy("highlight", "registerLanguage");
export const requireHljs = extractAndLoadChunksLazy(["codeBlock:{react("], new RegExp(`"hljs".+?${DefaultExtractAndLoadChunksRegex.source}`));
export const shouldUseHljs = ({
lang,
tryHljs,

View file

@ -56,15 +56,15 @@ export const Tooltip = waitForComponent<t.Tooltip>("Tooltip", m => m.prototype?.
/** @deprecated import from @vencord/components */
export const TooltipContainer = TooltipContainerComponent as never;
export const TextInput = waitForComponent<t.TextInput>("TextInput", filters.componentByCode("#{intl::MAXIMUM_LENGTH_ERROR}", '"input"'));
export const TextArea = waitForComponent<t.TextArea>("TextArea", filters.componentByCode('"data-mana-component":"text-area"'));
// FIXME: t.TextInput was for the old void components, and is not 100% correct for the mana component
export const TextInput = waitForComponent<t.TextInput>("TextInput", filters.componentByCode('setHasValue?.(""!==', '="text",'));
export const TextArea = waitForComponent<t.TextArea>("TextArea", filters.componentByCode("!0,rows:", "showRemainingCharacterCount:"));
export const Select = waitForComponent<t.Select>("Select", filters.componentByCode('selectionMode:"single",onSelectionChange:', "isSelected:"));
export const SearchableSelect = waitForComponent<t.SearchableSelect>("SearchableSelect", filters.componentByCode('?"multiple":"single",required:'));
export const Slider = waitForComponent<t.Slider>("Slider", filters.componentByCode("markDash", "this.renderMark("));
export const Popout = waitForComponent<t.Popout>("Popout", filters.componentByCode("ref:this.ref,", "renderPopout:this.renderPopout,"));
export const Dialog = waitForComponent<t.Dialog>("Dialog", filters.componentByCode('role:"dialog",tabIndex:-1'));
export const TabBar = waitForComponent("TabBar", filters.componentByCode("ref:this.tabBarRef,className:"));
export const Paginator = waitForComponent<t.Paginator>("Paginator", filters.componentByCode('rel:"prev",children:'));
// TODO: remake this component
export const Clickable = waitForComponent<t.Clickable>("Clickable", filters.componentByCode("this.context?this.renderNonInteractive():"));
export const Avatar = waitForComponent<t.Avatar>("Avatar", filters.componentByCode(".size-1.375*"));

View file

@ -46,8 +46,6 @@ export const Constants: t.Constants = mapMangledModuleLazy('ME:"/users/@me"', {
export const RestAPI: t.RestAPI = findLazy(m => typeof m === "object" && m.del && m.put);
export const moment: typeof import("moment") = findByPropsLazy("parseTwoDigitYear");
export const hljs: typeof import("highlight.js").default = findByPropsLazy("highlight", "registerLanguage");
export const { match, P }: { match: typeof TSPattern["match"], P: typeof TSPattern["P"]; } = mapMangledModuleLazy("@ts-pattern/matcher", {
match: filters.byCode("return new"),
P: filters.byProps("when")