@aishware/react-a11y-core 0.1.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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -0
  3. package/dist/aria.d.ts +4 -0
  4. package/dist/aria.d.ts.map +1 -0
  5. package/dist/aria.js +10 -0
  6. package/dist/color.d.ts +21 -0
  7. package/dist/color.d.ts.map +1 -0
  8. package/dist/color.js +93 -0
  9. package/dist/config.d.ts +5 -0
  10. package/dist/config.d.ts.map +1 -0
  11. package/dist/config.js +39 -0
  12. package/dist/element.d.ts +50 -0
  13. package/dist/element.d.ts.map +1 -0
  14. package/dist/element.js +162 -0
  15. package/dist/engine.d.ts +18 -0
  16. package/dist/engine.d.ts.map +1 -0
  17. package/dist/engine.js +52 -0
  18. package/dist/fixes.d.ts +15 -0
  19. package/dist/fixes.d.ts.map +1 -0
  20. package/dist/fixes.js +32 -0
  21. package/dist/helpers.d.ts +74 -0
  22. package/dist/helpers.d.ts.map +1 -0
  23. package/dist/helpers.js +209 -0
  24. package/dist/index.d.ts +15 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +14 -0
  27. package/dist/parse.d.ts +3 -0
  28. package/dist/parse.d.ts.map +1 -0
  29. package/dist/parse.js +14 -0
  30. package/dist/pkg-meta.d.ts +21 -0
  31. package/dist/pkg-meta.d.ts.map +1 -0
  32. package/dist/pkg-meta.js +31 -0
  33. package/dist/reporters/json.d.ts +3 -0
  34. package/dist/reporters/json.d.ts.map +1 -0
  35. package/dist/reporters/json.js +9 -0
  36. package/dist/reporters/sarif.d.ts +9 -0
  37. package/dist/reporters/sarif.d.ts.map +1 -0
  38. package/dist/reporters/sarif.js +61 -0
  39. package/dist/scanner.d.ts +16 -0
  40. package/dist/scanner.d.ts.map +1 -0
  41. package/dist/scanner.js +113 -0
  42. package/dist/types.d.ts +109 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/types.js +6 -0
  45. package/dist/wcag.d.ts +28 -0
  46. package/dist/wcag.d.ts.map +1 -0
  47. package/dist/wcag.js +117 -0
  48. package/package.json +36 -0
