@applicaster/zapp-react-native-utils 14.0.0-rc.12 → 14.0.0-rc.14
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/conf/player/__tests__/selectors.test.ts +34 -0
- package/conf/player/selectors.ts +10 -0
- package/manifestUtils/_internals/getDefaultConfiguration.js +28 -0
- package/manifestUtils/{_internals.js → _internals/index.js} +2 -25
- package/manifestUtils/createConfig.js +4 -1
- package/manifestUtils/defaultManifestConfigurations/player.js +1231 -200
- package/manifestUtils/progressBar/__tests__/mobileProgressBar.test.js +0 -30
- package/package.json +2 -2
- package/playerUtils/__tests__/configurationUtils.test.ts +1 -65
- package/playerUtils/__tests__/getPlayerActionButtons.test.ts +54 -0
- package/playerUtils/_internals/__tests__/utils.test.ts +71 -0
- package/playerUtils/_internals/index.ts +1 -0
- package/playerUtils/_internals/utils.ts +31 -0
- package/playerUtils/configurationUtils.ts +0 -44
- package/playerUtils/getPlayerActionButtons.ts +17 -0
- package/playerUtils/index.ts +2 -0
- package/playerUtils/useValidatePlayerConfig.tsx +22 -19
- package/reactHooks/feed/useBatchLoading.ts +2 -2
- package/utils/index.ts +3 -0
- package/playerUtils/configurationGenerator.ts +0 -2572
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { selectActionButtons } from "@applicaster/zapp-react-native-utils/conf/player/selectors";
|
|
2
|
+
|
|
3
|
+
describe("selectActionButtons", () => {
|
|
4
|
+
it("returns the player_action_buttons array if present", () => {
|
|
5
|
+
const pluginConf = {
|
|
6
|
+
player_action_buttons: [
|
|
7
|
+
{ id: "like", label: "Like" },
|
|
8
|
+
{ id: "share", label: "Share" },
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
expect(selectActionButtons(pluginConf)).toEqual(
|
|
13
|
+
pluginConf.player_action_buttons
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("returns null if player_action_buttons is not present", () => {
|
|
18
|
+
const pluginConf = { some_other_key: [] };
|
|
19
|
+
expect(selectActionButtons(pluginConf)).toBeNull();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("returns null if pluginConf is undefined", () => {
|
|
23
|
+
expect(selectActionButtons(undefined)).toBeNull();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("returns null if pluginConf is null", () => {
|
|
27
|
+
expect(selectActionButtons(null)).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("returns null if player_action_buttons is explicitly set to null", () => {
|
|
31
|
+
const pluginConf = { player_action_buttons: null };
|
|
32
|
+
expect(selectActionButtons(pluginConf)).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { get } from "@applicaster/zapp-react-native-utils/utils";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Selects the action buttons from the player configuration.
|
|
5
|
+
* @param {Object} pluginConf - player plugin config
|
|
6
|
+
* @returns {Array|null} An array of action buttons or null if not found.
|
|
7
|
+
*/
|
|
8
|
+
export const selectActionButtons = (pluginConf: any) => {
|
|
9
|
+
return get(pluginConf, "player_action_buttons", null);
|
|
10
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const R = require("ramda");
|
|
2
|
+
const { defaultConfigurations } = require("../defaultManifestConfigurations");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* returns default configuration keys for provided plugin type
|
|
6
|
+
* @param {('general-content'|'player')} pluginType
|
|
7
|
+
* @param options manifest generator information
|
|
8
|
+
* @param {string} options.version manifest version
|
|
9
|
+
* @param {string} options.platform qb platform value
|
|
10
|
+
*/
|
|
11
|
+
function getDefaultConfiguration(pluginType, options) {
|
|
12
|
+
const defConfig = R.compose(
|
|
13
|
+
R.unless(R.isNil, (fn) => fn(options)),
|
|
14
|
+
R.propOr(null, pluginType)
|
|
15
|
+
)(defaultConfigurations);
|
|
16
|
+
|
|
17
|
+
if (!defConfig) {
|
|
18
|
+
const availableKeys = R.keys(defaultConfigurations);
|
|
19
|
+
|
|
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);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return defConfig;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = { getDefaultConfiguration };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const R = require("ramda");
|
|
2
2
|
const camelize = require("camelize");
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
const { getDefaultConfiguration } = require("./getDefaultConfiguration");
|
|
4
5
|
|
|
5
6
|
const toSnakeCase = R.compose(R.replace(/\s/g, "_"), R.toLower, R.trim);
|
|
6
7
|
|
|
@@ -173,30 +174,6 @@ function generateFieldsFromDefaultsWithoutPrefixedLabel(
|
|
|
173
174
|
)(fields);
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
/**
|
|
177
|
-
* returns default configuration keys for provided plugin type
|
|
178
|
-
* @param {('general-content'|'player')} pluginType
|
|
179
|
-
* @param options manifest generator information
|
|
180
|
-
* @param {string} options.version manifest version
|
|
181
|
-
* @param {string} options.platform qb platform value
|
|
182
|
-
*/
|
|
183
|
-
function getDefaultConfiguration(pluginType, options) {
|
|
184
|
-
const defConfig = R.compose(
|
|
185
|
-
R.unless(R.isNil, (fn) => fn(options)),
|
|
186
|
-
R.propOr(null, pluginType)
|
|
187
|
-
)(defaultConfigurations);
|
|
188
|
-
|
|
189
|
-
if (!defConfig) {
|
|
190
|
-
const availableKeys = R.keys(defaultConfigurations);
|
|
191
|
-
|
|
192
|
-
const message = `Requested key "${pluginType}" doesn't exist in the default configuration\nAvailable keys: ${availableKeys}`;
|
|
193
|
-
// eslint-disable-next-line no-console
|
|
194
|
-
console.warn(message);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return defConfig;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
177
|
module.exports = {
|
|
201
178
|
toSnakeCase,
|
|
202
179
|
toCamelCase,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const R = require("ramda");
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
getDefaultConfiguration,
|
|
5
|
+
} = require("./_internals/getDefaultConfiguration");
|
|
3
6
|
|
|
4
7
|
const indexByKey = R.indexBy((obj) => R.prop(obj.group ? "label" : "key", obj));
|
|
5
8
|
const propIfExist = R.curry((prop) => R.when(R.prop(prop), R.prop(prop)));
|