aboutsummaryrefslogtreecommitdiff
path: root/src/webpack/webpack.ts
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-10-01 00:42:50 +0200
committerVendicated <vendicated@riseup.net>2022-10-01 00:42:50 +0200
commit8161a07dba401f04dac93f861e6b2cffe53ab7e3 (patch)
tree1499e825bcd6a162bc43507f492b262e9b1901ed /src/webpack/webpack.ts
parent9aaa47ea4e9ac068bf5fcbb997e31d722f43f1e5 (diff)
downloadVencord-8161a07dba401f04dac93f861e6b2cffe53ab7e3.tar.gz
Vencord-8161a07dba401f04dac93f861e6b2cffe53ab7e3.tar.bz2
Vencord-8161a07dba401f04dac93f861e6b2cffe53ab7e3.zip
Add in client updater, Notices API
Diffstat (limited to 'src/webpack/webpack.ts')
-rw-r--r--src/webpack/webpack.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts
index 9e550a4..ea5a7e3 100644
--- a/src/webpack/webpack.ts
+++ b/src/webpack/webpack.ts
@@ -1,5 +1,12 @@
import type { WebpackInstance } from "discord-types/other";
+export let _resolveReady: () => void;
+/**
+ * Fired once a gateway connection to Discord has been established.
+ * This indicates that the core webpack modules have been initialised
+ */
+export const onceReady = new Promise<void>(r => _resolveReady = r);
+
export let wreq: WebpackInstance;
export let cache: WebpackInstance["c"];
@@ -68,8 +75,19 @@ export function findAll(filter: FilterFn, getDefault = true) {
const ret = [] as any[];
for (const key in cache) {
const mod = cache[key];
- if (mod?.exports && filter(mod.exports)) ret.push(mod.exports);
- if (mod?.exports?.default && filter(mod.exports.default)) ret.push(getDefault ? mod.exports.default : mod.exports);
+ if (!mod?.exports) continue;
+
+ if (filter(mod.exports))
+ ret.push(mod.exports);
+ else if (typeof mod.exports !== "object")
+ continue;
+
+ if (mod.exports.default && filter(mod.exports.default))
+ ret.push(getDefault ? mod.exports.default : mod.exports);
+ else for (const nestedMod in mod.exports) if (nestedMod.length < 3) {
+ const nested = mod.exports[nestedMod];
+ if (nested && filter(nested)) ret.push(nested);
+ }
}
return ret;