ConsoleShortcuts: fix module preloader

This commit is contained in:
Vendicated 2025-04-14 14:43:13 +02:00
parent fe0309ffaa
commit a8c01a2a05
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -20,6 +20,7 @@ import { Devs } from "@utils/constants";
import { getCurrentChannel, getCurrentGuild } from "@utils/discord";
import { runtimeHashMessageKey } from "@utils/intlHash";
import { SYM_LAZY_CACHED, SYM_LAZY_GET } from "@utils/lazy";
import { sleep } from "@utils/misc";
import { ModalAPI } from "@utils/modal";
import { relaunch } from "@utils/native";
import { canonicalizeMatch, canonicalizeReplace, canonicalizeReplacement } from "@utils/patches";
@ -206,10 +207,13 @@ function loadAndCacheShortcut(key: string, val: any, forceLoad: boolean) {
return value;
}
const webpackModulesProbablyLoaded = Webpack.onceReady.then(() => sleep(1000));
export default definePlugin({
name: "ConsoleShortcuts",
description: "Adds shorter Aliases for many things on the window. Run `shortcutList` for a list.",
authors: [Devs.Ven],
startAt: StartAt.Init,
patches: [
{
@ -221,7 +225,7 @@ export default definePlugin({
}
],
startAt: StartAt.Init,
start() {
const shortcuts = makeShortcuts();
window.shortcutList = {};
@ -242,18 +246,16 @@ export default definePlugin({
}
// unproxy loaded modules
Webpack.onceReady.then(() => {
setTimeout(() => this.eagerLoad(false), 1000);
this.eagerLoad(false);
if (!IS_WEB) {
const Native = VencordNative.pluginHelpers.ConsoleShortcuts as PluginNative<typeof import("./native")>;
Native.initDevtoolsOpenEagerLoad();
}
});
},
async eagerLoad(forceLoad: boolean) {
await Webpack.onceReady;
await webpackModulesProbablyLoaded;
const shortcuts = makeShortcuts();