Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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/*"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions crates/webview/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
6 changes: 3 additions & 3 deletions crates/webview/src/browser_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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, &params, window, cx),
Expand Down
9 changes: 5 additions & 4 deletions crates/webview/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*};
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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),
);
Expand Down
3 changes: 2 additions & 1 deletion crates/webview/src/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -114,7 +115,7 @@ impl WebView {
_cx: &mut Context<Self>,
) {
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(
Expand Down
2 changes: 1 addition & 1 deletion crates/wef/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions examples/wef-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"