react-native-mmkv 4.0.0-beta.10 → 4.0.0-beta.11
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/android/build.gradle +2 -2
- package/package.json +1 -1
- package/app.plugin.js +0 -1
- package/lib/createMMKV/createMMKV.mock.d.ts +0 -5
- package/lib/createMMKV/createMMKV.mock.js +0 -74
- package/lib/expo-plugin/withMMKV.cjs +0 -26
- package/lib/expo-plugin/withMMKV.d.cts +0 -3
- package/lib/expo-plugin/withMMKV.d.ts +0 -3
- package/lib/expo-plugin/withMMKV.js +0 -17
- package/src/expo-plugin/withMMKV.cts +0 -31
package/android/build.gradle
CHANGED
|
@@ -11,7 +11,7 @@ buildscript {
|
|
|
11
11
|
|
|
12
12
|
def reactNativeArchitectures() {
|
|
13
13
|
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
14
|
-
return value ? value.split(",") : ["x86_64", "arm64-v8a"]
|
|
14
|
+
return value ? value.split(",") : ["x86", "x86_64", "armeabi-v7a", "arm64-v8a"]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
def isNewArchitectureEnabled() {
|
|
@@ -139,6 +139,6 @@ dependencies {
|
|
|
139
139
|
implementation project(":react-native-nitro-modules")
|
|
140
140
|
|
|
141
141
|
// Add a dependency on mmkv core (this ships a C++ prefab)
|
|
142
|
-
implementation "
|
|
142
|
+
implementation "io.github.zhongwuzw:mmkv:2.2.3.1"
|
|
143
143
|
}
|
|
144
144
|
|
package/package.json
CHANGED
package/app.plugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./lib/expo-plugin/withMMKV.cjs')
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mock MMKV instance when used in a Jest/Test environment.
|
|
3
|
-
*/
|
|
4
|
-
export function createMockMMKV() {
|
|
5
|
-
const storage = new Map();
|
|
6
|
-
const listeners = new Set();
|
|
7
|
-
const notifyListeners = (key) => {
|
|
8
|
-
listeners.forEach((listener) => {
|
|
9
|
-
listener(key);
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
return {
|
|
13
|
-
clearAll: () => {
|
|
14
|
-
const keysBefore = storage.keys();
|
|
15
|
-
storage.clear();
|
|
16
|
-
// Notify all listeners for all keys that were cleared
|
|
17
|
-
for (const key of keysBefore) {
|
|
18
|
-
notifyListeners(key);
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
remove: (key) => {
|
|
22
|
-
const deleted = storage.delete(key);
|
|
23
|
-
if (deleted) {
|
|
24
|
-
notifyListeners(key);
|
|
25
|
-
}
|
|
26
|
-
return deleted;
|
|
27
|
-
},
|
|
28
|
-
set: (key, value) => {
|
|
29
|
-
storage.set(key, value);
|
|
30
|
-
notifyListeners(key);
|
|
31
|
-
},
|
|
32
|
-
getString: (key) => {
|
|
33
|
-
const result = storage.get(key);
|
|
34
|
-
return typeof result === 'string' ? result : undefined;
|
|
35
|
-
},
|
|
36
|
-
getNumber: (key) => {
|
|
37
|
-
const result = storage.get(key);
|
|
38
|
-
return typeof result === 'number' ? result : undefined;
|
|
39
|
-
},
|
|
40
|
-
getBoolean: (key) => {
|
|
41
|
-
const result = storage.get(key);
|
|
42
|
-
return typeof result === 'boolean' ? result : undefined;
|
|
43
|
-
},
|
|
44
|
-
getBuffer: (key) => {
|
|
45
|
-
const result = storage.get(key);
|
|
46
|
-
return result instanceof ArrayBuffer ? result : undefined;
|
|
47
|
-
},
|
|
48
|
-
getAllKeys: () => Array.from(storage.keys()),
|
|
49
|
-
contains: (key) => storage.has(key),
|
|
50
|
-
recrypt: () => {
|
|
51
|
-
console.warn('Encryption is not supported in mocked MMKV instances!');
|
|
52
|
-
},
|
|
53
|
-
get size() {
|
|
54
|
-
return storage.size;
|
|
55
|
-
},
|
|
56
|
-
isReadOnly: false,
|
|
57
|
-
trim: () => {
|
|
58
|
-
// no-op
|
|
59
|
-
},
|
|
60
|
-
name: 'MMKV',
|
|
61
|
-
dispose: () => { },
|
|
62
|
-
equals: () => {
|
|
63
|
-
return false;
|
|
64
|
-
},
|
|
65
|
-
addOnValueChangedListener: (listener) => {
|
|
66
|
-
listeners.add(listener);
|
|
67
|
-
return {
|
|
68
|
-
remove: () => {
|
|
69
|
-
listeners.delete(listener);
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const { createRunOncePlugin, withGradleProperties } = require('@expo/config-plugins');
|
|
3
|
-
const pkg = require('../../package.json');
|
|
4
|
-
const withMMKV = (config) => {
|
|
5
|
-
// remove 32-bit architectures from gradle.properties
|
|
6
|
-
return withGradleProperties(config, (cfg) => {
|
|
7
|
-
// Define the wanted property
|
|
8
|
-
const property = {
|
|
9
|
-
type: 'property',
|
|
10
|
-
key: 'reactNativeArchitectures',
|
|
11
|
-
value: 'arm64-v8a,x86_64',
|
|
12
|
-
};
|
|
13
|
-
// If it exists, update its value
|
|
14
|
-
const index = cfg.modResults.findIndex((p) => p.type === 'property' && p.key === property.key);
|
|
15
|
-
if (index !== -1) {
|
|
16
|
-
// Overwrite it
|
|
17
|
-
cfg.modResults[index] = property;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
// Append it
|
|
21
|
-
cfg.modResults.push(property);
|
|
22
|
-
}
|
|
23
|
-
return cfg;
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
module.exports = createRunOncePlugin(withMMKV, pkg.name, pkg.version);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createRunOncePlugin, withGradleProperties } from '@expo/config-plugins';
|
|
2
|
-
const pkg = require('../../package.json');
|
|
3
|
-
const withMMKV = (config) => {
|
|
4
|
-
// remove 32-bit architectures from gradle.properties
|
|
5
|
-
return withGradleProperties(config, (cfg) => {
|
|
6
|
-
// Drop any existing entry…
|
|
7
|
-
cfg.modResults = cfg.modResults.filter((p) => !(p.type === 'property' && p.key === 'reactNativeArchitectures'));
|
|
8
|
-
// …and force 64-bit only.
|
|
9
|
-
cfg.modResults.push({
|
|
10
|
-
type: 'property',
|
|
11
|
-
key: 'reactNativeArchitectures',
|
|
12
|
-
value: 'arm64-v8a,x86_64',
|
|
13
|
-
});
|
|
14
|
-
return cfg;
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
export default createRunOncePlugin(withMMKV, pkg.name, pkg.version);
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins'
|
|
2
|
-
const { createRunOncePlugin, withGradleProperties } = require('@expo/config-plugins')
|
|
3
|
-
import type { Properties } from '@expo/config-plugins/build/android'
|
|
4
|
-
|
|
5
|
-
const pkg = require('../../package.json')
|
|
6
|
-
|
|
7
|
-
const withMMKV: ConfigPlugin<{}> = (config) => {
|
|
8
|
-
// remove 32-bit architectures from gradle.properties
|
|
9
|
-
return withGradleProperties(config, (cfg: ExportedConfigWithProps<Properties.PropertiesItem[]>) => {
|
|
10
|
-
// Define the wanted property
|
|
11
|
-
const property = {
|
|
12
|
-
type: 'property',
|
|
13
|
-
key: 'reactNativeArchitectures',
|
|
14
|
-
value: 'arm64-v8a,x86_64',
|
|
15
|
-
} as const
|
|
16
|
-
// If it exists, update its value
|
|
17
|
-
const index = cfg.modResults.findIndex(
|
|
18
|
-
(p) => p.type === 'property' && p.key === property.key
|
|
19
|
-
)
|
|
20
|
-
if (index !== -1) {
|
|
21
|
-
// Overwrite it
|
|
22
|
-
cfg.modResults[index] = property
|
|
23
|
-
} else {
|
|
24
|
-
// Append it
|
|
25
|
-
cfg.modResults.push(property)
|
|
26
|
-
}
|
|
27
|
-
return cfg
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export = createRunOncePlugin(withMMKV, pkg.name, pkg.version) as ConfigPlugin<{}>
|