react-native-mmkv 2.6.0 → 2.7.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.
@@ -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
@@ -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()
@@ -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) {
@@ -34,7 +34,7 @@
34
34
  #include <vector>
35
35
  #include <unordered_map>
36
36
 
37
- constexpr auto MMKV_VERSION = "v1.2.14";
37
+ constexpr auto MMKV_VERSION = "v1.2.15";
38
38
 
39
39
  #ifdef DEBUG
40
40
  # define MMKV_DEBUG
@@ -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;
@@ -0,0 +1,193 @@
1
+ Tencent is pleased to support the open source community by making MMKV available.
2
+ Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
3
+ If you have downloaded a copy of the MMKV binary from Tencent, please note that the MMKV binary is licensed under the BSD 3-Clause License.
4
+ If you have downloaded a copy of the MMKV source code from Tencent, please note that MMKV source code is licensed under the BSD 3-Clause License, except for the third-party components listed below which are subject to different license terms. Your integration of MMKV into your own projects may require compliance with the BSD 3-Clause License, as well as the other licenses applicable to the third-party components included within MMKV.
5
+ A copy of the BSD 3-Clause License is included in this file.
6
+
7
+ Other dependencies and licenses:
8
+
9
+ Open Source Software Licensed Under the OpenSSL License:
10
+ ----------------------------------------------------------------------------------------
11
+ 1. OpenSSL 1.1.0i
12
+ Copyright (c) 1998-2018 The OpenSSL Project.
13
+ All rights reserved.
14
+ Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
15
+ All rights reserved.
16
+
17
+
18
+ Terms of the OpenSSL License:
19
+ ---------------------------------------------------
20
+ LICENSE ISSUES:
21
+ --------------------------------------------------------------------
22
+
23
+ The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the OpenSSL License and the original SSLeay license apply to the toolkit.
24
+ See below for the actual license texts.
25
+
26
+ OpenSSL License:
27
+ --------------------------------------------------------------------
28
+ Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
29
+
30
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
31
+
32
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
33
+
34
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
35
+
36
+ 3. All advertising materials mentioning features or use of this software must display the following acknowledgment:
37
+ "This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
38
+
39
+ 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact openssl-core@openssl.org.
40
+
41
+ 5. Products derived from this software may not be called "OpenSSL" nor may "OpenSSL" appear in their names without prior written permission of the OpenSSL Project.
42
+
43
+ 6. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/)"
44
+
45
+ THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
+ ====================================================================
47
+ * This product includes cryptographic software written by Eric Young (eay@cryptsoft.com). This product includes software written by Tim Hudson (tjh@cryptsoft.com).
48
+
49
+
50
+ Original SSLeay License:
51
+ --------------------------------------------------------------------
52
+ Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
53
+ All rights reserved.
54
+
55
+ This package is an SSL implementation written by Eric Young (eay@cryptsoft.com).
56
+ The implementation was written so as to conform with Netscapes SSL.
57
+
58
+ This library is free for commercial and non-commercial use as long as the following conditions are aheared to. The following conditions apply to all code found in this distribution, be it the RC4, RSA, lhash, DES, etc., code; not just the SSL code. The SSL documentation included with this distribution is covered by the same copyright terms except that the holder is Tim Hudson (tjh@cryptsoft.com).
59
+
60
+ Copyright remains Eric Young's, and as such any Copyright notices in the code are not to be removed. If this package is used in a product, Eric Young should be given attribution as the author of the parts of the library used. This can be in the form of a textual message at program startup or in documentation (online or textual) provided with the package.
61
+
62
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
63
+ 1. Redistributions of source code must retain the copyright notice, this list of conditions and the following disclaimer.
64
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
65
+ 3. All advertising materials mentioning features or use of this software must display the following acknowledgement:" This product includes cryptographic software written by Eric Young (eay@cryptsoft.com)" The word 'cryptographic' can be left out if the rouines from the library being used are not cryptographic related :-).
66
+ 4. If you include any Windows specific code (or a derivative thereof) from the apps directory (application code) you must include an acknowledgement: "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
67
+
68
+ THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69
+
70
+ The licence and distribution terms for any publically available version or derivative of this code cannot be changed. i.e. this code cannot simply be copied and put under another distribution licence [including the GNU Public Licence.]
71
+
72
+
73
+
74
+ Open Source Software Licensed Under the Apache License, Version 2.0:
75
+ The below software in this distribution may have been modified by THL A29 Limited (“Tencent Modifications”). All Tencent Modifications are Copyright (C) 2018 THL A29 Limited.
76
+ ----------------------------------------------------------------------------------------
77
+ 1. MultiprocessSharedPreferences v1.0
78
+ Copyright (C) 2014 seven456@gmail.com
79
+
80
+
81
+ Terms of the Apache License, Version 2.0:
82
+ --------------------------------------------------------------------
83
+ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
84
+
85
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
86
+
87
+ 1. Definitions.
88
+
89
+ “License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
90
+
91
+ “Licensor” shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
92
+
93
+ “Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
94
+
95
+ “You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License.
96
+
97
+ “Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
98
+
99
+ “Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
100
+
101
+ “Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
102
+
103
+ “Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
104
+
105
+ “Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as “Not a Contribution.”
106
+
107
+ “Contributor” shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
108
+
109
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
110
+
111
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
112
+
113
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
114
+
115
+ a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
116
+
117
+ b) You must cause any modified files to carry prominent notices stating that You changed the files; and
118
+
119
+ c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
120
+
121
+ d) If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
126
+
127
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
128
+
129
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
130
+
131
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
132
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
133
+
134
+ END OF TERMS AND CONDITIONS
135
+
136
+ APPENDIX: How to apply the Apache License to your work
137
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
138
+
139
+ Copyright [yyyy] [name of copyright owner]
140
+
141
+ Licensed under the Apache License, Version 2.0 (the "License");
142
+ you may not use this file except in compliance with the License.
143
+ You may obtain a copy of the License at
144
+ http://www.apache.org/licenses/LICENSE-2.0
145
+ Unless required by applicable law or agreed to in writing, software
146
+ distributed under the License is distributed on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
148
+ See the License for the specific language governing permissions and
149
+ limitations under the License.
150
+
151
+
152
+
153
+ Open Source Software Licensed Under the zlib License:
154
+ The below software in this distribution may have been modified by THL A29 Limited (“Tencent Modifications”). All Tencent Modifications are Copyright (C) 2018 THL A29 Limited.
155
+ ----------------------------------------------------------------------------------------
156
+ 1. zlib v1.2.11
157
+ Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
158
+
159
+ Terms of the zlib License:
160
+ --------------------------------------------------------------------
161
+
162
+ This software is provided 'as-is', without any express or implied
163
+ warranty. In no event will the authors be held liable for any damages
164
+ arising from the use of this software.
165
+
166
+ Permission is granted to anyone to use this software for any purpose,
167
+ including commercial applications, and to alter it and redistribute it
168
+ freely, subject to the following restrictions:
169
+
170
+ 1. The origin of this software must not be misrepresented; you must not
171
+ claim that you wrote the original software. If you use this software
172
+ in a product, an acknowledgment in the product documentation would be
173
+ appreciated but is not required.
174
+ 2. Altered source versions must be plainly marked as such, and must not be
175
+ misrepresented as being the original software.
176
+ 3. This notice may not be removed or altered from any source distribution.
177
+
178
+
179
+ Open Source Software Licensed Under the BSD 3-Clause License:
180
+ ----------------------------------------------------------------------------------------
181
+ 1. pybind11 v2.5.0
182
+ Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.
183
+
184
+ Terms of the BSD 3-Clause License:
185
+ --------------------------------------------------------------------
186
+
187
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
188
+
189
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
190
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
191
+ Neither the name of [copyright holder] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
192
+
193
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/MMKV/README.md ADDED
@@ -0,0 +1,291 @@
1
+ [![license](https://img.shields.io/badge/license-BSD_3-brightgreen.svg?style=flat)](https://github.com/Tencent/MMKV/blob/master/LICENSE.TXT)
2
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/MMKV/pulls)
3
+ [![Release Version](https://img.shields.io/badge/release-1.2.15-brightgreen.svg)](https://github.com/Tencent/MMKV/releases)
4
+ [![Platform](https://img.shields.io/badge/Platform-%20Android%20%7C%20iOS%2FmacOS%20%7C%20Win32%20%7C%20POSIX-brightgreen.svg)](https://github.com/Tencent/MMKV/wiki/home)
5
+
6
+ 中文版本请参看[这里](./README_CN.md)
7
+
8
+ MMKV is an **efficient**, **small**, **easy-to-use** mobile key-value storage framework used in the WeChat application. It's currently available on **Android**, **iOS/macOS**, **Win32** and **POSIX**.
9
+
10
+ # MMKV for Android
11
+
12
+ ## Features
13
+
14
+ * **Efficient**. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of Android to achieve the best performance.
15
+ * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.
16
+
17
+ * **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `sync`, no `apply` calls needed.
18
+
19
+ * **Small**.
20
+ * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.
21
+ * **About 50K in binary size**: MMKV adds about 50K per architecture on App size, and much less when zipped (APK).
22
+
23
+
24
+ ## Getting Started
25
+
26
+ ### Installation Via Maven
27
+ Add the following lines to `build.gradle` on your app module:
28
+
29
+ ```gradle
30
+ dependencies {
31
+ implementation 'com.tencent:mmkv:1.2.15'
32
+ // replace "1.2.15" with any available version
33
+ }
34
+ ```
35
+
36
+ Starting from v1.2.8, MMKV has been **migrated to Maven Central**.
37
+ For other installation options, see [Android Setup](https://github.com/Tencent/MMKV/wiki/android_setup).
38
+
39
+ ### Quick Tutorial
40
+ You can use MMKV as you go. All changes are saved immediately, no `sync`, no `apply` calls needed.
41
+ Setup MMKV on App startup, say your `Application` class, add these lines:
42
+
43
+ ```Java
44
+ public void onCreate() {
45
+ super.onCreate();
46
+
47
+ String rootDir = MMKV.initialize(this);
48
+ System.out.println("mmkv root: " + rootDir);
49
+ //……
50
+ }
51
+ ```
52
+
53
+ MMKV has a global instance, that can be used directly:
54
+
55
+ ```Java
56
+ import com.tencent.mmkv.MMKV;
57
+
58
+ MMKV kv = MMKV.defaultMMKV();
59
+
60
+ kv.encode("bool", true);
61
+ boolean bValue = kv.decodeBool("bool");
62
+
63
+ kv.encode("int", Integer.MIN_VALUE);
64
+ int iValue = kv.decodeInt("int");
65
+
66
+ kv.encode("string", "Hello from mmkv");
67
+ String str = kv.decodeString("string");
68
+ ```
69
+
70
+ MMKV also supports **Multi-Process Access**. Full tutorials can be found here [Android Tutorial](https://github.com/Tencent/MMKV/wiki/android_tutorial).
71
+
72
+ ## Performance
73
+ Writing random `int` for 1000 times, we get this chart:
74
+ ![](https://github.com/Tencent/MMKV/wiki/assets/profile_android_mini.png)
75
+ For more benchmark data, please refer to [our benchmark](https://github.com/Tencent/MMKV/wiki/android_benchmark).
76
+
77
+ # MMKV for iOS/macOS
78
+
79
+ ## Features
80
+
81
+ * **Efficient**. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of iOS/macOS to achieve the best performance.
82
+
83
+ * **Easy-to-use**. You can use MMKV as you go, no configurations are needed. All changes are saved immediately, no `synchronize` calls are needed.
84
+
85
+ * **Small**.
86
+ * **A handful of files**: MMKV contains encode/decode helpers and mmap logics and nothing more. It's really tidy.
87
+ * **Less than 30K in binary size**: MMKV adds less than 30K per architecture on App size, and much less when zipped (IPA).
88
+
89
+ ## Getting Started
90
+
91
+ ### Installation Via CocoaPods:
92
+ 1. Install [CocoaPods](https://guides.CocoaPods.org/using/getting-started.html);
93
+ 2. Open the terminal, `cd` to your project directory, run `pod repo update` to make CocoaPods aware of the latest available MMKV versions;
94
+ 3. Edit your Podfile, add `pod 'MMKV'` to your app target;
95
+ 4. Run `pod install`;
96
+ 5. Open the `.xcworkspace` file generated by CocoaPods;
97
+ 6. Add `#import <MMKV/MMKV.h>` to your source file and we are done.
98
+
99
+ For other installation options, see [iOS/macOS Setup](https://github.com/Tencent/MMKV/wiki/iOS_setup).
100
+
101
+ ### Quick Tutorial
102
+ You can use MMKV as you go, no configurations are needed. All changes are saved immediately, no `synchronize` calls are needed.
103
+ Setup MMKV on App startup, in your `-[MyApp application: didFinishLaunchingWithOptions:]`, add these lines:
104
+
105
+ ```objective-c
106
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
107
+ // init MMKV in the main thread
108
+ [MMKV initializeMMKV:nil];
109
+
110
+ //...
111
+ return YES;
112
+ }
113
+ ```
114
+
115
+ MMKV has a global instance, that can be used directly:
116
+
117
+ ```objective-c
118
+ MMKV *mmkv = [MMKV defaultMMKV];
119
+
120
+ [mmkv setBool:YES forKey:@"bool"];
121
+ BOOL bValue = [mmkv getBoolForKey:@"bool"];
122
+
123
+ [mmkv setInt32:-1024 forKey:@"int32"];
124
+ int32_t iValue = [mmkv getInt32ForKey:@"int32"];
125
+
126
+ [mmkv setString:@"hello, mmkv" forKey:@"string"];
127
+ NSString *str = [mmkv getStringForKey:@"string"];
128
+ ```
129
+
130
+ MMKV also supports **Multi-Process Access**. Full tutorials can be found [here](https://github.com/Tencent/MMKV/wiki/iOS_tutorial).
131
+
132
+ ## Performance
133
+ Writing random `int` for 10000 times, we get this chart:
134
+ ![](https://github.com/Tencent/MMKV/wiki/assets/profile_mini.png)
135
+ For more benchmark data, please refer to [our benchmark](https://github.com/Tencent/MMKV/wiki/iOS_benchmark).
136
+
137
+
138
+ # MMKV for Win32
139
+
140
+ ## Features
141
+
142
+ * **Efficient**. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of Windows to achieve the best performance.
143
+ * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.
144
+
145
+ * **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `save`, no `sync` calls are needed.
146
+
147
+ * **Small**.
148
+ * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.
149
+ * **About 10K in binary size**: MMKV adds about 10K on application size, and much less when zipped.
150
+
151
+
152
+ ## Getting Started
153
+
154
+ ### Installation Via Source
155
+ 1. Getting source code from git repository:
156
+
157
+ ```
158
+ git clone https://github.com/Tencent/MMKV.git
159
+ ```
160
+
161
+ 2. Add `Win32/MMKV/MMKV.vcxproj` to your solution;
162
+ 3. Add `MMKV` project to your project's dependencies;
163
+ 4. Add `$(OutDir)include` to your project's `C/C++` -> `General` -> `Additional Include Directories`;
164
+ 5. Add `$(OutDir)` to your project's `Linker` -> `General` -> `Additional Library Directories`;
165
+ 6. Add `MMKV.lib` to your project's `Linker` -> `Input` -> `Additional Dependencies`;
166
+ 7. Add `#include <MMKV/MMKV.h>` to your source file and we are done.
167
+
168
+
169
+ note:
170
+
171
+ 1. MMKV is compiled with `MT/MTd` runtime by default. If your project uses `MD/MDd`, you should change MMKV's setting to match your project's (`C/C++` -> `Code Generation` -> `Runtime Library`), or vice versa.
172
+ 2. MMKV is developed with Visual Studio 2017, change the `Platform Toolset` if you use a different version of Visual Studio.
173
+
174
+ For other installation options, see [Win32 Setup](https://github.com/Tencent/MMKV/wiki/windows_setup).
175
+
176
+ ### Quick Tutorial
177
+ You can use MMKV as you go. All changes are saved immediately, no `sync`, no `save` calls needed.
178
+ Setup MMKV on App startup, say in your `main()`, add these lines:
179
+
180
+ ```C++
181
+ #include <MMKV/MMKV.h>
182
+
183
+ int main() {
184
+ std::wstring rootDir = getYourAppDocumentDir();
185
+ MMKV::initializeMMKV(rootDir);
186
+ //...
187
+ }
188
+ ```
189
+
190
+ MMKV has a global instance, that can be used directly:
191
+
192
+ ```C++
193
+ auto mmkv = MMKV::defaultMMKV();
194
+
195
+ mmkv->set(true, "bool");
196
+ std::cout << "bool = " << mmkv->getBool("bool") << std::endl;
197
+
198
+ mmkv->set(1024, "int32");
199
+ std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;
200
+
201
+ mmkv->set("Hello, MMKV for Win32", "string");
202
+ std::string result;
203
+ mmkv->getString("string", result);
204
+ std::cout << "string = " << result << std::endl;
205
+ ```
206
+
207
+ MMKV also supports **Multi-Process Access**. Full tutorials can be found here [Win32 Tutorial](https://github.com/Tencent/MMKV/wiki/windows_tutorial).
208
+
209
+ # MMKV for POSIX
210
+
211
+ ## Features
212
+
213
+ * **Efficient**. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of POSIX to achieve the best performance.
214
+ * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.
215
+
216
+ * **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `save`, no `sync` calls are needed.
217
+
218
+ * **Small**.
219
+ * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.
220
+ * **About 7K in binary size**: MMKV adds about 7K on application size, and much less when zipped.
221
+
222
+
223
+ ## Getting Started
224
+
225
+ ### Installation Via CMake
226
+ 1. Getting source code from the git repository:
227
+
228
+ ```
229
+ git clone https://github.com/Tencent/MMKV.git
230
+ ```
231
+ 2. Edit your `CMakeLists.txt`, add those lines:
232
+
233
+ ```cmake
234
+ add_subdirectory(mmkv/POSIX/src mmkv)
235
+ target_link_libraries(MyApp
236
+ mmkv)
237
+ ```
238
+ 3. Add `#include "MMKV.h"` to your source file and we are done.
239
+
240
+ For other installation options, see [POSIX Setup](https://github.com/Tencent/MMKV/wiki/posix_setup).
241
+
242
+ ### Quick Tutorial
243
+ You can use MMKV as you go. All changes are saved immediately, no `sync`, no `save` calls needed.
244
+ Setup MMKV on App startup, say in your `main()`, add these lines:
245
+
246
+ ```C++
247
+ #include "MMKV.h"
248
+
249
+ int main() {
250
+ std::string rootDir = getYourAppDocumentDir();
251
+ MMKV::initializeMMKV(rootDir);
252
+ //...
253
+ }
254
+ ```
255
+
256
+ MMKV has a global instance, that can be used directly:
257
+
258
+ ```C++
259
+ auto mmkv = MMKV::defaultMMKV();
260
+
261
+ mmkv->set(true, "bool");
262
+ std::cout << "bool = " << mmkv->getBool("bool") << std::endl;
263
+
264
+ mmkv->set(1024, "int32");
265
+ std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;
266
+
267
+ mmkv->set("Hello, MMKV for Win32", "string");
268
+ std::string result;
269
+ mmkv->getString("string", result);
270
+ std::cout << "string = " << result << std::endl;
271
+ ```
272
+
273
+ MMKV also supports **Multi-Process Access**. Full tutorials can be found here [POSIX Tutorial](https://github.com/Tencent/MMKV/wiki/posix_tutorial).
274
+
275
+ ## License
276
+ MMKV is published under the BSD 3-Clause license. For details check out the [LICENSE.TXT](./LICENSE.TXT).
277
+
278
+ ## Change Log
279
+ Check out the [CHANGELOG.md](./CHANGELOG.md) for details of change history.
280
+
281
+ ## Contributing
282
+
283
+ If you are interested in contributing, check out the [CONTRIBUTING.md](./CONTRIBUTING.md), also join our [Tencent OpenSource Plan](https://opensource.tencent.com/contribution).
284
+
285
+ To give clarity of what is expected of our members, MMKV has adopted the code of conduct defined by the Contributor Covenant, which is widely used. And we think it articulates our values well. For more, check out the [Code of Conduct](./CODE_OF_CONDUCT.md).
286
+
287
+ ## FAQ & Feedback
288
+ Check out the [FAQ](https://github.com/Tencent/MMKV/wiki/FAQ) first. Should there be any questions, don't hesitate to create [issues](https://github.com/Tencent/MMKV/issues).
289
+
290
+ ## Personal Information Protection Rules
291
+ User privacy is taken very seriously: MMKV does not obtain, collect or upload any personal information. Please refer to the [MMKV SDK Personal Information Protection Rules](https://support.weixin.qq.com/cgi-bin/mmsupportacctnodeweb-bin/pages/aY5BAtRiO1BpoHxo) for details.
package/README.md CHANGED
@@ -104,7 +104,8 @@ import { MMKV } from 'react-native-mmkv'
104
104
  export const storage = new MMKV({
105
105
  id: `user-${userId}-storage`,
106
106
  path: `${USER_DIRECTORY}/storage`,
107
- encryptionKey: 'hunter2'
107
+ encryptionKey: 'hunter2',
108
+ fastWrites: true
108
109
  })
109
110
  ```
110
111
 
@@ -115,6 +116,7 @@ The following values can be configured:
115
116
  * `id`: The MMKV instance's ID. If you want to use multiple instances, use different IDs. For example, you can separate the global app's storage and a logged-in user's storage. (required if `path` or `encryptionKey` fields are specified, otherwise defaults to: `'mmkv.default'`)
116
117
  * `path`: The MMKV instance's root path. By default, MMKV stores file inside `$(Documents)/mmkv/`. You can customize MMKV's root directory on MMKV initialization (documentation: [iOS](https://github.com/Tencent/MMKV/wiki/iOS_advance#customize-location) / [Android](https://github.com/Tencent/MMKV/wiki/android_advance#customize-location))
117
118
  * `encryptionKey`: The MMKV instance's encryption/decryption key. By default, MMKV stores all key-values in plain text on file, relying on iOS's/Android's sandbox to make sure the file is encrypted. Should you worry about information leaking, you can choose to encrypt MMKV. (documentation: [iOS](https://github.com/Tencent/MMKV/wiki/iOS_advance#encryption) / [Android](https://github.com/Tencent/MMKV/wiki/android_advance#encryption))
119
+ * `fastWrites`: Configure fast writes for MMKV. When set to `true`, all calls to `set(..)` do not overwrite the previous value to avoid storage resizing, this speeds up write speed. Only enable this if you use a small MMKV storage, as this uses more RAM.
118
120
 
119
121
  ### Set
120
122
 
@@ -27,7 +27,9 @@ def isNewArchitectureEnabled() {
27
27
  return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
28
28
  }
29
29
 
30
- apply plugin: 'com.facebook.react'
30
+ if (isNewArchitectureEnabled()) {
31
+ apply plugin: 'com.facebook.react'
32
+ }
31
33
  apply plugin: 'com.android.library'
32
34
 
33
35
  def safeExtGet(prop, fallback) {
@@ -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
@@ -25,7 +25,9 @@ class MMKV {
25
25
  _defineProperty(this, "nativeInstance", void 0);
26
26
  _defineProperty(this, "functionCache", void 0);
27
27
  _defineProperty(this, "id", void 0);
28
+ _defineProperty(this, "fastWrites", void 0);
28
29
  this.id = configuration.id;
30
+ this.fastWrites = configuration.fastWrites ?? false;
29
31
  this.nativeInstance = (0, _PlatformChecker.isJest)() ? (0, _createMMKV2.createMockMMKV)() : (0, _createMMKV.createMMKV)(configuration);
30
32
  this.functionCache = {};
31
33
  }
@@ -50,6 +52,10 @@ class MMKV {
50
52
  }
51
53
  }
52
54
  set(key, value) {
55
+ if (!this.fastWrites) {
56
+ // Delete the value first. MMKV just leaves old values dangling by default
57
+ this.delete(key);
58
+ }
53
59
  const func = this.getFunctionFromCache('set');
54
60
  func(key, value);
55
61
  this.onValuesChanged([key]);
@@ -1 +1 @@
1
- {"version":3,"names":["onValueChangedListeners","Map","MMKV","constructor","configuration","id","nativeInstance","isJest","createMockMMKV","createMMKV","functionCache","has","set","get","getFunctionFromCache","functionName","onValuesChanged","keys","length","key","listener","value","func","getBoolean","getString","getNumber","getBuffer","contains","delete","getAllKeys","clearAll","recrypt","toString","join","toJSON","addOnValueChangedListener","onValueChanged","push","remove","index","indexOf","splice"],"sourceRoot":"../../src","sources":["MMKV.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AAA2C;AA+H3C,MAAMA,uBAAuB,GAAG,IAAIC,GAAG,EAAqC;;AAE5E;AACA;AACA;AACO,MAAMC,IAAI,CAA0B;EAKzC;AACF;AACA;AACA;EACEC,WAAW,GAA4D;IAAA,IAA3DC,aAAgC,uEAAG;MAAEC,EAAE,EAAE;IAAe,CAAC;IAAA;IAAA;IAAA;IACnE,IAAI,CAACA,EAAE,GAAGD,aAAa,CAACC,EAAE;IAC1B,IAAI,CAACC,cAAc,GAAG,IAAAC,uBAAM,GAAE,GAC1B,IAAAC,2BAAc,GAAE,GAChB,IAAAC,sBAAU,EAACL,aAAa,CAAC;IAC7B,IAAI,CAACM,aAAa,GAAG,CAAC,CAAC;EACzB;EAEA,IAAYV,uBAAuB,GAAG;IACpC,IAAI,CAACA,uBAAuB,CAACW,GAAG,CAAC,IAAI,CAACN,EAAE,CAAC,EAAE;MACzCL,uBAAuB,CAACY,GAAG,CAAC,IAAI,CAACP,EAAE,EAAE,EAAE,CAAC;IAC1C;IACA,OAAOL,uBAAuB,CAACa,GAAG,CAAC,IAAI,CAACR,EAAE,CAAC;EAC7C;EAEQS,oBAAoB,CAC1BC,YAAe,EACA;IACf,IAAI,IAAI,CAACL,aAAa,CAACK,YAAY,CAAC,IAAI,IAAI,EAAE;MAC5C,IAAI,CAACL,aAAa,CAACK,YAAY,CAAC,GAAG,IAAI,CAACT,cAAc,CAACS,YAAY,CAAC;IACtE;IACA,OAAO,IAAI,CAACL,aAAa,CAACK,YAAY,CAAC;EACzC;EAEQC,eAAe,CAACC,IAAc,EAAE;IACtC,IAAI,IAAI,CAACjB,uBAAuB,CAACkB,MAAM,KAAK,CAAC,EAAE;IAE/C,KAAK,MAAMC,GAAG,IAAIF,IAAI,EAAE;MACtB,KAAK,MAAMG,Q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IAAI,GAAG,IAAI,CAACR,oBAAoB,CAAC,YAAY,CAAC;IACpD,OAAOQ,IAAI,EAAE;EACf;EACAQ,QAAQ,GAAS;IACf,MAAMb,IAAI,GAAG,IAAI,CAACY,UAAU,EAAE;IAE9B,MAAMP,IAAI,GAAG,IAAI,CAACR,oBAAoB,CAAC,UAAU,CAAC;IAClDQ,IAAI,EAAE;IAEN,IAAI,CAACN,eAAe,CAACC,IAAI,CAAC;EAC5B;EACAc,OAAO,CAACZ,GAAuB,EAAQ;IACrC,MAAMG,IAAI,GAAG,IAAI,CAACR,oBAAoB,CAAC,SAAS,CAAC;IACjD,OAAOQ,IAAI,CAACH,GAAG,CAAC;EAClB;EAEAa,QAAQ,GAAW;IACjB,OAAQ,SAAQ,IAAI,CAAC3B,EAAG,OAAM,IAAI,CAACwB,UAAU,EAAE,CAACI,IAAI,CAAC,IAAI,CAAE,GAAE;EAC/D;EACAC,MAAM,GAAW;IACf,OAAO;MACL,CAAC,IAAI,CAAC7B,EAAE,GAAG,IAAI,CAACwB,UAAU;IAC5B,CAAC;EACH;EAEAM,yBAAyB,CAACC,cAAqC,EAAY;IACzE,IAAI,CAACpC,uBAAuB,CAACqC,IAAI,CAACD,cAAc,CAAC;IAEjD,OAAO;MACLE,MAAM,EAAE,MAAM;QACZ,MAAMC,KAAK,GAAG,IAAI,CAACvC,uBAAuB,CAACwC,OAAO,CAACJ,cAAc,CAAC;QAClE,IAAIG,KAAK,KAAK,CAAC,CAAC,EAAE;UAChB,IAAI,CAACvC,uBAAuB,CAACyC,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;QAC/C;MACF;IACF,CAAC;EACH;AACF;AAAC"}
1
+ {"version":3,"names":["onValueChangedListeners","Map","MMKV","constructor","configuration","id","fastWrites","nativeInstance","isJest","createMockMMKV","createMMKV","functionCache","has","set","get","getFunctionFromCache","functionName","onValuesChanged","keys","length","key","listener","value","delete","func","getBoolean","getString","getNumber","getBuffer","contains","getAllKeys","clearAll","recrypt","toString","join","toJSON","addOnValueChangedListener","onValueChanged","push","remove","index","indexOf","splice"],"sourceRoot":"../../src","sources":["MMKV.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AAA2C;AA0I3C,MAAMA,uBAAuB,GAAG,IAAIC,GAAG,EAAqC;;AAE5E;AACA;AACA;AACO,MAAMC,IAAI,CAA0B;EAMzC;AACF;AACA;AACA;EACEC,WAAW,GAA4D;IAAA,IAA3DC,aAAgC,uEAAG;MAAEC,EAAE,EAAE;IAAe,CAAC;IAAA;IAAA;IAAA;IAAA;IACnE,IAAI,CAACA,EAAE,GAAGD,aAAa,CAACC,EAAE;IAC1B,IAAI,CAACC,UAAU,GAAGF,aAAa,CAACE,UAAU,IAAI,KAAK;IACnD,IAAI,CAACC,cAAc,GAAG,IAAAC,uBAAM,GAAE,GAC1B,IAAAC,2BAAc,GAAE,GAChB,IAAAC,sBAAU,EAACN,aAAa,CAAC;IAC7B,IAAI,CAACO,aAAa,GAAG,CAAC,CAAC;EACzB;EAEA,IAAYX,uBAAuB,GAAG;IACpC,IAAI,CAACA,uBAAuB,CAACY,GAAG,CAAC,IAAI,CAACP,EAAE,CAAC,EAAE;MACzCL,uBAAuB,CAACa,GAAG,CAAC,IAAI,CAACR,EAAE,EAAE,EAAE,CAAC;IAC1C;IACA,OAAOL,uBAAuB,CAACc,GAAG,CAAC,IAAI,CAACT,EAAE,CAAC;EAC7C;EAEQU,oBAAoB,CAC1BC,YAAe,EACA;IACf,IAAI,IAAI,CAACL,aAAa,CAACK,YAAY,CAAC,IAAI,IAAI,EAAE;MAC5C,IAAI,CAACL,aAAa,CAACK,YAAY,CAAC,GAAG,IAAI,CAACT,cAAc,CAACS,YAAY,CAAC;IACtE;IACA,OAAO,IAAI,CAACL,aAAa,CAACK,YAAY,CAAC;EACzC;EAEQC,eAAe,CAACC,IAAc,EAAE;IACtC,IAAI,IAAI,CAAClB,uBAAuB,CAACmB,MAAM,KAAK,CAAC,EAAE;IAE/C,KAAK,MAAMC,GAAG,IA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ineProperty(this, "functionCache", void 0);
21
21
  _defineProperty(this, "id", void 0);
22
+ _defineProperty(this, "fastWrites", void 0);
22
23
  this.id = configuration.id;
24
+ this.fastWrites = configuration.fastWrites ?? false;
23
25
  this.nativeInstance = isJest() ? createMockMMKV() : createMMKV(configuration);
24
26
  this.functionCache = {};
25
27
  }
@@ -44,6 +46,10 @@ export class MMKV {
44
46
  }
45
47
  }
46
48
  set(key, value) {
49
+ if (!this.fastWrites) {
50
+ // Delete the value first. MMKV just leaves old values dangling by default
51
+ this.delete(key);
52
+ }
47
53
  const func = this.getFunctionFromCache('set');
48
54
  func(key, value);
49
55
  this.onValuesChanged([key]);
@@ -1 +1 @@
1
- {"version":3,"names":["createMMKV","createMockMMKV","isJest","onValueChangedListeners","Map","MMKV","constructor","configuration","id","nativeInstance","functionCache","has","set","get","getFunctionFromCache","functionName","onValuesChanged","keys","length","key","listener","value","func","getBoolean","getString","getNumber","getBuffer","contains","delete","getAllKeys","clearAll","recrypt","toString","join","toJSON","addOnValueChangedListener","onValueChanged","push","remove","index","indexOf","splice"],"sourceRoot":"../../src","sources":["MMKV.ts"],"mappings":";AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,MAAM,QAAQ,mBAAmB;AA+H1C,MAAMC,uBAAuB,GAAG,IAAIC,GAAG,EAAqC;;AAE5E;AACA;AACA;AACA,OAAO,MAAMC,IAAI,CAA0B;EAKzC;AACF;AACA;AACA;EACEC,WAAW,GAA4D;IAAA,IAA3DC,aAAgC,uEAAG;MAAEC,EAAE,EAAE;IAAe,CAAC;IAAA;IAAA;IAAA;IACnE,IAAI,CAACA,EAAE,GAAGD,aAAa,CAACC,EAAE;IAC1B,IAAI,CAACC,cAAc,GAAGP,MAAM,EAAE,GAC1BD,cAAc,EAAE,GAChBD,UAAU,CAACO,aAAa,CAAC;IAC7B,IAAI,CAACG,aAAa,GAAG,CAAC,CAAC;EACzB;EAEA,IAAYP,uBAAu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CAAC,IAAI,CAAC1B,EAAE,GAAG,IAAI,CAACqB,UAAU;IAC5B,CAAC;EACH;EAEAM,yBAAyB,CAACC,cAAqC,EAAY;IACzE,IAAI,CAACjC,uBAAuB,CAACkC,IAAI,CAACD,cAAc,CAAC;IAEjD,OAAO;MACLE,MAAM,EAAE,MAAM;QACZ,MAAMC,KAAK,GAAG,IAAI,CAACpC,uBAAuB,CAACqC,OAAO,CAACJ,cAAc,CAAC;QAClE,IAAIG,KAAK,KAAK,CAAC,CAAC,EAAE;UAChB,IAAI,CAACpC,uBAAuB,CAACsC,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;QAC/C;MACF;IACF,CAAC;EACH;AACF"}
1
+ {"version":3,"names":["createMMKV","createMockMMKV","isJest","onValueChangedListeners","Map","MMKV","constructor","configuration","id","fastWrites","nativeInstance","functionCache","has","set","get","getFunctionFromCache","functionName","onValuesChanged","keys","length","key","listener","value","delete","func","getBoolean","getString","getNumber","getBuffer","contains","getAllKeys","clearAll","recrypt","toString","join","toJSON","addOnValueChangedListener","onValueChanged","push","remove","index","indexOf","splice"],"sourceRoot":"../../src","sources":["MMKV.ts"],"mappings":";AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,MAAM,QAAQ,mBAAmB;AA0I1C,MAAMC,uBAAuB,GAAG,IAAIC,GAAG,EAAqC;;AAE5E;AACA;AACA;AACA,OAAO,MAAMC,IAAI,CAA0B;EAMzC;AACF;AACA;AACA;EACEC,WAAW,GAA4D;IAAA,IAA3DC,aAAgC,uEAAG;MAAEC,EAAE,EAAE;IAAe,CAAC;IAAA;IAAA;IAAA;IAAA;IACnE,IAAI,CAACA,EAAE,GAAGD,aAAa,CAACC,EAAE;IAC1B,IAAI,CAACC,UAAU,GAAGF,aAAa,CAACE,UAAU,IAAI,KAAK;IACnD,IAAI,CAACC,cAAc,GAAGR,MAAM,EAAE,GAC1BD,cAAc,EAAE,GAChBD,UAAU,CA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AClB;EAEAa,QAAQ,GAAW;IACjB,OAAQ,SAAQ,IAAI,CAACzB,EAAG,OAAM,IAAI,CAACsB,UAAU,EAAE,CAACI,IAAI,CAAC,IAAI,CAAE,GAAE;EAC/D;EACAC,MAAM,GAAW;IACf,OAAO;MACL,CAAC,IAAI,CAAC3B,EAAE,GAAG,IAAI,CAACsB,UAAU;IAC5B,CAAC;EACH;EAEAM,yBAAyB,CAACC,cAAqC,EAAY;IACzE,IAAI,CAAClC,uBAAuB,CAACmC,IAAI,CAACD,cAAc,CAAC;IAEjD,OAAO;MACLE,MAAM,EAAE,MAAM;QACZ,MAAMC,KAAK,GAAG,IAAI,CAACrC,uBAAuB,CAACsC,OAAO,CAACJ,cAAc,CAAC;QAClE,IAAIG,KAAK,KAAK,CAAC,CAAC,EAAE;UAChB,IAAI,CAACrC,uBAAuB,CAACuC,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;QAC/C;MACF;IACF,CAAC;EACH;AACF"}
@@ -37,6 +37,17 @@ export interface MMKVConfiguration {
37
37
  * ```
38
38
  */
39
39
  encryptionKey?: string;
40
+ /**
41
+ * Configure fast writes for MMKV.
42
+ *
43
+ * When set to `true`, all calls to `set(..)` do not overwrite the previous
44
+ * value to avoid storage resizing, this speeds up writes.
45
+ *
46
+ * Only enable this if you use a small MMKV storage, as this uses more RAM.
47
+ *
48
+ * @default false
49
+ */
50
+ fastWrites?: boolean;
40
51
  }
41
52
  /**
42
53
  * Represents a single MMKV instance.
@@ -112,6 +123,7 @@ export declare class MMKV implements MMKVInterface {
112
123
  private nativeInstance;
113
124
  private functionCache;
114
125
  private id;
126
+ private fastWrites;
115
127
  /**
116
128
  * Creates a new MMKV instance with the given Configuration.
117
129
  * If no custom `id` is supplied, `'mmkv.default'` will be used.
@@ -1 +1 @@
1
- {"version":3,"file":"MMKV.d.ts","sourceRoot":"","sources":["../../src/MMKV.ts"],"names":[],"mappings":"AAIA,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,IAAI,C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": "react-native-mmkv",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
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",
@@ -72,7 +71,7 @@
72
71
  },
73
72
  "peerDependencies": {
74
73
  "react": "*",
75
- "react-native": "*"
74
+ "react-native": ">=0.71.0"
76
75
  },
77
76
  "jest": {
78
77
  "preset": "react-native",
@@ -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
  }