@applicaster/zapp-react-native-utils 15.0.0-alpha.1966607451 → 15.0.0-alpha.1969561484

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 (128) hide show
  1. package/README.md +0 -6
  2. package/actionsExecutor/ActionExecutorContext.tsx +83 -6
  3. package/adsUtils/__tests__/createVMAP.test.ts +419 -0
  4. package/analyticsUtils/analyticsMapper.ts +10 -2
  5. package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
  6. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
  7. package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
  8. package/appUtils/HooksManager/index.ts +35 -0
  9. package/appUtils/RiverFocusManager/{index.js → index.ts} +25 -18
  10. package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +7 -2
  11. package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +48 -0
  12. package/appUtils/contextKeysManager/contextResolver.ts +51 -22
  13. package/appUtils/contextKeysManager/index.ts +65 -10
  14. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +3 -0
  15. package/appUtils/focusManager/index.ios.ts +35 -2
  16. package/appUtils/focusManager/treeDataStructure/Tree/__tests__/Tree.test.js +46 -0
  17. package/appUtils/focusManager/treeDataStructure/Tree/index.js +18 -18
  18. package/appUtils/focusManagerAux/utils/index.ios.ts +122 -0
  19. package/appUtils/focusManagerAux/utils/index.ts +2 -4
  20. package/appUtils/focusManagerAux/utils/utils.ios.ts +61 -4
  21. package/appUtils/localizationsHelper.ts +4 -0
  22. package/appUtils/playerManager/index.ts +9 -0
  23. package/appUtils/playerManager/player.ts +1 -1
  24. package/appUtils/playerManager/playerNative.ts +2 -1
  25. package/appUtils/playerManager/usePlayer.tsx +5 -3
  26. package/cloudEventsUtils/__tests__/index.test.ts +529 -0
  27. package/cloudEventsUtils/index.ts +65 -1
  28. package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +38 -0
  29. package/configurationUtils/index.ts +17 -11
  30. package/dateUtils/__tests__/dayjs.test.ts +330 -0
  31. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
  32. package/errorUtils/__tests__/GeneralError.test.ts +97 -0
  33. package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
  34. package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
  35. package/errorUtils/__tests__/NetworkError.test.ts +202 -0
  36. package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
  37. package/errorUtils/__tests__/invariant.test.ts +112 -0
  38. package/headersUtils/__tests__/headersUtils.test.js +11 -1
  39. package/headersUtils/index.ts +2 -1
  40. package/manifestUtils/_internals/__tests__/index.test.js +41 -0
  41. package/manifestUtils/_internals/index.js +33 -0
  42. package/manifestUtils/defaultManifestConfigurations/player.js +42 -7
  43. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +49 -0
  44. package/manifestUtils/fieldUtils/index.js +54 -0
  45. package/manifestUtils/index.js +2 -0
  46. package/manifestUtils/keys.js +228 -0
  47. package/manifestUtils/mobileAction/button/__tests__/mobileActionButton.test.js +168 -0
  48. package/manifestUtils/mobileAction/button/index.js +140 -0
  49. package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +102 -0
  50. package/manifestUtils/mobileAction/container/index.js +73 -0
  51. package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +127 -0
  52. package/manifestUtils/mobileAction/groups/defaults.js +76 -0
  53. package/manifestUtils/mobileAction/groups/index.js +80 -0
  54. package/manifestUtils/platformIsTV.js +13 -0
  55. package/navigationUtils/index.ts +15 -5
  56. package/numberUtils/__tests__/toNumber.test.ts +27 -0
  57. package/numberUtils/__tests__/toPositiveNumber.test.ts +193 -0
  58. package/numberUtils/index.ts +23 -1
  59. package/package.json +4 -4
  60. package/pluginUtils/index.ts +4 -5
  61. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
  62. package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
  63. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  64. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -2
  65. package/reactHooks/cell-click/__tests__/index.test.js +1 -3
  66. package/reactHooks/cell-click/index.ts +2 -1
  67. package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
  68. package/reactHooks/connection/__tests__/index.test.js +1 -1
  69. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
  70. package/reactHooks/device/useIsTablet.tsx +14 -19
  71. package/reactHooks/events/index.ts +20 -0
  72. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +32 -23
  73. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
  74. package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +1 -1
  75. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +42 -30
  76. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +1 -1
  77. package/reactHooks/feed/index.ts +0 -2
  78. package/reactHooks/feed/useInflatedUrl.ts +1 -1
  79. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +12 -8
  80. package/reactHooks/index.ts +2 -0
  81. package/reactHooks/layout/__tests__/index.test.tsx +1 -1
  82. package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
  83. package/reactHooks/navigation/__tests__/index.test.tsx +40 -9
  84. package/reactHooks/navigation/index.ts +19 -4
  85. package/reactHooks/navigation/useRoute.ts +3 -1
  86. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
  87. package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
  88. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
  89. package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
  90. package/reactHooks/resolvers/useComponentResolver.ts +13 -3
  91. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
  92. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
  93. package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
  94. package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +2 -2
  95. package/reactHooks/state/__tests__/useComponentScreenState.test.ts +246 -0
  96. package/reactHooks/state/index.ts +2 -0
  97. package/reactHooks/state/useComponentScreenState.ts +45 -0
  98. package/reactHooks/state/useRefWithInitialValue.ts +10 -0
  99. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
  100. package/reactHooks/utils/__tests__/index.test.js +1 -1
  101. package/rectUtils/__tests__/index.test.ts +549 -0
  102. package/rectUtils/index.ts +2 -2
  103. package/refreshUtils/RefreshCoordinator/__tests__/refreshCoordinator.test.ts +161 -0
  104. package/refreshUtils/RefreshCoordinator/index.ts +216 -0
  105. package/refreshUtils/RefreshCoordinator/utils/__tests__/getDataRefreshConfig.test.ts +104 -0
  106. package/refreshUtils/RefreshCoordinator/utils/index.ts +29 -0
  107. package/screenPickerUtils/__tests__/index.test.ts +333 -0
  108. package/screenPickerUtils/index.ts +5 -0
  109. package/screenState/__tests__/index.test.ts +1 -1
  110. package/screenUtils/index.ts +3 -0
  111. package/searchUtils/const.ts +7 -0
  112. package/searchUtils/index.ts +3 -0
  113. package/services/storageServiceSync.web.ts +1 -1
  114. package/stringUtils/index.ts +1 -1
  115. package/testUtils/index.tsx +1 -1
  116. package/time/__tests__/BackgroundTimer.test.ts +156 -0
  117. package/time/__tests__/Timer.test.ts +236 -0
  118. package/typeGuards/__tests__/isString.test.ts +21 -0
  119. package/typeGuards/index.ts +4 -0
  120. package/utils/__tests__/clone.test.ts +158 -0
  121. package/utils/__tests__/mergeRight.test.ts +48 -0
  122. package/utils/__tests__/path.test.ts +7 -0
  123. package/utils/clone.ts +7 -0
  124. package/utils/index.ts +5 -1
  125. package/utils/mergeRight.ts +5 -0
  126. package/reactHooks/componentsMap/index.ts +0 -55
  127. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +0 -75
  128. package/reactHooks/feed/useFeedRefresh.tsx +0 -65
