webview: Let webview as a feature and not default enable. (#648)
Close #646
This commit is contained in:
parent
d54dcdf417
commit
9dade704fb
6 changed files with 50 additions and 3 deletions
|
|
@ -7,7 +7,6 @@ resolver = "2"
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
gpui-component = { path = "crates/ui" }
|
gpui-component = { path = "crates/ui" }
|
||||||
story = { path = "crates/story" }
|
story = { path = "crates/story" }
|
||||||
|
|
||||||
gpui = { git = "https://github.com/huacnlee/zed.git", branch = "webview" }
|
gpui = { git = "https://github.com/huacnlee/zed.git", branch = "webview" }
|
||||||
|
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,14 @@ gpui = { git = "https://github.com/huacnlee/zed.git", branch = "webview" }
|
||||||
gpui-component = { git = "https://github.com/longbridge/gpui-component.git" }
|
gpui-component = { git = "https://github.com/longbridge/gpui-component.git" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### WebView
|
||||||
|
|
||||||
|
GPUI Component have `WebView` element based on [Wry](https://github.com/tauri-apps/wry), this is an optional feature, you can enable it by feature flag.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
gpui-component = { git = "https://github.com/longbridge/gpui-component.git", features = ["webview"] }
|
||||||
|
```
|
||||||
|
|
||||||
More usage can be found in [story](https://github.com/longbridge/gpui-component/tree/main/crates/story) directory.
|
More usage can be found in [story](https://github.com/longbridge/gpui-component/tree/main/crates/story) directory.
|
||||||
|
|
||||||
### Icons
|
### Icons
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ charts-rs = "0.3"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
fake = { version = "2.10.0", features = ["dummy"] }
|
fake = { version = "2.10.0", features = ["dummy"] }
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
gpui-component.workspace = true
|
gpui-component = { workspace = true, features = ["webview"] }
|
||||||
reqwest_client = { git = "https://github.com/huacnlee/zed.git", branch = "webview" }
|
reqwest_client = { git = "https://github.com/huacnlee/zed.git", branch = "webview" }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
|
|
|
||||||
35
crates/story/examples/webview.rs
Normal file
35
crates/story/examples/webview.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
use gpui::*;
|
||||||
|
use story::{Assets, WebViewStory};
|
||||||
|
|
||||||
|
pub struct Example {
|
||||||
|
root: Entity<WebViewStory>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Example {
|
||||||
|
pub fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||||
|
let root = WebViewStory::view(window, cx);
|
||||||
|
|
||||||
|
Self { root }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn view(window: &mut Window, cx: &mut App) -> Entity<Self> {
|
||||||
|
cx.new(|cx| Self::new(window, cx))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Render for Example {
|
||||||
|
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
|
div().p_4().size_full().child(self.root.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let app = Application::new().with_assets(Assets);
|
||||||
|
|
||||||
|
app.run(move |cx| {
|
||||||
|
story::init(cx);
|
||||||
|
cx.activate(true);
|
||||||
|
|
||||||
|
story::create_new_window("WebView Example", Example::view, cx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,9 @@ keywords = ["ui", "desktop", "application", "GPUI"]
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
|
[features]
|
||||||
|
webview = ["dep:wry"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
|
|
@ -35,7 +38,7 @@ usvg = { version = "0.44.0", default-features = false, features = [
|
||||||
"text",
|
"text",
|
||||||
] }
|
] }
|
||||||
uuid = "1.10"
|
uuid = "1.10"
|
||||||
wry = "0.48.0"
|
wry = { version = "0.48.0", optional = true }
|
||||||
# Markdown Parser
|
# Markdown Parser
|
||||||
markdown = "1.0.0-alpha.22"
|
markdown = "1.0.0-alpha.22"
|
||||||
# HTML Parser
|
# HTML Parser
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,12 @@ pub mod tag;
|
||||||
pub mod text;
|
pub mod text;
|
||||||
pub mod theme;
|
pub mod theme;
|
||||||
pub mod tooltip;
|
pub mod tooltip;
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
pub mod webview;
|
pub mod webview;
|
||||||
|
|
||||||
use gpui::App;
|
use gpui::App;
|
||||||
// re-export
|
// re-export
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
pub use wry;
|
pub use wry;
|
||||||
|
|
||||||
pub use crate::Disableable;
|
pub use crate::Disableable;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue