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
package/MMKV/README.md DELETED
@@ -1,354 +0,0 @@
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-2.0.0-brightgreen.svg)](https://github.com/Tencent/MMKV/releases)
4
- [![Platform](https://img.shields.io/badge/Platform-%20Android%20%7C%20iOS%2FmacOS%20%7C%20Windows%20%7C%20POSIX%20%7C%20HarmonyOS%20NEXT-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**, **Windows**, **POSIX** and **HarmonyOS NEXT**.
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:2.0.0'
32
- // replace "2.0.0" with any available version
33
- }
34
- ```
35
-
36
- For other installation options, see [Android Setup](https://github.com/Tencent/MMKV/wiki/android_setup).
37
-
38
- ### Quick Tutorial
39
- You can use MMKV as you go. All changes are saved immediately, no `sync`, no `apply` calls needed.
40
- Setup MMKV on App startup, say your `Application` class, add these lines:
41
-
42
- ```Java
43
- public void onCreate() {
44
- super.onCreate();
45
-
46
- String rootDir = MMKV.initialize(this);
47
- System.out.println("mmkv root: " + rootDir);
48
- //……
49
- }
50
- ```
51
-
52
- MMKV has a global instance, that can be used directly:
53
-
54
- ```Java
55
- import com.tencent.mmkv.MMKV;
56
-
57
- MMKV kv = MMKV.defaultMMKV();
58
-
59
- kv.encode("bool", true);
60
- boolean bValue = kv.decodeBool("bool");
61
-
62
- kv.encode("int", Integer.MIN_VALUE);
63
- int iValue = kv.decodeInt("int");
64
-
65
- kv.encode("string", "Hello from mmkv");
66
- String str = kv.decodeString("string");
67
- ```
68
-
69
- MMKV also supports **Multi-Process Access**. Full tutorials can be found here [Android Tutorial](https://github.com/Tencent/MMKV/wiki/android_tutorial).
70
-
71
- ## Performance
72
- Writing random `int` for 1000 times, we get this chart:
73
- ![](https://github.com/Tencent/MMKV/wiki/assets/profile_android_mini.png)
74
- For more benchmark data, please refer to [our benchmark](https://github.com/Tencent/MMKV/wiki/android_benchmark).
75
-
76
- # MMKV for iOS/macOS
77
-
78
- ## Features
79
-
80
- * **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.
81
-
82
- * **Easy-to-use**. You can use MMKV as you go, no configurations are needed. All changes are saved immediately, no `synchronize` calls are needed.
83
-
84
- * **Small**.
85
- * **A handful of files**: MMKV contains encode/decode helpers and mmap logics and nothing more. It's really tidy.
86
- * **Less than 30K in binary size**: MMKV adds less than 30K per architecture on App size, and much less when zipped (IPA).
87
-
88
- ## Getting Started
89
-
90
- ### Installation Via CocoaPods:
91
- 1. Install [CocoaPods](https://guides.CocoaPods.org/using/getting-started.html);
92
- 2. Open the terminal, `cd` to your project directory, run `pod repo update` to make CocoaPods aware of the latest available MMKV versions;
93
- 3. Edit your Podfile, add `pod 'MMKV'` to your app target;
94
- 4. Run `pod install`;
95
- 5. Open the `.xcworkspace` file generated by CocoaPods;
96
- 6. Add `#import <MMKV/MMKV.h>` to your source file and we are done.
97
-
98
- For other installation options, see [iOS/macOS Setup](https://github.com/Tencent/MMKV/wiki/iOS_setup).
99
-
100
- ### Quick Tutorial
101
- You can use MMKV as you go, no configurations are needed. All changes are saved immediately, no `synchronize` calls are needed.
102
- Setup MMKV on App startup, in your `-[MyApp application: didFinishLaunchingWithOptions:]`, add these lines:
103
-
104
- ```objective-c
105
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
106
- // init MMKV in the main thread
107
- [MMKV initializeMMKV:nil];
108
-
109
- //...
110
- return YES;
111
- }
112
- ```
113
-
114
- MMKV has a global instance, that can be used directly:
115
-
116
- ```objective-c
117
- MMKV *mmkv = [MMKV defaultMMKV];
118
-
119
- [mmkv setBool:YES forKey:@"bool"];
120
- BOOL bValue = [mmkv getBoolForKey:@"bool"];
121
-
122
- [mmkv setInt32:-1024 forKey:@"int32"];
123
- int32_t iValue = [mmkv getInt32ForKey:@"int32"];
124
-
125
- [mmkv setString:@"hello, mmkv" forKey:@"string"];
126
- NSString *str = [mmkv getStringForKey:@"string"];
127
- ```
128
-
129
- MMKV also supports **Multi-Process Access**. Full tutorials can be found [here](https://github.com/Tencent/MMKV/wiki/iOS_tutorial).
130
-
131
- ## Performance
132
- Writing random `int` for 10000 times, we get this chart:
133
- ![](https://github.com/Tencent/MMKV/wiki/assets/profile_mini.png)
134
- For more benchmark data, please refer to [our benchmark](https://github.com/Tencent/MMKV/wiki/iOS_benchmark).
135
-
136
-
137
- # MMKV for Windows
138
-
139
- ## Features
140
-
141
- * **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.
142
- * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.
143
-
144
- * **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `save`, no `sync` calls are needed.
145
-
146
- * **Small**.
147
- * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.
148
- * **About 10K in binary size**: MMKV adds about 10K on application size, and much less when zipped.
149
-
150
-
151
- ## Getting Started
152
-
153
- ### Installation Via Source
154
- 1. Getting source code from git repository:
155
-
156
- ```
157
- git clone https://github.com/Tencent/MMKV.git
158
- ```
159
-
160
- 2. Add `Core/core.vcxproj` to your solution;
161
- 3. Add `MMKV` project to your project's dependencies;
162
- 4. Add `$(OutDir)include` to your project's `C/C++` -> `General` -> `Additional Include Directories`;
163
- 5. Add `$(OutDir)` to your project's `Linker` -> `General` -> `Additional Library Directories`;
164
- 6. Add `mmkv.lib` to your project's `Linker` -> `Input` -> `Additional Dependencies`;
165
- 7. Add `#include <MMKV/MMKV.h>` to your source file and we are done.
166
-
167
-
168
- note:
169
-
170
- 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.
171
- 2. MMKV is developed with Visual Studio 2017, change the `Platform Toolset` if you use a different version of Visual Studio.
172
-
173
- For other installation options, see [Windows Setup](https://github.com/Tencent/MMKV/wiki/windows_setup).
174
-
175
- ### Quick Tutorial
176
- You can use MMKV as you go. All changes are saved immediately, no `sync`, no `save` calls needed.
177
- Setup MMKV on App startup, say in your `main()`, add these lines:
178
-
179
- ```C++
180
- #include <MMKV/MMKV.h>
181
-
182
- int main() {
183
- std::wstring rootDir = getYourAppDocumentDir();
184
- MMKV::initializeMMKV(rootDir);
185
- //...
186
- }
187
- ```
188
-
189
- MMKV has a global instance, that can be used directly:
190
-
191
- ```C++
192
- auto mmkv = MMKV::defaultMMKV();
193
-
194
- mmkv->set(true, "bool");
195
- std::cout << "bool = " << mmkv->getBool("bool") << std::endl;
196
-
197
- mmkv->set(1024, "int32");
198
- std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;
199
-
200
- mmkv->set("Hello, MMKV for Windows", "string");
201
- std::string result;
202
- mmkv->getString("string", result);
203
- std::cout << "string = " << result << std::endl;
204
- ```
205
-
206
- MMKV also supports **Multi-Process Access**. Full tutorials can be found here [Windows Tutorial](https://github.com/Tencent/MMKV/wiki/windows_tutorial).
207
-
208
- # MMKV for POSIX
209
-
210
- ## Features
211
-
212
- * **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.
213
- * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.
214
-
215
- * **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `save`, no `sync` calls are needed.
216
-
217
- * **Small**.
218
- * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.
219
- * **About 7K in binary size**: MMKV adds about 7K on application size, and much less when zipped.
220
-
221
-
222
- ## Getting Started
223
-
224
- ### Installation Via CMake
225
- 1. Getting source code from the git repository:
226
-
227
- ```
228
- git clone https://github.com/Tencent/MMKV.git
229
- ```
230
- 2. Edit your `CMakeLists.txt`, add those lines:
231
-
232
- ```cmake
233
- add_subdirectory(mmkv/POSIX/src mmkv)
234
- target_link_libraries(MyApp
235
- mmkv)
236
- ```
237
- 3. Add `#include "MMKV.h"` to your source file and we are done.
238
-
239
- For other installation options, see [POSIX Setup](https://github.com/Tencent/MMKV/wiki/posix_setup).
240
-
241
- ### Quick Tutorial
242
- You can use MMKV as you go. All changes are saved immediately, no `sync`, no `save` calls needed.
243
- Setup MMKV on App startup, say in your `main()`, add these lines:
244
-
245
- ```C++
246
- #include "MMKV.h"
247
-
248
- int main() {
249
- std::string rootDir = getYourAppDocumentDir();
250
- MMKV::initializeMMKV(rootDir);
251
- //...
252
- }
253
- ```
254
-
255
- MMKV has a global instance, that can be used directly:
256
-
257
- ```C++
258
- auto mmkv = MMKV::defaultMMKV();
259
-
260
- mmkv->set(true, "bool");
261
- std::cout << "bool = " << mmkv->getBool("bool") << std::endl;
262
-
263
- mmkv->set(1024, "int32");
264
- std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;
265
-
266
- mmkv->set("Hello, MMKV for Windows", "string");
267
- std::string result;
268
- mmkv->getString("string", result);
269
- std::cout << "string = " << result << std::endl;
270
- ```
271
-
272
- MMKV also supports **Multi-Process Access**. Full tutorials can be found here [POSIX Tutorial](https://github.com/Tencent/MMKV/wiki/posix_tutorial).
273
-
274
- # MMKV for HarmonyOS NEXT
275
-
276
- ## Features
277
-
278
- * **Efficient**. MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values, making the most of native platform to achieve best performance.
279
- * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes.
280
-
281
- * **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `sync`, no `flush` calls needed.
282
-
283
- * **Small**.
284
- * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics and nothing more. It's really tidy.
285
- * **About 600K in binary size**: MMKV adds about 600K per architecture on App size, and much less when zipped (HAR/HAP).
286
-
287
-
288
- ## Getting Started
289
- ### Installation via OHPM:
290
-
291
- ```bash
292
- ohpm install @tencent/mmkv
293
- ```
294
- ### Quick Tutorial
295
- You can use MMKV as you go. All changes are saved immediately, no `sync`, no `apply` calls needed.
296
- Setup MMKV on App startup, say your `EntryAbility.onCreate()` function, add these lines:
297
-
298
- ```js
299
- import { MMKV } from '@tencent/mmkv';
300
-
301
- export default class EntryAbility extends UIAbility {
302
- onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
303
- let appCtx = this.context.getApplicationContext();
304
- let mmkvRootDir = MMKV.initialize(appCtx);
305
- console.info('mmkv rootDir: ', mmkvRootDir);
306
- ……
307
- }
308
- ```
309
-
310
- MMKV has a global instance, that can be used directly:
311
-
312
- ```js
313
- import { MMKV } from '@tencent/mmkv';
314
-
315
- let mmkv = MMKV.defaultMMKV();
316
- mmkv.encodeBool('bool', true);
317
- console.info('bool = ', mmkv.decodeBool('bool'));
318
-
319
- mmkv.encodeInt32('int32', Math.pow(2, 31) - 1);
320
- console.info('max int32 = ', mmkv.decodeInt32('int32'));
321
-
322
- mmkv.encodeInt64('int', BigInt(2**63) - BigInt(1));
323
- console.info('max int64 = ', mmkv.decodeInt64('int'));
324
-
325
- let str: string = 'Hello OpenHarmony from MMKV';
326
- mmkv.encodeString('string', str);
327
- console.info('string = ', mmkv.decodeString('string'));
328
-
329
- let arrayBuffer: ArrayBuffer = StringToArrayBuffer('Hello OpenHarmony from MMKV with bytes');
330
- mmkv.encodeBytes('bytes', arrayBuffer);
331
- let bytes = mmkv.decodeBytes('bytes');
332
- console.info('bytes = ', ArrayBufferToString(bytes));
333
- ```
334
-
335
- As you can see, MMKV is quite easy to use.
336
- For the full documentation, see [HarmonyOS NEXT Tutorial](https://github.com/Tencent/MMKV/wiki/ohos_setup).
337
-
338
- ## License
339
- MMKV is published under the BSD 3-Clause license. For details check out the [LICENSE.TXT](./LICENSE.TXT).
340
-
341
- ## Change Log
342
- Check out the [CHANGELOG.md](./CHANGELOG.md) for details of change history.
343
-
344
- ## Contributing
345
-
346
- If you are interested in contributing, check out the [CONTRIBUTING.md](./CONTRIBUTING.md), also join our [Tencent OpenSource Plan](https://opensource.tencent.com/contribution).
347
-
348
- 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).
349
-
350
- ## FAQ & Feedback
351
- 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).
352
-
353
- ## Personal Information Protection Rules
354
- 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.