From fb1a538854be0e1f049b6d355f5cfcfa88e2de9a Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 16 Oct 2025 10:07:10 +0800 Subject: [PATCH 1/3] chore: Update GPUI, GPUI Component deps and add note to README. --- Cargo.toml | 8 -------- README.md | 7 +++++++ crates/webview/Cargo.toml | 4 ++-- crates/webview/src/browser_handler.rs | 6 +++--- crates/webview/src/element.rs | 9 +++++---- crates/webview/src/webview.rs | 3 ++- examples/wef-example/Cargo.toml | 4 ++-- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ba3b6c0..bc65a74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,21 +13,16 @@ resolver = "2" [workspace.dependencies] wef = { path = "crates/wef" } gpui-webview = { path = "crates/webview" } -ropey = { version = "=2.0.0-beta.1", features = ["metric_utf16", "metric_lines_lf"] } anyhow = "1" log = "0.4" serde = { version = "1.0.219", features = ["derive"] } -serde_repr = "0.1" serde_json = "1" -schemars = "1" smallvec = "1" -rust-i18n = "3" raw-window-handle = "0.6.2" smol = "1" tracing = "0.1.41" notify = "7.0.0" -lsp-types = "0.97.0" [workspace.dependencies.windows] features = ["Wdk", "Wdk_System", "Wdk_System_SystemServices"] @@ -59,6 +54,3 @@ split-debuginfo = "unpacked" image = { opt-level = 3 } png = { opt-level = 3 } reqwest = { opt-level = 3 } - -[workspace.metadata.typos] -files.extend-exclude = ["**/fixtures/*"] \ No newline at end of file diff --git a/README.md b/README.md index 5a88b1e..7dc5916 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ > Web Embedding Framework +> [!WARNING] +> This is an experimental project, we was tried to build a offscreen rendering WebView for solve GPUI render level issues in game engine, but there still not good enough. +> +> For example, the app size (included a CEF Framework increase 1GB), development experience, etc. +> +> So, we are still use [Wry](https://github.com/longbridge/gpui-component/blob/main/crates/ui/src/webview.rs) in [Longbridge](https://longbridge.com/desktop) desktop app for now. + ![CI](https://github.com/longbridge/wef/workflows/CI/badge.svg) [![Crates.io](https://img.shields.io/crates/v/wef.svg)](https://crates.io/crates/wef) [![Documentation](https://docs.rs/wef/badge.svg)](https://docs.rs/wef) diff --git a/crates/webview/Cargo.toml b/crates/webview/Cargo.toml index 1e84371..61b21fe 100644 --- a/crates/webview/Cargo.toml +++ b/crates/webview/Cargo.toml @@ -8,8 +8,8 @@ homepage = "https://github.com/longbridge/wef" repository = "https://github.com/longbridge/wef" [dependencies] -gpui-component = { git = "https://github.com/longbridge/gpui-component.git" } -gpui = { git = "https://github.com/zed-industries/zed.git" } +gpui-component = "0.2.0" +gpui = "0.2.0" wef = { path = "../wef" } schemars = "1" serde = { version = "1.0.219", features = ["derive"] } diff --git a/crates/webview/src/browser_handler.rs b/crates/webview/src/browser_handler.rs index be69234..0ae7ae6 100644 --- a/crates/webview/src/browser_handler.rs +++ b/crates/webview/src/browser_handler.rs @@ -2,7 +2,7 @@ use std::{rc::Rc, sync::Arc}; use gpui::{AnyWindowHandle, AppContext, AsyncApp, ParentElement, RenderImage, Styled, WeakEntity}; use gpui_component::{ - ContextModal, + ContextModal, PixelsExt, input::{InputState, TextInput}, v_flex, }; @@ -236,8 +236,8 @@ impl BrowserHandler for WebViewHandler { cx.update_entity(&entity, |webview, cx| { webview.context_menu = Some(ContextMenuInfo { crood: Point::new( - LogicalUnit(params.crood.x.0 + webview.bounds.origin.x.0 as i32), - LogicalUnit(params.crood.y.0 + webview.bounds.origin.y.0 as i32), + LogicalUnit(params.crood.x.0 + webview.bounds.origin.x.as_f32() as i32), + LogicalUnit(params.crood.y.0 + webview.bounds.origin.y.as_f32() as i32), ), frame, menu: build_context_menu(webview, ¶ms, window, cx), diff --git a/crates/webview/src/element.rs b/crates/webview/src/element.rs index 6ff4ad7..6df5f5f 100644 --- a/crates/webview/src/element.rs +++ b/crates/webview/src/element.rs @@ -6,6 +6,7 @@ use gpui::{ IntoElement, LayoutId, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, RenderImage, Size, StyleRefinement, Styled, Window, hsla, point, px, size, }; +use gpui_component::PixelsExt; use wef::{Browser, LogicalUnit, Rect}; use crate::{WebView, utils::*}; @@ -138,8 +139,8 @@ impl Element for WebViewElement { |_, window, _cx| { let scale_factor = window.scale_factor(); self.browser.resize(wef::Size::new( - wef::PhysicalUnit((bounds.size.width.0 * scale_factor) as i32), - wef::PhysicalUnit((bounds.size.height.0 * scale_factor) as i32), + wef::PhysicalUnit((bounds.size.width.as_f32() * scale_factor) as i32), + wef::PhysicalUnit((bounds.size.height.as_f32() * scale_factor) as i32), )); let image_size = self.view_image.size(0); @@ -197,8 +198,8 @@ impl Element for WebViewElement { let position = event.position - bounds.origin; webview.browser().send_mouse_move_event( wef::Point::new( - wef::LogicalUnit(position.x.0 as i32), - wef::LogicalUnit(position.y.0 as i32), + wef::LogicalUnit(position.x.as_f32() as i32), + wef::LogicalUnit(position.y.as_f32() as i32), ), to_wef_key_modifiers(&event.modifiers), ); diff --git a/crates/webview/src/webview.rs b/crates/webview/src/webview.rs index 95401a6..4f658ac 100644 --- a/crates/webview/src/webview.rs +++ b/crates/webview/src/webview.rs @@ -6,6 +6,7 @@ use gpui::{ Subscription, UTF16Selection, WeakEntity, Window, anchored, deferred, div, point, prelude::*, px, }; +use gpui_component::PixelsExt; use wef::{Browser, FuncRegistry, LogicalUnit, Point, Rect}; use crate::{ @@ -114,7 +115,7 @@ impl WebView { _cx: &mut Context, ) { let (delta_x, delta_y) = match event.delta { - gpui::ScrollDelta::Pixels(point) => (point.x.0, point.y.0), + gpui::ScrollDelta::Pixels(point) => (point.x.as_f32(), point.y.as_f32()), gpui::ScrollDelta::Lines(point) => (point.x * 20.0, point.y * 20.0), }; self.browser().send_mouse_wheel_event(Point::new( diff --git a/examples/wef-example/Cargo.toml b/examples/wef-example/Cargo.toml index 60de6c2..abfae88 100644 --- a/examples/wef-example/Cargo.toml +++ b/examples/wef-example/Cargo.toml @@ -9,8 +9,8 @@ embed-manifest = "1.4.0" [dependencies] wef = { path = "../../crates/wef" } gpui-webview = { path = "../../crates/webview" } -gpui-component = { git = "https://github.com/longbridge/gpui-component.git" } -gpui = { git = "https://github.com/zed-industries/zed.git" } +gpui-component = "0.2.0" +gpui = "0.2.0" futures-util = "0.3.31" serde = { version = "1.0.219", features = ["derive"] } flume = "0.11.1" From c82b34721cb203ed999fa5aa28989c3e2e5cbe1d Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 16 Oct 2025 10:12:22 +0800 Subject: [PATCH 2/3] . --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6801213..6af0746 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,12 +3,16 @@ on: pull_request: push: branches: - - "*" + - main tags: - "*" env: CEF_VERSION: "136.1.6+g1ac1b14+chromium-136.0.7103.114" +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }} + cancel-in-progress: true + jobs: test: name: Test From 327195c69dbd6be47d71157bb685b920784ae656 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 16 Oct 2025 10:18:37 +0800 Subject: [PATCH 3/3] typo --- crates/wef/src/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wef/src/builder.rs b/crates/wef/src/builder.rs index 025ad22..08099f7 100644 --- a/crates/wef/src/builder.rs +++ b/crates/wef/src/builder.rs @@ -115,7 +115,7 @@ where } } - /// Cosumes the builder and creates a [`Browser`] instance. + /// Consumes the builder and creates a [`Browser`] instance. /// /// The creation of the browser is asynchronous, and the /// [`BrowserHandler::on_created`] method will be called upon completion.