Can't access plugin dimensions or use resize event properly in InDesign

In Photoshop, I’m able to use window.addEventListener('resize', ...) to detect when the plugin panel is resized, and I can access the updated width and height to recalculate styles accordingly.

However, in InDesign, window.addEventListener('resize') doesn’t seem to work at all. I noticed that document.addEventListener('resize') does fire when the panel is resized, but whenever I try to read the plugin’s width or height, the values are always 0 or undefined.

Is there a recommended way to detect panel resizing and retrieve its dimensions in InDesign UXP?