From c3852cb892e88eef6509d5114bd17910e72703cb Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 17 Jul 2024 02:34:05 +0200 Subject: [PATCH 1/3] fix badges on canary --- package.json | 1 + src/plugins/_api/badges/index.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index cfd4bd010..5d8f9f97d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "buildReporter": "pnpm buildWebStandalone --reporter --skip-extension", "buildReporterDesktop": "pnpm build --reporter", "watch": "pnpm build --watch", + "dev": "pnpm watch", "watchWeb": "pnpm buildWeb --watch", "generatePluginJson": "tsx scripts/generatePluginList.ts", "generateTypes": "tspc --emitDeclarationOnly --declaration --outDir packages/vencord-types", diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index 94dc673a5..89a992ac3 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -91,7 +91,7 @@ export default definePlugin({ /* new profiles */ { - find: ".PANEL]:14", + find: ".FULL_SIZE]:26", replacement: { match: /(?<=(\i)=\(0,\i\.\i\)\(\i\);)return 0===\i.length\?/, replace: "$1.unshift(...$self.getBadges(arguments[0].displayProfile));$&" From 67632ecc113ef490a322c894c6bb11e9c4c4b2e7 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 17 Jul 2024 02:35:53 +0200 Subject: [PATCH 2/3] MentionAvatars: fix mentions being ultra wide in topics --- src/plugins/mentionAvatars/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/mentionAvatars/styles.css b/src/plugins/mentionAvatars/styles.css index 33404d7b5..022f968c0 100644 --- a/src/plugins/mentionAvatars/styles.css +++ b/src/plugins/mentionAvatars/styles.css @@ -1,6 +1,6 @@ .vc-mentionAvatars-avatar { vertical-align: middle; - width: 1em; + width: 1em !important; /* insane discord sets width: 100% in channel topic */ height: 1em; margin: 0 4px 0.2rem 2px; border-radius: 50%; From 974953ba013dd1681ebc02e89aff5db0f9a90255 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:58:10 -0300 Subject: [PATCH 3/3] Fix mapMangledModule for primitives --- src/plugins/consoleShortcuts/index.ts | 32 ++++++++++++++++++++------- src/webpack/api.tsx | 8 ++++++- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/plugins/consoleShortcuts/index.ts b/src/plugins/consoleShortcuts/index.ts index 9896bcdfb..74243d9cd 100644 --- a/src/plugins/consoleShortcuts/index.ts +++ b/src/plugins/consoleShortcuts/index.ts @@ -161,16 +161,32 @@ function loadAndCacheShortcut(key: string, val: any, forceLoad: boolean) { const currentVal = val.getter(); if (!currentVal || val.preload === false) return currentVal; - let value: any; - if (currentVal[SYM_LAZY_GET]) { - value = forceLoad ? currentVal[SYM_LAZY_GET]() : currentVal[SYM_LAZY_CACHED]; - } else if (currentVal[SYM_PROXY_INNER_GET]) { - value = forceLoad ? currentVal[SYM_PROXY_INNER_GET]() : currentVal[SYM_PROXY_INNER_VALUE]; - } else { - value = currentVal; + function unwrapProxy(value: any) { + if (value[SYM_LAZY_GET]) { + return forceLoad ? value[SYM_LAZY_GET]() : value[SYM_LAZY_CACHED]; + } else if (value[SYM_PROXY_INNER_GET]) { + return forceLoad ? value[SYM_PROXY_INNER_GET]() : value[SYM_PROXY_INNER_VALUE]; + } + + return value; } - if (value) define(window.shortcutList, key, { value }); + const value = unwrapProxy(currentVal); + if (typeof value === "object") { + const descriptors = Object.getOwnPropertyDescriptors(value); + + for (const propKey in descriptors) { + const descriptor = descriptors[propKey]; + + if (descriptor.writable === true || descriptor.set != null) { + value[propKey] = unwrapProxy(value[propKey]); + } + } + } + + if (value) { + define(window.shortcutList, key, { value }); + } return value; } diff --git a/src/webpack/api.tsx b/src/webpack/api.tsx index 06f9bce11..6f360fa39 100644 --- a/src/webpack/api.tsx +++ b/src/webpack/api.tsx @@ -426,6 +426,8 @@ export function findByFactoryCode(...code: CodeFilter | [...CodeFilter, * Find the module exports of the first module which the factory includes all the given code, * then map them into an easily usable object via the specified mappers. * + * IMPORTANT: You can destructure the properties of the returned object at top level as long as the property filter does not return a primitive value export. + * * @example * const Modals = mapMangledModule("headerIdIsManaged:", { * openModal: filters.byCode("headerIdIsManaged:"), @@ -444,7 +446,7 @@ export function mapMangledModule(code: string | RegExp | // Wrapper to select whether the parent factory filter or child mapper filter failed when the error is thrown const errorMsgWrapper = lazyString(() => `Webpack mapMangledModule ${callbackCalled ? "mapper" : "factory"} filter matched no module. Filter: ${printFilter(callbackCalled ? mappers[newName] : factoryFilter)}`); - const [proxy, setInnerValue] = proxyInner(errorMsgWrapper, "Webpack find with proxy called on a primitive value."); + const [proxy, setInnerValue] = proxyInner(errorMsgWrapper, "Webpack find with proxy called on a primitive value. This may happen if you are trying to destructure a mapMangledModule primitive value on top level."); mapping[newName] = proxy; setters[newName] = setInnerValue; } @@ -463,6 +465,10 @@ export function mapMangledModule(code: string | RegExp | const filter = mappers[newName]; if (filter(exportValue)) { + if (typeof exportValue !== "object" && typeof exportValue !== "function") { + mapping[newName] = exportValue; + } + setters[newName](exportValue); } }