@applicaster/zapp-react-native-bridge 14.0.0-rc.9 → 15.0.0-rc.2
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/OfflineAssets/index.ts +5 -1
- package/PushNotifications/index.ts +1 -1
- package/QuickBrick/index.ts +1 -2
- package/ZappStorage/LocalStorage/index.ts +1 -1
- package/package.json +2 -3
- package/ZappStorage/StorageMultiSelectProvider.ts +0 -176
- package/ZappStorage/StorageSingleSelectProvider.ts +0 -108
package/OfflineAssets/index.ts
CHANGED
|
@@ -102,7 +102,11 @@ export const remapAssetPath = (
|
|
|
102
102
|
|
|
103
103
|
// Traverse the path to the appropriate nested object
|
|
104
104
|
for (let i = 0; i < path.length - 1; i++) {
|
|
105
|
-
|
|
105
|
+
if (typeof target[path[i]] !== "object" || target[path[i]] === null) {
|
|
106
|
+
target[path[i]] = {};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
target = target[path[i]];
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
if (!target) {
|
|
@@ -7,7 +7,7 @@ interface PushBridgeInterface {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line prefer-promise-reject-errors
|
|
10
|
-
const nullPromise = () => Promise.
|
|
10
|
+
const nullPromise = () => Promise.resolve(["Push Notification bridge is null"]);
|
|
11
11
|
|
|
12
12
|
const defaultPushNotification = {
|
|
13
13
|
registerTags: nullPromise,
|
package/QuickBrick/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
|
-
import { Platform } from "react-native";
|
|
3
2
|
import uuidv4 from "uuid/v4";
|
|
4
3
|
|
|
5
4
|
import { bridgeLogger } from "../logger";
|
|
@@ -27,7 +26,7 @@ export interface QuickBrickCommunicationModuleI extends AppData {
|
|
|
27
26
|
) => void;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
const { NativeModules } = require("react-native");
|
|
29
|
+
const { NativeModules, Platform } = require("react-native");
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
32
|
* sends an event to the native QuickBrick manager module
|
|
@@ -32,7 +32,7 @@ function getLocalStorageAndroid(): NativeLocalStorageI {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const LocalStorage = platformSelect({
|
|
35
|
+
const LocalStorage: NativeLocalStorageI = platformSelect({
|
|
36
36
|
android: getLocalStorageAndroid(),
|
|
37
37
|
amazon: getLocalStorageAndroid(),
|
|
38
38
|
android_tv: getLocalStorageAndroid(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-bridge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0-rc.2",
|
|
4
4
|
"description": "Applicaster Zapp React Native modules",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -32,14 +32,13 @@
|
|
|
32
32
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@applicaster/zapp-pipes-dev-kit": "1.4.7",
|
|
35
|
-
"@applicaster/zapp-react-native-utils": "
|
|
35
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-rc.2",
|
|
36
36
|
"md5": "^2.3.0",
|
|
37
37
|
"uuid": "^3.3.2"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@applicaster/zapp-pipes-v2-client": "*",
|
|
41
41
|
"@react-native-community/netinfo": "*",
|
|
42
|
-
"immer": "*",
|
|
43
42
|
"react": "*",
|
|
44
43
|
"react-native": "*",
|
|
45
44
|
"uglify-js": "*",
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
2
|
-
import { bridgeLogger } from "../logger";
|
|
3
|
-
import { BehaviorSubject } from "rxjs";
|
|
4
|
-
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
5
|
-
import { getNamespaceAndKey } from "@applicaster/zapp-react-native-utils/appUtils/contextKeysManager/utils";
|
|
6
|
-
|
|
7
|
-
export const { log_verbose, log_debug, log_warning, log_info, log_error } =
|
|
8
|
-
createLogger({
|
|
9
|
-
category: "StorageMultiSelectProvider",
|
|
10
|
-
subsystem: "zapp-react-native-bridge",
|
|
11
|
-
parent: bridgeLogger,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export interface MultiSelectProvider {
|
|
15
|
-
getObservable(): BehaviorSubject<string[]>;
|
|
16
|
-
|
|
17
|
-
addItem(item: string): Promise<void>;
|
|
18
|
-
|
|
19
|
-
addItems(items: string[]): Promise<void>;
|
|
20
|
-
|
|
21
|
-
setSelectedItems(items: string[]): Promise<void>;
|
|
22
|
-
|
|
23
|
-
removeItem(item: string): Promise<void>;
|
|
24
|
-
|
|
25
|
-
removeItems(items: string[]): Promise<void>;
|
|
26
|
-
|
|
27
|
-
removeAllItems(): Promise<void>;
|
|
28
|
-
|
|
29
|
-
getSelectedItems(): string[];
|
|
30
|
-
|
|
31
|
-
getSelectedAsync(): Promise<string[]>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
35
|
-
// TODO: Unsubscribe and remove when there is no listeners
|
|
36
|
-
private static multiSelectProviders: Record<
|
|
37
|
-
string,
|
|
38
|
-
StorageMultiSelectProvider
|
|
39
|
-
> = {};
|
|
40
|
-
|
|
41
|
-
public static getProvider(keyNamespace: string): StorageMultiSelectProvider {
|
|
42
|
-
if (!this.multiSelectProviders[keyNamespace]) {
|
|
43
|
-
this.multiSelectProviders[keyNamespace] = new StorageMultiSelectProvider(
|
|
44
|
-
keyNamespace
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return this.multiSelectProviders[keyNamespace];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private itemSubject: BehaviorSubject<string[] | null>;
|
|
52
|
-
|
|
53
|
-
private readonly key: string;
|
|
54
|
-
private readonly namespace: string;
|
|
55
|
-
|
|
56
|
-
private constructor(keyNamespace: string) {
|
|
57
|
-
const { namespace, key } = getNamespaceAndKey(keyNamespace);
|
|
58
|
-
|
|
59
|
-
if (!key) {
|
|
60
|
-
throw new Error("StorageMultiSelectProvider: Key is required");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
this.key = key;
|
|
64
|
-
this.namespace = namespace;
|
|
65
|
-
localStorage.addListener?.({ key, namespace }, this.reloadItems);
|
|
66
|
-
|
|
67
|
-
this.itemSubject = new BehaviorSubject([]);
|
|
68
|
-
|
|
69
|
-
void this.getSelectedAsync();
|
|
70
|
-
log_debug("StorageMultiSelectProvider: Initializing");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private reloadItems = async ({ value }: StorageListenerArgs) => {
|
|
74
|
-
const selectedItems = value ? value.split(",") : [];
|
|
75
|
-
|
|
76
|
-
log_debug(
|
|
77
|
-
`reloadItems: request to reload items for value: ${value}`,
|
|
78
|
-
selectedItems
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
this.itemSubject.next(selectedItems);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
public getObservable = (): BehaviorSubject<string[]> => this.itemSubject;
|
|
85
|
-
|
|
86
|
-
private async getSetOfCurrentItems() {
|
|
87
|
-
const currentResult: string = await localStorage.getItem(
|
|
88
|
-
this.key,
|
|
89
|
-
this.namespace
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
return new Set(currentResult ? currentResult.split(",") : []);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private async updateItemsAndNotifyObservers(currentItems: Set<string>) {
|
|
96
|
-
const arrayOfItems = Array.from(currentItems);
|
|
97
|
-
const newValue = arrayOfItems.join(",");
|
|
98
|
-
await localStorage.setItem(this.key, newValue, this.namespace);
|
|
99
|
-
|
|
100
|
-
this.itemSubject.next(arrayOfItems);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
public addItem = async (item: string): Promise<void> => {
|
|
104
|
-
const currentItems = await this.getSetOfCurrentItems();
|
|
105
|
-
currentItems.add(item);
|
|
106
|
-
log_debug(`addItem: Adding new item: ${item}`);
|
|
107
|
-
|
|
108
|
-
await this.updateItemsAndNotifyObservers(currentItems);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
public addItems = async (items: string[]): Promise<void> => {
|
|
112
|
-
const currentItems = await this.getSetOfCurrentItems();
|
|
113
|
-
|
|
114
|
-
items.forEach((item) => currentItems.add(item));
|
|
115
|
-
|
|
116
|
-
log_debug(
|
|
117
|
-
`addItems: Adding new items: ${items.join(
|
|
118
|
-
","
|
|
119
|
-
)}, current items: ${Array.from(currentItems).join(",")}`
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
await this.updateItemsAndNotifyObservers(currentItems);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
public removeItem = async (item: string): Promise<void> => {
|
|
126
|
-
const currentItems = await this.getSetOfCurrentItems();
|
|
127
|
-
currentItems.delete(item);
|
|
128
|
-
|
|
129
|
-
log_debug(
|
|
130
|
-
`removeItem: Removing item: ${item}, current items: ${Array.from(
|
|
131
|
-
currentItems
|
|
132
|
-
).join(",")}`
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
await this.updateItemsAndNotifyObservers(currentItems);
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
public removeItems = async (items: string[]): Promise<void> => {
|
|
139
|
-
const currentItems = await this.getSetOfCurrentItems();
|
|
140
|
-
|
|
141
|
-
items.forEach((item) => currentItems.delete(item));
|
|
142
|
-
|
|
143
|
-
log_debug(
|
|
144
|
-
`removeItems: Removing items: ${items.join(
|
|
145
|
-
","
|
|
146
|
-
)}, current items: ${Array.from(currentItems).join(",")}`
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
await this.updateItemsAndNotifyObservers(currentItems);
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
public removeAllItems = async (): Promise<void> => {
|
|
153
|
-
await localStorage.removeItem(this.key, this.namespace);
|
|
154
|
-
log_debug(`removeAllItems: Removing all items, current items: ${[]}`);
|
|
155
|
-
|
|
156
|
-
this.itemSubject.next([]);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
public getSelectedAsync = async (): Promise<string[]> => {
|
|
160
|
-
const value = await localStorage.getItem(this.key, this.namespace);
|
|
161
|
-
const selectedItems = value ? value.split(",") : [];
|
|
162
|
-
this.itemSubject.next(selectedItems);
|
|
163
|
-
|
|
164
|
-
return selectedItems;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
public getSelectedItems = (): string[] => {
|
|
168
|
-
return this.itemSubject.getValue();
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
setSelectedItems = async (items: string[]): Promise<void> => {
|
|
172
|
-
log_debug(`setSelectedItems: Setting selected items: ${items.join(",")}`);
|
|
173
|
-
|
|
174
|
-
await this.updateItemsAndNotifyObservers(new Set(items));
|
|
175
|
-
};
|
|
176
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
2
|
-
import { bridgeLogger } from "../logger";
|
|
3
|
-
import { BehaviorSubject } from "rxjs";
|
|
4
|
-
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
5
|
-
import { getNamespaceAndKey } from "@applicaster/zapp-react-native-utils/appUtils/contextKeysManager/utils";
|
|
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): StorageSingleValueProvider {
|
|
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
|
-
}
|