@applicaster/zapp-react-native-utils 12.0.3-alpha.6286106317 → 12.0.3-rc.1
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.
|
@@ -6,9 +6,6 @@ import { AccessibilityRole } from "react-native";
|
|
|
6
6
|
|
|
7
7
|
export class AccessibilityManager {
|
|
8
8
|
private static _instance: AccessibilityManager | null = null;
|
|
9
|
-
private headingTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
10
|
-
private WORDS_PER_MINUTE = 160;
|
|
11
|
-
private MINIMUM_PAUSE = 500;
|
|
12
9
|
private state$ = new BehaviorSubject<AccessibilityState>({
|
|
13
10
|
screenReaderEnabled: false,
|
|
14
11
|
reduceMotionEnabled: false,
|
|
@@ -23,7 +20,6 @@ export class AccessibilityManager {
|
|
|
23
20
|
|
|
24
21
|
private ttsManager = TTSManager.getInstance();
|
|
25
22
|
private localizations: { [key: string]: string } = {};
|
|
26
|
-
private headingQueue: string[] = [];
|
|
27
23
|
|
|
28
24
|
private constructor() {}
|
|
29
25
|
|
|
@@ -56,28 +52,6 @@ export class AccessibilityManager {
|
|
|
56
52
|
return this.state$.asObservable();
|
|
57
53
|
}
|
|
58
54
|
|
|
59
|
-
/** Calculates the reading time for a given text
|
|
60
|
-
* This method is a bit of a hack because we don't have a callback, or promise from VIZIO API
|
|
61
|
-
* @param text - The text to calculate the reading time for
|
|
62
|
-
* @returns The reading time in milliseconds
|
|
63
|
-
*/
|
|
64
|
-
private calculateReadingTime(text: string): number {
|
|
65
|
-
const words = text.trim().split(/\s+/).length;
|
|
66
|
-
|
|
67
|
-
return Math.max(
|
|
68
|
-
this.MINIMUM_PAUSE,
|
|
69
|
-
(words / this.WORDS_PER_MINUTE) * 60 * 1000
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Adds a heading to the queue, headings will be read before the next text
|
|
75
|
-
* Each heading will be read once and removed from the queue
|
|
76
|
-
*/
|
|
77
|
-
public addHeading(heading: string) {
|
|
78
|
-
this.headingQueue.push(heading);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
55
|
/**
|
|
82
56
|
* text you want to be read, if you want to use localized text pass keyOfLocalizedText instead
|
|
83
57
|
* keyOfLocalizedText is the key to the localized text
|
|
@@ -111,22 +85,7 @@ export class AccessibilityManager {
|
|
|
111
85
|
textToRead = localizedMessage;
|
|
112
86
|
}
|
|
113
87
|
|
|
114
|
-
|
|
115
|
-
const heading = this.headingQueue.shift()!;
|
|
116
|
-
this.ttsManager?.readText(heading);
|
|
117
|
-
|
|
118
|
-
if (this.headingTimeout) {
|
|
119
|
-
clearTimeout(this.headingTimeout);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const pauseTime = this.calculateReadingTime(heading);
|
|
123
|
-
|
|
124
|
-
this.headingTimeout = setTimeout(() => {
|
|
125
|
-
this.ttsManager?.readText(textToRead);
|
|
126
|
-
}, pauseTime);
|
|
127
|
-
} else {
|
|
128
|
-
this.ttsManager?.readText(textToRead);
|
|
129
|
-
}
|
|
88
|
+
this.ttsManager && this.ttsManager.readText(textToRead);
|
|
130
89
|
|
|
131
90
|
this.announcements$.next({
|
|
132
91
|
message: textToRead,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "12.0.3-
|
|
3
|
+
"version": "12.0.3-rc.1",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "12.0.3-
|
|
31
|
+
"@applicaster/applicaster-types": "12.0.3-rc.1",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|