Compact mains supply & wifi

I have to design a board that fits inside a 4x2 inches wall box and is powered directly from mains (110-220) and has wifi capabilities

As for power supply, I'm concerned for space as I probably can't fit a transformer there. Is there other mains->5v design I could look for? (I'm not THAT skilled on electronics). I know cell phone chargers do that on a pretty compact way.

I've seen this guy here that seems to do what I need, but is on end of life https://www.digikey.com/product-detail/en/BP5063-5/BP5063-5-ND/658569

As for wifi I would probably go with ESP8266, my concern is: Would wifi work well being so close to the AC circuitry?

(deleted)

spycatcher2k:
Then DON'T go near mains!!! :o

Thanks and I understand your concern :grinning:
In fact, I'm pretty confortable with working on the mains... Most of the work on my house I do by myself, and I'm capable enought to not put fire on anything, I'm just not skilled enough to know power supply designs and project one from scratch without guidance

(deleted)