@@ -561,25 +561,22 @@ 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 , `"context-menu".*value:"contextmenu"` )[0 ]
564
+ croppedInput := utils .FindFirstMatch (input , `\({menu:[^,]+,.*?triggerRef:[^,]+,[^}]*}\).*value:"contextmenu"` )[0 ]
565
+ fmt .Println (croppedInput )
565
566
566
- react := utils .FindFirstMatch (croppedInput , `([\w_$]+)\.useRef` )[1 ]
567
- var menu string
568
- var trigger string
569
- var target string
570
-
571
- menuCandidates := utils .FindMatch (croppedInput , `menu:([\w_$]+)` )
572
- if len (menuCandidates ) == 0 {
573
- // v1.2.13 fix
574
- menu = utils .FindFirstMatch (croppedInput , `([\w_$]+)=[\w_$]+\.menu,` )[1 ]
575
- trigger = utils .FindFirstMatch (croppedInput , `([\w_$]+)=[\w_$]+\.trigger,` )[1 ]
576
- target = utils .FindFirstMatch (croppedInput , `([\w_$]+)=[\w_$]+\.triggerRef,` )[1 ]
567
+ reactRef := utils .FindFirstMatch (croppedInput , `([\w_$]+)\.useRef` )
568
+ var react , menu , trigger , target string
569
+ if len (reactRef ) == 1 {
570
+ react = reactRef [0 ]
577
571
} else {
578
- menu = menuCandidates [0 ][1 ]
579
- trigger = utils .FindFirstMatch (croppedInput , `trigger:([\w_$]+)` )[1 ]
580
- target = utils .FindFirstMatch (croppedInput , `triggerRef:([\w_$]+)` )[1 ]
572
+ react = reactRef [1 ]
581
573
}
582
574
575
+ menuCandidates := utils .FindMatch (croppedInput , `menu:([\w_$]+)` )
576
+ menu = menuCandidates [0 ][1 ]
577
+ trigger = utils .FindFirstMatch (croppedInput , `trigger:([\w_$]+)` )[1 ]
578
+ target = utils .FindFirstMatch (croppedInput , `triggerRef:([\w_$]+)` )[1 ]
579
+
583
580
utils .Replace (& input , `\(0,([\w_$]+)\.jsx\)\([\w_$]+\.[\w_$]+,\{value:"contextmenu"[^\}]+\}\)\}\)` , func (submatches ... string ) string {
584
581
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 ])
585
582
})
0 commit comments