react-native-mmkv 4.0.0-beta.9 → 4.0.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.
package/NitroMmkv.podspec CHANGED
@@ -25,7 +25,15 @@ Pod::Spec.new do |s|
25
25
  # Add MMKV Core dependency
26
26
  s.compiler_flags = '-x objective-c++'
27
27
  s.libraries = 'z', 'c++'
28
- s.dependency 'MMKVCore', '>= 2.2.3'
28
+ s.dependency 'MMKVCore', '2.2.4'
29
+
30
+ # TODO: Remove when no one uses RN 0.79 anymore
31
+ # Add support for React Native 0.79 or below
32
+ s.pod_target_xcconfig = {
33
+ "HEADER_SEARCH_PATHS" => ["${PODS_ROOT}/RCT-Folly"],
34
+ "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES",
35
+ "OTHER_CPLUSPLUSFLAGS" => "$(inherited) -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1"
36
+ }
29
37
 
30
38
  load 'nitrogen/generated/ios/NitroMmkv+autolinking.rb'
31
39
  add_nitrogen_files(s)
@@ -5,13 +5,13 @@ buildscript {
5
5
  }
6
6
 
7
7
  dependencies {
8
- classpath "com.android.tools.build:gradle:8.12.1"
8
+ classpath "com.android.tools.build:gradle:8.13.0"
9
9
  }
10
10
  }
11
11
 
12
12
  def reactNativeArchitectures() {
13
13
  def value = rootProject.getProperties().get("reactNativeArchitectures")
14
- return value ? value.split(",") : ["x86_64", "arm64-v8a"]
14
+ return value ? value.split(",") : ["x86", "x86_64", "armeabi-v7a", "arm64-v8a"]
15
15
  }
16
16
 
