@applicaster/zapp-react-native-utils 14.0.0-alpha.7140739134 → 14.0.0-alpha.7900711229
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/actionsExecutor/ActionExecutorContext.tsx +60 -83
- package/actionsExecutor/ScreenActions.ts +163 -0
- package/actionsExecutor/StorageActions.ts +110 -0
- package/actionsExecutor/feedDecorator.ts +171 -0
- package/actionsExecutor/screenResolver.ts +11 -0
- package/appUtils/contextKeysManager/contextResolver.ts +14 -1
- package/audioPlayerUtils/index.ts +104 -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/_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/useValidatePlayerConfig.tsx +22 -19
- package/reactHooks/cell-click/index.ts +8 -1
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +20 -0
- package/reactHooks/feed/useFeedLoader.tsx +12 -5
- package/reactHooks/navigation/useRoute.ts +7 -2
- package/reactHooks/navigation/useScreenStateStore.ts +11 -0
- package/storage/ScreenSingleValueProvider.ts +197 -0
- package/storage/ScreenStateMultiSelectProvider.ts +282 -0
- package/storage/StorageMultiSelectProvider.ts +192 -0
- package/storage/StorageSingleSelectProvider.ts +108 -0
- package/utils/index.ts +3 -0
- package/playerUtils/configurationGenerator.ts +0 -2572
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { get, has } from "@applicaster/zapp-react-native-utils/utils";
|
|
3
|
+
import { useZStore } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
4
|
+
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
5
|
+
|
|
1
6
|
import { isNotEmptyString } from "@applicaster/zapp-react-native-utils/stringUtils";
|
|
2
7
|
import { getMediaItems } from "@applicaster/zapp-react-native-utils/configurationUtils";
|
|
3
8
|
|
|
@@ -136,3 +141,102 @@ export const getArtworkImage = ({
|
|
|
136
141
|
// default image
|
|
137
142
|
return DEFAULT_IMAGE;
|
|
138
143
|
};
|
|
144
|
+
|
|
145
|
+
const useAdjustedKeyFromScreenData = ({ config, keys }) => {
|
|
146
|
+
const { screenData } = useRoute();
|
|
147
|
+
|
|
148
|
+
const adjustedConfig = { ...config };
|
|
149
|
+
|
|
150
|
+
keys.forEach((key) => {
|
|
151
|
+
const path = ["targetScreen", "styles", key];
|
|
152
|
+
|
|
153
|
+
if (has(screenData, path)) {
|
|
154
|
+
const value = get(screenData, path);
|
|
155
|
+
|
|
156
|
+
adjustedConfig[key] = value;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return adjustedConfig;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const AUDIO_PLAYER_ARTWORK_IMAGE_KEY = "audio_player_artwork_image_key";
|
|
164
|
+
|
|
165
|
+
const audioPlayerArtworkImageKeySelector = (config) =>
|
|
166
|
+
config?.[AUDIO_PLAYER_ARTWORK_IMAGE_KEY];
|
|
167
|
+
|
|
168
|
+
export const useArtworkImage = (entry: ZappEntry): string => {
|
|
169
|
+
const configuration = useZStore("playerConfiguration");
|
|
170
|
+
|
|
171
|
+
const audio_player_artwork_image_key_value = configuration(
|
|
172
|
+
audioPlayerArtworkImageKeySelector
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
const pluginConfiguration = React.useMemo(
|
|
176
|
+
() => ({
|
|
177
|
+
audio_player_artwork_image_key: audio_player_artwork_image_key_value,
|
|
178
|
+
}),
|
|
179
|
+
[audio_player_artwork_image_key_value]
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
// HACK: for override [key] from screenData, because we treat empty string value as missing key and replace it to initial_value from manifest(which is wrong)
|
|
183
|
+
const adjustedPluginConfiguration = useAdjustedKeyFromScreenData({
|
|
184
|
+
keys: [AUDIO_PLAYER_ARTWORK_IMAGE_KEY],
|
|
185
|
+
config: pluginConfiguration,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
return React.useMemo(
|
|
189
|
+
() =>
|
|
190
|
+
getArtworkImage({
|
|
191
|
+
key: AUDIO_PLAYER_ARTWORK_IMAGE_KEY,
|
|
192
|
+
entry,
|
|
193
|
+
plugin_configuration: adjustedPluginConfiguration,
|
|
194
|
+
}),
|
|
195
|
+
[]
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const AUDIO_PLAYER_IMAGE_KEY = "audio_player_image_key";
|
|
200
|
+
const AUDIO_PLAYER_BACKGROUND_IMAGE = "audio_player_background_image";
|
|
201
|
+
|
|
202
|
+
const audioPlayerImageKeySelector = (config) =>
|
|
203
|
+
config?.[AUDIO_PLAYER_IMAGE_KEY];
|
|
204
|
+
|
|
205
|
+
const audioPlayerBackgroundImageSelector = (config) =>
|
|
206
|
+
config?.[AUDIO_PLAYER_BACKGROUND_IMAGE];
|
|
207
|
+
|
|
208
|
+
export const useBackgroundImage = (entry: ZappEntry): { uri: string } => {
|
|
209
|
+
const configuration = useZStore("playerConfiguration");
|
|
210
|
+
|
|
211
|
+
const audio_player_image_key_value = configuration(
|
|
212
|
+
audioPlayerImageKeySelector
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const audio_player_background_image_value = configuration(
|
|
216
|
+
audioPlayerBackgroundImageSelector
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
const pluginConfiguration = React.useMemo(
|
|
220
|
+
() => ({
|
|
221
|
+
audio_player_image_key: audio_player_image_key_value,
|
|
222
|
+
audio_player_background_image: audio_player_background_image_value,
|
|
223
|
+
}),
|
|
224
|
+
[audio_player_image_key_value, audio_player_background_image_value]
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
// HACK: for override [key] from screenData, because we treat empty string value as missing key and replace it to initial_value from manifest(which is wrong)
|
|
228
|
+
const adjustedPluginConfiguration = useAdjustedKeyFromScreenData({
|
|
229
|
+
keys: [AUDIO_PLAYER_IMAGE_KEY, AUDIO_PLAYER_BACKGROUND_IMAGE],
|
|
230
|
+
config: pluginConfiguration,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
return React.useMemo(
|
|
234
|
+
() => ({
|
|
235
|
+
uri: getBackgroundImage({
|
|
236
|
+
entry,
|
|
237
|
+
plugin_configuration: adjustedPluginConfiguration,
|
|
238
|
+
}),
|
|
239
|
+
}),
|
|
240
|
+
[entry, adjustedPluginConfiguration]
|
|
241
|
+
);
|
|
242
|
+
};
|
|
@@ -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)));
|