Skip to content

Commit

Permalink
Remove ureq dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Dec 16, 2024
1 parent c75bf78 commit f2bc20f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ http = "1.1.0"
data-url = "0.3.1"
tokio = "1.42"
reqwest = "0.12"
ureq = "2.9"

# Media & Decoding
image = { version = "0.25", default-features = false, features = ["jpeg", "png", "gif", "webp"] }
Expand Down Expand Up @@ -122,7 +121,6 @@ dioxus = { workspace = true }
euclid = { workspace = true }
reqwest = { workspace = true }
tokio = { workspace = true, features = ["macros"] }
ureq = { workspace = true }
image = { workspace = true }
png = "0.17"
env_logger = "0.11"
Expand Down
2 changes: 1 addition & 1 deletion packages/blitz-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ accesskit_winit = {workspace = true, optional = true }
# IO & Networking
url = { workspace = true, features = ["serde"] }
tokio = { workspace = true, features = ["rt-multi-thread"] }
ureq = { workspace = true }
reqwest = { workspace = true }

# Other dependencies
tracing = { workspace = true, optional = true }
Expand Down
32 changes: 26 additions & 6 deletions packages/blitz-shell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ use blitz_dom::net::Resource;
use blitz_html::HtmlDocument;
use blitz_net::Provider;
use blitz_traits::net::{NetCallback, SharedCallback};
use reqwest::Client;
use std::sync::Arc;
use tokio::runtime::Runtime;
use url::Url;
use winit::event_loop::EventLoopProxy;
use winit::event_loop::{ControlFlow, EventLoop};
Expand Down Expand Up @@ -62,15 +64,29 @@ pub fn launch_url(url: &str) {
let url = url.to_owned();
Url::parse(&url).expect("Invalid url");

let html = ureq::get(&url)
.set("User-Agent", USER_AGENT)
.call()
.unwrap()
.into_string()
// Turn on the runtime and enter it
let rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap();
let _guard = rt.enter();

launch_static_html_cfg(
let client = Client::new();
let html = rt.block_on(async {
client
.get(&url)
.header("User-Agent", USER_AGENT)
.send()
.await
.unwrap()
.text()
.await
.unwrap()
});

launch_internal(
&html,
rt,
Config {
stylesheets: Vec::new(),
base_url: Some(url),
Expand All @@ -90,6 +106,10 @@ pub fn launch_static_html_cfg(html: &str, cfg: Config) {
.unwrap();
let _guard = rt.enter();

launch_internal(html, rt, cfg)
}

fn launch_internal(html: &str, rt: Runtime, cfg: Config) {
let event_loop = create_default_event_loop::<BlitzEvent>();
let proxy = event_loop.create_proxy();

Expand Down

0 comments on commit f2bc20f

Please sign in to comment.