Skip to content

Commit

Permalink
feat: expose ContextMenu React component via wrapper (#2796)
Browse files Browse the repository at this point in the history
Co-authored-by: ririxi <[email protected]>
  • Loading branch information
SunsetTechuila and rxri authored Feb 2, 2024
1 parent 2369bf9 commit 50835b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 5 additions & 0 deletions jsHelper/spicetifyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,11 @@ window.Spicetify = {
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");
}

const playlistMenuChunk = chunks.find(
([, value]) => value.toString().includes('value:"playlist"') && value.toString().includes("canView") && value.toString().includes("permissions")
);
Expand Down
7 changes: 0 additions & 7 deletions src/preprocess/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,6 @@ func exposeAPIs_main(input string) string {
`(,[$\w]+=)((function\([\w$]{1}\)\{var [\w$]+=[\w$]+\.platform,[\w$]+=[\w$]+\.children,)|(\(\{platform:[\w$]+,children:[\w$]+\}\)=>\{))`,
`${1}Spicetify.ReactComponent.PlatformProvider=${2}`)

// React Component: Context Menu
// TODO: replace with webpack module
utils.Replace(
&input,
`=(?:function\()?(\w+)(?:=>|\)\{return ?)((?:\w+(?:\(\))?\.createElement|\([\w$\.,]+\))\(([\w\.]+),(?:[\w(){},\.]+,[\w{}]+,)?\{[.,\w+]*action:"open",trigger:"right-click"\}\)\)?)(?:\}(\}))?`,
`=${1}=>${2};Spicetify.ReactComponent.ContextMenu=${3};${4}`)

// Prevent breaking popupLyrics
utils.Replace(
&input,
Expand Down

0 comments on commit 50835b7

Please sign in to comment.