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

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 (87) 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/package.json +22 -23
  10. package/react-native-mmkv.podspec +3 -9
  11. package/react-native.config.js +9 -0
  12. package/MMKV/Core/CMakeLists.txt +0 -172
  13. package/MMKV/Core/CodedInputData.cpp +0 -252
  14. package/MMKV/Core/CodedInputData.h +0 -87
  15. package/MMKV/Core/CodedInputDataCrypt.cpp +0 -280
  16. package/MMKV/Core/CodedInputDataCrypt.h +0 -87
  17. package/MMKV/Core/CodedInputDataCrypt_OSX.cpp +0 -62
  18. package/MMKV/Core/CodedInputData_OSX.cpp +0 -92
  19. package/MMKV/Core/CodedOutputData.cpp +0 -186
  20. package/MMKV/Core/CodedOutputData.h +0 -88
  21. package/MMKV/Core/Core.xcodeproj/project.pbxproj +0 -707
  22. package/MMKV/Core/Core.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  23. package/MMKV/Core/Core.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  24. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme +0 -67
  25. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/MMKVWatchCore.xcscheme +0 -67
  26. package/MMKV/Core/InterProcessLock.cpp +0 -186
  27. package/MMKV/Core/InterProcessLock.h +0 -119
  28. package/MMKV/Core/InterProcessLock_Android.cpp +0 -103
  29. package/MMKV/Core/InterProcessLock_Win32.cpp +0 -108
  30. package/MMKV/Core/KeyValueHolder.cpp +0 -236
  31. package/MMKV/Core/KeyValueHolder.h +0 -122
  32. package/MMKV/Core/MMBuffer.cpp +0 -210
  33. package/MMKV/Core/MMBuffer.h +0 -111
  34. package/MMKV/Core/MMKV.cpp +0 -1702
  35. package/MMKV/Core/MMKV.h +0 -595
  36. package/MMKV/Core/MMKVLog.cpp +0 -127
  37. package/MMKV/Core/MMKVLog.h +0 -86
  38. package/MMKV/Core/MMKVLog_Android.cpp +0 -134
  39. package/MMKV/Core/MMKVMetaInfo.hpp +0 -99
  40. package/MMKV/Core/MMKVPredef.h +0 -293
  41. package/MMKV/Core/MMKV_Android.cpp +0 -261
  42. package/MMKV/Core/MMKV_IO.cpp +0 -1905
  43. package/MMKV/Core/MMKV_IO.h +0 -57
  44. package/MMKV/Core/MMKV_OSX.cpp +0 -423
  45. package/MMKV/Core/MMKV_OSX.h +0 -57
  46. package/MMKV/Core/MemoryFile.cpp +0 -603
  47. package/MMKV/Core/MemoryFile.h +0 -194
  48. package/MMKV/Core/MemoryFile_Android.cpp +0 -236
  49. package/MMKV/Core/MemoryFile_Linux.cpp +0 -125
  50. package/MMKV/Core/MemoryFile_OSX.cpp +0 -142
  51. package/MMKV/Core/MemoryFile_Win32.cpp +0 -554
  52. package/MMKV/Core/MiniPBCoder.cpp +0 -672
  53. package/MMKV/Core/MiniPBCoder.h +0 -151
  54. package/MMKV/Core/MiniPBCoder_OSX.cpp +0 -237
  55. package/MMKV/Core/PBEncodeItem.hpp +0 -104
  56. package/MMKV/Core/PBUtility.cpp +0 -61
  57. package/MMKV/Core/PBUtility.h +0 -148
  58. package/MMKV/Core/ScopedLock.hpp +0 -69
  59. package/MMKV/Core/ThreadLock.cpp +0 -75
  60. package/MMKV/Core/ThreadLock.h +0 -81
  61. package/MMKV/Core/ThreadLock_Win32.cpp +0 -89
  62. package/MMKV/Core/aes/AESCrypt.cpp +0 -273
  63. package/MMKV/Core/aes/AESCrypt.h +0 -112
  64. package/MMKV/Core/aes/openssl/openssl_aes-armv4.S +0 -1243
  65. package/MMKV/Core/aes/openssl/openssl_aes.h +0 -130
  66. package/MMKV/Core/aes/openssl/openssl_aes_core.cpp +0 -1044
  67. package/MMKV/Core/aes/openssl/openssl_aes_locl.h +0 -38
  68. package/MMKV/Core/aes/openssl/openssl_aesv8-armx.S +0 -308
  69. package/MMKV/Core/aes/openssl/openssl_arm_arch.h +0 -84
  70. package/MMKV/Core/aes/openssl/openssl_cfb128.cpp +0 -97
  71. package/MMKV/Core/aes/openssl/openssl_md32_common.h +0 -254
  72. package/MMKV/Core/aes/openssl/openssl_md5.h +0 -49
  73. package/MMKV/Core/aes/openssl/openssl_md5_dgst.cpp +0 -166
  74. package/MMKV/Core/aes/openssl/openssl_md5_locl.h +0 -75
  75. package/MMKV/Core/aes/openssl/openssl_md5_one.cpp +0 -30
  76. package/MMKV/Core/aes/openssl/openssl_opensslconf.h +0 -271
  77. package/MMKV/Core/core.vcxproj +0 -288
  78. package/MMKV/Core/core.vcxproj.filters +0 -150
  79. package/MMKV/Core/crc32/Checksum.h +0 -75
  80. package/MMKV/Core/crc32/crc32_armv8.cpp +0 -134
  81. package/MMKV/Core/crc32/zlib/CMakeLists.txt +0 -60
  82. package/MMKV/Core/crc32/zlib/crc32.cpp +0 -55
  83. package/MMKV/Core/crc32/zlib/crc32.h +0 -48
  84. package/MMKV/Core/crc32/zlib/zconf.h +0 -380
  85. package/MMKV/Core/crc32/zlib/zutil.h +0 -25
  86. package/MMKV/LICENSE.TXT +0 -193
  87. package/MMKV/README.md +0 -354
