@applicaster/zapp-react-native-utils 16.0.0-rc.13 → 16.0.0-rc.131

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.
Files changed (295) hide show
  1. package/actionUtils/index.ts +3 -1
  2. package/actionsExecutor/ActionExecutor.ts +59 -14
  3. package/actionsExecutor/ActionExecutorContext.tsx +115 -316
  4. package/actionsExecutor/__tests__/ActionExecutor.test.ts +71 -0
  5. package/actionsExecutor/__tests__/StorageActions.test.ts +98 -0
  6. package/actionsExecutor/__tests__/feedDecorator.test.ts +91 -0
  7. package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
  8. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +25 -0
  9. package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
  10. package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
  11. package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +88 -0
  12. package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +314 -0
  13. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +100 -0
  14. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +372 -0
  15. package/actionsExecutor/actions/__tests__/presentScreen.test.ts +127 -0
  16. package/actionsExecutor/actions/__tests__/showAlert.test.ts +49 -0
  17. package/actionsExecutor/actions/__tests__/showToast.test.ts +88 -0
  18. package/actionsExecutor/actions/appRestart.ts +24 -0
  19. package/actionsExecutor/actions/confirmDialog.ts +53 -0
  20. package/actionsExecutor/actions/dismissBottomSheet.ts +23 -0
  21. package/actionsExecutor/actions/goBack.ts +60 -0
  22. package/actionsExecutor/actions/goHome.ts +31 -0
  23. package/actionsExecutor/actions/index.ts +42 -0
  24. package/actionsExecutor/actions/localStorageRemove.ts +27 -0
  25. package/actionsExecutor/actions/localStorageSet.ts +28 -0
  26. package/actionsExecutor/actions/localStorageToggleFlag.ts +28 -0
  27. package/actionsExecutor/actions/navigateToScreen.ts +127 -0
  28. package/actionsExecutor/actions/openBottomSheet.ts +340 -0
  29. package/actionsExecutor/actions/presentScreen.ts +78 -0
  30. package/actionsExecutor/actions/refreshComponent.ts +85 -0
  31. package/actionsExecutor/actions/screenSetVariable.ts +35 -0
  32. package/actionsExecutor/actions/screenToggleFlag.ts +36 -0
  33. package/actionsExecutor/actions/sendCloudEvent.ts +93 -0
  34. package/actionsExecutor/actions/sessionStorageRemove.ts +19 -0
  35. package/actionsExecutor/actions/sessionStorageSet.ts +20 -0
  36. package/actionsExecutor/actions/sessionStorageToggleFlag.ts +15 -0
  37. package/actionsExecutor/actions/showAlert.ts +51 -0
  38. package/actionsExecutor/actions/showToast.ts +87 -0
  39. package/actionsExecutor/actions/switchLayout.ts +40 -0
  40. package/actionsExecutor/consts.ts +27 -0
  41. package/actionsExecutor/feedDecorator.ts +14 -8
  42. package/actionsExecutor/types.ts +66 -0
  43. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -2
  44. package/analyticsUtils/PlayerAnalyticsManager.ts +12 -2
  45. package/analyticsUtils/__tests__/analyticsMapper.test.ts +35 -0
  46. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testACP_events.json +1 -1
  47. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testBlockUnlistedParams_rules.json +1 -1
  48. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_events.json +4 -0
  49. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_rules.json +6 -0
  50. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEventRegex_events.json +3 -9
  51. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_events.json +18 -0
  52. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_rules.json +16 -0
  53. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_events.json +4 -0
  54. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_rules.json +6 -0
  55. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_events.json +4 -0
  56. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_rules.json +6 -0
  57. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_events.json +4 -0
  58. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_rules.json +6 -0
  59. package/analyticsUtils/__tests__/fixtures/index.js +20 -0
  60. package/analyticsUtils/__tests__/playerAnalyticsSafeguard.test.ts +62 -0
  61. package/analyticsUtils/analyticsMapper.ts +4 -1
  62. package/analyticsUtils/logger.ts +9 -4
  63. package/analyticsUtils/playerAnalyticsTracker.ts +27 -3
  64. package/appUtils/HooksManager/index.ts +9 -0
  65. package/appUtils/HooksManager/logger.ts +5 -2
  66. package/appUtils/accessibilityManager/logger.ts +2 -4
  67. package/appUtils/accessibilityManager/utils.ts +1 -1
  68. package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +2 -23
  69. package/appUtils/contextKeysManager/__tests__/getKey/success/fullSearch.test.ts +1 -25
  70. package/appUtils/contextKeysManager/__tests__/getKey/success/searchInSecure.test.ts +1 -7
  71. package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +1 -26
  72. package/appUtils/contextKeysManager/__tests__/removeKey/success.test.ts +0 -6
  73. package/appUtils/contextKeysManager/__tests__/setKey/failure/failedToSaveInStorage.test.ts +0 -40
  74. package/appUtils/contextKeysManager/__tests__/setKey/failure/invalidKey.test.ts +4 -4
  75. package/appUtils/contextKeysManager/__tests__/setKey/{success/saveItemAndReference.test.ts → success.test.ts} +2 -42
  76. package/appUtils/contextKeysManager/index.ts +31 -132
  77. package/appUtils/focusManager/__tests__/focusManager.test.js +33 -0
  78. package/appUtils/focusManager/__tests__/focusToolbox.test.ts +357 -0
  79. package/appUtils/focusManager/focusToolbox.ts +223 -0
  80. package/appUtils/focusManager/index.ios.ts +7 -1
  81. package/appUtils/focusManager/index.ts +3 -3
  82. package/appUtils/focusManager/logger.ts +2 -2
  83. package/appUtils/focusManagerAux/index.ts +2 -2
  84. package/appUtils/orientationHelper.ts +2 -2
  85. package/appUtils/platform/platformUtils.ts +6 -22
  86. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +143 -60
  87. package/appUtils/playerManager/OverlayObserver/__tests__/getUpcomingQueue.test.ts +67 -0
  88. package/appUtils/playerManager/OverlayObserver/__tests__/liveContent.test.ts +205 -0
  89. package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +56 -0
  90. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +4 -0
  91. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +4 -0
  92. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +24 -0
  93. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +4 -0
  94. package/appUtils/playerManager/OverlayObserver/utils.ts +51 -20
  95. package/appUtils/playerManager/__tests__/playerContent.test.ts +403 -0
  96. package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
  97. package/appUtils/playerManager/__tests__/playerFactory.test.ts +1 -1
  98. package/appUtils/playerManager/__tests__/playerNative.test.ts +114 -0
  99. package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
  100. package/appUtils/playerManager/__tests__/playerToolbox.test.ts +281 -0
  101. package/appUtils/playerManager/__tests__/usePlayerContent.test.tsx +64 -0
  102. package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
  103. package/appUtils/playerManager/{conts.ts → const.ts} +33 -0
  104. package/appUtils/playerManager/index.ts +10 -3
  105. package/appUtils/playerManager/player.ts +141 -4
  106. package/appUtils/playerManager/playerFactory.ts +1 -1
  107. package/appUtils/playerManager/playerNative.ts +29 -5
  108. package/appUtils/playerManager/playerNativeCommand.ts +3 -6
  109. package/appUtils/playerManager/playerToolbox.ts +196 -0
  110. package/appUtils/playerManager/usePlayNextOverlay.tsx +2 -2
  111. package/appUtils/playerManager/usePlayerContent.tsx +43 -0
  112. package/appUtils/playerManager/usePlayerControllerSetup.tsx +7 -1
  113. package/appUtils/playerManager/userCellPlayerMutedPreference.ts +1 -1
  114. package/appUtils/playerManager/userLanguagePreference.ts +2 -2
  115. package/arrayUtils/__tests__/{anyThruthy.test.ts → anyTruthy.test.ts} +8 -0
  116. package/arrayUtils/__tests__/arrayUtils.test.ts +165 -108
  117. package/arrayUtils/__tests__/isEmptyArray.test.ts +11 -0
  118. package/arrayUtils/__tests__/isFilledArray.test.ts +12 -0
  119. package/arrayUtils/__tests__/isFirst.test.ts +17 -0
  120. package/arrayUtils/__tests__/isIndexInRange.test.ts +14 -0
  121. package/arrayUtils/__tests__/isLast.test.ts +31 -0
  122. package/arrayUtils/__tests__/makeListOf.test.ts +31 -0
  123. package/arrayUtils/__tests__/makeListOfIndexes.test.ts +20 -0
  124. package/arrayUtils/__tests__/reorderByIds.test.ts +63 -0
  125. package/arrayUtils/__tests__/sample.test.ts +61 -0
  126. package/arrayUtils/index.ts +119 -20
  127. package/bottomSheet/__tests__/scrollContext.test.tsx +35 -0
  128. package/bottomSheet/index.ts +17 -0
  129. package/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
  130. package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
  131. package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
  132. package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
  133. package/cellUtils/index.ts +73 -8
  134. package/cellUtils/logger.ts +2 -2
  135. package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
  136. package/colorUtils/__tests__/isValidColor.test.ts +70 -0
  137. package/colorUtils/index.ts +50 -0
  138. package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
  139. package/configurationUtils/__tests__/modalBlocksParser.test.ts +403 -0
  140. package/configurationUtils/manifestKeyParser.ts +50 -10
  141. package/configurationUtils/modalBlocksParser.ts +252 -0
  142. package/domUtils/logger.ts +2 -2
  143. package/entryActions/__tests__/buildEntryActions.test.ts +235 -0
  144. package/entryActions/aliasPresentation.ts +109 -0
  145. package/entryActions/buildEntryActions.ts +167 -0
  146. package/entryActions/index.ts +15 -0
  147. package/entryActions/types.ts +39 -0
  148. package/focusManager/FocusManager.ts +35 -2
  149. package/focusManager/__tests__/FocusManager.test.ts +121 -0
  150. package/focusManager/focusToolbox.ts +208 -0
  151. package/focusManager/index.ts +7 -0
  152. package/focusManager/logger.ts +2 -6
  153. package/headersUtils/index.ts +2 -2
  154. package/localizationUtils/index.ts +12 -6
  155. package/logger/__tests__/subsystems.test.ts +148 -0
  156. package/logger/__tests__/xrayToolbox.test.ts +69 -0
  157. package/logger/index.ts +48 -9
  158. package/logger/subsystems.ts +112 -0
  159. package/logger/xrayToolbox.ts +69 -0
  160. package/manifestUtils/__tests__/player.audioControls.test.js +158 -0
  161. package/manifestUtils/_internals/index.js +14 -3
  162. package/manifestUtils/defaultManifestConfigurations/generalContent.js +41 -0
  163. package/manifestUtils/defaultManifestConfigurations/player.js +357 -20
  164. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +84 -0
  165. package/manifestUtils/fieldUtils/index.js +125 -0
  166. package/manifestUtils/index.js +3 -0
  167. package/manifestUtils/keys.js +16 -2
  168. package/manifestUtils/mobileAction/button/index.js +16 -0
  169. package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
  170. package/manifestUtils/mobileAction/container/index.js +3 -1
  171. package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
  172. package/manifestUtils/mobileAction/groups/defaults.js +5 -2
  173. package/manifestUtils/modalBlocks.js +304 -0
  174. package/manifestUtils/platformIsTV.js +1 -0
  175. package/modalState/ContentViewModel.ts +113 -0
  176. package/modalState/EditableCollection.ts +17 -0
  177. package/modalState/EditableCollectionRegistry.ts +51 -0
  178. package/modalState/ModalOrchestrator.ts +213 -0
  179. package/modalState/RemoteEditableCollection.ts +235 -0
  180. package/modalState/__tests__/ContentViewModel.editable.test.ts +69 -0
  181. package/modalState/__tests__/ContentViewModel.test.ts +165 -0
  182. package/modalState/__tests__/EditableCollectionRegistry.test.ts +112 -0
  183. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +86 -0
  184. package/modalState/__tests__/RemoteEditableCollection.test.ts +415 -0
  185. package/modalState/__tests__/index.test.ts +30 -1
  186. package/modalState/__tests__/useBottomSheetContent.test.ts +349 -0
  187. package/modalState/__tests__/useModalStoreState.test.ts +142 -0
  188. package/modalState/index.ts +37 -83
  189. package/modalState/store.ts +109 -0
  190. package/modalState/types.ts +173 -0
  191. package/modalState/useBottomSheetContent.ts +109 -0
  192. package/navigationUtils/index.ts +5 -2
  193. package/navigationUtils/xrayNavigator.ts +12 -0
  194. package/numberUtils/__tests__/isMinusZero.test.ts +20 -0
  195. package/numberUtils/__tests__/isZero.test.ts +27 -0
  196. package/numberUtils/__tests__/requireNumber.test.ts +50 -0
  197. package/numberUtils/__tests__/toNumber.test.ts +27 -0
  198. package/numberUtils/__tests__/toNumberWithDefault.test.ts +64 -0
  199. package/numberUtils/__tests__/toNumberWithDefaultZero.test.ts +48 -0
  200. package/numberUtils/index.ts +29 -10
  201. package/package.json +3 -2
  202. package/pipesUtils/__tests__/buildUrlWithQuery.test.ts +33 -0
  203. package/pipesUtils/__tests__/withPipesEndpoint.test.tsx +56 -0
  204. package/pipesUtils/index.ts +1 -0
  205. package/pipesUtils/withPipesEndpoint.tsx +54 -0
  206. package/playerUtils/PlayerTTS/PlayerTTS.ts +1 -1
  207. package/playerUtils/__tests__/contentDataKeys.test.ts +297 -0
  208. package/playerUtils/__tests__/resolvePlayerActions.test.ts +138 -0
  209. package/playerUtils/__tests__/resolvePlayerTitleSubtitle.test.ts +180 -0
  210. package/playerUtils/contentDataKeys.ts +134 -0
  211. package/playerUtils/imaScriptDom.ts +1 -1
  212. package/playerUtils/index.ts +37 -16
  213. package/playerUtils/isAudioItem.ts +26 -0
  214. package/playerUtils/resolvePlayerActions.ts +71 -0
  215. package/playerUtils/resolvePlayerTitleSubtitle.ts +76 -0
  216. package/playerUtils/useValidatePlayerConfig.tsx +1 -1
  217. package/pluginUtils/__tests__/pluginUtils.test.js +32 -0
  218. package/pluginUtils/index.ts +29 -0
  219. package/pluginUtils/logger.ts +2 -2
  220. package/quickBrickAssets/__tests__/index.test.ts +18 -0
  221. package/quickBrickAssets/index.ts +35 -0
  222. package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
  223. package/reactHooks/actions/index.ts +124 -3
  224. package/reactHooks/cell-click/__tests__/index.test.js +131 -1
  225. package/reactHooks/cell-click/index.ts +48 -25
  226. package/reactHooks/connection/index.tsx +8 -5
  227. package/reactHooks/feed/__mocks__/useMarkPipesDataStale.ts +4 -0
  228. package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
  229. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
  230. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +25 -0
  231. package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
  232. package/reactHooks/feed/index.ts +5 -1
  233. package/reactHooks/feed/useBatchLoading.ts +9 -1
  234. package/reactHooks/feed/useBuildPipesUrl.ts +5 -2
  235. package/reactHooks/feed/useFeedLoader.tsx +30 -3
  236. package/reactHooks/feed/useLoadPipesDataDispatch.ts +12 -11
  237. package/reactHooks/feed/useMarkPipesDataStale.ts +97 -0
  238. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +5 -2
  239. package/reactHooks/index.ts +2 -0
  240. package/reactHooks/layout/index.ts +1 -1
  241. package/reactHooks/logger.ts +5 -2
  242. package/reactHooks/navigation/__mocks__/index.ts +4 -0
  243. package/reactHooks/navigation/__tests__/index.test.tsx +176 -1
  244. package/reactHooks/navigation/__tests__/useIsScreenActive.test.ts +42 -0
  245. package/reactHooks/navigation/__tests__/usePresentScreen.test.ts +154 -0
  246. package/reactHooks/navigation/index.ts +3 -1
  247. package/reactHooks/navigation/useIsScreenActive.ts +29 -8
  248. package/reactHooks/navigation/usePresentScreen.ts +157 -0
  249. package/reactHooks/navigation/useRoute.ts +22 -5
  250. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +2 -2
  251. package/reactHooks/screen/useScreenData.ts +2 -2
  252. package/reactHooks/state/useComponentScreenState.ts +1 -1
  253. package/reactHooks/usePluginConfiguration.ts +88 -47
  254. package/reactHooks/utils/__tests__/index.test.js +22 -2
  255. package/reactHooks/utils/index.ts +13 -2
  256. package/reactHooks/videoModal/hooks/useChangeOrientation.ts +2 -7
  257. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +1 -1
  258. package/reactUtils/__tests__/deviceTargetGuards.test.js +73 -0
  259. package/reactUtils/createContext/helpers.ts +2 -2
  260. package/reactUtils/index.ts +28 -0
  261. package/reactUtils/logger.ts +2 -2
  262. package/riverComponetsMeasurementProvider/index.tsx +17 -13
  263. package/storage/ScreenSingleValueProvider.ts +1 -1
  264. package/storage/ScreenStateMultiSelectProvider.ts +1 -1
  265. package/storage/StorageMultiSelectProvider.ts +1 -1
  266. package/storage/StorageSingleSelectProvider.ts +1 -1
  267. package/stringUtils/__tests__/stringUtils.test.js +42 -0
  268. package/stringUtils/index.ts +2 -2
  269. package/stylesUtils/logger.ts +2 -2
  270. package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +93 -0
  271. package/uiActionsRegistrator/__tests__/subscribe.test.ts +133 -0
  272. package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +52 -0
  273. package/uiActionsRegistrator/index.ts +25 -0
  274. package/uiActionsRegistrator/registry.ts +351 -0
  275. package/uiActionsRegistrator/resolveActionIdentifiers.ts +100 -0
  276. package/uiActionsRegistrator/usableActionItems.ts +66 -0
  277. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +2 -1
  278. package/zappFrameworkUtils/__tests__/localStorageHelper.test.ts +146 -0
  279. package/zappFrameworkUtils/localStorageHelper.ts +19 -15
  280. package/zappFrameworkUtils/loginPluginUtils.ts +2 -1
  281. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -1
  282. package/appUtils/contextKeysManager/__tests__/getKey/success/byReference.test.ts +0 -56
  283. package/appUtils/contextKeysManager/__tests__/getKeyByReference/failure.test.ts +0 -265
  284. package/appUtils/contextKeysManager/__tests__/getKeyByReference/success.test.ts +0 -303
  285. package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/failure.test.ts +0 -82
  286. package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/success.test.ts +0 -41
  287. package/appUtils/contextKeysManager/__tests__/setKey/success/saveItemButNotReference.test.ts +0 -208
  288. package/appUtils/contextKeysManager/__tests__/setReferenceForKey/failure.test.ts +0 -93
  289. package/appUtils/contextKeysManager/__tests__/setReferenceForKey/success.test.ts +0 -45
  290. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +0 -56
  291. package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
  292. package/playerUtils/getPlayerActionButtons.ts +0 -17
  293. package/reactHooks/feed/__mocks__/usePipesCacheReset.ts +0 -1
  294. package/reactHooks/feed/usePipesCacheReset.ts +0 -44
  295. /package/reactHooks/actions/__tests__/{index.test.js → index.test.tsx} +0 -0
