@applicaster/zapp-react-native-utils 15.0.0-alpha.1351496011 → 15.0.0-alpha.1404014050

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.
@@ -69,6 +69,7 @@ exports[`focusManagerIOS should be defined 1`] = `
69
69
  "getGroupRootById": [Function],
70
70
  "getPreferredFocusChild": [Function],
71
71
  "invokeHandler": [Function],
72
+ "isChildOf": [Function],
72
73
  "isFocusOn": [Function],
73
74
  "isGroupItemFocused": [Function],
74
75
  "moveFocus": [Function],
@@ -1,12 +1,20 @@
1
1
  import { NativeModules } from "react-native";
2
2
  import * as R from "ramda";
3
3
 
4
- import { isCurrentFocusOn } from "../focusManagerAux/utils";
4
+ import {
5
+ isCurrentFocusOn,
6
+ isChildOf as isChildOfUtils,
7
+ } from "../focusManagerAux/utils";
5
8
  import { Tree } from "./treeDataStructure/Tree";
6
9
  import { findFocusableNode } from "./treeDataStructure/Utils";
7
10
  import { subscriber } from "../../functionUtils";
8
11
  import { findChild } from "./utils";
9
12
 
13
+ import {
14
+ emitRegistered,
15
+ emitUnregistered,
16
+ } from "../focusManagerAux/utils/utils.ios";
17
+
10
18
  const { FocusableManagerModule } = NativeModules;
11
19
 
12
20
  /**
@@ -180,10 +188,14 @@ export const focusManager = (function () {
180
188
  function register({ id, component }) {
181
189
  const { isGroup = false } = component;
182
190
 
191
+ emitRegistered(id);
192
+
183
193
  return isGroup ? registerGroup(id, component) : registerItem(id, component);
184
194
  }
185
195
 
186
196
  function unregister(id, { group = false } = {}) {
197
+ emitUnregistered(id);
198
+
187
199
  group ? unregisterGroup(id) : unregisterItem(id);
188
200
  }
189
201
 
@@ -400,6 +412,10 @@ export const focusManager = (function () {
400
412
  return id && isCurrentFocusOn(id, currentFocusNode);
401
413
  }
402
414
 
415
+ function isChildOf(childId, parentId): boolean {
416
+ return isChildOfUtils(focusableTree, childId, parentId);
417
+ }
418
+
403
419
  return {
404
420
  on,
405
421
  invokeHandler,
@@ -422,5 +438,6 @@ export const focusManager = (function () {
422
438
  isGroupItemFocused,
423
439
  getPreferredFocusChild,
424
440
  isFocusOn,
441
+ isChildOf,
425
442
  };
426
443
  })();
@@ -64,8 +64,6 @@ export async function setFocusOnContent(currentRoute: string) {
64
64
 
65
65
  const { success } = setInitialFocus(content);
66
66
 
67
- console.log("debug_2", "setFocusOnContent", { success, currentRoute });
68
-
69
67
  if (!success) {
70
68
  // we've failed to put initial focus on content, re-run "setFocusOnContent" again as a fallback
71
69
  throw Error(
@@ -190,3 +190,21 @@ export const isCurrentFocusOn = (id, node) => {
190
190
 
191
191
  return isCurrentFocusOn(id, node.parent);
192
192
  };
193
+
194
+ export const isChildOf = (focusableTree, childId, parentId) => {
195
+ if (isNil(childId) || isNil(parentId)) {
196
+ return false;
197
+ }
198
+
199
+ const childNode = focusableTree.findInTree(childId);
200
+
201
+ if (isNil(childNode)) {
202
+ return false;
203
+ }
204
+
205
+ if (childNode.parent?.id === parentId) {
206
+ return true;
207
+ }
208
+
209
+ return isChildOf(focusableTree, childNode.parent?.id, parentId);
210
+ };
@@ -0,0 +1,35 @@
1
+ import { ReplaySubject } from "rxjs";
2
+ import { filter } from "rxjs/operators";
3
+ import { BUTTON_PREFIX } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const";
4
+ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
5
+
6
+ type FocusableID = string;
7
+ type RegistrationEvent = {
8
+ id: FocusableID;
9
+ registered: boolean;
10
+ };
11
+
12
+ const isFocusableButton = (id: Option<FocusableID>): boolean =>
13
+ id && id.includes?.(BUTTON_PREFIX);
14
+
15
+ const registeredSubject$ = new ReplaySubject<RegistrationEvent>(1);
16
+
17
+ export const focusableButtonsRegistration$ = (focusableGroupId: string) =>
18
+ registeredSubject$.pipe(
19
+ filter(
20
+ (value) =>
21
+ value.registered && focusManager.isChildOf(value.id, focusableGroupId)
22
+ )
23
+ );
24
+
25
+ export const emitRegistered = (id: Option<FocusableID>): void => {
26
+ if (isFocusableButton(id)) {
27
+ registeredSubject$.next({ id, registered: true });
28
+ }
29
+ };
30
+
31
+ export const emitUnregistered = (id: Option<FocusableID>): void => {
32
+ if (isFocusableButton(id)) {
33
+ registeredSubject$.next({ id, registered: false });
34
+ }
35
+ };
@@ -229,14 +229,14 @@ export class TTSManager {
229
229
  try {
230
230
  window.webOS.service.request("luna://com.webos.service.tts", {
231
231
  method: "speak",
232
- onFailure(error: any) {
232
+ onFailure: (error: any) => {
233
233
  log_debug("There was a failure setting up webOS TTS service", {
234
234
  error,
235
235
  });
236
236
 
237
237
  this.ttsState$.next(false);
238
238
  },
239
- onSuccess(response: any) {
239
+ onSuccess: (response: any) => {
240
240
  log_debug("webOS TTS service is configured successfully", {
241
241
  response,
242
242
  });
@@ -0,0 +1,24 @@
1
+ import { allTruthy } from "..";
2
+
3
+ describe("allTruthy", () => {
4
+ it("should return true when all values are true", () => {
5
+ expect(allTruthy([true, true, true])).toBe(true);
6
+ });
7
+
8
+ it("should return false when at least one value is false", () => {
9
+ expect(allTruthy([true, false, true])).toBe(false);
10
+ });
11
+
12
+ it("should return false when all values are false", () => {
13
+ expect(allTruthy([false, false, false])).toBe(false);
14
+ });
15
+
16
+ it("should return false for an empty array", () => {
17
+ expect(allTruthy([])).toBe(false);
18
+ });
19
+
20
+ it("should handle single-element arrays correctly", () => {
21
+ expect(allTruthy([true])).toBe(true);
22
+ expect(allTruthy([false])).toBe(false);
23
+ });
24
+ });
@@ -0,0 +1,24 @@
1
+ import { anyTruthy } from "..";
2
+
3
+ describe("anyTruthy", () => {
4
+ it("should return true when at least one value is true", () => {
5
+ expect(anyTruthy([false, true, false])).toBe(true);
6
+ });
7
+
8
+ it("should return false when all values are false", () => {
9
+ expect(anyTruthy([false, false, false])).toBe(false);
10
+ });
11
+
12
+ it("should return true when all values are true", () => {
13
+ expect(anyTruthy([true, true, true])).toBe(true);
14
+ });
15
+
16
+ it("should return false for an empty array", () => {
17
+ expect(anyTruthy([])).toBe(false);
18
+ });
19
+
20
+ it("should handle single-element arrays correctly", () => {
21
+ expect(anyTruthy([true])).toBe(true);
22
+ expect(anyTruthy([false])).toBe(false);
23
+ });
24
+ });
@@ -116,3 +116,8 @@ export const sample = (xs: unknown[]): unknown => {
116
116
 
117
117
  return xs[index];
118
118
  };
119
+
120
+ export const allTruthy = (xs: boolean[]) =>
121
+ isFilledArray(xs) && xs.every(Boolean);
122
+
123
+ export const anyTruthy = (xs: boolean[]) => xs.some(Boolean);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "15.0.0-alpha.1351496011",
3
+ "version": "15.0.0-alpha.1404014050",
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": "15.0.0-alpha.1351496011",
30
+ "@applicaster/applicaster-types": "15.0.0-alpha.1404014050",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
@@ -151,7 +151,13 @@ export const useBatchLoading = (
151
151
  }
152
152
  }
153
153
  });
154
- }, [feedUrls, feeds, loadPipesDataDispatcher]);
154
+ }, [
155
+ batchComponents,
156
+ feeds,
157
+ getUrl,
158
+ loadPipesDataDispatcher,
159
+ options.riverId,
160
+ ]);
155
161
 
156
162
  React.useEffect(() => {
157
163
  runBatchLoading();
@@ -34,7 +34,9 @@ export const usePipesCacheReset = (riverId, riverComponents) => {
34
34
  component
35
35
  );
36
36
 
37
- dispatch(clearPipesData(url, { riverId }));
37
+ if (url) {
38
+ dispatch(clearPipesData(url, { riverId }));
39
+ }
38
40
  }
39
41
  });
40
42
  };
@@ -44,7 +44,7 @@ export function useStatusBarHeight() {
44
44
 
45
45
  return platformSelect({
46
46
  ios: StatusBarHeight,
47
- android: StatusBar.currentHeight,
47
+ android: StatusBar.currentHeight ?? 0,
48
48
  default: 0,
49
49
  });
50
50
  }
package/utils/index.ts CHANGED
@@ -34,4 +34,8 @@ export {
34
34
  last,
35
35
  toLower,
36
36
  isEqual as equals,
37
+ uniq,
38
+ uniqWith,
39
+ flowRight as compose,
40
+ partial,
37
41
  } from "lodash";
@@ -56,9 +56,23 @@ const legacyMappingKeys = {
56
56
  actionType: "logout_completion_action",
57
57
  targetScreen: "navigate_to_logout_screen",
58
58
  },
59
+ "quick-brick-storefront": {
60
+ actionType: "purchase_completion_action",
61
+ targetScreen: "navigate_to_screen_after_purchase",
62
+ },
63
+ "zapp_login_plugin_oauth_tv_2_0.login": {
64
+ actionType: "login_completion_action",
65
+ targetScreen: "navigate_to_login_screen",
66
+ },
67
+ "zapp_login_plugin_oauth_tv_2_0.logout": {
68
+ actionType: "logout_completion_action",
69
+ targetScreen: "navigate_to_logout_screen",
70
+ },
59
71
  };
60
72
 
61
- const NAV_ACTIONS = Object.values(NavigationCallbackOptions) as string[];
73
+ const NAV_ACTIONS = (
74
+ Object.values(NavigationCallbackOptions) as string[]
75
+ ).filter((value) => value !== NavigationCallbackOptions.DEFAULT);
62
76
 
63
77
  const isNavAction = (v: unknown): v is NavigationCallbackOptions =>
64
78
  typeof v === "string" && NAV_ACTIONS.includes(v);