react-native-mmkv 2.6.1 → 2.6.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/MMKV/Core/CMakeLists.txt +13 -2
- package/MMKV/Core/MMKV.cpp +7 -3
- package/MMKV/Core/MMKV.h +1 -1
- package/MMKV/Core/MMKVLog.cpp +1 -1
- package/MMKV/Core/MMKVPredef.h +1 -1
- package/MMKV/Core/MMKV_OSX.cpp +2 -2
- package/MMKV/Core/MemoryFile_OSX.cpp +1 -1
- package/README.md +1 -0
- package/android/src/main/cpp/MmkvHostObject.cpp +1 -1
- package/ios/JSIUtils.mm +2 -1
- package/package.json +7 -3
package/MMKV/Core/CMakeLists.txt
CHANGED
|
@@ -121,8 +121,6 @@ add_library(core
|
|
|
121
121
|
aes/openssl/openssl_md5_one.cpp
|
|
122
122
|
aes/openssl/openssl_md5.h
|
|
123
123
|
aes/openssl/openssl_md32_common.h
|
|
124
|
-
aes/openssl/openssl_aesv8-armx.S
|
|
125
|
-
aes/openssl/openssl_aes-armv4.S
|
|
126
124
|
aes/openssl/openssl_arm_arch.h
|
|
127
125
|
crc32/Checksum.h
|
|
128
126
|
crc32/crc32_armv8.cpp
|
|
@@ -133,8 +131,21 @@ add_library(core
|
|
|
133
131
|
MMKVPredef.h
|
|
134
132
|
)
|
|
135
133
|
|
|
134
|
+
IF (NOT MSVC)
|
|
135
|
+
# .S files is not supported by MSVC.
|
|
136
|
+
target_sources(core PRIVATE
|
|
137
|
+
aes/openssl/openssl_aesv8-armx.S
|
|
138
|
+
aes/openssl/openssl_aes-armv4.S)
|
|
139
|
+
ENDIF()
|
|
140
|
+
|
|
136
141
|
target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
137
142
|
|
|
143
|
+
IF (WIN32)
|
|
144
|
+
# MMKV can be used only with Unicode on Windows.
|
|
145
|
+
target_compile_definitions(core PUBLIC UNICODE)
|
|
146
|
+
target_compile_definitions(core PUBLIC _UNICODE)
|
|
147
|
+
ENDIF()
|
|
148
|
+
|
|
138
149
|
set_target_properties(core PROPERTIES
|
|
139
150
|
CXX_STANDARD 17
|
|
140
151
|
CXX_EXTENSIONS OFF
|
package/MMKV/Core/MMKV.cpp
CHANGED
|
@@ -189,15 +189,16 @@ void initialize() {
|
|
|
189
189
|
#endif // __aarch64__ && defined(__linux__)
|
|
190
190
|
|
|
191
191
|
#if defined(MMKV_DEBUG) && !defined(MMKV_DISABLE_CRYPT)
|
|
192
|
-
AESCrypt::testAESCrypt();
|
|
193
|
-
KeyValueHolderCrypt::testAESToMMBuffer();
|
|
192
|
+
// AESCrypt::testAESCrypt();
|
|
193
|
+
// KeyValueHolderCrypt::testAESToMMBuffer();
|
|
194
194
|
#endif
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
ThreadOnceToken_t once_control = ThreadOnceUninitialized;
|
|
198
198
|
|
|
199
|
-
void MMKV::initializeMMKV(const MMKVPath_t &rootDir, MMKVLogLevel logLevel) {
|
|
199
|
+
void MMKV::initializeMMKV(const MMKVPath_t &rootDir, MMKVLogLevel logLevel, mmkv::LogHandler handler) {
|
|
200
200
|
g_currentLogLevel = logLevel;
|
|
201
|
+
g_logHandler = handler;
|
|
201
202
|
|
|
202
203
|
ThreadLock::ThreadOnce(&once_control, initialize);
|
|
203
204
|
|
|
@@ -975,12 +976,15 @@ void MMKV::sync(SyncFlag flag) {
|
|
|
975
976
|
}
|
|
976
977
|
|
|
977
978
|
void MMKV::lock() {
|
|
979
|
+
SCOPED_LOCK(m_lock);
|
|
978
980
|
m_exclusiveProcessLock->lock();
|
|
979
981
|
}
|
|
980
982
|
void MMKV::unlock() {
|
|
983
|
+
SCOPED_LOCK(m_lock);
|
|
981
984
|
m_exclusiveProcessLock->unlock();
|
|
982
985
|
}
|
|
983
986
|
bool MMKV::try_lock() {
|
|
987
|
+
SCOPED_LOCK(m_lock);
|
|
984
988
|
return m_exclusiveProcessLock->try_lock();
|
|
985
989
|
}
|
|
986
990
|
|
package/MMKV/Core/MMKV.h
CHANGED
|
@@ -156,7 +156,7 @@ class MMKV {
|
|
|
156
156
|
|
|
157
157
|
public:
|
|
158
158
|
// call this before getting any MMKV instance
|
|
159
|
-
static void initializeMMKV(const MMKVPath_t &rootDir, MMKVLogLevel logLevel = MMKVLogInfo);
|
|
159
|
+
static void initializeMMKV(const MMKVPath_t &rootDir, MMKVLogLevel logLevel = MMKVLogInfo, mmkv::LogHandler handler = nullptr);
|
|
160
160
|
|
|
161
161
|
#ifdef MMKV_APPLE
|
|
162
162
|
// protect from some old code that don't call initializeMMKV()
|
package/MMKV/Core/MMKVLog.cpp
CHANGED
|
@@ -28,7 +28,7 @@ MMKVLogLevel g_currentLogLevel = MMKVLogDebug;
|
|
|
28
28
|
MMKVLogLevel g_currentLogLevel = MMKVLogInfo;
|
|
29
29
|
#endif
|
|
30
30
|
|
|
31
|
-
mmkv::LogHandler g_logHandler;
|
|
31
|
+
mmkv::LogHandler g_logHandler = nullptr;
|
|
32
32
|
|
|
33
33
|
#ifndef __FILE_NAME__
|
|
34
34
|
const char *_getFileName(const char *path) {
|
package/MMKV/Core/MMKVPredef.h
CHANGED
package/MMKV/Core/MMKV_OSX.cpp
CHANGED
|
@@ -186,10 +186,10 @@ NSObject *MMKV::getObject(MMKVKey_t key, Class cls) {
|
|
|
186
186
|
} else {
|
|
187
187
|
if ([cls conformsToProtocol:@protocol(NSCoding)]) {
|
|
188
188
|
auto tmp = [NSData dataWithBytesNoCopy:data.getPtr() length:data.length() freeWhenDone:NO];
|
|
189
|
-
try {
|
|
189
|
+
@try {
|
|
190
190
|
id result = [NSKeyedUnarchiver unarchiveObjectWithData:tmp];
|
|
191
191
|
return result;
|
|
192
|
-
} catch (NSException *exception) {
|
|
192
|
+
} @catch (NSException *exception) {
|
|
193
193
|
MMKVError("%s", exception.reason);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
@@ -61,7 +61,7 @@ bool tryAtomicRename(const char *src, const char *dst) {
|
|
|
61
61
|
bool renamed = false;
|
|
62
62
|
|
|
63
63
|
// try atomic swap first
|
|
64
|
-
if (@available(iOS 10.0, watchOS 3.0, *)) {
|
|
64
|
+
if (@available(iOS 10.0, watchOS 3.0, macOS 10.12, *)) {
|
|
65
65
|
// renameat2() equivalent
|
|
66
66
|
if (renamex_np(src, dst, RENAME_SWAP) == 0) {
|
|
67
67
|
renamed = true;
|
package/README.md
CHANGED
|
@@ -196,6 +196,7 @@ A mocked MMKV instance is automatically used when testing with Jest, so you will
|
|
|
196
196
|
* [Using MMKV with mobx-persist](./docs/WRAPPER_MOBXPERSIST.md)
|
|
197
197
|
* [Using MMKV with zustand persist-middleware](./docs/WRAPPER_ZUSTAND_PERSIST_MIDDLEWARE.md)
|
|
198
198
|
* [Using MMKV with jotai](./docs/WRAPPER_JOTAI.md)
|
|
199
|
+
* [Using MMKV with react-query](./docs/WRAPPER_REACT_QUERY.md)
|
|
199
200
|
* [How is this library different from **react-native-mmkv-storage**?](https://github.com/mrousavy/react-native-mmkv/issues/100#issuecomment-886477361)
|
|
200
201
|
|
|
201
202
|
## Limitations
|
|
@@ -55,7 +55,7 @@ jsi::Value MmkvHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pro
|
|
|
55
55
|
auto funcName = "MMKV." + propName;
|
|
56
56
|
|
|
57
57
|
if (propName == "set") {
|
|
58
|
-
// MMKV.set(key: string, value: string | number | bool)
|
|
58
|
+
// MMKV.set(key: string, value: string | number | bool | Uint8Array)
|
|
59
59
|
return jsi::Function::createFromHostFunction(runtime,
|
|
60
60
|
jsi::PropNameID::forAscii(runtime, funcName),
|
|
61
61
|
2, // key, value
|
package/ios/JSIUtils.mm
CHANGED
|
@@ -80,7 +80,8 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value);
|
|
|
80
80
|
|
|
81
81
|
NSString *convertJSIStringToNSString(jsi::Runtime &runtime, const jsi::String &value)
|
|
82
82
|
{
|
|
83
|
-
|
|
83
|
+
auto string = value.utf8(runtime);
|
|
84
|
+
return [NSString stringWithUTF8String:string.c_str()];
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
NSArray *convertJSIArrayToNSArray(jsi::Runtime &runtime,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-mmkv",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "The fastest key/value storage for React Native. ~30x faster than AsyncStorage! Works on Android, iOS and Web.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
"typescript": "tsc --noEmit",
|
|
30
30
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
31
31
|
"lint-ci": "yarn lint -f ./node_modules/@firmnav/eslint-github-actions-formatter/dist/formatter.js",
|
|
32
|
-
"prepare": "git submodule update --init --recursive",
|
|
33
|
-
"build": "bob build",
|
|
32
|
+
"prepare": "git submodule update --init --recursive && bob build",
|
|
34
33
|
"prepack": "bob build",
|
|
35
34
|
"update-submodule": "git submodule update --remote --merge",
|
|
36
35
|
"release": "release-it",
|
|
@@ -165,5 +164,10 @@
|
|
|
165
164
|
}
|
|
166
165
|
]
|
|
167
166
|
]
|
|
167
|
+
},
|
|
168
|
+
"codegenConfig": {
|
|
169
|
+
"name": "reactnativemmkv",
|
|
170
|
+
"type": "modules",
|
|
171
|
+
"jsSrcsDir": "./lib/module"
|
|
168
172
|
}
|
|
169
173
|
}
|