@reticular/speakable 1.2.0 → 1.4.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 +129 -9
- package/dist/cli.js +240 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1058 -1
- package/dist/index.js +4715 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +258 -19
- package/dist/mcp.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -345,4 +345,1061 @@ 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
|
+
/**
|
|
754
|
+
* Runtime Accessibility Timeline - Type System
|
|
755
|
+
*
|
|
756
|
+
* Normalized event structures for representing accessibility-relevant
|
|
757
|
+
* changes during component interaction. All events use a discriminated
|
|
758
|
+
* union via the `kind` field on payloads and the `type` field on actions.
|
|
759
|
+
*/
|
|
760
|
+
/**
|
|
761
|
+
* Classification of accessibility-relevant events observed during runtime.
|
|
762
|
+
*/
|
|
763
|
+
type EventType = 'FOCUS_CHANGED' | 'ANNOUNCEMENT' | 'DOM_MUTATION' | 'ROLE_CHANGED' | 'ACCESSIBLE_NAME_CHANGED' | 'STATE_CHANGED' | 'KEYBOARD_ACTION' | 'DIALOG_OPENED' | 'DIALOG_CLOSED' | 'WARNING' | 'REGRESSION';
|
|
764
|
+
/**
|
|
765
|
+
* Identifies the DOM element targeted by an accessibility event.
|
|
766
|
+
*/
|
|
767
|
+
interface EventTarget {
|
|
768
|
+
/** ARIA role of the target element */
|
|
769
|
+
role: string;
|
|
770
|
+
/** Computed accessible name */
|
|
771
|
+
accessibleName: string;
|
|
772
|
+
/** Stable CSS selector path for element identification */
|
|
773
|
+
selector: string;
|
|
774
|
+
}
|
|
775
|
+
interface FocusChangedPayload {
|
|
776
|
+
kind: 'focus_changed';
|
|
777
|
+
previousTarget: EventTarget | null;
|
|
778
|
+
}
|
|
779
|
+
interface AnnouncementPayload {
|
|
780
|
+
kind: 'announcement';
|
|
781
|
+
politeness: 'polite' | 'assertive';
|
|
782
|
+
text: string;
|
|
783
|
+
}
|
|
784
|
+
interface RoleChangedPayload {
|
|
785
|
+
kind: 'role_changed';
|
|
786
|
+
previousRole: string;
|
|
787
|
+
newRole: string;
|
|
788
|
+
}
|
|
789
|
+
interface AccessibleNameChangedPayload {
|
|
790
|
+
kind: 'accessible_name_changed';
|
|
791
|
+
previousName: string;
|
|
792
|
+
newName: string;
|
|
793
|
+
}
|
|
794
|
+
interface StateChangedPayload {
|
|
795
|
+
kind: 'state_changed';
|
|
796
|
+
attribute: string;
|
|
797
|
+
previousValue: string | boolean | null;
|
|
798
|
+
newValue: string | boolean | null;
|
|
799
|
+
}
|
|
800
|
+
interface DialogOpenedPayload {
|
|
801
|
+
kind: 'dialog_opened';
|
|
802
|
+
dialogName: string;
|
|
803
|
+
isModal: boolean;
|
|
804
|
+
}
|
|
805
|
+
interface DialogClosedPayload {
|
|
806
|
+
kind: 'dialog_closed';
|
|
807
|
+
dialogName: string;
|
|
808
|
+
}
|
|
809
|
+
interface KeyboardActionPayload {
|
|
810
|
+
kind: 'keyboard_action';
|
|
811
|
+
key: string;
|
|
812
|
+
modifiers: string[];
|
|
813
|
+
}
|
|
814
|
+
interface WarningPayload {
|
|
815
|
+
kind: 'warning';
|
|
816
|
+
message: string;
|
|
817
|
+
relatedEvent?: AccessibilityEvent;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Discriminated union of all event payload types.
|
|
821
|
+
* Use the `kind` field to narrow the type.
|
|
822
|
+
*/
|
|
823
|
+
type EventPayload = FocusChangedPayload | AnnouncementPayload | RoleChangedPayload | AccessibleNameChangedPayload | StateChangedPayload | DialogOpenedPayload | DialogClosedPayload | KeyboardActionPayload | WarningPayload;
|
|
824
|
+
/**
|
|
825
|
+
* A normalized event representing a single accessibility-relevant change.
|
|
826
|
+
* Contains common fields for classification, timing, targeting, and
|
|
827
|
+
* type-specific payload data.
|
|
828
|
+
*/
|
|
829
|
+
interface AccessibilityEvent {
|
|
830
|
+
/** Event classification */
|
|
831
|
+
type: EventType;
|
|
832
|
+
/** Milliseconds elapsed since session start */
|
|
833
|
+
timestamp: number;
|
|
834
|
+
/** Target element information */
|
|
835
|
+
target: EventTarget;
|
|
836
|
+
/** Type-specific payload data */
|
|
837
|
+
payload: EventPayload;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Discriminated union of interaction actions.
|
|
841
|
+
* Use the `type` field to narrow the action kind.
|
|
842
|
+
*/
|
|
843
|
+
type InteractionAction = {
|
|
844
|
+
type: 'click';
|
|
845
|
+
selector: string;
|
|
846
|
+
} | {
|
|
847
|
+
type: 'tab';
|
|
848
|
+
} | {
|
|
849
|
+
type: 'shiftTab';
|
|
850
|
+
} | {
|
|
851
|
+
type: 'escape';
|
|
852
|
+
} | {
|
|
853
|
+
type: 'enter';
|
|
854
|
+
} | {
|
|
855
|
+
type: 'space';
|
|
856
|
+
} | {
|
|
857
|
+
type: 'arrowUp';
|
|
858
|
+
} | {
|
|
859
|
+
type: 'arrowDown';
|
|
860
|
+
} | {
|
|
861
|
+
type: 'arrowLeft';
|
|
862
|
+
} | {
|
|
863
|
+
type: 'arrowRight';
|
|
864
|
+
} | {
|
|
865
|
+
type: 'key';
|
|
866
|
+
combo: string;
|
|
867
|
+
} | {
|
|
868
|
+
type: 'wait';
|
|
869
|
+
ms: number;
|
|
870
|
+
};
|
|
871
|
+
/**
|
|
872
|
+
* An ordered sequence of user actions to perform during timeline capture.
|
|
873
|
+
*/
|
|
874
|
+
interface InteractionSequence {
|
|
875
|
+
/** Human-readable description of the interaction */
|
|
876
|
+
description: string;
|
|
877
|
+
/** Ordered list of actions to perform */
|
|
878
|
+
actions: InteractionAction[];
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Metadata captured alongside an accessibility timeline session.
|
|
882
|
+
*/
|
|
883
|
+
interface TimelineMetadata {
|
|
884
|
+
/** ISO timestamp of when the timeline was captured */
|
|
885
|
+
capturedAt: string;
|
|
886
|
+
/** Speakable package version used for capture */
|
|
887
|
+
speakableVersion: string;
|
|
888
|
+
/** The URL that was analyzed */
|
|
889
|
+
sourceUrl: string;
|
|
890
|
+
/** Browser context identifier (e.g., "jsdom/23.0.0") */
|
|
891
|
+
userAgent: string;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* A complete accessibility timeline captured during an interaction session.
|
|
895
|
+
* Contains the ordered event sequence, session metadata, and extracted warnings.
|
|
896
|
+
*/
|
|
897
|
+
interface AccessibilityTimeline {
|
|
898
|
+
/** Timeline format version string (e.g., "1.0") */
|
|
899
|
+
version: string;
|
|
900
|
+
/** Component name */
|
|
901
|
+
component: string;
|
|
902
|
+
/** Story or variant name */
|
|
903
|
+
story: string | null;
|
|
904
|
+
/** Human-readable description of the interaction sequence performed */
|
|
905
|
+
interactionSequence: string;
|
|
906
|
+
/** Total session duration in milliseconds */
|
|
907
|
+
duration: number;
|
|
908
|
+
/** All accessibility events in chronological order */
|
|
909
|
+
events: AccessibilityEvent[];
|
|
910
|
+
/** WARNING-type events extracted for quick reference */
|
|
911
|
+
warnings: AccessibilityEvent[];
|
|
912
|
+
/** Session capture metadata */
|
|
913
|
+
metadata: TimelineMetadata;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Runtime Accessibility Engine
|
|
918
|
+
*
|
|
919
|
+
* Coordinates all accessibility observers (focus, mutation, live region, dialog)
|
|
920
|
+
* into a single engine that collects normalized AccessibilityEvents during
|
|
921
|
+
* component interaction. Events are timestamped relative to session start
|
|
922
|
+
* and stored in chronological order.
|
|
923
|
+
*
|
|
924
|
+
* @module runtime/engine
|
|
925
|
+
*/
|
|
926
|
+
|
|
927
|
+
interface EngineOptions {
|
|
928
|
+
/** Document to observe */
|
|
929
|
+
document: Document;
|
|
930
|
+
/** Whether to enable heuristic warnings (default: true) */
|
|
931
|
+
heuristics?: boolean;
|
|
932
|
+
/** Custom settle time in ms (default: 100) */
|
|
933
|
+
settleTime?: number;
|
|
934
|
+
}
|
|
935
|
+
interface RuntimeAccessibilityEngine {
|
|
936
|
+
/** Attach observers to the document and begin event collection */
|
|
937
|
+
attach(): void;
|
|
938
|
+
/** Detach all observers and stop collection */
|
|
939
|
+
detach(): void;
|
|
940
|
+
/** Get all collected events since attach (chronological order) */
|
|
941
|
+
getEvents(): AccessibilityEvent[];
|
|
942
|
+
/** Clear collected events without detaching */
|
|
943
|
+
reset(): void;
|
|
944
|
+
/** Whether the engine is currently attached */
|
|
945
|
+
readonly isAttached: boolean;
|
|
946
|
+
/** Expose dialog observer for heuristics module */
|
|
947
|
+
readonly dialogObserver: {
|
|
948
|
+
getOpenDialogs(): string[];
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Creates a RuntimeAccessibilityEngine that coordinates all observers
|
|
953
|
+
* and collects accessibility events with monotonically increasing timestamps.
|
|
954
|
+
*/
|
|
955
|
+
declare function createEngine(options: EngineOptions): RuntimeAccessibilityEngine;
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Timeline Generator
|
|
959
|
+
*
|
|
960
|
+
* Orchestrates interaction sessions by coordinating the RuntimeAccessibilityEngine
|
|
961
|
+
* with interaction execution and heuristic analysis. Produces complete
|
|
962
|
+
* AccessibilityTimeline objects containing ordered events, warnings, and
|
|
963
|
+
* session metadata.
|
|
964
|
+
*
|
|
965
|
+
* @module runtime/timeline-generator
|
|
966
|
+
*/
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Configuration options for creating a TimelineGenerator.
|
|
970
|
+
*/
|
|
971
|
+
interface TimelineGeneratorOptions {
|
|
972
|
+
/** Document or iframe to attach to */
|
|
973
|
+
document: Document;
|
|
974
|
+
/** Component name for metadata */
|
|
975
|
+
componentName: string;
|
|
976
|
+
/** Story or variant name for metadata */
|
|
977
|
+
storyName?: string;
|
|
978
|
+
/** Settle period after last action (default: 500ms) */
|
|
979
|
+
settlePeriod?: number;
|
|
980
|
+
/** Maximum wait for document load (default: 10000ms) */
|
|
981
|
+
loadTimeout?: number;
|
|
982
|
+
/** Enable heuristic warnings (default: true) */
|
|
983
|
+
heuristics?: boolean;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Orchestrates an interaction session and produces an AccessibilityTimeline.
|
|
987
|
+
*/
|
|
988
|
+
interface TimelineGenerator {
|
|
989
|
+
/** Execute an interaction sequence and produce a timeline */
|
|
990
|
+
capture(sequence: InteractionSequence): Promise<AccessibilityTimeline>;
|
|
991
|
+
/** Abort an in-progress capture */
|
|
992
|
+
abort(): void;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Creates a TimelineGenerator that coordinates the engine, interaction
|
|
996
|
+
* execution, and heuristic analysis to produce accessibility timelines.
|
|
997
|
+
*
|
|
998
|
+
* Usage:
|
|
999
|
+
* ```ts
|
|
1000
|
+
* const generator = createTimelineGenerator({
|
|
1001
|
+
* document: myDocument,
|
|
1002
|
+
* componentName: 'LoginForm',
|
|
1003
|
+
* storyName: 'Default',
|
|
1004
|
+
* });
|
|
1005
|
+
*
|
|
1006
|
+
* const timeline = await generator.capture({
|
|
1007
|
+
* description: 'Tab through form fields',
|
|
1008
|
+
* actions: [{ type: 'tab' }, { type: 'tab' }, { type: 'enter' }],
|
|
1009
|
+
* });
|
|
1010
|
+
* ```
|
|
1011
|
+
*/
|
|
1012
|
+
declare function createTimelineGenerator(options: TimelineGeneratorOptions): TimelineGenerator;
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* Interaction Execution
|
|
1016
|
+
*
|
|
1017
|
+
* Executes interaction sequences against a document, dispatching proper
|
|
1018
|
+
* DOM events (keyboard, mouse, focus) and emitting KEYBOARD_ACTION
|
|
1019
|
+
* accessibility events for each action.
|
|
1020
|
+
*
|
|
1021
|
+
* @module runtime/interactions
|
|
1022
|
+
*/
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* Execute a single interaction action against the document.
|
|
1026
|
+
*
|
|
1027
|
+
* For keyboard actions, dispatches proper KeyboardEvent sequences (keydown, keypress, keyup).
|
|
1028
|
+
* For tab/shiftTab, computes next/previous focusable element and moves focus.
|
|
1029
|
+
* Emits KEYBOARD_ACTION events for each keyboard action.
|
|
1030
|
+
* Handles missing elements by emitting WARNING events and continuing.
|
|
1031
|
+
*
|
|
1032
|
+
* Click and wait actions do not emit KEYBOARD_ACTION events.
|
|
1033
|
+
*/
|
|
1034
|
+
declare function executeAction(action: InteractionAction, document: Document, onEvent: (event: AccessibilityEvent) => void, getTimestamp: () => number): Promise<void>;
|
|
1035
|
+
/**
|
|
1036
|
+
* Execute an interaction sequence in order, with DOM stability waits between actions.
|
|
1037
|
+
*
|
|
1038
|
+
* Runs each action sequentially, waiting for `settleTime` milliseconds between actions
|
|
1039
|
+
* to allow the DOM to stabilize. This ensures observers can capture resulting changes
|
|
1040
|
+
* before the next action fires.
|
|
1041
|
+
*
|
|
1042
|
+
* @param sequence - The interaction sequence to execute
|
|
1043
|
+
* @param document - The target document
|
|
1044
|
+
* @param onEvent - Callback to emit accessibility events
|
|
1045
|
+
* @param getTimestamp - Function returning current timestamp in ms since session start
|
|
1046
|
+
* @param settleTime - Milliseconds to wait between actions for DOM stability (default: 100)
|
|
1047
|
+
*/
|
|
1048
|
+
declare function executeSequence(sequence: InteractionSequence, document: Document, onEvent: (event: AccessibilityEvent) => void, getTimestamp: () => number, settleTime?: number): Promise<void>;
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* Built-in Interaction Patterns
|
|
1052
|
+
*
|
|
1053
|
+
* Provides pre-defined interaction sequences for common ARIA widget patterns.
|
|
1054
|
+
* Each pattern exercises standard keyboard interaction behavior as defined by
|
|
1055
|
+
* the WAI-ARIA Authoring Practices. Patterns use configurable selectors that
|
|
1056
|
+
* can be overridden to match component-specific markup.
|
|
1057
|
+
*
|
|
1058
|
+
* @module runtime/patterns
|
|
1059
|
+
*/
|
|
1060
|
+
|
|
1061
|
+
/**
|
|
1062
|
+
* Optional map of CSS selectors to override defaults for built-in patterns.
|
|
1063
|
+
*
|
|
1064
|
+
* - `trigger` — element that opens/activates the widget
|
|
1065
|
+
* - `container` — wrapper/container element for the widget
|
|
1066
|
+
* - `content` — the content region within the widget
|
|
1067
|
+
* - `items` — individual items within the widget (options, tabs, etc.)
|
|
1068
|
+
* - `input` — text input element within the widget
|
|
1069
|
+
*/
|
|
1070
|
+
interface PatternSelectorMap {
|
|
1071
|
+
trigger?: string;
|
|
1072
|
+
container?: string;
|
|
1073
|
+
content?: string;
|
|
1074
|
+
items?: string;
|
|
1075
|
+
input?: string;
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Names of built-in interaction patterns.
|
|
1079
|
+
*/
|
|
1080
|
+
type BuiltinPatternName = 'modal-dialog' | 'combobox' | 'tabs' | 'accordion';
|
|
1081
|
+
/**
|
|
1082
|
+
* Get a built-in interaction pattern by name.
|
|
1083
|
+
*
|
|
1084
|
+
* Each pattern returns an InteractionSequence with a descriptive name and the
|
|
1085
|
+
* appropriate actions for testing common ARIA widget patterns. Optional selectors
|
|
1086
|
+
* can override the defaults used to locate trigger, container, and content elements.
|
|
1087
|
+
*
|
|
1088
|
+
* Default selectors:
|
|
1089
|
+
* - modal-dialog: trigger = 'button', container = '[role="dialog"], dialog'
|
|
1090
|
+
* - combobox: input = '[role="combobox"], input[type="text"]', items = '[role="option"]'
|
|
1091
|
+
* - tabs: container = '[role="tablist"]', items = '[role="tab"]'
|
|
1092
|
+
* - accordion: trigger = 'button[aria-expanded]'
|
|
1093
|
+
*
|
|
1094
|
+
* @param name - The built-in pattern name
|
|
1095
|
+
* @param selectors - Optional CSS selectors to override defaults
|
|
1096
|
+
* @returns An InteractionSequence representing the pattern
|
|
1097
|
+
*/
|
|
1098
|
+
declare function getBuiltinPattern(name: BuiltinPatternName, selectors?: PatternSelectorMap): InteractionSequence;
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Heuristic Warning Analyzer
|
|
1102
|
+
*
|
|
1103
|
+
* Processes accessibility events one at a time and emits WARNING events
|
|
1104
|
+
* when common runtime accessibility anti-patterns are detected. Operates
|
|
1105
|
+
* independently of baselines, providing value from the first run.
|
|
1106
|
+
*
|
|
1107
|
+
* Detected patterns:
|
|
1108
|
+
* - Focus not moved into modal dialog within configured timeout (default: 100ms)
|
|
1109
|
+
* - Focus escaped modal dialog (focus moved to element outside open dialog)
|
|
1110
|
+
* - Rapid announcements (too many in a short window)
|
|
1111
|
+
* - Keyboard action with no accessibility response within timeout
|
|
1112
|
+
* - Focused element removed from DOM without explicit focus management
|
|
1113
|
+
*
|
|
1114
|
+
* Uses event timestamps (not real-time timers) for timeout detection,
|
|
1115
|
+
* enabling deterministic testing with jsdom.
|
|
1116
|
+
*
|
|
1117
|
+
* @module runtime/heuristics
|
|
1118
|
+
*/
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Configuration for heuristic warning thresholds.
|
|
1122
|
+
*/
|
|
1123
|
+
interface HeuristicConfig {
|
|
1124
|
+
/** Time window to detect focus moving into dialog (default: 100ms) */
|
|
1125
|
+
dialogFocusTimeout: number;
|
|
1126
|
+
/** Time window to detect rapid announcements (default: 500ms) */
|
|
1127
|
+
rapidAnnouncementWindow: number;
|
|
1128
|
+
/** Threshold for rapid announcement count (default: 3) */
|
|
1129
|
+
rapidAnnouncementThreshold: number;
|
|
1130
|
+
/** Time window to detect keyboard action response (default: 200ms) */
|
|
1131
|
+
keyboardResponseTimeout: number;
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Processes accessibility events and detects runtime anti-patterns.
|
|
1135
|
+
*/
|
|
1136
|
+
interface HeuristicAnalyzer {
|
|
1137
|
+
/** Process an event and return any warnings it triggers */
|
|
1138
|
+
process(event: AccessibilityEvent): AccessibilityEvent[];
|
|
1139
|
+
/** Get current open dialog selectors (for focus escape detection) */
|
|
1140
|
+
readonly openDialogs: string[];
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Creates a heuristic analyzer that processes accessibility events and
|
|
1144
|
+
* emits warnings when common anti-patterns are detected.
|
|
1145
|
+
*
|
|
1146
|
+
* The analyzer uses event timestamps for timeout detection rather than
|
|
1147
|
+
* real-time timers, making it deterministic and testable with jsdom.
|
|
1148
|
+
*/
|
|
1149
|
+
declare function createHeuristicAnalyzer(config?: Partial<HeuristicConfig>): HeuristicAnalyzer;
|
|
1150
|
+
|
|
1151
|
+
/**
|
|
1152
|
+
* Deterministic serialization and deserialization for Runtime Accessibility
|
|
1153
|
+
* Timeline types.
|
|
1154
|
+
*
|
|
1155
|
+
* All serializers produce JSON with recursively sorted keys and 2-space
|
|
1156
|
+
* indentation, guaranteeing:
|
|
1157
|
+
* - Byte-identical output for equivalent inputs (determinism)
|
|
1158
|
+
* - Round-trip integrity (serialize → deserialize → serialize = identical)
|
|
1159
|
+
* - Stable version-control diffs
|
|
1160
|
+
*/
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* Serializes an AccessibilityEvent to deterministic JSON with sorted keys
|
|
1164
|
+
* and 2-space indentation.
|
|
1165
|
+
*
|
|
1166
|
+
* @param event - The accessibility event to serialize
|
|
1167
|
+
* @returns Deterministic JSON string
|
|
1168
|
+
*/
|
|
1169
|
+
declare function serializeEvent(event: AccessibilityEvent): string;
|
|
1170
|
+
/**
|
|
1171
|
+
* Deserializes a JSON string into a validated AccessibilityEvent.
|
|
1172
|
+
*
|
|
1173
|
+
* @param json - JSON string to parse
|
|
1174
|
+
* @returns Validated AccessibilityEvent
|
|
1175
|
+
* @throws Error if the JSON is invalid or does not conform to the event schema
|
|
1176
|
+
*/
|
|
1177
|
+
declare function deserializeEvent(json: string): AccessibilityEvent;
|
|
1178
|
+
/**
|
|
1179
|
+
* Serializes an AccessibilityTimeline to deterministic JSON with sorted keys
|
|
1180
|
+
* and 2-space indentation.
|
|
1181
|
+
*
|
|
1182
|
+
* @param timeline - The accessibility timeline to serialize
|
|
1183
|
+
* @returns Deterministic JSON string
|
|
1184
|
+
*/
|
|
1185
|
+
declare function serializeTimeline(timeline: AccessibilityTimeline): string;
|
|
1186
|
+
/**
|
|
1187
|
+
* Deserializes a JSON string into a validated AccessibilityTimeline.
|
|
1188
|
+
*
|
|
1189
|
+
* @param json - JSON string to parse
|
|
1190
|
+
* @returns Validated AccessibilityTimeline
|
|
1191
|
+
* @throws Error if the JSON is invalid or does not conform to the timeline schema
|
|
1192
|
+
*/
|
|
1193
|
+
declare function deserializeTimeline(json: string): AccessibilityTimeline;
|
|
1194
|
+
/**
|
|
1195
|
+
* Serializes an InteractionSequence to deterministic JSON with sorted keys
|
|
1196
|
+
* and 2-space indentation.
|
|
1197
|
+
*
|
|
1198
|
+
* @param seq - The interaction sequence to serialize
|
|
1199
|
+
* @returns Deterministic JSON string
|
|
1200
|
+
*/
|
|
1201
|
+
declare function serializeInteractionSequence(seq: InteractionSequence): string;
|
|
1202
|
+
/**
|
|
1203
|
+
* Deserializes a JSON string into a validated InteractionSequence.
|
|
1204
|
+
*
|
|
1205
|
+
* @param json - JSON string to parse
|
|
1206
|
+
* @returns Validated InteractionSequence
|
|
1207
|
+
* @throws Error if the JSON is invalid or does not conform to the interaction schema
|
|
1208
|
+
*/
|
|
1209
|
+
declare function deserializeInteractionSequence(json: string): InteractionSequence;
|
|
1210
|
+
/**
|
|
1211
|
+
* Checks whether two AccessibilityTimelines are deeply equal by comparing
|
|
1212
|
+
* their deterministic serializations. Because serialization sorts keys
|
|
1213
|
+
* recursively, structurally equivalent timelines produce identical strings.
|
|
1214
|
+
*
|
|
1215
|
+
* @param a - First timeline
|
|
1216
|
+
* @param b - Second timeline
|
|
1217
|
+
* @returns true if timelines are equivalent
|
|
1218
|
+
*/
|
|
1219
|
+
declare function timelinesEqual(a: AccessibilityTimeline, b: AccessibilityTimeline): boolean;
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* Stable CSS Selector Generation
|
|
1223
|
+
*
|
|
1224
|
+
* Generates unique, deterministic CSS selectors for DOM elements.
|
|
1225
|
+
* The selector strategy prioritizes stability and readability:
|
|
1226
|
+
*
|
|
1227
|
+
* 1. If the element has an ID, return `#id`
|
|
1228
|
+
* 2. Walk up from the element to the document root, building a path
|
|
1229
|
+
* 3. At each level, try tag name alone, then tag+classes, then tag:nth-child(n)
|
|
1230
|
+
* 4. Stop building the path when the partial selector already uniquely identifies the element
|
|
1231
|
+
*/
|
|
1232
|
+
/**
|
|
1233
|
+
* Generate a stable CSS selector that uniquely identifies the given element
|
|
1234
|
+
* within its document.
|
|
1235
|
+
*
|
|
1236
|
+
* The selector is deterministic: given the same DOM structure, the same element
|
|
1237
|
+
* will always produce the same selector string.
|
|
1238
|
+
*/
|
|
1239
|
+
declare function generateSelector(element: Element): string;
|
|
1240
|
+
|
|
1241
|
+
/**
|
|
1242
|
+
* Behavior Diff Engine
|
|
1243
|
+
*
|
|
1244
|
+
* Compares two Accessibility Timelines and produces a BehaviorDiffReport
|
|
1245
|
+
* describing added, removed, and modified events. Events are matched by
|
|
1246
|
+
* type + target selector. Timestamp differences alone do not count as
|
|
1247
|
+
* modifications.
|
|
1248
|
+
*/
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* A single entry in the diff report representing one difference between
|
|
1252
|
+
* baseline and current timelines.
|
|
1253
|
+
*/
|
|
1254
|
+
interface DiffEntry {
|
|
1255
|
+
/** The event from the current timeline (for added/modified) or baseline (for removed) */
|
|
1256
|
+
event: AccessibilityEvent;
|
|
1257
|
+
/** The corresponding event from the other timeline (for modified entries) */
|
|
1258
|
+
previousEvent?: AccessibilityEvent;
|
|
1259
|
+
/** Human-readable description of the difference */
|
|
1260
|
+
message: string;
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Structured summary of differences between two Accessibility Timelines.
|
|
1264
|
+
*/
|
|
1265
|
+
interface BehaviorDiffReport {
|
|
1266
|
+
baseline: {
|
|
1267
|
+
totalEvents: number;
|
|
1268
|
+
};
|
|
1269
|
+
current: {
|
|
1270
|
+
totalEvents: number;
|
|
1271
|
+
};
|
|
1272
|
+
/** Events present in current but not in baseline */
|
|
1273
|
+
added: DiffEntry[];
|
|
1274
|
+
/** Events present in baseline but not in current */
|
|
1275
|
+
removed: DiffEntry[];
|
|
1276
|
+
/** Events present in both but with different payloads */
|
|
1277
|
+
modified: DiffEntry[];
|
|
1278
|
+
/** Aggregate counts (must equal array lengths exactly) */
|
|
1279
|
+
summary: {
|
|
1280
|
+
totalBaseline: number;
|
|
1281
|
+
totalCurrent: number;
|
|
1282
|
+
added: number;
|
|
1283
|
+
removed: number;
|
|
1284
|
+
modified: number;
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Compare two Accessibility Timelines and produce a structured diff report.
|
|
1289
|
+
*
|
|
1290
|
+
* Algorithm:
|
|
1291
|
+
* 1. Create matching keys for events: type + target selector
|
|
1292
|
+
* 2. Walk baseline events and find matching current events
|
|
1293
|
+
* 3. If matched: compare payloads (ignoring timestamp). Different = modified.
|
|
1294
|
+
* 4. If no match in current: classify as removed
|
|
1295
|
+
* 5. Unmatched current events: classify as added
|
|
1296
|
+
* 6. Timestamp-only differences do NOT count as modifications
|
|
1297
|
+
*/
|
|
1298
|
+
declare function diffTimelines(baseline: AccessibilityTimeline, current: AccessibilityTimeline): BehaviorDiffReport;
|
|
1299
|
+
|
|
1300
|
+
type SeverityLevel = 'critical' | 'high' | 'medium' | 'low';
|
|
1301
|
+
interface ClassifiedDiffEntry {
|
|
1302
|
+
event: AccessibilityEvent;
|
|
1303
|
+
previousEvent?: AccessibilityEvent;
|
|
1304
|
+
message: string;
|
|
1305
|
+
severity: SeverityLevel;
|
|
1306
|
+
}
|
|
1307
|
+
interface ClassifiedDiffReport {
|
|
1308
|
+
entries: ClassifiedDiffEntry[];
|
|
1309
|
+
highestSeverity: SeverityLevel | null;
|
|
1310
|
+
criticalCount: number;
|
|
1311
|
+
highCount: number;
|
|
1312
|
+
mediumCount: number;
|
|
1313
|
+
lowCount: number;
|
|
1314
|
+
}
|
|
1315
|
+
declare function classifyDiff(report: BehaviorDiffReport): ClassifiedDiffReport;
|
|
1316
|
+
|
|
1317
|
+
interface BaselineFile {
|
|
1318
|
+
baseline: {
|
|
1319
|
+
createdAt: string;
|
|
1320
|
+
speakableVersion: string;
|
|
1321
|
+
storybookUrl?: string;
|
|
1322
|
+
interactionSequence: string;
|
|
1323
|
+
};
|
|
1324
|
+
timeline: AccessibilityTimeline;
|
|
1325
|
+
}
|
|
1326
|
+
interface BaselineStorage {
|
|
1327
|
+
save(componentName: string, storyName: string, timeline: AccessibilityTimeline, meta?: {
|
|
1328
|
+
storybookUrl?: string;
|
|
1329
|
+
}): Promise<void>;
|
|
1330
|
+
load(componentName: string, storyName: string): Promise<BaselineFile | null>;
|
|
1331
|
+
exists(componentName: string, storyName: string): Promise<boolean>;
|
|
1332
|
+
getBaselinePath(componentName: string, storyName: string): string;
|
|
1333
|
+
}
|
|
1334
|
+
declare function createBaselineStorage(baseDir: string): BaselineStorage;
|
|
1335
|
+
|
|
1336
|
+
/**
|
|
1337
|
+
* Runtime Accessibility Timeline - Public API
|
|
1338
|
+
*
|
|
1339
|
+
* Exports all public types, interfaces, and factory functions for the
|
|
1340
|
+
* Runtime Accessibility Engine. This module provides:
|
|
1341
|
+
*
|
|
1342
|
+
* - Event type system (EventType, AccessibilityEvent, payloads)
|
|
1343
|
+
* - Runtime engine (createEngine)
|
|
1344
|
+
* - Timeline generation (createTimelineGenerator)
|
|
1345
|
+
* - Interaction execution (executeAction, executeSequence)
|
|
1346
|
+
* - Built-in patterns (getBuiltinPattern)
|
|
1347
|
+
* - Heuristic analysis (createHeuristicAnalyzer)
|
|
1348
|
+
* - Serialization (serializeTimeline, deserializeTimeline, etc.)
|
|
1349
|
+
* - Stable CSS selector generation (generateSelector)
|
|
1350
|
+
*/
|
|
1351
|
+
|
|
1352
|
+
type index_AccessibilityEvent = AccessibilityEvent;
|
|
1353
|
+
type index_AccessibilityTimeline = AccessibilityTimeline;
|
|
1354
|
+
type index_AccessibleNameChangedPayload = AccessibleNameChangedPayload;
|
|
1355
|
+
type index_AnnouncementPayload = AnnouncementPayload;
|
|
1356
|
+
type index_BaselineFile = BaselineFile;
|
|
1357
|
+
type index_BaselineStorage = BaselineStorage;
|
|
1358
|
+
type index_BehaviorDiffReport = BehaviorDiffReport;
|
|
1359
|
+
type index_BuiltinPatternName = BuiltinPatternName;
|
|
1360
|
+
type index_ClassifiedDiffEntry = ClassifiedDiffEntry;
|
|
1361
|
+
type index_ClassifiedDiffReport = ClassifiedDiffReport;
|
|
1362
|
+
type index_DialogClosedPayload = DialogClosedPayload;
|
|
1363
|
+
type index_DialogOpenedPayload = DialogOpenedPayload;
|
|
1364
|
+
type index_DiffEntry = DiffEntry;
|
|
1365
|
+
type index_EngineOptions = EngineOptions;
|
|
1366
|
+
type index_EventPayload = EventPayload;
|
|
1367
|
+
type index_EventTarget = EventTarget;
|
|
1368
|
+
type index_EventType = EventType;
|
|
1369
|
+
type index_FocusChangedPayload = FocusChangedPayload;
|
|
1370
|
+
type index_HeuristicAnalyzer = HeuristicAnalyzer;
|
|
1371
|
+
type index_HeuristicConfig = HeuristicConfig;
|
|
1372
|
+
type index_InteractionAction = InteractionAction;
|
|
1373
|
+
type index_InteractionSequence = InteractionSequence;
|
|
1374
|
+
type index_KeyboardActionPayload = KeyboardActionPayload;
|
|
1375
|
+
type index_PatternSelectorMap = PatternSelectorMap;
|
|
1376
|
+
type index_RoleChangedPayload = RoleChangedPayload;
|
|
1377
|
+
type index_RuntimeAccessibilityEngine = RuntimeAccessibilityEngine;
|
|
1378
|
+
type index_SeverityLevel = SeverityLevel;
|
|
1379
|
+
type index_StateChangedPayload = StateChangedPayload;
|
|
1380
|
+
type index_TimelineGenerator = TimelineGenerator;
|
|
1381
|
+
type index_TimelineGeneratorOptions = TimelineGeneratorOptions;
|
|
1382
|
+
type index_TimelineMetadata = TimelineMetadata;
|
|
1383
|
+
type index_WarningPayload = WarningPayload;
|
|
1384
|
+
declare const index_classifyDiff: typeof classifyDiff;
|
|
1385
|
+
declare const index_createBaselineStorage: typeof createBaselineStorage;
|
|
1386
|
+
declare const index_createEngine: typeof createEngine;
|
|
1387
|
+
declare const index_createHeuristicAnalyzer: typeof createHeuristicAnalyzer;
|
|
1388
|
+
declare const index_createTimelineGenerator: typeof createTimelineGenerator;
|
|
1389
|
+
declare const index_deserializeEvent: typeof deserializeEvent;
|
|
1390
|
+
declare const index_deserializeInteractionSequence: typeof deserializeInteractionSequence;
|
|
1391
|
+
declare const index_deserializeTimeline: typeof deserializeTimeline;
|
|
1392
|
+
declare const index_diffTimelines: typeof diffTimelines;
|
|
1393
|
+
declare const index_executeAction: typeof executeAction;
|
|
1394
|
+
declare const index_executeSequence: typeof executeSequence;
|
|
1395
|
+
declare const index_generateSelector: typeof generateSelector;
|
|
1396
|
+
declare const index_getBuiltinPattern: typeof getBuiltinPattern;
|
|
1397
|
+
declare const index_serializeEvent: typeof serializeEvent;
|
|
1398
|
+
declare const index_serializeInteractionSequence: typeof serializeInteractionSequence;
|
|
1399
|
+
declare const index_serializeTimeline: typeof serializeTimeline;
|
|
1400
|
+
declare const index_timelinesEqual: typeof timelinesEqual;
|
|
1401
|
+
declare namespace index {
|
|
1402
|
+
export { type index_AccessibilityEvent as AccessibilityEvent, type index_AccessibilityTimeline as AccessibilityTimeline, type index_AccessibleNameChangedPayload as AccessibleNameChangedPayload, type index_AnnouncementPayload as AnnouncementPayload, type index_BaselineFile as BaselineFile, type index_BaselineStorage as BaselineStorage, type index_BehaviorDiffReport as BehaviorDiffReport, type index_BuiltinPatternName as BuiltinPatternName, type index_ClassifiedDiffEntry as ClassifiedDiffEntry, type index_ClassifiedDiffReport as ClassifiedDiffReport, type index_DialogClosedPayload as DialogClosedPayload, type index_DialogOpenedPayload as DialogOpenedPayload, type index_DiffEntry as DiffEntry, type index_EngineOptions as EngineOptions, type index_EventPayload as EventPayload, type index_EventTarget as EventTarget, type index_EventType as EventType, type index_FocusChangedPayload as FocusChangedPayload, type index_HeuristicAnalyzer as HeuristicAnalyzer, type index_HeuristicConfig as HeuristicConfig, type index_InteractionAction as InteractionAction, type index_InteractionSequence as InteractionSequence, type index_KeyboardActionPayload as KeyboardActionPayload, type index_PatternSelectorMap as PatternSelectorMap, type index_RoleChangedPayload as RoleChangedPayload, type index_RuntimeAccessibilityEngine as RuntimeAccessibilityEngine, type index_SeverityLevel as SeverityLevel, type index_StateChangedPayload as StateChangedPayload, type index_TimelineGenerator as TimelineGenerator, type index_TimelineGeneratorOptions as TimelineGeneratorOptions, type index_TimelineMetadata as TimelineMetadata, type index_WarningPayload as WarningPayload, index_classifyDiff as classifyDiff, index_createBaselineStorage as createBaselineStorage, index_createEngine as createEngine, index_createHeuristicAnalyzer as createHeuristicAnalyzer, index_createTimelineGenerator as createTimelineGenerator, index_deserializeEvent as deserializeEvent, index_deserializeInteractionSequence as deserializeInteractionSequence, index_deserializeTimeline as deserializeTimeline, index_diffTimelines as diffTimelines, index_executeAction as executeAction, index_executeSequence as executeSequence, index_generateSelector as generateSelector, index_getBuiltinPattern as getBuiltinPattern, index_serializeEvent as serializeEvent, index_serializeInteractionSequence as serializeInteractionSequence, index_serializeTimeline as serializeTimeline, index_timelinesEqual as timelinesEqual };
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
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, index as runtime, serializeModel, validateHTMLNotEmpty, validateModel, validateRole, validateState, validateTreeStructure };
|