@@ -0,0 +1,188 @@
1
+ import { getParsedResponse } from "../index";
2
+ import { RESPONSES } from "../errorCodes";
3
+
4
+ describe("getParsedResponse", () => {
5
+ it("should parse error with response status code from response.data", () => {
6
+ const err = {
7
+ response: {
8
+ data: {
9
+ statusCode: 404,
10
+ message: "Resource not found",
11
+ },
12
+ config: {
13
+ url: "https://api.example.com/data",
14
+ params: { id: 123 },
15
+ },
16
+ },
17
+ name: "AxiosError",
18
+ context: { userId: "user123" },
19
+ };
20
+
21
+ const result = getParsedResponse(err);
22
+
23
+ expect(result.message).toBe("Error: Resource not found");
24
+ expect(result.data.statusCode).toBe("404");
25
+ expect(result.data.url).toBe("https://api.example.com/data");
26
+ expect(result.data.params).toEqual({ id: 123 });
27
+ expect(result.data.context).toEqual({ userId: "user123" });
28
+ expect(result.data.name).toBe("AxiosError");
29
+ expect(result.jsOnly).toBe(false);
30
+ expect(result.exception).toBe(result.message);
31
+ });
32
+
33
+ it("should parse error with response status code from response.status", () => {
34
+ const err = {
35
+ response: {
36
+ status: 500,
37
+ config: {
38
+ url: "https://api.example.com/data",
39
+ },
40
+ },
41
+ };
42
+
43
+ const result = getParsedResponse(err);
44
+
45
+ expect(result.message).toBe(`Error: ${RESPONSES[500]}`);
46
+ expect(result.data.statusCode).toBe("500");
47
+ });
48
+
49
+ it("should handle error with request but no response", () => {
50
+ const err = {
51
+ request: {},
52
+ message: "Network timeout",
53
+ config: {
54
+ url: "https://api.example.com/data",
55
+ params: { test: "value" },
56
+ },
57
+ name: "NetworkError",
58
+ context: { app: "test" },
59
+ };
60
+
61
+ const result = getParsedResponse(err);
62
+
63
+ expect(result.message).toBe("Error: Network timeout");
64
+ expect(result.data.url).toBe("https://api.example.com/data");
65
+ expect(result.data.params).toEqual({ test: "value" });
66
+ expect(result.data.name).toBe("NetworkError");
67
+ expect(result.data.context).toEqual({ app: "test" });
68
+ expect(result.jsOnly).toBe(false);
69
+ });
70
+
71
+ it("should handle error with request but no response and no message", () => {
72
+ const err = {
73
+ request: {},
74
+ config: {
75
+ url: "https://api.example.com/data",
76
+ },
77
+ };
78
+
79
+ const result = getParsedResponse(err);
80
+
81
+ expect(result.message).toBe(`Error: ${RESPONSES.noResponse}`);
82
+ });
83
+
84
+ it("should handle error with neither response nor request", () => {
85
+ const err = {
86
+ message: "Failed to set up request",
87
+ config: {
88
+ url: "https://api.example.com/data",
89
+ },
90
+ };
91
+
92
+ const result = getParsedResponse(err);
93
+
94
+ expect(result.message).toBe("Error: Failed to set up request");
95
+ });
96
+
97
+ it("should handle error with neither response nor request and no message", () => {
98
+ const err = {
99
+ config: {
100
+ url: "https://api.example.com/data",
101
+ },
102
+ };
103
+
104
+ const result = getParsedResponse(err);
105
+
106
+ expect(result.message).toBe(`Error: ${RESPONSES.unknown}`);
107
+ });
108
+
109
+ it("should handle null error", () => {
110
+ const err = null;
111
+
112
+ const result = getParsedResponse(err);
113
+
114
+ expect(result.message).toBe(`Error: ${RESPONSES.unknown}`);
115
+
116
+ expect(result.data).toEqual({
117
+ context: undefined,
118
+ name: undefined,
119
+ params: undefined,
120
+ url: undefined,
121
+ });
122
+ });
123
+
124
+ it("should handle undefined error", () => {
125
+ const err = undefined;
126
+
127
+ const result = getParsedResponse(err);
128
+
129
+ expect(result.message).toBe(`Error: ${RESPONSES.unknown}`);
130
+ });
131
+
132
+ it("should extract params from err.config when response is not present", () => {
133
+ const err = {
134
+ request: {},
135
+ message: "Request failed",
136
+ config: {
137
+ url: "https://api.example.com/data",
138
+ params: { key: "value" },
139
+ },
140
+ };
141
+
142
+ const result = getParsedResponse(err);
143
+
144
+ expect(result.data.params).toEqual({ key: "value" });
145
+ expect(result.data.url).toBe("https://api.example.com/data");
146
+ });
147
+
148
+ it("should prioritize response config over error config", () => {
149
+ const err = {
150
+ response: {
151
+ status: 404,
152
+ config: {
153
+ url: "https://api.example.com/response-url",
154
+ params: { from: "response" },
155
+ },
156
+ },
157
+ config: {
158
+ url: "https://api.example.com/error-url",
159
+ params: { from: "error" },
160
+ },
161
+ };
162
+
163
+ const result = getParsedResponse(err);
164
+
165
+ expect(result.data.url).toBe("https://api.example.com/response-url");
166
+ expect(result.data.params).toEqual({ from: "response" });
167
+ });
168
+
169
+ it("should handle response with custom status codes", () => {
170
+ const err = {
171
+ response: {
172
+ data: {
173
+ statusCode: 418,
174
+ message: "I'm a teapot",
175
+ },
176
+ status: 418,
177
+ config: {
178
+ url: "https://api.example.com/coffee",
179
+ },
180
+ },
181
+ };
182
+
183
+ const result = getParsedResponse(err);
184
+
185
+ expect(result.message).toBe("Error: I'm a teapot");
186
+ expect(result.data.statusCode).toBe("418");
187
+ });
188
+ });
@@ -0,0 +1,112 @@
1
+ import { invariant } from "../index";
2
+
3
+ // Mock __DEV__ global
4
+ declare global {
5
+ var __DEV__: boolean;
6
+ }
7
+
8
+ describe("invariant", () => {
9
+ const originalDev = global.__DEV__;
10
+
11
+ afterEach(() => {
12
+ global.__DEV__ = originalDev;
13
+ });
14
+
15
+ describe("in development mode", () => {
16
+ beforeEach(() => {
17
+ global.__DEV__ = true;
18
+ });
19
+
20
+ it("should not throw when condition is true", () => {
21
+ expect(() => {
22
+ invariant(true, "This should not throw");
23
+ }).not.toThrow();
24
+ });
25
+
26
+ it("should throw when condition is false", () => {
27
+ expect(() => {
28
+ invariant(false, "This should throw");
29
+ }).toThrow("This should throw");
30
+ });
31
+
32
+ it("should throw with correct error message", () => {
33
+ const errorMessage = "Custom error message";
34
+
35
+ expect(() => {
36
+ invariant(false, errorMessage);
37
+ }).toThrow(errorMessage);
38
+ });
39
+
40
+ it("should not throw when condition is truthy value", () => {
41
+ expect(() => {
42
+ invariant(1 as any, "Should not throw");
43
+ }).not.toThrow();
44
+
45
+ expect(() => {
46
+ invariant("string" as any, "Should not throw");
47
+ }).not.toThrow();
48
+
49
+ expect(() => {
50
+ invariant({} as any, "Should not throw");
51
+ }).not.toThrow();
52
+
53
+ expect(() => {
54
+ invariant([] as any, "Should not throw");
55
+ }).not.toThrow();
56
+ });
57
+
58
+ it("should throw when condition is falsy value", () => {
59
+ expect(() => {
60
+ invariant(0 as any, "Should throw for 0");
61
+ }).toThrow("Should throw for 0");
62
+
63
+ expect(() => {
64
+ invariant("" as any, "Should throw for empty string");
65
+ }).toThrow("Should throw for empty string");
66
+
67
+ expect(() => {
68
+ invariant(null as any, "Should throw for null");
69
+ }).toThrow("Should throw for null");
70
+
71
+ expect(() => {
72
+ invariant(undefined as any, "Should throw for undefined");
73
+ }).toThrow("Should throw for undefined");
74
+
75
+ expect(() => {
76
+ invariant(NaN as any, "Should throw for NaN");
77
+ }).toThrow("Should throw for NaN");
78
+ });
79
+ });
80
+
81
+ describe("in production mode", () => {
82
+ beforeEach(() => {
83
+ global.__DEV__ = false;
84
+ });
85
+
86
+ it("should not throw when condition is true", () => {
87
+ expect(() => {
88
+ invariant(true, "This should not throw");
89
+ }).not.toThrow();
90
+ });
91
+
92
+ it("should not throw when condition is false", () => {
93
+ expect(() => {
94
+ invariant(false, "This should not throw in production");
95
+ }).not.toThrow();
96
+ });
97
+
98
+ it("should not throw for any condition", () => {
99
+ expect(() => {
100
+ invariant(0 as any, "Should not throw in production");
101
+ }).not.toThrow();
102
+
103
+ expect(() => {
104
+ invariant(null as any, "Should not throw in production");
105
+ }).not.toThrow();
106
+
107
+ expect(() => {
108
+ invariant(undefined as any, "Should not throw in production");
109
+ }).not.toThrow();
110
+ });
111
+ });
112
+ });
@@ -1,6 +1,15 @@
1
1
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
2
2
  import { getAppDataHeaders } from "../index";
