@applicaster/zapp-react-native-utils 13.0.0-rc.17 → 13.0.0-rc.19

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.
@@ -4,6 +4,8 @@ import { HOOKS_EVENTS } from "./constants";
4
4
  export interface HookConfiguration {}
5
5
 
6
6
  /* existing Hook Plugn props: sample */
7
+
8
+ /*
7
9
  interface _HookModulePlugin {
8
10
  Component:
9
11
  | React.FC<HookPluginProps>
@@ -23,6 +25,7 @@ interface _HookModulePlugin {
23
25
  presentUI: (payload?: HookPluginProps["payload"]) => void
24
26
  ) => any;
25
27
  }
28
+ */
26
29
 
27
30
  //* Derived from usage */
28
31
  export interface HookModule {
@@ -6,6 +6,9 @@ import { AccessibilityRole } from "react-native";
6
6
 
7
7
  export class AccessibilityManager {
8
8
  private static _instance: AccessibilityManager | null = null;
9
+ private headingTimeout: NodeJS.Timeout | null = null;
10
+ private WORDS_PER_MINUTE = 160;
11
+ private MINIMUM_PAUSE = 500;
9
12
  private state$ = new BehaviorSubject<AccessibilityState>({
10
13
  screenReaderEnabled: false,
11
14
  reduceMotionEnabled: false,
@@ -20,6 +23,7 @@ export class AccessibilityManager {
20
23
 
21
24
  private ttsManager = TTSManager.getInstance();
22
25
  private localizations: { [key: string]: string } = {};
26
+ private headingQueue: string[] = [];
23
27
 
24
28
  private constructor() {}
25
29
 
@@ -52,6 +56,28 @@ export class AccessibilityManager {
52
56
  return this.state$.asObservable();
53
57
  }
54
58
 
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
+
55
81
  /**
56
82
  * text you want to be read, if you want to use localized text pass keyOfLocalizedText instead
57
83
  * keyOfLocalizedText is the key to the localized text
@@ -85,7 +111,22 @@ export class AccessibilityManager {
85
111
  textToRead = localizedMessage;
86
112
  }
87
113
 
88
- this.ttsManager && this.ttsManager.readText(textToRead);
114
+ if (this.headingQueue.length > 0) {
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
+ }
89
130
 
90
131
  this.announcements$.next({
91
132
  message: textToRead,
@@ -1,8 +1,8 @@
1
1
  import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
2
- import { find, last, startsWith, pathOr } from "ramda";
2
+ import { find, last, pathOr, startsWith } from "ramda";
3
3
  import {
4
- QUICK_BRICK_NAVBAR,
5
4
  QUICK_BRICK_CONTENT,
5
+ QUICK_BRICK_NAVBAR,
6
6
  } from "@applicaster/quick-brick-core/const";
7
7
 
8
8
  // run check each 300 ms
@@ -66,7 +66,8 @@ export const getContentNode = (focusableTree) => {
66
66
  const content = find(
67
67
  (child) =>
68
68
  startsWith(QUICK_BRICK_CONTENT, child.id) ||
69
- startsWith("player", child.id),
69
+ startsWith("player", child.id) ||
70
+ startsWith("/hooks", child?.parent?.id), // For startup hooks case
70
71
  getActiveScreenChildren(focusableTree)
71
72
  );
72
73
 
@@ -23,3 +23,17 @@ export const PLATFORMS = {
23
23
  export const PLATFORM_KEYS = {
24
24
  deviceClosedCaptioningEnabled: "device_closed_captioning_enabled",
25
25
  };
26
+
27
+ export enum ZappPlatform {
28
+ Android = "android",
29
+ AndroidTV = "android_tv",
30
+ AmazonFireTV = "amazon",
31
+ iOS = "ios",
32
+ tvOS = "tvos",
33
+ Roku = "roku",
34
+ Tizen = "tizen",
35
+ Web = "web",
36
+ WebOS = "webos",
37
+ Vizio = "vizio",
38
+ Unknown = "unknown",
39
+ }
@@ -6,8 +6,10 @@ import {
6
6
  isSamsungPlatform,
7
7
  } from "@applicaster/zapp-react-dom-app/App/Loader/utils/platform";
8
8
 
9
- import { PLATFORM_KEYS, PLATFORMS } from "./const";
9
+ import { PLATFORM_KEYS, PLATFORMS, ZappPlatform } from "./const";
10
10
  import { createLogger, utilsLogger } from "../../logger";
11
+ import { getPlatform } from "../../reactUtils";
12
+ import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
11
13
 
12
14
  const { log_debug } = createLogger({
13
15
  category: "General",
@@ -15,6 +17,20 @@ const { log_debug } = createLogger({
15
17
  parent: utilsLogger,
16
18
  });
17
19
 
20
+ export const getZappPlatform = (): ZappPlatform => {
21
+ const platform = appStore.get("appData")?.platform;
22
+
23
+ switch (platform) {
24
+ case "amazon_fire_tv":
25
+ return ZappPlatform.AmazonFireTV;
26
+ case ZappPlatform.Vizio:
27
+ return ZappPlatform.Vizio;
28
+ default:
29
+ // TODO: Use only ZappPlatform enum
30
+ return getPlatform() as ZappPlatform;
31
+ }
32
+ };
33
+
18
34
  export const getUserAgent = () => window?.navigator?.userAgent;
19
35
 
20
36
  /** VIZIO UTILS */
package/logger/const.ts CHANGED
@@ -1,6 +1,3 @@
1
- /* eslint-disable unused-imports/no-unused-vars */
2
- import * as R from "ramda";
3
-
4
1
  enum XRayLogLevel {
5
2
  verbose = 0,
6
3
  debug = 1,
@@ -11,51 +8,9 @@ enum XRayLogLevel {
11
8
  off = 100,
12
9
  }
13
10
 
14
- enum ToastLogLevel {
15
- off = "off",
16
- verbose = "verbose",
17
- debug = "debug",
18
- info = "info",
19
- warning = "warning",
20
- error = "error",
21
- }
22
-
23
- const toastLevelToLogLevel = (toastLogLevel: ToastLogLevel): XRayLogLevel => {
24
- if (R.isNil(toastLogLevel)) {
25
- return XRayLogLevel.off;
26
- }
27
-
28
- switch (toastLogLevel) {
29
- case ToastLogLevel.verbose:
30
- return XRayLogLevel.verbose;
31
- case ToastLogLevel.debug:
32
- return XRayLogLevel.debug;
33
- case ToastLogLevel.info:
34
- return XRayLogLevel.info;
35
- case ToastLogLevel.error:
36
- return XRayLogLevel.error;
37
- default:
38
- return XRayLogLevel.off;
39
- }
40
- };
41
-
42
- const PLUGIN_IDENTIFIER = "xray_logging_plugin";
43
-
44
- const wrapInObject = (obj, name) => {};
45
-
46
- const applyConditions = (wrappedObj) => {};
47
-
48
- const sanitizeEventPayload = () => {};
11
+ const wrapInObject = (_ctx: unknown, _key: string) => {};
49
12
 
50
- const __isRunningRepoTests = () => {};
51
-
52
- const isWeb = () => {};
53
-
54
- const isDOMApp = () => {};
55
-
56
- const isBrowser = () => {};
57
-
58
- const eventAllowed = () => {};
13
+ const applyConditions = (_fn: unknown) => {};
59
14
 
60
15
  /**
61
16
  * This is the mocked version of XRayLogger
@@ -90,34 +45,21 @@ export default class XRayLogger {
90
45
  );
91
46
  };
92
47
 
93
- log = (event: string | XRayEventData) => {
94
- const logEvent = typeof event === "string" ? { message: event } : event;
95
- };
48
+ log = (_event) => {};
96
49
 
97
- debug = (event: string | XRayEventData) => {
98
- const logEvent = typeof event === "string" ? { message: event } : event;
99
- };
50
+ debug = (_event) => {};
100
51
 
101
- info = (event: string | XRayEventData) => {
102
- const logEvent = typeof event === "string" ? { message: event } : event;
103
- };
52
+ info = (_event) => {};
104
53
 
105
- warning = (event: string | XRayEventData) => {
106
- const logEvent = typeof event === "string" ? { message: event } : event;
107
- };
54
+ warning = (_event) => {};
108
55
 
109
- warn = (event: string | XRayEventData) => {
56
+ warn = (_event) => {
110
57
  this.warning(event);
111
58
  };
112
59
 
113
- error = (event: Error | XRayEventData) => {
114
- const logEvent: XRayEventData =
115
- event instanceof Error
116
- ? { exception: event as Error, message: event.message }
117
- : (event as XRayEventData);
118
- };
60
+ error = (_event) => {};
119
61
 
120
- sendEvent = (event, eventData) => {};
62
+ sendEvent = (_event, _eventData) => {};
121
63
 
122
64
  // To be used by QuickBrick Hook events
123
65
  sendAudienceEvent = (event, eventData = null) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-rc.17",
3
+ "version": "13.0.0-rc.19",
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": "13.0.0-rc.17",
31
+ "@applicaster/applicaster-types": "13.0.0-rc.19",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -87,7 +87,7 @@ export const useFeedLoader = ({
87
87
  );
88
88
  }
89
89
  }
90
- }, [callableFeedUrl, currentFeed?.data]);
90
+ }, [callableFeedUrl, currentFeed?.data?.next]);
91
91
 
92
92
  useEffect(() => {
93
93
  if (
package/time/Timer.ts CHANGED
@@ -4,7 +4,7 @@ export class Timer {
4
4
  private timeoutId: NodeJS.Timeout | null;
5
5
 
6
6
  constructor(private callback: () => void, private duration: number) {
7
- this.remaining = duration;
7
+ this.remaining = this.duration;
8
8
  this.timeoutId = null;
9
9
  }
10
10