@@ -561,20 +561,11 @@ func exposeAPIs_main(input string) string {
561
561
return fmt .Sprintf ("%s[Spicetify.ContextMenuV2.renderItems(),%s].flat()" , submatches [1 ], submatches [2 ])
562
562
})
563
563
564
- croppedInput := utils .FindFirstMatch (input , `\({menu:[^,]+,.*?triggerRef:[^,]+,[^}]*}\).*value:"contextmenu"` )[0 ]
565
-
566
- reactRef := utils .FindFirstMatch (croppedInput , `([\w_$]+)\.useRef` )
567
- var react , menu , trigger , target string
568
- if len (reactRef ) == 1 {
569
- react = reactRef [0 ]
570
- } else {
571
- react = reactRef [1 ]
572
- }
573
-
574
- menuCandidates := utils .FindMatch (croppedInput , `menu:([\w_$]+)` )
575
- menu = menuCandidates [0 ][1 ]
576
- trigger = utils .FindFirstMatch (croppedInput , `trigger:([\w_$]+)` )[1 ]
577
- target = utils .FindFirstMatch (croppedInput , `triggerRef:([\w_$]+)` )[1 ]
564
+ croppedInput := utils .FindFirstMatch (input , `.*value:"contextmenu"` )[0 ]
565
+ react := utils .FindLastMatch (croppedInput , `([a-zA-Z_\$][\w\$]*)\.useRef` )[1 ]
566
+ menu := utils .FindLastMatch (croppedInput , `menu:([\w_$]+)` )[1 ]
567
+ trigger := utils .FindLastMatch (croppedInput , `trigger:([\w_$]+)` )[1 ]
568
+ target := utils .FindLastMatch (croppedInput , `triggerRef:([\w_$]+)` )[1 ]
578
569
579
570
utils .Replace (& input , `\(0,([\w_$]+)\.jsx\)\([\w_$]+\.[\w_$]+,\{value:"contextmenu"[^\}]+\}\)\}\)` , func (submatches ... string ) string {
580
571
return fmt .Sprintf ("(0,%s.jsx)((Spicetify.ContextMenuV2._context||(Spicetify.ContextMenuV2._context=%s.createContext(null))).Provider,{value:{props:%s?.props,trigger:%s,target:%s},children:%s})" , submatches [1 ], react , menu , trigger , target , submatches [0 ])
0 commit comments