3
3
 
4
+ const mockUILanguage = "en-US";
5
+
6
+ jest.mock(
7
+ "@applicaster/zapp-react-native-utils/appUtils/localizationsHelper",
8
+ () => ({
9
+ getUILanguage: jest.fn(() => mockUILanguage),
10
+ })
11
+ );
12
+
4
13
  describe("getAppDataHeaders", () => {
5
14
  const mockAppData = {
6
15
  riversConfigurationId: "test-layout",
@@ -25,7 +34,7 @@ describe("getAppDataHeaders", () => {
25
34
  const expectedHeaders = {
26
35
  "x-applicaster-layout-id": mockAppData.riversConfigurationId,
27
36
  "x-applicaster-screen-id": screenId,
28
- "x-applicaster-language-code": mockAppData.languageCode,
37
+ "x-applicaster-language-code": mockUILanguage,
29
38
  "x-applicaster-version-number": mockAppData.version_name,
30
39
  "x-applicaster-platform": mockAppData.platform,
31
40
  "x-applicaster-country-code": mockAppData.countryCode,
@@ -33,6 +42,7 @@ describe("getAppDataHeaders", () => {
33
42
  mockAppData.signedDeviceInfoToken,
34
43
  "x-applicaster-device-make": mockAppData.deviceMake,
35
44
  "x-applicaster-device-model": mockAppData.deviceModel,
45
+ "x-applicaster-uuid": undefined,
36
46
  };
37
47
 
38
48
  const headers = getAppDataHeaders(screenId);
@@ -1,6 +1,7 @@
1
1
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
2
2
  import { getPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
3
3
  import { utilsLogger } from "../logger";
4
+ import { getUILanguage } from "../localizationUtils";
4
5
 
5
6
  const logger = utilsLogger.addSubsystem("headersUtils");
6
7
 
@@ -21,7 +22,7 @@ export const getAppDataHeaders = (screenId: string) => {
21
22
  "x-applicaster-layout-id":
22
23
  appData.riversConfigurationId || appData.rivers_configuration_id,
23
24
  "x-applicaster-screen-id": screenId,
24
- "x-applicaster-language-code": appData.languageCode,
25
+ "x-applicaster-language-code": getUILanguage(),
25
26
  "x-applicaster-version-number": appData.version_name || appData.versionName,
26
27
  "x-applicaster-platform": (platform || appData.platform).toLowerCase(),
27
28
  "x-applicaster-country-code": appData.countryCode,
@@ -0,0 +1,41 @@
1
+ const {
2
+ isKeyHasSuffix,
3
+ isKeyHasAnyOfSuffixes,
4
+ getKeyWithPrefixGenerator,
5
+ } = require("..");
6
+
7
+ describe("manifestUtils/_internals helpers", () => {
8
+ it("checks a key suffix", () => {
9
+ expect(
10
+ isKeyHasSuffix("button_enabled", "mobile_button_1_button_enabled")
11
+ ).toBe(true);
12
+
13
+ expect(
14
+ isKeyHasSuffix("button_enabled", "mobile_button_1_assign_action")
15
+ ).toBe(false);
16
+ });
17
+
18
+ it("checks key against multiple suffixes", () => {
19
+ const suffixes = ["font_color", "focused_font_color", "text_transform"];
20
+
21
+ expect(
22
+ isKeyHasAnyOfSuffixes(suffixes, "mobile_button_1_text_transform")
23
+ ).toBe(true);
24
+
25
+ expect(
26
+ isKeyHasAnyOfSuffixes(suffixes, "mobile_button_1_asset_alignment")
27
+ ).toBe(false);
28
+ });
29
+
30
+ it("generates stable key names using a prefix", () => {
31
+ const withMobileButtonPrefix = getKeyWithPrefixGenerator("mobile_button_2");
32
+
33
+ expect(withMobileButtonPrefix("display_mode")).toBe(
34
+ "mobile_button_2_display_mode"
35
+ );
36
+
37
+ expect(withMobileButtonPrefix("asset_enabled")).toBe(
38
+ "mobile_button_2_asset_enabled"
39
+ );
40
+ });
41
+ });
@@ -174,6 +174,36 @@ function generateFieldsFromDefaultsWithoutPrefixedLabel(
174
174
  )(fields);
175
175
  }
176
176
 
177
+ /**
178
+ * Checks whether a generated manifest field key ends with the given suffix.
179
+ *
180
+ * @param {string} suffix
181
+ * @param {string} key
182
+ * @returns {boolean}
183
+ */
184
+ const isKeyHasSuffix = (suffix, key) => key.endsWith(`_${suffix}`);
185
+
186
+ /**
187
+ * Checks whether a generated manifest field key ends with any supported suffix.
188
+ *
189
+ * @param {string[]} suffixes
190
+ * @param {string} key
191
+ * @returns {boolean}
192
+ */
193
+ const isKeyHasAnyOfSuffixes = (suffixes, key) =>
194
+ suffixes.some((suffix) => key.endsWith(`_${suffix}`));
195
+
196
+ /**
197
+ * Creates a helper that prefixes a manifest field suffix with a shared key stem.
198
+ *
199
+ * @param {string} prefix
200
+ * @returns {(suffix: string) => string}
201
+ */
202
+ function getKeyWithPrefixGenerator(prefix) {
203
+ // expect prefix as lower snake case, e.g. "mobile_buttons_container"
204
+ return (suffix) => `${prefix}_${suffix}`;
205
+ }
206
+
177
207
  module.exports = {
178
208
  toSnakeCase,
179
209
  toCamelCase,
@@ -185,4 +215,7 @@ module.exports = {
185
215
  getDefaultConfiguration,
186
216
  compact,
187
217
  replaceUnderscoreToSpace,
218
+ isKeyHasSuffix,
219
+ isKeyHasAnyOfSuffixes,
220
+ getKeyWithPrefixGenerator,
188
221
  };
@@ -123,6 +123,12 @@ function getPlayerConfiguration({ platform, version }) {
123
123
  key: "skip_button_localization_text_skip_intro",
124
124
  initial_value: "Skip Intro",
125
125
  },
126
+ {
127
+ type: "text_input",
128
+ label: "Stream error message",
129
+ key: "stream_error_message",
130
+ initial_value: "Cannot play stream",
131
+ },
126
132
  {
127
133
  type: "text_input",
128
134
  label: "Locked message",
@@ -331,6 +337,35 @@ function getPlayerConfiguration({ platform, version }) {
331
337
  label_tooltip: "Hint for skip intro button accessibility",
332
338
  type: "text_input",
333
339
  },
340
+ {
341
+ type: "text_input",
342
+ label: "Text Tracks Label",
343
+ key: "text_tracks_label",
344
+ initial_value: "Subtitles",
345
+ label_tooltip: "Label for the text tracks list",
346
+ },
347
+ {
348
+ type: "text_input",
349
+ label: "Audio Tracks Label",
350
+ key: "audio_tracks_label",
351
+ initial_value: "Audio",
352
+ label_tooltip: "Label for the audio tracks list",
353
+ },
354
+ {
355
+ type: "text_input",
356
+ label: "Off Track Label",
357
+ key: "off_track_label",
358
+ initial_value: "Off",
359
+ label_tooltip: "Label for the 'Off' option in text tracks list",
360
+ },
361
+ {
362
+ type: "text_input",
363
+ label: "Default Track Label",
364
+ key: "default_track_label",
365
+ initial_value: "Default",
366
+ label_tooltip:
367
+ "Label for the 'Default' audio track in audio tracks list",
368
+ },
334
369
  ],
335
370
  };
336
371
 
@@ -1196,49 +1231,49 @@ function getPlayerConfiguration({ platform, version }) {
1196
1231
  "Upload Assets Folder Zip File, expected format: pip_play, pip_pause, pip_seek_forward, pip_seek_backward",
1197
1232
  },
1198
1233
  {
1199
- key: "image_speed_0_8",
1234
+ key: "speed_0_8",
1200
1235
  label: "Playback Speed 0.8x",
1201
1236
  type: "uploader",
1202
1237
  label_tooltip: "Playback Speed 0.8x",
1203
1238
  initial_value: null,
1204
1239
  },
1205
1240
  {
1206
- key: "image_speed_1",
1241
+ key: "speed_1",
1207
1242
  label: "Playback Speed 1x",
1208
1243
  type: "uploader",
1209
1244
  label_tooltip: "Playback Speed 1x",
1210
1245
  initial_value: null,
1211
1246
  },
1212
1247
  {
1213
- key: "image_speed_1_2",
1248
+ key: "speed_1_2",
1214
1249
  label: "Playback Speed 1.2x",
1215
1250
  type: "uploader",
1216
1251
  label_tooltip: "Playback Speed 1.2x",
1217
1252
  initial_value: null,
1218
1253
  },
1219
1254
  {
1220
- key: "image_speed_1_5",
1255
+ key: "speed_1_5",
1221
1256
  label: "Playback Speed 1.5x",
1222
1257
  type: "uploader",
1223
1258
  label_tooltip: "Playback Speed 1.5x",
1224
1259
  initial_value: null,
1225
1260
  },
1226
1261
  {
1227
- key: "image_speed_2",
1262
+ key: "speed_2",
1228
1263
  label: "Playback Speed 2x",
1229
1264
  type: "uploader",
1230
1265
  label_tooltip: "Playback Speed 2x",
1231
1266
  initial_value: null,
1232
1267
  },
1233
1268
  {
1234
- key: "image_sleep_timer",
1269
+ key: "sleep_timer",
1235
1270
  label: "Sleep Timer Default",
1236
1271
  type: "uploader",
1237
1272
  label_tooltip: "Sleep Timer Default",
1238
1273
  initial_value: null,
1239
1274
  },
1240
1275
  {
1241
- key: "image_sleep_timer_active",
1276
+ key: "sleep_timer_active",
1242
1277
  label: "Sleep Timer Active",
1243
1278
  type: "uploader",
1244
1279
  label_tooltip: "Sleep Timer Active",
@@ -0,0 +1,49 @@
1
+ const {
2
+ withConditional,
3
+ getConditionalKey,
4
+ createConditionalField,
5
+ } = require("..");
6
+
7
+ describe("manifestUtils/fieldUtils", () => {
8
+ it("appends conditions and adds all_conditions when there is more than one condition", () => {
9
+ const config = {
10
+ key: "mobile_button_1_width",
11
+ conditional_fields: [
12
+ { key: "styles/mobile_button_1_button_enabled", condition_value: true },
13
+ ],
14
+ };
15
+
16
+ const result = withConditional([
17
+ { key: "styles/mobile_button_1_display_mode", condition_value: "fixed" },
18
+ ])(config);
19
+
20
+ expect(result.conditional_fields).toEqual([
21
+ { key: "styles/mobile_button_1_button_enabled", condition_value: true },
22
+ { key: "styles/mobile_button_1_display_mode", condition_value: "fixed" },
23
+ ]);
24
+
25
+ expect(result.rules).toBe("all_conditions");
26
+ });
27
+
28
+ it("creates category-prefixed conditional key", () => {
29
+ expect(
30
+ getConditionalKey("mobile_buttons_container_position", "styles")
31
+ ).toBe("styles/mobile_buttons_container_position");
32
+ });
33
+
34
+ it("creates conditional fields with default category and with raw key", () => {
35
+ expect(
36
+ createConditionalField("mobile_button_1_asset_enabled", true)
37
+ ).toEqual({
38
+ key: "styles/mobile_button_1_asset_enabled",
39
+ condition_value: true,
40
+ });
41
+
42
+ expect(
43
+ createConditionalField("mobile_button_1_asset_enabled", true, null)
44
+ ).toEqual({
45
+ key: "mobile_button_1_asset_enabled",
46
+ condition_value: true,
47
+ });
48
+ });
49
+ });
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Appends new conditional_fields from conditions array
3
+ * to config.conditional_fields
4
+ * if there are more than 1 condition, sets rules to "all_conditions"
5
+ *
6
+ * @param {Array<{key: string, condition_value: unknown}>} conditions
7
+ * @returns {(config: object) => object}
8
+ */
9
+ const withConditional = (conditions) => (config) => {
10
+ const conditional_fields = [
11
+ ...(config.conditional_fields || []),
12
+ ...conditions,
13
+ ];
14
+
15
+ const next = { ...config, conditional_fields };
16
+
17
+ if (conditional_fields.length > 1) {
18
+ return { ...next, rules: "all_conditions" };
19
+ }
20
+
21
+ return next;
22
+ };
23
+
24
+ /**
25
+ * Builds key for conditional fields prepending category, e.g. "styles/mobile_buttons_container_position"
26
+ *
27
+ * @param {string} key
28
+ * @param {string} category
29
+ * @returns {string}
30
+ */
31
+ function getConditionalKey(key, category) {
32
+ return `${category}/${key}`;
33
+ }
34
+
35
+ /**
36
+ * Returns a conditional field object for manifest visibility rules.
37
+ *
38
+ * @param {string} key
39
+ * @param {unknown} condition_value
40
+ * @param {string|null} [category="styles"] Pass `null` to use the key as-is.
41
+ * @returns {{key: string, condition_value: unknown}}
42
+ */
43
+ function createConditionalField(key, condition_value, category = "styles") {
44
+ return {
45
+ key: category ? getConditionalKey(key, category) : key,
46
+ condition_value,
47
+ };
48
+ }
49
+
50
+ module.exports = {
51
+ withConditional,
52
+ getConditionalKey,
53
+ createConditionalField,
54
+ };
@@ -8,6 +8,7 @@ const {
8
8
 
9
9
  const { tvActionButtonsContainer } = require("./tvAction/container");
10
10
  const { tvActionButton } = require("./tvAction/button");
11
+ const { buildMobileActionButtonGroups } = require("./mobileAction/groups");
11
12
  const { compact } = require("./_internals");
12
13
 
13
14
  const { spacingKey, absolutePositionElement } = require("./containers");
@@ -43,6 +44,7 @@ module.exports = {
43
44
  tvMenuLabel,
44
45
  tvActionButtonsContainer,
45
46
  tvActionButton,
47
+ buildMobileActionButtonGroups,
46
48
  mobileCellLabel,
47
49
  tvCellLabel,
48
50
  tvBadges,