@applicaster/zapp-react-native-utils 17.0.0-alpha.3352797522 → 17.0.0-alpha.9147048829
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.
- package/actionsExecutor/actions/navigateToScreen.ts +11 -8
- package/appUtils/HooksManager/index.ts +10 -2
- package/appUtils/focusManager/__tests__/focusLogs.test.ts +137 -0
- package/appUtils/focusManager/focusLogsFlag.ts +48 -0
- package/appUtils/focusManager/index.ts +117 -10
- package/appUtils/platform/platformUtils.ts +4 -20
- package/appUtils/playerManager/player.ts +2 -0
- package/debugging/DebugFeatues.tsx +2 -25
- package/debugging/DebugFeatures.ts +495 -0
- package/debugging/__tests__/DebugFeatures.test.ts +313 -0
- package/debugging/index.ts +3 -0
- package/errorUtils/index.ts +2 -0
- package/focusManager/FocusManager.ts +8 -4
- package/focusManager/__tests__/FocusManager.test.ts +3 -3
- package/focusManager/focusToolbox.ts +208 -0
- package/focusManager/index.ts +7 -0
- package/navigationUtils/index.ts +25 -0
- package/package.json +2 -2
- package/reactHooks/cell-click/helpers.ts +3 -1
- package/reactHooks/navigation/usePresentScreen.ts +15 -9
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +22 -0
- package/reactHooks/resolvers/useCellResolver.ts +4 -1
- package/reactHooks/resolvers/useComponentResolver.ts +10 -0
- package/reactUtils/__tests__/deviceTargetGuards.test.js +73 -0
- package/reactUtils/index.ts +28 -0
- package/uiActionsRegistrator/resolveActionIdentifiers.ts +5 -1
|
@@ -6,6 +6,7 @@ import { useContentTypes } from "@applicaster/zapp-react-native-redux/hooks";
|
|
|
6
6
|
import { modalStore } from "../../modalState";
|
|
7
7
|
import { isWeb } from "../../reactUtils";
|
|
8
8
|
import { createLogger } from "../../logger";
|
|
9
|
+
import { getTypeMappingCase } from "../../navigationUtils";
|
|
9
10
|
import { useRivers } from "../state";
|
|
10
11
|
|
|
11
12
|
const { log_error, log_info } = createLogger({
|
|
@@ -44,8 +45,11 @@ interface Dependencies {
|
|
|
44
45
|
contentTypes: ZappContentTypes;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
const failure = (
|
|
48
|
-
|
|
48
|
+
const failure = (
|
|
49
|
+
error: string,
|
|
50
|
+
data?: Record<string, unknown>
|
|
51
|
+
): Promise<PresentScreenResult> => {
|
|
52
|
+
log_error(`presentScreen: ${error}`, data);
|
|
49
53
|
|
|
50
54
|
return Promise.resolve({ success: false, cancelled: false, error });
|
|
51
55
|
};
|
|
@@ -75,15 +79,17 @@ export const presentScreen = ({
|
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
const screenId = contentTypes?.[typeMapping]?.screen_id;
|
|
78
|
-
|
|
79
|
-
if (!screenId) {
|
|
80
|
-
return failure(`can not resolve screen type mapping: ${typeMapping}`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const river = rivers?.[screenId];
|
|
82
|
+
const river = screenId ? rivers?.[screenId] : undefined;
|
|
84
83
|
|
|
85
84
|
if (!river) {
|
|
86
|
-
return failure(`can not resolve
|
|
85
|
+
return failure(`can not resolve screen type mapping: ${typeMapping}`, {
|
|
86
|
+
// For X-Ray diagnostics: keep when the message is reworded.
|
|
87
|
+
diagnostic: {
|
|
88
|
+
code: "action-type-mapping",
|
|
89
|
+
case: getTypeMappingCase(typeMapping, rivers, contentTypes),
|
|
90
|
+
},
|
|
91
|
+
type_mapping: typeMapping,
|
|
92
|
+
});
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
return new Promise<PresentScreenResult>((resolve) => {
|
|
@@ -66,4 +66,26 @@ describe("cellResolver", () => {
|
|
|
66
66
|
|
|
67
67
|
expect(testCellModule).toBeCalled();
|
|
68
68
|
});
|
|
69
|
+
|
|
70
|
+
it("does not share a renderer between components with the same styles", () => {
|
|
71
|
+
testCellModule.mockClear();
|
|
72
|
+
|
|
73
|
+
renderHook(
|
|
74
|
+
() => useCellResolver({ component: { ...component, id: "a" } }),
|
|
75
|
+
{
|
|
76
|
+
wrapper,
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
renderHook(
|
|
81
|
+
() => useCellResolver({ component: { ...component, id: "b" } }),
|
|
82
|
+
{
|
|
83
|
+
wrapper,
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(testCellModule).toHaveBeenCalledTimes(2);
|
|
88
|
+
|
|
89
|
+
expect(testCellModule.mock.calls[1][0].component.id).toBe("b");
|
|
90
|
+
});
|
|
69
91
|
});
|
|
@@ -36,7 +36,7 @@ type Props = {
|
|
|
36
36
|
const cellWidthLens = R.lensPath(["styles", "cell_width"]);
|
|
37
37
|
const viewAtCellWidth = R.view(cellWidthLens);
|
|
38
38
|
const setCellWidth = R.set(cellWidthLens);
|
|
39
|
-
const MEMOIZED_LENGTH =
|
|
39
|
+
const MEMOIZED_LENGTH = 10;
|
|
40
40
|
|
|
41
41
|
const cellRenderer = (...args) => CellRendererResolver(args[MEMOIZED_LENGTH]); // pick 6th argument with data
|
|
42
42
|
|
|
@@ -79,6 +79,9 @@ export function useCellResolver({
|
|
|
79
79
|
|
|
80
80
|
return memoCellRenderer(
|
|
81
81
|
/* memoizee check prop list */
|
|
82
|
+
// The renderer is built from the component (its type, styles and X-Ray diagnostics), so two
|
|
83
|
+
// components without a cell style must not share one.
|
|
84
|
+
_component?.id,
|
|
82
85
|
cell_plugin_configuration_id,
|
|
83
86
|
width,
|
|
84
87
|
height,
|
|
@@ -39,6 +39,16 @@ export function useComponentResolver(
|
|
|
39
39
|
if (!component) {
|
|
40
40
|
coreLogger.warn({
|
|
41
41
|
message: `useComponentResolver: Component of type ${componentType} not found`,
|
|
42
|
+
data: {
|
|
43
|
+
// For X-Ray diagnostics: keep when the message is reworded. Not for a plugin that is in
|
|
44
|
+
// the build and only has no component to give.
|
|
45
|
+
...(!plugins?.some(
|
|
46
|
+
(plugin) => plugin?.identifier === componentType
|
|
47
|
+
) && {
|
|
48
|
+
diagnostic: { code: "component-plugin-missing" },
|
|
49
|
+
}),
|
|
50
|
+
component: { component_type: componentType },
|
|
51
|
+
},
|
|
42
52
|
});
|
|
43
53
|
}
|
|
44
54
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isLgPlatform,
|
|
3
|
+
isSamsungPlatform,
|
|
4
|
+
isVizioPlatform,
|
|
5
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
6
|
+
|
|
7
|
+
const UA = {
|
|
8
|
+
lg: "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 Chrome/87.0",
|
|
9
|
+
samsung: "Mozilla/5.0 (SMART-TV; Linux; Tizen 6.0) AppleWebKit/537.36",
|
|
10
|
+
vizio: "Mozilla/5.0 (X11; Linux) Chrome/76.0 VIZIO SmartCast Conjure/MTK",
|
|
11
|
+
desktop: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Chrome/120.0",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const originalNavigator = window.navigator;
|
|
15
|
+
|
|
16
|
+
const setUserAgent = (userAgent) => {
|
|
17
|
+
Object.defineProperty(window, "navigator", {
|
|
18
|
+
value: { userAgent },
|
|
19
|
+
configurable: true,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe("web TV device checks and the build-time device target", () => {
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
delete process.env.QUICK_BRICK_DEVICE_TARGET;
|
|
26
|
+
|
|
27
|
+
Object.defineProperty(window, "navigator", {
|
|
28
|
+
value: originalNavigator,
|
|
29
|
+
configurable: true,
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("detects every TV at runtime when no device target is set", () => {
|
|
34
|
+
setUserAgent(UA.lg);
|
|
35
|
+
expect(isLgPlatform()).toBe(true);
|
|
36
|
+
|
|
37
|
+
setUserAgent(UA.samsung);
|
|
38
|
+
expect(isSamsungPlatform()).toBe(true);
|
|
39
|
+
|
|
40
|
+
setUserAgent(UA.vizio);
|
|
41
|
+
expect(isVizioPlatform()).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("rejects other TVs on a Samsung build, whatever the user agent", () => {
|
|
45
|
+
process.env.QUICK_BRICK_DEVICE_TARGET = "samsung_tv";
|
|
46
|
+
|
|
47
|
+
setUserAgent(UA.lg);
|
|
48
|
+
expect(isLgPlatform()).toBe(false);
|
|
49
|
+
|
|
50
|
+
setUserAgent(UA.vizio);
|
|
51
|
+
expect(isVizioPlatform()).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("still checks its own TV at runtime, so a desktop browser is not the TV", () => {
|
|
55
|
+
process.env.QUICK_BRICK_DEVICE_TARGET = "samsung_tv";
|
|
56
|
+
|
|
57
|
+
setUserAgent(UA.samsung);
|
|
58
|
+
expect(isSamsungPlatform()).toBe(true);
|
|
59
|
+
|
|
60
|
+
setUserAgent(UA.desktop);
|
|
61
|
+
expect(isSamsungPlatform()).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("keeps a Vizio build's identity separate from LG", () => {
|
|
65
|
+
process.env.QUICK_BRICK_DEVICE_TARGET = "vizio";
|
|
66
|
+
|
|
67
|
+
setUserAgent(UA.lg);
|
|
68
|
+
expect(isLgPlatform()).toBe(false);
|
|
69
|
+
|
|
70
|
+
setUserAgent(UA.vizio);
|
|
71
|
+
expect(isVizioPlatform()).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
});
|
package/reactUtils/index.ts
CHANGED
|
@@ -129,7 +129,21 @@ export const hasWebOS = typeof window?.webOS !== "undefined";
|
|
|
129
129
|
|
|
130
130
|
export const getUserAgent = () => window?.navigator?.userAgent;
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Web TV device checks return false outright when the bundle was built for another
|
|
134
|
+
* TV: the web template inlines `process.env.QUICK_BRICK_DEVICE_TARGET` (Zapp
|
|
135
|
+
* `device_target`), so the guard and the code after it fold away at build time.
|
|
136
|
+
* A build for this TV still checks at runtime, because the same bundle also runs
|
|
137
|
+
* in a desktop browser.
|
|
138
|
+
*/
|
|
132
139
|
export const isLgPlatform = () => {
|
|
140
|
+
if (
|
|
141
|
+
process.env.QUICK_BRICK_DEVICE_TARGET &&
|
|
142
|
+
process.env.QUICK_BRICK_DEVICE_TARGET !== "lg_tv"
|
|
143
|
+
) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
133
147
|
const userAgent = getUserAgent();
|
|
134
148
|
|
|
135
149
|
if (!userAgent) {
|
|
@@ -141,6 +155,13 @@ export const isLgPlatform = () => {
|
|
|
141
155
|
};
|
|
142
156
|
|
|
143
157
|
export const isSamsungPlatform = () => {
|
|
158
|
+
if (
|
|
159
|
+
process.env.QUICK_BRICK_DEVICE_TARGET &&
|
|
160
|
+
process.env.QUICK_BRICK_DEVICE_TARGET !== "samsung_tv"
|
|
161
|
+
) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
144
165
|
const userAgent = getUserAgent();
|
|
145
166
|
|
|
146
167
|
if (!userAgent) {
|
|
@@ -161,6 +182,13 @@ export const isSamsungPlatform = () => {
|
|
|
161
182
|
* before the VIZIO Companion Library has loaded
|
|
162
183
|
*/
|
|
163
184
|
export const isVizioPlatform = () => {
|
|
185
|
+
if (
|
|
186
|
+
process.env.QUICK_BRICK_DEVICE_TARGET &&
|
|
187
|
+
process.env.QUICK_BRICK_DEVICE_TARGET !== "vizio"
|
|
188
|
+
) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
|
|
164
192
|
const userAgent = getUserAgent();
|
|
165
193
|
|
|
166
194
|
if (!userAgent) {
|
|
@@ -91,7 +91,11 @@ export function resolveActionIdentifiers({
|
|
|
91
91
|
|
|
92
92
|
log_warning(
|
|
93
93
|
`resolveActionIdentifiers: configured action "${identifier}" has no registered provider - its button will not be shown`,
|
|
94
|
-
{
|
|
94
|
+
{
|
|
95
|
+
diagnostic: { code: "action-plugin-missing" },
|
|
96
|
+
identifier,
|
|
97
|
+
entryId: (entry as ZappEntry)?.id,
|
|
98
|
+
}
|
|
95
99
|
);
|
|
96
100
|
}
|
|
97
101
|
|