react-native-mmkv 4.0.0-beta.7 → 4.0.0-beta.9
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/app.plugin.js +1 -1
- package/cpp/HybridMMKV.cpp +2 -2
- package/cpp/HybridMMKV.hpp +1 -1
- package/lib/createMMKV/createMMKV.mock.js +1 -0
- package/lib/createMMKV/createMMKV.web.js +1 -1
- package/lib/expo-plugin/withMMKV.cjs +26 -0
- package/lib/expo-plugin/withMMKV.d.cts +3 -0
- package/lib/specs/MMKV.nitro.d.ts +2 -1
- package/nitrogen/generated/android/NitroMmkvOnLoad.cpp +1 -2
- package/nitrogen/generated/shared/c++/HybridMMKVSpec.hpp +1 -1
- package/package.json +4 -4
- package/src/createMMKV/createMMKV.mock.ts +1 -0
- package/src/createMMKV/createMMKV.web.ts +1 -1
- package/src/expo-plugin/withMMKV.cts +31 -0
- package/src/specs/MMKV.nitro.ts +2 -1
- package/src/expo-plugin/withMMKV.ts +0 -23
package/app.plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./lib/
|
|
1
|
+
module.exports = require('./lib/expo-plugin/withMMKV.cjs')
|
package/cpp/HybridMMKV.cpp
CHANGED
|
@@ -129,8 +129,8 @@ std::optional<std::shared_ptr<ArrayBuffer>> HybridMMKV::getBuffer(const std::str
|
|
|
129
129
|
bool HybridMMKV::contains(const std::string& key) {
|
|
130
130
|
return instance->containsKey(key);
|
|
131
131
|
}
|
|
132
|
-
|
|
133
|
-
instance->removeValueForKey(key);
|
|
132
|
+
bool HybridMMKV::remove(const std::string& key) {
|
|
133
|
+
return instance->removeValueForKey(key);
|
|
134
134
|
}
|
|
135
135
|
std::vector<std::string> HybridMMKV::getAllKeys() {
|
|
136
136
|
return instance->allKeys();
|
package/cpp/HybridMMKV.hpp
CHANGED
|
@@ -30,7 +30,7 @@ public:
|
|
|
30
30
|
std::optional<double> getNumber(const std::string& key) override;
|
|
31
31
|
std::optional<std::shared_ptr<ArrayBuffer>> getBuffer(const std::string& key) override;
|
|
32
32
|
bool contains(const std::string& key) override;
|
|
33
|
-
|
|
33
|
+
bool remove(const std::string& key) override;
|
|
34
34
|
std::vector<std::string> getAllKeys() override;
|
|
35
35
|
void clearAll() override;
|
|
36
36
|
void recrypt(const std::optional<std::string>& key) override;
|
|
@@ -64,7 +64,7 @@ export function createMMKV(config) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
-
remove: (key) => storage().removeItem(prefixedKey(key)),
|
|
67
|
+
remove: (key) => storage().removeItem(prefixedKey(key)) ?? false,
|
|
68
68
|
set: (key, value) => {
|
|
69
69
|
storage().setItem(prefixedKey(key), value.toString());
|
|
70
70
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
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);
|
|
@@ -42,8 +42,9 @@ export interface MMKV extends HybridObject<{
|
|
|
42
42
|
contains(key: string): boolean;
|
|
43
43
|
/**
|
|
44
44
|
* Removes the given `key`.
|
|
45
|
+
* @returns true if the key was removed, false otherwise
|
|
45
46
|
*/
|
|
46
|
-
remove(key: string):
|
|
47
|
+
remove(key: string): boolean;
|
|
47
48
|
/**
|
|
48
49
|
* Get all keys.
|
|
49
50
|
*
|
|
@@ -45,8 +45,7 @@ int initialize(JavaVM* vm) {
|
|
|
45
45
|
[]() -> std::shared_ptr<HybridObject> {
|
|
46
46
|
static DefaultConstructableObject<JHybridMMKVPlatformContextSpec::javaobject> object("com/margelo/nitro/mmkv/HybridMMKVPlatformContext");
|
|
47
47
|
auto instance = object.create();
|
|
48
|
-
|
|
49
|
-
return globalRef->cthis()->shared();
|
|
48
|
+
return instance->cthis()->shared();
|
|
50
49
|
}
|
|
51
50
|
);
|
|
52
51
|
});
|
|
@@ -64,7 +64,7 @@ namespace margelo::nitro::mmkv {
|
|
|
64
64
|
virtual std::optional<double> getNumber(const std::string& key) = 0;
|
|
65
65
|
virtual std::optional<std::shared_ptr<ArrayBuffer>> getBuffer(const std::string& key) = 0;
|
|
66
66
|
virtual bool contains(const std::string& key) = 0;
|
|
67
|
-
virtual
|
|
67
|
+
virtual bool remove(const std::string& key) = 0;
|
|
68
68
|
virtual std::vector<std::string> getAllKeys() = 0;
|
|
69
69
|
virtual void clearAll() = 0;
|
|
70
70
|
virtual void recrypt(const std::optional<std::string>& key) = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-mmkv",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.9",
|
|
4
4
|
"description": "react-native-mmkv",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
|
|
38
38
|
"lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
|
|
39
39
|
"typescript": "tsc",
|
|
40
|
-
"specs": "tsc &&
|
|
40
|
+
"specs": "tsc && nitrogen --logLevel=\"debug\"",
|
|
41
41
|
"build": "tsc --noEmit false",
|
|
42
42
|
"release": "release-it",
|
|
43
43
|
"test": "jest"
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"eslint": "^8.57.0",
|
|
69
69
|
"eslint-config-prettier": "^9.1.0",
|
|
70
70
|
"eslint-plugin-prettier": "^5.2.1",
|
|
71
|
-
"
|
|
71
|
+
"nitrogen": "^0.29.4",
|
|
72
72
|
"prettier": "^3.3.3",
|
|
73
73
|
"react": "19.1.0",
|
|
74
74
|
"react-native": "0.81.0",
|
|
75
|
-
"react-native-nitro-modules": "
|
|
75
|
+
"react-native-nitro-modules": "^0.29.4",
|
|
76
76
|
"typescript": "^5.8.3"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
@@ -87,7 +87,7 @@ export function createMMKV(config: Configuration): MMKV {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
|
-
remove: (key) => storage().removeItem(prefixedKey(key)),
|
|
90
|
+
remove: (key) => storage().removeItem(prefixedKey(key)) ?? false,
|
|
91
91
|
set: (key, value) => {
|
|
92
92
|
storage().setItem(prefixedKey(key), value.toString())
|
|
93
93
|
},
|
|
@@ -0,0 +1,31 @@
|
|
|
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<{}>
|
package/src/specs/MMKV.nitro.ts
CHANGED
|
@@ -41,8 +41,9 @@ export interface MMKV extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
41
41
|
contains(key: string): boolean
|
|
42
42
|
/**
|
|
43
43
|
* Removes the given `key`.
|
|
44
|
+
* @returns true if the key was removed, false otherwise
|
|
44
45
|
*/
|
|
45
|
-
remove(key: string):
|
|
46
|
+
remove(key: string): boolean
|
|
46
47
|
/**
|
|
47
48
|
* Get all keys.
|
|
48
49
|
*
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ConfigPlugin } from '@expo/config-plugins'
|
|
2
|
-
import { createRunOncePlugin, withGradleProperties } from '@expo/config-plugins'
|
|
3
|
-
|
|
4
|
-
const pkg = require('../../package.json')
|
|
5
|
-
|
|
6
|
-
const withMMKV: ConfigPlugin<{}> = (config) => {
|
|
7
|
-
// remove 32-bit architectures from gradle.properties
|
|
8
|
-
return withGradleProperties(config, (cfg) => {
|
|
9
|
-
// Drop any existing entry…
|
|
10
|
-
cfg.modResults = cfg.modResults.filter(
|
|
11
|
-
(p) => !(p.type === 'property' && p.key === 'reactNativeArchitectures')
|
|
12
|
-
)
|
|
13
|
-
// …and force 64-bit only.
|
|
14
|
-
cfg.modResults.push({
|
|
15
|
-
type: 'property',
|
|
16
|
-
key: 'reactNativeArchitectures',
|
|
17
|
-
value: 'arm64-v8a,x86_64',
|
|
18
|
-
})
|
|
19
|
-
return cfg
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default createRunOncePlugin(withMMKV, pkg.name, pkg.version)
|