diff --git a/Cargo.lock b/Cargo.lock index f0948e6..3a995a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "accessibility-rs" -version = "0.0.64" +version = "0.1.3" dependencies = [ "accessibility-scraper", "accessibility-tree", @@ -32,7 +32,7 @@ dependencies = [ [[package]] name = "accessibility-scraper" -version = "0.0.12" +version = "0.0.14" dependencies = [ "ahash", "cssparser 0.27.2", @@ -50,7 +50,7 @@ dependencies = [ [[package]] name = "accessibility-tree" -version = "0.0.12" +version = "0.0.14" dependencies = [ "accessibility-scraper", "atomic_refcell", @@ -1378,9 +1378,9 @@ dependencies = [ [[package]] name = "grid" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d196ffc1627db18a531359249b2bf8416178d84b729f3cebeb278f285fb9b58c" +checksum = "be136d9dacc2a13cc70bb6c8f902b414fb2641f8db1314637c6b7933411a8f82" [[package]] name = "h2" @@ -3540,9 +3540,9 @@ dependencies = [ [[package]] name = "taffy" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ec17858c2d465b2f734b798b920818a974faf0babb15d7fef81818a4b2d16f1" +checksum = "e8b61630cba2afd2c851821add2e1bb1b7851a2436e839ab73b56558b009035e" dependencies = [ "arrayvec", "grid", diff --git a/Cargo.toml b/Cargo.toml index bf32865..59da509 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,6 @@ members = [ smallvec = "1" selectors = "0.22.0" cssparser = "0.27.0" -fast_html5ever = "0.26.1" +fast_html5ever = "0.26.6" ego-tree = "0.6.2" lazy_static = "1.4" \ No newline at end of file diff --git a/README.md b/README.md index d5f2b98..7577b78 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The Rust web accessibility engine. ```toml [dependencies] -accessibility-rs = "^0.0.64" +accessibility-rs = "^0.1.0" ``` ```rs @@ -32,7 +32,7 @@ With the Tokio runtime. ```toml [dependencies] -accessibility-rs = { version = "^0.0.64", features = ["tokio"]} +accessibility-rs = { version = "^0.1.0", features = ["tokio"]} ``` ```rs @@ -60,7 +60,7 @@ With the Spider full website crawling. ```toml [dependencies] -accessibility-rs = { version = "^0.0.64", features = ["spider"]} +accessibility-rs = { version = "^0.1.0", features = ["spider"]} ``` ```rs @@ -87,6 +87,7 @@ async fn main() { 1. i18n support for multiple languages. 1. Re-creating layout tree to get element position coordinates. 1. Crawling full websites lightning-fast using [spider](https://github.com/spider-rs/spider). +1. Low-level built to be used as an engine in browsers. ## [Benchmarks](./benches/) diff --git a/accessibility-rs/Cargo.toml b/accessibility-rs/Cargo.toml index d6272a4..51f6244 100644 --- a/accessibility-rs/Cargo.toml +++ b/accessibility-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "accessibility-rs" -version = "0.0.64" +version = "0.1.3" authors = ["The A11yWatch Project Developers", "Jeff Mendez "] edition = "2021" license = "MIT OR Apache-2.0" @@ -12,11 +12,11 @@ include = ["/src", "../LICENSE_MIT", "../LICENSE_APACHE", "../README.md", "local [dependencies] lazy_static = { workspace = true } -accessibility-scraper = { version = "0.0.12", features = ["main"], default-features = false, path = "../accessibility-scraper" } -accessibility-tree = { version = "0.0.12", path = "../accessibility-tree/victor" } +accessibility-scraper = { version = "0.0.14", features = ["main"], default-features = false, path = "../accessibility-scraper" } +accessibility-tree = { version = "0.0.14", path = "../accessibility-tree/victor" } getrandom = { version = "0.2", features = ["js"] } -taffy = { version = "0.4.0" } -serde = { version = "1.0", features = ["derive"] } +taffy = { version = "0.5" } +serde = { version = "1", features = ["derive"] } selectors = { workspace = true } smallvec = { workspace = true } ego-tree = { workspace = true } @@ -29,7 +29,7 @@ contrast = "0.1" rgb = "0.8" rayon = { version = "1", optional = true } crossbeam-channel = { version = "0.5", optional = true } -tokio = { version = "1", features = ["macros"], optional = true } +tokio = { version = "1", features = ["macros", "rt-multi-thread", "parking_lot"], optional = true } tokio-stream = { version = "0.1", optional = true } spider = { version = "1.98.2", optional = true } diff --git a/accessibility-rs/src/integration_test.rs b/accessibility-rs/src/integration_test.rs index 68d0014..5ca365f 100644 --- a/accessibility-rs/src/integration_test.rs +++ b/accessibility-rs/src/integration_test.rs @@ -6,7 +6,7 @@ use mocks::mock; #[test] fn _audit() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_WEBSITE_HTML, &mock::MOCK_CSS_RULES, false, @@ -17,7 +17,7 @@ fn _audit() { #[test] fn _audit_large() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_HTML_LARGE_PAGE, &mock::MOCK_CSS_RULES_LARGE, false, @@ -28,7 +28,7 @@ fn _audit_large() { #[test] fn _audit_bounded() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_WEBSITE_HTML, &mock::MOCK_CSS_RULES, true, @@ -39,7 +39,7 @@ fn _audit_bounded() { #[test] fn _audit_large_bounded() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_HTML_LARGE_PAGE, &mock::MOCK_CSS_RULES_LARGE, true, diff --git a/accessibility-rs/src/lib.rs b/accessibility-rs/src/lib.rs index 5bf8a7d..81db77a 100644 --- a/accessibility-rs/src/lib.rs +++ b/accessibility-rs/src/lib.rs @@ -61,9 +61,9 @@ pub use spider; pub mod engine; /// locales for translations. pub mod i18n; - use crate::engine::audit::auditor::Auditor; use crate::engine::issue::Issue; +pub use accessibility_scraper; use accessibility_scraper::ElementRef; i18n!("locales", fallback = "en"); @@ -253,7 +253,7 @@ pub async fn audit(config: AuditConfig) -> AuditResults { /// audit a web page passing the html and css rules. #[cfg(not(feature = "tokio"))] -pub fn audit(config: AuditConfig) -> Vec { +pub fn audit(config: &AuditConfig) -> Vec { let document = accessibility_scraper::Html::parse_document(&config.html); let auditor = Auditor::new(&document, &config.css, config.bounding_box, &config.locale); engine::audit::wcag::WCAGAAA::audit(auditor) diff --git a/accessibility-rs/tests/integration_test.rs b/accessibility-rs/tests/integration_test.rs index 56469c9..47023f8 100644 --- a/accessibility-rs/tests/integration_test.rs +++ b/accessibility-rs/tests/integration_test.rs @@ -7,7 +7,7 @@ use mocks::mock; #[cfg(feature = "tokio")] #[tokio::test] async fn _audit() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_WEBSITE_HTML, &mock::MOCK_CSS_RULES, false, @@ -20,7 +20,7 @@ async fn _audit() { #[test] #[cfg(not(feature = "tokio"))] fn _audit() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_WEBSITE_HTML, &mock::MOCK_CSS_RULES, false, @@ -32,7 +32,7 @@ fn _audit() { #[test] #[cfg(not(feature = "tokio"))] fn _audit_large() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_HTML_LARGE_PAGE, &mock::MOCK_CSS_RULES_LARGE, false, @@ -44,7 +44,7 @@ fn _audit_large() { #[test] #[cfg(not(feature = "tokio"))] fn _audit_with_layout() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_WEBSITE_HTML, &mock::MOCK_CSS_RULES, true, @@ -56,7 +56,7 @@ fn _audit_with_layout() { #[test] #[cfg(not(feature = "tokio"))] fn _audit_large_with_layout() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_HTML_LARGE_PAGE, &mock::MOCK_CSS_RULES_LARGE, true, @@ -68,7 +68,7 @@ fn _audit_large_with_layout() { #[test] #[cfg(not(feature = "tokio"))] fn _audit_xlarge() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_WEBSITE_XLARGE_HTML, &mock::MOCK_CSS_RULES_XLARGE, false, @@ -80,7 +80,7 @@ fn _audit_xlarge() { #[tokio::test] #[cfg(feature = "tokio")] async fn _audit_xlarge() { - let report = accessibility_rs::audit(AuditConfig::new( + let report = accessibility_rs::audit(&AuditConfig::new( mock::MOCK_WEBSITE_XLARGE_HTML, &mock::MOCK_CSS_RULES_XLARGE, false, @@ -94,6 +94,6 @@ async fn _audit_xlarge() { #[tokio::test] async fn _audit_website() { let audit_config = AuditConfig::new_website("https://choosealicense.com", "", false, ""); - let report = accessibility_rs::audit(audit_config).await; + let report = accessibility_rs::audit(&audit_config).await; println!("{:?}", report) } diff --git a/accessibility-rs/tests/unit/anchor.rs b/accessibility-rs/tests/unit/anchor.rs index 5cb9360..eda2ccb 100644 --- a/accessibility-rs/tests/unit/anchor.rs +++ b/accessibility-rs/tests/unit/anchor.rs @@ -7,7 +7,7 @@ use maud::html; #[cfg(not(feature = "tokio"))] /// anchor contains single img element without alt fn _audit_missing_alt_anchor_img() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Decrative Img: Do not use! @@ -33,7 +33,7 @@ fn _audit_missing_anchor_content_valid_href() { let markup = html! { a href="www.example.com"; }; - let audit = accessibility_rs::audit(AuditConfig::basic(&markup.into_string())); + let audit = accessibility_rs::audit(&AuditConfig::basic(&markup.into_string())); let valid = !audit .iter() .any(|x| x.code == "WCAGAAA.Principle4.Guideline4_1.H91"); @@ -48,7 +48,7 @@ fn _audit_missing_anchor_content() { let markup = html! { a { "" } }; - let audit = accessibility_rs::audit(AuditConfig::basic(&markup.into_string())); + let audit = accessibility_rs::audit(&AuditConfig::basic(&markup.into_string())); let valid = !audit .iter() .any(|x| x.code == "WCAGAAA.Principle4.Guideline4_1.H91"); @@ -60,7 +60,7 @@ fn _audit_missing_anchor_content() { #[cfg(not(feature = "tokio"))] /// anchor text matches img alt fn _audit_img_alt_matches_text_anchor() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Decrative Img: Do not use! diff --git a/accessibility-rs/tests/unit/applet.rs b/accessibility-rs/tests/unit/applet.rs index a249fa1..cf4e42f 100644 --- a/accessibility-rs/tests/unit/applet.rs +++ b/accessibility-rs/tests/unit/applet.rs @@ -6,7 +6,7 @@ use accessibility_rs::AuditConfig; #[cfg(not(feature = "tokio"))] /// missing applet alt fn _audit_missing_applet_alt() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Missing applet alt: Do not use this! @@ -34,7 +34,7 @@ fn _audit_missing_applet_alt() { #[cfg(not(feature = "tokio"))] /// missing applet body fn _audit_missing_applet_body() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Missing applet alt: Do not use this! diff --git a/accessibility-rs/tests/unit/area.rs b/accessibility-rs/tests/unit/area.rs index ea90eef..8e3df76 100644 --- a/accessibility-rs/tests/unit/area.rs +++ b/accessibility-rs/tests/unit/area.rs @@ -14,7 +14,7 @@ fn _audit_missing_alt_area() { Cup of coffee "#; let audit: Vec = - accessibility_rs::audit(AuditConfig::basic(html)); + accessibility_rs::audit(&AuditConfig::basic(html)); let valid = audit .iter() @@ -35,7 +35,7 @@ fn _audit_missing_alt_map() { Cup of coffee "#; let audit: Vec = - accessibility_rs::audit(AuditConfig::basic(html)); + accessibility_rs::audit(&AuditConfig::basic(html)); let valid = audit.iter().any(|x| x.message == "1_1_1_H24.ImageMapNoAlt"); diff --git a/accessibility-rs/tests/unit/contrast.rs b/accessibility-rs/tests/unit/contrast.rs index 8c879f6..844adb5 100644 --- a/accessibility-rs/tests/unit/contrast.rs +++ b/accessibility-rs/tests/unit/contrast.rs @@ -12,7 +12,7 @@ fn _audit_contrast_text_anchor() { a href="www.example.com" style="color:blue;" { "example" }; } }; - let audit = accessibility_rs::audit(AuditConfig::basic(&markup.into_string())); + let audit = accessibility_rs::audit(&AuditConfig::basic(&markup.into_string())); let valid = !audit .iter() diff --git a/accessibility-rs/tests/unit/fieldset.rs b/accessibility-rs/tests/unit/fieldset.rs index fc8d367..050f4d7 100644 --- a/accessibility-rs/tests/unit/fieldset.rs +++ b/accessibility-rs/tests/unit/fieldset.rs @@ -15,7 +15,7 @@ fn _audit_missing_fieldset_legend() { } }; - let audit = accessibility_rs::audit(AuditConfig::basic(&m.into_string())); + let audit = accessibility_rs::audit(&AuditConfig::basic(&m.into_string())); let valid = !audit .iter() diff --git a/accessibility-rs/tests/unit/heading.rs b/accessibility-rs/tests/unit/heading.rs index 23569ef..679cd9d 100644 --- a/accessibility-rs/tests/unit/heading.rs +++ b/accessibility-rs/tests/unit/heading.rs @@ -6,7 +6,7 @@ use accessibility_rs::AuditConfig; #[cfg(not(feature = "tokio"))] /// empty headings fn _audit_headings_empty() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Valid headings @@ -48,7 +48,7 @@ fn _audit_headings_empty() { assert_eq!(valid, true); - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Do not use missing Headings conent. diff --git a/accessibility-rs/tests/unit/img.rs b/accessibility-rs/tests/unit/img.rs index 59e5cf0..efd0c30 100644 --- a/accessibility-rs/tests/unit/img.rs +++ b/accessibility-rs/tests/unit/img.rs @@ -5,7 +5,7 @@ use accessibility_rs::AuditConfig; #[cfg(not(feature = "tokio"))] /// img is missing an alt fn _audit_img_missing_alt() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Missing Alt: Do not Use. @@ -31,7 +31,7 @@ fn _audit_img_missing_alt() { #[cfg(not(feature = "tokio"))] /// img is missing an alt fn _audit_form_submit_img_missing_alt() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Missing Alt: Do not Use. @@ -60,7 +60,7 @@ fn _audit_form_submit_img_missing_alt() { #[cfg(not(feature = "tokio"))] /// img has empty alt and title fn _audit_form_submit_img_has_alt_and_title() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Contains Title with Alt: Do not Use. diff --git a/accessibility-rs/tests/unit/input.rs b/accessibility-rs/tests/unit/input.rs index 2d8bf39..0fb1526 100644 --- a/accessibility-rs/tests/unit/input.rs +++ b/accessibility-rs/tests/unit/input.rs @@ -5,7 +5,7 @@ use accessibility_rs::AuditConfig; #[cfg(not(feature = "tokio"))] /// input is missing a valid name fn _audit_input_valid_name() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Missing Form control name: Do not Use. diff --git a/accessibility-rs/tests/unit/label.rs b/accessibility-rs/tests/unit/label.rs index 0f140cd..9a00c96 100644 --- a/accessibility-rs/tests/unit/label.rs +++ b/accessibility-rs/tests/unit/label.rs @@ -12,7 +12,7 @@ fn _audit_label_valid_name() { label for="accessibility" { "My label" } }; - let audit = accessibility_rs::audit(AuditConfig::basic(&markup.into_string())); + let audit = accessibility_rs::audit(&AuditConfig::basic(&markup.into_string())); let valid = !audit .iter() @@ -30,7 +30,7 @@ fn _audit_label_id_noexist() { input type="text" placeholder="Accessibility rocks!" value="Here"; }; - let audit = accessibility_rs::audit(AuditConfig::basic(&markup.into_string())); + let audit = accessibility_rs::audit(&AuditConfig::basic(&markup.into_string())); let valid = !audit .iter() diff --git a/accessibility-rs/tests/unit/meta.rs b/accessibility-rs/tests/unit/meta.rs index 0947015..cebe643 100644 --- a/accessibility-rs/tests/unit/meta.rs +++ b/accessibility-rs/tests/unit/meta.rs @@ -8,7 +8,7 @@ use crate::mocks::mock; #[cfg(not(feature = "tokio"))] /// missing title element fn _audit_missing_title() { - let audit = accessibility_rs::audit(AuditConfig::basic(mock::MOCK_WEBSITE_HTML)); + let audit = accessibility_rs::audit(&AuditConfig::basic(mock::MOCK_WEBSITE_HTML)); let mut valid = true; for x in &audit { @@ -25,7 +25,7 @@ fn _audit_missing_title() { #[cfg(not(feature = "tokio"))] /// meta refresh redirect fn _audit_meta_refresh() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Do not use this! @@ -53,7 +53,7 @@ fn _audit_meta_refresh() { assert_eq!(valid, false); - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" HTML Techniques for WCAG 2.0 @@ -79,7 +79,7 @@ fn _audit_meta_refresh() { #[cfg(not(feature = "tokio"))] /// no blink elements fn _audit_blink_found() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Do not use this! @@ -105,7 +105,7 @@ fn _audit_blink_found() { #[cfg(not(feature = "tokio"))] /// iframe missing title fn _iframe_missing_title() { - let audit = accessibility_rs::audit(AuditConfig { + let audit = accessibility_rs::audit(&AuditConfig { html: r###" A simple frameset document @@ -156,7 +156,7 @@ fn _iframe_missing_title() { false, "en", ); - let audit = accessibility_rs::audit(config); + let audit = accessibility_rs::audit(&config); let mut valid = true; for x in &audit { @@ -182,7 +182,7 @@ fn _iframe_missing_title() { "en", ); - let audit = accessibility_rs::audit(config); + let audit = accessibility_rs::audit(&config); let mut valid = true; for x in &audit { @@ -199,7 +199,7 @@ fn _iframe_missing_title() { #[cfg(not(feature = "tokio"))] /// incorrect xml:lang fn _xml_lang_incorrect_format() { - let audit = accessibility_rs::audit(AuditConfig::basic( + let audit = accessibility_rs::audit(&AuditConfig::basic( r###" Do not use this! diff --git a/accessibility-scraper/Cargo.toml b/accessibility-scraper/Cargo.toml index 93d8e6f..2d452ae 100644 --- a/accessibility-scraper/Cargo.toml +++ b/accessibility-scraper/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "accessibility-scraper" -version = "0.0.12" +version = "0.0.14" edition = "2021" description = "HTML parsing and querying with CSS selectors with CSS binding styles to elements." keywords = ["html", "css", "selector", "scraping"] @@ -11,6 +11,7 @@ authors = [ license = "ISC" repository = "https://github.com/a11ywatch/accessibility-rs" readme = "README.md" + [dependencies] cssparser = { workspace = true } ego-tree = { workspace = true } @@ -21,8 +22,8 @@ tendril = "0.4.3" ahash = "0.8" indexmap = { version = "2.0.0", optional = true } once_cell = "1.0" -tokio-stream = { version = "0.1.15", optional = true } -tokio = { version = "1.36.0", features = ["macros"], optional = true } +tokio-stream = { version = "0.1", optional = true } +tokio = { version = "1", features = ["macros", "rt-multi-thread", "parking_lot"], optional = true } [dependencies.getopts] version = "0.2.21" diff --git a/accessibility-tree/victor/Cargo.toml b/accessibility-tree/victor/Cargo.toml index be4db0d..61516b2 100644 --- a/accessibility-tree/victor/Cargo.toml +++ b/accessibility-tree/victor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "accessibility-tree" -version = "0.0.12" +version = "0.0.14" authors = ["Jeff Mendez