@reticular/speakable 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +234 -10
  2. package/package.json +4 -2
package/README.md CHANGED
@@ -1,31 +1,255 @@
1
1
  # Speakable
2
2
 
3
- CLI tool for analyzing HTML accessibility announcements.
3
+ Simulate how NVDA, JAWS, and VoiceOver interpret your HTML — from a single CLI tool. Catch screen reader issues early, detect regressions in CI/CD, and reduce manual testing overhead.
4
+
5
+ Speakable bridges the gap between rule-based linting tools (like axe) and manual screen reader testing. It gives you scalable, automated insight into how assistive technologies will interpret your UI.
6
+
7
+ > Screen reader output is heuristic and may differ from actual behavior. Speakable complements manual testing — it doesn't replace it.
4
8
 
5
9
  ## Installation
6
10
 
7
11
  ```bash
8
- npm install
12
+ npm install @reticular/speakable
13
+ ```
14
+
15
+ Or install globally for CLI usage:
16
+
17
+ ```bash
18
+ npm install -g @reticular/speakable
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ # Analyze an HTML file (JSON output)
25
+ speakable page.html
26
+
27
+ # Get screen reader announcement text
28
+ speakable page.html -f text -s nvda
29
+
30
+ # Generate an accessibility audit report
31
+ speakable page.html -f audit
32
+
33
+ # Compare two versions for regressions
34
+ speakable new.html --diff old.html
35
+
36
+ # Pipe from stdin
37
+ cat page.html | speakable -
38
+ ```
39
+
40
+ ## CLI Reference
41
+
42
+ ```
43
+ Usage: speakable [options] [input...]
44
+
45
+ Analyze HTML accessibility announcements and generate screen reader output
46
+
47
+ Arguments:
48
+ input HTML file path(s) or "-" for stdin
49
+
50
+ Options:
51
+ -v, --version Output the current version
52
+ -o, --output <path> Output file path (default: stdout)
53
+ -f, --format <format> Output format (default: "json")
54
+ -s, --screen-reader <reader> Screen reader to simulate (default: "nvda")
55
+ --selector <selector> CSS selector to filter elements
56
+ --validate Validate round-trip serialization
57
+ --diff <file> Compare with another HTML file
58
+ --batch Process multiple files in batch mode
59
+ -h, --help Display help for command
60
+ ```
61
+
62
+ ## Output Formats
63
+
64
+ | Format | Flag | Description |
65
+ |--------|------|-------------|
66
+ | JSON | `-f json` | Canonical accessibility model as JSON. Best for CI/CD and programmatic use. |
67
+ | Text | `-f text` | Screen reader announcement text. Human-readable output showing what each reader would say. |
68
+ | Audit | `-f audit` | Developer-friendly audit report with landmark structure, heading hierarchy, interactive elements, and issue detection. |
69
+ | Both | `-f both` | JSON and text output combined. |
70
+
71
+ ## Screen Readers
72
+
73
+ | Reader | Flag | Platform |
74
+ |--------|------|----------|
75
+ | NVDA | `-s nvda` | Windows |
76
+ | JAWS | `-s jaws` | Windows |
77
+ | VoiceOver | `-s voiceover` | macOS |
78
+ | All | `-s all` | All three readers side by side |
79
+
80
+ Each renderer produces heuristic output approximating the real screen reader's behavior. Key differences are preserved — for example, NVDA says "navigation landmark" while JAWS says "navigation region" and VoiceOver says "navigation".
81
+
82
+ ## Features
83
+
84
+ ### Semantic Diff
85
+
86
+ Compare two HTML files and see exactly what changed in the accessibility tree:
87
+
88
+ ```bash
89
+ speakable new-version.html --diff old-version.html
90
+ speakable new-version.html --diff old-version.html -f text
9
91
  ```
10
92
 
11
- ## Development
93
+ The diff identifies added, removed, and changed nodes with specific property-level details (name changes, role changes, state changes, focus changes).
94
+
95
+ ### CSS Selector Filtering
96
+
97
+ Focus analysis on specific elements:
12
98
 
13
99
  ```bash
14
- npm run dev
100
+ # Analyze only buttons
101
+ speakable page.html --selector "button"
102
+
103
+ # Analyze a specific component
104
+ speakable page.html --selector ".my-component"
105
+
106
+ # Analyze all interactive elements
107
+ speakable page.html --selector "button, a, input, select"
15
108
  ```
16
109
 
17
- ## Testing
110
+ ### Batch Processing
111
+
112
+ Analyze multiple files in a single run:
18
113
 
19
114
  ```bash
20
- npm test
115
+ speakable --batch file1.html file2.html file3.html
21
116
  ```
22
117
 
23
- ## Build
118
+ Batch mode continues processing even if individual files fail, and reports a summary at the end.
119
+
120
+ ### Audit Reports
121
+
122
+ Generate comprehensive accessibility reports:
24
123
 
25
124
  ```bash
26
- npm run build
125
+ speakable page.html -f audit
27
126
  ```
28
127
 