@@ -0,0 +1,35 @@
1
+ import assets from "@applicaster/quick-brick-assets";
2
+ import type {
3
+ QuickBrickAssetKey,
4
+ QuickBrickAssetSource,
5
+ } from "@applicaster/quick-brick-assets";
6
+
7
+ export type { QuickBrickAssetKey, QuickBrickAssetSource };
8
+
9
+ type PluginOf<K> = K extends `${infer Plugin}/${string}` ? Plugin : never;
10
+
11
+ type PathOf<K, Plugin extends string> = K extends `${Plugin}/${infer Path}`
12
+ ? Path
13
+ : never;
14
+
15
+ /** Plugin identifiers that have a folder in `@applicaster/quick-brick-assets`. */
16
+ export type QuickBrickAssetPlugin = PluginOf<QuickBrickAssetKey>;
17
+
18
+ /** Asset paths inside the given plugin's folder. */
19
+ export type QuickBrickAssetPath<Plugin extends QuickBrickAssetPlugin> = PathOf<
20
+ QuickBrickAssetKey,
21
+ Plugin
22
+ >;
23
+
24
+ /**
25
+ * Looks up an asset of `@applicaster/quick-brick-assets` by plugin identifier
26
+ * and path relative to the plugin folder, e.g.
27
+ * `getQuickBrickAsset("mute_unmute_action", "action/flavour_1/mute.png")`.
28
+ * Both arguments are checked against the package's files at compile time.
29
+ * Density variants (`@2x` / `@3x`) are not supported.
30
+ */
31
+ export const getQuickBrickAsset = <Plugin extends QuickBrickAssetPlugin>(
32
+ pluginIdentifier: Plugin,
33
+ assetPath: QuickBrickAssetPath<Plugin>
34
+ ): QuickBrickAssetSource =>
35
+ assets[`${pluginIdentifier}/${assetPath}` as QuickBrickAssetKey];
@@ -0,0 +1,82 @@
1
+ import { renderHook } from "@testing-library/react-native";
2
+
3
+ const plugin = {
4
+ identifier: "cast",
5
+ configuration: {
6
+ title: "Configured",
7
+ localizations: { fr: { close: "Fermer" } },
8
+ },
9
+ };
10
+
11
+ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
12
+ usePlugins: () => [plugin],
13
+ }));
14
+
15
+ jest.mock(
16
+ "@applicaster/zapp-react-native-utils/appUtils/localizationsHelper",
17
+ () => ({ getUILanguage: () => "fr" })
18
+ );
19
+
20
+ import {
21
+ getPluginConfiguration,
22
+ mergeLocalizations,
23
+ usePluginConfiguration,
24
+ } from "../usePluginConfiguration";
25
+
26
+ const manifest = {
27
+ custom_configuration_fields: [
28
+ { key: "title", initial_value: "Default" },
29
+ { key: "color", initial_value: "red" },
30
+ ],
31
+ localizations: {
32
+ fields: [
33
+ { key: "close", initial_value: "Close" },
34
+ { key: "cancel", initial_value: "Cancel" },
35
+ ],
36
+ },
37
+ };
38
+
39
+ it("matches usePluginConfiguration outside React", () => {
40
+ const { result } = renderHook(() => usePluginConfiguration("cast", manifest));
41
+
42
+ expect(getPluginConfiguration(plugin, manifest)).toEqual(result.current);
43
+ });
44
+
45
+ // Expected values are what R.mergeDeepWith((l, r) => (isNil(l) ? r : l)) returned before ramda was removed
46
+ describe("mergeLocalizations", () => {
47
+ const defaults = { en: { close: "Close", cancel: "Cancel" } };
48
+
49
+ it("returns the defaults when nothing is configured", () => {
50
+ expect(mergeLocalizations(undefined, defaults)).toEqual(defaults);
51
+ });
52
+
53
+ it("keeps configured values, fills nil ones and missing keys from defaults", () => {
54
+ expect(
55
+ mergeLocalizations(
56
+ { en: { close: null, extra: "X" }, fr: { close: "Fermer" } },
57
+ defaults
58
+ )
59
+ ).toEqual({
60
+ en: { close: "Close", extra: "X", cancel: "Cancel" },
61
+ fr: { close: "Fermer" },
62
+ });
63
+ });
64
+
65
+ it("does not merge arrays", () => {
66
+ expect(
67
+ mergeLocalizations(
68
+ { en: { close: ["a"] } },
69
+ { en: { close: ["b"], cancel: "C" } }
70
+ )
71
+ ).toEqual({ en: { close: ["a"], cancel: "C" } });
72
+ });
73
+ });
74
+
75
+ it("keeps configured languages first, so the fallback language stays the configured one", () => {
76
+ const merged = mergeLocalizations(
77
+ { he: { close: "סגור" }, en: { close: "Close it" } },
78
+ { en: { close: "Close" } }
79
+ );
80
+
81
+ expect(Object.keys(merged)).toEqual(["he", "en"]);
82
+ });
@@ -1,8 +1,13 @@
1
1
  /// <reference types="@applicaster/applicaster-types" />
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
- import { Context, useContext, useState } from "react";
3
+ import { Context, useCallback, useContext, useEffect, useState } from "react";
4
4
  import { ActionsContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ActionsContext";
5
5
 
6
+ import {
7
+ observeEntryState,
8
+ RegisteredActionValue,
9
+ uiActionsRegistry,
10
+ } from "../../uiActionsRegistrator";
6
11
  import { reactHooksLogger } from "../logger";
7
12
 
8
13
  const logger = reactHooksLogger.addSubsystem("actions");
@@ -16,21 +21,55 @@ type ActionContexts<T = unknown> = {
16
21
  };
17
22
 
18
23
  /**
19
- * React Hook to subscribe to the custom action context
24
+ * A value that changes whenever a provider is added to or removed from
25
+ * `uiActionsRegistry`.
26
+ *
27
+ * Providers can register after the UI that wants them has rendered - the audio
28
+ * player registers playback speed only once its controller has state, and
29
+ * plugin-backed actions are bridged in from an effect. Put this in the
30
+ * dependency list of anything that resolves actions, so the list is re-read
31
+ * instead of being frozen at first paint.
32
+ */
33
+ export function useRegistryRevision(): number {
34
+ const [revision, setRevision] = useState(0);
35
+
36
+ useEffect(
37
+ () =>
38
+ uiActionsRegistry.subscribe(() => setRevision((current) => current + 1)),
39
+ []
40
+ );
41
+
42
+ return revision;
43
+ }
44
+
45
+ /**
46
+ * Resolves a legacy action context or falls back to the UI action registry.
20
47
  * @param {*} plugId - subscribes to the context of that action plugin
21
48
  * @return {*} - global action provider context or context for specific action plugin
22
49
  */
23
50
  export function useActions<T = unknown>(plugId: string): any {
24
51
  const [logged, setLogged] = useState(false);
25
52
  const context = useContext<ActionContexts<T>>(ActionsContext);
53
+ useRegistryRevision();
54
+
26
55
  const actionContext = context?.actions?.[plugId]?.module?.context;
27
56
 
28
57
  if (plugId) {
29
58
  if (!actionContext) {
59
+ const registeredAction = uiActionsRegistry.getAction(plugId);
60
+
61
+ if (registeredAction) return registeredAction;
62
+
30
63
  if (!logged) {
31
64
  logger.warning({
32
65
  message: `useActions: Couldn't find an action for ${plugId} plugin`,
33
- data: { actions: context?.actions },
66
+ // Identifiers only. The action map holds every plugin's module and
67
+ // live React context, which is far too large for a log line and can
68
+ // carry whatever state those plugins hold.
69
+ data: {
70
+ plugId,
71
+ availableActions: Object.keys(context?.actions ?? {}),
72
+ },
34
73
  });
35
74
 
36
75
  setLogged(true);
@@ -46,3 +85,85 @@ export function useActions<T = unknown>(plugId: string): any {
46
85
 
47
86
  return context;
48
87
  }
88
+
89
+ export type UseEntryActionState = {
90
+ state: CellActionEntryState | undefined;
91
+ invokeAction: (options?: InvokeArgsOptions) => void;
92
+ };
93
+
94
+ /**
95
+ * Subscribes a component to a single action's state for a given `entry`.
96
+ *
97
+ * It observes state changes reactively via `observeEntryState` (which is backed
98
+ * by the action's `addListener`), seeds the initial value synchronously from
99
+ * `initialEntryState`, and returns a memoized `invokeAction` that forwards
100
+ * optimistic `updateState` updates back into local state.
101
+ *
102
+ * This is the single, unified way to drive an action button - it works the same
103
+ * for registry actions, legacy context-provider actions and entry actions.
104
+ */
105
+ export function useEntryActionState(
106
+ action: RegisteredActionValue | undefined,
107
+ entry: ZappEntry | ZappFeed
108
+ ): UseEntryActionState {
109
+ const [state, setState] = useState<CellActionEntryState | undefined>(() =>
110
+ action?.initialEntryState?.(entry)
111
+ );
112
+
113
+ const entryId = (entry as ZappEntry)?.id;
114
+
115
+ useEffect(() => {
116
+ if (!action) return undefined;
117
+
118
+ // An action's stream is third-party code. Subscribing with only a `next`
119
+ // handler lets RxJS rethrow an error notification asynchronously, where no
120
+ // error boundary catches it - one plugin faulting would take the app down
121
+ // rather than this one button. The button keeps its last known state.
122
+ let subscription;
123
+
124
+ try {
125
+ subscription = observeEntryState(action, entry).subscribe({
126
+ next: setState,
127
+ error: (error) =>
128
+ logger.warning({
129
+ message:
130
+ "useEntryActionState: the action's state stream failed - the button keeps its last state",
131
+ data: { entryId, error },
132
+ }),
133
+ });
134
+ } catch (error) {
135
+ logger.warning({
136
+ message:
137
+ "useEntryActionState: could not observe the action - the button keeps its initial state",
138
+ data: { entryId, error },
139
+ });
140
+
141
+ return undefined;
142
+ }
143
+
144
+ return () => subscription.unsubscribe();
145
+ // eslint-disable-next-line @wogns3623/better-exhaustive-deps/exhaustive-deps
146
+ }, [action, entryId]);
147
+
148
+ const invokeAction = useCallback(
149
+ (options: InvokeArgsOptions = {}) => {
150
+ if (typeof action?.invokeAction !== "function") {
151
+ // A button was rendered and pressed, and the press goes nowhere. Only
152
+ // reachable on a user interaction, so it costs nothing on render. The
153
+ // action value carries no identifier, so the label is what locates the
154
+ // button that misbehaved.
155
+ logger.warning({
156
+ message:
157
+ "useEntryActionState: the pressed action has no invokeAction - the press did nothing",
158
+ data: { entryId, label: state?.label },
159
+ });
160
+ }
161
+
162
+ action?.invokeAction?.(entry, { updateState: setState, ...options });
163
+ },
164
+ // eslint-disable-next-line @wogns3623/better-exhaustive-deps/exhaustive-deps
165
+ [action, entryId]
166
+ );
167
+
168
+ return { state, invokeAction };
169
+ }
@@ -5,6 +5,7 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
5
5
 
6
6
  const mockNavigator = {
7
7
  getPathname: () => "pathnameMock",
8
+ currentRoute: "pathnameMock",
8
9
  push: jest.fn(),
9
10
  data: {},
10
11
  };
@@ -29,14 +30,17 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
29
30
  ),
30
31
  useTargetScreenData: jest.fn(() => ({})),
31
32
  useCurrentScreenData: jest.fn(() => ({})),
33
+ useScreenContext: jest.fn(() => ({})),
32
34
  }));
33
35
 
36
+ const mockSetEntryContext = jest.fn();
37
+
34
38
  jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
35
39
  ...jest.requireActual(
36
40
  "@applicaster/zapp-react-native-ui-components/Contexts"
37
41
  ),
38
42
  ZappPipesEntryContext: {
39
- useZappPipesContext: jest.fn(() => [undefined, jest.fn()]),
43
+ useZappPipesContext: jest.fn(() => [undefined, mockSetEntryContext]),
40
44
  },
41
45
  }));
