From e50f6e2ef4bcbba771f7681e357d3b81fe335a74 Mon Sep 17 00:00:00 2001 From: ririxi Date: Sun, 16 Jun 2024 19:21:06 +0200 Subject: [PATCH] fix(wrapper): find correct `classnames` for `1.2.40` (#3071) Co-authored-by: Delusoire --- jsHelper/spicetifyWrapper.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/jsHelper/spicetifyWrapper.js b/jsHelper/spicetifyWrapper.js index a399b14d46..13808aba2b 100644 --- a/jsHelper/spicetifyWrapper.js +++ b/jsHelper/spicetifyWrapper.js @@ -512,10 +512,11 @@ window.Spicetify = { ReactJSX: cache.find(m => m?.jsx), ReactDOM: cache.find(m => m?.createPortal), ReactDOMServer: cache.find(m => m?.renderToString), - // classnames for 1.2.13 - classnames: cache - .filter(module => typeof module === "function") - .find(module => module.toString().includes('"string"') && module.toString().includes("[native code]")), + // https://github.com/JedWatson/classnames/ + classnames: chunks + .filter(([_, v]) => v.toString().includes("[native code]")) + .map(([i]) => require(i)) + .find(e => typeof e === "function"), Color: functionModules.find(m => m.toString().includes("static fromHex") || m.toString().includes("this.rgb")), Player: { ...Spicetify.Player, @@ -696,16 +697,6 @@ window.Spicetify = { } }); - // classnames - // https://github.com/JedWatson/classnames/ - const classnamesChunk = chunks.find( - ([_, value]) => - value.toString().includes("[native code]") && !value.toString().includes("") && !value.toString().includes("Super expression") - ); - if (classnamesChunk && !Spicetify.classnames) { - Spicetify.classnames = Object.values(require(classnamesChunk[0])).find(m => typeof m === "function"); - } - const contextMenuChunk = chunks.find(([, value]) => value.toString().includes("toggleContextMenu")); if (contextMenuChunk) { Spicetify.ReactComponent.ContextMenu = Object.values(require(contextMenuChunk[0])).find(m => typeof m === "function"); @@ -1045,7 +1036,7 @@ Spicetify._getStyledClassName = (args, component) => { } } - const excludedKeys = ["children", "className", "style", "dir", "key", "ref", "as", "$autoMirror", "$hasFocus", ""]; + const excludedKeys = ["children", "className", "style", "dir", "key", "ref", "as", "$autoMirror", "autoMirror", "$hasFocus", ""]; const excludedPrefix = ["aria-"]; const childrenProps = ["iconLeading", "iconTrailing", "iconOnly", "$iconOnly", "$iconLeading", "$iconTrailing"];