Shopify Theme App Extension, variants and thumbnails interaction

I’m developing a Shopify Theme App Extension and need a robust solution that allows consistent interaction with product variants across any theme being used by the store. Specifically, I need help with:

  1. Capturing variant selection events: I want to ensure that, regardless of the active theme, I can capture the event when a product variant is selected and trigger actions based on that selection.

  2. Adding thumbnail images: I need to programmatically add thumbnail images associated with variants or products. Ideally, I would prefer doing this through an API to maintain flexibility and compatibility across different themes.

Since this solution is built as a Shopify Theme App Extension, it’s important that it works seamlessly with any Shopify theme, without depending on theme-specific code.

What’s the best approach to implement this functionality in a reliable and scalable way? Any guidance or examples would be greatly appreciated!