@applicaster/zapp-react-native-utils 14.0.0-alpha.1235043154 → 14.0.0-alpha.1355728993
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/analyticsUtils/AnalyticsEvents/sendHeaderClickEvent.ts +1 -1
- package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +1 -2
- package/analyticsUtils/index.tsx +4 -3
- package/analyticsUtils/manager.ts +1 -1
- package/arrayUtils/__tests__/isFilledArray.test.ts +1 -1
- package/arrayUtils/index.ts +2 -7
- package/configurationUtils/__tests__/configurationUtils.test.js +31 -0
- package/configurationUtils/index.ts +34 -63
- package/manifestUtils/{_internals/index.js → _internals.js} +25 -2
- package/manifestUtils/createConfig.js +1 -4
- package/manifestUtils/defaultManifestConfigurations/player.js +200 -1231
- package/manifestUtils/progressBar/__tests__/mobileProgressBar.test.js +30 -0
- package/package.json +2 -2
- package/playerUtils/__tests__/configurationUtils.test.ts +65 -1
- package/playerUtils/configurationGenerator.ts +2572 -0
- package/playerUtils/configurationUtils.ts +44 -0
- package/playerUtils/index.ts +51 -2
- package/playerUtils/useValidatePlayerConfig.tsx +19 -22
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +13 -12
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +88 -39
- package/reactHooks/feed/useBatchLoading.ts +2 -2
- package/reactHooks/navigation/index.ts +2 -2
- package/testUtils/index.tsx +8 -7
- package/utils/index.ts +1 -12
- package/arrayUtils/__tests__/isEmptyArray.test.ts +0 -63
- package/audioPlayerUtils/__tests__/getArtworkImage.test.ts +0 -144
- package/audioPlayerUtils/__tests__/getBackgroundImage.test.ts +0 -72
- package/audioPlayerUtils/__tests__/getImageFromEntry.test.ts +0 -110
- package/audioPlayerUtils/assets/index.ts +0 -2
- package/audioPlayerUtils/index.ts +0 -242
- package/conf/player/__tests__/selectors.test.ts +0 -34
- package/conf/player/selectors.ts +0 -10
- package/configurationUtils/__tests__/getMediaItems.test.ts +0 -65
- package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +0 -34
- package/manifestUtils/_internals/getDefaultConfiguration.js +0 -28
- package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
- package/playerUtils/_internals/__tests__/utils.test.ts +0 -71
- package/playerUtils/_internals/index.ts +0 -1
- package/playerUtils/_internals/utils.ts +0 -31
- package/playerUtils/getPlayerActionButtons.ts +0 -17
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { getMediaItems } from "..";
|
|
2
|
-
import { entry as baseEntry } from "./testEntry";
|
|
3
|
-
|
|
4
|
-
describe("getMediaItems", () => {
|
|
5
|
-
it("returns both image and thumbnail media items", () => {
|
|
6
|
-
const items = getMediaItems(baseEntry);
|
|
7
|
-
expect(items).toHaveLength(2);
|
|
8
|
-
expect(items[0].key).toBe("image_base");
|
|
9
|
-
expect(items[1].key).toBe("logo_thumbnail");
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("returns only image media items if no thumbnail present", () => {
|
|
13
|
-
const entry = {
|
|
14
|
-
...baseEntry,
|
|
15
|
-
media_group: [
|
|
16
|
-
{
|
|
17
|
-
type: "image",
|
|
18
|
-
media_item: [
|
|
19
|
-
{ key: "image_base", src: "img.png" },
|
|
20
|
-
{ key: "other", src: "other.png" },
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const items = getMediaItems(entry);
|
|
27
|
-
expect(items).toHaveLength(2);
|
|
28
|
-
expect(items[0].key).toBe("image_base");
|
|
29
|
-
expect(items[1].key).toBe("other");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("returns only thumbnail media items if no image present", () => {
|
|
33
|
-
const entry = {
|
|
34
|
-
...baseEntry,
|
|
35
|
-
media_group: [
|
|
36
|
-
{
|
|
37
|
-
type: "thumbnail",
|
|
38
|
-
media_item: [{ key: "thumb1", src: "thumb1.png" }],
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const items = getMediaItems(entry);
|
|
44
|
-
expect(items).toHaveLength(1);
|
|
45
|
-
expect(items[0].key).toBe("thumb1");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("returns undefined if no media_group present", () => {
|
|
49
|
-
const entry = { ...baseEntry };
|
|
50
|
-
delete entry.media_group;
|
|
51
|
-
expect(getMediaItems(entry)).toBeUndefined();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("returns undefined if media_group is present but has no image or thumbnail", () => {
|
|
55
|
-
const entry = {
|
|
56
|
-
...baseEntry,
|
|
57
|
-
media_group: [
|
|
58
|
-
{ type: "audio", media_item: [{ key: "audio1", src: "audio1.mp3" }] },
|
|
59
|
-
],
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const items = getMediaItems(entry);
|
|
63
|
-
expect(items).toBeUndefined();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
|
-
import { imageSrcFromMediaItem } from "../";
|
|
3
|
-
import { entry } from "./testEntry";
|
|
4
|
-
|
|
5
|
-
describe("imageSrcFromMediaItem", () => {
|
|
6
|
-
it("when the matching key is found and the src is not empty", () => {
|
|
7
|
-
const result = imageSrcFromMediaItem(entry as ZappEntry, [
|
|
8
|
-
"logo_thumbnail",
|
|
9
|
-
]);
|
|
10
|
-
|
|
11
|
-
expect(result).toEqual(entry.media_group[1].media_item[0].src);
|
|
12
|
-
expect(result).not.toEqual("");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("returns a media item with the 'image_base' key as a fallback", () => {
|
|
16
|
-
const result = imageSrcFromMediaItem(entry as ZappEntry, [
|
|
17
|
-
"does_not_exist",
|
|
18
|
-
]);
|
|
19
|
-
|
|
20
|
-
const fallback = entry.media_group[0].media_item[0];
|
|
21
|
-
expect(result).toEqual(fallback.src);
|
|
22
|
-
expect(fallback.key).toBe("image_base");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("returns undefined if the key was found but the source was empty", () => {
|
|
26
|
-
const badEntry: ZappEntry = R.set(
|
|
27
|
-
R.lensPath(["media_group", 0, "media_item", 0, "src"]),
|
|
28
|
-
"",
|
|
29
|
-
entry
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
expect(imageSrcFromMediaItem(badEntry, ["image_base"])).toBeUndefined();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
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,54 +0,0 @@
|
|
|
1
|
-
import { getPlayerActionButtons } from "../getPlayerActionButtons";
|
|
2
|
-
import { selectActionButtons } from "../../conf/player/selectors";
|
|
3
|
-
|
|
4
|
-
jest.mock("../../conf/player/selectors", () => ({
|
|
5
|
-
selectActionButtons: jest.fn(),
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
describe("getPlayerActionButtons", () => {
|
|
9
|
-
afterEach(() => {
|
|
10
|
-
jest.clearAllMocks();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("returns an empty array if selectActionButtons returns undefined", () => {
|
|
14
|
-
(selectActionButtons as jest.Mock).mockReturnValue(undefined);
|
|
15
|
-
const result = getPlayerActionButtons({});
|
|
16
|
-
expect(result).toEqual([]);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("returns an empty array if selectActionButtons returns null", () => {
|
|
20
|
-
(selectActionButtons as jest.Mock).mockReturnValue(null);
|
|
21
|
-
const result = getPlayerActionButtons({});
|
|
22
|
-
expect(result).toEqual([]);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("returns an empty array if selectActionButtons returns empty string", () => {
|
|
26
|
-
(selectActionButtons as jest.Mock).mockReturnValue("");
|
|
27
|
-
const result = getPlayerActionButtons({});
|
|
28
|
-
expect(result).toEqual([]);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("returns the first two trimmed action buttons", () => {
|
|
32
|
-
(selectActionButtons as jest.Mock).mockReturnValue(" play , pause , stop ");
|
|
33
|
-
const result = getPlayerActionButtons({});
|
|
34
|
-
expect(result).toEqual(["play", "pause"]);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("returns only one button if only one is present", () => {
|
|
38
|
-
(selectActionButtons as jest.Mock).mockReturnValue(" play ");
|
|
39
|
-
const result = getPlayerActionButtons({});
|
|
40
|
-
expect(result).toEqual(["play"]);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("trims whitespace from button names", () => {
|
|
44
|
-
(selectActionButtons as jest.Mock).mockReturnValue(" play , pause ");
|
|
45
|
-
const result = getPlayerActionButtons({});
|
|
46
|
-
expect(result).toEqual(["play", "pause"]);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("returns an empty array if selectActionButtons returns only commas", () => {
|
|
50
|
-
(selectActionButtons as jest.Mock).mockReturnValue(" , , ");
|
|
51
|
-
const result = getPlayerActionButtons({});
|
|
52
|
-
expect(result).toEqual(["", ""]);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { getAllFields, getConfigurationDiff } from "../utils";
|
|
2
|
-
|
|
3
|
-
describe("getAllFields", () => {
|
|
4
|
-
it("should return all field keys from flat configs", () => {
|
|
5
|
-
const config1 = {
|
|
6
|
-
fields: [{ key: "foo" }, { key: "bar" }],
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const config2 = {
|
|
10
|
-
fields: [{ key: "baz" }],
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
expect(getAllFields(config1, config2)).toEqual(["foo", "bar", "baz"]);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("should handle grouped fields", () => {
|
|
17
|
-
const config = {
|
|
18
|
-
fields: [
|
|
19
|
-
{
|
|
20
|
-
group: true,
|
|
21
|
-
fields: [{ key: "grouped1" }, { key: "grouped2" }],
|
|
22
|
-
},
|
|
23
|
-
{ key: "single" },
|
|
24
|
-
],
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
expect(getAllFields(config)).toEqual(["grouped1", "grouped2", "single"]);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("should filter out fields without a key", () => {
|
|
31
|
-
const config = {
|
|
32
|
-
fields: [{ key: "foo" }, { notAKey: "bar" }],
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
expect(getAllFields(config)).toEqual(["foo"]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("should return an empty array if no fields are present", () => {
|
|
39
|
-
expect(getAllFields({})).toEqual([]);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe("getConfigurationDiff", () => {
|
|
44
|
-
it("should return keys in defaultConfig not present in config", () => {
|
|
45
|
-
const defaultConfig = ["foo", "bar", "baz"];
|
|
46
|
-
const config = { foo: 1, baz: 2 };
|
|
47
|
-
|
|
48
|
-
expect(getConfigurationDiff(defaultConfig, config)).toEqual(["bar"]);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("should return all keys if config is empty", () => {
|
|
52
|
-
const defaultConfig = ["foo", "bar"];
|
|
53
|
-
const config = {};
|
|
54
|
-
|
|
55
|
-
expect(getConfigurationDiff(defaultConfig, config)).toEqual(["foo", "bar"]);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should return an empty array if all keys are present", () => {
|
|
59
|
-
const defaultConfig = ["foo"];
|
|
60
|
-
const config = { foo: 1 };
|
|
61
|
-
|
|
62
|
-
expect(getConfigurationDiff(defaultConfig, config)).toEqual([]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("should return defaultConfig if config has no matching keys", () => {
|
|
66
|
-
const defaultConfig = ["foo", "bar"];
|
|
67
|
-
const config = { baz: 1 };
|
|
68
|
-
|
|
69
|
-
expect(getConfigurationDiff(defaultConfig, config)).toEqual(["foo", "bar"]);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./utils";
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
flatMap,
|
|
3
|
-
get,
|
|
4
|
-
flatten,
|
|
5
|
-
difference,
|
|
6
|
-
} from "@applicaster/zapp-react-native-utils/utils";
|
|
7
|
-
|
|
8
|
-
const extractFields = (field: any) => {
|
|
9
|
-
if (field.group === true) {
|
|
10
|
-
return field.fields;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return field;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const getAllFields = (...configs: any[]) => {
|
|
17
|
-
const allFields = flatMap(configs, (config) => get(config, "fields", []));
|
|
18
|
-
|
|
19
|
-
const processedFields = flatten(allFields.map(extractFields))
|
|
20
|
-
.map((field) => get(field, "key"))
|
|
21
|
-
.filter(Boolean);
|
|
22
|
-
|
|
23
|
-
return processedFields;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const getConfigurationDiff = (
|
|
27
|
-
defaultConfig,
|
|
28
|
-
config: Record<string, any>
|
|
29
|
-
) => {
|
|
30
|
-
return difference(defaultConfig, Object.keys(config));
|
|
31
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { take, map, trim } from "lodash";
|
|
2
|
-
import { selectActionButtons } from "../conf/player/selectors";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Returns the first two action buttons from the configuration.
|
|
6
|
-
* @param {Object} configuration - The player configuration object.
|
|
7
|
-
* @returns {Array} An array containing the first two action buttons.
|
|
8
|
-
*/
|
|
9
|
-
export const getPlayerActionButtons = (configuration: any) => {
|
|
10
|
-
const buttonsString = selectActionButtons(configuration);
|
|
11
|
-
|
|
12
|
-
if (!buttonsString) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return take(map(buttonsString.split(","), trim), 2);
|
|
17
|
-
};
|