Skip to content

Commit

Permalink
Merge branch 'spicetify:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Lseoksee authored Feb 11, 2024
2 parents 372efae + cdca8d0 commit aaee254
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ go 1.21
require (
github.com/go-ini/ini v1.67.0
github.com/mattn/go-colorable v0.1.13
golang.org/x/net v0.20.0
golang.org/x/net v0.21.0
)

require (
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/stretchr/testify v1.7.1 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/sys v0.17.0 // indirect
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion jsHelper/spicetifyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ Spicetify.ContextMenuV2 = (() => {
})();

Spicetify.Menu = (() => {
const shouldAdd = (_, trigger, target) => trigger === "click" && target.parentElement.classList.contains("main-topBar-topbarContentRight");
const shouldAdd = (_, trigger, target) => trigger === "click" && target.closest(".main-topBar-container");

class Item extends Spicetify.ContextMenuV2.Item {
constructor(children, isEnabled, onClick, leadingIcon) {
Expand Down
26 changes: 19 additions & 7 deletions src/preprocess/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,26 @@ func exposeAPIs_main(input string) string {
// Menu hook
utils.Replace(&input, `("Menu".+?children:)([\w$][\w$\d]*)`, `${1}[Spicetify.ContextMenuV2.renderItems(),${2}].flat()`)

croppedInput := utils.FindFirstMatch(input, `.*value:"contextmenu"`)[0]

react := utils.FindLastMatch(croppedInput, `([\w_$]+)\.useRef`)[1]
menu := utils.FindLastMatch(croppedInput, `menu:([\w_$]+)`)[1]
trigger := utils.FindLastMatch(croppedInput, `trigger:([\w_$]+)`)[1]
target := utils.FindLastMatch(croppedInput, `triggerRef:([\w_$]+)`)[1]
croppedInput := utils.FindFirstMatch(input, `"context-menu".*value:"contextmenu"`)[0]

react := utils.FindFirstMatch(croppedInput, `([\w_$]+)\.useRef`)[1]
var menu string
var trigger string
var target string

menuCandidates := utils.FindMatch(croppedInput, `menu:([\w_$]+)`)
if len(menuCandidates) == 0 {
// v1.2.13 fix
menu = utils.FindFirstMatch(croppedInput, `([\w_$]+)=[\w_$]+\.menu,`)[1]
trigger = utils.FindFirstMatch(croppedInput, `([\w_$]+)=[\w_$]+\.trigger,`)[1]
target = utils.FindFirstMatch(croppedInput, `([\w_$]+)=[\w_$]+\.triggerRef,`)[1]
} else {
menu = menuCandidates[0][1]
trigger = utils.FindFirstMatch(croppedInput, `trigger:([\w_$]+)`)[1]
target = utils.FindFirstMatch(croppedInput, `triggerRef:([\w_$]+)`)[1]
}

utils.Replace(&input, `\(0,([\w_$]+)\.jsx\)\([\w_$]+\.[\w_$]+,\{value:"contextmenu"[^\}]+\}\)\}\)`, `${1}.jsx((Spicetify.ContextMenuV2._context||(Spicetify.ContextMenuV2._context=`+react+`.createContext(null))).Provider,{value:{props:`+menu+`?.props,trigger:`+trigger+`,target:`+target+`},children:${0}})`)
utils.Replace(&input, `\(0,([\w_$]+)\.jsx\)\([\w_$]+\.[\w_$]+,\{value:"contextmenu"[^\}]+\}\)\}\)`, `(0,${1}.jsx)((Spicetify.ContextMenuV2._context||(Spicetify.ContextMenuV2._context=`+react+`.createContext(null))).Provider,{value:{props:`+menu+`?.props,trigger:`+trigger+`,target:`+target+`},children:${0}})`)

return input
}
Expand Down

0 comments on commit aaee254

Please sign in to comment.