@applicaster/zapp-react-native-utils 16.0.0-rc.99 → 17.0.0-alpha.1102403272
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/actionUtils/index.ts +3 -1
- package/actionsExecutor/ActionExecutor.ts +2 -2
- package/actionsExecutor/ActionExecutorContext.tsx +2 -2
- package/actionsExecutor/__tests__/StorageActions.test.ts +98 -0
- package/actionsExecutor/__tests__/feedDecorator.test.ts +30 -0
- package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
- package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +186 -5
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +24 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +72 -0
- package/actionsExecutor/actions/appRestart.ts +2 -2
- package/actionsExecutor/actions/confirmDialog.ts +2 -2
- package/actionsExecutor/actions/dismissBottomSheet.ts +2 -2
- package/actionsExecutor/actions/goBack.ts +2 -2
- package/actionsExecutor/actions/goHome.ts +2 -2
- package/actionsExecutor/actions/navigateToScreen.ts +46 -45
- package/actionsExecutor/actions/openBottomSheet.ts +4 -2
- package/actionsExecutor/actions/presentScreen.ts +2 -2
- package/actionsExecutor/actions/refreshComponent.ts +2 -2
- package/actionsExecutor/actions/screenToggleFlag.ts +1 -3
- package/actionsExecutor/actions/sendCloudEvent.ts +2 -2
- package/actionsExecutor/actions/showAlert.ts +2 -2
- package/actionsExecutor/actions/switchLayout.ts +2 -2
- package/actionsExecutor/feedDecorator.ts +8 -2
- package/actionsExecutor/types.ts +7 -0
- package/analyticsUtils/__tests__/playerAnalyticsSafeguard.test.ts +62 -0
- package/analyticsUtils/logger.ts +9 -4
- package/analyticsUtils/playerAnalyticsTracker.ts +1 -0
- package/appUtils/HooksManager/index.ts +10 -2
- package/appUtils/HooksManager/logger.ts +5 -2
- package/appUtils/accessibilityManager/logger.ts +2 -4
- package/appUtils/accessibilityManager/utils.ts +1 -1
- package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -22
- package/appUtils/contextKeysManager/__tests__/getKey/success/fullSearch.test.ts +1 -25
- package/appUtils/contextKeysManager/__tests__/getKey/success/searchInSecure.test.ts +1 -7
- package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +0 -25
- package/appUtils/contextKeysManager/__tests__/removeKey/success.test.ts +0 -6
- package/appUtils/contextKeysManager/__tests__/setKey/failure/failedToSaveInStorage.test.ts +0 -40
- package/appUtils/contextKeysManager/__tests__/setKey/{success/saveItemAndReference.test.ts → success.test.ts} +2 -42
- package/appUtils/contextKeysManager/index.ts +30 -131
- package/appUtils/focusManager/__tests__/focusManager.test.js +33 -0
- package/appUtils/focusManager/__tests__/focusToolbox.test.ts +357 -0
- package/appUtils/focusManager/focusToolbox.ts +223 -0
- package/appUtils/focusManager/index.ios.ts +7 -1
- package/appUtils/focusManager/index.ts +3 -3
- package/appUtils/focusManager/logger.ts +2 -2
- package/appUtils/focusManagerAux/index.ts +2 -2
- package/appUtils/orientationHelper.ts +2 -2
- package/appUtils/platform/platformUtils.ts +6 -22
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +1 -1
- package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerNative.test.ts +76 -0
- package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerToolbox.test.ts +281 -0
- package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
- package/appUtils/playerManager/const.ts +13 -0
- package/appUtils/playerManager/index.ts +9 -2
- package/appUtils/playerManager/player.ts +28 -1
- package/appUtils/playerManager/playerNative.ts +23 -1
- package/appUtils/playerManager/playerNativeCommand.ts +3 -6
- package/appUtils/playerManager/playerToolbox.ts +196 -0
- package/appUtils/playerManager/usePlayNextOverlay.tsx +2 -2
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -0
- package/appUtils/playerManager/userCellPlayerMutedPreference.ts +1 -1
- package/appUtils/playerManager/userLanguagePreference.ts +1 -1
- package/arrayUtils/__tests__/reorderByIds.test.ts +13 -0
- package/arrayUtils/index.ts +26 -43
- package/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
- package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
- package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
- package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
- package/cellUtils/index.ts +40 -0
- package/cellUtils/logger.ts +2 -2
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +134 -0
- package/configurationUtils/modalBlocksParser.ts +38 -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/domUtils/logger.ts +2 -2
- package/entryActions/aliasPresentation.ts +1 -0
- package/entryActions/buildEntryActions.ts +1 -1
- package/errorUtils/index.ts +2 -0
- package/focusManager/FocusManager.ts +43 -6
- package/focusManager/__tests__/FocusManager.test.ts +124 -3
- package/focusManager/focusToolbox.ts +208 -0
- package/focusManager/index.ts +7 -0
- package/focusManager/logger.ts +2 -6
- package/headersUtils/index.ts +2 -2
- package/localizationUtils/index.ts +12 -6
- package/logger/__tests__/subsystems.test.ts +148 -0
- package/logger/__tests__/xrayToolbox.test.ts +69 -0
- package/logger/index.ts +48 -9
- package/logger/subsystems.ts +112 -0
- package/logger/xrayToolbox.ts +69 -0
- package/manifestUtils/__tests__/createConfig.test.js +17 -7
- package/manifestUtils/_internals/getDefaultConfiguration.js +9 -11
- package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
- package/manifestUtils/keys.js +7 -2
- package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
- package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
- package/manifestUtils/mobileAction/groups/defaults.js +2 -1
- package/modalState/EditableCollectionRegistry.ts +1 -1
- package/modalState/ModalOrchestrator.ts +1 -0
- package/modalState/RemoteEditableCollection.ts +1 -1
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +23 -0
- package/modalState/index.ts +2 -0
- package/modalState/types.ts +11 -0
- package/navigationUtils/index.ts +5 -2
- package/navigationUtils/xrayNavigator.ts +12 -0
- package/numberUtils/index.ts +2 -2
- package/package.json +3 -2
- package/playerUtils/PlayerTTS/PlayerTTS.ts +1 -1
- package/playerUtils/imaScriptDom.ts +1 -1
- package/playerUtils/useValidatePlayerConfig.tsx +1 -1
- package/pluginUtils/logger.ts +2 -2
- package/quickBrickAssets/__tests__/index.test.ts +18 -0
- package/quickBrickAssets/index.ts +35 -0
- package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
- package/reactHooks/actions/index.ts +29 -23
- package/reactHooks/cell-click/__tests__/index.test.js +67 -1
- package/reactHooks/cell-click/helpers.ts +3 -1
- package/reactHooks/cell-click/index.ts +10 -2
- package/reactHooks/connection/index.tsx +8 -5
- package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
- package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
- package/reactHooks/feed/useBuildPipesUrl.ts +5 -2
- package/reactHooks/feed/useFeedLoader.tsx +30 -3
- package/reactHooks/feed/useLoadPipesDataDispatch.ts +12 -11
- package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +5 -2
- package/reactHooks/logger.ts +5 -2
- package/reactHooks/navigation/usePresentScreen.ts +19 -6
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +2 -2
- package/reactHooks/resolvers/useComponentResolver.ts +10 -0
- package/reactHooks/screen/useScreenData.ts +2 -2
- package/reactHooks/usePluginConfiguration.ts +84 -46
- package/reactHooks/videoModal/hooks/useChangeOrientation.ts +2 -7
- package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +1 -1
- package/reactUtils/__tests__/deviceTargetGuards.test.js +73 -0
- package/reactUtils/createContext/helpers.ts +2 -2
- package/reactUtils/index.ts +28 -0
- package/reactUtils/logger.ts +2 -2
- package/riverComponetsMeasurementProvider/index.tsx +5 -5
- package/storage/ScreenSingleValueProvider.ts +1 -1
- package/storage/ScreenStateMultiSelectProvider.ts +1 -1
- package/storage/StorageMultiSelectProvider.ts +1 -1
- package/storage/StorageSingleSelectProvider.ts +1 -1
- package/stylesUtils/logger.ts +2 -2
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +26 -0
- package/uiActionsRegistrator/registry.ts +17 -1
- package/uiActionsRegistrator/resolveActionIdentifiers.ts +6 -2
- package/uiActionsRegistrator/usableActionItems.ts +1 -1
- package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +2 -1
- package/zappFrameworkUtils/loginPluginUtils.ts +2 -1
- package/zappFrameworkUtils/presentPluginOneTime.ts +2 -1
- package/appUtils/contextKeysManager/__tests__/getKey/success/byReference.test.ts +0 -56
- package/appUtils/contextKeysManager/__tests__/getKeyByReference/failure.test.ts +0 -265
- package/appUtils/contextKeysManager/__tests__/getKeyByReference/success.test.ts +0 -303
- package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/failure.test.ts +0 -82
- package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/success.test.ts +0 -41
- package/appUtils/contextKeysManager/__tests__/setKey/success/saveItemButNotReference.test.ts +0 -208
- package/appUtils/contextKeysManager/__tests__/setReferenceForKey/failure.test.ts +0 -93
- package/appUtils/contextKeysManager/__tests__/setReferenceForKey/success.test.ts +0 -45
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
1
|
import { useMemo } from "react";
|
|
3
2
|
|
|
4
3
|
import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
|
|
@@ -6,7 +5,8 @@ import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
|
|
|
6
5
|
// importing this way prevents typescript packages importing from this
|
|
7
6
|
// file to go crazy reporting errors on JS
|
|
8
7
|
import { populateConfigurationValues } from "@applicaster/zapp-react-native-utils/configurationUtils";
|
|
9
|
-
import { useLocalizedStrings } from "../localizationUtils";
|
|
8
|
+
import { getLocalizedStrings, useLocalizedStrings } from "../localizationUtils";
|
|
9
|
+
import { isNil, pathOr } from "../utils";
|
|
10
10
|
|
|
11
11
|
const populateFields = (
|
|
12
12
|
data,
|
|
@@ -14,16 +14,72 @@ const populateFields = (
|
|
|
14
14
|
pathToValues: string | string[] = "configuration",
|
|
15
15
|
skipDefaults = false
|
|
16
16
|
) =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
)
|
|
17
|
+
populateConfigurationValues(
|
|
18
|
+
manifestFields,
|
|
19
|
+
pathOr({}, pathToValues, data),
|
|
20
|
+
skipDefaults
|
|
21
|
+
);
|
|
22
22
|
|
|
23
23
|
export function parsePluginConfiguration(plugin, manifest) {
|
|
24
24
|
return populateFields(plugin, manifest.custom_configuration_fields);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const getDefaultLocalizations = (manifest) =>
|
|
28
|
+
manifest?.localizations?.fields?.reduce(
|
|
29
|
+
(defaults, { key, initial_value }) => ({
|
|
30
|
+
en: { ...defaults.en, [key]: initial_value },
|
|
31
|
+
}),
|
|
32
|
+
{ en: {} }
|
|
33
|
+
) || {};
|
|
34
|
+
|
|
35
|
+
const isPlainObject = (value) =>
|
|
36
|
+
Object.prototype.toString.call(value) === "[object Object]";
|
|
37
|
+
|
|
38
|
+
// Deep merge where configured values win, except nil ones (defaults fill the gaps)
|
|
39
|
+
export const mergeLocalizations = (configured, defaults) => {
|
|
40
|
+
if (!isPlainObject(configured)) return { ...defaults };
|
|
41
|
+
if (!isPlainObject(defaults)) return { ...configured };
|
|
42
|
+
|
|
43
|
+
// Configured keys first, as R.mergeDeepWith: the first language is the fallback
|
|
44
|
+
return Object.keys({ ...configured, ...defaults }).reduce((merged, key) => {
|
|
45
|
+
const left = configured[key];
|
|
46
|
+
const right = defaults[key];
|
|
47
|
+
|
|
48
|
+
if (!(key in defaults)) {
|
|
49
|
+
merged[key] = left;
|
|
50
|
+
} else if (!(key in configured)) {
|
|
51
|
+
merged[key] = right;
|
|
52
|
+
} else if (isPlainObject(left) && isPlainObject(right)) {
|
|
53
|
+
merged[key] = mergeLocalizations(left, right);
|
|
54
|
+
} else {
|
|
55
|
+
merged[key] = isNil(left) ? right : left;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return merged;
|
|
59
|
+
}, {});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* usePluginConfiguration outside React: the same result, read once instead of subscribed.
|
|
64
|
+
*/
|
|
65
|
+
export function getPluginConfiguration<T = any, S = Record<string, any>>(
|
|
66
|
+
plugin,
|
|
67
|
+
manifest?: any
|
|
68
|
+
): { configurationFields: T; localizations: S } {
|
|
69
|
+
return {
|
|
70
|
+
configurationFields: populateFields(
|
|
71
|
+
plugin,
|
|
72
|
+
manifest?.custom_configuration_fields
|
|
73
|
+
),
|
|
74
|
+
localizations: getLocalizedStrings(
|
|
75
|
+
mergeLocalizations(
|
|
76
|
+
plugin?.configuration?.localizations,
|
|
77
|
+
getDefaultLocalizations(manifest)
|
|
78
|
+
)
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
27
83
|
export function usePluginConfiguration<T = any, S = Record<string, any>>(
|
|
28
84
|
identifier: string,
|
|
29
85
|
manifest?: any
|
|
@@ -31,7 +87,7 @@ export function usePluginConfiguration<T = any, S = Record<string, any>>(
|
|
|
31
87
|
const plugins = usePlugins();
|
|
32
88
|
|
|
33
89
|
const plugin = useMemo(
|
|
34
|
-
() =>
|
|
90
|
+
() => plugins?.find((item) => item?.identifier === identifier),
|
|
35
91
|
[plugins, identifier]
|
|
36
92
|
);
|
|
37
93
|
|
|
@@ -40,29 +96,20 @@ export function usePluginConfiguration<T = any, S = Record<string, any>>(
|
|
|
40
96
|
[plugin, manifest]
|
|
41
97
|
);
|
|
42
98
|
|
|
43
|
-
const defaultLocalizations = useMemo(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
R.assocPath(["en", key], initial_value, defaults),
|
|
48
|
-
{ en: {} }
|
|
49
|
-
) || {}
|
|
50
|
-
);
|
|
51
|
-
}, [manifest]);
|
|
52
|
-
|
|
53
|
-
const localizationsParams = useMemo(() => {
|
|
54
|
-
return {
|
|
55
|
-
localizations: R.mergeDeepWith(
|
|
56
|
-
(left, right) => {
|
|
57
|
-
if (R.isNil(left)) return right;
|
|
99
|
+
const defaultLocalizations = useMemo(
|
|
100
|
+
() => getDefaultLocalizations(manifest),
|
|
101
|
+
[manifest]
|
|
102
|
+
);
|
|
58
103
|
|
|
59
|
-
|
|
60
|
-
|
|
104
|
+
const localizationsParams = useMemo(
|
|
105
|
+
() => ({
|
|
106
|
+
localizations: mergeLocalizations(
|
|
61
107
|
plugin?.configuration?.localizations,
|
|
62
108
|
defaultLocalizations
|
|
63
109
|
),
|
|
64
|
-
}
|
|
65
|
-
|
|
110
|
+
}),
|
|
111
|
+
[plugin?.configuration?.localizations, defaultLocalizations]
|
|
112
|
+
);
|
|
66
113
|
|
|
67
114
|
const localizations: S = useLocalizedStrings(localizationsParams);
|
|
68
115
|
|
|
@@ -105,29 +152,20 @@ export function useLayoutConfiguration<
|
|
|
105
152
|
"localizations",
|
|
106
153
|
];
|
|
107
154
|
|
|
108
|
-
const defaultLocalizations = useMemo(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
R.assocPath(["en", key], initial_value, defaults),
|
|
113
|
-
{ en: {} }
|
|
114
|
-
) || {}
|
|
115
|
-
);
|
|
116
|
-
}, [manifest]);
|
|
117
|
-
|
|
118
|
-
const localizationsParams = useMemo(() => {
|
|
119
|
-
return {
|
|
120
|
-
localizations: R.mergeDeepWith(
|
|
121
|
-
(left, right) => {
|
|
122
|
-
if (R.isNil(left)) return right;
|
|
155
|
+
const defaultLocalizations = useMemo(
|
|
156
|
+
() => getDefaultLocalizations(manifest),
|
|
157
|
+
[manifest]
|
|
158
|
+
);
|
|
123
159
|
|
|
124
|
-
|
|
125
|
-
|
|
160
|
+
const localizationsParams = useMemo(
|
|
161
|
+
() => ({
|
|
162
|
+
localizations: mergeLocalizations(
|
|
126
163
|
layoutData?.localizations,
|
|
127
164
|
defaultLocalizations
|
|
128
165
|
),
|
|
129
|
-
}
|
|
130
|
-
|
|
166
|
+
}),
|
|
167
|
+
[layoutData?.localizations, defaultLocalizations]
|
|
168
|
+
);
|
|
131
169
|
|
|
132
170
|
// Always call useLocalizedStrings regardless of whether localizations is in the keys
|
|
133
171
|
const localizations: L = useLocalizedStrings(localizationsParams);
|
|
@@ -9,9 +9,7 @@ import {
|
|
|
9
9
|
|
|
10
10
|
import { skipIf, shouldHandleOrientationChange } from "../utils";
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
const { Logger } = getXray();
|
|
14
|
-
|
|
12
|
+
import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
15
13
|
type Props = {
|
|
16
14
|
isPortrait: boolean;
|
|
17
15
|
onTransitToPortrait: () => void;
|
|
@@ -20,10 +18,7 @@ type Props = {
|
|
|
20
18
|
docked: boolean;
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
export const logger =
|
|
24
|
-
"hooks",
|
|
25
|
-
"zapp-react-native-utils/reactHooks/videoModal"
|
|
26
|
-
);
|
|
21
|
+
export const logger = subsystemLogger("player/modal", "hooks");
|
|
27
22
|
|
|
28
23
|
export const useChangeOrientation = ({
|
|
29
24
|
isPortrait,
|
|
@@ -5,7 +5,7 @@ import { useRivers } from "../../state";
|
|
|
5
5
|
import { createLogger } from "../../../logger";
|
|
6
6
|
|
|
7
7
|
const { log_warning } = createLogger({
|
|
8
|
-
subsystem: "
|
|
8
|
+
subsystem: "player/modal",
|
|
9
9
|
category: "useVideoModalScreenData",
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -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
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import { capitalize } from "../../stringUtils";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { subsystemLogger } from "../../logger";
|
|
5
5
|
|
|
6
|
-
const logger =
|
|
6
|
+
const logger = subsystemLogger("core/react/create_context", "CreateContext");
|
|
7
7
|
|
|
8
8
|
const SETTER_PREFIX = "set";
|
|
9
9
|
|
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) {
|
package/reactUtils/logger.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { subsystemLogger } from "../logger";
|
|
2
2
|
|
|
3
|
-
export const reactUtilsLogger =
|
|
3
|
+
export const reactUtilsLogger = subsystemLogger("core/react", "ReactUtils");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { NativeModules, View, StyleSheet } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
4
4
|
|
|
5
5
|
import { isApplePlatform, isWeb, isTV } from "../reactUtils";
|
|
6
6
|
import { useRivers } from "../reactHooks";
|
|
@@ -34,15 +34,14 @@ type Props = {
|
|
|
34
34
|
type ItemProps = {
|
|
35
35
|
children: React.ReactNode;
|
|
36
36
|
index: number;
|
|
37
|
+
testID?: string;
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
type MeasurementContext = {
|
|
40
41
|
onLayout: (index: number) => (event) => void;
|
|
41
42
|
};
|
|
42
43
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const logger = new Logger("general", "ui");
|
|
44
|
+
const logger = subsystemLogger("ui/river", "general");
|
|
46
45
|
|
|
47
46
|
let notified = false;
|
|
48
47
|
|
|
@@ -153,11 +152,12 @@ export const ScreenLoadingMeasurements = ({
|
|
|
153
152
|
export const ScreenLoadingMeasurementsListItemWrapper = ({
|
|
154
153
|
children,
|
|
155
154
|
index,
|
|
155
|
+
testID,
|
|
156
156
|
}: ItemProps) => {
|
|
157
157
|
const { onLayout } = React.useContext(MeasurementsSettersContext);
|
|
158
158
|
|
|
159
159
|
return (
|
|
160
|
-
<View style={styles.container} onLayout={onLayout?.(index)}>
|
|
160
|
+
<View style={styles.container} onLayout={onLayout?.(index)} testID={testID}>
|
|
161
161
|
{children}
|
|
162
162
|
</View>
|
|
163
163
|
);
|
|
@@ -6,7 +6,7 @@ import { useScreenStateStore } from "../reactHooks/navigation/useScreenStateStor
|
|
|
6
6
|
|
|
7
7
|
export const { log_debug, log_error } = createLogger({
|
|
8
8
|
category: "ScreenSingleValueProvider",
|
|
9
|
-
subsystem: "
|
|
9
|
+
subsystem: "storage/native",
|
|
10
10
|
parent: bridgeLogger,
|
|
11
11
|
});
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@ import { useScreenStateStore } from "../reactHooks/navigation/useScreenStateStor
|
|
|
6
6
|
|
|
7
7
|
export const { log_debug, log_error } = createLogger({
|
|
8
8
|
category: "ScreenMultiSelectProvider",
|
|
9
|
-
subsystem: "
|
|
9
|
+
subsystem: "storage/native",
|
|
10
10
|
parent: bridgeLogger,
|
|
11
11
|
});
|
|
12
12
|
|
|
@@ -10,7 +10,7 @@ import { createLogger } from "../logger";
|
|
|
10
10
|
export const { log_verbose, log_debug, log_warning, log_info, log_error } =
|
|
11
11
|
createLogger({
|
|
12
12
|
category: "StorageMultiSelectProvider",
|
|
13
|
-
subsystem: "
|
|
13
|
+
subsystem: "storage/native",
|
|
14
14
|
parent: bridgeLogger,
|
|
15
15
|
});
|
|
16
16
|
|
|
@@ -7,7 +7,7 @@ import { createLogger } from "../logger";
|
|
|
7
7
|
export const { log_verbose, log_debug, log_warning, log_info, log_error } =
|
|
8
8
|
createLogger({
|
|
9
9
|
category: "StorageSingleValueProvider",
|
|
10
|
-
subsystem: "
|
|
10
|
+
subsystem: "storage/native",
|
|
11
11
|
parent: bridgeLogger,
|
|
12
12
|
});
|
|
13
13
|
|
package/stylesUtils/logger.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { subsystemLogger } from "../logger";
|
|
2
2
|
|
|
3
|
-
export const stylesUtilsLogger =
|
|
3
|
+
export const stylesUtilsLogger = subsystemLogger("ui/styles", "StylesUtils");
|
|
@@ -105,3 +105,29 @@ describe("isActionAvailableFor", () => {
|
|
|
105
105
|
expect(isActionAvailableFor(undefined, entry)).toBe(true);
|
|
106
106
|
});
|
|
107
107
|
});
|
|
108
|
+
|
|
109
|
+
describe("uiActionsRegistry.notifyProviderChanged", () => {
|
|
110
|
+
it("notifies subscribers for a registered provider", () => {
|
|
111
|
+
const unregister = uiActionsRegistry.registerAction("live-action", value);
|
|
112
|
+
const listener = jest.fn();
|
|
113
|
+
const unsubscribe = uiActionsRegistry.subscribe(listener);
|
|
114
|
+
|
|
115
|
+
uiActionsRegistry.notifyProviderChanged("live-action");
|
|
116
|
+
|
|
117
|
+
expect(listener).toHaveBeenCalledTimes(1);
|
|
118
|
+
|
|
119
|
+
unsubscribe();
|
|
120
|
+
unregister();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("ignores names that are not registered", () => {
|
|
124
|
+
const listener = jest.fn();
|
|
125
|
+
const unsubscribe = uiActionsRegistry.subscribe(listener);
|
|
126
|
+
|
|
127
|
+
uiActionsRegistry.notifyProviderChanged("unknown-action");
|
|
128
|
+
|
|
129
|
+
expect(listener).not.toHaveBeenCalled();
|
|
130
|
+
|
|
131
|
+
unsubscribe();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -4,7 +4,7 @@ import { Observable } from "rxjs";
|
|
|
4
4
|
import { createLogger } from "../logger";
|
|
5
5
|
|
|
6
6
|
const { log_debug, log_warning } = createLogger({
|
|
7
|
-
subsystem: "
|
|
7
|
+
subsystem: "core/actions/ui_registry",
|
|
8
8
|
category: "ActionRegistration",
|
|
9
9
|
});
|
|
10
10
|
|
|
@@ -246,6 +246,22 @@ class UIActionsRegistry {
|
|
|
246
246
|
this.changeListeners.slice().forEach((listener) => listener());
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Tells consumers that a registered provider now returns different actions.
|
|
251
|
+
*
|
|
252
|
+
* Resolved actions are snapshots: an action whose availability depends on
|
|
253
|
+
* live state (cast devices found, downloads allowed) hands out a new value
|
|
254
|
+
* when that state changes, and consumers that resolved the old one keep
|
|
255
|
+
* asking it until they re-resolve. Registration alone never tells them.
|
|
256
|
+
*/
|
|
257
|
+
notifyProviderChanged(name: string): void {
|
|
258
|
+
if (!this.registeredActions[name]) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
this.notifyChanged();
|
|
263
|
+
}
|
|
264
|
+
|
|
249
265
|
/**
|
|
250
266
|
* Register a dynamic action provider under a unique `name`.
|
|
251
267
|
* The provider can return one or more actions and may use the passed `entry`.
|
|
@@ -3,7 +3,7 @@ import { createLogger } from "../logger";
|
|
|
3
3
|
import { RegisteredAction, uiActionsRegistry } from "./registry";
|
|
4
4
|
|
|
5
5
|
const { log_warning } = createLogger({
|
|
6
|
-
subsystem: "
|
|
6
|
+
subsystem: "core/actions/ui_registry",
|
|
7
7
|
category: "ActionRegistration",
|
|
8
8
|
});
|
|
9
9
|
|
|
@@ -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
|
|
|
@@ -38,7 +38,8 @@ type General = Record<string, unknown>;
|
|
|
38
38
|
const LogPrefix = "useCallbackNavigationAction:";
|
|
39
39
|
|
|
40
40
|
const { log_info, log_verbose, log_debug } = createLogger({
|
|
41
|
-
|
|
41
|
+
category: "HookNavigationCallback",
|
|
42
|
+
subsystem: "core/plugins/hooks",
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
const legacyMappingKeys = {
|
|
@@ -152,7 +152,8 @@ const runInBackground = async ({
|
|
|
152
152
|
|
|
153
153
|
export const loginPluginUtils = ({ pluginId }: LoginPluginUtils) => {
|
|
154
154
|
const logs: Logs = createLogger({
|
|
155
|
-
|
|
155
|
+
category: "LoginPluginUtils",
|
|
156
|
+
subsystem: "core/plugins/login",
|
|
156
157
|
});
|
|
157
158
|
|
|
158
159
|
return {
|
|
@@ -5,7 +5,8 @@ import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/
|
|
|
5
5
|
|
|
6
6
|
export const { log_debug, log_error, log_info, log_verbose, log_warning } =
|
|
7
7
|
createLogger({
|
|
8
|
-
|
|
8
|
+
category: "PresentOneTime",
|
|
9
|
+
subsystem: "core/plugins/hooks",
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
// To enable this logic please add in the manifest of the plugin this code:
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { ContextKeysManager } from "../../..";
|
|
2
|
-
|
|
3
|
-
describe("Context Keys Manager - getKey", () => {
|
|
4
|
-
it("returns value if found by reference", async () => {
|
|
5
|
-
// setup
|
|
6
|
-
const key = "namespace.key";
|
|
7
|
-
const value = "value";
|
|
8
|
-
|
|
9
|
-
const mockedLogger = {
|
|
10
|
-
warn: jest.fn(),
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const mockedSessionStorage = {
|
|
14
|
-
getItem: jest.fn(),
|
|
15
|
-
setItem: jest.fn(),
|
|
16
|
-
removeItem: jest.fn(),
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const mockedLocalStorage = {
|
|
20
|
-
getItem: jest.fn(),
|
|
21
|
-
setItem: jest.fn(),
|
|
22
|
-
removeItem: jest.fn(),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const mockedSecureStorage = {
|
|
26
|
-
getItem: jest.fn(),
|
|
27
|
-
setItem: jest.fn(),
|
|
28
|
-
removeItem: jest.fn(),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const contextManager = new ContextKeysManager({
|
|
32
|
-
logger: mockedLogger,
|
|
33
|
-
sessionStorage: mockedSessionStorage,
|
|
34
|
-
localStorage: mockedLocalStorage,
|
|
35
|
-
secureStorage: mockedSecureStorage,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const getKeyByReference = jest
|
|
39
|
-
.spyOn(contextManager, "getKeyByReference")
|
|
40
|
-
.mockResolvedValueOnce(value);
|
|
41
|
-
|
|
42
|
-
// run
|
|
43
|
-
const result = await contextManager.getKey(key);
|
|
44
|
-
|
|
45
|
-
// verify
|
|
46
|
-
expect(result).toEqual(value);
|
|
47
|
-
|
|
48
|
-
expect(mockedLogger.warn).not.toHaveBeenCalled();
|
|
49
|
-
|
|
50
|
-
expect(getKeyByReference).toHaveBeenCalledWith("key", "namespace");
|
|
51
|
-
|
|
52
|
-
expect(mockedSessionStorage.getItem).not.toHaveBeenCalled();
|
|
53
|
-
expect(mockedLocalStorage.getItem).not.toHaveBeenCalled();
|
|
54
|
-
expect(mockedSecureStorage.getItem).not.toHaveBeenCalled();
|
|
55
|
-
});
|
|
56
|
-
});
|