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
@@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.9.0)
2
2
  project(ReactNativeMmkv)
3
3
 
4
4
  set(CMAKE_VERBOSE_MAKEFILE ON)
5
- set(CMAKE_CXX_STANDARD 17)
5
+ set(CMAKE_CXX_STANDARD 20)
6
+
7
+ # Check for supported ABIs only
8
+ if(NOT (ANDROID_ABI STREQUAL "arm64-v8a" OR ANDROID_ABI STREQUAL "x86_64"))
9
+ message(FATAL_ERROR "MMKV prefab does not support ABI: ${ANDROID_ABI}. Supported ABIs: arm64-v8a, x86_64")
10
+ endif()
6
11
 
7
12
  # Compile sources
8
13
  add_library(
@@ -13,20 +18,24 @@ add_library(
13
18
  ../cpp/NativeMmkvModule.cpp
14
19
  )
15
20
 
16
- # Add headers search paths
17
- target_include_directories(react-native-mmkv PUBLIC ../MMKV/Core)
18
- target_include_directories(react-native-mmkv PUBLIC ../cpp)
21
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../cpp)
19
22
 
20
- # Add MMKV core dependency
21
- add_subdirectory(../MMKV/Core core)
23
+ # Find MMKV prefab package
24
+ find_package(mmkv REQUIRED CONFIG)
22
25
 
23
26
  # Add android/log dependency
24
- find_library(log-lib log)
27
+ find_library(android_log log)
28
+
29
+ target_include_directories(
30
+ react-native-mmkv
31
+ PUBLIC
32
+ ${CMAKE_CURRENT_SOURCE_DIR}/../cpp
33
+ )
25
34
 
26
35
  target_link_libraries(
27
36
  react-native-mmkv
28
- core # <-- MMKV core
29
- ${log-lib} # <-- Logcat logger
37
+ mmkv::mmkv # <-- MMKV core (now manually configured)
38
+ ${android_log} # <-- Logcat logger
30
39
  android # <-- Android JNI core
31
40
  react_codegen_RNMmkvSpec # <-- Generated Specs from CodeGen
32
41
  )
@@ -5,7 +5,7 @@ buildscript {
5
5
  }
6
6
 
7
7
  dependencies {
8
- classpath "com.android.tools.build:gradle:7.2.1"
8
+ classpath "com.android.tools.build:gradle:7.2.2"
9
9
  }
10
10
  }
11
11
 
