@applicaster/zapp-react-native-utils 13.0.7-alpha.7163853950 → 13.0.8-alpha.1940580104
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/appUtils/accessibilityManager/const.ts +9 -0
- package/appUtils/accessibilityManager/index.ts +9 -19
- package/appUtils/accessibilityManager/utils.ts +24 -0
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -0
- package/appUtils/focusManager/index.ios.ts +10 -0
- package/appUtils/focusManager/index.ts +11 -0
- package/appUtils/focusManagerAux/utils/index.ts +18 -0
- package/appUtils/platform/platformUtils.ts +2 -3
- package/package.json +2 -2
|
@@ -69,4 +69,13 @@ export const BUTTON_ACCESSIBILITY_KEYS = {
|
|
|
69
69
|
label: "accessibility_skip_intro_label",
|
|
70
70
|
hint: "accessibility_skip_intro_hint",
|
|
71
71
|
},
|
|
72
|
+
// Top Menu Bar-specific buttons
|
|
73
|
+
top_menu_bar_item_selected: {
|
|
74
|
+
label: "accessibility_top_menu_bar_item_selected_label",
|
|
75
|
+
hint: "accessibility_top_menu_bar_item_selected_hint",
|
|
76
|
+
},
|
|
77
|
+
top_menu_title: {
|
|
78
|
+
label: "accessibility_top_menu_title_label",
|
|
79
|
+
hint: "accessibility_top_menu_hint",
|
|
80
|
+
},
|
|
72
81
|
} as const;
|
|
@@ -3,6 +3,7 @@ import { BehaviorSubject } from "rxjs";
|
|
|
3
3
|
import { accessibilityManagerLogger as logger } from "./logger";
|
|
4
4
|
import { TTSManager } from "../platform/platformUtils";
|
|
5
5
|
import { BUTTON_ACCESSIBILITY_KEYS } from "./const";
|
|
6
|
+
import { calculateReadingTime } from "./utils";
|
|
6
7
|
import { AccessibilityRole } from "react-native";
|
|
7
8
|
import _ from "lodash";
|
|
8
9
|
|
|
@@ -10,9 +11,9 @@ export class AccessibilityManager {
|
|
|
10
11
|
private static _instance: AccessibilityManager | null = null;
|
|
11
12
|
private headingTimeout: NodeJS.Timeout | null = null;
|
|
12
13
|
private announcementDelayTimeout: NodeJS.Timeout | null = null;
|
|
13
|
-
private WORDS_PER_MINUTE =
|
|
14
|
+
private WORDS_PER_MINUTE = 140;
|
|
14
15
|
private MINIMUM_PAUSE = 500;
|
|
15
|
-
private ANNOUNCEMENT_DELAY =
|
|
16
|
+
private ANNOUNCEMENT_DELAY = 700;
|
|
16
17
|
private state$ = new BehaviorSubject<AccessibilityState>({
|
|
17
18
|
screenReaderEnabled: false,
|
|
18
19
|
reduceMotionEnabled: false,
|
|
@@ -88,22 +89,6 @@ export class AccessibilityManager {
|
|
|
88
89
|
return this.state$.asObservable();
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
/** Calculates the reading time for a given text
|
|
92
|
-
* This method is a bit of a hack because we don't have a callback, or promise from VIZIO API
|
|
93
|
-
* @param text - The text to calculate the reading time for
|
|
94
|
-
* @returns The reading time in milliseconds
|
|
95
|
-
*/
|
|
96
|
-
private calculateReadingTime(text: string): number {
|
|
97
|
-
const words = text.trim().split(/\s+/).length;
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
Math.max(
|
|
101
|
-
this.MINIMUM_PAUSE,
|
|
102
|
-
(words / this.WORDS_PER_MINUTE) * 60 * 1000
|
|
103
|
-
) + 300
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
92
|
/**
|
|
108
93
|
* Adds a heading to the queue, headings will be read before the next text
|
|
109
94
|
* Each heading will be read once and removed from the queue
|
|
@@ -221,7 +206,12 @@ export class AccessibilityManager {
|
|
|
221
206
|
clearTimeout(this.headingTimeout);
|
|
222
207
|
}
|
|
223
208
|
|
|
224
|
-
const pauseTime =
|
|
209
|
+
const pauseTime = calculateReadingTime(
|
|
210
|
+
heading,
|
|
211
|
+
this.WORDS_PER_MINUTE,
|
|
212
|
+
this.MINIMUM_PAUSE,
|
|
213
|
+
this.ANNOUNCEMENT_DELAY
|
|
214
|
+
);
|
|
225
215
|
|
|
226
216
|
this.headingTimeout = setTimeout(() => {
|
|
227
217
|
this.processHeadingQueue(textToRead, focusId);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the reading time for a given text based on word count
|
|
3
|
+
* @param text - The text to calculate the reading time for
|
|
4
|
+
* @param wordsPerMinute - Words per minute reading speed (default: 160)
|
|
5
|
+
* @param minimumPause - Minimum pause time in milliseconds (default: 500)
|
|
6
|
+
* @param announcementDelay - Additional delay for announcement in milliseconds (default: 700)
|
|
7
|
+
* @returns The reading time in milliseconds
|
|
8
|
+
*/
|
|
9
|
+
export function calculateReadingTime(
|
|
10
|
+
text: string,
|
|
11
|
+
wordsPerMinute: number = 140,
|
|
12
|
+
minimumPause: number = 500,
|
|
13
|
+
announcementDelay: number = 700
|
|
14
|
+
): number {
|
|
15
|
+
const words = text
|
|
16
|
+
.trim()
|
|
17
|
+
.split(/(?<=\d)(?=[a-zA-Z])|(?<=[a-zA-Z])(?=\d)|[^\w\s]+|\s+/)
|
|
18
|
+
.filter(Boolean).length;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
Math.max(minimumPause, (words / wordsPerMinute) * 60 * 1000) +
|
|
22
|
+
announcementDelay
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -24,6 +24,7 @@ exports[`focusManager should be defined 1`] = `
|
|
|
24
24
|
"invokeHandler": [Function],
|
|
25
25
|
"isCurrentFocusOnTheTopScreen": [Function],
|
|
26
26
|
"isFocusDisabled": [Function],
|
|
27
|
+
"isFocusOn": [Function],
|
|
27
28
|
"isGroupItemFocused": [Function],
|
|
28
29
|
"longPress": [Function],
|
|
29
30
|
"moveFocus": [Function],
|
|
@@ -63,6 +64,7 @@ exports[`focusManagerIOS should be defined 1`] = `
|
|
|
63
64
|
"getGroupRootById": [Function],
|
|
64
65
|
"getPreferredFocusChild": [Function],
|
|
65
66
|
"invokeHandler": [Function],
|
|
67
|
+
"isFocusOn": [Function],
|
|
66
68
|
"isGroupItemFocused": [Function],
|
|
67
69
|
"moveFocus": [Function],
|
|
68
70
|
"on": [Function],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NativeModules } from "react-native";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
|
|
4
|
+
import { isCurrentFocusOn } from "../focusManagerAux/utils";
|
|
4
5
|
import { Tree } from "./treeDataStructure/Tree";
|
|
5
6
|
import { findFocusableNode } from "./treeDataStructure/Utils";
|
|
6
7
|
import { subscriber } from "../../functionUtils";
|
|
@@ -391,6 +392,14 @@ export const focusManager = (function () {
|
|
|
391
392
|
return node;
|
|
392
393
|
}
|
|
393
394
|
|
|
395
|
+
function isFocusOn(id): boolean {
|
|
396
|
+
const currentFocusNode = focusableTree.findInTree(
|
|
397
|
+
getCurrentFocus()?.props?.id
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
return id && isCurrentFocusOn(id, currentFocusNode);
|
|
401
|
+
}
|
|
402
|
+
|
|
394
403
|
return {
|
|
395
404
|
on,
|
|
396
405
|
invokeHandler,
|
|
@@ -412,5 +421,6 @@ export const focusManager = (function () {
|
|
|
412
421
|
getGroupRootById,
|
|
413
422
|
isGroupItemFocused,
|
|
414
423
|
getPreferredFocusChild,
|
|
424
|
+
isFocusOn,
|
|
415
425
|
};
|
|
416
426
|
})();
|
|
@@ -14,6 +14,8 @@ import { subscriber } from "../../functionUtils";
|
|
|
14
14
|
import { coreLogger } from "../../logger";
|
|
15
15
|
import { ACTION } from "./utils/enums";
|
|
16
16
|
|
|
17
|
+
import { isCurrentFocusOn } from "../focusManagerAux/utils";
|
|
18
|
+
|
|
17
19
|
const logger = coreLogger.addSubsystem("focusManager");
|
|
18
20
|
|
|
19
21
|
const isFocusEnabled = (focusableItem): boolean => {
|
|
@@ -546,6 +548,14 @@ export const focusManager = (function () {
|
|
|
546
548
|
return preferredFocus[0];
|
|
547
549
|
}
|
|
548
550
|
|
|
551
|
+
function isFocusOn(id): boolean {
|
|
552
|
+
return (
|
|
553
|
+
id &&
|
|
554
|
+
isCurrentFocusOnTheTopScreen() &&
|
|
555
|
+
isCurrentFocusOn(id, currentFocusNode)
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
|
|
549
559
|
/**
|
|
550
560
|
* this is the list of the functions available externally
|
|
551
561
|
* when importing the focus manager
|
|
@@ -576,5 +586,6 @@ export const focusManager = (function () {
|
|
|
576
586
|
recoverFocus,
|
|
577
587
|
isCurrentFocusOnTheTopScreen,
|
|
578
588
|
findPreferredFocusChild,
|
|
589
|
+
isFocusOn,
|
|
579
590
|
};
|
|
580
591
|
})();
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
// run this check too often could lead to performance penalty on low-end devices
|
|
10
10
|
const HOW_OFTEN_TO_CHECK_CONDITION = 300; // ms
|
|
11
11
|
|
|
12
|
+
const isRoot = (node) => node?.id === "root";
|
|
13
|
+
|
|
12
14
|
type Props = {
|
|
13
15
|
maxTimeout: number;
|
|
14
16
|
conditionFn: () => boolean;
|
|
@@ -99,3 +101,19 @@ export const waitForContent = (focusableTree) => {
|
|
|
99
101
|
conditionFn: contentHasAnyChildren,
|
|
100
102
|
});
|
|
101
103
|
};
|
|
104
|
+
|
|
105
|
+
export const isCurrentFocusOn = (id, node) => {
|
|
106
|
+
if (!node) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (isRoot(node)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (node?.id === id) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return isCurrentFocusOn(id, node.parent);
|
|
119
|
+
};
|
|
@@ -10,6 +10,7 @@ import { PLATFORM_KEYS, PLATFORMS, ZappPlatform } from "./const";
|
|
|
10
10
|
import { createLogger, utilsLogger } from "../../logger";
|
|
11
11
|
import { getPlatform } from "../../reactUtils";
|
|
12
12
|
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
13
|
+
import { calculateReadingTime } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/utils";
|
|
13
14
|
|
|
14
15
|
const { log_debug } = createLogger({
|
|
15
16
|
category: "General",
|
|
@@ -267,9 +268,7 @@ export class TTSManager {
|
|
|
267
268
|
}
|
|
268
269
|
|
|
269
270
|
private scheduleTTSComplete(text: string) {
|
|
270
|
-
|
|
271
|
-
const words = text.trim().split(/\s+/).length;
|
|
272
|
-
const readingTime = Math.max(500, (words / 160) * 60 * 1000) + 300;
|
|
271
|
+
const readingTime = calculateReadingTime(text);
|
|
273
272
|
|
|
274
273
|
setTimeout(() => {
|
|
275
274
|
this.ttsState$.next(false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.8-alpha.1940580104",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "13.0.
|
|
30
|
+
"@applicaster/applicaster-types": "13.0.8-alpha.1940580104",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|