diff --git a/Cargo.lock b/Cargo.lock index 5acdf13..a45166f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,17 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.8", - "once_cell", - "version_check", -] +version = 4 [[package]] name = "aho-corasick" @@ -22,6 +11,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -39,7 +34,7 @@ checksum = "677d1d8ab452a3936018a687b20e6f7cf5363d713b732b8884001317b0e48aa3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -77,6 +72,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" + [[package]] name = "bumpalo" version = "3.11.1" @@ -106,11 +107,11 @@ dependencies = [ "cached_proc_macro", "cached_proc_macro_types", "futures", - "hashbrown", + "hashbrown 0.12.3", "instant", "lazy_static", "once_cell", - "thiserror", + "thiserror 1.0.38", "tokio", ] @@ -123,7 +124,7 @@ dependencies = [ "cached_proc_macro_types", "darling 0.13.4", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -164,7 +165,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_derive", "clap_lex", "indexmap", @@ -184,7 +185,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -269,7 +270,24 @@ dependencies = [ "proc-macro2", "quote", "smallvec", - "syn", + "syn 1.0.103", +] + +[[package]] +name = "cssparser" +version = "0.29.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93d03419cb5950ccfd3daf3ff1c7a36ace64609a1a8746d493df1ca0afde0fa" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa 1.0.4", + "matches", + "phf 0.10.1", + "proc-macro2", + "quote", + "smallvec", + "syn 1.0.103", ] [[package]] @@ -279,7 +297,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfae75de57f2b2e85e8768c3ea840fd159c8f33e2b6522c7835b7abac81be16e" dependencies = [ "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -306,7 +324,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.103", ] [[package]] @@ -323,7 +341,7 @@ checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -357,7 +375,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 1.0.103", ] [[package]] @@ -371,7 +389,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 1.0.103", ] [[package]] @@ -382,7 +400,7 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core 0.13.4", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -393,7 +411,7 @@ checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" dependencies = [ "darling_core 0.14.2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -412,7 +430,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.103", ] [[package]] @@ -464,6 +482,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "fastrand" version = "1.8.0" @@ -490,6 +514,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" + [[package]] name = "foreign-types" version = "0.3.2" @@ -580,7 +610,7 @@ checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -677,8 +707,16 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ - "ahash", + "allocator-api2", + "equivalent", + "foldhash", ] [[package]] @@ -713,7 +751,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -851,7 +889,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", "serde", ] @@ -909,12 +947,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" version = "0.2.137" @@ -951,21 +983,19 @@ dependencies = [ [[package]] name = "lol_html" -version = "0.3.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16d7d17063591adf0017a068a8ce2ed29a4f5402b9e6cac01888ff9c0527ff7" +checksum = "3b1058123f6262982b891dccc395cff0144d9439de366460b47fab719258b96e" dependencies = [ - "bitflags", + "bitflags 2.8.0", "cfg-if", - "cssparser", + "cssparser 0.29.6", "encoding_rs", - "hashbrown", - "lazy_static", - "lazycell", + "hashbrown 0.15.2", "memchr", - "safemem", - "selectors", - "thiserror", + "mime", + "selectors 0.24.0", + "thiserror 2.0.11", ] [[package]] @@ -1105,7 +1135,7 @@ version = "0.10.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "foreign-types", "libc", @@ -1122,7 +1152,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1185,7 +1215,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" dependencies = [ - "phf_macros", + "phf_macros 0.8.0", "phf_shared 0.8.0", "proc-macro-hack", ] @@ -1196,7 +1226,9 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" dependencies = [ + "phf_macros 0.10.0", "phf_shared 0.10.0", + "proc-macro-hack", ] [[package]] @@ -1250,7 +1282,21 @@ dependencies = [ "proc-macro-hack", "proc-macro2", "quote", - "syn", + "syn 1.0.103", +] + +[[package]] +name = "phf_macros" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn 1.0.103", ] [[package]] @@ -1310,7 +1356,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.103", "version_check", ] @@ -1333,9 +1379,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -1364,9 +1410,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.21" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -1467,7 +1513,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1595,12 +1641,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - [[package]] name = "schannel" version = "0.1.20" @@ -1623,12 +1663,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5684396b456f3eb69ceeb34d1b5cb1a2f6acf7ca4452131efa3ba0ee2c2d0a70" dependencies = [ - "cssparser", + "cssparser 0.27.2", "ego-tree", "getopts", "html5ever", "matches", - "selectors", + "selectors 0.22.0", "smallvec", "tendril", ] @@ -1645,7 +1685,7 @@ version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -1668,8 +1708,8 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe" dependencies = [ - "bitflags", - "cssparser", + "bitflags 1.3.2", + "cssparser 0.27.2", "derive_more", "fxhash", "log", @@ -1677,11 +1717,29 @@ dependencies = [ "phf 0.8.0", "phf_codegen 0.8.0", "precomputed-hash", - "servo_arc", + "servo_arc 0.1.1", "smallvec", "thin-slice", ] +[[package]] +name = "selectors" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c37578180969d00692904465fb7f6b3d50b9a2b952b87c23d0e2e5cb5013416" +dependencies = [ + "bitflags 1.3.2", + "cssparser 0.29.6", + "derive_more", + "fxhash", + "log", + "phf 0.8.0", + "phf_codegen 0.8.0", + "precomputed-hash", + "servo_arc 0.2.0", + "smallvec", +] + [[package]] name = "semver" version = "1.0.14" @@ -1705,7 +1763,7 @@ checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1756,7 +1814,7 @@ dependencies = [ "darling 0.14.2", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1769,6 +1827,16 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "servo_arc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52aa42f8fdf0fed91e5ce7f23d8138441002fa31dca008acf47e6fd4721f741" +dependencies = [ + "nodrop", + "stable_deref_trait", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -1889,6 +1957,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tempfile" version = "3.3.0" @@ -1941,7 +2020,16 @@ version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.38", +] + +[[package]] +name = "thiserror" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +dependencies = [ + "thiserror-impl 2.0.11", ] [[package]] @@ -1952,7 +2040,18 @@ checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", ] [[package]] @@ -2007,7 +2106,7 @@ dependencies = [ "log", "regex", "serde_json", - "thiserror", + "thiserror 1.0.38", "url", ] @@ -2039,7 +2138,7 @@ checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2207,7 +2306,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.103", "wasm-bindgen-shared", ] @@ -2241,7 +2340,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index 9282eba..715a4d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ serde = { version = "1.0", features = ["derive", "rc"] } serde_json = "1.0" futures = "0.3.25" tldextract = "0.6.0" -lol_html = "0.3.2" +lol_html = "2.2.0" [target.'cfg(target_arch = "wasm32")'.dependencies] reqwest = { package = "reqwest-wasm", version = "0.11.16", features = [ diff --git a/src/html_parser/head.rs b/src/html_parser/head.rs index 075b938..626b32f 100644 --- a/src/html_parser/head.rs +++ b/src/html_parser/head.rs @@ -6,7 +6,13 @@ use futures::future::join_all; use futures::FutureExt; use futures::Stream; use futures::StreamExt; -use lol_html::{element, errors::RewritingError, HtmlRewriter, Settings}; +use lol_html::{ + element, + errors::RewritingError, + send::{HtmlRewriter, Settings}, +}; +use std::sync::Arc; +use std::sync::Mutex; use std::{ cell::RefCell, error::Error, @@ -30,14 +36,15 @@ pub async fn parse_head( mut body: impl Stream, String>> + Unpin, ) -> Result, Box> { let mut icons = Vec::new(); - let new_icons = RefCell::new(Vec::new()); + let new_icons = Arc::new(Mutex::new(Vec::new())); { let mut rewriter = HtmlRewriter::new( Settings { element_content_handlers: vec![ element!("head", |head| { - head.on_end_tag(|_| Err(Box::new(EndOfHead {})))?; + let c: lol_html::send::EndTagHandler = Box::new(|_| Err(Box::new(EndOfHead {}))); + head.end_tag_handlers().unwrap().push(c); Ok(()) }), element!("link[rel~='manifest']", |manifest| { @@ -45,9 +52,9 @@ pub async fn parse_head( .get_attribute("href") .and_then(|href| url.join(&href).ok()) { - new_icons.borrow_mut().push( + new_icons.lock().unwrap().push( async { SiteIcons::load_manifest(href).await.unwrap_or(Vec::new()) } - .boxed_local() + .boxed() .shared(), ) } @@ -76,14 +83,14 @@ pub async fn parse_head( let sizes = link.get_attribute("sizes"); - new_icons.borrow_mut().push( + new_icons.lock().unwrap().push( async { Icon::load(href, kind, sizes) .await .map(|icon| vec![icon]) .unwrap_or(Vec::new()) } - .boxed_local() + .boxed() .shared(), ) }; @@ -92,7 +99,7 @@ pub async fn parse_head( } ), ], - ..Settings::default() + ..Settings::new_send() }, |_: &[u8]| {}, ); @@ -100,7 +107,7 @@ pub async fn parse_head( while let Some(data) = poll_in_background(body.next(), join_all(icons.clone())).await { let result = rewriter.write(&data?); - icons.extend(new_icons.borrow_mut().drain(..)); + icons.extend(new_icons.lock().unwrap().drain(..)); match result { Err(RewritingError::ContentHandlerError(result)) => { diff --git a/src/icon/icon_info.rs b/src/icon/icon_info.rs index 50ab597..6ec4f06 100644 --- a/src/icon/icon_info.rs +++ b/src/icon/icon_info.rs @@ -76,7 +76,7 @@ impl IconInfo { ) -> Result> { let sizes = sizes.as_ref().and_then(|s| IconSizes::try_from(s).ok()); - let (mime, mut body): (_, Box) = match url.scheme() { + let (mime, mut body): (_, Box) = match url.scheme() { "data" => { let url = url.to_string(); let url = DataUrl::process(&url).map_err(|_| "failed to parse data uri")?; diff --git a/src/icons.rs b/src/icons.rs index df05595..4044ae9 100644 --- a/src/icons.rs +++ b/src/icons.rs @@ -91,7 +91,7 @@ impl SiteIcons { None => None, }) } - .boxed_local(), + .boxed(), async { let html_response = html_response.clone().await;