diff options
author | Vendicated <vendicated@riseup.net> | 2022-10-01 00:42:50 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-10-01 00:42:50 +0200 |
commit | 8161a07dba401f04dac93f861e6b2cffe53ab7e3 (patch) | |
tree | 1499e825bcd6a162bc43507f492b262e9b1901ed /src/webpack/webpack.ts | |
parent | 9aaa47ea4e9ac068bf5fcbb997e31d722f43f1e5 (diff) | |
download | Vencord-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.ts | 22 |
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; |