forked from microsoft/microcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
accessibility.ts
54 lines (46 loc) · 1.4 KB
/
accessibility.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
namespace accessibility {
export interface AccessibilityMessage {
type: "text" | "tile" | "rule" | "led" | "note"
force?: boolean
}
export interface TextAccessibilityMessage extends AccessibilityMessage {
type: "text"
value: string
}
export interface LEDAccessibilityMessage extends AccessibilityMessage {
type: "led"
on: boolean
x: number
y: number
}
export interface NoteAccessibilityMessage extends AccessibilityMessage {
type: "note"
on: boolean
index: number
}
export interface TileAccessibilityMessage extends AccessibilityMessage {
type: "tile"
value: string
}
export interface RuleAccessibilityMessage extends AccessibilityMessage {
type: "rule"
dos: string[]
whens: string[]
}
/**
* Notifies web application about the current content.
*/
//% shim=TD_ID
export function setLiveContent(msg: AccessibilityMessage) {
const data = Buffer.fromUTF8(JSON.stringify(msg))
control.simmessages.send("accessibility", data)
}
export function resolveTooltip(id: string) {
const tooltip = microcode.tooltips[id] as string
const s = tooltip || ""
return s
}
export function ariaToTooltip(ariaId: string) {
return resolveTooltip(ariaId).replaceAll("_", " ")
}
}