Skip to content

Commit

Permalink
fix(wrapper): find correct classnames for 1.2.40 (#3071)
Browse files Browse the repository at this point in the history
Co-authored-by: Delusoire <deluso7re@outlook.com>
  • Loading branch information
rxri and Delusoire authored Jun 16, 2024
1 parent c1493ae commit e50f6e2
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions jsHelper/spicetifyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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("<anonymous>") && !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");
Expand Down Expand Up @@ -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"];
Expand Down

0 comments on commit e50f6e2

Please sign in to comment.