@@ -1,62 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making
3
- * MMKV available.
4
- *
5
- * Copyright (C) 2020 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 "CodedInputDataCrypt.h"
22
-
23
- #if defined(MMKV_APPLE) && !defined(MMKV_DISABLE_CRYPT)
24
-
25
- # include "PBUtility.h"
26
- # include <stdexcept>
27
-
28
- # if __has_feature(objc_arc)
29
- # error This file must be compiled with MRC. Use -fno-objc-arc flag.
30
- # endif
31
-
32
- using namespace std;
33
-
34
- namespace mmkv {
35
-
36
- NSString *CodedInputDataCrypt::readString(KeyValueHolderCrypt &kvHolder) {
37
- kvHolder.offset = static_cast<uint32_t>(m_position);
38
-
39
- int32_t size = this->readRawVarint32(true);
40
- if (size < 0) {
41
- throw length_error("InvalidProtocolBuffer negativeSize");
42
- }
43
-
44
- auto s_size = static_cast<size_t>(size);
45
- if (s_size <= m_size - m_position) {
46
- consumeBytes(s_size);
47
-
48
- kvHolder.keySize = static_cast<uint16_t>(s_size);
49
-
50
- auto ptr = m_decryptBuffer + m_decryptBufferPosition;
51
- NSString *result = [[NSString alloc] initWithBytes:ptr length:s_size encoding:NSUTF8StringEncoding];
52
- m_position += s_size;
53
- m_decryptBufferPosition += s_size;
54
- return [result autorelease];
55
- } else {
56
- throw out_of_range("InvalidProtocolBuffer truncatedMessage");
57
- }
58
- }
59
-
60
- } // namespace mmkv
61
-
62
- #endif // MMKV_APPLE && !MMKV_DISABLE_CRYPT
@@ -1,92 +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 "CodedInputData.h"
22
-
23
- #ifdef MMKV_APPLE
24
-
25
- # include "PBUtility.h"
26
- # include <stdexcept>
27
-
28
- # if __has_feature(objc_arc)
29
- # error This file must be compiled with MRC. Use -fno-objc-arc flag.
30
- # endif
31
-
32
- using namespace std;
33
-
34
- namespace mmkv {
35
-
36
- NSString *CodedInputData::readString() {
37
- int32_t size = this->readRawVarint32();
38
- if (size < 0) {
39
- throw length_error("InvalidProtocolBuffer negativeSize");
40
- }
41
-
42
- auto s_size = static_cast<size_t>(size);
43
- if (s_size <= m_size - m_position) {
44
- auto ptr = m_ptr + m_position;
45
- NSString *result = [[NSString alloc] initWithBytes:ptr length:s_size encoding:NSUTF8StringEncoding];
46
- m_position += s_size;
47
- return [result autorelease];
48
- } else {
49
- throw out_of_range("InvalidProtocolBuffer truncatedMessage");
50
- }
51
- }
52
-
53
- NSString *CodedInputData::readString(KeyValueHolder &kvHolder) {
54
- kvHolder.offset = static_cast<uint32_t>(m_position);
55
-
56
- int32_t size = this->readRawVarint32();
57
- if (size < 0) {
58
- throw length_error("InvalidProtocolBuffer negativeSize");
59
- }
60
-
61
- auto s_size = static_cast<size_t>(size);
62
- if (s_size <= m_size - m_position) {
63
- kvHolder.keySize = static_cast<uint16_t>(s_size);
64
-
65
- auto ptr = m_ptr + m_position;
66
- NSString *result = [[NSString alloc] initWithBytes:ptr length:s_size encoding:NSUTF8StringEncoding];
67
- m_position += s_size;
68
- return [result autorelease];
69
- } else {
70
- throw out_of_range("InvalidProtocolBuffer truncatedMessage");
71
- }
72
- }
73
-
74
- NSData *CodedInputData::readNSData() {
75
- int32_t size = this->readRawVarint32();
76
- if (size < 0) {
77
- throw length_error("InvalidProtocolBuffer negativeSize");
78
- }
79
-
80
- auto s_size = static_cast<size_t>(size);
81
- if (s_size <= m_size - m_position) {
82
- NSData *result = [NSData dataWithBytes:(m_ptr + m_position) length:s_size];
83
- m_position += s_size;
84
- return result;
85
- } else {
86
- throw out_of_range("InvalidProtocolBuffer truncatedMessage");
87
- }
88
- }
89
-
90
- } // namespace mmkv
91
-
92
- #endif // MMKV_APPLE
@@ -1,186 +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
- #include "CodedOutputData.h"
22
- #include "PBUtility.h"
23
- #include <cstring>
24
- #include <stdexcept>
25
-
26
- #ifdef MMKV_APPLE
27
- # if __has_feature(objc_arc)
28
- # error This file must be compiled with MRC. Use -fno-objc-arc flag.
29
- # endif
30
- #endif // MMKV_APPLE
31
-
32
- using namespace std;
33
-
34
- namespace mmkv {
35
-
36
- CodedOutputData::CodedOutputData(void *ptr, size_t len) : m_ptr((uint8_t *) ptr), m_size(len), m_position(0) {
37
- MMKV_ASSERT(m_ptr);
38
- }
39
-
40
- uint8_t *CodedOutputData::curWritePointer() {
41
- return m_ptr + m_position;
42
- }
43
-
44
- void CodedOutputData::writeDouble(double value) {
45
- this->writeRawLittleEndian64(Float64ToInt64(value));
46
- }
47
-
48
- void CodedOutputData::writeFloat(float value) {
49
- this->writeRawLittleEndian32(Float32ToInt32(value));
50
- }
51
-
52
- void CodedOutputData::writeInt64(int64_t value) {
53
- this->writeRawVarint64(value);
54
- }
55
-
56
- void CodedOutputData::writeUInt64(uint64_t value) {
57
- writeRawVarint64(static_cast<int64_t>(value));
58
- }
59
-
60
- void CodedOutputData::writeInt32(int32_t value) {
61
- if (value >= 0) {
62
- this->writeRawVarint32(value);
63
- } else {
64
- this->writeRawVarint64(value);
65
- }
66
- }
67
-
68
- void CodedOutputData::writeUInt32(uint32_t value) {
69
- writeRawVarint32(static_cast<int32_t>(value));
70
- }
71
-
72
- void CodedOutputData::writeBool(bool value) {
73
- this->writeRawByte(static_cast<uint8_t>(value ? 1 : 0));
74
- }
75
-
76
- void CodedOutputData::writeData(const MMBuffer &value) {
77
- this->writeRawVarint32((int32_t) value.length());
78
- this->writeRawData(value);
79
- }
80
-
81
- #ifndef MMKV_APPLE
82
-
83
- void CodedOutputData::writeString(const string &value) {
84
- size_t numberOfBytes = value.size();
85
- this->writeRawVarint32((int32_t) numberOfBytes);
86
- if (m_position + numberOfBytes > m_size) {
87
- auto msg = "m_position: " + to_string(m_position) + ", numberOfBytes: " + to_string(numberOfBytes) +
88
- ", m_size: " + to_string(m_size);
89
- throw out_of_range(msg);
90
- }
91
- memcpy(m_ptr + m_position, ((uint8_t *) value.data()), numberOfBytes);
92
- m_position += numberOfBytes;
93
- }
94
-
95
- #endif // MMKV_APPLE
96
-
97
- size_t CodedOutputData::spaceLeft() {
98
- if (m_size <= m_position) {
99
- return 0;
100
- }
101
- return m_size - m_position;
102
- }
103
-
104
- void CodedOutputData::seek(size_t addedSize) {
105
- m_position += addedSize;
106
-
107
- if (m_position > m_size) {
108
- throw out_of_range("OutOfSpace");
109
- }
110
- }
111
-
112
- void CodedOutputData::reset() {
113
- m_position = 0;
114
- }
115
-
116
- size_t CodedOutputData::getPosition() {
117
- return m_position;
118
- }
119
-
120
- void CodedOutputData::setPosition(size_t position) {
121
- m_position = position;
122
- }
123
-
124
- void CodedOutputData::writeRawByte(uint8_t value) {
125
- if (m_position == m_size) {
126
- throw out_of_range("m_position: " + to_string(m_position) + " m_size: " + to_string(m_size));
127
- return;
128
- }
129
-
130
- m_ptr[m_position++] = value;
131
- }
132
-
133
- void CodedOutputData::writeRawData(const MMBuffer &data) {
134
- size_t numberOfBytes = data.length();
135
- if (m_position + numberOfBytes > m_size) {
136
- auto msg = "m_position: " + to_string(m_position) + ", numberOfBytes: " + to_string(numberOfBytes) +
137
- ", m_size: " + to_string(m_size);
138
- throw out_of_range(msg);
139
- }
140
- memcpy(m_ptr + m_position, data.getPtr(), numberOfBytes);
141
- m_position += numberOfBytes;
142
- }
143
-
144
- void CodedOutputData::writeRawVarint32(int32_t value) {
145
- while (true) {
146
- if ((value & ~0x7f) == 0) {
147
- this->writeRawByte(static_cast<uint8_t>(value));
148
- return;
149
- } else {
150
- this->writeRawByte(static_cast<uint8_t>((value & 0x7F) | 0x80));
151
- value = logicalRightShift32(value, 7);
152
- }
153
- }
154
- }
155
-
156
- void CodedOutputData::writeRawVarint64(int64_t value) {
157
- while (true) {
158
- if ((value & ~0x7f) == 0) {
159
- this->writeRawByte(static_cast<uint8_t>(value));
160
- return;
161
- } else {
162
- this->writeRawByte(static_cast<uint8_t>((value & 0x7f) | 0x80));
163
- value = logicalRightShift64(value, 7);
164
- }
165
- }
166
- }
167
-
168
- void CodedOutputData::writeRawLittleEndian32(int32_t value) {
169
- this->writeRawByte(static_cast<uint8_t>((value) &0xff));
170
- this->writeRawByte(static_cast<uint8_t>((value >> 8) & 0xff));
171
- this->writeRawByte(static_cast<uint8_t>((value >> 16) & 0xff));
172
- this->writeRawByte(static_cast<uint8_t>((value >> 24) & 0xff));
173
- }
174
-
175
- void CodedOutputData::writeRawLittleEndian64(int64_t value) {
176
- this->writeRawByte(static_cast<uint8_t>((value) &0xff));
177
- this->writeRawByte(static_cast<uint8_t>((value >> 8) & 0xff));
178
- this->writeRawByte(static_cast<uint8_t>((value >> 16) & 0xff));
179
- this->writeRawByte(static_cast<uint8_t>((value >> 24) & 0xff));
180
- this->writeRawByte(static_cast<uint8_t>((value >> 32) & 0xff));
181
- this->writeRawByte(static_cast<uint8_t>((value >> 40) & 0xff));
182
- this->writeRawByte(static_cast<uint8_t>((value >> 48) & 0xff));
183
- this->writeRawByte(static_cast<uint8_t>((value >> 56) & 0xff));
184
- }
185
-
186
- } // namespace mmkv
@@ -1,88 +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_CODEDOUTPUTDATA_H
22
- #define MMKV_CODEDOUTPUTDATA_H
23
- #ifdef __cplusplus
24
-
25
- #include "MMKVPredef.h"
26
-
27
- #include "MMBuffer.h"
28
- #include <cstdint>
29
-
30
- namespace mmkv {
31
-
32
- class CodedOutputData {
33
- uint8_t *const m_ptr;
34
- size_t m_size;
35
- size_t m_position;
36
-
37
- public:
38
- CodedOutputData(void *ptr, size_t len);
39
-
40
- size_t spaceLeft();
41
-
42
- uint8_t *curWritePointer();
43
-
44
- void seek(size_t addedSize);
45
-
46
- void reset();
47
-
48
- size_t getPosition();
49
-
50
- void setPosition(size_t position);
51
-
52
- void writeRawByte(uint8_t value);
53
-
54
- void writeRawLittleEndian32(int32_t value);
55
-
56
- void writeRawLittleEndian64(int64_t value);
57
-
58
- void writeRawVarint32(int32_t value);
59
-
60
- void writeRawVarint64(int64_t value);
61
-
62
- void writeRawData(const MMBuffer &data);
63
-
64
- void writeDouble(double value);
65
-
66
- void writeFloat(float value);
67
-
68
- void writeInt64(int64_t value);
69
-
70
- void writeUInt64(uint64_t value);
71
-
72
- void writeInt32(int32_t value);
73
-
74
- void writeUInt32(uint32_t value);
75
-
76
- void writeBool(bool value);
77
-
78
- void writeData(const MMBuffer &value);
79
-
80
- #ifndef MMKV_APPLE
81
- void writeString(const std::string &value);
82
- #endif
83
- };
84
-
85
- } // namespace mmkv
86
-
87
- #endif
88
- #endif //MMKV_CODEDOUTPUTDATA_H