#pragma once #include #include #include #include #include // CaptureWorker: Napi::AsyncWorker subclass implementing DWM shared surface capture. // Uses DwmGetDxSharedSurface (the same API used by OBS and AHK) for // flicker-free, occlusion-immune window capture without yellow borders. // Runs on libuv worker thread (per D-15). Returns PNG buffer via Promise. class CaptureWorker : public Napi::AsyncWorker { public: CaptureWorker(Napi::Env env, HWND hwnd, Microsoft::WRL::ComPtr device, Microsoft::WRL::ComPtr context); Napi::Promise GetPromise(); void Execute() override; void OnOK() override; void OnError(const Napi::Error& error) override; private: HWND hwnd_; Microsoft::WRL::ComPtr device_; Microsoft::WRL::ComPtr context_; Napi::Promise::Deferred deferred_; std::vector pngData_; };