@applicaster/zapp-react-native-utils 15.0.0-alpha.9361645236 → 15.0.0-alpha.9667030680

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.
@@ -250,10 +250,6 @@ export class Player {
250
250
  return false;
251
251
  }
252
252
 
253
- if (!Number.isFinite(duration)) {
254
- return this.getSeekableDuration() > 0;
255
- }
256
-
257
253
  return duration > 0;
258
254
  };
259
255
 
@@ -9,7 +9,10 @@ import {
9
9
  } from "@applicaster/zapp-react-native-utils/stringUtils";
10
10
  import { cellUtilsLogger } from "@applicaster/zapp-react-native-utils/cellUtils/logger";
11
11
  import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
12
- import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
12
+ import {
13
+ isNotNil,
14
+ isNilOrEmpty,
15
+ } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
13
16
 
14
17
  import { toNumberWithDefault, toNumberWithDefaultZero } from "../numberUtils";
15
18
 
@@ -505,3 +508,39 @@ export const getImageContainerMarginStyles = ({ value }: { value: any }) => {
505
508
  marginRight: value("image_margin_right"),
506
509
  };
507
510
  };
511
+
512
+ export const withoutNilOrEmpty = (arr: string[]): string[] =>
513
+ arr.filter((item) => !isNilOrEmpty(item));
514
+
515
+ export const isTextLabel = (key: string): boolean =>
516
+ key.includes("text_label_") && key.endsWith("_switch");
517
+
518
+ export const hasTextLabelsEnabled = (
519
+ configuration: Record<string, any>
520
+ ): boolean => {
521
+ const textLabelsKeys = Object.keys(configuration).filter(isTextLabel);
522
+
523
+ const picked = textLabelsKeys.reduce(
524
+ (acc, key) => {
525
+ acc[key] = configuration[key];
526
+
527
+ return acc;
528
+ },
529
+ {} as Record<string, any>
530
+ );
531
+
532
+ const pickedValues = Object.values(picked);
533
+
534
+ // Check if any switch value is truthy (true, "true", "1", etc.)
535
+ return pickedValues.some((value) => {
536
+ if (typeof value === "boolean") {
537
+ return value === true;
538
+ }
539
+
540
+ if (typeof value === "string") {
541
+ return value !== "" && value.toLowerCase() !== "false";
542
+ }
543
+
544
+ return Boolean(value);
545
+ });
546
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "15.0.0-alpha.9361645236",
3
+ "version": "15.0.0-alpha.9667030680",
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.9361645236",
30
+ "@applicaster/applicaster-types": "15.0.0-alpha.9667030680",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
@@ -147,34 +147,17 @@ export class TVSeekController
147
147
 
148
148
  let targetPos = currentPos;
149
149
 
150
- const isLive = this.playerController.isLive();
151
-
152
- if (isLive) {
153
- if (this.currentSeekType === SEEK_TYPE.REWIND) {
154
- targetPos = Math.min(
155
- currentPos + offset,
156
- this.playerController.getSeekableDuration()
157
- );
158
- } else if (this.currentSeekType === SEEK_TYPE.FORWARD) {
159
- targetPos = Math.max(0, currentPos - offset);
160
- } else {
161
- log_warning(
162
- `TVSeekController: handleDelayedSeek - invalid seek type: ${this.currentSeekType}`
163
- );
164
- }
150
+ if (this.currentSeekType === SEEK_TYPE.FORWARD) {
151
+ targetPos = Math.min(
152
+ currentPos + offset,
153
+ this.playerController.getSeekableDuration()
154
+ );
155
+ } else if (this.currentSeekType === SEEK_TYPE.REWIND) {
156
+ targetPos = Math.max(0, currentPos - offset);
165
157
  } else {
166
- if (this.currentSeekType === SEEK_TYPE.FORWARD) {
167
- targetPos = Math.min(
168
- currentPos + offset,
169
- this.playerController.getSeekableDuration()
170
- );
171
- } else if (this.currentSeekType === SEEK_TYPE.REWIND) {
172
- targetPos = Math.max(0, currentPos - offset);
173
- } else {
174
- log_warning(
175
- `TVSeekController: handleDelayedSeek - invalid seek type: ${this.currentSeekType}`
176
- );
177
- }
158
+ log_warning(
159
+ `TVSeekController: handleDelayedSeek - invalid seek type: ${this.currentSeekType}`
160
+ );
178
161
  }
179
162
 
180
163
  log_debug(
@@ -0,0 +1,73 @@
1
+ import { mapAccum } from "../mapAccum";
2
+
3
+ describe("mapAccum", () => {
4
+ it("using standard ramda test", () => {
5
+ const digits = ["1", "2", "3", "4"];
6
+ const appender = (a, b) => [a + b, a + b];
7
+
8
+ const [acc, result] = mapAccum(appender, 0, digits); //= > ['01234', ['01', '012', '0123', '01234']]
9
+ expect(acc).toBe("01234");
10
+ expect(result).toEqual(["01", "012", "0123", "01234"]);
11
+ });
12
+
13
+ it("maps and accumulates over an array", () => {
14
+ const fn = (acc, x) => [acc + x, x * 2];
15
+ const [acc, result] = mapAccum(fn, 0, [1, 2, 3]);
16
+
17
+ expect(acc).toBe(6); // final accumulator (0 + 1 + 2 + 3)
18
+ expect(result).toEqual([2, 4, 6]); // mapped values (acc + x*2 at each step)
19
+ });
20
+
21
+ it("returns initial accumulator for empty array", () => {
22
+ const fn = (acc, x) => [acc + x, acc * x];
23
+ const [acc, result] = mapAccum(fn, 10, []);
24
+
25
+ expect(acc).toBe(10);
26
+ expect(result).toEqual([]);
27
+ });
28
+
29
+ it("accumulates strings correctly", () => {
30
+ const fn = (acc, x) => [acc + x, acc + x];
31
+ const [acc, result] = mapAccum(fn, "A", ["B", "C", "D"]);
32
+
33
+ expect(acc).toBe("ABCD");
34
+ expect(result).toEqual(["AB", "ABC", "ABCD"]);
35
+ });
36
+
37
+ it("works with objects as accumulator", () => {
38
+ const fn = (acc, x) => {
39
+ const newAcc = { sum: acc.sum + x };
40
+
41
+ return [newAcc, newAcc.sum];
42
+ };
43
+
44
+ const [acc, result] = mapAccum(fn, { sum: 0 }, [1, 2, 3]);
45
+
46
+ expect(acc).toEqual({ sum: 6 });
47
+ expect(result).toEqual([1, 3, 6]);
48
+ });
49
+
50
+ it("is curried", () => {
51
+ const fn = (acc, x) => [acc + x, x * 2];
52
+ const mapWithFn = mapAccum(fn);
53
+ const withInit = mapWithFn(2);
54
+ const [acc, result] = withInit([1, 2, 3]);
55
+
56
+ expect(acc).toBe(8);
57
+ expect(result).toEqual([2, 4, 6]);
58
+ });
59
+
60
+ it("does not mutate the original array", () => {
61
+ const arr = [1, 2, 3];
62
+ mapAccum((acc, x) => [acc + x, acc + x], 0, arr);
63
+ expect(arr).toEqual([1, 2, 3]);
64
+ });
65
+
66
+ it("handles mixed types in accumulator and result", () => {
67
+ const fn = (acc, x) => [acc + x.length, acc + "-" + x];
68
+ const [acc, result] = mapAccum(fn, 0, ["a", "bb", "ccc"]);
69
+
70
+ expect(acc).toBe(6);
71
+ expect(result).toEqual(["0-a", "1-bb", "3-ccc"]);
72
+ });
73
+ });
package/utils/index.ts CHANGED
@@ -16,6 +16,8 @@ export { endsWith } from "./endsWith";
16
16
 
17
17
  export { take } from "./take";
18
18
 
19
+ export { mapAccum } from "./mapAccum";
20
+
19
21
  export {
20
22
  cloneDeep as clone,
21
23
  flatten,
@@ -38,4 +40,5 @@ export {
38
40
  uniqWith,
39
41
  flowRight as compose,
40
42
  partial,
43
+ reverse,
41
44
  } from "lodash";
@@ -0,0 +1,23 @@
1
+ import { curry } from "lodash";
2
+
3
+ /**
4
+ * A native reimplementation of Ramda's mapAccum.
5
+ *
6
+ * @template A, B, C
7
+ * @param {(acc: A, value: B) => [A, C]} fn - Function returning [newAcc, mappedValue]
8
+ * @param {A} acc - Initial accumulator
9
+ * @param {B[]} list - List to process
10
+ * @returns {[A, C[]]} - Tuple of [final accumulator, mapped array]
11
+ */
12
+ export const mapAccum = curry((fn, acc, list) => {
13
+ const result = [];
14
+ let currentAcc = acc;
15
+
16
+ for (let i = 0; i < list.length; i++) {
17
+ const [nextAcc, mapped] = fn(currentAcc, list[i]);
18
+ currentAcc = nextAcc;
19
+ result.push(mapped);
20
+ }
21
+
22
+ return [currentAcc, result];
23
+ });