In the next version of Bun
— Jarred Sumner (@jarredsumner) March 18, 2026
`Bun.WebView` programmatically controls a headless web browser in Bun pic.twitter.com/Yp8UiNoeoy
it’s a real WKWebView on macOS
— Jarred Sumner (@jarredsumner) March 18, 2026
haven’t implemented it yet on Linux or Windows. It’ll be Chrome for those, but not exactly sure how it’ll be done yet. The obvious way is CDP, but then it’s not really a WebView.
also: this involved lots of reverse-engineering to make the browser think it’s not headless.
— Jarred Sumner (@jarredsumner) March 18, 2026
so that visibilityState reports visible. requestAnimationFrame runs. CSS animations run. so it looks/feels externally like the an actual browser
AI 中文摘要Claude 生成
Bun 的下一版本將推出「Bun.WebView」功能,讓使用者能在 Bun 中以程式方式控制無頭網路瀏覽器。在 macOS 上,這個實現使用真正的 WKWebView;Linux 和 Windows 版本的實現方案仍未敲定,可能採用 Chrome,但開發團隊對於具體作法還不確定。若採用 CDP(Chrome DevTools Protocol),則無法真正稱之為 WebView。
實現這項功能需要大量逆向工程,使瀏覽器認為自己並非無頭模式。具體而言,必須讓 visibilityState 報告為可見狀態,使 requestAnimationFrame 能正常執行,CSS 動畫能順利運行,最終看起來和表現得像真正的瀏覽器一樣。這說明 Bun 團隊為了讓無頭瀏覽器的行為更接近實際瀏覽器,投入了相當深入的技術工作。
