AC switch & power supply reverse engineering
This circuit actually has two separate power supplies.

The transformer is a current transformer, and it, along with the bridge rectifier (D1, D2, D5, D6), supplies power to the circuit when the main triac is switched on, making use of the load current to do so. D3 and D4 serve to limit the voltage across the primary side of this transformer, mainly bypassing any high-frequency transients that the inductance of the transformer would block.

However, when the main triac is off (no load current), this transformer does not supply any energy to the control circuit, so a second power supply based on C1, R4 and D8 uses "leakage current" (limited by the impedance of C1) to keep the circuit alive. But this supply can't work when the main triac is on, since there isn't enough voltage drop to drive significant current through C1.

Filter compontents C3 C4, D7 and L1 are common to both power supplies.