@reticular/speakable 1.0.0 → 1.0.2

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