@@ -0,0 +1,109 @@
1
+ export type Platform = 'web' | 'native';
2
+ export type Severity = 'critical' | 'serious' | 'moderate' | 'minor';
3
+ export declare const SEVERITY_ORDER: Record<Severity, number>;
4
+ export type WcagLevel = 'A' | 'AA' | 'AAA';
5
+ export interface WcagRef {
6
+ /** Success criterion number, e.g. "1.1.1" */
7
+ sc: string;
8
+ name: string;
9
+ level: WcagLevel;
10
+ /** WCAG version the criterion first appeared in, e.g. "2.0" or "2.2" */
11
+ version: string;
12
+ url: string;
13
+ }
14
+ /** A source replacement: [start, end) character offsets in the file. */
15
+ export interface Fix {
16
+ start: number;
17
+ end: number;
18
+ replacement: string;
19
+ }
20
+ export interface Diagnostic {
21
+ ruleId: string;
22
+ message: string;
23
+ severity: Severity;
24
+ file: string;
25
+ line: number;
26
+ column: number;
27
+ endLine: number;
28
+ endColumn: number;
29
+ wcag: WcagRef[];
30
+ helpUrl?: string;
31
+ /** Mechanical fix, applied by `--fix`. Only set when unambiguously correct. */
32
+ fix?: Fix;
33
+ }
34
+ export interface RuleMeta {
35
+ id: string;
36
+ description: string;
37
+ severity: Severity;
38
+ platforms: Platform[];
39
+ /** WCAG success criterion numbers, resolved against the WCAG 2.2 table. */
40
+ wcag: string[];
41
+ /**
42
+ * True when the rule checks only a statically-decidable slice of its
43
+ * criteria (e.g. contrast of inline literal styles). Coverage reporting
44
+ * marks these criteria as partially automated.
45
+ */
46
+ partial?: boolean;
47
+ /** True when at least some reports from this rule carry an autofix. */
48
+ fixable?: boolean;
49
+ /**
50
+ * True when the rule's findings come only from project-wide analysis (a
51
+ * project pass or `projectCheck`), never from per-file scanning — e.g.
52
+ * cross-file label resolution or config-file checks. Lets editors route
53
+ * these to a project-scan surface instead of live per-file linting.
54
+ */
55
+ project?: boolean;
56
+ helpUrl?: string;
57
+ }
58
+ export interface ReportDescriptor {
59
+ el: import('./element.js').ElementNode;
60
+ message: string;
61
+ /** Per-report severity override (e.g. tiered touch-target sizes). */
62
+ severity?: Severity;
63
+ fix?: Fix;
64
+ }
65
+ /**
66
+ * Cross-file analysis: `collect` sees every file's model during the scan,
67
+ * `finalize` reports once the whole project has been seen. Used for checks
68
+ * a single file cannot decide, like <label htmlFor> ↔ id resolution.
69
+ */
70
+ export interface ProjectPass {
71
+ collect(model: import('./element.js').FileModel, filename: string): void;
72
+ finalize(): Diagnostic[];
73
+ }
74
+ export interface RuleContext {
75
+ filename: string;
76
+ platform: Platform;
77
+ sourceFile: import('typescript').SourceFile;
78
+ report(descriptor: ReportDescriptor): void;
79
+ }
80
+ export interface RuleVisitor {
81
+ element?(el: import('./element.js').ElementNode): void;
82
+ }
83
+ export interface Rule {
84
+ meta: RuleMeta;
85
+ create(ctx: RuleContext): RuleVisitor;
86
+ /**
87
+ * Optional project-level check for configuration files outside the JSX
88
+ * scan (app.json, AndroidManifest.xml, …). Runs once per scan; returned
89
+ * diagnostics use paths relative to the project root.
90
+ */
91
+ projectCheck?(root: string): Diagnostic[];
92
+ }
93
+ export type RuleSetting = 'off' | Severity;
94
+ export interface A11yConfig {
95
+ /** Per-rule overrides: "off" disables, a severity re-classifies. */
96
+ rules?: Record<string, RuleSetting>;
97
+ /** Glob patterns (relative to project root) to skip. */
98
+ ignore?: string[];
99
+ /** Force a platform instead of auto-detecting from package.json. */
100
+ platform?: Platform;
101
+ }
102
+ export interface ScanResult {
103
+ diagnostics: Diagnostic[];
104
+ filesScanned: number;
105
+ durationMs: number;
106
+ platform: Platform;
107
+ root: string;
108
+ }
109
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAC;AAExC,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,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AAW,UAAU;IACzB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ export const SEVERITY_ORDER = {
2
+ critical: 4,
3
+ serious: 3,
4
+ moderate: 2,
5
+ minor: 1,
6
+ };
package/dist/wcag.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import type { WcagRef } from './types.js';
2
+ /**
3
+ * Every WCAG 2.2 Level A and AA success criterion (plus AAA criteria the
4
+ * rule packs reference). 2.2 is the current W3C Recommendation; criteria
5
+ * carry the version they first appeared in so reports can say "new in 2.2".
6
+ */
7
+ export declare const WCAG: Record<string, WcagRef>;
8
+ /** All 55 Level A + AA criteria of WCAG 2.2, in document order. */
9
+ export declare const WCAG22_A_AA: string[];
10
+ /**
11
+ * Success criterion counts for WCAG 2.2 (the current Recommendation):
12
+ * 31 Level A + 24 Level AA + 31 Level AAA = 86 total (4.1.1 was removed).
13
+ * Used by coverage reporting.
14
+ */
15
+ export declare const WCAG22_TOTALS: {
16
+ readonly A: 31;
17
+ readonly AA: 24;
18
+ readonly AAA: 31;
19
+ readonly total: 86;
20
+ };
21
+ export declare function resolveWcag(scs: string[]): WcagRef[];
22
+ /**
23
+ * One-line verification guidance for A+AA criteria that cannot be decided
24
+ * from source code alone. Surfaced by `react-a11y --coverage` so every
25
+ * criterion is either machine-checked or has an explicit manual check.
26
+ */
27
+ export declare const MANUAL_CHECKS: Record<string, string>;
28
+ //# sourceMappingURL=wcag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wcag.d.ts","sourceRoot":"","sources":["../src/wcag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAyDxC,CAAC;AAEF,mEAAmE;AACnE,eAAO,MAAM,WAAW,EAAE,MAAM,EAET,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;CAAiD,CAAC;AAE5E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAMpD;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA6BhD,CAAC"}
package/dist/wcag.js ADDED
@@ -0,0 +1,117 @@
1
+ const U = 'https://www.w3.org/WAI/WCAG22/Understanding/';
2
+ /**
3
+ * Every WCAG 2.2 Level A and AA success criterion (plus AAA criteria the
4
+ * rule packs reference). 2.2 is the current W3C Recommendation; criteria
5
+ * carry the version they first appeared in so reports can say "new in 2.2".
6
+ */
7
+ export const WCAG = {
8
+ '1.1.1': { sc: '1.1.1', name: 'Non-text Content', level: 'A', version: '2.0', url: `${U}non-text-content` },
9
+ '1.2.1': { sc: '1.2.1', name: 'Audio-only and Video-only (Prerecorded)', level: 'A', version: '2.0', url: `${U}audio-only-and-video-only-prerecorded` },
10
+ '1.2.2': { sc: '1.2.2', name: 'Captions (Prerecorded)', level: 'A', version: '2.0', url: `${U}captions-prerecorded` },
11
+ '1.2.3': { sc: '1.2.3', name: 'Audio Description or Media Alternative (Prerecorded)', level: 'A', version: '2.0', url: `${U}audio-description-or-media-alternative-prerecorded` },
12
+ '1.2.4': { sc: '1.2.4', name: 'Captions (Live)', level: 'AA', version: '2.0', url: `${U}captions-live` },
13
+ '1.2.5': { sc: '1.2.5', name: 'Audio Description (Prerecorded)', level: 'AA', version: '2.0', url: `${U}audio-description-prerecorded` },
14
+ '1.3.1': { sc: '1.3.1', name: 'Info and Relationships', level: 'A', version: '2.0', url: `${U}info-and-relationships` },
15
+ '1.3.2': { sc: '1.3.2', name: 'Meaningful Sequence', level: 'A', version: '2.0', url: `${U}meaningful-sequence` },
16
+ '1.3.3': { sc: '1.3.3', name: 'Sensory Characteristics', level: 'A', version: '2.0', url: `${U}sensory-characteristics` },
17
+ '1.3.4': { sc: '1.3.4', name: 'Orientation', level: 'AA', version: '2.1', url: `${U}orientation` },
18
+ '1.3.5': { sc: '1.3.5', name: 'Identify Input Purpose', level: 'AA', version: '2.1', url: `${U}identify-input-purpose` },
19
+ '1.4.1': { sc: '1.4.1', name: 'Use of Color', level: 'A', version: '2.0', url: `${U}use-of-color` },
20
+ '1.4.2': { sc: '1.4.2', name: 'Audio Control', level: 'A', version: '2.0', url: `${U}audio-control` },
21
+ '1.4.3': { sc: '1.4.3', name: 'Contrast (Minimum)', level: 'AA', version: '2.0', url: `${U}contrast-minimum` },
22
+ '1.4.4': { sc: '1.4.4', name: 'Resize Text', level: 'AA', version: '2.0', url: `${U}resize-text` },
23
+ '1.4.5': { sc: '1.4.5', name: 'Images of Text', level: 'AA', version: '2.0', url: `${U}images-of-text` },
24
+ '1.4.10': { sc: '1.4.10', name: 'Reflow', level: 'AA', version: '2.1', url: `${U}reflow` },
25
+ '1.4.11': { sc: '1.4.11', name: 'Non-text Contrast', level: 'AA', version: '2.1', url: `${U}non-text-contrast` },
26
+ '1.4.12': { sc: '1.4.12', name: 'Text Spacing', level: 'AA', version: '2.1', url: `${U}text-spacing` },
27
+ '1.4.13': { sc: '1.4.13', name: 'Content on Hover or Focus', level: 'AA', version: '2.1', url: `${U}content-on-hover-or-focus` },
28
+ '2.1.1': { sc: '2.1.1', name: 'Keyboard', level: 'A', version: '2.0', url: `${U}keyboard` },
29
+ '2.1.2': { sc: '2.1.2', name: 'No Keyboard Trap', level: 'A', version: '2.0', url: `${U}no-keyboard-trap` },
30
+ '2.1.4': { sc: '2.1.4', name: 'Character Key Shortcuts', level: 'A', version: '2.1', url: `${U}character-key-shortcuts` },
31
+ '2.2.1': { sc: '2.2.1', name: 'Timing Adjustable', level: 'A', version: '2.0', url: `${U}timing-adjustable` },
32
+ '2.2.2': { sc: '2.2.2', name: 'Pause, Stop, Hide', level: 'A', version: '2.0', url: `${U}pause-stop-hide` },
33
+ '2.3.1': { sc: '2.3.1', name: 'Three Flashes or Below Threshold', level: 'A', version: '2.0', url: `${U}three-flashes-or-below-threshold` },
34
+ '2.4.1': { sc: '2.4.1', name: 'Bypass Blocks', level: 'A', version: '2.0', url: `${U}bypass-blocks` },
35
+ '2.4.2': { sc: '2.4.2', name: 'Page Titled', level: 'A', version: '2.0', url: `${U}page-titled` },
36
+ '2.4.3': { sc: '2.4.3', name: 'Focus Order', level: 'A', version: '2.0', url: `${U}focus-order` },
37
+ '2.4.4': { sc: '2.4.4', name: 'Link Purpose (In Context)', level: 'A', version: '2.0', url: `${U}link-purpose-in-context` },
38
+ '2.4.5': { sc: '2.4.5', name: 'Multiple Ways', level: 'AA', version: '2.0', url: `${U}multiple-ways` },
39
+ '2.4.6': { sc: '2.4.6', name: 'Headings and Labels', level: 'AA', version: '2.0', url: `${U}headings-and-labels` },
40
+ '2.4.7': { sc: '2.4.7', name: 'Focus Visible', level: 'AA', version: '2.0', url: `${U}focus-visible` },
41
+ '2.4.11': { sc: '2.4.11', name: 'Focus Not Obscured (Minimum)', level: 'AA', version: '2.2', url: `${U}focus-not-obscured-minimum` },
42
+ '2.5.1': { sc: '2.5.1', name: 'Pointer Gestures', level: 'A', version: '2.1', url: `${U}pointer-gestures` },
43
+ '2.5.2': { sc: '2.5.2', name: 'Pointer Cancellation', level: 'A', version: '2.1', url: `${U}pointer-cancellation` },
44
+ '2.5.3': { sc: '2.5.3', name: 'Label in Name', level: 'A', version: '2.1', url: `${U}label-in-name` },
45
+ '2.5.4': { sc: '2.5.4', name: 'Motion Actuation', level: 'A', version: '2.1', url: `${U}motion-actuation` },
46
+ '2.5.5': { sc: '2.5.5', name: 'Target Size (Enhanced)', level: 'AAA', version: '2.1', url: `${U}target-size-enhanced` },
47
+ '2.5.7': { sc: '2.5.7', name: 'Dragging Movements', level: 'AA', version: '2.2', url: `${U}dragging-movements` },
48
+ '2.5.8': { sc: '2.5.8', name: 'Target Size (Minimum)', level: 'AA', version: '2.2', url: `${U}target-size-minimum` },
49
+ '3.1.1': { sc: '3.1.1', name: 'Language of Page', level: 'A', version: '2.0', url: `${U}language-of-page` },
50
+ '3.1.2': { sc: '3.1.2', name: 'Language of Parts', level: 'AA', version: '2.0', url: `${U}language-of-parts` },
51
+ '3.2.1': { sc: '3.2.1', name: 'On Focus', level: 'A', version: '2.0', url: `${U}on-focus` },
52
+ '3.2.2': { sc: '3.2.2', name: 'On Input', level: 'A', version: '2.0', url: `${U}on-input` },
53
+ '3.2.3': { sc: '3.2.3', name: 'Consistent Navigation', level: 'AA', version: '2.0', url: `${U}consistent-navigation` },
54
+ '3.2.4': { sc: '3.2.4', name: 'Consistent Identification', level: 'AA', version: '2.0', url: `${U}consistent-identification` },
55
+ '3.2.6': { sc: '3.2.6', name: 'Consistent Help', level: 'A', version: '2.2', url: `${U}consistent-help` },
56
+ '3.3.1': { sc: '3.3.1', name: 'Error Identification', level: 'A', version: '2.0', url: `${U}error-identification` },
57
+ '3.3.2': { sc: '3.3.2', name: 'Labels or Instructions', level: 'A', version: '2.0', url: `${U}labels-or-instructions` },
58
+ '3.3.3': { sc: '3.3.3', name: 'Error Suggestion', level: 'AA', version: '2.0', url: `${U}error-suggestion` },
59
+ '3.3.4': { sc: '3.3.4', name: 'Error Prevention (Legal, Financial, Data)', level: 'AA', version: '2.0', url: `${U}error-prevention-legal-financial-data` },
60
+ '3.3.7': { sc: '3.3.7', name: 'Redundant Entry', level: 'A', version: '2.2', url: `${U}redundant-entry` },
61
+ '3.3.8': { sc: '3.3.8', name: 'Accessible Authentication (Minimum)', level: 'AA', version: '2.2', url: `${U}accessible-authentication-minimum` },
62
+ '4.1.2': { sc: '4.1.2', name: 'Name, Role, Value', level: 'A', version: '2.0', url: `${U}name-role-value` },
63
+ '4.1.3': { sc: '4.1.3', name: 'Status Messages', level: 'AA', version: '2.1', url: `${U}status-messages` },
64
+ };
65
+ /** All 55 Level A + AA criteria of WCAG 2.2, in document order. */
66
+ export const WCAG22_A_AA = Object.values(WCAG)
67
+ .filter((ref) => ref.level !== 'AAA')
68
+ .map((ref) => ref.sc);
69
+ /**
70
+ * Success criterion counts for WCAG 2.2 (the current Recommendation):
71
+ * 31 Level A + 24 Level AA + 31 Level AAA = 86 total (4.1.1 was removed).
72
+ * Used by coverage reporting.
73
+ */
74
+ export const WCAG22_TOTALS = { A: 31, AA: 24, AAA: 31, total: 86 };
75
+ export function resolveWcag(scs) {
76
+ return scs.map((sc) => {
77
+ const ref = WCAG[sc];
78
+ if (!ref)
79
+ throw new Error(`Unknown WCAG success criterion: ${sc}`);
80
+ return ref;
81
+ });
82
+ }
83
+ /**
84
+ * One-line verification guidance for A+AA criteria that cannot be decided
85
+ * from source code alone. Surfaced by `react-a11y --coverage` so every
86
+ * criterion is either machine-checked or has an explicit manual check.
87
+ */
88
+ export const MANUAL_CHECKS = {
89
+ '1.2.1': 'Audio-only content has a transcript; video-only content has a transcript or audio track.',
90
+ '1.2.3': 'Prerecorded video has an audio description or a full text alternative.',
91
+ '1.2.4': 'Live video streams provide captions.',
92
+ '1.2.5': 'Prerecorded video has an audio description track.',
93
+ '1.3.3': 'Instructions never rely on shape, color, size or position alone ("click the round button on the right").',
94
+ '1.3.4': 'The app works in both portrait and landscape; orientation is not locked without an essential reason.',
95
+ '1.4.1': 'Color is never the only way information is conveyed (e.g. error fields also get text/icons, links are underlined).',
96
+ '1.4.5': 'Text is real text, not baked into images (logos excepted).',
97
+ '1.4.10': 'At 320px wide / 400% zoom, content reflows without two-dimensional scrolling.',
98
+ '1.4.11': 'UI component boundaries and graphical objects have 3:1 contrast against adjacent colors.',
99
+ '1.4.12': 'Nothing breaks when users override line height (1.5×), paragraph (2×), letter (0.12×) and word (0.16×) spacing.',
100
+ '1.4.13': 'Tooltips/popovers shown on hover or focus are dismissable (Esc), hoverable, and persistent.',
101
+ '2.1.4': 'Single-character keyboard shortcuts can be turned off, remapped, or only fire on focus.',
102
+ '2.3.1': 'Nothing flashes more than three times per second.',
103
+ '2.4.1': 'A skip link or landmark structure lets keyboard users bypass repeated blocks.',
104
+ '2.4.5': 'There are at least two ways to find each page (nav, search, sitemap…).',
105
+ '2.4.11': 'Focused elements are never fully hidden behind sticky headers/footers or overlays.',
106
+ '2.5.1': 'Multipoint/path-based gestures (pinch, swipe) have single-pointer alternatives.',
107
+ '2.5.4': 'Motion-based input (shake, tilt) has a UI alternative and can be disabled.',
108
+ '2.5.7': 'Drag-and-drop interactions have a click/tap alternative.',
109
+ '3.2.2': 'Changing a form control never auto-submits or navigates without warning.',
110
+ '3.2.3': 'Navigation appears in the same relative order on every page/screen.',
111
+ '3.2.4': 'Components with the same function are labeled consistently across the product.',
112
+ '3.2.6': 'Help (contact, FAQ, chat) appears in the same place on every page that offers it.',
113
+ '3.3.1': 'Validation errors are described in text and identify the field in error.',
114
+ '3.3.3': 'Validation errors suggest how to fix the input when possible.',
115
+ '3.3.4': 'Legal/financial submissions are reversible, checked, or confirmable before commit.',
116
+ '3.3.7': 'Information already entered in a flow is auto-populated or selectable, never retyped.',
117
+ };
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@aishware/react-a11y-core",
3
+ "version": "0.1.0",
4
+ "description": "Platform-agnostic static analysis engine for React accessibility auditing (web and native).",
5
+ "keywords": ["accessibility", "a11y", "wcag", "wcag-2.2", "react", "react-native", "static-analysis", "linter", "typescript"],
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "dependencies": {
27
+ "typescript": "^5.6.0"
28
+ },
29
+ "license": "MIT",
30
+ "homepage": "https://github.com/1aishwaryasharma/react-a11y",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/1aishwaryasharma/react-a11y.git",
34
+ "directory": "packages/core"
35
+ }
36
+ }