Merge branch 'immediate-finds' into immediate-finds-modules-proxy
This commit is contained in:
commit
5462bb1438
|
@ -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",
|
||||
|
|
|
@ -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));$&"
|
||||
|
|
|
@ -162,16 +162,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];
|
||||
}
|
||||
|
||||
if (value) define(window.shortcutList, key, { value });
|
||||
return 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;
|
||||
}
|
||||
|
|
|
@ -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%;
|
||||
|
|
|
@ -432,6 +432,8 @@ export function findByFactoryCode<T = any>(...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:"),
|
||||
|
@ -450,7 +452,7 @@ export function mapMangledModule<S extends PropertyKey>(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;
|
||||
}
|
||||
|
@ -469,6 +471,10 @@ export function mapMangledModule<S extends PropertyKey>(code: string | RegExp |
|
|||
const filter = mappers[newName];
|
||||
|
||||
if (filter(exportValue)) {
|
||||
if (typeof exportValue !== "object" && typeof exportValue !== "function") {
|
||||
mapping[newName] = exportValue;
|
||||
}
|
||||
|
||||
setters[newName](exportValue);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue