Field notes/pure Rust alternativeTrustrusty_a11y

rusty_a11y: बाद में जोड़े गए ARIA सहायकों का शुद्ध Rust विकल्प

बिना label वाले glyphs और चुप sync states screen reader उपयोगकर्ताओं को बाहर कर देते हैं। rusty_a11y शुद्ध Rust से escaped, labelled HTML और ARIA live regions बनाता है, बिना किसी DOM crate के।

Signed by M·
नरम स्वागतकारी रोशनियों वाले garden gate में जाती हुई रंगी हुई कोमल ramp
DOM binding के बिना Rust UI में screen reader labels और live regions कैसे जोड़ूँ?

rusty_a11y का उपयोग करें। label::img एक glyph को role="img" के साथ नाम देता है, live::polite और live::assertive updates को ARIA live regions में लपेटते हैं, और status::announce Saved, Syncing, Offline, Error या Ready states बोलता है। हर एक escaped HTML string लौटाता है जिसे आप WebView या Dioxus में inject करते हैं।

Related reading

rusty_a11y: ARIA Labels and Live Regions for Rust UI Chrome

rusty_a11y builds labelled glyphs, polite and assertive live regions and status announcements as escaped HTML strings in pure Rust, with no DOM crate and no JavaScript.

Ship it

A11y Built In

labelled glyphs and live regions as primitives, not afterthoughts.

Rust डेस्कटॉप या वेब UI में accessibility अक्सर देर से आती है, रिलीज़ से एक हफ़्ता पहले लिखे गए कुछ helper functions के रूप में। कोई aria-label को string concatenation से कुछ buttons में जोड़ता है, sync indicator को पूरी तरह भूल जाता है, और check mark glyph को एक खाली symbol छोड़ देता है जिसे screen reader बिल्कुल कुछ नहीं के रूप में पढ़ता है। rusty_a11y इसे उन तीन चीज़ों के लिए परखे गए builders के छोटे सेट से बदलता है जिनमें application chrome सबसे अधिक गलती करता है। यह पेज bolted-on helpers से crate की ओर बढ़ने को कवर करता है। परिवार के overview के लिए, rusty_a11y field note पढ़ें।

बाद में जोड़े गए helpers उपयोगकर्ताओं के लिए क्यों विफल होते हैं

बिना नाम वाले glyphs

Icon fonts और Unicode symbols स्क्रीन पर साफ़ दिखते हैं और assistive technology से कुछ नहीं कहते। जो check mark "verified" का मतलब रखता है, वह या तो छोड़ दिया जाता है या character name के रूप में पढ़ा जाता है। WAI-ARIA का fix बहुत ज्ञात है, role="img" के साथ एक accessible name, लेकिन हाथ से लिखे helpers इसे कुछ glyphs पर लागू करते हैं और दूसरों पर नहीं।

Status changes जिन्हें कोई नहीं सुनता

Sync, saved और offline indicators focus हिले बिना बदल जाते हैं। जब तक बदलाव किसी live region के अंदर नहीं होता, screen reader उपयोगकर्ता को कभी पता नहीं चलता कि save पूरा हुआ या connection टूट गया। MDN पर ARIA live region guidance इस पर स्पष्ट है, और यही वह हिस्सा है जो सबसे अधिक छोड़ा जाता है।

उम्मीद के भरोसे escaping

जो helpers labels को attributes में concatenate करते हैं, वे पहली बार तब टूटते हैं जब किसी label में quote आ जाए। raw HTML inject करने वाले WebView में, unescaped user-supplied string markup injection का जोखिम भी है। बाद में जोड़े गए code में इनमें से किसी भी स्थिति के लिए tests शायद ही होते हैं।

rusty_a11y क्या कवर करता है

तीन modules

label symbols के लिए img(glyph, aria_label) और उन elements के लिए named(visible, aria_label) देता है जिनके visible text को अधिक पूरा spoken name चाहिए। live polite और assertive live-region wrappers देता है। status announce और announce_error के साथ Kind::{Saved, Syncing, Offline, Error, Ready} परिभाषित करता है, ताकि सामान्य state messages पूरे app में एक जैसे रहें।

Strings, DOM नहीं

हर builder HTML का String लौटाता है। dependency graph में कोई DOM crate नहीं है और कोई JavaScript नहीं है। आप परिणाम को dangerous_inner_html या उसके equivalent के साथ Dioxus या WebView में inject करते हैं। quotes और HTML की escaping अंदर बनी हुई है, और doctests के साथ unit tests escapes और ARIA attributes दोनों की रक्षा करते हैं।

Targets और features

crate Windows, macOS, Linux, browser और wasm32-unknown-unknown पर चलता है, alloc चाहिए लेकिन std नहीं, और इसमें कोई OS APIs नहीं हैं। MSRV 1.73 है और license MIT है। default rusty-alloc feature shared seam के जरिए rusty_alloc install करता है, इसलिए इसे rusty_tokens और rusty_symbols के defaults के साथ मिलाना सुरक्षित है। zero dependencies के लिए defaults बंद करें, या hardened allocator के लिए secure enable करें।

एक विस्तृत उदाहरण

Dioxus header में एक sync indicator लें। बाद में जोड़ा गया version state बदलने पर icon और CSS class बदल देता है और कुछ नहीं कहता। crate के साथ, icon label::img बन जाता है जिसका नाम "synced" जैसा होता है, और state change खुद काम चलते समय status::announce(status::Kind::Syncing) से गुजरता है, फिर पूरा होने पर status::Kind::Saved से। अगर connection टूट जाए, तो status::Kind::Offline announce होता है, और failed save announce_error का उपयोग करता है ताकि वह interrupt करे। इन सबका markup Rust में बनाया जाता है, escaped होता है, और crate के tests से कवर होता है, इसलिए header component में हाथ से जोड़े गए ARIA attributes बिल्कुल नहीं होते। वही pattern upload progress, verification badges और settings screens में connection state को कवर करता है।

दायरे से बाहर

README स्पष्ट है कि document engines और canvas accessibility कवर नहीं होते। Focus management, keyboard navigation और contrast checking भी तीन modules के बाहर हैं। rusty_a11y को chrome layer मानें और बाकी के लिए manual audit रखें।

चरण दर चरण migrate करना

1. चुपचाप रहने वाली जगहें खोजें

हर उस glyph की सूची बनाएं जो icon के रूप में उपयोग होता है, हर status indicator की, और हर उस जगह की जहाँ label को markup में concatenate किया जाता है। वे तीन सूचियाँ label, status और live से मेल खाती हैं।

2. crate को pin करें

[dependencies]
rusty_a11y = "0.2"
# own allocator, zero dependencies:
# rusty_a11y = { version = "0.2", default-features = false }

3. glyphs को नाम दें

खाली symbols को label::img से बदलें। एक verified badge label::img("\u{2713}", "verified") बन जाता है। जहाँ visible text संक्षिप्त है, वहाँ अधिक पूरे spoken name के लिए label::named का उपयोग करें।

4. status को live regions से गुजारें

सामान्य updates live::polite या status::announce(status::Kind::Saved) से भेजें। live::assertive या announce_error का उपयोग केवल उन failures के लिए करें जिन्हें उपयोगकर्ता को तुरंत सुनना हो।

5. असली screen reader से जाँचें

cargo test चलाएं, फिर NVDA, VoiceOver या Orca के साथ flows आज़माएं। save trigger करें, network काटें और पुष्टि करें कि हर बदलाव एक बार बोला जाता है।

pin repo page पर है और source github.com/Remade-With-Rust/rusty_a11y पर। इसका sibling glyph toolkit thoth है। Disco Party पर रखे गए apps, जो MATA की hosting layer है, उन्हीं users तक उसी chrome से पहुँचते हैं, इसलिए एक बार लिखे गए labels desktop और web दोनों पर लागू होते हैं। बाकी band Vision में Trust पर है, और sovereign ID से बनाए गए identity screens को उन्हीं status messages का लाभ मिलता है।

FAQ

label::img क्या उत्पन्न करता है?

एक HTML string जो किसी glyph को role="img" और एक accessible name देती है, उदाहरण के लिए label::img("\u{2713}", "verified")। Screen readers raw symbol या कुछ नहीं के बजाय नाम announce करते हैं।

polite बनाम assertive live regions का उपयोग कब करना चाहिए?

Syncing जैसे सामान्य updates के लिए live::polite का उपयोग करें, जो reader के idle होने तक रुकते हैं। live::assertive को उन interruptions के लिए रखें जिन्हें उपयोगकर्ता को अभी सुनना हो, जैसे कोई error, जैसा WAI-ARIA live region guidance बताती है।

क्या rusty_a11y मेरे द्वारा दिए गए text को escape करता है?

हाँ। Attribute और text escaping अंदर बनी हुई है और doctests तथा unit tests से कवर है, इसलिए quotes या angle brackets वाला label आसपास के markup को तोड़ नहीं सकता।

क्या rusty_a11y किसी canvas या document editor को accessible बना सकता है?

नहीं। इसका README document engines और canvas accessibility को दायरे से बाहर रखता है। यह application chrome को लक्षित करता है: labelled graphics, live regions और status messages।

rusty_a11y किन targets और Rust versions का समर्थन करता है?

Windows, macOS, Linux, browser और wasm32-unknown-unknown। इसे alloc चाहिए लेकिन std नहीं, इसमें कोई OS APIs नहीं हैं, और यह Rust 1.73 या नया चाहता है। rusty_a11y = "0.2" pin करें।