@applicaster/zapp-react-native-ui-components 14.0.29 → 14.0.30-alpha.6838902303

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.
@@ -107,6 +107,12 @@ export const GeneralContentScreen = ({
107
107
 
108
108
  const isReady = useRiverActionProviderReady();
109
109
 
110
+ React.useEffect(() => {
111
+ if (isReady) {
112
+ (globalThis as any).performance?.mark?.(`qb:content-ready:${screenId}`);
113
+ }
114
+ }, [isReady, screenId]);
115
+
110
116
  const contextValue = React.useMemo(
111
117
  () => whenMatchingType(Function, cellTapAction) || onCellTapAction,
112
118
  [typeof cellTapAction === "function" ? cellTapAction : onCellTapAction]
@@ -0,0 +1,56 @@
1
+ import { renderHook, act } from "@testing-library/react-hooks";
2
+
3
+ import { useAfterPaint } from "../useAfterPaint";
4
+
5
+ describe("useAfterPaint", () => {
6
+ let frameCallbacks: FrameRequestCallback[];
7
+ let originalRaf: typeof requestAnimationFrame;
8
+ let originalCancelRaf: typeof cancelAnimationFrame;
9
+
10
+ const flushFrame = () => {
11
+ const callbacks = frameCallbacks;
12
+ frameCallbacks = [];
13
+ act(() => {
14
+ callbacks.forEach((cb) => cb(0));
15
+ });
16
+ };
17
+
18
+ beforeEach(() => {
19
+ frameCallbacks = [];
20
+ originalRaf = global.requestAnimationFrame;
21
+ originalCancelRaf = global.cancelAnimationFrame;
22
+ global.requestAnimationFrame = jest.fn((cb: FrameRequestCallback) => {
23
+ frameCallbacks.push(cb);
24
+ return frameCallbacks.length;
25
+ }) as unknown as typeof requestAnimationFrame;
26
+ global.cancelAnimationFrame = jest.fn();
27
+ });
28
+
29
+ afterEach(() => {
30
+ global.requestAnimationFrame = originalRaf;
31
+ global.cancelAnimationFrame = originalCancelRaf;
32
+ });
33
+
34
+ it("returns false on the initial render", () => {
35
+ const { result } = renderHook(() => useAfterPaint());
36
+
37
+ expect(result.current).toBe(false);
38
+ });
39
+
40
+ it("stays false after only one animation frame (before paint completes)", () => {
41
+ const { result } = renderHook(() => useAfterPaint());
42
+
43
+ flushFrame();
44
+
45
+ expect(result.current).toBe(false);
46
+ });
47
+
48
+ it("returns true after two animation frames (a real post-paint boundary)", () => {
49
+ const { result } = renderHook(() => useAfterPaint());
50
+
51
+ flushFrame();
52
+ flushFrame();
53
+
54
+ expect(result.current).toBe(true);
55
+ });
56
+ });
@@ -1 +1,2 @@
1
1
  export { useInitialFocus } from "./useInitialFocus";
2
+ export { useAfterPaint } from "./useAfterPaint";
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+
3
+ export const useAfterPaint = (): boolean => {
4
+ const [painted, setPainted] = React.useState(false);
5
+
6
+ React.useEffect(() => {
7
+ let secondFrame: number | undefined;
8
+
9
+ const firstFrame = requestAnimationFrame(() => {
10
+ secondFrame = requestAnimationFrame(() => setPainted(true));
11
+ });
12
+
13
+ return () => {
14
+ cancelAnimationFrame(firstFrame);
15
+
16
+ if (secondFrame !== undefined) {
17
+ cancelAnimationFrame(secondFrame);
18
+ }
19
+ };
20
+ }, []);
21
+
22
+ return painted;
23
+ };
@@ -20,7 +20,7 @@ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/he
20
20
 
21
21
  import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
22
22
  import { ScreenResolver } from "../../ScreenResolver";
23
- import { useInitialFocus } from "./hooks";
23
+ import { useInitialFocus, useAfterPaint } from "./hooks";
24
24
  import { isPlayerPlugin } from "@applicaster/zapp-react-native-utils/pluginUtils";
25
25
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
26
26
  import { FreezeWithCallback } from "../../FreezeWithCallback";
@@ -155,6 +155,14 @@ export const Screen = ({ route, Components }: Props) => {
155
155
 
156
156
  const isScreenActive = useIsScreenActive();
157
157
 
158
+ const isContentReady = useAfterPaint();
159
+
160
+ React.useEffect(() => {
161
+ if (isContentReady) {
162
+ (globalThis as any).performance?.mark?.(`qb:navbar-painted:${route}`);
163
+ }
164
+ }, [isContentReady, route]);
165
+
158
166
  return (
159
167
  <FreezeWithCallback freeze={!isScreenActive} onRelease={onRelease}>
160
168
  <View style={[styles.container, { backgroundColor }]}>
@@ -165,12 +173,14 @@ export const Screen = ({ route, Components }: Props) => {
165
173
  navigationProps={navigationProps}
166
174
  />
167
175
  </NavBarContainer>
168
- <ScreenResolver
169
- screenType={screenType}
170
- screenId={screenId}
171
- screenData={screenData}
172
- groupId={route}
173
- />
176
+ {isContentReady ? (
177
+ <ScreenResolver
178
+ screenType={screenType}
179
+ screenId={screenId}
180
+ screenData={screenData}
181
+ groupId={route}
182
+ />
183
+ ) : null}
174
184
  </View>
175
185
  </FreezeWithCallback>
176
186
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "14.0.29",
3
+ "version": "14.0.30-alpha.6838902303",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "14.0.29",
32
- "@applicaster/zapp-react-native-bridge": "14.0.29",
33
- "@applicaster/zapp-react-native-redux": "14.0.29",
34
- "@applicaster/zapp-react-native-utils": "14.0.29",
31
+ "@applicaster/applicaster-types": "14.0.30-alpha.6838902303",
32
+ "@applicaster/zapp-react-native-bridge": "14.0.30-alpha.6838902303",
33
+ "@applicaster/zapp-react-native-redux": "14.0.30-alpha.6838902303",
34
+ "@applicaster/zapp-react-native-utils": "14.0.30-alpha.6838902303",
35
35
  "fast-json-stable-stringify": "^2.1.0",
36
36
  "promise": "^8.3.0",
37
37
  "url": "^0.11.0",