@applicaster/zapp-react-native-utils 16.0.0-rc.99 → 17.0.0-alpha.1201533844

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 (156) hide show
  1. package/actionUtils/index.ts +3 -1
  2. package/actionsExecutor/ActionExecutor.ts +2 -2
  3. package/actionsExecutor/ActionExecutorContext.tsx +2 -2
  4. package/actionsExecutor/__tests__/StorageActions.test.ts +98 -0
  5. package/actionsExecutor/__tests__/feedDecorator.test.ts +30 -0
  6. package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
  7. package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +186 -5
  8. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +24 -0
  9. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +72 -0
  10. package/actionsExecutor/actions/appRestart.ts +2 -2
  11. package/actionsExecutor/actions/confirmDialog.ts +2 -2
  12. package/actionsExecutor/actions/dismissBottomSheet.ts +2 -2
  13. package/actionsExecutor/actions/goBack.ts +2 -2
  14. package/actionsExecutor/actions/goHome.ts +2 -2
  15. package/actionsExecutor/actions/navigateToScreen.ts +35 -45
  16. package/actionsExecutor/actions/openBottomSheet.ts +4 -2
  17. package/actionsExecutor/actions/presentScreen.ts +2 -2
  18. package/actionsExecutor/actions/refreshComponent.ts +2 -2
  19. package/actionsExecutor/actions/screenToggleFlag.ts +1 -3
  20. package/actionsExecutor/actions/sendCloudEvent.ts +2 -2
  21. package/actionsExecutor/actions/showAlert.ts +2 -2
  22. package/actionsExecutor/actions/switchLayout.ts +2 -2
  23. package/actionsExecutor/feedDecorator.ts +8 -2
  24. package/actionsExecutor/types.ts +7 -0
  25. package/analyticsUtils/__tests__/playerAnalyticsSafeguard.test.ts +62 -0
  26. package/analyticsUtils/logger.ts +9 -4
  27. package/analyticsUtils/playerAnalyticsTracker.ts +1 -0
  28. package/appUtils/HooksManager/logger.ts +5 -2
  29. package/appUtils/accessibilityManager/logger.ts +2 -4
  30. package/appUtils/accessibilityManager/utils.ts +1 -1
  31. package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -22
  32. package/appUtils/contextKeysManager/__tests__/getKey/success/fullSearch.test.ts +1 -25
  33. package/appUtils/contextKeysManager/__tests__/getKey/success/searchInSecure.test.ts +1 -7
  34. package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +0 -25
  35. package/appUtils/contextKeysManager/__tests__/removeKey/success.test.ts +0 -6
  36. package/appUtils/contextKeysManager/__tests__/setKey/failure/failedToSaveInStorage.test.ts +0 -40
  37. package/appUtils/contextKeysManager/__tests__/setKey/{success/saveItemAndReference.test.ts → success.test.ts} +2 -42
  38. package/appUtils/contextKeysManager/index.ts +30 -131
  39. package/appUtils/focusManager/__tests__/focusManager.test.js +33 -0
  40. package/appUtils/focusManager/__tests__/focusToolbox.test.ts +357 -0
  41. package/appUtils/focusManager/focusToolbox.ts +223 -0
  42. package/appUtils/focusManager/index.ios.ts +7 -1
  43. package/appUtils/focusManager/index.ts +3 -3
  44. package/appUtils/focusManager/logger.ts +2 -2
  45. package/appUtils/focusManagerAux/index.ts +2 -2
  46. package/appUtils/orientationHelper.ts +2 -2
  47. package/appUtils/platform/platformUtils.ts +6 -22
  48. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +1 -1
  49. package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
  50. package/appUtils/playerManager/__tests__/playerNative.test.ts +76 -0
  51. package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
  52. package/appUtils/playerManager/__tests__/playerToolbox.test.ts +281 -0
  53. package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
  54. package/appUtils/playerManager/const.ts +13 -0
  55. package/appUtils/playerManager/index.ts +9 -2
  56. package/appUtils/playerManager/player.ts +26 -1
  57. package/appUtils/playerManager/playerNative.ts +23 -1
  58. package/appUtils/playerManager/playerNativeCommand.ts +3 -6
  59. package/appUtils/playerManager/playerToolbox.ts +196 -0
  60. package/appUtils/playerManager/usePlayNextOverlay.tsx +2 -2
  61. package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -0
  62. package/appUtils/playerManager/userCellPlayerMutedPreference.ts +1 -1
  63. package/appUtils/playerManager/userLanguagePreference.ts +1 -1
  64. package/arrayUtils/__tests__/reorderByIds.test.ts +13 -0
  65. package/arrayUtils/index.ts +26 -43
  66. package/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
  67. package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
  68. package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
  69. package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
  70. package/cellUtils/index.ts +40 -0
  71. package/cellUtils/logger.ts +2 -2
  72. package/configurationUtils/__tests__/modalBlocksParser.test.ts +134 -0
  73. package/configurationUtils/modalBlocksParser.ts +38 -0
  74. package/domUtils/logger.ts +2 -2
  75. package/entryActions/aliasPresentation.ts +1 -0
  76. package/entryActions/buildEntryActions.ts +1 -1
  77. package/focusManager/FocusManager.ts +35 -2
  78. package/focusManager/__tests__/FocusManager.test.ts +121 -0
  79. package/focusManager/focusToolbox.ts +208 -0
  80. package/focusManager/index.ts +7 -0
  81. package/focusManager/logger.ts +2 -6
  82. package/headersUtils/index.ts +2 -2
  83. package/localizationUtils/index.ts +12 -6
  84. package/logger/__tests__/subsystems.test.ts +148 -0
  85. package/logger/__tests__/xrayToolbox.test.ts +69 -0
  86. package/logger/index.ts +48 -9
  87. package/logger/subsystems.ts +112 -0
  88. package/logger/xrayToolbox.ts +69 -0
  89. package/manifestUtils/__tests__/createConfig.test.js +17 -7
  90. package/manifestUtils/_internals/getDefaultConfiguration.js +9 -11
  91. package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
  92. package/manifestUtils/keys.js +7 -2
  93. package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
  94. package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
  95. package/manifestUtils/mobileAction/groups/defaults.js +2 -1
  96. package/modalState/EditableCollectionRegistry.ts +1 -1
  97. package/modalState/ModalOrchestrator.ts +1 -0
  98. package/modalState/RemoteEditableCollection.ts +1 -1
  99. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +23 -0
  100. package/modalState/index.ts +2 -0
  101. package/modalState/types.ts +11 -0
  102. package/navigationUtils/index.ts +5 -2
  103. package/navigationUtils/xrayNavigator.ts +12 -0
  104. package/numberUtils/index.ts +2 -2
  105. package/package.json +3 -2
  106. package/playerUtils/PlayerTTS/PlayerTTS.ts +1 -1
  107. package/playerUtils/imaScriptDom.ts +1 -1
  108. package/playerUtils/useValidatePlayerConfig.tsx +1 -1
  109. package/pluginUtils/logger.ts +2 -2
  110. package/quickBrickAssets/__tests__/index.test.ts +18 -0
  111. package/quickBrickAssets/index.ts +35 -0
  112. package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
  113. package/reactHooks/actions/index.ts +29 -23
  114. package/reactHooks/cell-click/__tests__/index.test.js +67 -1
  115. package/reactHooks/cell-click/index.ts +10 -2
  116. package/reactHooks/connection/index.tsx +8 -5
  117. package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
  118. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
  119. package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
  120. package/reactHooks/feed/useBuildPipesUrl.ts +5 -2
  121. package/reactHooks/feed/useFeedLoader.tsx +30 -3
  122. package/reactHooks/feed/useLoadPipesDataDispatch.ts +12 -11
  123. package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
  124. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +5 -2
  125. package/reactHooks/logger.ts +5 -2
  126. package/reactHooks/navigation/usePresentScreen.ts +2 -2
  127. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +2 -2
  128. package/reactHooks/screen/useScreenData.ts +2 -2
  129. package/reactHooks/usePluginConfiguration.ts +84 -46
  130. package/reactHooks/videoModal/hooks/useChangeOrientation.ts +2 -7
  131. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +1 -1
  132. package/reactUtils/__tests__/deviceTargetGuards.test.js +73 -0
  133. package/reactUtils/createContext/helpers.ts +2 -2
  134. package/reactUtils/index.ts +28 -0
  135. package/reactUtils/logger.ts +2 -2
  136. package/riverComponetsMeasurementProvider/index.tsx +5 -5
  137. package/storage/ScreenSingleValueProvider.ts +1 -1
  138. package/storage/ScreenStateMultiSelectProvider.ts +1 -1
  139. package/storage/StorageMultiSelectProvider.ts +1 -1
  140. package/storage/StorageSingleSelectProvider.ts +1 -1
  141. package/stylesUtils/logger.ts +2 -2
  142. package/uiActionsRegistrator/__tests__/subscribe.test.ts +26 -0
  143. package/uiActionsRegistrator/registry.ts +17 -1
  144. package/uiActionsRegistrator/resolveActionIdentifiers.ts +1 -1
  145. package/uiActionsRegistrator/usableActionItems.ts +1 -1
  146. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +2 -1
  147. package/zappFrameworkUtils/loginPluginUtils.ts +2 -1
  148. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -1
  149. package/appUtils/contextKeysManager/__tests__/getKey/success/byReference.test.ts +0 -56
  150. package/appUtils/contextKeysManager/__tests__/getKeyByReference/failure.test.ts +0 -265
  151. package/appUtils/contextKeysManager/__tests__/getKeyByReference/success.test.ts +0 -303
  152. package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/failure.test.ts +0 -82
  153. package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/success.test.ts +0 -41
  154. package/appUtils/contextKeysManager/__tests__/setKey/success/saveItemButNotReference.test.ts +0 -208
  155. package/appUtils/contextKeysManager/__tests__/setReferenceForKey/failure.test.ts +0 -93
  156. package/appUtils/contextKeysManager/__tests__/setReferenceForKey/success.test.ts +0 -45
@@ -1,7 +1,3 @@
1
- import { getXray } from "@applicaster/zapp-react-native-utils/logger";
2
- const { Logger } = getXray();
1
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
3
2
 
4
- export const logger = new Logger(
5
- "QuickBrick",
6
- "packages/zapp-react-native-utils/focusManager/FocusManager"
7
- );
3
+ export const logger = subsystemLogger("ui/focus", "FocusManager");
@@ -1,9 +1,9 @@
1
1
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
2
2
  import { getPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
3
- import { utilsLogger } from "../logger";
3
+ import { subsystemLogger } from "../logger";
4
4
  import { getUILanguage } from "../localizationUtils";
5
5
 
6
- const logger = utilsLogger.addSubsystem("headersUtils");
6
+ const logger = subsystemLogger("network/headers", "HeadersUtils");
7
7
 
8
8
  export const getAppDataHeaders = (screenId: string) => {
9
9
  const appData = appStore.get("appData");
@@ -28,17 +28,23 @@ const RTL_LOCALES = [
28
28
  "yi", // Yiddish
29
29
  ];
30
30
 
31
+ // The strings for the UI language, else the first language present
32
+ export const getLocalizedStrings = (
33
+ localizations = {},
34
+ languageCode = getUILanguage()
35
+ ) =>
36
+ localizations?.[languageCode] ||
37
+ Object.values(localizations).find(
38
+ (value) => typeof value === "object" && value !== null
39
+ ) ||
40
+ {};
41
+
31
42
  export function useLocalizedStrings({ localizations = {} }) {
32
43
  const languageCode = getUILanguage();
33
44
 
34
45
  // TODO: probably we can call getLocalizations here from localizationsHelper.js
35
46
  const result = useMemo(
36
- () =>
37
- localizations?.[languageCode] ||
38
- Object.values(localizations).find(
39
- (value) => typeof value === "object" && value !== null
40
- ) ||
41
- {},
47
+ () => getLocalizedStrings(localizations, languageCode),
42
48
  [languageCode, localizations]
43
49
  );
44
50
 
@@ -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 = quickBrickLogger.addSubsystem("core");
48
- const logger = quickBrickLogger.addSubsystem("plugins");
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.addSubsystem("utils");
51
-
52
- return { quickBrickLogger, coreLogger, logger, logLevels, utilsLogger };
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 { quickBrickLogger, coreLogger, logger, logLevels, utilsLogger } =
65
- getUtilsLogger();
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 = "MyPlugin",
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
- const logger = new XRayLogger(category, subsystem, parent);
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
+ };
@@ -58,15 +58,25 @@ describe("createConfig", () => {
58
58
  expect(currentValue).toBe(manifest);
59
59
  });
60
60
 
61
- it("should return unmodified manifest ig provided extend key doesn't exist", () => {
62
- const manifest = { identifier: "test" };
63
- const manifestFactory = () => manifest;
61
+ it.each(["non-existing-key", "", null, "toString"])(
62
+ "should throw before generating a manifest for invalid extend key %p",
63
+ (extend) => {
64
+ const manifestFactory = jest.fn();
64
65
 
65
- const currentValue = createConfig(manifestFactory, {
66
- extend: "non-existing-key",
67
- })({});
66
+ expect(() => createConfig(manifestFactory, { extend })({})).toThrow(
67
+ `Requested key "${extend}" doesn't exist in the default configuration`
68
+ );
68
69
 
69
- expect(currentValue).toBe(manifest);
70
+ expect(manifestFactory).not.toHaveBeenCalled();
71
+ }
72
+ );
73
+
74
+ it("should leave the manifest unchanged when extend is undefined", () => {
75
+ const manifest = { identifier: "test" };
76
+
77
+ expect(createConfig(() => manifest, { extend: undefined })({})).toBe(
78
+ manifest
79
+ );
70
80
  });
71
81
 
72
82
  it("should pass the props to the manifest generator", () => {
@@ -1,4 +1,3 @@
1
- const R = require("ramda");
2
1
  const { defaultConfigurations } = require("../defaultManifestConfigurations");
3
2
 
4
3
  /**
@@ -9,20 +8,19 @@ const { defaultConfigurations } = require("../defaultManifestConfigurations");
9
8
  * @param {string} options.platform qb platform value
10
9
  */
11
10
  function getDefaultConfiguration(pluginType, options) {
12
- const defConfig = R.compose(
13
- R.unless(R.isNil, (fn) => fn(options)),
14
- R.propOr(null, pluginType)
15
- )(defaultConfigurations);
11
+ if (pluginType === undefined) return null;
16
12
 
17
- if (!defConfig) {
18
- const availableKeys = R.keys(defaultConfigurations);
13
+ if (
14
+ !Object.prototype.hasOwnProperty.call(defaultConfigurations, pluginType)
15
+ ) {
16
+ const availableKeys = Object.keys(defaultConfigurations);
19
17
 
20
- const message = `Requested key "${pluginType}" doesn't exist in the default configuration\nAvailable keys: ${availableKeys}`;
21
- // eslint-disable-next-line no-console
22
- console.warn(message);
18
+ throw new Error(
19
+ `Requested key "${pluginType}" doesn't exist in the default configuration\nAvailable keys: ${availableKeys}`
20
+ );
23
21
  }
24
22
 
25
- return defConfig;
23
+ return defaultConfigurations[pluginType](options);
26
24
  }
27
25
 
28
26
  module.exports = { getDefaultConfiguration };
@@ -830,6 +830,14 @@ function getPlayerConfiguration({ platform, version }) {
830
830
  type: "switch",
831
831
  label_tooltip:
832
832
  "Enable this option to have a floating video player when the app is in the background.",
833
+ },
834
+ {
835
+ key: "vertical_video_player",
836
+ label: "Vertical video mode",
837
+ initial_value: false,
838
+ type: "switch",
839
+ label_tooltip:
840
+ "Enable this option to use the vertical video player layout.",
833
841
  }
834
842
  );
835
843
 
@@ -412,6 +412,12 @@ const mobileActionButtonContainerFields = (positionOptions) => [
412
412
  type: ZAPPIFEST_FIELDS.switch,
413
413
  suffix: "buttons enabled",
414
414
  },
415
+ {
416
+ type: ZAPPIFEST_FIELDS.switch,
417
+ suffix: "cell navigation enabled",
418
+ label_tooltip:
419
+ "Controls whether tapping on the cell (outside the buttons) triggers its navigation behavior. When disabled, only the configured buttons are interactive. Useful for Home screens (tap anywhere to open) vs. Details screens (only buttons should work).",
420
+ },
415
421
  {
416
422
  type: ZAPPIFEST_FIELDS.select,
417
423
  suffix: "position",
@@ -472,14 +478,13 @@ const MOBILE_ACTION_BUTTON_FIELDS = [
472
478
  suffix: "assign action",
473
479
  options: [
474
480
  { text: "primary navigation", value: "navigation_action" },
475
- { text: "secondary navigation", value: "secondary_navigation" },
476
481
  { text: "favorite", value: "local_storage_favourites_action" },
477
482
  { text: "more", value: "open-modal-bottom-sheet-cell-action" },
478
483
  { text: "add to calendar", value: "add_to_calendar_action" },
479
484
  { text: "share", value: "native_share_action" },
480
485
  { text: "downloads", value: "offline-content-button" },
481
486
  { text: "trailer", value: "trailer_action" },
482
- { text: "mute/unmute", value: "mute_unmute" },
487
+ { text: "mute/unmute", value: "mute_unmute_action" },
483
488
  ],
484
489
  },
485
490
  {