17
17
  def isNewArchitectureEnabled() {
@@ -139,6 +139,6 @@ dependencies {
139
139
  implementation project(":react-native-nitro-modules")
140
140
 
141
141
  // Add a dependency on mmkv core (this ships a C++ prefab)
142
- implementation "com.tencent:mmkv-shared:2.2.3"
142
+ implementation "io.github.zhongwuzw:mmkv:2.2.4"
143
143
  }
144
144
 
@@ -70,15 +70,33 @@ struct overloaded : Ts... {
70
70
  template <class... Ts>
71
71
  overloaded(Ts...) -> overloaded<Ts...>;
72
72
 
73
- void HybridMMKV::set(const std::string& key, const std::variant<std::string, double, bool, std::shared_ptr<ArrayBuffer>>& value) {
73
+ void HybridMMKV::set(const std::string& key, const std::variant<bool, std::shared_ptr<ArrayBuffer>, std::string, double>& value) {
74
+ if (key.empty()) [[unlikely]] {
75
+ throw std::runtime_error("Cannot set a value for an empty key!");
76
+ }
77
+
74
78
  // Pattern-match each potential value in std::variant
75
- std::visit(overloaded{[&](const std::string& string) { instance->set(string, key); }, [&](double number) { instance->set(number, key); },
76
- [&](bool b) { instance->set(b, key); },
77
- [&](const std::shared_ptr<ArrayBuffer>& buf) {
78
- MMBuffer buffer(buf->data(), buf->size(), MMBufferCopyFlag::MMBufferNoCopy);
79
- instance->set(std::move(buffer), key);
80
- }},
81
- value);
79
+ bool didSet = std::visit(overloaded{[&](bool b) {
80
+ // boolean
81
+ return instance->set(b, key);
82
+ },
83
+ [&](const std::shared_ptr<ArrayBuffer>& buf) {
84
+ // ArrayBuffer
85
+ MMBuffer buffer(buf->data(), buf->size(), MMBufferCopyFlag::MMBufferNoCopy);
86
+ return instance->set(std::move(buffer), key);
87
+ },
88
+ [&](const std::string& string) {
89
+ // string
90
+ return instance->set(string, key);
91
+ },
92
+ [&](double number) {
93
+ // number
94
+ return instance->set(number, key);
95
+ }},
96
+ value);
97
+ if (!didSet) {
98
+ throw std::runtime_error("Failed to set value for key \"" + key + "\"!");
99
+ }
82
100
 
83
101
  // Notify on changed
84
102
  MMKVValueChangedListenerRegistry::notifyOnValueChanged(instance->mmapID(), key);
@@ -130,13 +148,23 @@ bool HybridMMKV::contains(const std::string& key) {
130
148
  return instance->containsKey(key);
131
149
  }
132
150
  bool HybridMMKV::remove(const std::string& key) {
133
- return instance->removeValueForKey(key);
151
+ bool wasRemoved = instance->removeValueForKey(key);
152
+ if (wasRemoved) {
153
+ // Notify on changed
154
+ MMKVValueChangedListenerRegistry::notifyOnValueChanged(instance->mmapID(), key);
155
+ }
156
+ return wasRemoved;
134
157
  }
135
158
  std::vector<std::string> HybridMMKV::getAllKeys() {
136
159
  return instance->allKeys();
137
160
  }
138
161
  void HybridMMKV::clearAll() {
162
+ auto keysBefore = getAllKeys();
139
163
  instance->clearAll();
164
+ for (const auto& key : keysBefore) {
165
+ // Notify on changed
166
+ MMKVValueChangedListenerRegistry::notifyOnValueChanged(instance->mmapID(), key);
167
+ }
140
168
  }
141
169
  void HybridMMKV::recrypt(const std::optional<std::string>& key) {
142
170
  bool successful = false;
@@ -24,7 +24,7 @@ public:
24
24
 
25
25
  public:
26
26
  // Methods
27
- void set(const std::string& key, const std::variant<std::string, double, bool, std::shared_ptr<ArrayBuffer>>& value) override;
27
+ void set(const std::string& key, const std::variant<bool, std::shared_ptr<ArrayBuffer>, std::string, double>& value) override;
28
28
  std::optional<bool> getBoolean(const std::string& key) override;
29
29
  std::optional<std::string> getString(const std::string& key) override;
30
30
  std::optional<double> getNumber(const std::string& key) override;
@@ -2,7 +2,7 @@ import { NitroModules } from 'react-native-nitro-modules';
2
2
  import { Platform } from 'react-native';
3
3
  import { addMemoryWarningListener } from '../addMemoryWarningListener/addMemoryWarningListener';
4
4
  import { isTest } from '../isTest';
5
- import { createMockMMKV } from './createMMKV.mock';
5
+ import { createMockMMKV } from './createMockMMKV';
6
6
  let factory;
7
7
  let platformContext;
8
8
  export function createMMKV(configuration) {
@@ -1,3 +1,3 @@
1
1
  import type { MMKV } from '../specs/MMKV.nitro';
2
2
  import type { Configuration } from '../specs/MMKVFactory.nitro';
3
- export declare function createMMKV(config: Configuration): MMKV;
3
+ export declare function createMMKV(config?: Configuration): MMKV;
@@ -12,7 +12,7 @@ const hasAccessToLocalStorage = () => {
12
12
  };
13
13
  const KEY_WILDCARD = '\\';
14
14
  const inMemoryStorage = new Map();
15
- export function createMMKV(config) {
15
+ export function createMMKV(config = { id: 'mmkv.default' }) {
16
16
  if (config.encryptionKey != null) {
17
17
  throw new Error("MMKV: 'encryptionKey' is not supported on Web!");
18
18
  }
@@ -55,18 +55,30 @@ export function createMMKV(config) {
55
55
  }
56
56
  return `${keyPrefix}${key}`;
57
57
  };
58
+ const callListeners = (key) => {
59
+ listeners.forEach((l) => l(key));
60
+ };
58
61
  return {
59
62
  clearAll: () => {
60
63
  const keys = Object.keys(storage());
61
64
  for (const key of keys) {
62
65
  if (key.startsWith(keyPrefix)) {
63
66
  storage().removeItem(key);
67
+ callListeners(key);
64
68
  }
65
69
  }
66
70
  },
67
- remove: (key) => storage().removeItem(prefixedKey(key)) ?? false,
71
+ remove: (key) => {
72
+ const wasRemoved = storage().removeItem(prefixedKey(key)) ?? false;
73
+ if (wasRemoved)
74
+ callListeners(key);
75
+ return wasRemoved;
76
+ },
68
77
  set: (key, value) => {
78
+ if (key === '')
79
+ throw new Error('Cannot set a value for an empty key!');
69
80
  storage().setItem(prefixedKey(key), value.toString());
81
+ callListeners(key);
70
82
  },
71
83
  getString: (key) => storage().getItem(prefixedKey(key)) ?? undefined,
72
84
  getNumber: (key) => {
@@ -26,6 +26,8 @@ export function createMockMMKV() {
26
26
  return deleted;
27
27
  },
28
28
  set: (key, value) => {
29
+ if (key === '')
30
+ throw new Error('Cannot set a value for an empty key!');
29
31
  storage.set(key, value);
30
32
  notifyListeners(key);
31
33
  },
@@ -7,9 +7,10 @@ export interface MMKV extends HybridObject<{
7
7
  android: 'c++';
8
8
  }> {
9
9
  /**
10
- * Set a value for the given `key`.
10
+ * Set a {@linkcode value} for the given {@linkcode key}.
11
11
  *
12
- * @throws an Error if the value cannot be set.
12
+ * @throws an Error if the {@linkcode key} is empty.
13
+ * @throws an Error if the {@linkcode value} cannot be set.
13
14
  */
14
15
  set(key: string, value: boolean | string | number | ArrayBuffer): void;
15
16
  /**
@@ -13,6 +13,12 @@
13
13
  # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroMmkv+autolinking.cmake)
14
14
  # ```
15
15
 
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_NITROMMKV_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
16
22
  # Add all headers that were generated by Nitrogen
17
23
  include_directories(
18
24
  "../nitrogen/generated/shared/c++"
@@ -34,12 +40,9 @@ target_sources(
34
40
  ../nitrogen/generated/android/c++/JHybridMMKVPlatformContextSpec.cpp
35
41
  )
36
42
 
37
- # Define a flag to check if we are building properly
38
- add_definitions(-DBUILDING_NITROMMKV_WITH_GENERATED_CMAKE_PROJECT)
39
-
40
43
  # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
41
44
  # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
42
- target_compile_definitions(
45
+ target_compile_definitions(
43
46
  NitroMmkv PRIVATE
44
47
  -DFOLLY_NO_CONFIG=1
45
48
  -DFOLLY_HAVE_CLOCK_GETTIME=1
@@ -10,7 +10,7 @@ package com.margelo.nitro.mmkv
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import com.margelo.nitro.core.*
13
+ import com.margelo.nitro.core.HybridObject
14
14
 
15
15
  /**
16
16
  * A Kotlin class representing the MMKVPlatformContext HybridObject.
@@ -51,6 +51,6 @@ abstract class HybridMMKVPlatformContextSpec: HybridObject() {
51
51
  private external fun initHybrid(): HybridData
52
52
 
53
53
  companion object {
54
- private const val TAG = "HybridMMKVPlatformContextSpec"
54
+ protected const val TAG = "HybridMMKVPlatformContextSpec"
55
55
  }
56
56
  }
@@ -14,11 +14,11 @@
14
14
  namespace margelo::nitro::mmkv::bridge::swift {
15
15
 
16
16
  // pragma MARK: std::shared_ptr<HybridMMKVPlatformContextSpec>
17
- std::shared_ptr<HybridMMKVPlatformContextSpec> create_std__shared_ptr_HybridMMKVPlatformContextSpec_(void* _Nonnull swiftUnsafePointer) noexcept {
17
+ std::shared_ptr<HybridMMKVPlatformContextSpec> create_std__shared_ptr_HybridMMKVPlatformContextSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
18
18
  NitroMmkv::HybridMMKVPlatformContextSpec_cxx swiftPart = NitroMmkv::HybridMMKVPlatformContextSpec_cxx::fromUnsafe(swiftUnsafePointer);
19
19
  return std::make_shared<margelo::nitro::mmkv::HybridMMKVPlatformContextSpecSwift>(swiftPart);
20
20
  }
21
- void* _Nonnull get_std__shared_ptr_HybridMMKVPlatformContextSpec_(std__shared_ptr_HybridMMKVPlatformContextSpec_ cppType) noexcept {
21
+ void* NON_NULL get_std__shared_ptr_HybridMMKVPlatformContextSpec_(std__shared_ptr_HybridMMKVPlatformContextSpec_ cppType) {
22
22
  std::shared_ptr<margelo::nitro::mmkv::HybridMMKVPlatformContextSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::mmkv::HybridMMKVPlatformContextSpecSwift>(cppType);
23
23
  #ifdef NITRO_DEBUG
24
24
  if (swiftWrapper == nullptr) [[unlikely]] {
@@ -49,8 +49,8 @@ namespace margelo::nitro::mmkv::bridge::swift {
49
49
  * Specialized version of `std::shared_ptr<HybridMMKVPlatformContextSpec>`.
50
50
  */
51
51
  using std__shared_ptr_HybridMMKVPlatformContextSpec_ = std::shared_ptr<HybridMMKVPlatformContextSpec>;
52
- std::shared_ptr<HybridMMKVPlatformContextSpec> create_std__shared_ptr_HybridMMKVPlatformContextSpec_(void* _Nonnull swiftUnsafePointer) noexcept;
53
- void* _Nonnull get_std__shared_ptr_HybridMMKVPlatformContextSpec_(std__shared_ptr_HybridMMKVPlatformContextSpec_ cppType) noexcept;
52
+ std::shared_ptr<HybridMMKVPlatformContextSpec> create_std__shared_ptr_HybridMMKVPlatformContextSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
53
+ void* NON_NULL get_std__shared_ptr_HybridMMKVPlatformContextSpec_(std__shared_ptr_HybridMMKVPlatformContextSpec_ cppType);
54
54
 
55
55
  // pragma MARK: std::weak_ptr<HybridMMKVPlatformContextSpec>
56
56
  using std__weak_ptr_HybridMMKVPlatformContextSpec_ = std::weak_ptr<HybridMMKVPlatformContextSpec>;
@@ -17,6 +17,11 @@
17
17
  #else
18
18
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
19
  #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
20
25
 
21
26
  // Forward declaration of `Mode` to properly resolve imports.
22
27
  namespace margelo::nitro::mmkv { enum class Mode; }
@@ -74,6 +79,9 @@ namespace margelo::nitro {
74
79
  return false;
75
80
  }
76
81
  jsi::Object obj = value.getObject(runtime);
82
+ if (!nitro::isPlainObject(runtime, obj)) {
83
+ return false;
84
+ }
77
85
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "id"))) return false;
78
86
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "path"))) return false;
79
87
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "encryptionKey"))) return false;
@@ -13,8 +13,6 @@
13
13
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
14
  #endif
15
15
 
16
- // Forward declaration of `ArrayBuffer` to properly resolve imports.
17
- namespace NitroModules { class ArrayBuffer; }
18
16
  // Forward declaration of `Listener` to properly resolve imports.
19
17
  namespace margelo::nitro::mmkv { struct Listener; }
20
18
 
@@ -58,7 +56,7 @@ namespace margelo::nitro::mmkv {
58
56
 
59
57
  public:
60
58
  // Methods
61
- virtual void set(const std::string& key, const std::variant<std::string, double, bool, std::shared_ptr<ArrayBuffer>>& value) = 0;
59
+ virtual void set(const std::string& key, const std::variant<bool, std::shared_ptr<ArrayBuffer>, std::string, double>& value) = 0;
62
60
  virtual std::optional<bool> getBoolean(const std::string& key) = 0;
63
61
  virtual std::optional<std::string> getString(const std::string& key) = 0;
64
62
  virtual std::optional<double> getNumber(const std::string& key) = 0;
@@ -17,6 +17,11 @@
17
17
  #else
18
18
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
19
  #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
20
25
 
21
26
 
22
27
 
@@ -59,6 +64,9 @@ namespace margelo::nitro {
59
64
  return false;
60
65
  }
61
66
  jsi::Object obj = value.getObject(runtime);
67
+ if (!nitro::isPlainObject(runtime, obj)) {
68
+ return false;
69
+ }
62
70
  if (!JSIConverter<std::function<void()>>::canConvert(runtime, obj.getProperty(runtime, "remove"))) return false;
63
71
  return true;
64
72
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-mmkv",
3
- "version": "4.0.0-beta.9",
4
- "description": "react-native-mmkv",
3
+ "version": "4.0.0",
4
+ "description": "⚡️ The fastest key/value storage for React Native.",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
7
7
  "types": "lib/index.d.ts",
@@ -61,18 +61,18 @@
61
61
  },
62
62
  "devDependencies": {
63
63
  "@expo/config-plugins": "^10.1.2",
64
- "@react-native/eslint-config": "0.81.0",
64
+ "@react-native/eslint-config": "0.82.0",
65
65
  "@testing-library/react-native": "^13.3.1",
66
66
  "@types/jest": "^29.5.12",
67
67
  "@types/react": "^19.0.6",
68
68
  "eslint": "^8.57.0",
69
69
  "eslint-config-prettier": "^9.1.0",
70
70
  "eslint-plugin-prettier": "^5.2.1",
71
- "nitrogen": "^0.29.4",
71
+ "nitrogen": "0.31.0",
72
72
  "prettier": "^3.3.3",
73
- "react": "19.1.0",
74
- "react-native": "0.81.0",
75
- "react-native-nitro-modules": "^0.29.4",
73
+ "react": "19.1.1",
74
+ "react-native": "0.82.0",
75
+ "react-native-nitro-modules": "0.31.0",
76
76
  "typescript": "^5.8.3"
77
77
  },
78
78
  "peerDependencies": {
@@ -5,7 +5,7 @@ import type { MMKVPlatformContext } from '../specs/MMKVPlatformContext.nitro'
5
5
  import { Platform } from 'react-native'
6
6
  import { addMemoryWarningListener } from '../addMemoryWarningListener/addMemoryWarningListener'
7
7
  import { isTest } from '../isTest'
8
- import { createMockMMKV } from './createMMKV.mock'
8
+ import { createMockMMKV } from './createMockMMKV'
9
9
 
10
10
  let factory: MMKVFactory | undefined
11
11
  let platformContext: MMKVPlatformContext | undefined
@@ -19,7 +19,9 @@ const hasAccessToLocalStorage = () => {
19
19
  const KEY_WILDCARD = '\\'
20
20
  const inMemoryStorage = new Map<string, string>()
21
21
 
22
- export function createMMKV(config: Configuration): MMKV {
22
+ export function createMMKV(
23
+ config: Configuration = { id: 'mmkv.default' }
24
+ ): MMKV {
23
25
  if (config.encryptionKey != null) {
24
26
  throw new Error("MMKV: 'encryptionKey' is not supported on Web!")
25
27
  }
@@ -78,18 +80,29 @@ export function createMMKV(config: Configuration): MMKV {
78
80
  return `${keyPrefix}${key}`
79
81
  }
80
82
 
83
+ const callListeners = (key: string) => {
84
+ listeners.forEach((l) => l(key))
85
+ }
86
+
81
87
  return {
82
88
  clearAll: () => {
83
89
  const keys = Object.keys(storage())
84
90
  for (const key of keys) {
85
91
  if (key.startsWith(keyPrefix)) {
86
92
  storage().removeItem(key)
93
+ callListeners(key)
87
94
  }
88
95
  }
89
96
  },
90
- remove: (key) => storage().removeItem(prefixedKey(key)) ?? false,
97
+ remove: (key) => {
98
+ const wasRemoved = storage().removeItem(prefixedKey(key)) ?? false
99
+ if (wasRemoved) callListeners(key)
100
+ return wasRemoved
101
+ },
91
102
  set: (key, value) => {
103
+ if (key === '') throw new Error('Cannot set a value for an empty key!')
92
104
  storage().setItem(prefixedKey(key), value.toString())
105
+ callListeners(key)
93
106
  },
94
107
  getString: (key) => storage().getItem(prefixedKey(key)) ?? undefined,
95
108
  getNumber: (key) => {
@@ -30,6 +30,7 @@ export function createMockMMKV(): MMKV {
30
30
  return deleted
31
31
  },
32
32
  set: (key, value) => {
33
+ if (key === '') throw new Error('Cannot set a value for an empty key!')
33
34
  storage.set(key, value)
34
35
  notifyListeners(key)
35
36
  },
@@ -6,9 +6,10 @@ export interface Listener {
6
6
 
7
7
  export interface MMKV extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
8
8
  /**
9
- * Set a value for the given `key`.
9
+ * Set a {@linkcode value} for the given {@linkcode key}.
10
10
  *
11
- * @throws an Error if the value cannot be set.
11
+ * @throws an Error if the {@linkcode key} is empty.
12
+ * @throws an Error if the {@linkcode value} cannot be set.
12
13
  */
13
14
  set(key: string, value: boolean | string | number | ArrayBuffer): void
14
15
  /**
package/app.plugin.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./lib/expo-plugin/withMMKV.cjs')
@@ -1,26 +0,0 @@
1
- "use strict";
2
- const { createRunOncePlugin, withGradleProperties } = require('@expo/config-plugins');
3
- const pkg = require('../../package.json');
4
- const withMMKV = (config) => {
5
- // remove 32-bit architectures from gradle.properties
6
- return withGradleProperties(config, (cfg) => {
7
- // Define the wanted property
8
- const property = {
9
- type: 'property',
10
- key: 'reactNativeArchitectures',
11
- value: 'arm64-v8a,x86_64',
12
- };
13
- // If it exists, update its value
14
- const index = cfg.modResults.findIndex((p) => p.type === 'property' && p.key === property.key);
15
- if (index !== -1) {
16
- // Overwrite it
17
- cfg.modResults[index] = property;
18
- }
19
- else {
20
- // Append it
21
- cfg.modResults.push(property);
22
- }
23
- return cfg;
24
- });
25
- };
26
- module.exports = createRunOncePlugin(withMMKV, pkg.name, pkg.version);
@@ -1,3 +0,0 @@
1
- import type { ConfigPlugin } from '@expo/config-plugins';
2
- declare const _default: ConfigPlugin<{}>;
3
- export = _default;
@@ -1,3 +0,0 @@
1
- import type { ConfigPlugin } from '@expo/config-plugins';
2
- declare const _default: ConfigPlugin<{}>;
3
- export default _default;
@@ -1,17 +0,0 @@
1
- import { createRunOncePlugin, withGradleProperties } from '@expo/config-plugins';
2
- const pkg = require('../../package.json');
3
- const withMMKV = (config) => {
4
- // remove 32-bit architectures from gradle.properties
5
- return withGradleProperties(config, (cfg) => {
6
- // Drop any existing entry…
7
- cfg.modResults = cfg.modResults.filter((p) => !(p.type === 'property' && p.key === 'reactNativeArchitectures'));
8
- // …and force 64-bit only.
9
- cfg.modResults.push({
10
- type: 'property',
11
- key: 'reactNativeArchitectures',
12
- value: 'arm64-v8a,x86_64',
13
- });
14
- return cfg;
15
- });
16
- };
17
- export default createRunOncePlugin(withMMKV, pkg.name, pkg.version);
@@ -1,31 +0,0 @@
1
- import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins'
2
- const { createRunOncePlugin, withGradleProperties } = require('@expo/config-plugins')
3
- import type { Properties } from '@expo/config-plugins/build/android'
4
-
5
- const pkg = require('../../package.json')
6
-
7
- const withMMKV: ConfigPlugin<{}> = (config) => {
8
- // remove 32-bit architectures from gradle.properties
9
- return withGradleProperties(config, (cfg: ExportedConfigWithProps<Properties.PropertiesItem[]>) => {
10
- // Define the wanted property
11
- const property = {
12
- type: 'property',
13
- key: 'reactNativeArchitectures',
14
- value: 'arm64-v8a,x86_64',
15
- } as const
16
- // If it exists, update its value
17
- const index = cfg.modResults.findIndex(
18
- (p) => p.type === 'property' && p.key === property.key
19
- )
20
- if (index !== -1) {
21
- // Overwrite it
22
- cfg.modResults[index] = property
23
- } else {
24
- // Append it
25
- cfg.modResults.push(property)
26
- }
27
- return cfg
28
- })
29
- }
30
-
31
- export = createRunOncePlugin(withMMKV, pkg.name, pkg.version) as ConfigPlugin<{}>