@applicaster/zapp-react-native-utils 12.0.0-alpha.4054240460 → 12.0.0-alpha.4195481103

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.
@@ -0,0 +1,50 @@
1
+ export const BUTTON_ACCESSIBILITY_KEYS = {
2
+ play: {
3
+ label: "accessibility_play_label",
4
+ hint: "accessibility_play_hint",
5
+ mini: {
6
+ label: "accessibility_play_mini_label",
7
+ hint: "accessibility_play_mini_hint",
8
+ },
9
+ },
10
+ pause: {
11
+ label: "accessibility_pause_label",
12
+ hint: "accessibility_pause_hint",
13
+ mini: {
14
+ label: "accessibility_pause_mini_label",
15
+ hint: "accessibility_pause_mini_hint",
16
+ },
17
+ },
18
+ rewind: {
19
+ label: "accessibility_rewind_label",
20
+ hint: "accessibility_rewind_hint",
21
+ },
22
+ forward: {
23
+ label: "accessibility_forward_label",
24
+ hint: "accessibility_forward_hint",
25
+ },
26
+ close: {
27
+ label: "accessibility_close_label",
28
+ hint: "accessibility_close_hint",
29
+ mini: {
30
+ label: "accessibility_close_mini_label",
31
+ hint: "accessibility_close_mini_hint",
32
+ },
33
+ },
34
+ maximize: {
35
+ label: "accessibility_maximize_label",
36
+ hint: "accessibility_maximize_hint",
37
+ },
38
+ subtitles: {
39
+ label: "accessibility_subtitle_label",
40
+ hint: "accessibility_subtitle_hint",
41
+ },
42
+ back: {
43
+ label: "accessibility_back_label",
44
+ hint: "accessibility_back_hint",
45
+ },
46
+ fullscreen: {
47
+ label: "accessibility_fullscreen_label",
48
+ hint: "accessibility_fullscreen_hint",
49
+ },
50
+ } as const;
@@ -0,0 +1,31 @@
1
+ import { useEffect, useMemo } from "react";
2
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
+ import { AccessibilityManager } from "./index";
4
+
5
+ export const useAccessibilityManager = () => {
6
+ const { remoteConfigurations } = usePickFromState(["remoteConfigurations"]);
7
+ const { localizations } = remoteConfigurations;
8
+
9
+ const accessibilityManager = useMemo(() => {
10
+ return AccessibilityManager.getInstance();
11
+ }, []);
12
+
13
+ useEffect(() => {
14
+ accessibilityManager.updateLocalizations(localizations);
15
+ }, [localizations]);
16
+
17
+ useEffect(() => {
18
+ const subscription = accessibilityManager.getStateAsObservable().subscribe({
19
+ next: () => {
20
+ // TODO: handle accessibility states
21
+ // screenReaderEnabled: false
22
+ // reduceMotionEnabled: false
23
+ // boldTextEnabled: false
24
+ },
25
+ });
26
+
27
+ return () => subscription.unsubscribe();
28
+ }, [accessibilityManager]);
29
+
30
+ return accessibilityManager;
31
+ };
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ import { utilsLogger } from "../../logger";
2
+
3
+ export const accessibilityManagerLogger = utilsLogger.addSubsystem(
4
+ "accessibilityManager"
5
+ );
@@ -206,7 +206,7 @@ export function getTargetInDirection(
206
206
  const overrideTarget = currentNode?.component?.props[overridePropName];
207
207
 
208
208
  if (overrideTarget) {
209
- const target = targetNodes.find((n) => n.id === overrideTarget);
209
+ const target = targetNodes.find((n) => n?.id === overrideTarget);
210
210
 
211
211
  if (target) return target;
212
212
  }
package/appUtils/index.js CHANGED
@@ -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 **/");
@@ -246,9 +246,11 @@ export class TTSManager {
246
246
  }
247
247
 
248
248
  async initialize() {
249
+ if (!isVizioPlatform()) return;
250
+
249
251
  document.addEventListener(
250
252
  "VIZIO_TTS_ENABLED",
251
- function () {
253
+ () => {
252
254
  this.ttsState$.next(true);
253
255
  },
254
256
  false
@@ -256,7 +258,7 @@ export class TTSManager {
256
258
 
257
259
  document.addEventListener(
258
260
  "VIZIO_TTS_DISABLED",
259
- function () {
261
+ () => {
260
262
  this.ttsState$.next(false);
261
263
  },
262
264
  false
@@ -7,6 +7,7 @@ export enum SharedPlayerCallBacksKeys {
7
7
  OnPlayerPause = "onPlayerPause",
8
8
  OnLoad = "onLoad",
9
9
  OnError = "onError",
10
+ OnVideoError = "onVideoError",
10
11
  OnVideoEnd = "onVideoEnd",
11
12
  OnPlaybackRateChange = "onPlaybackRateChange",
12
13
  OnVideoLoad = "onVideoLoad",
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "12.0.0-alpha.4054240460",
3
+ "version": "12.0.0-alpha.4195481103",
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.0-alpha.4054240460",
31
+ "@applicaster/applicaster-types": "12.0.0-alpha.4195481103",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -245,3 +245,12 @@ export function generateManifest({ manifestConfig, version }) {
245
245
 
246
246
  return manifestConfig({ platform, version });
247
247
  }
248
+
249
+ const getPluginType = R.pathOr("unknown_plugin_type", [
250
+ "state",
251
+ "screen",
252
+ "plugin_type",
253
+ ]);
254
+
255
+ export const isPlayerPlugin = (routeState): boolean =>
256
+ getPluginType(routeState) === "player";
@@ -78,6 +78,10 @@ export function isNavBarVisible(
78
78
  return false;
79
79
  }
80
80
 
81
+ if (screenData?.plugin_type === "login" && isTV()) {
82
+ return false;
83
+ }
84
+
81
85
  /* Match if screen is Hook */
82
86
  if (route.startsWith("/hooks/")) {
83
87
  const module = screenData?.module;
@@ -1,8 +0,0 @@
1
- export const FOCUSABLE_EVENTS = {
2
- IS_REGISTERED: "isRegistered",
3
- WILL_RECEIVE_FOCUS: "willReceiveFocus",
4
- HAS_RECEIVED_FOCUS: "hasReceivedFocus",
5
- WILL_LOSE_FOCUS: "willLoseFocus",
6
- HAS_LOST_FOCUS: "hasLostFocus",
7
- WILL_UNREGISTER: "willUnregister",
8
- };