From 349169e67a82fad9ebbaf0d42cc313f653ac0f4d Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 24 May 2024 01:05:17 +0200 Subject: [PATCH 01/10] discord why tf would u roll back to 10 days old build??? --- src/plugins/_core/settings.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index b743b0066..fd221d27e 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -56,6 +56,26 @@ export default definePlugin({ } ] }, + // Discord Stable + // FIXME: remove once change merged to stable + { + find: "Messages.ACTIVITY_SETTINGS", + replacement: { + get match() { + switch (Settings.plugins.Settings.settingsLocation) { + case "top": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.USER_SETTINGS/; + case "aboveNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.BILLING_SETTINGS/; + case "belowNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.APP_SETTINGS/; + case "belowActivity": return /(?<=\{section:(\i\.\i)\.DIVIDER},)\{section:"changelog"/; + case "bottom": return /\{section:(\i\.\i)\.CUSTOM,\s*element:.+?}/; + case "aboveActivity": + default: + return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.ACTIVITY_SETTINGS/; + } + }, + replace: "...$self.makeSettingsCategories($1),$&" + } + }, { find: "Messages.ACTIVITY_SETTINGS", replacement: { From 1866e4d379831aef135cf152b805f7fe2c9a96ab Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 24 May 2024 01:07:07 +0200 Subject: [PATCH 02/10] Bump to v1.8.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a99b0ad70..04b811e9c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.8.5", + "version": "1.8.6", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From 8f59cd8a1a0069a7579c22e424e4a3e983943313 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 21:48:12 -0300 Subject: [PATCH 03/10] Optimize slowest patches --- src/plugins/_api/notices.ts | 2 +- src/plugins/alwaysAnimate/index.ts | 4 ++-- src/plugins/betterFolders/index.tsx | 4 ++-- src/plugins/betterSettings/index.tsx | 4 ++-- src/plugins/colorSighted/index.ts | 4 ++-- src/plugins/fakeNitro/index.tsx | 4 ++-- src/plugins/ignoreActivities/index.tsx | 8 ++++---- src/plugins/memberCount/index.tsx | 4 ++-- src/plugins/pinDms/index.tsx | 4 ++-- src/plugins/resurrectHome/index.tsx | 4 ++-- src/plugins/showHiddenChannels/index.tsx | 12 ++++++------ src/plugins/spotifyCrack/index.ts | 4 ++-- src/plugins/superReactionTweaks/index.ts | 4 ++-- src/plugins/viewIcons/index.tsx | 4 ++-- 14 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/plugins/_api/notices.ts b/src/plugins/_api/notices.ts index 90ae6ded9..0c6f6e1db 100644 --- a/src/plugins/_api/notices.ts +++ b/src/plugins/_api/notices.ts @@ -29,7 +29,7 @@ export default definePlugin({ find: '"NoticeStore"', replacement: [ { - match: /\i=null;(?=.{0,80}getPremiumSubscription\(\))/g, + match: /(?<=!1;)\i=null;(?=.{0,80}getPremiumSubscription\(\))/g, replace: "if(Vencord.Api.Notices.currentNotice)return false;$&" }, { diff --git a/src/plugins/alwaysAnimate/index.ts b/src/plugins/alwaysAnimate/index.ts index dbec3b4e3..20cb4f974 100644 --- a/src/plugins/alwaysAnimate/index.ts +++ b/src/plugins/alwaysAnimate/index.ts @@ -31,10 +31,10 @@ export default definePlugin({ // Some modules match the find but the replacement is returned untouched noWarn: true, replacement: { - match: /canAnimate:.+?(?=([,}].*?\)))/g, + match: /canAnimate:.+?([,}].*?\))/g, replace: (m, rest) => { const destructuringMatch = rest.match(/}=.+/); - if (destructuringMatch == null) return "canAnimate:!0"; + if (destructuringMatch == null) return `canAnimate:!0${rest}`; return m; } } diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index 795f19901..38e1b8412 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -112,8 +112,8 @@ export default definePlugin({ replacement: [ // Create the isBetterFolders variable in the GuildsBar component { - match: /(?<=let{disableAppDownload:\i=\i\.isPlatformEmbedded,isOverlay:.+?)(?=}=\i,)/, - replace: ",isBetterFolders" + match: /let{disableAppDownload:\i=\i\.isPlatformEmbedded,isOverlay:.+?(?=}=\i,)/, + replace: "$&,isBetterFolders" }, // If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders { diff --git a/src/plugins/betterSettings/index.tsx b/src/plugins/betterSettings/index.tsx index e90e5c82a..e0267e4b0 100644 --- a/src/plugins/betterSettings/index.tsx +++ b/src/plugins/betterSettings/index.tsx @@ -111,8 +111,8 @@ export default definePlugin({ { // Load menu TOC eagerly find: "Messages.USER_SETTINGS_WITH_BUILD_OVERRIDE.format", replacement: { - match: /(?<=(\i)\(this,"handleOpenSettingsContextMenu",.{0,100}?openContextMenuLazy.{0,100}?(await Promise\.all[^};]*?\)\)).*?,)(?=\1\(this)/, - replace: "(async ()=>$2)()," + match: /(\i)\(this,"handleOpenSettingsContextMenu",.{0,100}?openContextMenuLazy.{0,100}?(await Promise\.all[^};]*?\)\)).*?,(?=\1\(this)/, + replace: "$&(async ()=>$2)()," }, predicate: () => settings.store.eagerLoad }, diff --git a/src/plugins/colorSighted/index.ts b/src/plugins/colorSighted/index.ts index d741aaae6..025cfb94e 100644 --- a/src/plugins/colorSighted/index.ts +++ b/src/plugins/colorSighted/index.ts @@ -34,9 +34,9 @@ export default definePlugin({ { find: ".AVATAR_STATUS_MOBILE_16;", replacement: { - match: /(?<=fromIsMobile:\i=!0,.+?)status:(\i)/, + match: /(fromIsMobile:\i=!0,.+?)status:(\i)/, // Rename field to force it to always use "online" - replace: 'status_$:$1="online"' + replace: '$1status_$:$2="online"' } } ] diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index 9c8af1e7c..4ab0e18ee 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -344,8 +344,8 @@ export default definePlugin({ { // Patch the stickers array to add fake nitro stickers predicate: () => settings.store.transformStickers, - match: /(?<=renderStickersAccessories\((\i)\){let (\i)=\(0,\i\.\i\)\(\i\).+?;)/, - replace: (_, message, stickers) => `${stickers}=$self.patchFakeNitroStickers(${stickers},${message});` + match: /renderStickersAccessories\((\i)\){let (\i)=\(0,\i\.\i\)\(\i\).+?;/, + replace: (m, message, stickers) => `${m}${stickers}=$self.patchFakeNitroStickers(${stickers},${message});` }, { // Filter attachments to remove fake nitro stickers or emojis diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index e2262129d..f687a0caf 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -228,15 +228,15 @@ export default definePlugin({ { find: ".activityTitleText,variant", replacement: { - match: /(?<=\i\.activityTitleText.+?children:(\i)\.name.*?}\),)/, - replace: (_, props) => `$self.renderToggleActivityButton(${props}),` + match: /\.activityTitleText.+?children:(\i)\.name.*?}\),/, + replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` }, }, { find: ".activityCardDetails,children", replacement: { - match: /(?<=\i\.activityCardDetails.+?children:(\i\.application)\.name.*?}\),)/, - replace: (_, props) => `$self.renderToggleActivityButton(${props}),` + match: /\.activityCardDetails.+?children:(\i\.application)\.name.*?}\),/, + replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` } } ], diff --git a/src/plugins/memberCount/index.tsx b/src/plugins/memberCount/index.tsx index 92e9a2057..28ecb9db7 100644 --- a/src/plugins/memberCount/index.tsx +++ b/src/plugins/memberCount/index.tsx @@ -70,8 +70,8 @@ export default definePlugin({ { find: ".invitesDisabledTooltip", replacement: { - match: /(?<=\.VIEW_AS_ROLES_MENTIONS_WARNING.{0,100})]/, - replace: ",$self.renderTooltip(arguments[0].guild)]" + match: /\.VIEW_AS_ROLES_MENTIONS_WARNING.{0,100}(?=])/, + replace: "$&,$self.renderTooltip(arguments[0].guild)" }, predicate: () => settings.store.toolTip } diff --git a/src/plugins/pinDms/index.tsx b/src/plugins/pinDms/index.tsx index 60484561a..033552593 100644 --- a/src/plugins/pinDms/index.tsx +++ b/src/plugins/pinDms/index.tsx @@ -111,8 +111,8 @@ export default definePlugin({ replace: "$self.getScrollOffset(arguments[0],$1,this.props.padding,this.state.preRenderedChildren,$&)" }, { - match: /(?<=scrollToChannel\(\i\){.{1,300})this\.props\.privateChannelIds/, - replace: "[...$&,...$self.getAllUncollapsedChannels()]" + match: /(scrollToChannel\(\i\){.{1,300})(this\.props\.privateChannelIds)/, + replace: "$1[...$2,...$self.getAllUncollapsedChannels()]" }, ] diff --git a/src/plugins/resurrectHome/index.tsx b/src/plugins/resurrectHome/index.tsx index 70827e08f..5193090ea 100644 --- a/src/plugins/resurrectHome/index.tsx +++ b/src/plugins/resurrectHome/index.tsx @@ -134,8 +134,8 @@ export default definePlugin({ { find: '"MessageActionCreators"', replacement: { - match: /(?<=focusMessage\(\i\){.+?)(?=focus:{messageId:(\i)})/, - replace: "after:$1," + match: /focusMessage\(\i\){.+?(?=focus:{messageId:(\i)})/, + replace: "$&after:$1," } }, // Force Server Home instead of Server Guide diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index f08bc2d1d..c120d72d8 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -89,8 +89,8 @@ export default definePlugin({ }, // Remove permission checking for getRenderLevel function { - match: /(?<=getRenderLevel\(\i\){.+?return)!\i\.\i\.can\(\i\.\i\.VIEW_CHANNEL,this\.record\)\|\|/, - replace: " " + match: /(getRenderLevel\(\i\){.+?return)!\i\.\i\.can\(\i\.\i\.VIEW_CHANNEL,this\.record\)\|\|/, + replace: (_, rest) => `${rest} ` } ] }, @@ -159,8 +159,8 @@ export default definePlugin({ replacement: [ // Make the channel appear as muted if it's hidden { - match: /(?<={channel:(\i),name:\i,muted:(\i).+?;)/, - replace: (_, channel, muted) => `${muted}=$self.isHiddenChannel(${channel})?true:${muted};` + match: /{channel:(\i),name:\i,muted:(\i).+?;/, + replace: (m, channel, muted) => `${m}${muted}=$self.isHiddenChannel(${channel})?true:${muted};` }, // Add the hidden eye icon if the channel is hidden { @@ -186,8 +186,8 @@ export default definePlugin({ { // Hide unreads predicate: () => settings.store.hideUnreads === true, - match: /(?<={channel:(\i),name:\i,.+?unread:(\i).+?;)/, - replace: (_, channel, unread) => `${unread}=$self.isHiddenChannel(${channel})?false:${unread};` + match: /{channel:(\i),name:\i,.+?unread:(\i).+?;/, + replace: (m, channel, unread) => `${m}${unread}=$self.isHiddenChannel(${channel})?false:${unread};` } ] }, diff --git a/src/plugins/spotifyCrack/index.ts b/src/plugins/spotifyCrack/index.ts index 1beccad60..37504be2e 100644 --- a/src/plugins/spotifyCrack/index.ts +++ b/src/plugins/spotifyCrack/index.ts @@ -60,8 +60,8 @@ export default definePlugin({ }, { predicate: () => settings.store.keepSpotifyActivityOnIdle, - match: /(?<=shouldShowActivity\(\){.{0,50})&&!\i\.\i\.isIdle\(\)/, - replace: "" + match: /(shouldShowActivity\(\){.{0,50})&&!\i\.\i\.isIdle\(\)/, + replace: "$1" } ] } diff --git a/src/plugins/superReactionTweaks/index.ts b/src/plugins/superReactionTweaks/index.ts index 89197b4c3..7878ba630 100644 --- a/src/plugins/superReactionTweaks/index.ts +++ b/src/plugins/superReactionTweaks/index.ts @@ -42,8 +42,8 @@ export default definePlugin({ { find: ",BURST_REACTION_EFFECT_PLAY", replacement: { - match: /(?<=BURST_REACTION_EFFECT_PLAY:\i=>{.{50,100})(\i\(\i,\i\))>=\d+/, - replace: "!$self.shouldPlayBurstReaction($1)" + match: /(BURST_REACTION_EFFECT_PLAY:\i=>{.{50,100})(\i\(\i,\i\))>=\d+/, + replace: "$1!$self.shouldPlayBurstReaction($2)" } }, { diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index 359365ee4..09254d511 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -206,8 +206,8 @@ export default definePlugin({ { find: ".avatarPositionPanel", replacement: { - match: /(?<=avatarWrapperNonUserBot.{0,50})onClick:(\i\|\|\i)\?void 0(?<=,avatarSrc:(\i).+?)/, - replace: "style:($1)?{cursor:\"pointer\"}:{},onClick:$1?()=>{$self.openImage($2)}" + match: /(avatarWrapperNonUserBot.{0,50})onClick:(\i\|\|\i)\?void 0(?<=,avatarSrc:(\i).+?)/, + replace: "$1style:($2)?{cursor:\"pointer\"}:{},onClick:$2?()=>{$self.openImage($3)}" } }, // Group DMs top small & large icon From 6f25005057e99bfe7d60bca22f87430bfc9b7c5b Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 22:20:24 -0300 Subject: [PATCH 04/10] Monkey patch toString on proxyInner and proxyLazy --- src/utils/lazy.ts | 8 +++++++- src/utils/proxyInner.ts | 30 ++++++++++++++++++------------ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/utils/lazy.ts b/src/utils/lazy.ts index 92c9c32d6..899b05f1c 100644 --- a/src/utils/lazy.ts +++ b/src/utils/lazy.ts @@ -83,6 +83,10 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild if (!proxyDummy[proxyLazyCache]) { throw new Error(`proxyLazy factory failed:\n\n${factory}`); + } else { + if (typeof proxyDummy[proxyLazyCache] === "function") { + proxy.toString = proxyDummy[proxyLazyCache].toString.bind(proxyDummy[proxyLazyCache]); + } } } @@ -91,7 +95,7 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild [proxyLazyCache]: void 0 as T | undefined }); - return new Proxy(proxyDummy, { + const proxy = new Proxy(proxyDummy, { ...handler, get(target, p, receiver) { if (p === proxyLazyGet) return target[proxyLazyGet]; @@ -117,4 +121,6 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild throw new Error("proxyLazy called on a primitive value. This can happen if you try to destructure a primitive at the same tick as the proxy was created."); } }); + + return proxy; } diff --git a/src/utils/proxyInner.ts b/src/utils/proxyInner.ts index f78aaf32f..96d2f4262 100644 --- a/src/utils/proxyInner.ts +++ b/src/utils/proxyInner.ts @@ -65,17 +65,7 @@ export function proxyInner( [proxyInnerValue]: void 0 as T | undefined }); - // Values destructured in the same tick the proxy was created will push their setInnerValue here - const recursiveSetInnerValues = [] as Array<(innerValue: T) => void>; - - // Once we set the parent inner value, we will call the setInnerValue functions of the destructured values, - // for them to get the proper value from the parent and use as their inner instead - function setInnerValue(innerValue: T) { - proxyDummy[proxyInnerValue] = innerValue; - recursiveSetInnerValues.forEach(setInnerValue => setInnerValue(innerValue)); - } - - return [new Proxy(proxyDummy, { + const proxy = new Proxy(proxyDummy, { ...handler, get(target, p, receiver) { if (p === proxyInnerValue) return target[proxyInnerValue]; @@ -104,5 +94,21 @@ export function proxyInner( throw new Error(primitiveErrMsg); } - }), setInnerValue]; + }); + + // Values destructured in the same tick the proxy was created will push their setInnerValue here + const recursiveSetInnerValues = [] as Array<(innerValue: T) => void>; + + // Once we set the parent inner value, we will call the setInnerValue functions of the destructured values, + // for them to get the proper value from the parent and use as their inner instead + function setInnerValue(innerValue: T) { + proxyDummy[proxyInnerValue] = innerValue; + recursiveSetInnerValues.forEach(setInnerValue => setInnerValue(innerValue)); + + if (typeof innerValue === "function") { + proxy.toString = innerValue.toString.bind(innerValue); + } + } + + return [proxy, setInnerValue]; } From 90c26432f53c8ded339b1c87478ddd36dd3f6863 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 22:51:23 -0300 Subject: [PATCH 05/10] Properly set receiver --- src/utils/lazy.ts | 7 ++++--- src/utils/proxyInner.ts | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/utils/lazy.ts b/src/utils/lazy.ts index 899b05f1c..76bcbb159 100644 --- a/src/utils/lazy.ts +++ b/src/utils/lazy.ts @@ -43,6 +43,7 @@ const handler: ProxyHandler = { ...Object.fromEntries(Object.getOwnPropertyNames(Reflect).map(propName => [propName, (target: any, ...args: any[]) => Reflect[propName](target[proxyLazyGet](), ...args)] )), + set: (target, p, newValue) => Reflect.set(target[proxyLazyGet](), p, newValue, target[proxyLazyGet]()), ownKeys: target => { const keys = Reflect.ownKeys(target[proxyLazyGet]()); for (const key of unconfigurable) { @@ -97,7 +98,7 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild const proxy = new Proxy(proxyDummy, { ...handler, - get(target, p, receiver) { + get(target, p) { if (p === proxyLazyGet) return target[proxyLazyGet]; if (p === proxyLazyCache) return target[proxyLazyCache]; @@ -107,7 +108,7 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild // `const { meow } = proxyLazy(() => ({ meow: [] }));` if (!isChild && isSameTick) { return proxyLazy( - () => Reflect.get(target[proxyLazyGet](), p, receiver), + () => Reflect.get(target[proxyLazyGet](), p, target[proxyLazyGet]()), attempts, true ); @@ -115,7 +116,7 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild const lazyTarget = target[proxyLazyGet](); if (typeof lazyTarget === "object" || typeof lazyTarget === "function") { - return Reflect.get(lazyTarget, p, receiver); + return Reflect.get(lazyTarget, p, lazyTarget); } throw new Error("proxyLazy called on a primitive value. This can happen if you try to destructure a primitive at the same tick as the proxy was created."); diff --git a/src/utils/proxyInner.ts b/src/utils/proxyInner.ts index 96d2f4262..2511649a5 100644 --- a/src/utils/proxyInner.ts +++ b/src/utils/proxyInner.ts @@ -22,6 +22,7 @@ const handler: ProxyHandler = { ...Object.fromEntries(Object.getOwnPropertyNames(Reflect).map(propName => [propName, (target: any, ...args: any[]) => Reflect[propName](target[proxyInnerGet](), ...args)] )), + set: (target, p, value) => Reflect.set(target[proxyInnerGet](), p, value, target[proxyInnerGet]()), ownKeys: target => { const keys = Reflect.ownKeys(target[proxyInnerGet]()); for (const key of unconfigurable) { @@ -67,7 +68,7 @@ export function proxyInner( const proxy = new Proxy(proxyDummy, { ...handler, - get(target, p, receiver) { + get(target, p) { if (p === proxyInnerValue) return target[proxyInnerValue]; if (p === proxyInnerGet) return target[proxyInnerGet]; @@ -80,7 +81,7 @@ export function proxyInner( recursiveSetInnerValues.push((innerValue: T) => { // Set the inner value of the destructured value as the prop value p of the parent - recursiveSetInnerValue(Reflect.get(innerValue as object, p, receiver)); + recursiveSetInnerValue(Reflect.get(innerValue as object, p, innerValue)); }); return recursiveProxy; @@ -88,7 +89,7 @@ export function proxyInner( const innerTarget = target[proxyInnerGet](); if (typeof innerTarget === "object" || typeof innerTarget === "function") { - return Reflect.get(innerTarget, p, receiver); + return Reflect.get(innerTarget, p, innerTarget); } throw new Error(primitiveErrMsg); From c01a8c2f780319e1dcac15daf57b113d62a1d04d Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 22:52:32 -0300 Subject: [PATCH 06/10] I changed my mind --- src/utils/lazy.ts | 5 ++++- src/utils/proxyInner.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils/lazy.ts b/src/utils/lazy.ts index 76bcbb159..439ec1bef 100644 --- a/src/utils/lazy.ts +++ b/src/utils/lazy.ts @@ -43,7 +43,10 @@ const handler: ProxyHandler = { ...Object.fromEntries(Object.getOwnPropertyNames(Reflect).map(propName => [propName, (target: any, ...args: any[]) => Reflect[propName](target[proxyLazyGet](), ...args)] )), - set: (target, p, newValue) => Reflect.set(target[proxyLazyGet](), p, newValue, target[proxyLazyGet]()), + set: (target, p, newValue) => { + const lazyTarget = target[proxyLazyGet](); + return Reflect.set(lazyTarget, p, newValue, lazyTarget); + }, ownKeys: target => { const keys = Reflect.ownKeys(target[proxyLazyGet]()); for (const key of unconfigurable) { diff --git a/src/utils/proxyInner.ts b/src/utils/proxyInner.ts index 2511649a5..51d62bdc4 100644 --- a/src/utils/proxyInner.ts +++ b/src/utils/proxyInner.ts @@ -22,7 +22,10 @@ const handler: ProxyHandler = { ...Object.fromEntries(Object.getOwnPropertyNames(Reflect).map(propName => [propName, (target: any, ...args: any[]) => Reflect[propName](target[proxyInnerGet](), ...args)] )), - set: (target, p, value) => Reflect.set(target[proxyInnerGet](), p, value, target[proxyInnerGet]()), + set: (target, p, value) => { + const innerTarget = target[proxyInnerGet](); + return Reflect.set(innerTarget, p, value, innerTarget); + }, ownKeys: target => { const keys = Reflect.ownKeys(target[proxyInnerGet]()); for (const key of unconfigurable) { From 74f36a093b2605f017e0b7db2d38a7347a4c8767 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 23:14:00 -0300 Subject: [PATCH 07/10] Preserve ProxyDummy function name after minification --- src/utils/lazy.ts | 10 +++++++++- src/utils/proxyInner.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/utils/lazy.ts b/src/utils/lazy.ts index 439ec1bef..c3cb0f794 100644 --- a/src/utils/lazy.ts +++ b/src/utils/lazy.ts @@ -77,7 +77,13 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild let isSameTick = true; if (!isChild) setTimeout(() => isSameTick = false, 0); - const proxyDummy = Object.assign(function ProxyDummy() { }, { + // Define the function in an object to preserve the name after minification + const dummyObj = { + ProxyDummy() { } + } as { ProxyDummy: any; }; + + const proxyDummy = dummyObj.ProxyDummy; + Object.assign(proxyDummy, { [proxyLazyGet]() { if (!proxyDummy[proxyLazyCache]) { // @ts-ignore @@ -99,6 +105,8 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild [proxyLazyCache]: void 0 as T | undefined }); + delete dummyObj.ProxyDummy; + const proxy = new Proxy(proxyDummy, { ...handler, get(target, p) { diff --git a/src/utils/proxyInner.ts b/src/utils/proxyInner.ts index 51d62bdc4..4f6c67991 100644 --- a/src/utils/proxyInner.ts +++ b/src/utils/proxyInner.ts @@ -58,7 +58,13 @@ export function proxyInner( let isSameTick = true; if (!isChild) setTimeout(() => isSameTick = false, 0); - const proxyDummy = Object.assign(function ProxyDummy() { }, { + // Define the function in an object to preserve the name after minification + const dummyObj = { + ProxyDummy() { } + } as { ProxyDummy: any; }; + + const proxyDummy = dummyObj.ProxyDummy; + Object.assign(proxyDummy, { [proxyInnerGet]: function () { if (proxyDummy[proxyInnerValue] == null) { throw new Error(errMsg); @@ -69,6 +75,8 @@ export function proxyInner( [proxyInnerValue]: void 0 as T | undefined }); + delete dummyObj.ProxyDummy; + const proxy = new Proxy(proxyDummy, { ...handler, get(target, p) { From 64212512ca7e89d348978a519bec5dbe2f93205e Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 23:20:46 -0300 Subject: [PATCH 08/10] cya dummyObj --- src/utils/lazy.ts | 8 +------- src/utils/proxyInner.ts | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/utils/lazy.ts b/src/utils/lazy.ts index c3cb0f794..57e68398f 100644 --- a/src/utils/lazy.ts +++ b/src/utils/lazy.ts @@ -78,11 +78,7 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild if (!isChild) setTimeout(() => isSameTick = false, 0); // Define the function in an object to preserve the name after minification - const dummyObj = { - ProxyDummy() { } - } as { ProxyDummy: any; }; - - const proxyDummy = dummyObj.ProxyDummy; + const proxyDummy = ({ ProxyDummy() { } }).ProxyDummy; Object.assign(proxyDummy, { [proxyLazyGet]() { if (!proxyDummy[proxyLazyCache]) { @@ -105,8 +101,6 @@ export function proxyLazy(factory: () => T, attempts = 5, isChild [proxyLazyCache]: void 0 as T | undefined }); - delete dummyObj.ProxyDummy; - const proxy = new Proxy(proxyDummy, { ...handler, get(target, p) { diff --git a/src/utils/proxyInner.ts b/src/utils/proxyInner.ts index 4f6c67991..76eb06f1e 100644 --- a/src/utils/proxyInner.ts +++ b/src/utils/proxyInner.ts @@ -59,11 +59,7 @@ export function proxyInner( if (!isChild) setTimeout(() => isSameTick = false, 0); // Define the function in an object to preserve the name after minification - const dummyObj = { - ProxyDummy() { } - } as { ProxyDummy: any; }; - - const proxyDummy = dummyObj.ProxyDummy; + const proxyDummy = ({ ProxyDummy() { } }).ProxyDummy; Object.assign(proxyDummy, { [proxyInnerGet]: function () { if (proxyDummy[proxyInnerValue] == null) { @@ -75,8 +71,6 @@ export function proxyInner( [proxyInnerValue]: void 0 as T | undefined }); - delete dummyObj.ProxyDummy; - const proxy = new Proxy(proxyDummy, { ...handler, get(target, p) { From 07361ff6feb8af4101fef5f593e1f1dfb2da6863 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 23:32:46 -0300 Subject: [PATCH 09/10] eww new line --- src/utils/proxyInner.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/proxyInner.ts b/src/utils/proxyInner.ts index 76eb06f1e..d02517882 100644 --- a/src/utils/proxyInner.ts +++ b/src/utils/proxyInner.ts @@ -23,6 +23,10 @@ const handler: ProxyHandler = { [propName, (target: any, ...args: any[]) => Reflect[propName](target[proxyInnerGet](), ...args)] )), set: (target, p, value) => { + if (p === Symbol.toStringTag) { + return Reflect.set(target, p, value, target); + } + const innerTarget = target[proxyInnerGet](); return Reflect.set(innerTarget, p, value, innerTarget); }, @@ -98,7 +102,6 @@ export function proxyInner( } throw new Error(primitiveErrMsg); - } }); From 8eb4eab2b0cca4a5825af95db3c20dc00ba6fef8 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 23:33:20 -0300 Subject: [PATCH 10/10] oops you were not meant to be here --- src/utils/proxyInner.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/utils/proxyInner.ts b/src/utils/proxyInner.ts index d02517882..e8bb60ff3 100644 --- a/src/utils/proxyInner.ts +++ b/src/utils/proxyInner.ts @@ -23,10 +23,6 @@ const handler: ProxyHandler = { [propName, (target: any, ...args: any[]) => Reflect[propName](target[proxyInnerGet](), ...args)] )), set: (target, p, value) => { - if (p === Symbol.toStringTag) { - return Reflect.set(target, p, value, target); - } - const innerTarget = target[proxyInnerGet](); return Reflect.set(innerTarget, p, value, innerTarget); },