@applicaster/zapp-react-native-utils 12.0.0-alpha.3964644693 → 12.0.0-alpha.4043183114
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/HooksManager/{Hook.js → Hook.ts} +17 -11
- package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
- package/appUtils/HooksManager/{index.js → index.ts} +98 -109
- package/appUtils/HooksManager/types.ts +93 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/accessibilityManager/const.ts +50 -0
- package/appUtils/accessibilityManager/hooks.ts +31 -0
- package/appUtils/accessibilityManager/index.ts +150 -0
- package/appUtils/accessibilityManager/logger.ts +5 -0
- package/appUtils/focusManager/index.ts +0 -1
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +2 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +2 -4
- package/appUtils/{index.js → index.ts} +2 -0
- package/appUtils/keyCodes/{index.js → index.ts} +2 -0
- package/appUtils/keyCodes/keys/index.ts +3 -0
- package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
- package/appUtils/keyCodes/keys/keys.android.ts +18 -0
- package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
- package/appUtils/keyCodes/keys/keys.ts +15 -0
- package/appUtils/platform/platformUtils.ts +40 -92
- package/appUtils/playerManager/conts.ts +1 -0
- package/appUtils/playerManager/player.ts +9 -0
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -0
- package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
- package/functionUtils/index.ts +15 -11
- package/modalState/index.ts +1 -5
- package/navigationUtils/index.ts +62 -5
- package/package.json +2 -2
- package/pluginUtils/index.ts +9 -0
- package/reactHooks/navigation/index.ts +11 -4
- package/reactUtils/index.ts +0 -11
- package/appUtils/keyCodes/keys.ios.js +0 -46
- /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
- /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
- /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
- /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
- /package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +0 -0
- /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
- /package/domUtils/{logger.js → logger.ts} +0 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { BehaviorSubject } from "rxjs";
|
|
2
|
+
import { accessibilityManagerLogger as logger } from "./logger";
|
|
3
|
+
import { TTSManager } from "../platform/platformUtils";
|
|
4
|
+
import { getLocalizations } from "../../localizationUtils";
|
|
5
|
+
import { BUTTON_ACCESSIBILITY_KEYS } from "./const";
|
|
6
|
+
|
|
7
|
+
export interface AccessibilityState {
|
|
8
|
+
screenReaderEnabled: boolean;
|
|
9
|
+
reduceMotionEnabled: boolean;
|
|
10
|
+
boldTextEnabled: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AccessibilityProps {
|
|
14
|
+
accessibilityLabel?: string;
|
|
15
|
+
accessibilityHint?: string;
|
|
16
|
+
"aria-label"?: string;
|
|
17
|
+
"aria-description"?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class AccessibilityManager {
|
|
21
|
+
private static _instance: AccessibilityManager | null = null;
|
|
22
|
+
private state$ = new BehaviorSubject<AccessibilityState>({
|
|
23
|
+
screenReaderEnabled: false,
|
|
24
|
+
reduceMotionEnabled: false,
|
|
25
|
+
boldTextEnabled: false,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
private announcements$ = new BehaviorSubject<{
|
|
29
|
+
message: string;
|
|
30
|
+
localizedMessage?: string | undefined;
|
|
31
|
+
timestamp: number;
|
|
32
|
+
} | null>(null);
|
|
33
|
+
|
|
34
|
+
private ttsManager = TTSManager.getInstance();
|
|
35
|
+
private localizations: { [key: string]: string };
|
|
36
|
+
|
|
37
|
+
private constructor(localizations?: { [key: string]: string }) {
|
|
38
|
+
if (localizations) {
|
|
39
|
+
this.localizations = getLocalizations({ localizations });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static getInstance(): AccessibilityManager {
|
|
44
|
+
if (!AccessibilityManager._instance) {
|
|
45
|
+
AccessibilityManager._instance = new AccessibilityManager();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return AccessibilityManager._instance;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public updateLocalizations(localizations: { [key: string]: string }) {
|
|
52
|
+
this.localizations = getLocalizations({ localizations });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public getState(): AccessibilityState {
|
|
56
|
+
return this.state$.getValue();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public getStateAsObservable() {
|
|
60
|
+
return this.state$.asObservable();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* text you want to be read, if you want to use localized text pass keyOfLocalizedText instead
|
|
65
|
+
* keyOfLocalizedText is the key to the localized text
|
|
66
|
+
*/
|
|
67
|
+
public readText({
|
|
68
|
+
text,
|
|
69
|
+
keyOfLocalizedText,
|
|
70
|
+
}: {
|
|
71
|
+
text: string;
|
|
72
|
+
keyOfLocalizedText?: string;
|
|
73
|
+
}) {
|
|
74
|
+
logger.debug("Reading text", { text, keyOfLocalizedText });
|
|
75
|
+
|
|
76
|
+
if (keyOfLocalizedText) {
|
|
77
|
+
if (!this.localizations) {
|
|
78
|
+
logger.error(
|
|
79
|
+
"Attempting to use localized key without initialized localizations"
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const localizedMessage = this.getLocalizedMessage(keyOfLocalizedText);
|
|
86
|
+
|
|
87
|
+
if (!localizedMessage) {
|
|
88
|
+
logger.warn(`No localization found for key: ${keyOfLocalizedText}`);
|
|
89
|
+
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
text = localizedMessage;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (this.ttsManager) {
|
|
97
|
+
this.ttsManager.readText(text);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.announcements$.next({
|
|
101
|
+
message: text,
|
|
102
|
+
localizedMessage: keyOfLocalizedText ? text : undefined,
|
|
103
|
+
timestamp: Date.now(),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public getButtonAccessibilityProps(buttonName: string): AccessibilityProps {
|
|
108
|
+
const buttonConfig = BUTTON_ACCESSIBILITY_KEYS[buttonName];
|
|
109
|
+
|
|
110
|
+
if (!buttonConfig) {
|
|
111
|
+
return {
|
|
112
|
+
accessibilityLabel: buttonName,
|
|
113
|
+
accessibilityHint: `Press button to perform action on ${buttonName}`,
|
|
114
|
+
"aria-label": buttonName,
|
|
115
|
+
"aria-description": `Press button to perform action on ${buttonName}`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const labelKey = buttonConfig.label;
|
|
120
|
+
const hintKey = buttonConfig.hint;
|
|
121
|
+
|
|
122
|
+
const label = this.getLocalizedMessage(labelKey) || buttonName;
|
|
123
|
+
|
|
124
|
+
const hint =
|
|
125
|
+
this.getLocalizedMessage(hintKey) ||
|
|
126
|
+
`Press button to perform action on ${buttonName}`;
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
accessibilityLabel: label,
|
|
130
|
+
accessibilityHint: hint,
|
|
131
|
+
"aria-label": label,
|
|
132
|
+
"aria-description": hint,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public getLocalizedMessage(key: string): string | void {
|
|
137
|
+
if (!key) return;
|
|
138
|
+
|
|
139
|
+
if (!this.localizations) {
|
|
140
|
+
logger.error(
|
|
141
|
+
"Attempting to use localized key without initialized localizations",
|
|
142
|
+
{ key }
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return this.localizations[key];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import { subscriber } from "../../functionUtils";
|
|
14
14
|
import * as FOCUS_EVENTS from "./events";
|
|
15
15
|
import { coreLogger } from "../../logger";
|
|
16
|
-
|
|
17
16
|
const logger = coreLogger.addSubsystem("focusManager");
|
|
18
17
|
|
|
19
18
|
const isFocusEnabled = (focusableItem): boolean => {
|
|
@@ -59,7 +59,7 @@ export class Tree {
|
|
|
59
59
|
/**
|
|
60
60
|
* Update node with provided data from newNode
|
|
61
61
|
* @private
|
|
62
|
-
* @param {Object}
|
|
62
|
+
* @param {Object} currentNode to update
|
|
63
63
|
* @param {Object} newNode node to take data from
|
|
64
64
|
*/
|
|
65
65
|
updateNode(currentNode, newNode) {
|
|
@@ -175,7 +175,6 @@ export class Tree {
|
|
|
175
175
|
* @private
|
|
176
176
|
* @param {Object} node to check
|
|
177
177
|
* @returns True if node has defined groupID
|
|
178
|
-
* @returns False if node has NOT defined groupID
|
|
179
178
|
*/
|
|
180
179
|
hasGroupID(node) {
|
|
181
180
|
return node.component && node.component.props.groupId;
|
|
@@ -191,7 +190,7 @@ export class Tree {
|
|
|
191
190
|
const findChildNode = this.findInTree(node.component.props.groupId);
|
|
192
191
|
|
|
193
192
|
if (findChildNode) {
|
|
194
|
-
this.root.children.pop(
|
|
193
|
+
this.root.children.pop();
|
|
195
194
|
node.children.push(findChildNode);
|
|
196
195
|
}
|
|
197
196
|
}
|
|
@@ -191,7 +191,6 @@ const toDistance = ({ target, direction, comparisonRect }) => {
|
|
|
191
191
|
* Get target in shortest distance in specified direction
|
|
192
192
|
* @private
|
|
193
193
|
* @param {Object} direction of the navigation, which led to this focus change
|
|
194
|
-
* @param {Object} excludedNode node which should be excluded from target group
|
|
195
194
|
* @param {Array} targetNodes array of input target nodes
|
|
196
195
|
* @param {Object} comparisonRect rectangle to compare sides in direction.
|
|
197
196
|
* @returns {Object} target in direction.
|
|
@@ -206,7 +205,7 @@ export function getTargetInDirection(
|
|
|
206
205
|
const overrideTarget = currentNode?.component?.props[overridePropName];
|
|
207
206
|
|
|
208
207
|
if (overrideTarget) {
|
|
209
|
-
const target = targetNodes.find((n) => n
|
|
208
|
+
const target = targetNodes.find((n) => n?.id === overrideTarget);
|
|
210
209
|
|
|
211
210
|
if (target) return target;
|
|
212
211
|
}
|
|
@@ -300,8 +299,7 @@ export function findFocusableNode(direction, currentFocusNode) {
|
|
|
300
299
|
* @public
|
|
301
300
|
* @param {Object} direction of the navigation, which led to this focus change
|
|
302
301
|
* @param {Object} component - object to check props.prioritiseFocusOn
|
|
303
|
-
* @returns {Boolean} TRUE if object has priority in direction.
|
|
304
|
-
* @returns {Boolean} FALSE if object has NO priority in direction.
|
|
302
|
+
* @returns {Boolean} TRUE if object has priority in direction. FALSE if object has NO priority in direction.
|
|
305
303
|
*/
|
|
306
304
|
export function hasPriorityInDirection(direction, component) {
|
|
307
305
|
const { prioritiseFocusOn = 0 } = component.props;
|
|
@@ -9,6 +9,8 @@ export { KEYS, ARROW_KEYS } from "./keyCodes/keys";
|
|
|
9
9
|
|
|
10
10
|
export { playerManager } from "./playerManager";
|
|
11
11
|
|
|
12
|
+
export { AccessibilityManager } from "./accessibilityManager";
|
|
13
|
+
|
|
12
14
|
export function deprecationMessage(fn, replacement) {
|
|
13
15
|
if (__DEV__ && process.env.NODE_ENV !== "test") {
|
|
14
16
|
console.warn("/** DEPRECATION WARNING **/");
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
export const KEYS = {
|
|
2
|
-
Enter: { code: "Enter", keyCode: 13 },
|
|
3
|
-
EnterKeyboard: { code: "EnterKeyboard", keyCode: 66 },
|
|
4
|
-
Back: { code: "Back", keyCode: 8 },
|
|
5
|
-
Space: { code: "Space", keyCode: 32 },
|
|
6
|
-
m: { code: "m", keyCode: 77 },
|
|
7
|
-
ArrowLeft: { code: "ArrowLeft", keyCode: 37 },
|
|
8
|
-
ArrowUp: { code: "ArrowUp", keyCode: 38 },
|
|
9
|
-
ArrowRight: { code: "ArrowRight", keyCode: 39 },
|
|
10
|
-
ArrowDown: { code: "ArrowDown", keyCode: 40 },
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const ARROW_KEYS = [
|
|
14
|
-
KEYS.ArrowUp,
|
|
15
|
-
KEYS.ArrowLeft,
|
|
16
|
-
KEYS.ArrowDown,
|
|
17
|
-
KEYS.ArrowRight,
|
|
18
|
-
];
|
|
19
|
-
|
|
20
1
|
export function keyEventMapper(keyCode) {
|
|
21
2
|
switch (keyCode) {
|
|
22
3
|
case 19: // ArrowUp
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const KEYS = {
|
|
2
|
+
Enter: { code: "Enter", keyCode: 13 },
|
|
3
|
+
EnterKeyboard: { code: "EnterKeyboard", keyCode: 66 },
|
|
4
|
+
Back: { code: "Back", keyCode: 8 },
|
|
5
|
+
Space: { code: "Space", keyCode: 32 },
|
|
6
|
+
m: { code: "m", keyCode: 77 },
|
|
7
|
+
ArrowLeft: { code: "ArrowLeft", keyCode: 37 },
|
|
8
|
+
ArrowUp: { code: "ArrowUp", keyCode: 38 },
|
|
9
|
+
ArrowRight: { code: "ArrowRight", keyCode: 39 },
|
|
10
|
+
ArrowDown: { code: "ArrowDown", keyCode: 40 },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const ARROW_KEYS = [
|
|
14
|
+
KEYS.ArrowUp,
|
|
15
|
+
KEYS.ArrowLeft,
|
|
16
|
+
KEYS.ArrowDown,
|
|
17
|
+
KEYS.ArrowRight,
|
|
18
|
+
];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const KEYS = {
|
|
2
|
+
Enter: { code: "Enter", keyCode: 13 },
|
|
3
|
+
Space: { code: "Space", keyCode: 32 },
|
|
4
|
+
m: { code: "m", keyCode: 77 },
|
|
5
|
+
ArrowLeft: { code: "ArrowLeft", keyCode: 37 },
|
|
6
|
+
ArrowUp: { code: "ArrowUp", keyCode: 38 },
|
|
7
|
+
ArrowRight: { code: "ArrowRight", keyCode: 39 },
|
|
8
|
+
ArrowDown: { code: "ArrowDown", keyCode: 40 },
|
|
9
|
+
Back: { code: "Backspace", keyCode: 8 },
|
|
10
|
+
Play: { code: "PlayPause", keyCode: 179 },
|
|
11
|
+
Pause: { code: "Pause", keyCode: 179 },
|
|
12
|
+
Forward: { code: "Forward", keyCode: 176 },
|
|
13
|
+
Rewind: { code: "Rewind", keyCode: 177 },
|
|
14
|
+
VolumeUp: { code: "VolumeUp", keyCode: 175 },
|
|
15
|
+
VolumeDown: { code: "VolumeDown", keyCode: 174 },
|
|
16
|
+
ToggleMute: { code: "VolumeMute", keyCode: 173 },
|
|
17
|
+
Stop: { code: "Q", keyCode: 81 },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const ARROW_KEYS = [
|
|
21
|
+
KEYS.ArrowUp,
|
|
22
|
+
KEYS.ArrowLeft,
|
|
23
|
+
KEYS.ArrowDown,
|
|
24
|
+
KEYS.ArrowRight,
|
|
25
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// dummy file to make sure the folder structure is created
|
|
2
|
+
export const KEYS: Record<string, { code: string; keyCode: number }> = {
|
|
3
|
+
ArrowLeft: { code: "ArrowLeft", keyCode: -1 },
|
|
4
|
+
ArrowUp: { code: "ArrowUp", keyCode: -1 },
|
|
5
|
+
ArrowRight: { code: "ArrowRight", keyCode: -1 },
|
|
6
|
+
ArrowDown: { code: "ArrowDown", keyCode: -1 },
|
|
7
|
+
Back: { code: "Back", keyCode: -1 },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const ARROW_KEYS = [
|
|
11
|
+
KEYS.ArrowUp,
|
|
12
|
+
KEYS.ArrowLeft,
|
|
13
|
+
KEYS.ArrowDown,
|
|
14
|
+
KEYS.ArrowRight,
|
|
15
|
+
];
|
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import { BehaviorSubject } from "rxjs";
|
|
2
2
|
|
|
3
3
|
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
4
|
-
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
5
|
-
import { PlayerWebController } from "@applicaster/zapp-react-native-default-player/src/playerFactory/players/playerWebController";
|
|
6
4
|
|
|
7
5
|
import { PLATFORM_KEYS, PLATFORMS } from "./const";
|
|
8
6
|
import { createLogger, utilsLogger } from "../../logger";
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
interface Window {
|
|
12
|
-
VIZIO?: {
|
|
13
|
-
exitApplication: () => void;
|
|
14
|
-
setClosedCaptionHandler: (
|
|
15
|
-
callback: (isCCEnabled: boolean) => void
|
|
16
|
-
) => void;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const { log_debug, log_error } = createLogger({
|
|
8
|
+
const { log_debug } = createLogger({
|
|
22
9
|
category: "General",
|
|
23
10
|
subsystem: "PlatformUtils",
|
|
24
11
|
parent: utilsLogger,
|
|
@@ -63,7 +50,7 @@ export const hasVizioAPIs = () => {
|
|
|
63
50
|
* Manages device based closed captioning state
|
|
64
51
|
* Returns an observable that emits the current state and updates whenever it changes
|
|
65
52
|
*/
|
|
66
|
-
class ClosedCaptioningManager {
|
|
53
|
+
export class ClosedCaptioningManager {
|
|
67
54
|
private ccState$ = new BehaviorSubject<boolean>(false);
|
|
68
55
|
private static ccManagerInstance: ClosedCaptioningManager;
|
|
69
56
|
|
|
@@ -128,96 +115,57 @@ export const getClosedCaptionState = () => {
|
|
|
128
115
|
return ccManager.getStateAsObservable();
|
|
129
116
|
};
|
|
130
117
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
static
|
|
138
|
-
if (!TextTrackManager.instance) {
|
|
139
|
-
TextTrackManager.instance = new TextTrackManager();
|
|
140
|
-
}
|
|
118
|
+
/**
|
|
119
|
+
* Manages device based closed captioning state
|
|
120
|
+
* Returns an observable that emits the current state and updates whenever it changes
|
|
121
|
+
*/
|
|
122
|
+
export class TTSManager {
|
|
123
|
+
private ttsState$ = new BehaviorSubject<boolean>(false);
|
|
124
|
+
private static ttsManagerInstance: TTSManager;
|
|
141
125
|
|
|
142
|
-
|
|
126
|
+
private constructor() {
|
|
127
|
+
this.initialize();
|
|
143
128
|
}
|
|
144
129
|
|
|
145
|
-
|
|
146
|
-
if (!
|
|
147
|
-
|
|
148
|
-
"Controller is required for TextTrackManager initialization"
|
|
149
|
-
);
|
|
130
|
+
static getInstance(): TTSManager {
|
|
131
|
+
if (!TTSManager.ttsManagerInstance) {
|
|
132
|
+
TTSManager.ttsManagerInstance = new TTSManager();
|
|
150
133
|
}
|
|
151
134
|
|
|
152
|
-
|
|
135
|
+
return TTSManager.ttsManagerInstance;
|
|
153
136
|
}
|
|
154
137
|
|
|
155
|
-
async
|
|
156
|
-
if (!
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const preferredTextTrack = await this.getPreferredTextTrack(textTracks);
|
|
165
|
-
|
|
166
|
-
if (preferredTextTrack) {
|
|
167
|
-
this.controller.selectTrack(preferredTextTrack);
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
170
|
-
this.controller.selectTrack(null);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async getPreferredTextTrack(
|
|
175
|
-
textTracks: QuickBrickPlayer.TextTrack[]
|
|
176
|
-
): Promise<QuickBrickPlayer.TextTrack | undefined> {
|
|
177
|
-
if (!this.controller) return;
|
|
178
|
-
|
|
179
|
-
const userPreferredTextLanguageLocalStorage = await localStorage.getItem(
|
|
180
|
-
"preferred_text_language",
|
|
181
|
-
"user_preferences"
|
|
138
|
+
async initialize() {
|
|
139
|
+
if (!isVizioPlatform()) return;
|
|
140
|
+
|
|
141
|
+
document.addEventListener(
|
|
142
|
+
"VIZIO_TTS_ENABLED",
|
|
143
|
+
() => {
|
|
144
|
+
this.ttsState$.next(true);
|
|
145
|
+
},
|
|
146
|
+
false
|
|
182
147
|
);
|
|
183
148
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (userPreferredTextLanguage?.id) {
|
|
193
|
-
return userPreferredTextLanguage;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const enableAutoTextTrackSelection =
|
|
197
|
-
this.controller.getPluginConfiguration()
|
|
198
|
-
?.enable_auto_text_track_selection ||
|
|
199
|
-
this.controller.getTracksState().textTracks.length > 0;
|
|
200
|
-
|
|
201
|
-
if (enableAutoTextTrackSelection) {
|
|
202
|
-
const languageCode = await sessionStorage.getItem("languageCode");
|
|
203
|
-
|
|
204
|
-
if (languageCode) {
|
|
205
|
-
const chosenTextTrackBySystemLanguage = textTracks.find(
|
|
206
|
-
(track) => track.language === languageCode
|
|
207
|
-
);
|
|
149
|
+
document.addEventListener(
|
|
150
|
+
"VIZIO_TTS_DISABLED",
|
|
151
|
+
() => {
|
|
152
|
+
this.ttsState$.next(false);
|
|
153
|
+
},
|
|
154
|
+
false
|
|
155
|
+
);
|
|
156
|
+
}
|
|
208
157
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
}
|
|
158
|
+
getCurrentState(): boolean {
|
|
159
|
+
return this.ttsState$.getValue();
|
|
160
|
+
}
|
|
214
161
|
|
|
215
|
-
|
|
162
|
+
getStateAsObservable() {
|
|
163
|
+
return this.ttsState$.asObservable();
|
|
216
164
|
}
|
|
217
165
|
|
|
218
|
-
|
|
219
|
-
if (!
|
|
166
|
+
readText(text: string) {
|
|
167
|
+
if (!window.VIZIO?.Chromevox) return;
|
|
220
168
|
|
|
221
|
-
|
|
169
|
+
window.VIZIO.Chromevox.play(text);
|
|
222
170
|
}
|
|
223
171
|
}
|
|
@@ -359,6 +359,13 @@ export class Player {
|
|
|
359
359
|
});
|
|
360
360
|
};
|
|
361
361
|
|
|
362
|
+
onVideoError = (error: Error) => {
|
|
363
|
+
this.invokeListenersUpdate({
|
|
364
|
+
callbackName: SharedPlayerCallBacksKeys.OnVideoError,
|
|
365
|
+
event: error,
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
|
|
362
369
|
onError = (error: Error) => {
|
|
363
370
|
this.invokeListenersUpdate({
|
|
364
371
|
callbackName: SharedPlayerCallBacksKeys.OnError,
|
|
@@ -650,6 +657,7 @@ export class Player {
|
|
|
650
657
|
onPlayerSeekComplete: this.onSeekComplete,
|
|
651
658
|
onVideoEnd: this.onVideoEnd,
|
|
652
659
|
onError: this.onError,
|
|
660
|
+
onVideoError: this.onVideoError,
|
|
653
661
|
onLoad: this.onLoad,
|
|
654
662
|
onPlayerPause: this.onPlayerPause,
|
|
655
663
|
onPlayerResume: this.onPlayerResume,
|
|
@@ -725,4 +733,5 @@ export class Player {
|
|
|
725
733
|
|
|
726
734
|
public supportsNativeControls = (): boolean => false;
|
|
727
735
|
public supportNativeCast = (): boolean => false;
|
|
736
|
+
public destroy = () => {};
|
|
728
737
|
}
|
|
@@ -2,7 +2,6 @@ import { domUtilsLogger } from "./logger";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Gets an object of cookies and sets them on the DOM.
|
|
5
|
-
* @param {Object} cookies selected data key for label.
|
|
6
5
|
*/
|
|
7
6
|
export function setCookies(cookies): void {
|
|
8
7
|
const cookieKeys = Object.keys(cookies);
|
|
@@ -25,7 +24,7 @@ export function setCookies(cookies): void {
|
|
|
25
24
|
/**
|
|
26
25
|
* Gets cookies set on DOM
|
|
27
26
|
*/
|
|
28
|
-
export function getCookies():
|
|
27
|
+
export function getCookies(): typeof document.cookie {
|
|
29
28
|
try {
|
|
30
29
|
if (document) {
|
|
31
30
|
return document.cookie;
|
package/functionUtils/index.ts
CHANGED
|
@@ -73,12 +73,12 @@ type SubscriberFn<T> = (
|
|
|
73
73
|
|
|
74
74
|
export type EventHandlerFn<T> = (event: string, ...args: unknown[]) => T;
|
|
75
75
|
|
|
76
|
-
type SubscriberObj =
|
|
77
|
-
on
|
|
78
|
-
invokeHandler: EventHandlerFn<SubscriberObj
|
|
79
|
-
removeHandler: EventHandlerFn<SubscriberObj
|
|
80
|
-
handlers: Record<string, SubscriberFn<SubscriberObj
|
|
81
|
-
}
|
|
76
|
+
export type SubscriberObj<T extends {} = {}> = {
|
|
77
|
+
on: SubscriberFn<SubscriberObj<T>>;
|
|
78
|
+
invokeHandler: EventHandlerFn<SubscriberObj<T>>;
|
|
79
|
+
removeHandler: EventHandlerFn<SubscriberObj<T>>;
|
|
80
|
+
handlers: Record<string, SubscriberFn<SubscriberObj<T>>[] | []>;
|
|
81
|
+
} & T;
|
|
82
82
|
|
|
83
83
|
export const clearObject = (object: { [key: string]: unknown }) =>
|
|
84
84
|
Object.keys(object).forEach((key) => delete object[key]);
|
|
@@ -88,7 +88,11 @@ export const clearObject = (object: { [key: string]: unknown }) =>
|
|
|
88
88
|
* @param {Object} obj to add the subscription feature on
|
|
89
89
|
* @returns {Object} subscriber object
|
|
90
90
|
*/
|
|
91
|
-
export function subscriber
|
|
91
|
+
export function subscriber<T extends Partial<SubscriberObj> = {}>(
|
|
92
|
+
_obj: T = {} as T
|
|
93
|
+
): SubscriberObj {
|
|
94
|
+
const obj: T = _obj;
|
|
95
|
+
|
|
92
96
|
if (!obj.handlers) {
|
|
93
97
|
obj.handlers = {};
|
|
94
98
|
}
|
|
@@ -134,7 +138,7 @@ export function subscriber(obj: SubscriberObj = {}): SubscriberObj {
|
|
|
134
138
|
| SubscriberFn<SubscriberObj>[]
|
|
135
139
|
| [];
|
|
136
140
|
|
|
137
|
-
return obj;
|
|
141
|
+
return obj as SubscriberObj;
|
|
138
142
|
};
|
|
139
143
|
|
|
140
144
|
/**
|
|
@@ -150,16 +154,16 @@ export function subscriber(obj: SubscriberObj = {}): SubscriberObj {
|
|
|
150
154
|
|
|
151
155
|
R.compose(R.forEach(callHandlerWithDispose), R.propOr([], event))(handlers);
|
|
152
156
|
|
|
153
|
-
return obj;
|
|
157
|
+
return obj as SubscriberObj;
|
|
154
158
|
};
|
|
155
159
|
|
|
156
160
|
obj.removeHandler = function (event, handler) {
|
|
157
161
|
handlers[event] = R.reject(R.equals(handler), handlers[event]);
|
|
158
162
|
|
|
159
|
-
return obj;
|
|
163
|
+
return obj as SubscriberObj;
|
|
160
164
|
};
|
|
161
165
|
|
|
162
|
-
return obj;
|
|
166
|
+
return obj as SubscriberObj;
|
|
163
167
|
}
|
|
164
168
|
|
|
165
169
|
/**
|
package/modalState/index.ts
CHANGED
|
@@ -31,11 +31,7 @@ export const useModalStore = create<ModalStore>((set) => ({
|
|
|
31
31
|
set((state) => ({
|
|
32
32
|
modalState: { ...state.modalState, ...newState },
|
|
33
33
|
})),
|
|
34
|
-
openModal: ({
|
|
35
|
-
item,
|
|
36
|
-
options = {},
|
|
37
|
-
props = { screenData: {} },
|
|
38
|
-
}: OpenModalArg) =>
|
|
34
|
+
openModal: ({ item, options = {}, props }: OpenModalArg) =>
|
|
39
35
|
set({
|
|
40
36
|
modalState: {
|
|
41
37
|
visible: true,
|