@obinexusltd/obix-driver-accessibility-tree 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.
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/package.json +26 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessibility Tree Driver
|
|
3
|
+
* ARIA/live region management and screen reader bridge
|
|
4
|
+
*/
|
|
5
|
+
export type AriaLiveRegion = "off" | "polite" | "assertive";
|
|
6
|
+
export type AriaRole = string;
|
|
7
|
+
export interface LiveRegionDefaults {
|
|
8
|
+
level?: AriaLiveRegion;
|
|
9
|
+
atomic?: boolean;
|
|
10
|
+
relevant?: string[];
|
|
11
|
+
label?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AccessibilityTreeDriverConfig {
|
|
14
|
+
/** Root element for accessibility tree */
|
|
15
|
+
rootElement: Element;
|
|
16
|
+
/** Default configuration for live regions */
|
|
17
|
+
liveRegionDefaults?: LiveRegionDefaults;
|
|
18
|
+
/** Screen reader hints and optimizations */
|
|
19
|
+
screenReaderHints?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface AccessibilityNode {
|
|
22
|
+
role: AriaRole;
|
|
23
|
+
label?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
attributes?: Record<string, string>;
|
|
26
|
+
children?: AccessibilityNode[];
|
|
27
|
+
}
|
|
28
|
+
export interface AccessibilityTreeDriverAPI {
|
|
29
|
+
initialize(): Promise<void>;
|
|
30
|
+
registerLiveRegion(element: Element, config?: LiveRegionDefaults): Promise<void>;
|
|
31
|
+
announce(message: string, level?: AriaLiveRegion): void;
|
|
32
|
+
updateAccessibilityNode(element: Element, node: AccessibilityNode): void;
|
|
33
|
+
getAccessibilityTree(): AccessibilityNode;
|
|
34
|
+
setScreenReaderMode(enabled: boolean): void;
|
|
35
|
+
destroy(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export declare function createAccessibilityTreeDriver(config: AccessibilityTreeDriverConfig): AccessibilityTreeDriverAPI;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,WAAW,CAAC;AAC5D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,6BAA6B;IAC5C,0CAA0C;IAC1C,WAAW,EAAE,OAAO,CAAC;IACrB,6CAA6C;IAC7C,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,4CAA4C;IAC5C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACxD,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzE,oBAAoB,IAAI,iBAAiB,CAAC;IAC1C,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,6BAA6B,GACpC,0BAA0B,CAoD5B"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessibility Tree Driver
|
|
3
|
+
* ARIA/live region management and screen reader bridge
|
|
4
|
+
*/
|
|
5
|
+
export function createAccessibilityTreeDriver(config) {
|
|
6
|
+
let initialized = false;
|
|
7
|
+
let screenReaderMode = Boolean(config.screenReaderHints);
|
|
8
|
+
const nodeMap = new Map();
|
|
9
|
+
const liveRegions = new Map();
|
|
10
|
+
let lastAnnouncement = "";
|
|
11
|
+
return {
|
|
12
|
+
async initialize() {
|
|
13
|
+
initialized = true;
|
|
14
|
+
},
|
|
15
|
+
async registerLiveRegion(element, overrides) {
|
|
16
|
+
liveRegions.set(element, { ...config.liveRegionDefaults, ...overrides });
|
|
17
|
+
},
|
|
18
|
+
announce(message, level = "polite") {
|
|
19
|
+
lastAnnouncement = message;
|
|
20
|
+
if (typeof config.rootElement.setAttribute === "function") {
|
|
21
|
+
config.rootElement.setAttribute("aria-live", level);
|
|
22
|
+
config.rootElement.setAttribute("aria-label", message);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
updateAccessibilityNode(element, node) {
|
|
26
|
+
nodeMap.set(element, node);
|
|
27
|
+
if (typeof element.setAttribute === "function") {
|
|
28
|
+
element.setAttribute("role", node.role);
|
|
29
|
+
if (node.label) {
|
|
30
|
+
element.setAttribute("aria-label", node.label);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
getAccessibilityTree() {
|
|
35
|
+
const children = Array.from(nodeMap.values());
|
|
36
|
+
return {
|
|
37
|
+
role: "root",
|
|
38
|
+
label: lastAnnouncement || "accessibility-tree",
|
|
39
|
+
children,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
setScreenReaderMode(enabled) {
|
|
43
|
+
screenReaderMode = enabled;
|
|
44
|
+
if (typeof config.rootElement.setAttribute === "function") {
|
|
45
|
+
config.rootElement.setAttribute("data-screen-reader-mode", String(screenReaderMode));
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
async destroy() {
|
|
49
|
+
initialized = false;
|
|
50
|
+
nodeMap.clear();
|
|
51
|
+
liveRegions.clear();
|
|
52
|
+
lastAnnouncement = "";
|
|
53
|
+
void initialized;
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuCH,MAAM,UAAU,6BAA6B,CAC3C,MAAqC;IAErC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,IAAI,GAAG,EAA8B,CAAC;IACtD,MAAM,WAAW,GAAG,IAAI,GAAG,EAA+B,CAAC;IAC3D,IAAI,gBAAgB,GAAG,EAAE,CAAC;IAE1B,OAAO;QACL,KAAK,CAAC,UAAU;YACd,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,SAAS;YACzC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,MAAM,CAAC,kBAAkB,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,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AAO,CAAC,KAAK,EAAE,CAAC;YAChB,WAAW,CAAC,KAAK,EAAE,CAAC;YACpB,gBAAgB,GAAG,EAAE,CAAC;YACtB,KAAK,WAAW,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@obinexusltd/obix-driver-accessibility-tree",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "OBIX Accessibility Tree Driver - ARIA/live region management and screen reader bridge",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"test": "vitest run"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "OBINexus <okpalan@protonmail.com>",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
}
|
|
26
|
+
}
|