@applicaster/zapp-react-native-utils 13.0.0-rc.28 → 13.0.0-rc.29

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.
@@ -81,9 +81,12 @@ export class ClosedCaptioningManager {
81
81
 
82
82
  static getInstance(): ClosedCaptioningManager {
83
83
  if (!ClosedCaptioningManager.ccManagerInstance) {
84
+ log_debug("ClosedCaptioningManager: Creating new instance");
84
85
  ClosedCaptioningManager.ccManagerInstance = new ClosedCaptioningManager();
85
86
  }
86
87
 
88
+ log_debug("ClosedCaptioningManager: Returning existing instance");
89
+
87
90
  return ClosedCaptioningManager.ccManagerInstance;
88
91
  }
89
92
 
@@ -92,23 +95,41 @@ export class ClosedCaptioningManager {
92
95
  PLATFORM_KEYS.deviceClosedCaptioningEnabled
93
96
  );
94
97
 
95
- log_debug("Initializing closed captioning manager", { existingState });
96
-
97
98
  if (existingState !== null) {
99
+ log_debug(
100
+ `ClosedCaptioningManager: Setting initial state to ${existingState}`
101
+ );
102
+
98
103
  this.ccState$.next(existingState === "true" || existingState === true);
104
+ } else {
105
+ log_debug("ClosedCaptioningManager: No existing state found");
99
106
  }
100
107
 
101
108
  if (hasVizioAPIs()) {
109
+ log_debug("ClosedCaptioningManager: Setting closed captioning handler");
110
+
102
111
  window.VIZIO!.setClosedCaptionHandler((isCCEnabled) => {
103
- log_debug("CC state changed", { isCCEnabled });
112
+ log_debug(
113
+ "ClosedCaptioningManager: There was a change in the CC state",
114
+ { isCCEnabled }
115
+ );
104
116
 
105
117
  sessionStorage.setItem(
106
118
  PLATFORM_KEYS.deviceClosedCaptioningEnabled,
107
119
  isCCEnabled
108
120
  );
109
121
 
122
+ log_debug(
123
+ "ClosedCaptioningManager: Saved CC state to session storage",
124
+ { isCCEnabled }
125
+ );
126
+
110
127
  this.ccState$.next(isCCEnabled);
111
128
  });
129
+ } else {
130
+ log_debug(
131
+ "ClosedCaptioningManager: Vizio APIs are not available, skipping setup"
132
+ );
112
133
  }
113
134
  }
114
135
 
@@ -78,8 +78,6 @@ describe("createConfig", () => {
78
78
  extend: "styles",
79
79
  })(props);
80
80
 
81
- console.log(mockGenerators.styles.mock.calls);
82
-
83
81
  expect(mockGenerators.styles).toBeCalledWith(props);
84
82
  });
85
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-rc.28",
3
+ "version": "13.0.0-rc.29",
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.28",
31
+ "@applicaster/applicaster-types": "13.0.0-rc.29",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -52,6 +52,14 @@ export const useDimensions: UseDimensions = (
52
52
  ? { fullDimensions }
53
53
  : { ...fullDimensions };
54
54
 
55
+ if (options.updateForInactiveScreens === undefined) {
56
+ options.updateForInactiveScreens = true;
57
+ }
58
+
59
+ if (options.fullDimensions === undefined) {
60
+ options.fullDimensions = false;
61
+ }
62
+
55
63
  const [dimensions, setDimensions] = useState(getInitialDimensions(context));
56
64
  const deviceInfo = useRef(getDeviceInfo(dimensions, appData));
57
65
 
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+
3
+ /**
4
+ * returns a ref with an initial value that is lazily evaluated once
5
+ * */
6
+ export const useRefWithInitialValue = <T>(initialValueGetter: () => T) => {
7
+ const ref = React.useRef<T>(null);
8
+
9
+ if (ref.current === null) {
10
+ ref.current = initialValueGetter();
11
+ }
12
+
13
+ return ref;
14
+ };
@@ -0,0 +1,23 @@
1
+ import { useEffect, useState } from "react";
2
+ import type { Subject } from "rxjs";
3
+
4
+ export const useStateFromSubscribe = <T, U>(
5
+ subject: Subject<T>,
6
+ onUpdate: (
7
+ observerValue: T,
8
+ next: React.Dispatch<React.SetStateAction<U>>
9
+ ) => void,
10
+ initialValue: U
11
+ ) => {
12
+ const [state, setState] = useState<U>(initialValue);
13
+
14
+ useEffect(() => {
15
+ const subscription = subject.subscribe((observer) =>
16
+ onUpdate(observer, setState)
17
+ );
18
+
19
+ return () => subscription.unsubscribe();
20
+ }, [subject]);
21
+
22
+ return state;
23
+ };