29
- ## Usage
128
+ The audit report includes:
129
+ - Landmark structure analysis
130
+ - Heading hierarchy validation (detects skipped levels)
131
+ - Interactive element inventory with state tracking
132
+ - Missing accessible name detection
133
+ - Severity-coded issues (errors, warnings, info)
134
+ - Overall assessment with remediation suggestions
135
+
136
+ ### Colorized Output
137
+
138
+ When outputting to a terminal, Speakable automatically colorizes human-readable formats:
139
+ - Section headers in cyan
140
+ - Errors in red, warnings in yellow, info in blue
141
+ - Success indicators in green
142
+ - Role names in cyan, element names in bold, states in yellow
143
+
144
+ Colors are automatically disabled when piping to files or other commands.
145
+
146
+ ### Round-Trip Validation
147
+
148
+ Verify that the accessibility model serializes and deserializes consistently:
149
+
150
+ ```bash
151
+ speakable page.html --validate
152
+ ```
153
+
154
+ ## CI/CD Integration
155
+
156
+ ### GitHub Actions
157
+
158
+ ```yaml
159
+ - name: Run Speakable
160
+ run: npx @reticular/speakable page.html -f audit
161
+
162
+ - name: Check for regressions
163
+ run: npx @reticular/speakable new.html --diff baseline.html -f text
164
+ ```
165
+
166
+ ### Exit Codes
167
+
168
+ | Code | Meaning |
169
+ |------|---------|
170
+ | 0 | Success — analysis completed, no issues |
171
+ | 1 | User error — invalid arguments or options |
172
+ | 2 | Content error — accessibility issues found, or diff detected changes |
173
+ | 3 | System error — file not found, I/O failure |
174
+
175
+ Use exit codes in CI to fail builds on regressions:
176
+
177
+ ```bash
178
+ speakable new.html --diff baseline.html || echo "Accessibility regression detected"
179
+ ```
180
+
181
+ ## Programmatic API
182
+
183
+ Speakable can also be used as a library:
184
+
185
+ ```typescript
186
+ import {
187
+ parseHTML,
188
+ buildAccessibilityTree,
189
+ serializeModel,
190
+ renderNVDA,
191
+ renderJAWS,
192
+ renderVoiceOver,
193
+ renderAuditReport,
194
+ diffAccessibilityTrees,
195
+ } from '@reticular/speakable';
196
+
197
+ const html = '<button aria-label="Submit">Pay</button>';
198
+ const doc = parseHTML(html);
199
+ const result = buildAccessibilityTree(doc.document.body);
200
+
201
+ // Screen reader output
202
+ console.log(renderNVDA(result.model)); // "Submit, button"
203
+ console.log(renderJAWS(result.model)); // "Submit, button"
204
+ console.log(renderVoiceOver(result.model)); // "button, Submit"
205
+
206
+ // JSON model
207
+ console.log(serializeModel(result.model));
208
+
209
+ // Audit report
210
+ console.log(renderAuditReport(result.model));
211
+ ```
212
+
213
+ ## How It Works
214
+
215
+ Speakable processes HTML through a four-stage pipeline:
216
+
217
+ 1. **Parser** — Parses HTML into a DOM using jsdom with lenient error recovery
218
+ 2. **Extractor** — Walks the DOM and builds a canonical accessibility tree following the ARIA spec (role computation, accessible name calculation, state extraction, focus detection)
219
+ 3. **Model** — Produces a deterministic, serializable `AnnouncementModel` suitable for snapshot testing and diffing
220
+ 4. **Renderers** — Transforms the model into screen reader-specific announcement text, applying each reader's unique patterns
221
+
222
+ ## What Speakable Catches
223
+
224
+ - Missing accessible names on buttons, links, and form controls
225
+ - Heading hierarchy violations (skipped levels, wrong starting level)
226
+ - Unnamed landmarks that should have labels
227
+ - Duplicate landmarks without distinguishing names
228
+ - ARIA attribute issues and invalid values
229
+ - Changes in screen reader output between code versions (via diff)
230
+
231
+ ## What Speakable Does Not Do
232
+
233
+ - Replace manual screen reader testing with real assistive technology
234
+ - Guarantee WCAG compliance
235
+ - Test dynamic/JavaScript-driven content (it analyzes static HTML)
236
+ - Perfectly replicate screen reader behavior (output is heuristic)
237
+
238
+ Use Speakable to catch issues early and reduce the manual testing burden — then validate critical flows with real screen readers.
239
+
240
+ ## Best Practices
241
+
242
+ 1. **Run in CI** — Add Speakable to your build pipeline to catch regressions on every PR
243
+ 2. **Use semantic diff** — Compare before/after HTML to detect accessibility changes
244
+ 3. **Focus with selectors** — Use `--selector` to analyze specific components rather than entire pages
245
+ 4. **Check all readers** — Use `-s all` to see cross-platform differences
246
+ 5. **Start with audit** — Use `-f audit` for a quick overview of accessibility health
247
+ 6. **Save baselines** — Store JSON output as baselines for regression detection
248
+
249
+ ## Requirements
250
+
251
+ - Node.js 18 or higher
252
+
253
+ ## License
30
254
 
31
- Documentation coming soon.
255
+ MIT
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@reticular/speakable",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "CLI tool for analyzing HTML accessibility announcements",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
- "files": ["dist"],
8
+ "files": [
9
+ "dist"
10
+ ],
9
11
  "bin": {
10
12
  "speakable": "dist/cli.js"
11
13
  },