Thank you all! Tons of great ideas, now I scratch my head and thinking on how to get them into a simple API. Here is what I think virtual display API should look like: https://github.com/pavlobu/deskreen/tree/master/drivers
Btw, deskreen has been shared enough times now to become popular on "TypeScript LibHunt" too https://www.libhunt.com/lang/typescript (disclosure: LibHunt founder).
Definitely seems like a helpful project. The stars on GitHub have jumped from 1 to 1,900+ in just one week! Enjoy the ride and thanks for open-sourcing your work.
Since android 10 and its desktop mode would be nice to have virtual displays there as well. On rooted phones it shouldn't be hard to get such a driver into a kernel. Android distros like LineageOS would be probably more than happy to incorporate such a solution.
Another thing is Linux, drivers for virtual screen already exist, check xvfb and xorg-video-dummy