@reticular/speakable 1.1.1 → 1.3.0
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.
- package/README.md +6 -5
- package/dist/cli.js +257 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +406 -1
- package/dist/index.js +2194 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +265 -19
- package/dist/mcp.js.map +1 -1
- package/package.json +12 -4
package/dist/index.d.ts
CHANGED
|
@@ -345,4 +345,409 @@ declare function formatDiffForCI(diff: SemanticDiff): string;
|
|
|
345
345
|
*/
|
|
346
346
|
declare function hasAccessibilityRegression(diff: SemanticDiff): boolean;
|
|
347
347
|
|
|
348
|
-
|
|
348
|
+
/**
|
|
349
|
+
* NVDA screen reader announcement renderer.
|
|
350
|
+
*
|
|
351
|
+
* Generates heuristic announcement text approximating NVDA output.
|
|
352
|
+
* This is NOT a perfect emulation - real NVDA behavior varies by version,
|
|
353
|
+
* settings, and context. Use for development guidance only.
|
|
354
|
+
*/
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Renders an announcement model as NVDA-style announcement text.
|
|
358
|
+
*
|
|
359
|
+
* @param model - Announcement model to render
|
|
360
|
+
* @param colorize - Whether to apply ANSI color codes to the output
|
|
361
|
+
* @returns NVDA-style announcement text
|
|
362
|
+
*/
|
|
363
|
+
declare function renderNVDA(model: AnnouncementModel, colorize?: boolean): string;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* JAWS screen reader announcement renderer.
|
|
367
|
+
*
|
|
368
|
+
* Generates heuristic announcement text approximating JAWS output.
|
|
369
|
+
* This is NOT a perfect emulation - real JAWS behavior varies by version,
|
|
370
|
+
* settings, verbosity level, and context. Use for development guidance only.
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Renders an announcement model as JAWS-style announcement text.
|
|
375
|
+
*
|
|
376
|
+
* @param model - Announcement model to render
|
|
377
|
+
* @param colorize - Whether to apply ANSI color codes to the output
|
|
378
|
+
* @returns JAWS-style announcement text
|
|
379
|
+
*/
|
|
380
|
+
declare function renderJAWS(model: AnnouncementModel, colorize?: boolean): string;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* VoiceOver screen reader announcement renderer.
|
|
384
|
+
*
|
|
385
|
+
* Generates heuristic announcement text approximating VoiceOver output.
|
|
386
|
+
* This is NOT a perfect emulation - real VoiceOver behavior varies by version,
|
|
387
|
+
* settings, and context. Use for development guidance only.
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Renders an announcement model as VoiceOver-style announcement text.
|
|
392
|
+
*
|
|
393
|
+
* @param model - Announcement model to render
|
|
394
|
+
* @param colorize - Whether to apply ANSI color codes to the output
|
|
395
|
+
* @returns VoiceOver-style announcement text
|
|
396
|
+
*/
|
|
397
|
+
declare function renderVoiceOver(model: AnnouncementModel, colorize?: boolean): string;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Windows Narrator screen reader announcement renderer.
|
|
401
|
+
*
|
|
402
|
+
* Generates heuristic announcement text approximating Windows Narrator output.
|
|
403
|
+
* This is NOT a perfect emulation - real Narrator behavior varies by version,
|
|
404
|
+
* settings, and context. Use for development guidance only.
|
|
405
|
+
*/
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Renders an announcement model as Narrator-style announcement text.
|
|
409
|
+
*
|
|
410
|
+
* @param model - Announcement model to render
|
|
411
|
+
* @param colorize - Whether to apply ANSI color codes to the output
|
|
412
|
+
* @returns Narrator-style announcement text
|
|
413
|
+
*/
|
|
414
|
+
declare function renderNarrator(model: AnnouncementModel, colorize?: boolean): string;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Developer-friendly audit report renderer.
|
|
418
|
+
*
|
|
419
|
+
* Generates human-readable accessibility audit reports with:
|
|
420
|
+
* - Landmark structure analysis
|
|
421
|
+
* - Heading hierarchy validation
|
|
422
|
+
* - Interactive element inventory
|
|
423
|
+
* - Common accessibility issue detection
|
|
424
|
+
* - Summary statistics
|
|
425
|
+
*/
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Severity level for accessibility issues.
|
|
429
|
+
*/
|
|
430
|
+
type IssueSeverity = 'error' | 'warning' | 'info';
|
|
431
|
+
/**
|
|
432
|
+
* Accessibility issue detected during audit.
|
|
433
|
+
*/
|
|
434
|
+
interface AccessibilityIssue {
|
|
435
|
+
severity: IssueSeverity;
|
|
436
|
+
message: string;
|
|
437
|
+
suggestion?: string;
|
|
438
|
+
element?: {
|
|
439
|
+
role: AccessibleRole;
|
|
440
|
+
name: string;
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Audit report statistics.
|
|
445
|
+
*/
|
|
446
|
+
interface AuditStatistics {
|
|
447
|
+
totalElements: number;
|
|
448
|
+
roleDistribution: Record<string, number>;
|
|
449
|
+
landmarkCount: number;
|
|
450
|
+
headingCount: number;
|
|
451
|
+
interactiveCount: number;
|
|
452
|
+
focusableCount: number;
|
|
453
|
+
statesUsed: Set<string>;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Complete audit report.
|
|
457
|
+
*/
|
|
458
|
+
interface AuditReport {
|
|
459
|
+
statistics: AuditStatistics;
|
|
460
|
+
landmarks: AccessibleNode[];
|
|
461
|
+
headings: AccessibleNode[];
|
|
462
|
+
interactiveElements: AccessibleNode[];
|
|
463
|
+
issues: AccessibilityIssue[];
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Renders an announcement model as a developer-friendly audit report.
|
|
467
|
+
*
|
|
468
|
+
* @param model - Announcement model to audit
|
|
469
|
+
* @returns Formatted audit report text
|
|
470
|
+
*/
|
|
471
|
+
declare function renderAuditReport(model: AnnouncementModel, colorize?: boolean): string;
|
|
472
|
+
/**
|
|
473
|
+
* Generates audit report data from an announcement model.
|
|
474
|
+
*
|
|
475
|
+
* @param model - Announcement model to analyze
|
|
476
|
+
* @returns Audit report data
|
|
477
|
+
*/
|
|
478
|
+
declare function generateAuditReport(model: AnnouncementModel): AuditReport;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* HTML parsing using jsdom.
|
|
482
|
+
*
|
|
483
|
+
* Provides lenient parsing with error recovery for malformed HTML.
|
|
484
|
+
*/
|
|
485
|
+
/**
|
|
486
|
+
* Parsing error class.
|
|
487
|
+
*/
|
|
488
|
+
declare class ParsingError extends Error {
|
|
489
|
+
readonly cause?: Error | undefined;
|
|
490
|
+
constructor(message: string, cause?: Error | undefined);
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Parsing warning.
|
|
494
|
+
*/
|
|
495
|
+
interface ParsingWarning {
|
|
496
|
+
message: string;
|
|
497
|
+
line?: number;
|
|
498
|
+
column?: number;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Result of HTML parsing.
|
|
502
|
+
*/
|
|
503
|
+
interface ParseResult {
|
|
504
|
+
/** Parsed DOM document */
|
|
505
|
+
document: Document;
|
|
506
|
+
/** Warnings encountered during parsing */
|
|
507
|
+
warnings: ParsingWarning[];
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Parses HTML string into a DOM document.
|
|
511
|
+
*
|
|
512
|
+
* Uses jsdom with lenient parsing mode to handle malformed HTML.
|
|
513
|
+
* Emits warnings for issues but continues processing.
|
|
514
|
+
*
|
|
515
|
+
* @param html - HTML string to parse
|
|
516
|
+
* @returns Parse result with document and warnings
|
|
517
|
+
* @throws ParsingError if parsing fails completely or input exceeds size limit
|
|
518
|
+
*/
|
|
519
|
+
declare function parseHTML(html: string): ParseResult;
|
|
520
|
+
/**
|
|
521
|
+
* Parses HTML and returns just the document (throws on warnings).
|
|
522
|
+
*
|
|
523
|
+
* Convenience function for cases where warnings should be treated as errors.
|
|
524
|
+
*
|
|
525
|
+
* @param html - HTML string to parse
|
|
526
|
+
* @returns Parsed DOM document
|
|
527
|
+
* @throws ParsingError if parsing fails or warnings are present
|
|
528
|
+
*/
|
|
529
|
+
declare function parseHTMLStrict(html: string): Document;
|
|
530
|
+
/**
|
|
531
|
+
* Validates that HTML string is not empty.
|
|
532
|
+
*
|
|
533
|
+
* @param html - HTML string to validate
|
|
534
|
+
* @throws ParsingError if HTML is empty or whitespace-only
|
|
535
|
+
*/
|
|
536
|
+
declare function validateHTMLNotEmpty(html: string): void;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* ARIA accessible name computation.
|
|
540
|
+
*
|
|
541
|
+
* Implements the ARIA name computation algorithm following the W3C specification.
|
|
542
|
+
* https://www.w3.org/TR/accname-1.2/
|
|
543
|
+
*/
|
|
544
|
+
/**
|
|
545
|
+
* Warning emitted during name computation.
|
|
546
|
+
*/
|
|
547
|
+
interface NameComputationWarning {
|
|
548
|
+
message: string;
|
|
549
|
+
element: Element;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Result of name computation.
|
|
553
|
+
*/
|
|
554
|
+
interface NameComputationResult {
|
|
555
|
+
name: string;
|
|
556
|
+
warnings: NameComputationWarning[];
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Result of description computation.
|
|
560
|
+
*/
|
|
561
|
+
interface DescriptionComputationResult {
|
|
562
|
+
description: string;
|
|
563
|
+
warnings: NameComputationWarning[];
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Computes the accessible name for an element following ARIA specification.
|
|
567
|
+
*
|
|
568
|
+
* Priority order:
|
|
569
|
+
* 1. aria-labelledby (references to other elements)
|
|
570
|
+
* 2. aria-label
|
|
571
|
+
* 3. Native label (for form controls)
|
|
572
|
+
* 4. alt attribute (for images)
|
|
573
|
+
* 5. Text content (for elements that support it)
|
|
574
|
+
* 6. title attribute (fallback)
|
|
575
|
+
*
|
|
576
|
+
* @param element - Element to compute name for
|
|
577
|
+
* @param visited - Set of visited elements (for cycle detection)
|
|
578
|
+
* @returns Computed accessible name and warnings
|
|
579
|
+
*/
|
|
580
|
+
declare function computeAccessibleName(element: Element, visited?: Set<Element>): NameComputationResult;
|
|
581
|
+
/**
|
|
582
|
+
* Computes the accessible description for an element.
|
|
583
|
+
*
|
|
584
|
+
* Priority order:
|
|
585
|
+
* 1. aria-describedby (references to other elements)
|
|
586
|
+
* 2. title attribute (fallback)
|
|
587
|
+
*
|
|
588
|
+
* @param element - Element to compute description for
|
|
589
|
+
* @returns Computed accessible description and warnings
|
|
590
|
+
*/
|
|
591
|
+
declare function computeAccessibleDescription(element: Element): DescriptionComputationResult;
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Role computation and mapping.
|
|
595
|
+
*
|
|
596
|
+
* Maps HTML elements to their implicit ARIA roles and validates explicit roles.
|
|
597
|
+
*/
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Warning emitted during role computation.
|
|
601
|
+
*/
|
|
602
|
+
interface RoleComputationWarning {
|
|
603
|
+
message: string;
|
|
604
|
+
element: Element;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Result of role computation.
|
|
608
|
+
*/
|
|
609
|
+
interface RoleComputationResult {
|
|
610
|
+
role: AccessibleRole | null;
|
|
611
|
+
warnings: RoleComputationWarning[];
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Computes the accessible role for an element.
|
|
615
|
+
*
|
|
616
|
+
* Priority:
|
|
617
|
+
* 1. Explicit role attribute (if valid)
|
|
618
|
+
* 2. Implicit role based on element type
|
|
619
|
+
* 3. null if no role
|
|
620
|
+
*
|
|
621
|
+
* @param element - Element to compute role for
|
|
622
|
+
* @returns Computed role and warnings
|
|
623
|
+
*/
|
|
624
|
+
declare function computeRole(element: Element): RoleComputationResult;
|
|
625
|
+
/**
|
|
626
|
+
* Checks if an element should be included in the accessibility tree.
|
|
627
|
+
*
|
|
628
|
+
* Elements are excluded if:
|
|
629
|
+
* - They have role="presentation" or role="none"
|
|
630
|
+
* - They have aria-hidden="true"
|
|
631
|
+
* - They have no accessible role
|
|
632
|
+
*
|
|
633
|
+
* @param element - Element to check
|
|
634
|
+
* @returns true if element should be included
|
|
635
|
+
*/
|
|
636
|
+
declare function isAccessible(element: Element): boolean;
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* State and property extraction from ARIA attributes.
|
|
640
|
+
*
|
|
641
|
+
* Extracts accessibility states and properties from elements.
|
|
642
|
+
*/
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Warning emitted during state extraction.
|
|
646
|
+
*/
|
|
647
|
+
interface StateExtractionWarning {
|
|
648
|
+
message: string;
|
|
649
|
+
element: Element;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Result of state extraction.
|
|
653
|
+
*/
|
|
654
|
+
interface StateExtractionResult {
|
|
655
|
+
state: AccessibleState;
|
|
656
|
+
warnings: StateExtractionWarning[];
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Result of value extraction.
|
|
660
|
+
*/
|
|
661
|
+
interface ValueExtractionResult {
|
|
662
|
+
value: AccessibleValue | undefined;
|
|
663
|
+
warnings: StateExtractionWarning[];
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Extracts accessibility state from an element.
|
|
667
|
+
*
|
|
668
|
+
* Extracts ARIA state attributes and native element states.
|
|
669
|
+
*
|
|
670
|
+
* @param element - Element to extract state from
|
|
671
|
+
* @returns Extracted state and warnings
|
|
672
|
+
*/
|
|
673
|
+
declare function extractState(element: Element): StateExtractionResult;
|
|
674
|
+
/**
|
|
675
|
+
* Extracts value information from form controls.
|
|
676
|
+
*
|
|
677
|
+
* @param element - Element to extract value from
|
|
678
|
+
* @returns Extracted value and warnings
|
|
679
|
+
*/
|
|
680
|
+
declare function extractValue(element: Element): ValueExtractionResult;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Focus information extraction.
|
|
684
|
+
*
|
|
685
|
+
* Determines focusability and tabindex for elements.
|
|
686
|
+
*/
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Extracts focus information from an element.
|
|
690
|
+
*
|
|
691
|
+
* Determines if an element is focusable and extracts explicit tabindex.
|
|
692
|
+
*
|
|
693
|
+
* @param element - Element to extract focus info from
|
|
694
|
+
* @returns Focus information
|
|
695
|
+
*/
|
|
696
|
+
declare function extractFocusInfo(element: Element): FocusInfo;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Accessibility tree builder.
|
|
700
|
+
*
|
|
701
|
+
* Builds the complete accessibility tree from a DOM tree by integrating
|
|
702
|
+
* all extraction components (role, name, description, state, value, focus).
|
|
703
|
+
*
|
|
704
|
+
* Supports transparent traversal through role-less elements, text node
|
|
705
|
+
* capture as staticText nodes, shadow DOM traversal, and CSS hidden state.
|
|
706
|
+
*/
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Warning emitted during tree building.
|
|
710
|
+
*/
|
|
711
|
+
interface TreeBuildWarning {
|
|
712
|
+
message: string;
|
|
713
|
+
element: Element;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Result of tree building.
|
|
717
|
+
*/
|
|
718
|
+
interface TreeBuildResult {
|
|
719
|
+
model: AnnouncementModel;
|
|
720
|
+
warnings: TreeBuildWarning[];
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Error thrown when selector filtering fails.
|
|
724
|
+
*/
|
|
725
|
+
declare class SelectorError extends Error {
|
|
726
|
+
constructor(message: string);
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Builds an accessibility tree from a DOM element.
|
|
730
|
+
*
|
|
731
|
+
* Traverses the DOM tree depth-first, applies all extractors,
|
|
732
|
+
* filters inaccessible elements, and builds the hierarchical tree.
|
|
733
|
+
*
|
|
734
|
+
* @param rootElement - Root DOM element to build tree from
|
|
735
|
+
* @param sourceHash - Optional hash of source HTML for change detection
|
|
736
|
+
* @returns Announcement model and warnings
|
|
737
|
+
*/
|
|
738
|
+
declare function buildAccessibilityTree(rootElement: Element, sourceHash?: string): TreeBuildResult;
|
|
739
|
+
/**
|
|
740
|
+
* Builds accessibility trees for elements matching a CSS selector.
|
|
741
|
+
*
|
|
742
|
+
* Uses querySelector/querySelectorAll to find matching elements,
|
|
743
|
+
* then builds an accessibility tree for each match.
|
|
744
|
+
*
|
|
745
|
+
* @param rootElement - Root DOM element to search within
|
|
746
|
+
* @param selector - CSS selector to match elements
|
|
747
|
+
* @param sourceHash - Optional hash of source HTML for change detection
|
|
748
|
+
* @returns Array of announcement models and warnings
|
|
749
|
+
* @throws SelectorError if no elements match the selector
|
|
750
|
+
*/
|
|
751
|
+
declare function buildAccessibilityTreeWithSelector(rootElement: Element, selector: string, sourceHash?: string): TreeBuildResult[];
|
|
752
|
+
|
|
753
|
+
export { type AccessibilityIssue, type AccessibleNode, type AccessibleRole, type AccessibleState, type AccessibleValue, type AnnouncementModel, type AuditReport, type AuditStatistics, CURRENT_MODEL_VERSION, type ChangeType, type DescriptionComputationResult, type DeserializationOptions, type FocusInfo, type IssueSeverity, type ModelVersion, type NameComputationResult, type NameComputationWarning, type NodeChange, type NodePath, type ParseResult, ParsingError, type ParsingWarning, type PropertyChange, type RoleComputationResult, type RoleComputationWarning, SUPPORTED_ROLES, SelectorError, type SemanticDiff, type SerializationOptions, type StateExtractionResult, type StateExtractionWarning, type TreeBuildResult, type TreeBuildWarning, ValidationError, type ValueExtractionResult, buildAccessibilityTree, buildAccessibilityTreeWithSelector, cloneModel, computeAccessibleDescription, computeAccessibleName, computeRole, createModel, describeChange, deserializeModel, diffAccessibilityTrees, extractFocusInfo, extractState, extractValue, formatDiffAsJSON, formatDiffAsText, formatDiffForCI, generateAuditReport, hasAccessibilityRegression, isAccessible, modelsEqual, parseHTML, parseHTMLStrict, renderAuditReport, renderJAWS, renderNVDA, renderNarrator, renderVoiceOver, serializeModel, validateHTMLNotEmpty, validateModel, validateRole, validateState, validateTreeStructure };
|