@yuktishaalaa/a11y 0.0.0-stage → 6.0.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/LICENSE +674 -0
- package/README.md +76 -2
- package/dist/a11y.global.js +2 -0
- package/dist/aria.d.ts +11 -0
- package/dist/attributes.d.ts +12 -0
- package/dist/contrast.d.ts +49 -0
- package/dist/finder.d.ts +8 -0
- package/dist/global.d.ts +13 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +2 -0
- package/dist/language.d.ts +70 -0
- package/dist/prefs.d.ts +29 -0
- package/dist/report.d.ts +35 -0
- package/dist/speak.d.ts +37 -0
- package/dist/speakButtons.d.ts +6 -0
- package/package.json +69 -4
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type FindingStatus = "fixed" | "check" | "unknown";
|
|
2
|
+
export interface Finding {
|
|
3
|
+
rule: RuleId;
|
|
4
|
+
status: FindingStatus;
|
|
5
|
+
/** WCAG 2.2 success criterion, e.g. "1.4.3"; "" when none applies. */
|
|
6
|
+
wcag: string;
|
|
7
|
+
/** Short CSS-like path to the element, for people. */
|
|
8
|
+
where: string;
|
|
9
|
+
/** Values for the message, e.g. { ratio: 3.1, required: 4.5 }. */
|
|
10
|
+
data?: Record<string, string | number>;
|
|
11
|
+
/** The element itself (not serializable). */
|
|
12
|
+
el?: Element;
|
|
13
|
+
}
|
|
14
|
+
export interface Report {
|
|
15
|
+
level: "off" | "AA" | "AAA";
|
|
16
|
+
mode: "auto" | "check" | "off";
|
|
17
|
+
fixed: Finding[];
|
|
18
|
+
check: Finding[];
|
|
19
|
+
unknown: Finding[];
|
|
20
|
+
/** Elements looked at. */
|
|
21
|
+
scanned: number;
|
|
22
|
+
/** ISO time of the run. */
|
|
23
|
+
at: string;
|
|
24
|
+
}
|
|
25
|
+
export type RuleId = "page-lang-missing" | "page-lang-mismatch" | "part-lang-missing" | "contrast" | "contrast-unknown" | "img-alt-missing" | "control-name-missing" | "fake-button" | "clickable-not-focusable" | "field-label-missing" | "heading-skip" | "h1-count" | "link-text-vague" | "iframe-title-missing" | "iframe-cross-origin" | "table-headers-missing" | "media-autoplay" | "tabindex-positive" | "aria-hidden-focusable" | "main-landmark-missing" | "closed-shadow-root";
|
|
26
|
+
export declare const WCAG: Record<RuleId, string>;
|
|
27
|
+
type Lang = "en" | "te";
|
|
28
|
+
/** Message templates. {name} is filled from Finding.data. */
|
|
29
|
+
export declare const MESSAGES: Record<Lang, Record<RuleId, string>>;
|
|
30
|
+
export declare function message(f: Finding, lang?: Lang): string;
|
|
31
|
+
/** A short path for people: tag#id.class (up to 3 levels). */
|
|
32
|
+
export declare function describe(el: Element): string;
|
|
33
|
+
/** Report without element references, safe for JSON and postMessage. */
|
|
34
|
+
export declare function toJSON(r: Report): Omit<Report, "fixed" | "check" | "unknown"> & Record<FindingStatus, Omit<Finding, "el">[]>;
|
|
35
|
+
export {};
|
package/dist/speak.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Segment } from "./language";
|
|
2
|
+
export interface SpeakOptions {
|
|
3
|
+
/** Language to assume where the text gives no clue. Default: the element's `lang`, else the page's, else "en". */
|
|
4
|
+
lang?: string;
|
|
5
|
+
/** 0.5–2. Default 1. */
|
|
6
|
+
rate?: number;
|
|
7
|
+
/** Called once per language the device cannot speak. */
|
|
8
|
+
onMissingVoice?: (lang: string) => void;
|
|
9
|
+
/** Called when everything has been read, or reading stopped. */
|
|
10
|
+
onEnd?: () => void;
|
|
11
|
+
/** Called before each part is read. */
|
|
12
|
+
onPart?: (part: Segment, index: number, total: number) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface Speaker {
|
|
15
|
+
pause(): void;
|
|
16
|
+
resume(): void;
|
|
17
|
+
stop(): void;
|
|
18
|
+
readonly parts: Segment[];
|
|
19
|
+
}
|
|
20
|
+
/** True when this browser can read aloud at all. */
|
|
21
|
+
export declare const canSpeak: () => boolean;
|
|
22
|
+
/** The device's voices. Some browsers load them late; waits up to `timeoutMs`. */
|
|
23
|
+
export declare function getVoices(timeoutMs?: number): Promise<SpeechSynthesisVoice[]>;
|
|
24
|
+
/**
|
|
25
|
+
* The best voice for a language: exact region ("te-IN"), then the same
|
|
26
|
+
* language in any region ("te"), local voices before network ones. Null when
|
|
27
|
+
* the device has none — then the caller must not read that part.
|
|
28
|
+
*/
|
|
29
|
+
export declare function pickVoice(lang: string, voices: SpeechSynthesisVoice[]): SpeechSynthesisVoice | null;
|
|
30
|
+
/** Languages the device can read, e.g. ["en", "hi", "te"]. */
|
|
31
|
+
export declare function speakableLanguages(): Promise<string[]>;
|
|
32
|
+
/** Cuts text into sentences of at most `max` characters (Telugu, Hindi and English stops). */
|
|
33
|
+
export declare function sentences(text: string, max?: number): string[];
|
|
34
|
+
/** The readable text of an element, without typing areas, code or switched-off parts. */
|
|
35
|
+
export declare function readableText(el: Element): string;
|
|
36
|
+
/** Reads text (or an element's text) aloud, part by part, each in its own language. */
|
|
37
|
+
export declare function speak(target: string | Element, options?: SpeakOptions): Speaker;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface SpeakButtonsOptions {
|
|
2
|
+
/** Called when a language has no voice on this device. */
|
|
3
|
+
onMissingVoice?: (lang: string, message: string) => void;
|
|
4
|
+
}
|
|
5
|
+
/** Adds the buttons; returns a function that removes them. */
|
|
6
|
+
export declare function addSpeakButtons(doc: Document, opts?: SpeakButtonsOptions): () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuktishaalaa/a11y",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "6.0.0",
|
|
4
|
+
"description": "Web accessibility for any page, in the browser: safe ARIA, WCAG AA/AAA contrast, automatic lang for every part, read aloud in the right voice, visitor preferences. One attribute, no server.",
|
|
5
|
+
"author": "Sandeep Miriyala — Yuktishaalaa AI Lab",
|
|
6
|
+
"license": "GPL-3.0-only",
|
|
7
|
+
"homepage": "https://sandeep-miriyala.github.io/yuktai/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/sandeep-miriyala/yuktai.git",
|
|
11
|
+
"directory": "packages/a11y"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/sandeep-miriyala/yuktai/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"accessibility",
|
|
18
|
+
"a11y",
|
|
19
|
+
"wcag",
|
|
20
|
+
"aria",
|
|
21
|
+
"contrast",
|
|
22
|
+
"lang",
|
|
23
|
+
"text-to-speech",
|
|
24
|
+
"web-speech",
|
|
25
|
+
"telugu",
|
|
26
|
+
"indic",
|
|
27
|
+
"screen-reader"
|
|
28
|
+
],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"main": "./dist/index.cjs",
|
|
31
|
+
"module": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"unpkg": "./dist/a11y.global.js",
|
|
34
|
+
"jsdelivr": "./dist/a11y.global.js",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"require": "./dist/index.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./global": "./dist/a11y.global.js",
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"README.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"sideEffects": [
|
|
50
|
+
"./dist/a11y.global.js"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup && npm run build:types",
|
|
54
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"prepublishOnly": "npm run build"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"happy-dom": "^21.0.4",
|
|
61
|
+
"tsup": "^9.0.0",
|
|
62
|
+
"typescript": "^7.0.2",
|
|
63
|
+
"vitest": "^5.0.5"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=18"
|
|
67
|
+
},
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public"
|
|
70
|
+
}
|
|
71
|
+
}
|