@applicaster/zapp-react-native-utils 13.0.0-rc.99 → 14.0.0-alpha.1216545755
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 +87 -67
- package/actionsExecutor/ScreenActions.ts +92 -0
- package/actionsExecutor/StorageActions.ts +110 -0
- package/actionsExecutor/consts.ts +4 -0
- package/actionsExecutor/feedDecorator.ts +171 -0
- package/actionsExecutor/screenResolver.ts +11 -0
- package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
- package/appUtils/__tests__/allZappLocales.ts +79 -0
- package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
- package/appUtils/accessibilityManager/const.ts +18 -0
- package/appUtils/accessibilityManager/index.ts +4 -1
- package/appUtils/contextKeysManager/contextResolver.ts +14 -1
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +1 -0
- package/appUtils/focusManager/index.ios.ts +14 -4
- package/appUtils/focusManager/utils/__tests__/findChild.test.ts +35 -0
- package/appUtils/focusManager/utils/index.ts +5 -0
- package/appUtils/localizationsHelper.ts +10 -2
- package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +11 -7
- package/arrayUtils/__tests__/isEmptyArray.test.ts +63 -0
- package/arrayUtils/__tests__/isFilledArray.test.ts +1 -1
- package/arrayUtils/index.ts +7 -2
- package/audioPlayerUtils/__tests__/getArtworkImage.test.ts +144 -0
- package/audioPlayerUtils/__tests__/getBackgroundImage.test.ts +72 -0
- package/audioPlayerUtils/__tests__/getImageFromEntry.test.ts +110 -0
- package/audioPlayerUtils/assets/index.ts +2 -0
- package/audioPlayerUtils/index.ts +242 -0
- package/cellUtils/index.ts +9 -5
- package/componentsUtils/index.ts +8 -1
- package/conf/player/__tests__/selectors.test.ts +34 -0
- package/conf/player/selectors.ts +10 -0
- package/configurationUtils/__tests__/configurationUtils.test.js +0 -31
- package/configurationUtils/__tests__/getMediaItems.test.ts +65 -0
- package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +34 -0
- package/configurationUtils/index.ts +63 -34
- package/localizationUtils/index.ts +3 -3
- 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/generalContent.js +13 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +1228 -205
- package/manifestUtils/index.js +2 -0
- package/manifestUtils/keys.js +27 -2
- package/manifestUtils/progressBar/__tests__/mobileProgressBar.test.js +0 -30
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +1 -2
- package/navigationUtils/__tests__/navigationUtils.test.js +0 -65
- package/navigationUtils/index.ts +0 -31
- 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 +25 -0
- package/playerUtils/useValidatePlayerConfig.tsx +22 -19
- package/reactHooks/app/useAppState.ts +2 -2
- package/reactHooks/cell-click/index.ts +8 -1
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +20 -0
- package/reactHooks/feed/useBatchLoading.ts +12 -14
- package/reactHooks/feed/useFeedLoader.tsx +12 -5
- package/reactHooks/navigation/{useGetTabBarHeight.ts → getTabBarHeight.ts} +1 -1
- package/reactHooks/navigation/useGetBottomTabBarHeight.ts +10 -3
- package/reactHooks/navigation/useNavigationPluginData.ts +8 -4
- package/reactHooks/navigation/useNavigationType.ts +4 -2
- package/reactHooks/navigation/useRoute.ts +7 -2
- package/reactHooks/navigation/useScreenStateStore.ts +11 -0
- package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +69 -0
- package/reactHooks/screen/useScreenBackgroundColor.ts +3 -15
- package/reactHooks/state/README.md +79 -0
- package/reactHooks/state/ZStoreProvider.tsx +71 -0
- package/reactHooks/state/__tests__/ZStoreProvider.test.tsx +66 -0
- package/reactHooks/state/index.ts +2 -0
- package/reactHooks/useListenEventBusEvent.ts +1 -1
- package/reactUtils/index.ts +9 -0
- package/storage/ScreenSingleValueProvider.ts +198 -0
- package/storage/ScreenStateMultiSelectProvider.ts +293 -0
- package/storage/StorageMultiSelectProvider.ts +192 -0
- package/storage/StorageSingleSelectProvider.ts +108 -0
- package/typeGuards/index.ts +3 -0
- package/utils/index.ts +12 -1
- package/zappFrameworkUtils/localStorageHelper.ts +32 -10
- package/playerUtils/configurationGenerator.ts +0 -2588
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { bridgeLogger } from "../../zapp-react-native-bridge/logger";
|
|
2
|
+
import { BehaviorSubject } from "rxjs";
|
|
3
|
+
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
4
|
+
import { getNamespaceAndKey } from "../appUtils/contextKeysManager/utils";
|
|
5
|
+
import { createLogger } from "../logger";
|
|
6
|
+
|
|
7
|
+
export const { log_verbose, log_debug, log_warning, log_info, log_error } =
|
|
8
|
+
createLogger({
|
|
9
|
+
category: "StorageSingleValueProvider",
|
|
10
|
+
subsystem: "zapp-react-native-bridge",
|
|
11
|
+
parent: bridgeLogger,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export interface SingleValueProvider {
|
|
15
|
+
getObservable(): BehaviorSubject<string | null>;
|
|
16
|
+
|
|
17
|
+
setValue(value: string): Promise<void>;
|
|
18
|
+
getValue(): string | null;
|
|
19
|
+
getValueAsync(): Promise<string | null>;
|
|
20
|
+
clearValue(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface StorageListenerArgs {
|
|
24
|
+
value: string | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class StorageSingleValueProvider implements SingleValueProvider {
|
|
28
|
+
// Static cache of providers by namespace
|
|
29
|
+
private static singleValueProviders: Record<
|
|
30
|
+
string,
|
|
31
|
+
StorageSingleValueProvider
|
|
32
|
+
> = {};
|
|
33
|
+
|
|
34
|
+
public static getProvider(keyNamespace: string): SingleValueProvider {
|
|
35
|
+
if (!this.singleValueProviders[keyNamespace]) {
|
|
36
|
+
this.singleValueProviders[keyNamespace] = new StorageSingleValueProvider(
|
|
37
|
+
keyNamespace
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return this.singleValueProviders[keyNamespace];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private valueSubject: BehaviorSubject<string | null>;
|
|
45
|
+
|
|
46
|
+
private readonly key: string;
|
|
47
|
+
private readonly namespace: string;
|
|
48
|
+
|
|
49
|
+
private constructor(keyNamespace: string) {
|
|
50
|
+
const { namespace, key } = getNamespaceAndKey(keyNamespace);
|
|
51
|
+
|
|
52
|
+
if (!key) {
|
|
53
|
+
throw new Error("StorageSingleValueProvider: Key is required");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.key = key;
|
|
57
|
+
this.namespace = namespace;
|
|
58
|
+
localStorage.addListener?.({ key, namespace }, this.reloadValue);
|
|
59
|
+
|
|
60
|
+
this.valueSubject = new BehaviorSubject<string | null>(null);
|
|
61
|
+
|
|
62
|
+
void this.getValueAsync();
|
|
63
|
+
log_debug("StorageSingleValueProvider: Initializing");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private reloadValue = async ({ value }: StorageListenerArgs) => {
|
|
67
|
+
log_debug(`reloadValue: request to reload value: ${value}`);
|
|
68
|
+
|
|
69
|
+
this.valueSubject.next(value);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
public getObservable = (): BehaviorSubject<string | null> =>
|
|
73
|
+
this.valueSubject;
|
|
74
|
+
|
|
75
|
+
private async updateValueAndNotifyObservers(value: string | null) {
|
|
76
|
+
if (value === null) {
|
|
77
|
+
await localStorage.removeItem(this.key, this.namespace);
|
|
78
|
+
} else {
|
|
79
|
+
await localStorage.setItem(this.key, value, this.namespace);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.valueSubject.next(value);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public setValue = async (value: string): Promise<void> => {
|
|
86
|
+
log_debug(`setValue: Setting new value: ${value}`);
|
|
87
|
+
|
|
88
|
+
await this.updateValueAndNotifyObservers(value);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
public clearValue = async (): Promise<void> => {
|
|
92
|
+
await localStorage.removeItem(this.key, this.namespace);
|
|
93
|
+
log_debug("clearValue: Removing value");
|
|
94
|
+
|
|
95
|
+
this.valueSubject.next(null);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
public getValueAsync = async (): Promise<string | null> => {
|
|
99
|
+
const value = await localStorage.getItem(this.key, this.namespace);
|
|
100
|
+
this.valueSubject.next(value);
|
|
101
|
+
|
|
102
|
+
return value;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
public getValue = (): string | null => {
|
|
106
|
+
return this.valueSubject.getValue();
|
|
107
|
+
};
|
|
108
|
+
}
|
package/utils/index.ts
CHANGED
|
@@ -2,4 +2,15 @@ export { chunk } from "./chunk";
|
|
|
2
2
|
|
|
3
3
|
export { times } from "./times";
|
|
4
4
|
|
|
5
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
cloneDeep as clone,
|
|
7
|
+
flatten,
|
|
8
|
+
drop,
|
|
9
|
+
size,
|
|
10
|
+
isNil,
|
|
11
|
+
isEmpty,
|
|
12
|
+
get,
|
|
13
|
+
has,
|
|
14
|
+
flatMap,
|
|
15
|
+
difference,
|
|
16
|
+
} from "lodash";
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
StorageValuesToRemove,
|
|
8
8
|
StorageValuesToAdd,
|
|
9
9
|
} from "./types";
|
|
10
|
+
import { Storage } from "@applicaster/zapp-react-native-bridge/ZappStorage/Storage";
|
|
10
11
|
|
|
11
12
|
const defaultOwnedKey = "owned_keys";
|
|
12
13
|
const DEFAULT_NAMESPACE = "applicaster.v2";
|
|
@@ -50,8 +51,9 @@ function mapOwnedKeysToAdd(
|
|
|
50
51
|
return mappedData;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
export async function
|
|
54
|
-
storageValues: StorageValuesToAdd
|
|
54
|
+
export async function batchSave(
|
|
55
|
+
storageValues: StorageValuesToAdd,
|
|
56
|
+
storage: Storage
|
|
55
57
|
) {
|
|
56
58
|
if (isNilOrEmpty(storageValues)) {
|
|
57
59
|
return false;
|
|
@@ -64,24 +66,37 @@ export async function batchSaveToLocalStorage(
|
|
|
64
66
|
const value = namespaceData[key];
|
|
65
67
|
|
|
66
68
|
if (!isNilOrEmpty(value)) {
|
|
67
|
-
await
|
|
69
|
+
await storage.setItem(key, value, namespace);
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
export async function
|
|
74
|
-
storageValues:
|
|
75
|
+
export async function batchSaveToLocalStorage(
|
|
76
|
+
storageValues: StorageValuesToAdd
|
|
77
|
+
) {
|
|
78
|
+
return await batchSave(storageValues, localStorage);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function batchRemoveFromStorage(
|
|
82
|
+
storageValues: StorageValuesToRemove,
|
|
83
|
+
storage: Storage = localStorage
|
|
75
84
|
) {
|
|
76
85
|
for (const namespace of Object.keys(storageValues)) {
|
|
77
86
|
const namespaceData = storageValues[namespace];
|
|
78
87
|
|
|
79
88
|
for (const key of namespaceData) {
|
|
80
|
-
await
|
|
89
|
+
await storage.removeItem(key, namespace);
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
92
|
}
|
|
84
93
|
|
|
94
|
+
export async function batchRemoveFromLocalStorage(
|
|
95
|
+
storageValues: StorageValuesToRemove
|
|
96
|
+
) {
|
|
97
|
+
await batchRemoveFromStorage(storageValues, localStorage);
|
|
98
|
+
}
|
|
99
|
+
|
|
85
100
|
async function addOwnedKeys({
|
|
86
101
|
newKeys,
|
|
87
102
|
ownershipKey,
|
|
@@ -224,13 +239,20 @@ export async function batchRemoveOwnedNamespaceKeys({
|
|
|
224
239
|
});
|
|
225
240
|
}
|
|
226
241
|
|
|
227
|
-
export async function
|
|
228
|
-
|
|
242
|
+
export async function batchRemoveAllFromNamespaceForStorage(
|
|
243
|
+
namespace: string,
|
|
244
|
+
storage: Storage
|
|
245
|
+
) {
|
|
246
|
+
const allDataInNamespace = await storage.getAllItems(namespace);
|
|
229
247
|
const keysToRemove = Object.keys(allDataInNamespace);
|
|
230
248
|
|
|
231
|
-
const dataToRemove = {
|
|
249
|
+
const dataToRemove: StorageValuesToRemove = {
|
|
232
250
|
[namespace]: keysToRemove,
|
|
233
251
|
};
|
|
234
252
|
|
|
235
|
-
await
|
|
253
|
+
await batchRemoveFromStorage(dataToRemove, storage);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export async function batchRemoveAllFromNamespace(namespace: string) {
|
|
257
|
+
await batchRemoveAllFromNamespaceForStorage(namespace, localStorage);
|
|
236
258
|
}
|