@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.
- package/actionUtils/index.ts +3 -1
- package/actionsExecutor/ActionExecutor.ts +59 -14
- package/actionsExecutor/ActionExecutorContext.tsx +115 -316
- package/actionsExecutor/__tests__/ActionExecutor.test.ts +71 -0
- package/actionsExecutor/__tests__/StorageActions.test.ts +98 -0
- package/actionsExecutor/__tests__/feedDecorator.test.ts +91 -0
- package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
- package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +25 -0
- package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
- package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
- package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +88 -0
- package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +314 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +100 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +372 -0
- package/actionsExecutor/actions/__tests__/presentScreen.test.ts +127 -0
- package/actionsExecutor/actions/__tests__/showAlert.test.ts +49 -0
- package/actionsExecutor/actions/__tests__/showToast.test.ts +88 -0
- package/actionsExecutor/actions/appRestart.ts +24 -0
- package/actionsExecutor/actions/confirmDialog.ts +53 -0
- package/actionsExecutor/actions/dismissBottomSheet.ts +23 -0
- package/actionsExecutor/actions/goBack.ts +60 -0
- package/actionsExecutor/actions/goHome.ts +31 -0
- package/actionsExecutor/actions/index.ts +42 -0
- package/actionsExecutor/actions/localStorageRemove.ts +27 -0
- package/actionsExecutor/actions/localStorageSet.ts +28 -0
- package/actionsExecutor/actions/localStorageToggleFlag.ts +28 -0
- package/actionsExecutor/actions/navigateToScreen.ts +127 -0
- package/actionsExecutor/actions/openBottomSheet.ts +340 -0
- package/actionsExecutor/actions/presentScreen.ts +78 -0
- package/actionsExecutor/actions/refreshComponent.ts +85 -0
- package/actionsExecutor/actions/screenSetVariable.ts +35 -0
- package/actionsExecutor/actions/screenToggleFlag.ts +36 -0
- package/actionsExecutor/actions/sendCloudEvent.ts +93 -0
- package/actionsExecutor/actions/sessionStorageRemove.ts +19 -0
- package/actionsExecutor/actions/sessionStorageSet.ts +20 -0
- package/actionsExecutor/actions/sessionStorageToggleFlag.ts +15 -0
- package/actionsExecutor/actions/showAlert.ts +51 -0
- package/actionsExecutor/actions/showToast.ts +87 -0
- package/actionsExecutor/actions/switchLayout.ts +40 -0
- package/actionsExecutor/consts.ts +27 -0
- package/actionsExecutor/feedDecorator.ts +14 -8
- package/actionsExecutor/types.ts +66 -0
- package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -2
- package/analyticsUtils/PlayerAnalyticsManager.ts +12 -2
- package/analyticsUtils/__tests__/analyticsMapper.test.ts +35 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testACP_events.json +1 -1
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testBlockUnlistedParams_rules.json +1 -1
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_events.json +4 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_rules.json +6 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEventRegex_events.json +3 -9
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_events.json +18 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_rules.json +16 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_events.json +4 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_rules.json +6 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_events.json +4 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_rules.json +6 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_events.json +4 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_rules.json +6 -0
- package/analyticsUtils/__tests__/fixtures/index.js +20 -0
- package/analyticsUtils/__tests__/playerAnalyticsSafeguard.test.ts +62 -0
- package/analyticsUtils/analyticsMapper.ts +4 -1
- package/analyticsUtils/logger.ts +9 -4
- package/analyticsUtils/playerAnalyticsTracker.ts +27 -3
- package/appUtils/HooksManager/index.ts +9 -0
- 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 +2 -23
- 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 +1 -26
- 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/failure/invalidKey.test.ts +4 -4
- package/appUtils/contextKeysManager/__tests__/setKey/{success/saveItemAndReference.test.ts → success.test.ts} +2 -42
- package/appUtils/contextKeysManager/index.ts +31 -132
- 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 +143 -60
- package/appUtils/playerManager/OverlayObserver/__tests__/getUpcomingQueue.test.ts +67 -0
- package/appUtils/playerManager/OverlayObserver/__tests__/liveContent.test.ts +205 -0
- package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +56 -0
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +4 -0
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +4 -0
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +24 -0
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +4 -0
- package/appUtils/playerManager/OverlayObserver/utils.ts +51 -20
- package/appUtils/playerManager/__tests__/playerContent.test.ts +403 -0
- package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerFactory.test.ts +1 -1
- package/appUtils/playerManager/__tests__/playerNative.test.ts +114 -0
- package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerToolbox.test.ts +281 -0
- package/appUtils/playerManager/__tests__/usePlayerContent.test.tsx +64 -0
- package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
- package/appUtils/playerManager/{conts.ts → const.ts} +33 -0
- package/appUtils/playerManager/index.ts +10 -3
- package/appUtils/playerManager/player.ts +141 -4
- package/appUtils/playerManager/playerFactory.ts +1 -1
- package/appUtils/playerManager/playerNative.ts +29 -5
- package/appUtils/playerManager/playerNativeCommand.ts +3 -6
- package/appUtils/playerManager/playerToolbox.ts +196 -0
- package/appUtils/playerManager/usePlayNextOverlay.tsx +2 -2
- package/appUtils/playerManager/usePlayerContent.tsx +43 -0
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +7 -1
- package/appUtils/playerManager/userCellPlayerMutedPreference.ts +1 -1
- package/appUtils/playerManager/userLanguagePreference.ts +2 -2
- package/arrayUtils/__tests__/{anyThruthy.test.ts → anyTruthy.test.ts} +8 -0
- package/arrayUtils/__tests__/arrayUtils.test.ts +165 -108
- package/arrayUtils/__tests__/isEmptyArray.test.ts +11 -0
- package/arrayUtils/__tests__/isFilledArray.test.ts +12 -0
- package/arrayUtils/__tests__/isFirst.test.ts +17 -0
- package/arrayUtils/__tests__/isIndexInRange.test.ts +14 -0
- package/arrayUtils/__tests__/isLast.test.ts +31 -0
- package/arrayUtils/__tests__/makeListOf.test.ts +31 -0
- package/arrayUtils/__tests__/makeListOfIndexes.test.ts +20 -0
- package/arrayUtils/__tests__/reorderByIds.test.ts +63 -0
- package/arrayUtils/__tests__/sample.test.ts +61 -0
- package/arrayUtils/index.ts +119 -20
- package/bottomSheet/__tests__/scrollContext.test.tsx +35 -0
- package/bottomSheet/index.ts +17 -0
- 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 +73 -8
- package/cellUtils/logger.ts +2 -2
- package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
- package/colorUtils/__tests__/isValidColor.test.ts +70 -0
- package/colorUtils/index.ts +50 -0
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +403 -0
- package/configurationUtils/manifestKeyParser.ts +50 -10
- package/configurationUtils/modalBlocksParser.ts +252 -0
- package/domUtils/logger.ts +2 -2
- package/entryActions/__tests__/buildEntryActions.test.ts +235 -0
- package/entryActions/aliasPresentation.ts +109 -0
- package/entryActions/buildEntryActions.ts +167 -0
- package/entryActions/index.ts +15 -0
- package/entryActions/types.ts +39 -0
- package/focusManager/FocusManager.ts +35 -2
- package/focusManager/__tests__/FocusManager.test.ts +121 -0
- 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__/player.audioControls.test.js +158 -0
- package/manifestUtils/_internals/index.js +14 -3
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +41 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +357 -20
- package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +84 -0
- package/manifestUtils/fieldUtils/index.js +125 -0
- package/manifestUtils/index.js +3 -0
- package/manifestUtils/keys.js +16 -2
- package/manifestUtils/mobileAction/button/index.js +16 -0
- package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
- package/manifestUtils/mobileAction/container/index.js +3 -1
- package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
- package/manifestUtils/mobileAction/groups/defaults.js +5 -2
- package/manifestUtils/modalBlocks.js +304 -0
- package/manifestUtils/platformIsTV.js +1 -0
- package/modalState/ContentViewModel.ts +113 -0
- package/modalState/EditableCollection.ts +17 -0
- package/modalState/EditableCollectionRegistry.ts +51 -0
- package/modalState/ModalOrchestrator.ts +213 -0
- package/modalState/RemoteEditableCollection.ts +235 -0
- package/modalState/__tests__/ContentViewModel.editable.test.ts +69 -0
- package/modalState/__tests__/ContentViewModel.test.ts +165 -0
- package/modalState/__tests__/EditableCollectionRegistry.test.ts +112 -0
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +86 -0
- package/modalState/__tests__/RemoteEditableCollection.test.ts +415 -0
- package/modalState/__tests__/index.test.ts +30 -1
- package/modalState/__tests__/useBottomSheetContent.test.ts +349 -0
- package/modalState/__tests__/useModalStoreState.test.ts +142 -0
- package/modalState/index.ts +37 -83
- package/modalState/store.ts +109 -0
- package/modalState/types.ts +173 -0
- package/modalState/useBottomSheetContent.ts +109 -0
- package/navigationUtils/index.ts +5 -2
- package/navigationUtils/xrayNavigator.ts +12 -0
- package/numberUtils/__tests__/isMinusZero.test.ts +20 -0
- package/numberUtils/__tests__/isZero.test.ts +27 -0
- package/numberUtils/__tests__/requireNumber.test.ts +50 -0
- package/numberUtils/__tests__/toNumber.test.ts +27 -0
- package/numberUtils/__tests__/toNumberWithDefault.test.ts +64 -0
- package/numberUtils/__tests__/toNumberWithDefaultZero.test.ts +48 -0
- package/numberUtils/index.ts +29 -10
- package/package.json +3 -2
- package/pipesUtils/__tests__/buildUrlWithQuery.test.ts +33 -0
- package/pipesUtils/__tests__/withPipesEndpoint.test.tsx +56 -0
- package/pipesUtils/index.ts +1 -0
- package/pipesUtils/withPipesEndpoint.tsx +54 -0
- package/playerUtils/PlayerTTS/PlayerTTS.ts +1 -1
- package/playerUtils/__tests__/contentDataKeys.test.ts +297 -0
- package/playerUtils/__tests__/resolvePlayerActions.test.ts +138 -0
- package/playerUtils/__tests__/resolvePlayerTitleSubtitle.test.ts +180 -0
- package/playerUtils/contentDataKeys.ts +134 -0
- package/playerUtils/imaScriptDom.ts +1 -1
- package/playerUtils/index.ts +37 -16
- package/playerUtils/isAudioItem.ts +26 -0
- package/playerUtils/resolvePlayerActions.ts +71 -0
- package/playerUtils/resolvePlayerTitleSubtitle.ts +76 -0
- package/playerUtils/useValidatePlayerConfig.tsx +1 -1
- package/pluginUtils/__tests__/pluginUtils.test.js +32 -0
- package/pluginUtils/index.ts +29 -0
- 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 +124 -3
- package/reactHooks/cell-click/__tests__/index.test.js +131 -1
- package/reactHooks/cell-click/index.ts +48 -25
- package/reactHooks/connection/index.tsx +8 -5
- package/reactHooks/feed/__mocks__/useMarkPipesDataStale.ts +4 -0
- package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
- package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +25 -0
- package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
- package/reactHooks/feed/index.ts +5 -1
- package/reactHooks/feed/useBatchLoading.ts +9 -1
- 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 +97 -0
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +5 -2
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/index.ts +1 -1
- package/reactHooks/logger.ts +5 -2
- package/reactHooks/navigation/__mocks__/index.ts +4 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +176 -1
- package/reactHooks/navigation/__tests__/useIsScreenActive.test.ts +42 -0
- package/reactHooks/navigation/__tests__/usePresentScreen.test.ts +154 -0
- package/reactHooks/navigation/index.ts +3 -1
- package/reactHooks/navigation/useIsScreenActive.ts +29 -8
- package/reactHooks/navigation/usePresentScreen.ts +157 -0
- package/reactHooks/navigation/useRoute.ts +22 -5
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +2 -2
- package/reactHooks/screen/useScreenData.ts +2 -2
- package/reactHooks/state/useComponentScreenState.ts +1 -1
- package/reactHooks/usePluginConfiguration.ts +88 -47
- package/reactHooks/utils/__tests__/index.test.js +22 -2
- package/reactHooks/utils/index.ts +13 -2
- 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 +17 -13
- 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/stringUtils/__tests__/stringUtils.test.js +42 -0
- package/stringUtils/index.ts +2 -2
- package/stylesUtils/logger.ts +2 -2
- package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +93 -0
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +133 -0
- package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +52 -0
- package/uiActionsRegistrator/index.ts +25 -0
- package/uiActionsRegistrator/registry.ts +351 -0
- package/uiActionsRegistrator/resolveActionIdentifiers.ts +100 -0
- package/uiActionsRegistrator/usableActionItems.ts +66 -0
- package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +2 -1
- package/zappFrameworkUtils/__tests__/localStorageHelper.test.ts +146 -0
- package/zappFrameworkUtils/localStorageHelper.ts +19 -15
- 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
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +0 -56
- package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
- package/playerUtils/getPlayerActionButtons.ts +0 -17
- package/reactHooks/feed/__mocks__/usePipesCacheReset.ts +0 -1
- package/reactHooks/feed/usePipesCacheReset.ts +0 -44
- /package/reactHooks/actions/__tests__/{index.test.js → index.test.tsx} +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { PLUGIN_KINDS, XRAY_SUBSYSTEMS } from "../subsystems";
|
|
5
|
+
|
|
6
|
+
const REPO_ROOT = path.resolve(__dirname, "../../../..");
|
|
7
|
+
const SOURCE_DIRS = ["packages", "plugins"];
|
|
8
|
+
|
|
9
|
+
const SKIP_DIRS = new Set([
|
|
10
|
+
"node_modules",
|
|
11
|
+
"__tests__",
|
|
12
|
+
"__mocks__",
|
|
13
|
+
"dist",
|
|
14
|
+
"lib",
|
|
15
|
+
"android",
|
|
16
|
+
"ios",
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
const SHARED_LOGGER_DIR = "packages/zapp-react-native-utils/logger/";
|
|
20
|
+
|
|
21
|
+
// `subsystem: "x"`, `anySubsystem = "x"`, `subsystemLogger("x"` and `new Logger("Category", "x"`
|
|
22
|
+
const SUBSYSTEM_LITERALS = [
|
|
23
|
+
/\bsubsystem:\s*"([^"]+)"/g,
|
|
24
|
+
/\b\w*(?:Subsystem|SUBSYSTEM)\s*=\s*"([^"]+)"/g,
|
|
25
|
+
/\bsubsystemLogger\(\s*"([^"]+)"/g,
|
|
26
|
+
/\bnew Logger\(\s*"[^"]*"\s*,\s*"([^"]+)"/g,
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const PLUGIN_NODE = new RegExp(
|
|
30
|
+
`^plugins/(?:${PLUGIN_KINDS.join("|")})/[a-z0-9_]+(/[a-z0-9_]+)?$`
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// A template string is built at runtime, so it cannot be checked against the tree.
|
|
34
|
+
const TEMPLATE_SUBSYSTEMS = [
|
|
35
|
+
/\bsubsystem:\s*`/,
|
|
36
|
+
/\b\w*(?:Subsystem|SUBSYSTEM)\s*=\s*`/,
|
|
37
|
+
/\bsubsystemLogger\(\s*`/,
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const SHARED_CREATE_LOGGER_IMPORT =
|
|
41
|
+
/import\s*\{[^}]*\bcreateLogger\b[^}]*\}\s*from\s*"@applicaster\/zapp-react-native-utils\/logger"/;
|
|
42
|
+
|
|
43
|
+
// Inside zapp-react-native-utils the shared logger is imported by a relative path.
|
|
44
|
+
const RELATIVE_CREATE_LOGGER_IMPORT =
|
|
45
|
+
/import\s*\{[^}]*\bcreateLogger\b[^}]*\}\s*from\s*"(?:\.\.\/)+logger"/;
|
|
46
|
+
|
|
47
|
+
const CREATE_LOGGER_CALLS = /\bcreateLogger\(\s*(\{[^}]*\})?\s*\)/g;
|
|
48
|
+
|
|
49
|
+
// Native-side keys read by the X-Ray sinks, not nodes of the tree.
|
|
50
|
+
const NOT_TREE_NODES = new Set(["xray", "xray/logger"]);
|
|
51
|
+
|
|
52
|
+
// The default player moves onto the tree in its own change; its old names are not checked until then.
|
|
53
|
+
const LEFT_OUT = ["plugins/zapp-react-native-default-player/"];
|
|
54
|
+
|
|
55
|
+
const sourceFiles = (dir: string): string[] =>
|
|
56
|
+
fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
57
|
+
if (entry.isDirectory()) {
|
|
58
|
+
return SKIP_DIRS.has(entry.name)
|
|
59
|
+
? []
|
|
60
|
+
: sourceFiles(path.join(dir, entry.name));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return /\.(ts|tsx|js|jsx)$/.test(entry.name) &&
|
|
64
|
+
!entry.name.endsWith(".d.ts")
|
|
65
|
+
? [path.join(dir, entry.name)]
|
|
66
|
+
: [];
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Commented-out code does not log.
|
|
70
|
+
const loggingSources = () =>
|
|
71
|
+
SOURCE_DIRS.flatMap((dir) => sourceFiles(path.join(REPO_ROOT, dir)))
|
|
72
|
+
.map((file) => path.relative(REPO_ROOT, file))
|
|
73
|
+
.filter((file) => !LEFT_OUT.some((dir) => file.startsWith(dir)))
|
|
74
|
+
.map((file) => ({
|
|
75
|
+
file,
|
|
76
|
+
text: fs
|
|
77
|
+
.readFileSync(path.join(REPO_ROOT, file), "utf8")
|
|
78
|
+
.replace(/^\s*\/\/.*$/gm, ""),
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
const usesSharedCreateLogger = (file: string, text: string) =>
|
|
82
|
+
SHARED_CREATE_LOGGER_IMPORT.test(text) ||
|
|
83
|
+
(file.startsWith("packages/zapp-react-native-utils/") &&
|
|
84
|
+
RELATIVE_CREATE_LOGGER_IMPORT.test(text));
|
|
85
|
+
|
|
86
|
+
describe("X-Ray subsystems", () => {
|
|
87
|
+
const sources = loggingSources();
|
|
88
|
+
|
|
89
|
+
it("only uses nodes of the subsystem tree", () => {
|
|
90
|
+
const known = new Set<string>(XRAY_SUBSYSTEMS);
|
|
91
|
+
const unknown: string[] = [];
|
|
92
|
+
|
|
93
|
+
sources.forEach(({ file, text }) => {
|
|
94
|
+
SUBSYSTEM_LITERALS.forEach((pattern) => {
|
|
95
|
+
Array.from(text.matchAll(pattern)).forEach((match) => {
|
|
96
|
+
const node = match[1];
|
|
97
|
+
|
|
98
|
+
if (
|
|
99
|
+
!known.has(node) &&
|
|
100
|
+
!PLUGIN_NODE.test(node) &&
|
|
101
|
+
!NOT_TREE_NODES.has(node)
|
|
102
|
+
) {
|
|
103
|
+
unknown.push(`${file}: "${node}"`);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Add the node to the tree (xray-subsystems skill in Zapp-Frameworks) and to XRAY_SUBSYSTEMS first.
|
|
110
|
+
expect(unknown).toEqual([]);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("does not build a subsystem from a template string", () => {
|
|
114
|
+
const templates = sources
|
|
115
|
+
.filter(
|
|
116
|
+
({ file, text }) =>
|
|
117
|
+
!file.startsWith(SHARED_LOGGER_DIR) &&
|
|
118
|
+
TEMPLATE_SUBSYSTEMS.some((pattern) => pattern.test(text))
|
|
119
|
+
)
|
|
120
|
+
.map(({ file }) => file);
|
|
121
|
+
|
|
122
|
+
expect(templates).toEqual([]);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("does not call the shared createLogger without a subsystem", () => {
|
|
126
|
+
const missing = sources
|
|
127
|
+
.filter(({ file, text }) => usesSharedCreateLogger(file, text))
|
|
128
|
+
.flatMap(({ file, text }) =>
|
|
129
|
+
Array.from(text.matchAll(CREATE_LOGGER_CALLS))
|
|
130
|
+
.filter(([, args]) => !/\bsubsystem\b/.test(args ?? ""))
|
|
131
|
+
.map(([call]) => `${file}: ${call}`)
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
expect(missing).toEqual([]);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("creates loggers through the shared logger module, not new Logger", () => {
|
|
138
|
+
const direct = sources
|
|
139
|
+
.filter(
|
|
140
|
+
({ file, text }) =>
|
|
141
|
+
!file.startsWith(SHARED_LOGGER_DIR) && /\bnew Logger\(/.test(text)
|
|
142
|
+
)
|
|
143
|
+
.map(({ file }) => file);
|
|
144
|
+
|
|
145
|
+
// Use subsystemLogger(subsystem, category).
|
|
146
|
+
expect(direct).toEqual([]);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const xray = require("@applicaster/quick-brick-xray");
|
|
2
|
+
|
|
3
|
+
const toolbox = { name: "test", description: "", tools: [] };
|
|
4
|
+
|
|
5
|
+
const load = (): typeof import("../xrayToolbox") => {
|
|
6
|
+
let module;
|
|
7
|
+
|
|
8
|
+
jest.isolateModules(() => {
|
|
9
|
+
module = require("../xrayToolbox");
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
return module;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe("registerXrayToolbox", () => {
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
delete xray.registerReactToolbox;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("registers once per name", async () => {
|
|
21
|
+
xray.registerReactToolbox = jest.fn().mockResolvedValue(undefined);
|
|
22
|
+
const { registerXrayToolbox } = load();
|
|
23
|
+
|
|
24
|
+
await expect(registerXrayToolbox(toolbox)).resolves.toBe(true);
|
|
25
|
+
await expect(registerXrayToolbox(toolbox)).resolves.toBe(true);
|
|
26
|
+
|
|
27
|
+
expect(xray.registerReactToolbox).toHaveBeenCalledTimes(1);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("resolves false without a toolbox API", async () => {
|
|
31
|
+
await expect(load().registerXrayToolbox(toolbox)).resolves.toBe(false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("keeps a failed registration instead of retrying it", async () => {
|
|
35
|
+
xray.registerReactToolbox = jest
|
|
36
|
+
.fn()
|
|
37
|
+
.mockRejectedValue(new Error("XRayToolboxBridge is not available"));
|
|
38
|
+
|
|
39
|
+
const { registerXrayToolbox } = load();
|
|
40
|
+
|
|
41
|
+
await expect(registerXrayToolbox(toolbox)).resolves.toBe(false);
|
|
42
|
+
await expect(registerXrayToolbox(toolbox)).resolves.toBe(false);
|
|
43
|
+
|
|
44
|
+
expect(xray.registerReactToolbox).toHaveBeenCalledTimes(1);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("registers new tools under the same name again (Fast Refresh)", async () => {
|
|
48
|
+
xray.registerReactToolbox = jest.fn().mockResolvedValue(undefined);
|
|
49
|
+
const { registerXrayToolbox } = load();
|
|
50
|
+
|
|
51
|
+
await registerXrayToolbox(toolbox);
|
|
52
|
+
await registerXrayToolbox({ ...toolbox, tools: [] });
|
|
53
|
+
|
|
54
|
+
expect(xray.registerReactToolbox).toHaveBeenCalledTimes(2);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("stops trying every toolbox once the bridge is missing", async () => {
|
|
58
|
+
xray.registerReactToolbox = jest.fn().mockRejectedValue(new Error("no"));
|
|
59
|
+
const { registerXrayToolbox } = load();
|
|
60
|
+
|
|
61
|
+
await registerXrayToolbox(toolbox);
|
|
62
|
+
|
|
63
|
+
await expect(
|
|
64
|
+
registerXrayToolbox({ ...toolbox, name: "other" })
|
|
65
|
+
).resolves.toBe(false);
|
|
66
|
+
|
|
67
|
+
expect(xray.registerReactToolbox).toHaveBeenCalledTimes(1);
|
|
68
|
+
});
|
|
69
|
+
});
|
package/logger/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { useEffect } from "react";
|
|
|
2
2
|
import { identity } from "ramda";
|
|
3
3
|
|
|
4
4
|
import MockLogger from "./const";
|
|
5
|
+
import type { XraySubsystem } from "./subsystems";
|
|
5
6
|
|
|
6
7
|
const mockObj = new MockLogger("mock", "native-utils");
|
|
7
8
|
|
|
@@ -43,13 +44,27 @@ export const getUtilsLogger = (): XrayUtils => {
|
|
|
43
44
|
const { Logger } = xray || {};
|
|
44
45
|
|
|
45
46
|
if (xray && !Logger.mock) {
|
|
47
|
+
// A subsystem starts with its domain (xray-subsystems skill), so core and plugins are not under `app/`.
|
|
48
|
+
// The parent is only there to share the context.
|
|
46
49
|
const quickBrickLogger = new Logger("QuickBrick", "app");
|
|
47
|
-
const coreLogger =
|
|
48
|
-
const logger =
|
|
50
|
+
const coreLogger = new Logger("QuickBrick", "core", quickBrickLogger);
|
|
51
|
+
const logger = new Logger("QuickBrick", "plugins", quickBrickLogger);
|
|
49
52
|
const logLevels = Logger.logLevels;
|
|
50
|
-
const utilsLogger = coreLogger
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
const utilsLogger = coreLogger;
|
|
54
|
+
|
|
55
|
+
// A logger on a node of the tree, e.g. subsystemLogger("ui/navigation", "Navigator").
|
|
56
|
+
// The subsystem says where in the product, the category names the component or feature.
|
|
57
|
+
const subsystemLogger = (subsystem: string, category = "QuickBrick") =>
|
|
58
|
+
new Logger(category, subsystem, quickBrickLogger);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
quickBrickLogger,
|
|
62
|
+
coreLogger,
|
|
63
|
+
logger,
|
|
64
|
+
logLevels,
|
|
65
|
+
utilsLogger,
|
|
66
|
+
subsystemLogger,
|
|
67
|
+
};
|
|
53
68
|
}
|
|
54
69
|
|
|
55
70
|
return {
|
|
@@ -58,11 +73,27 @@ export const getUtilsLogger = (): XrayUtils => {
|
|
|
58
73
|
logger: mockObj,
|
|
59
74
|
logLevels: MockLogger.logLevels,
|
|
60
75
|
utilsLogger: mockObj,
|
|
76
|
+
subsystemLogger: () => mockObj,
|
|
61
77
|
}; // TODO: check if this is the best approach
|
|
62
78
|
};
|
|
63
79
|
|
|
64
|
-
const {
|
|
65
|
-
|
|
80
|
+
const {
|
|
81
|
+
quickBrickLogger,
|
|
82
|
+
coreLogger,
|
|
83
|
+
logger,
|
|
84
|
+
logLevels,
|
|
85
|
+
utilsLogger,
|
|
86
|
+
subsystemLogger: anySubsystemLogger,
|
|
87
|
+
} = getUtilsLogger();
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A logger on a node of the X-Ray subsystem tree (see ./subsystems), named after the component by `category`.
|
|
91
|
+
* Only nodes of the tree compile, so a new path has to be added to the list first.
|
|
92
|
+
*/
|
|
93
|
+
const subsystemLogger = anySubsystemLogger as (
|
|
94
|
+
subsystem: XraySubsystem,
|
|
95
|
+
category?: string
|
|
96
|
+
) => ReturnType<XrayUtils["subsystemLogger"]>;
|
|
66
97
|
|
|
67
98
|
/**
|
|
68
99
|
* useLogger is a React hook that can be used within the React lifecycle
|
|
@@ -89,11 +120,16 @@ function useLogger(
|
|
|
89
120
|
|
|
90
121
|
const createLogger = ({
|
|
91
122
|
category = "General",
|
|
92
|
-
subsystem
|
|
123
|
+
subsystem,
|
|
93
124
|
parent = null,
|
|
125
|
+
}: {
|
|
126
|
+
category?: string;
|
|
127
|
+
subsystem: XraySubsystem;
|
|
128
|
+
parent?: XRayLoggerI | null;
|
|
94
129
|
}) => {
|
|
95
130
|
const XRayLogger = getXray().Logger as any;
|
|
96
|
-
|
|
131
|
+
// The type requires a subsystem; the fallback only keeps already built plugins working.
|
|
132
|
+
const logger = new XRayLogger(category, subsystem ?? "MyPlugin", parent);
|
|
97
133
|
|
|
98
134
|
const log_verbose = (message: string, data: any = null) => {
|
|
99
135
|
logger.log({
|
|
@@ -133,6 +169,8 @@ const createLogger = ({
|
|
|
133
169
|
return { log_verbose, log_debug, log_info, log_error, log_warning };
|
|
134
170
|
};
|
|
135
171
|
|
|
172
|
+
export type { XraySubsystem } from "./subsystems";
|
|
173
|
+
|
|
136
174
|
export {
|
|
137
175
|
createLogger,
|
|
138
176
|
useLogger,
|
|
@@ -141,4 +179,5 @@ export {
|
|
|
141
179
|
logger,
|
|
142
180
|
logLevels,
|
|
143
181
|
utilsLogger,
|
|
182
|
+
subsystemLogger,
|
|
144
183
|
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The X-Ray subsystems QuickBrick logs to: nodes of the shared subsystem tree, not names of packages or classes.
|
|
3
|
+
* The tree and its rules are in the xray-subsystems skill of Zapp-Frameworks (plugins/quick-brick-xray).
|
|
4
|
+
* Do not invent a path at the call site: pick a node from this list, or add the node to the tree and to this list.
|
|
5
|
+
* Precision (which class, hook or feature) goes in the logger's `category`, not here.
|
|
6
|
+
*/
|
|
7
|
+
export const XRAY_SUBSYSTEMS = [
|
|
8
|
+
"analytics/player",
|
|
9
|
+
"analytics/utils",
|
|
10
|
+
"app",
|
|
11
|
+
"app/deep_linking",
|
|
12
|
+
"app/lifecycle",
|
|
13
|
+
"app/loading",
|
|
14
|
+
"app/remote_control",
|
|
15
|
+
"core",
|
|
16
|
+
"core/actions",
|
|
17
|
+
"core/actions/legacy_registry",
|
|
18
|
+
"core/actions/ui_registry",
|
|
19
|
+
"core/context",
|
|
20
|
+
"core/dom",
|
|
21
|
+
"core/numbers",
|
|
22
|
+
"core/platform",
|
|
23
|
+
"core/plugins",
|
|
24
|
+
"core/plugins/hooks",
|
|
25
|
+
"core/plugins/login",
|
|
26
|
+
"core/react",
|
|
27
|
+
"core/react/create_context",
|
|
28
|
+
"core/react_hooks",
|
|
29
|
+
"core/react_hooks/feed_loader",
|
|
30
|
+
"core/react_hooks/hook_modal",
|
|
31
|
+
"core/react_hooks/pipes_url",
|
|
32
|
+
"core/react_hooks/present_screen",
|
|
33
|
+
"core/react_hooks/screen_data",
|
|
34
|
+
"crash/error_boundary",
|
|
35
|
+
"network/feed",
|
|
36
|
+
"network/headers",
|
|
37
|
+
"network/reachability",
|
|
38
|
+
"network/zapp_pipes",
|
|
39
|
+
"network/zapp_pipes/app_data",
|
|
40
|
+
"network/zapp_pipes/filter",
|
|
41
|
+
"network/zapp_pipes/request",
|
|
42
|
+
"offline",
|
|
43
|
+
"player",
|
|
44
|
+
"player/audio",
|
|
45
|
+
"player/config",
|
|
46
|
+
"player/container",
|
|
47
|
+
"player/controls",
|
|
48
|
+
"player/ima",
|
|
49
|
+
"player/live",
|
|
50
|
+
"player/manager",
|
|
51
|
+
"player/modal",
|
|
52
|
+
"player/overlay",
|
|
53
|
+
"player/play_next",
|
|
54
|
+
"player/playable",
|
|
55
|
+
"player/preferences",
|
|
56
|
+
"player/seek",
|
|
57
|
+
"player/tts",
|
|
58
|
+
"plugins",
|
|
59
|
+
"react_native/bridge",
|
|
60
|
+
"react_native/push_topic",
|
|
61
|
+
"storage/app_store",
|
|
62
|
+
"storage/asset_cache",
|
|
63
|
+
"storage/native",
|
|
64
|
+
"ui",
|
|
65
|
+
"ui/accessibility",
|
|
66
|
+
"ui/bottom_sheet",
|
|
67
|
+
"ui/cells",
|
|
68
|
+
"ui/components",
|
|
69
|
+
"ui/focus",
|
|
70
|
+
"ui/focus/list",
|
|
71
|
+
"ui/images",
|
|
72
|
+
"ui/modal",
|
|
73
|
+
"ui/navigation",
|
|
74
|
+
"ui/orientation",
|
|
75
|
+
"ui/river",
|
|
76
|
+
"ui/screens",
|
|
77
|
+
"ui/styles",
|
|
78
|
+
] as const;
|
|
79
|
+
|
|
80
|
+
/** The plugin kinds of the shared tree. A new kind goes to the tree and to this list. */
|
|
81
|
+
export const PLUGIN_KINDS = [
|
|
82
|
+
"actions",
|
|
83
|
+
"ads",
|
|
84
|
+
"analytics",
|
|
85
|
+
"auth",
|
|
86
|
+
"cmp",
|
|
87
|
+
"crashlogs",
|
|
88
|
+
"general",
|
|
89
|
+
"parental_control",
|
|
90
|
+
"player",
|
|
91
|
+
"player_overlay",
|
|
92
|
+
"purchases",
|
|
93
|
+
"push",
|
|
94
|
+
"sports",
|
|
95
|
+
"storage",
|
|
96
|
+
"ui",
|
|
97
|
+
"ui_component",
|
|
98
|
+
"universal_links",
|
|
99
|
+
"video_ads",
|
|
100
|
+
] as const;
|
|
101
|
+
|
|
102
|
+
/** A plugin logs to its own node: `plugins/<kind>/<name>[/<component>]`, for example `plugins/ui_component/grid`. */
|
|
103
|
+
export type PluginSubsystem =
|
|
104
|
+
`plugins/${(typeof PLUGIN_KINDS)[number]}/${string}`;
|
|
105
|
+
|
|
106
|
+
/** Not a node of the tree: the native error collection sinks build error reports from events with this prefix. */
|
|
107
|
+
export type ErrorReportSubsystem = `error_report_collector/${string}`;
|
|
108
|
+
|
|
109
|
+
export type XraySubsystem =
|
|
110
|
+
| (typeof XRAY_SUBSYSTEMS)[number]
|
|
111
|
+
| PluginSubsystem
|
|
112
|
+
| ErrorReportSubsystem;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { getXray } from ".";
|
|
2
|
+
|
|
3
|
+
/** One tool of an X-Ray React toolbox: an agent calls it by name with JSON arguments. */
|
|
4
|
+
export type XrayToolSpec = {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
parameters?: Array<{
|
|
8
|
+
name: string;
|
|
9
|
+
type: "number" | "string";
|
|
10
|
+
description: string;
|
|
11
|
+
/** Defaults to true on the native side. */
|
|
12
|
+
required?: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
handler: (args: Record<string, unknown>) => unknown;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type XrayToolbox = {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
tools: XrayToolSpec[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type RegisterReactToolbox = (toolbox: XrayToolbox) => Promise<void>;
|
|
24
|
+
|
|
25
|
+
const registered = new Map<
|
|
26
|
+
string,
|
|
27
|
+
{ tools: XrayToolSpec[]; registration: Promise<boolean> }
|
|
28
|
+
>();
|
|
29
|
+
|
|
30
|
+
/** Set once a registration fails: the build has no X-Ray bridge, which cannot appear later. */
|
|
31
|
+
let bridgeMissing = false;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Registers an X-Ray React toolbox and resolves whether it is registered. The same tools are
|
|
35
|
+
* registered once; new tools under the same name (Fast Refresh re-ran the module) replace them.
|
|
36
|
+
* A build without the X-Ray native bridge (release builds) rejects the first attempt and every
|
|
37
|
+
* later call resolves false at once, so callers on hot paths pay for one attempt only.
|
|
38
|
+
*/
|
|
39
|
+
export const registerXrayToolbox = (toolbox: XrayToolbox): Promise<boolean> => {
|
|
40
|
+
const cached = registered.get(toolbox.name);
|
|
41
|
+
|
|
42
|
+
if (cached?.tools === toolbox.tools) return cached.registration;
|
|
43
|
+
|
|
44
|
+
if (bridgeMissing) return Promise.resolve(false);
|
|
45
|
+
|
|
46
|
+
const register = (
|
|
47
|
+
getXray() as
|
|
48
|
+
| { registerReactToolbox?: RegisterReactToolbox }
|
|
49
|
+
| null
|
|
50
|
+
| undefined
|
|
51
|
+
)?.registerReactToolbox;
|
|
52
|
+
|
|
53
|
+
const registration = register
|
|
54
|
+
? register(toolbox).then(
|
|
55
|
+
() => true,
|
|
56
|
+
() => {
|
|
57
|
+
bridgeMissing = true;
|
|
58
|
+
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
: Promise.resolve(false);
|
|
63
|
+
|
|
64
|
+
if (!register) bridgeMissing = true;
|
|
65
|
+
|
|
66
|
+
registered.set(toolbox.name, { tools: toolbox.tools, registration });
|
|
67
|
+
|
|
68
|
+
return registration;
|
|
69
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
const { player } = require("../defaultManifestConfigurations/player");
|
|
2
|
+
|
|
3
|
+
const manifestFor = (platform) => player({ platform, version: "0.0.0" });
|
|
4
|
+
|
|
5
|
+
const findGroup = (manifest, label) =>
|
|
6
|
+
manifest.styles.fields.find((group) => group.group && group.label === label);
|
|
7
|
+
|
|
8
|
+
const findFieldInGroup = (manifest, label, key) =>
|
|
9
|
+
findGroup(manifest, label)?.fields?.find((field) => field.key === key);
|
|
10
|
+
|
|
11
|
+
const findLocalization = (manifest, key) =>
|
|
12
|
+
manifest.localizations.fields.find((field) => field.key === key);
|
|
13
|
+
|
|
14
|
+
describe("player manifest — audio playlist controls", () => {
|
|
15
|
+
const manifest = manifestFor("ios_for_quickbrick");
|
|
16
|
+
|
|
17
|
+
describe("Player Controls Layout", () => {
|
|
18
|
+
const field = () =>
|
|
19
|
+
findFieldInGroup(manifest, "Audio Player", "player_controls_layout");
|
|
20
|
+
|
|
21
|
+
it("is declared in the Audio Player group", () => {
|
|
22
|
+
expect(field()).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("is a select defaulting to the existing controls", () => {
|
|
26
|
+
expect(field().type).toBe("select");
|
|
27
|
+
expect(field().initial_value).toBe("playback_speed_and_sleep_timer");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("only shows when the audio player layout is in use", () => {
|
|
31
|
+
expect(field()).toMatchObject({
|
|
32
|
+
rules: "conditional",
|
|
33
|
+
conditional_fields: [
|
|
34
|
+
{ key: "styles/full_screen_audio_player", condition_value: true },
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("offers exactly the two documented options", () => {
|
|
40
|
+
expect(field().options).toEqual([
|
|
41
|
+
{
|
|
42
|
+
text: "Playback Speed & Sleep Timer (Default)",
|
|
43
|
+
value: "playback_speed_and_sleep_timer",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
text: "Playlist Controls (Previous & Next)",
|
|
47
|
+
value: "playlist_controls",
|
|
48
|
+
},
|
|
49
|
+
]);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe("control icons", () => {
|
|
54
|
+
it.each(["previous_track", "next_track"])(
|
|
55
|
+
"declares %s as an uploader",
|
|
56
|
+
(key) => {
|
|
57
|
+
expect(findFieldInGroup(manifest, "Assets", key)).toMatchObject({
|
|
58
|
+
key,
|
|
59
|
+
type: "uploader",
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
it.each(["previous_track", "next_track"])(
|
|
65
|
+
"only shows %s when the playlist controls layout is selected",
|
|
66
|
+
(key) => {
|
|
67
|
+
expect(findFieldInGroup(manifest, "Assets", key)).toMatchObject({
|
|
68
|
+
rules: "conditional",
|
|
69
|
+
conditional_fields: [
|
|
70
|
+
{
|
|
71
|
+
key: "styles/player_controls_layout",
|
|
72
|
+
condition_value: "playlist_controls",
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
it.each([
|
|
80
|
+
"speed_0_8",
|
|
81
|
+
"speed_1",
|
|
82
|
+
"speed_1_2",
|
|
83
|
+
"speed_1_5",
|
|
84
|
+
"speed_2",
|
|
85
|
+
"sleep_timer",
|
|
86
|
+
"sleep_timer_active",
|
|
87
|
+
])(
|
|
88
|
+
"only shows %s when the playback speed and sleep timer layout is selected",
|
|
89
|
+
(key) => {
|
|
90
|
+
expect(findFieldInGroup(manifest, "Assets", key)).toMatchObject({
|
|
91
|
+
rules: "conditional",
|
|
92
|
+
conditional_fields: [
|
|
93
|
+
{
|
|
94
|
+
key: "styles/player_controls_layout",
|
|
95
|
+
condition_value: "playback_speed_and_sleep_timer",
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe("accessibility strings", () => {
|
|
104
|
+
it.each([
|
|
105
|
+
"accessibility_previous_track_label",
|
|
106
|
+
"accessibility_previous_track_hint",
|
|
107
|
+
"accessibility_next_track_label",
|
|
108
|
+
"accessibility_next_track_hint",
|
|
109
|
+
])("declares %s with a default", (key) => {
|
|
110
|
+
expect(findLocalization(manifest, key)).toMatchObject({
|
|
111
|
+
type: "text_input",
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expect(findLocalization(manifest, key).initial_value).toBeTruthy();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe("tv platforms", () => {
|
|
119
|
+
// The audio player layout is mobile only, so nothing this feature adds —
|
|
120
|
+
// including its screen reader strings — belongs in a tv manifest.
|
|
121
|
+
it.each(["tvos_for_quickbrick", "android_tv_for_quickbrick", "lg_tv"])(
|
|
122
|
+
"adds no audio controls layout field on %s",
|
|
123
|
+
(platform) => {
|
|
124
|
+
expect(
|
|
125
|
+
findFieldInGroup(
|
|
126
|
+
manifestFor(platform),
|
|
127
|
+
"Audio Player",
|
|
128
|
+
"player_controls_layout"
|
|
129
|
+
)
|
|
130
|
+
).toBeUndefined();
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
it.each([
|
|
135
|
+
"accessibility_previous_track_label",
|
|
136
|
+
"accessibility_previous_track_hint",
|
|
137
|
+
"accessibility_next_track_label",
|
|
138
|
+
"accessibility_next_track_hint",
|
|
139
|
+
])("does not declare %s on tv", (key) => {
|
|
140
|
+
expect(
|
|
141
|
+
findLocalization(manifestFor("tvos_for_quickbrick"), key)
|
|
142
|
+
).toBeUndefined();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("still declares the tv-only localizations", () => {
|
|
146
|
+
expect(
|
|
147
|
+
findLocalization(
|
|
148
|
+
manifestFor("tvos_for_quickbrick"),
|
|
149
|
+
"back_to_live_label"
|
|
150
|
+
)
|
|
151
|
+
).toBeDefined();
|
|
152
|
+
|
|
153
|
+
expect(
|
|
154
|
+
findLocalization(manifestFor("tvos_for_quickbrick"), "start_over_label")
|
|
155
|
+
).toBeDefined();
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|