@@ -44,6 +44,7 @@ android {
44
44
 
45
45
  buildFeatures {
46
46
  buildConfig true
47
+ prefab true
47
48
  }
48
49
 
49
50
  buildTypes {
@@ -74,8 +75,8 @@ android {
74
75
  }
75
76
 
76
77
  repositories {
77
- mavenCentral()
78
78
  google()
79
+ mavenCentral()
79
80
  }
80
81
 
81
82
 
@@ -84,6 +85,9 @@ dependencies {
84
85
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
85
86
  //noinspection GradleDynamicVersion
86
87
  implementation "com.facebook.react:react-native:+"
88
+
89
+ // Use the MMKV shared lib - includes C++ prefabs (shared STL for React Native compatibility)
90
+ implementation "com.tencent:mmkv-shared:2.2.3"
87
91
  }
88
92
 
89
93
  if (isNewArchitectureEnabled()) {
@@ -1,5 +1,5 @@
1
1
  //
2
- // ManagedBuffer.h
2
+ // ManagedMMBuffer.h
3
3
  // react-native-mmkv
4
4
  //
5
5
  // Created by Marc Rousavy on 25.03.24.
@@ -7,17 +7,17 @@
7
7
 
8
8
  #pragma once
9
9
 
10
- #include "MMKVManagedBuffer.h"
10
+ #include "MmkvTypes.h" // IWYU pragma: keep
11
11
  #include <jsi/jsi.h>
12
12
 
13
13
  using namespace facebook;
14
14
 
15
15
  /**
16
- A jsi::MutableBuffer that manages mmkv::MMBuffer memory (by ownership).
16
+ A jsi::MutableBuffer that manages MMBuffer memory (by ownership).
17
17
  */
18
- class MMKVManagedBuffer : public jsi::MutableBuffer {
18
+ class ManagedMMBuffer : public jsi::MutableBuffer {
19
19
  public:
20
- explicit MMKVManagedBuffer(mmkv::MMBuffer&& buffer) : _buffer(std::move(buffer)) {}
20
+ explicit ManagedMMBuffer(MMBuffer&& buffer) : _buffer(std::move(buffer)) {}
21
21
 
22
22
  uint8_t* data() override {
23
23
  return static_cast<uint8_t*>(_buffer.getPtr());
@@ -28,5 +28,5 @@ public:
28
28
  }
29
29
 
30
30
  private:
31
- mmkv::MMBuffer _buffer;
31
+ MMBuffer _buffer;
32
32
  };
@@ -7,9 +7,8 @@
7
7
  //
8
8
 
9
9
  #include "MmkvHostObject.h"
10
- #include "MMKVManagedBuffer.h"
10
+ #include "ManagedMMBuffer.h"
11
11
  #include "MmkvLogger.h"
12
- #include <MMKV.h>
13
12
  #include <string>
14
13
  #include <vector>
15
14
 
@@ -28,7 +27,7 @@ MmkvHostObject::MmkvHostObject(const facebook::react::MMKVConfig& config) {
28
27
  MMKVMode mode = getMMKVMode(config);
29
28
  if (config.readOnly.has_value() && config.readOnly.value()) {
30
29
  MmkvLogger::log("RNMMKV", "Instance is read-only!");
31
- mode = mode | MMKVMode::MMKV_READ_ONLY;
30
+ mode = mode | mmkv::MMKV_READ_ONLY;
32
31
  }
33
32
 
34
33
  #ifdef __APPLE__
@@ -71,14 +70,14 @@ std::vector<jsi::PropNameID> MmkvHostObject::getPropertyNames(jsi::Runtime& rt)
71
70
 
72
71
  MMKVMode MmkvHostObject::getMMKVMode(const facebook::react::MMKVConfig& config) {
73
72
  if (!config.mode.has_value()) {
74
- return MMKVMode::MMKV_SINGLE_PROCESS;
73
+ return mmkv::MMKV_SINGLE_PROCESS;
75
74
  }
76
75
  react::NativeMmkvMode mode = config.mode.value();
77
76
  switch (mode) {
78
77
  case react::NativeMmkvMode::SINGLE_PROCESS:
79
- return MMKVMode::MMKV_SINGLE_PROCESS;
78
+ return mmkv::MMKV_SINGLE_PROCESS;
80
79
  case react::NativeMmkvMode::MULTI_PROCESS:
81
- return MMKVMode::MMKV_MULTI_PROCESS;
80
+ return mmkv::MMKV_MULTI_PROCESS;
82
81
  default:
83
82
  [[unlikely]] throw std::runtime_error("Invalid MMKV Mode value!");
84
83
  }
@@ -221,12 +220,18 @@ jsi::Value MmkvHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pro
221
220
  }
222
221
 
223
222
  std::string keyName = arguments[0].getString(runtime).utf8(runtime);
224
- mmkv::MMBuffer buffer;
223
+ MMBuffer buffer;
224
+ #ifdef __OBJC__
225
+ // iOS: Convert std::string to NSString* for MMKVCore pod compatibility
226
+ bool hasValue = instance->getBytes(@(keyName.c_str()), buffer);
227
+ #else
228
+ // Android/other platforms: Use std::string directly (converts to std::string_view)
225
229
  bool hasValue = instance->getBytes(keyName, buffer);
230
+ #endif
226
231
  if (!hasValue) [[unlikely]] {
227
232
  return jsi::Value::undefined();
228
233
  }
229
- auto mutableData = std::make_shared<MMKVManagedBuffer>(std::move(buffer));
234
+ auto mutableData = std::make_shared<ManagedMMBuffer>(std::move(buffer));
230
235
  return jsi::ArrayBuffer(runtime, mutableData);
231
236
  });
232
237
  }
@@ -8,12 +8,11 @@
8
8
 
9
9
  #pragma once
10
10
 
11
- #include "MMKV.h"
11
+ #include "MmkvTypes.h" // IWYU pragma: keep
12
12
  #include "NativeMmkvModule.h"
13
13
  #include <jsi/jsi.h>
14
14
 
15
15
  using namespace facebook;
16
- using namespace mmkv;
17
16
 
18
17
  class MmkvHostObject : public jsi::HostObject {
19
18
  public:
@@ -0,0 +1,50 @@
1
+ //
2
+ // MmkvTypes.h
3
+ // react-native-mmkv
4
+ //
5
+ // Created by Brad Anderson on 10.08.2025.
6
+ // Platform-specific MMKV type unification header
7
+ //
8
+
9
+ #pragma once
10
+
11
+ // Platform-specific MMKV includes
12
+ #ifdef __ANDROID__
13
+ #include <MMKV/MMKV.h>
14
+
15
+ // On Android, bring global namespace types into mmkv namespace for consistency
16
+ namespace mmkv {
17
+ using MMKV = ::MMKV;
18
+ using MMKVMode = ::MMKVMode;
19
+ using MMKVLogLevel = ::MMKVLogLevel;
20
+
21
+ // Constants - bring into mmkv namespace
22
+ constexpr auto MMKVLogDebug = ::MMKVLogDebug;
23
+ constexpr auto MMKVLogInfo = ::MMKVLogInfo;
24
+ constexpr auto MMKVLogWarning = ::MMKVLogWarning;
25
+ constexpr auto MMKVLogError = ::MMKVLogError;
26
+ constexpr auto MMKVLogNone = ::MMKVLogNone;
27
+
28
+ constexpr auto MMKV_SINGLE_PROCESS = ::MMKV_SINGLE_PROCESS;
29
+ constexpr auto MMKV_MULTI_PROCESS = ::MMKV_MULTI_PROCESS;
30
+ constexpr auto MMKV_READ_ONLY = ::MMKVMode::MMKV_READ_ONLY;
31
+ } // namespace mmkv
32
+
33
+ #else
34
+ #include <MMKVCore/MMKV.h>
35
+ // iOS already has everything in mmkv:: namespace
36
+ #endif
37
+
38
+ /**
39
+ * Unified MMKV namespace usage for cross-platform compatibility.
40
+ *
41
+ * After including this header, use:
42
+ * - mmkv::MMKV for the main class
43
+ * - mmkv::MMKVMode for mode enum
44
+ * - mmkv::MMKVLogLevel for log level enum
45
+ * - mmkv::MMBuffer for buffer type
46
+ * - mmkv::MMKV_SINGLE_PROCESS / mmkv::MMKV_MULTI_PROCESS for modes
47
+ * - mmkv::MMKVLogDebug, etc. for log levels
48
+ */
49
+
50
+ using namespace mmkv;
@@ -6,9 +6,9 @@
6
6
  //
7
7
 
8
8
  #include "NativeMmkvModule.h"
9
- #include "MMKV.h"
10
9
  #include "MmkvHostObject.h"
11
10
  #include "MmkvLogger.h"
11
+ #include "MmkvTypes.h" // IWYU pragma: keep
12
12
 
13
13
  namespace facebook::react {
14
14
 
@@ -23,9 +23,9 @@ bool NativeMmkvModule::initialize(jsi::Runtime& runtime, std::string basePath) {
23
23
  MmkvLogger::log("RNMMKV", "Initializing MMKV at %s...", basePath.c_str());
24
24
 
25
25
  #ifdef DEBUG
26
- MMKVLogLevel logLevel = MMKVLogDebug;
26
+ MMKVLogLevel logLevel = mmkv::MMKVLogDebug;
27
27
  #else
28
- MMKVLogLevel logLevel = MMKVLogWarning;
28
+ MMKVLogLevel logLevel = mmkv::MMKVLogWarning;
29
29
  #endif
30
30
 
31
31
  MMKV::initializeMMKV(basePath, logLevel);
@@ -7,15 +7,8 @@
7
7
 
8
8
  #pragma once
9
9
 
10
- #if __has_include(<React-Codegen/RNMmkvSpecJSI.h>)
11
- // CocoaPods include (iOS)
12
- #include <React-Codegen/RNMmkvSpecJSI.h>
13
- #elif __has_include(<RNMmkvSpecJSI.h>)
14
- // CMake include on Android
15
10
  #include <RNMmkvSpecJSI.h>
16
- #else
17
- #error Cannot find react-native-mmkv spec! Try cleaning your cache and re-running CodeGen!
18
- #endif
11
+ #include <string>
19
12
 
20
13
  namespace facebook::react {
21
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mmkv",
3
- "version": "3.3.0",
3
+ "version": "4.0.0-beta.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",
@@ -10,7 +10,6 @@
10
10
  "files": [
11
11
  "cpp/**/*.h",
12
12
  "cpp/**/*.cpp",
13
- "MMKV/Core",
14
13
  "android/src",
15
14
  "android/build.gradle",
16
15
  "android/CMakeLists.txt",
@@ -37,9 +36,8 @@
37
36
  "test": "jest",
38
37
  "typecheck": "tsc --noEmit",
39
38
  "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
40
- "prepare": "git submodule update --init --recursive && bob build",
39
+ "prepare": "bob build",
41
40
  "prepack": "bob build",
42
- "update-submodule": "git submodule update --remote --merge",
43
41
  "pods": "cd example && yarn pods",
44
42
  "release": "release-it",
45
43
  "codegen": "npx react-native codegen"
@@ -70,26 +68,27 @@
70
68
  "registry": "https://registry.npmjs.org/"
71
69
  },
72
70
  "devDependencies": {
73
- "@firmnav/eslint-github-actions-formatter": "^1.0.1",
74
- "@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
75
- "@react-native-community/cli-types": "^15.1.3",
76
- "@react-native/eslint-config": "^0.77.1",
77
- "@release-it/conventional-changelog": "^9.0.1",
78
- "@testing-library/react-native": "^13.0.1",
79
- "@types/jest": "^29.5.13",
80
- "@types/react": "^18.3.11",
81
- "del-cli": "^6.0.0",
82
- "eslint": "^8.51.0",
83
- "eslint-config-prettier": "^9.0.0",
84
- "eslint-plugin-prettier": "^5.2.1",
85
- "jest": "^29.7.0",
86
- "prettier": "^3.3.3",
87
- "react": "^18.3.1",
88
- "react-native": "^0.77.1",
89
- "react-native-builder-bob": "^0.37.0",
71
+ "@firmnav/eslint-github-actions-formatter": "1.0.1",
72
+ "@jamesacarr/eslint-formatter-github-actions": "0.2.0",
73
+ "@react-native-community/cli": "19.1.1",
74
+ "@react-native-community/cli-types": "18.0.0",
75
+ "@react-native/eslint-config": "0.77.1",
76
+ "@release-it/conventional-changelog": "9.0.1",
77
+ "@testing-library/react-native": "13.0.1",
78
+ "@types/jest": "29.5.13",
79
+ "@types/react": "18.3.11",
80
+ "del-cli": "6.0.0",
81
+ "eslint": "8.51.0",
82
+ "eslint-config-prettier": "9.0.0",
83
+ "eslint-plugin-prettier": "5.2.1",
84
+ "jest": "29.7.0",
85
+ "prettier": "3.3.3",
86
+ "react": "18.3.1",
87
+ "react-native": "0.77.1",
88
+ "react-native-builder-bob": "0.37.0",
90
89
  "react-test-renderer": "18.3.1",
91
- "release-it": "^17.10.0",
92
- "typescript": "^5.5.4"
90
+ "release-it": "17.10.0",
91
+ "typescript": "5.5.4"
93
92
  },
94
93
  "peerDependencies": {
95
94
  "react": "*",
@@ -1,7 +1,6 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
4
 
6
5
  Pod::UI.puts "[react-native-mmkv] Thank you for using react-native-mmkv ❤️"
7
6
  Pod::UI.puts "[react-native-mmkv] If you enjoy using react-native-mmkv, please consider sponsoring this project: https://github.com/sponsors/mrousavy"
@@ -18,21 +17,16 @@ Pod::Spec.new do |s|
18
17
  s.source = { :git => "https://github.com/mrousavy/react-native-mmkv.git", :tag => "#{s.version}" }
19
18
 
20
19
  s.pod_target_xcconfig = {
21
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
22
- "CLANG_CXX_LIBRARY" => "libc++",
23
- "CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF" => "NO",
24
- # FORCE_POSIX ensures we are using C++ types instead of Objective-C types for MMKV.
25
- "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FORCE_POSIX",
20
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
26
21
  }
27
22
  s.compiler_flags = '-x objective-c++'
28
23
  s.libraries = "z", "c++"
29
24
  s.source_files = [
30
25
  # react-native-mmkv
31
26
  "ios/**/*.{h,m,mm}",
32
- "cpp/**/*.{hpp,cpp,c,h}",
33
- # MMKV/Core
34
- "MMKV/Core/**/*.{h,cpp,hpp,S}",
27
+ "cpp/**/*.{hpp,cpp,c,h}"
35
28
  ]
36
29
 
30
+ s.dependency 'MMKVCore', '>= 2.2.3'
37
31
  install_modules_dependencies(s)
38
32
  end
@@ -17,4 +17,13 @@ module.exports = {
17
17
  },
18
18
  },
19
19
  },
20
+ // Codegen configuration for TurboModules
21
+ codegenConfig: {
22
+ name: 'RNMmkvSpec',
23
+ type: 'modules',
24
+ jsSrcsDir: 'src',
25
+ android: {
26
+ javaPackageName: 'com.mrousavy.mmkv',
27
+ },
28
+ },
20
29
  };
@@ -1,172 +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
- # Sets the minimum version of CMake required to build the native library.
22
-
23
- cmake_minimum_required(VERSION 3.10.0)
24
-
25
- IF(APPLE)
26
- # tell ranlib to ignore empty compilation units
27
- SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
28
- SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
29
- # prevents ar from invoking ranlib, let CMake do it
30
- SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qc -S <TARGET> <LINK_FLAGS> <OBJECTS>")
31
- SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qc -S <TARGET> <LINK_FLAGS> <OBJECTS>")
32
-
33
- add_compile_definitions(FORCE_POSIX)
34
- ENDIF()
35
-
36
- set(can_use_assembler TRUE)
37
- enable_language(ASM)
38
- IF("${ANDROID_ABI}" STREQUAL "arm64-v8a")
39
- SET(ASM_OPTIONS "-x assembler-with-cpp")
40
- SET(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS} -march=armv8+crypto -D__ANDROID__")
41
- ELSEIF("${ANDROID_ABI}" STREQUAL "armeabi-v7a")
42
- SET(ASM_OPTIONS "-x assembler-with-cpp")
43
- SET(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS} -march=armv7a -D__ANDROID__")
44
- ELSEIF("${ANDROID_ABI}" STREQUAL "armeabi")
45
- SET(ASM_OPTIONS "-x assembler-with-cpp")
46
- SET(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS} -march=armv5 -D__ANDROID__")
47
- ENDIF()
48
-
49
- #include(CMakePrintHelpers)
50
- #cmake_print_variables(CMAKE_SYSTEM_PROCESSOR OHOS OHOS_ARCH CFLAGS ASM_OPTIONS CMAKE_ASM_FLAGS)
51
-
52
- IF(OHOS)
53
- IF("${OHOS_ARCH}" STREQUAL "arm64-v8a")
54
- SET(ASM_OPTIONS "-x assembler-with-cpp")
55
- SET(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS} -march=armv8+crypto -D__MUSL__")
56
- ENDIF()
57
- ELSEIF(UNIX AND (NOT APPLE))
58
- IF("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
59
- SET(ASM_OPTIONS "-x assembler-with-cpp")
60
- SET(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS} -march=armv8-a+crypto")
61
- ENDIF()
62
- ENDIF()
63
-
64
-
65
- project(core)
66
-
67
- # Creates and names a library, sets it as either STATIC
68
- # or SHARED, and provides the relative paths to its source code.
69
- # You can define multiple libraries, and CMake builds them for you.
70
- # Gradle automatically packages shared libraries with your APK.
71
-
72
- add_library(core
73
-
74
- # Sets the library as a shared library.
75
- STATIC
76
-
77
- # Provides a relative path to your source file(s).
78
- MMKV.h
79
- MMKV.cpp
80
- MMKV_Android.cpp
81
- MMKV_IO.h
82
- MMKV_IO.cpp
83
- MMKV_OSX.cpp
84
- MMKVLog.h
85
- MMKVLog.cpp
86
- MMKVLog_Android.cpp
87
- CodedInputData.h
88
- CodedInputData.cpp
89
- CodedInputData_OSX.cpp
90
- CodedInputDataCrypt.h
91
- CodedInputDataCrypt.cpp
92
- CodedInputDataCrypt_OSX.cpp
93
- CodedOutputData.h
94
- CodedOutputData.cpp
95
- KeyValueHolder.h
96
- KeyValueHolder.cpp
97
- PBUtility.h
98
- PBUtility.cpp
99
- MiniPBCoder.h
100
- MiniPBCoder.cpp
101
- MiniPBCoder_OSX.cpp
102
- MMBuffer.h
103
- MMBuffer.cpp
104
- InterProcessLock.h
105
- InterProcessLock.cpp
106
- InterProcessLock_Win32.cpp
107
- InterProcessLock_Android.cpp
108
- MemoryFile.h
109
- MemoryFile.cpp
110
- MemoryFile_Android.cpp
111
- MemoryFile_Linux.cpp
112
- MemoryFile_Win32.cpp
113
- MemoryFile_OSX.cpp
114
- ThreadLock.h
115
- ThreadLock.cpp
116
- ThreadLock_Win32.cpp
117
- MMKVMetaInfo.hpp
118
- aes/AESCrypt.h
119
- aes/AESCrypt.cpp
120
- aes/openssl/openssl_aes.h
121
- aes/openssl/openssl_aes_core.cpp
122
- aes/openssl/openssl_aes_locl.h
123
- aes/openssl/openssl_cfb128.cpp
124
- aes/openssl/openssl_opensslconf.h
125
- aes/openssl/openssl_md5_dgst.cpp
126
- aes/openssl/openssl_md5_locl.h
127
- aes/openssl/openssl_md5_one.cpp
128
- aes/openssl/openssl_md5.h
129
- aes/openssl/openssl_md32_common.h
130
- aes/openssl/openssl_arm_arch.h
131
- crc32/Checksum.h
132
- crc32/crc32_armv8.cpp
133
- crc32/zlib/zconf.h
134
- crc32/zlib/zutil.h
135
- crc32/zlib/crc32.h
136
- crc32/zlib/crc32.cpp
137
- MMKVPredef.h
138
- )
139
-
140
- IF (MSVC OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"))
141
- # .S files is not supported by MSVC.
142
- # x86_64 asm not supported in OHOS
143
- ELSE()
144
- target_sources(core PRIVATE
145
- aes/openssl/openssl_aesv8-armx.S
146
- aes/openssl/openssl_aes-armv4.S)
147
- ENDIF()
148
-
149
- target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
150
-
151
- IF (WIN32)
152
- # MMKV can be used only with Unicode on Windows.
153
- target_compile_definitions(core PUBLIC UNICODE)
154
- target_compile_definitions(core PUBLIC _UNICODE)
155
- ENDIF()
156
-
157
- set_target_properties(core PROPERTIES
158
- CXX_STANDARD 20
159
- CXX_EXTENSIONS OFF
160
- POSITION_INDEPENDENT_CODE ON
161
- )
162
-
163
- find_library(zlib
164
- z
165
- )
166
-
167
- IF (NOT zlib)
168
- target_compile_definitions(core PUBLIC MMKV_EMBED_ZLIB=1)
169
- ELSE()
170
- target_link_libraries(core ${zlib})
171
- ENDIF()
172
-