@applicaster/zapp-react-native-bridge 13.0.0-alpha.2761483533 → 13.0.0-alpha.2807014304
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
CHANGED
|
@@ -85,37 +85,40 @@ export const remapAssetPath = (
|
|
|
85
85
|
): Record<string, any> => {
|
|
86
86
|
const startTime = performance.now();
|
|
87
87
|
|
|
88
|
-
const result = assets.reduce(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
const result = assets.reduce(
|
|
89
|
+
(obj, { path, url }) => {
|
|
90
|
+
const localFile = localFiles[url];
|
|
91
|
+
|
|
92
|
+
if (!localFile) {
|
|
93
|
+
bridgeLogger.warning({
|
|
94
|
+
message: `remapAssetPath: Could not replace asset with local file for url: ${url}`,
|
|
95
|
+
data: { path, obj },
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return obj;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let target = obj;
|
|
102
|
+
|
|
103
|
+
// Traverse the path to the appropriate nested object
|
|
104
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
105
|
+
target = target[path[i]] = target[path[i]];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!target) {
|
|
109
|
+
bridgeLogger.error({
|
|
110
|
+
message: `remapAssetPath: Could not find path ${path.join(".")}`,
|
|
111
|
+
data: obj,
|
|
112
|
+
});
|
|
113
|
+
} else {
|
|
114
|
+
// Set the final value
|
|
115
|
+
target[path[path.length - 1]] = localFile;
|
|
116
|
+
}
|
|
96
117
|
|
|
97
118
|
return obj;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// Traverse the path to the appropriate nested object
|
|
103
|
-
for (let i = 0; i < path.length - 1; i++) {
|
|
104
|
-
target = target[path[i]] = target[path[i]];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (!target) {
|
|
108
|
-
bridgeLogger.error({
|
|
109
|
-
message: `remapAssetPath: Could not find path ${path.join(".")}`,
|
|
110
|
-
data: obj,
|
|
111
|
-
});
|
|
112
|
-
} else {
|
|
113
|
-
// Set the final value
|
|
114
|
-
target[path[path.length - 1]] = localFile;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return obj;
|
|
118
|
-
}, JSON.parse(JSON.stringify(source)));
|
|
119
|
+
},
|
|
120
|
+
JSON.parse(JSON.stringify(source))
|
|
121
|
+
);
|
|
119
122
|
|
|
120
123
|
bridgeLogger.log({
|
|
121
124
|
message: `remapAssetPath: remapping took ${
|
package/PluginManager/index.ts
CHANGED
|
@@ -105,9 +105,8 @@ async function isPluginEnabled(identifier) {
|
|
|
105
105
|
return isPluginEnabledNative(identifier);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
const enabledInConfigurationJSON =
|
|
109
|
-
identifier
|
|
110
|
-
);
|
|
108
|
+
const enabledInConfigurationJSON =
|
|
109
|
+
await isPluginSupportToggleLogic(identifier);
|
|
111
110
|
|
|
112
111
|
if (enabledInConfigurationJSON !== undefined) {
|
|
113
112
|
const enabledOverriden = await localStorage.getItem(
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-bridge",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.2807014304",
|
|
4
4
|
"description": "Applicaster Zapp React Native modules",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "jest -w=2",
|
|
9
8
|
"build": "echo 'skipping ts build for core packages'"
|
|
10
9
|
},
|
|
11
10
|
"publishConfig": {
|
|
@@ -33,18 +32,16 @@
|
|
|
33
32
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
34
33
|
"dependencies": {
|
|
35
34
|
"@applicaster/zapp-pipes-dev-kit": "1.4.7",
|
|
36
|
-
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.
|
|
35
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.2807014304",
|
|
37
36
|
"md5": "^2.3.0",
|
|
38
37
|
"uuid": "^3.3.2"
|
|
39
38
|
},
|
|
40
39
|
"peerDependencies": {
|
|
41
40
|
"@applicaster/zapp-pipes-v2-client": "*",
|
|
42
41
|
"@react-native-community/netinfo": "*",
|
|
43
|
-
"@types/node": "*",
|
|
44
|
-
"@types/react-native": "0.69.6",
|
|
45
42
|
"immer": "*",
|
|
46
|
-
"react": "
|
|
47
|
-
"react-native": "
|
|
43
|
+
"react": "*",
|
|
44
|
+
"react-native": "*",
|
|
48
45
|
"uglify-js": "*",
|
|
49
46
|
"validate-color": "*",
|
|
50
47
|
"zustand": "*"
|