react-native-mmkv 3.3.0 → 4.0.0-beta.1

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.
Files changed (95) hide show
  1. package/android/CMakeLists.txt +18 -9
  2. package/android/build.gradle +6 -2
  3. package/cpp/{MMKVManagedBuffer.h → ManagedMMBuffer.h} +6 -6
  4. package/cpp/MmkvHostObject.cpp +13 -8
  5. package/cpp/MmkvHostObject.h +1 -2
  6. package/cpp/MmkvTypes.h +50 -0
  7. package/cpp/NativeMmkvModule.cpp +3 -3
  8. package/cpp/NativeMmkvModule.h +1 -8
  9. package/lib/commonjs/hooks.js +2 -2
  10. package/lib/commonjs/hooks.js.map +1 -1
  11. package/lib/module/hooks.js +2 -2
  12. package/lib/module/hooks.js.map +1 -1
  13. package/lib/typescript/src/MemoryWarningListener.web.d.ts.map +1 -1
  14. package/lib/typescript/src/createMMKV.d.ts.map +1 -1
  15. package/lib/typescript/src/createMMKV.web.d.ts.map +1 -1
  16. package/package.json +24 -24
  17. package/react-native-mmkv.podspec +3 -9
  18. package/react-native.config.js +9 -0
  19. package/src/hooks.ts +2 -2
  20. package/MMKV/Core/CMakeLists.txt +0 -172
  21. package/MMKV/Core/CodedInputData.cpp +0 -252
  22. package/MMKV/Core/CodedInputData.h +0 -87
  23. package/MMKV/Core/CodedInputDataCrypt.cpp +0 -280
  24. package/MMKV/Core/CodedInputDataCrypt.h +0 -87
  25. package/MMKV/Core/CodedInputDataCrypt_OSX.cpp +0 -62
  26. package/MMKV/Core/CodedInputData_OSX.cpp +0 -92
  27. package/MMKV/Core/CodedOutputData.cpp +0 -186
  28. package/MMKV/Core/CodedOutputData.h +0 -88
  29. package/MMKV/Core/Core.xcodeproj/project.pbxproj +0 -707
  30. package/MMKV/Core/Core.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  31. package/MMKV/Core/Core.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  32. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme +0 -67
  33. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/MMKVWatchCore.xcscheme +0 -67
  34. package/MMKV/Core/InterProcessLock.cpp +0 -186
  35. package/MMKV/Core/InterProcessLock.h +0 -119
  36. package/MMKV/Core/InterProcessLock_Android.cpp +0 -103
  37. package/MMKV/Core/InterProcessLock_Win32.cpp +0 -108
  38. package/MMKV/Core/KeyValueHolder.cpp +0 -236
  39. package/MMKV/Core/KeyValueHolder.h +0 -122
  40. package/MMKV/Core/MMBuffer.cpp +0 -210
  41. package/MMKV/Core/MMBuffer.h +0 -111
  42. package/MMKV/Core/MMKV.cpp +0 -1702
  43. package/MMKV/Core/MMKV.h +0 -595
  44. package/MMKV/Core/MMKVLog.cpp +0 -127
  45. package/MMKV/Core/MMKVLog.h +0 -86
  46. package/MMKV/Core/MMKVLog_Android.cpp +0 -134
  47. package/MMKV/Core/MMKVMetaInfo.hpp +0 -99
  48. package/MMKV/Core/MMKVPredef.h +0 -293
  49. package/MMKV/Core/MMKV_Android.cpp +0 -261
  50. package/MMKV/Core/MMKV_IO.cpp +0 -1905
  51. package/MMKV/Core/MMKV_IO.h +0 -57
  52. package/MMKV/Core/MMKV_OSX.cpp +0 -423
  53. package/MMKV/Core/MMKV_OSX.h +0 -57
  54. package/MMKV/Core/MemoryFile.cpp +0 -603
  55. package/MMKV/Core/MemoryFile.h +0 -194
  56. package/MMKV/Core/MemoryFile_Android.cpp +0 -236
  57. package/MMKV/Core/MemoryFile_Linux.cpp +0 -125
  58. package/MMKV/Core/MemoryFile_OSX.cpp +0 -142
  59. package/MMKV/Core/MemoryFile_Win32.cpp +0 -554
  60. package/MMKV/Core/MiniPBCoder.cpp +0 -672
  61. package/MMKV/Core/MiniPBCoder.h +0 -151
  62. package/MMKV/Core/MiniPBCoder_OSX.cpp +0 -237
  63. package/MMKV/Core/PBEncodeItem.hpp +0 -104
  64. package/MMKV/Core/PBUtility.cpp +0 -61
  65. package/MMKV/Core/PBUtility.h +0 -148
  66. package/MMKV/Core/ScopedLock.hpp +0 -69
  67. package/MMKV/Core/ThreadLock.cpp +0 -75
  68. package/MMKV/Core/ThreadLock.h +0 -81
  69. package/MMKV/Core/ThreadLock_Win32.cpp +0 -89
  70. package/MMKV/Core/aes/AESCrypt.cpp +0 -273
  71. package/MMKV/Core/aes/AESCrypt.h +0 -112
  72. package/MMKV/Core/aes/openssl/openssl_aes-armv4.S +0 -1243
  73. package/MMKV/Core/aes/openssl/openssl_aes.h +0 -130
  74. package/MMKV/Core/aes/openssl/openssl_aes_core.cpp +0 -1044
  75. package/MMKV/Core/aes/openssl/openssl_aes_locl.h +0 -38
  76. package/MMKV/Core/aes/openssl/openssl_aesv8-armx.S +0 -308
  77. package/MMKV/Core/aes/openssl/openssl_arm_arch.h +0 -84
  78. package/MMKV/Core/aes/openssl/openssl_cfb128.cpp +0 -97
  79. package/MMKV/Core/aes/openssl/openssl_md32_common.h +0 -254
  80. package/MMKV/Core/aes/openssl/openssl_md5.h +0 -49
  81. package/MMKV/Core/aes/openssl/openssl_md5_dgst.cpp +0 -166
  82. package/MMKV/Core/aes/openssl/openssl_md5_locl.h +0 -75
  83. package/MMKV/Core/aes/openssl/openssl_md5_one.cpp +0 -30
  84. package/MMKV/Core/aes/openssl/openssl_opensslconf.h +0 -271
  85. package/MMKV/Core/core.vcxproj +0 -288
  86. package/MMKV/Core/core.vcxproj.filters +0 -150
  87. package/MMKV/Core/crc32/Checksum.h +0 -75
  88. package/MMKV/Core/crc32/crc32_armv8.cpp +0 -134
  89. package/MMKV/Core/crc32/zlib/CMakeLists.txt +0 -60
  90. package/MMKV/Core/crc32/zlib/crc32.cpp +0 -55
  91. package/MMKV/Core/crc32/zlib/crc32.h +0 -48
  92. package/MMKV/Core/crc32/zlib/zconf.h +0 -380
  93. package/MMKV/Core/crc32/zlib/zutil.h +0 -25
  94. package/MMKV/LICENSE.TXT +0 -193
  95. package/MMKV/README.md +0 -354
