From 453c0b62f476465c8979f793299d7723e140aa45 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 22 Jun 2024 05:50:09 -0300 Subject: [PATCH 1/2] ff --- src/utils/lazy.ts | 3 ++- src/utils/proxyInner.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/lazy.ts b/src/utils/lazy.ts index 14349379f..fee6e8133 100644 --- a/src/utils/lazy.ts +++ b/src/utils/lazy.ts @@ -59,8 +59,9 @@ const handler: ProxyHandler = { return keys; }, getOwnPropertyDescriptor: (target, p) => { - if (typeof p === "string" && unconfigurable.includes(p)) + if (typeof p === "string" && unconfigurable.includes(p)) { return Reflect.getOwnPropertyDescriptor(target, p); + } const descriptor = Reflect.getOwnPropertyDescriptor(target[SYM_LAZY_GET](), p); if (descriptor) Object.defineProperty(target, p, descriptor); diff --git a/src/utils/proxyInner.ts b/src/utils/proxyInner.ts index 50fa26dc2..2f701fe64 100644 --- a/src/utils/proxyInner.ts +++ b/src/utils/proxyInner.ts @@ -34,8 +34,9 @@ const handler: ProxyHandler = { return keys; }, getOwnPropertyDescriptor: (target, p) => { - if (typeof p === "string" && unconfigurable.includes(p)) + if (typeof p === "string" && unconfigurable.includes(p)) { return Reflect.getOwnPropertyDescriptor(target, p); + } const descriptor = Reflect.getOwnPropertyDescriptor(target[SYM_PROXY_INNER_GET](), p); if (descriptor) Object.defineProperty(target, p, descriptor); From b4b67a98daee9fc218fe1b959b2106e2d3d53847 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 22 Jun 2024 06:14:43 -0300 Subject: [PATCH 2/2] fix proxies not being constructable --- src/utils/lazy.ts | 4 +--- src/utils/proxyInner.ts | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/utils/lazy.ts b/src/utils/lazy.ts index fee6e8133..d1bb3e0ae 100644 --- a/src/utils/lazy.ts +++ b/src/utils/lazy.ts @@ -83,9 +83,7 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild let isSameTick = true; if (!isChild) setTimeout(() => isSameTick = false, 0); - // Define the function in an object to preserve the name after minification - const proxyDummy = ({ ProxyDummy() { } }).ProxyDummy; - Object.assign(proxyDummy, { + const proxyDummy = Object.assign(function () { }, { [SYM_LAZY_GET]() { if (!proxyDummy[SYM_LAZY_CACHED]) { if (!get.$$vencordLazyFailed()) { diff --git a/src/utils/proxyInner.ts b/src/utils/proxyInner.ts index 2f701fe64..bd1dd96da 100644 --- a/src/utils/proxyInner.ts +++ b/src/utils/proxyInner.ts @@ -60,9 +60,7 @@ export function proxyInner( let isSameTick = true; if (!isChild) setTimeout(() => isSameTick = false, 0); - // Define the function in an object to preserve the name after minification - const proxyDummy = ({ ProxyDummy() { } }).ProxyDummy; - Object.assign(proxyDummy, { + const proxyDummy = Object.assign(function () { }, { [SYM_PROXY_INNER_GET]: function () { if (proxyDummy[SYM_PROXY_INNER_VALUE] == null) { throw new Error(errMsg);