42
46
 
@@ -66,6 +70,12 @@ const wrapper = ({ children }) => (
66
70
  </CellTapContext.Provider>
67
71
  );
68
72
 
73
+ const actionExecutorWrapper = ({ children }) => (
74
+ <ActionExecutorContext.Provider value={actionExecutor}>
75
+ {children}
76
+ </ActionExecutorContext.Provider>
77
+ );
78
+
69
79
  describe("useCellClick", () => {
70
80
  it("returns a function", () => {
71
81
  const { result } = renderHook(() => useCellClick(mockProps));
@@ -95,4 +105,124 @@ describe("useCellClick", () => {
95
105
 
96
106
  cleanup();
97
107
  });
108
+
109
+ it("does not push when the cell finishes a hook", async () => {
110
+ mockNavigator.push.mockClear();
111
+
112
+ const item = {
113
+ id: "profile-1",
114
+ type: { value: "feed" },
115
+ extensions: {
116
+ tap_actions: {
117
+ actions: [
118
+ { type: "sessionStorageSet" },
119
+ { type: "finishHook", options: { success: true } },
120
+ ],
121
+ },
122
+ },
123
+ };
124
+
125
+ const { result } = renderHook(() => useCellClick({ item }), {
126
+ wrapper: actionExecutorWrapper,
127
+ });
128
+
129
+ await result.current();
130
+
131
+ await waitFor(() => {
132
+ expect(actionExecutor.handleEntryActions).toHaveBeenCalled();
133
+ });
134
+
135
+ expect(mockNavigator.push).not.toHaveBeenCalled();
136
+ cleanup();
137
+ });
138
+
139
+ it("pushes after tap actions that do not finish a hook", async () => {
140
+ mockNavigator.push.mockClear();
141
+
142
+ const item = {
143
+ id: "episode-1",
144
+ type: { value: "feed" },
145
+ extensions: {
146
+ tap_actions: {
147
+ actions: [{ type: "sessionStorageSet" }],
148
+ },
149
+ },
150
+ };
151
+
152
+ const { result } = renderHook(() => useCellClick({ item }), {
153
+ wrapper: actionExecutorWrapper,
154
+ });
155
+
156
+ await result.current();
157
+
158
+ await waitFor(() => {
159
+ expect(mockNavigator.push).toHaveBeenCalled();
160
+ });
161
+
162
+ cleanup();
163
+ });
164
+
165
+ describe("entry context", () => {
166
+ const tapWith = async (item) => {
167
+ mockSetEntryContext.mockClear();
168
+ actionExecutor.handleEntryActions.mockClear();
169
+
170
+ const { result } = renderHook(() => useCellClick({ item }), {
171
+ wrapper: actionExecutorWrapper,
172
+ });
173
+
174
+ await result.current();
175
+ cleanup();
176
+ };
177
+
178
+ it("is not set on a tap of an action cell", async () => {
179
+ await tapWith({
180
+ id: "team-1",
181
+ type: { value: "action" },
182
+ extensions: {
183
+ tap_actions: {
184
+ actions: [
185
+ { type: "localStorageToggleFlag" },
186
+ { type: "sendCloudEvent" },
187
+ ],
188
+ },
189
+ },
190
+ });
191
+
192
+ expect(mockSetEntryContext).not.toHaveBeenCalled();
193
+ });
194
+
195
+ it("is handed to the actions so an action can set it", async () => {
196
+ await tapWith({
197
+ id: "link-1",
198
+ type: { value: "action" },
199
+ extensions: {
200
+ tap_actions: { actions: [{ type: "navigateToScreen" }] },
201
+ },
202
+ });
203
+
204
+ expect(actionExecutor.handleEntryActions).toHaveBeenCalledWith(
205
+ expect.objectContaining({ id: "link-1" }),
206
+ expect.objectContaining({ setEntryContext: mockSetEntryContext })
207
+ );
208
+ });
209
+
210
+ it("is set after the actions for any other cell", async () => {
211
+ await tapWith({
212
+ id: "episode-2",
213
+ type: { value: "feed" },
214
+ extensions: {
215
+ tap_actions: { actions: [{ type: "localStorageToggleFlag" }] },
216
+ },
217
+ });
218
+
219
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
220
+ expect.objectContaining({ id: "episode-2" })
221
+ );
222
+
223
+ expect(
224
+ actionExecutor.handleEntryActions.mock.invocationCallOrder[0]
225
+ ).toBeLessThan(mockSetEntryContext.mock.invocationCallOrder[0]);
226
+ });
227
+ });
98
228
  });
@@ -4,6 +4,7 @@ import * as React from "react";
4
4
  import * as R from "ramda";
5
5
  import { handleActionSchemeUrl } from "@applicaster/quick-brick-core/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useUrlSchemeHandler";
6
6
  import { CellTapContext } from "@applicaster/zapp-react-native-ui-components/Contexts/CellTapContext";
7
+ import { useUIComponentContext } from "@applicaster/zapp-react-native-ui-components/Contexts/UIComponentContext";
7
8
  import {
8
9
  useNavigation,
9
10
  useProfilerLogging,
@@ -28,7 +29,6 @@ import { useScreenStateStore } from "../navigation/useScreenStateStore";
28
29
  type Props = {
29
30
  item?: ZappEntry;
30
31
  index?: number;
31
- component?: ZappUIComponent;
32
32
  zappPipesData?: ZappPipesData;
33
33
  };
34
34
 
@@ -37,24 +37,25 @@ type onPressReturnFn =
37
37
  | (() => void);
38
38
 
39
39
  export const useCellClick = ({
40
- component,
41
40
  zappPipesData,
42
41
  item,
43
- }: Props): onPressReturnFn => {
42
+ }: Props = {}): onPressReturnFn => {
44
43
  const { push, currentRoute } = useNavigation();
45
44
  const { pathname } = useRoute();
46
45
  const screenStateStore = useScreenStateStore();
47
46
 
48
47
  const onCellTap: Option<Function> = React.useContext(CellTapContext);
49
48
  const actionExecutor = React.useContext(ActionExecutorContext);
49
+ const component = useUIComponentContext();
50
50
  const screenData = useCurrentScreenData();
51
51
  const screenState = useScreenContext()?.options;
52
+ const entry = useScreenContext()?.entry;
52
53
 
53
54
  const cellSelectable = toBooleanWithDefaultTrue(
54
55
  component?.rules?.component_cells_selectable
55
56
  );
56
57
 
57
- const [entryContext, setEntryContext] =
58
+ const [_entryContext, setEntryContext] =
58
59
  ZappPipesEntryContext.useZappPipesContext(pathname);
59
60
 
60
61
  const logTimestamp = useProfilerLogging();
@@ -70,7 +71,6 @@ export const useCellClick = ({
70
71
  // Making sure we are not getting GestureResponderEvent in here.
71
72
  const isZappEntry = _item?.id && _item?.type;
72
73
  const selectedItem = isZappEntry ? _item : item;
73
- setEntryContext?.(selectedItem);
74
74
 
75
75
  if (!selectedItem?.type?.value) {
76
76
  warnEmptyContentType(selectedItem);
@@ -82,14 +82,22 @@ export const useCellClick = ({
82
82
 
83
83
  logOnPress(selectedItem, pathname, component, onCellTap);
84
84
 
85
+ const tapActions = selectedItem?.extensions?.tap_actions?.actions;
86
+
87
+ const finishesHook =
88
+ Array.isArray(tapActions) &&
89
+ tapActions.some((action) => action?.type === "finishHook");
90
+
85
91
  if (selectedItem) {
86
92
  await actionExecutor?.handleEntryActions(selectedItem, {
93
+ setEntryContext,
87
94
  component,
88
95
  screenData,
89
96
  screenState,
90
97
  screenRoute: pathname,
91
98
  screenStateStore,
92
- entryContext,
99
+ entryContext: selectedItem,
100
+ screenEntry: entry,
93
101
  });
94
102
  }
95
103
 
@@ -99,32 +107,47 @@ export const useCellClick = ({
99
107
  url: selectedItem.link.href,
100
108
  });
101
109
  }
102
- } else {
103
- if (isFunction(onCellTap)) {
104
- onCellTap?.(selectedItem, _index);
105
- } else {
106
- if (currentRoute === pathname || pathname.includes("video-modal")) {
107
- const targetScreen = component?.data?.target;
108
-
109
- push(
110
- R.when(
111
- () => targetScreen,
112
- R.mergeLeft({ screen_type: targetScreen })
113
- )(selectedItem)
114
- );
115
- }
110
+
111
+ // An action cell does not open a screen by itself: the actions that do
112
+ // (navigateToScreen) set the entry context for it.
113
+ return;
114
+ }
115
+
116
+ setEntryContext?.(selectedItem);
117
+
118
+ if (isFunction(onCellTap)) {
119
+ onCellTap?.(selectedItem, _index);
120
+ } else if (!finishesHook) {
121
+ // finishHook already completes the hook and navigates to the original
122
+ // target. Pushing the cell as well stacks a second copy of that screen
123
+ // (e.g. home/home after a profile selector hook).
124
+ if (currentRoute === pathname || pathname.includes("video-modal")) {
125
+ const targetScreen = component?.data?.target;
126
+
127
+ push(
128
+ R.when(
129
+ () => targetScreen,
130
+ R.mergeLeft({ screen_type: targetScreen })
131
+ )(selectedItem)
132
+ );
116
133
  }
117
134
  }
118
135
  },
119
136
  [
120
- onCellTap,
121
- currentRoute,
137
+ item,
122
138
  setEntryContext,
123
- pathname,
124
- push,
125
139
  sendAnalyticsOnPress,
140
+ logTimestamp,
141
+ pathname,
142
+ component,
143
+ onCellTap,
144
+ entry,
145
+ actionExecutor,
126
146
  screenData,
127
147
  screenState,
148
+ screenStateStore,
149
+ currentRoute,
150
+ push,
128
151
  ]
129
152
  );
130
153
 
@@ -138,5 +161,5 @@ export const useCellClick = ({
138
161
  onPressRef.current = onPress;
139
162
  }
140
163
 
141
- return React.useCallback(onPressRef.current, []);
164
+ return React.useCallback(onPressRef.current, [item]);
142
165
  };
@@ -4,6 +4,11 @@ import { NetInfoState } from "@react-native-community/netinfo";
4
4
  import { NetworkStatusContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NetworkStatusContext";
5
5
  import { isOnline } from "@applicaster/quick-brick-core/App/NetworkStatusProvider/utils";
6
6
 
7
+ type ConnectionInfo = NetInfoState & {
8
+ deviceStatus: NetStatus;
9
+ stillOfflineAfterResumeCount?: number;
10
+ };
11
+
7
12
  /**
8
13
  * This hook returns connection type from RN NetInfo component or boolean for iConnected if justOnlineStatus flag is set
9
14
  * @param {boolean} justOnlineStatus - flag if to return boolean for isConnected
@@ -12,16 +17,14 @@ import { isOnline } from "@applicaster/quick-brick-core/App/NetworkStatusProvide
12
17
 
13
18
  export function useConnectionInfo(justOnlineStatus: true): boolean;
14
19
 
15
- export function useConnectionInfo(
16
- justOnlineStatus: false
17
- ): NetInfoState & { deviceStatus: NetStatus };
20
+ export function useConnectionInfo(justOnlineStatus: false): ConnectionInfo;
18
21
 
19
22
  export function useConnectionInfo(
20
23
  justOnlineStatus: boolean
21
- ): boolean | (NetInfoState & { deviceStatus: NetStatus }) {
24
+ ): boolean | ConnectionInfo {
22
25
  const connectionInfo = React.useContext(
23
26
  NetworkStatusContext
24
- ) as NetInfoState & { deviceStatus: NetStatus };
27
+ ) as ConnectionInfo;
25
28
 
26
29
  return justOnlineStatus ? isOnline(connectionInfo) === true : connectionInfo;
27
30
  }
@@ -0,0 +1,4 @@
1
+ export const useMarkPipesDataStale = jest.fn();
2
+
3
+ /** @deprecated alias of useMarkPipesDataStale */
4
+ export const usePipesCacheReset = useMarkPipesDataStale;