@@ -1,127 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making
3
- * MMKV available.
4
- *
5
- * Copyright (C) 2019 THL A29 Limited, a Tencent company.
6
- * All rights reserved.
7
- *
8
- * Licensed under the BSD 3-Clause License (the "License"); you may not use
9
- * this file except in compliance with the License. You may obtain a copy of
10
- * the License at
11
- *
12
- * https://opensource.org/licenses/BSD-3-Clause
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
-
21
- #include "MMKVLog.h"
22
-
23
- MMKV_NAMESPACE_BEGIN
24
-
25
- #ifdef MMKV_DEBUG
26
- MMKVLogLevel g_currentLogLevel = MMKVLogDebug;
27
- #else
28
- MMKVLogLevel g_currentLogLevel = MMKVLogInfo;
29
- #endif
30
-
31
- mmkv::LogHandler g_logHandler = nullptr;
32
-
33
- #ifndef __FILE_NAME__
34
- const char *_getFileName(const char *path) {
35
- const char *ptr = strrchr(path, '/');
36
- if (!ptr) {
37
- ptr = strrchr(path, '\\');
38
- }
39
- if (ptr) {
40
- return ptr + 1;
41
- } else {
42
- return path;
43
- }
44
- }
45
- #endif
46
-
47
- MMKV_NAMESPACE_END
48
-
49
-
50
- #ifdef ENABLE_MMKV_LOG
51
- # include <cstdarg>
52
- # include <string>
53
-
54
- using namespace mmkv;
55
-
56
- # ifndef MMKV_ANDROID
57
-
58
- static const char *MMKVLogLevelDesc(MMKVLogLevel level) {
59
- switch (level) {
60
- case MMKVLogDebug:
61
- return "D";
62
- case MMKVLogInfo:
63
- return "I";
64
- case MMKVLogWarning:
65
- return "W";
66
- case MMKVLogError:
67
- return "E";
68
- default:
69
- return "N";
70
- }
71
- }
72
-
73
- # ifdef MMKV_APPLE
74
-
75
- void _MMKVLogWithLevel(MMKVLogLevel level, const char *filename, const char *func, int line, const char *format, ...) {
76
- if (level >= g_currentLogLevel) {
77
- NSString *nsFormat = [NSString stringWithUTF8String:format];
78
- va_list argList;
79
- va_start(argList, format);
80
- NSString *message = [[NSString alloc] initWithFormat:nsFormat arguments:argList];
81
- va_end(argList);
82
-
83
- if (g_logHandler) {
84
- g_logHandler(level, filename, line, func, message);
85
- } else {
86
- NSLog(@"[%s] <%s:%d::%s> %@", MMKVLogLevelDesc(level), filename, line, func, message);
87
- }
88
- }
89
- }
90
-
91
- # else
92
-
93
- void _MMKVLogWithLevel(MMKVLogLevel level, const char *filename, const char *func, int line, const char *format, ...) {
94
- if (level >= g_currentLogLevel) {
95
- std::string message;
96
- char buffer[16];
97
-
98
- va_list args;
99
- va_start(args, format);
100
- auto length = std::vsnprintf(buffer, sizeof(buffer), format, args);
101
- va_end(args);
102
-
103
- if (length < 0) { // something wrong
104
- message = {};
105
- } else if (length < sizeof(buffer)) {
106
- message = std::string(buffer, static_cast<unsigned long>(length));
107
- } else {
108
- message.resize(static_cast<unsigned long>(length), '\0');
109
- va_start(args, format);
110
- std::vsnprintf(const_cast<char *>(message.data()), static_cast<size_t>(length) + 1, format, args);
111
- va_end(args);
112
- }
113
-
114
- if (g_logHandler) {
115
- g_logHandler(level, filename, line, func, message);
116
- } else {
117
- printf("[%s] <%s:%d::%s> %s\n", MMKVLogLevelDesc(level), filename, line, func, message.c_str());
118
- //fflush(stdout);
119
- }
120
- }
121
- }
122
-
123
- # endif // MMKV_APPLE
124
-
125
- # endif // MMKV_ANDROID
126
-
127
- #endif // ENABLE_MMKV_LOG
@@ -1,86 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making
3
- * MMKV available.
4
- *
5
- * Copyright (C) 2018 THL A29 Limited, a Tencent company.
6
- * All rights reserved.
7
- *
8
- * Licensed under the BSD 3-Clause License (the "License"); you may not use
9
- * this file except in compliance with the License. You may obtain a copy of
10
- * the License at
11
- *
12
- * https://opensource.org/licenses/BSD-3-Clause
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
-
21
- #ifndef MMKV_MMKVLOG_H
22
- #define MMKV_MMKVLOG_H
23
- #ifdef __cplusplus
24
-
25
- #include "MMKVPredef.h"
26
-
27
- #include <cerrno>
28
- #include <cstdint>
29
- #include <cstring>
30
-
31
- void _MMKVLogWithLevel(
32
- MMKV_NAMESPACE_PREFIX::MMKVLogLevel level, const char *filename, const char *func, int line, const char *format, ...);
33
-
34
- MMKV_NAMESPACE_BEGIN
35
-
36
- extern MMKVLogLevel g_currentLogLevel;
37
- extern mmkv::LogHandler g_logHandler;
38
-
39
- // enable logging
40
- #define ENABLE_MMKV_LOG
41
-
42
- #ifdef ENABLE_MMKV_LOG
43
-
44
- # ifdef __FILE_NAME__
45
- # define __MMKV_FILE_NAME__ __FILE_NAME__
46
- # else
47
- const char *_getFileName(const char *path);
48
- # define __MMKV_FILE_NAME__ MMKV_NAMESPACE_PREFIX::_getFileName(__FILE__)
49
- # endif
50
-
51
- # define MMKVError(format, ...) \
52
- _MMKVLogWithLevel(MMKV_NAMESPACE_PREFIX::MMKVLogError, __MMKV_FILE_NAME__, __func__, __LINE__, format, \
53
- ##__VA_ARGS__)
54
- # define MMKVWarning(format, ...) \
55
- _MMKVLogWithLevel(MMKV_NAMESPACE_PREFIX::MMKVLogWarning, __MMKV_FILE_NAME__, __func__, __LINE__, format, \
56
- ##__VA_ARGS__)
57
- # define MMKVInfo(format, ...) \
58
- _MMKVLogWithLevel(MMKV_NAMESPACE_PREFIX::MMKVLogInfo, __MMKV_FILE_NAME__, __func__, __LINE__, format, \
59
- ##__VA_ARGS__)
60
-
61
- # ifdef MMKV_DEBUG
62
- # define MMKVDebug(format, ...) \
63
- _MMKVLogWithLevel(MMKV_NAMESPACE_PREFIX::MMKVLogDebug, __MMKV_FILE_NAME__, __func__, __LINE__, format, \
64
- ##__VA_ARGS__)
65
- # else
66
- # define MMKVDebug(format, ...) \
67
- {}
68
- # endif
69
-
70
- #else
71
-
72
- # define MMKVError(format, ...) \
73
- {}
74
- # define MMKVWarning(format, ...) \
75
- {}
76
- # define MMKVInfo(format, ...) \
77
- {}
78
- # define MMKVDebug(format, ...) \
79
- {}
80
-
81
- #endif
82
-
83
- MMKV_NAMESPACE_END
84
-
85
- #endif
86
- #endif //MMKV_MMKVLOG_H
@@ -1,134 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making
3
- * MMKV available.
4
- *
5
- * Copyright (C) 2019 THL A29 Limited, a Tencent company.
6
- * All rights reserved.
7
- *
8
- * Licensed under the BSD 3-Clause License (the "License"); you may not use
9
- * this file except in compliance with the License. You may obtain a copy of
10
- * the License at
11
- *
12
- * https://opensource.org/licenses/BSD-3-Clause
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
-
21
- #include "MMKVLog.h"
22
-
23
- #ifdef ENABLE_MMKV_LOG
24
- # ifdef MMKV_OHOS
25
- # include <hilog/log.h>
26
- # include <cstdarg>
27
- # include <string>
28
-
29
- using namespace std;
30
-
31
- constexpr auto APP_NAME = "MMKV";
32
-
33
- static LogLevel MMKVLogLevelDesc(MMKVLogLevel level) {
34
- switch (level) {
35
- case MMKVLogDebug:
36
- return LOG_DEBUG;
37
- case MMKVLogInfo:
38
- return LOG_INFO;
39
- case MMKVLogWarning:
40
- return LOG_WARN;
41
- case MMKVLogError:
42
- return LOG_ERROR;
43
- default:
44
- return LOG_INFO;
45
- }
46
- }
47
-
48
- void _MMKVLogWithLevel(MMKVLogLevel level, const char *filename, const char *func, int line, const char *format, ...) {
49
- if (level >= g_currentLogLevel) {
50
- string message;
51
- char buffer[16];
52
-
53
- va_list args;
54
- va_start(args, format);
55
- auto length = std::vsnprintf(buffer, sizeof(buffer), format, args);
56
- va_end(args);
57
-
58
- if (length < 0) { // something wrong
59
- message = {};
60
- } else if (length < sizeof(buffer)) {
61
- message = string(buffer, static_cast<unsigned long>(length));
62
- } else {
63
- message.resize(static_cast<unsigned long>(length), '\0');
64
- va_start(args, format);
65
- std::vsnprintf(const_cast<char *>(message.data()), static_cast<size_t>(length) + 1, format, args);
66
- va_end(args);
67
- }
68
-
69
- if (g_logHandler) {
70
- g_logHandler(level, filename, line, func, message);
71
- } else {
72
- auto desc = MMKVLogLevelDesc(level);
73
- OH_LOG_Print(LOG_APP, desc, 0, APP_NAME, "<%{public}s:%{public}d::%{public}s> %{public}s",
74
- filename, line, func, message.c_str());
75
- }
76
- }
77
- }
78
-
79
- # elif defined(MMKV_ANDROID)
80
- # include <android/log.h>
81
- # include <cstdarg>
82
- # include <string>
83
-
84
- using namespace std;
85
-
86
- constexpr auto APP_NAME = "MMKV";
87
-
88
- static android_LogPriority MMKVLogLevelDesc(MMKVLogLevel level) {
89
- switch (level) {
90
- case MMKVLogDebug:
91
- return ANDROID_LOG_DEBUG;
92
- case MMKVLogInfo:
93
- return ANDROID_LOG_INFO;
94
- case MMKVLogWarning:
95
- return ANDROID_LOG_WARN;
96
- case MMKVLogError:
97
- return ANDROID_LOG_ERROR;
98
- default:
99
- return ANDROID_LOG_UNKNOWN;
100
- }
101
- }
102
-
103
- void _MMKVLogWithLevel(MMKVLogLevel level, const char *filename, const char *func, int line, const char *format, ...) {
104
- if (level >= g_currentLogLevel) {
105
- string message;
106
- char buffer[16];
107
-
108
- va_list args;
109
- va_start(args, format);
110
- auto length = std::vsnprintf(buffer, sizeof(buffer), format, args);
111
- va_end(args);
112
-
113
- if (length < 0) { // something wrong
114
- message = {};
115
- } else if (length < sizeof(buffer)) {
116
- message = string(buffer, static_cast<unsigned long>(length));
117
- } else {
118
- message.resize(static_cast<unsigned long>(length), '\0');
119
- va_start(args, format);
120
- std::vsnprintf(const_cast<char *>(message.data()), static_cast<size_t>(length) + 1, format, args);
121
- va_end(args);
122
- }
123
-
124
- if (g_logHandler) {
125
- g_logHandler(level, filename, line, func, message);
126
- } else {
127
- auto desc = MMKVLogLevelDesc(level);
128
- __android_log_print(desc, APP_NAME, "<%s:%d::%s> %s", filename, line, func, message.c_str());
129
- }
130
- }
131
- }
132
- # endif // MMKV_ANDROID
133
-
134
- #endif // ENABLE_MMKV_LOG
@@ -1,99 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making
3
- * MMKV available.
4
- *
5
- * Copyright (C) 2018 THL A29 Limited, a Tencent company.
6
- * All rights reserved.
7
- *
8
- * Licensed under the BSD 3-Clause License (the "License"); you may not use
9
- * this file except in compliance with the License. You may obtain a copy of
10
- * the License at
11
- *
12
- * https://opensource.org/licenses/BSD-3-Clause
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
-
21
- #ifndef MMKV_MMKVMETAINFO_H
22
- #define MMKV_MMKVMETAINFO_H
23
- #ifdef __cplusplus
24
-
25
- #include "aes/AESCrypt.h"
26
- #include <cstdint>
27
- #include <cstring>
28
-
29
- namespace mmkv {
30
-
31
- enum MMKVVersion : uint32_t {
32
- MMKVVersionDefault = 0,
33
-
34
- // record full write back count
35
- MMKVVersionSequence = 1,
36
-
37
- // store random iv for encryption
38
- MMKVVersionRandomIV = 2,
39
-
40
- // store actual size together with crc checksum, try to reduce file corruption
41
- MMKVVersionActualSize = 3,
42
-
43
- // store extra flags
44
- MMKVVersionFlag = 4,
45
-
46
- // preserved for next use
47
- MMKVVersionNext = 5,
48
-
49
- // always large than next, a placeholder for error check
50
- MMKVVersionHolder = MMKVVersionNext + 1,
51
- };
52
-
53
- struct MMKVMetaInfo {
54
- uint32_t m_crcDigest = 0;
55
- uint32_t m_version = MMKVVersionSequence;
56
- uint32_t m_sequence = 0; // full write-back count
57
- uint8_t m_vector[AES_KEY_LEN] = {};
58
- uint32_t m_actualSize = 0;
59
-
60
- // confirmed info: it's been synced to file
61
- struct {
62
- uint32_t lastActualSize = 0;
63
- uint32_t lastCRCDigest = 0;
64
- uint32_t _reserved[16] = {};
65
- } m_lastConfirmedMetaInfo;
66
-
67
- uint64_t m_flags = 0;
68
-
69
- enum MMKVMetaInfoFlag : uint64_t {
70
- EnableKeyExipre = 1 << 0,
71
- };
72
- bool hasFlag(MMKVMetaInfoFlag flag) { return (m_flags & flag) != 0; }
73
- void setFlag(MMKVMetaInfoFlag flag) { m_flags |= flag; }
74
- void unsetFlag(MMKVMetaInfoFlag flag) { m_flags &= ~flag; }
75
-
76
- void write(void *ptr) const {
77
- MMKV_ASSERT(ptr);
78
- memcpy(ptr, this, sizeof(MMKVMetaInfo));
79
- }
80
-
81
- void writeCRCAndActualSizeOnly(void *ptr) const {
82
- MMKV_ASSERT(ptr);
83
- auto other = (MMKVMetaInfo *) ptr;
84
- other->m_crcDigest = m_crcDigest;
85
- other->m_actualSize = m_actualSize;
86
- }
87
-
88
- void read(const void *ptr) {
89
- MMKV_ASSERT(ptr);
90
- memcpy(this, ptr, sizeof(MMKVMetaInfo));
91
- }
92
- };
93
-
94
- static_assert(sizeof(MMKVMetaInfo) <= (4 * 1024), "MMKVMetaInfo lager than one pagesize");
95
-
96
- } // namespace mmkv
97
-
98
- #endif
99
- #endif //MMKV_MMKVMETAINFO_H