Skip to content

Commit 176e4f3

Browse files
authored
feat: Upgrade to Nitro 0.31 (#929)
1 parent e551230 commit 176e4f3

File tree

7 files changed

+22
-24
lines changed

7 files changed

+22
-24
lines changed

bun.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"react": "19.1.0",
2424
"react-native": "0.81.0",
2525
"react-native-mmkv": "*",
26-
"react-native-nitro-modules": "^0.30.0",
26+
"react-native-nitro-modules": "0.31.0",
2727
"react-native-safe-area-context": "^5.5.2",
2828
},
2929
"devDependencies": {
@@ -60,11 +60,11 @@
6060
"eslint": "^8.57.0",
6161
"eslint-config-prettier": "^9.1.0",
6262
"eslint-plugin-prettier": "^5.2.1",
63-
"nitrogen": "^0.30.0",
63+
"nitrogen": "0.31.0",
6464
"prettier": "^3.3.3",
6565
"react": "19.1.0",
6666
"react-native": "0.81.0",
67-
"react-native-nitro-modules": "^0.30.0",
67+
"react-native-nitro-modules": "0.31.0",
6868
"typescript": "^5.8.3",
6969
},
7070
"peerDependencies": {
@@ -1593,7 +1593,7 @@
15931593

15941594
"new-github-release-url": ["[email protected]", "", { "dependencies": { "type-fest": "^2.5.1" } }, "sha512-NHDDGYudnvRutt/VhKFlX26IotXe1w0cmkDm6JGquh5bz/bDTw0LufSmH/GxTjEdpHEO+bVKFTwdrcGa/9XlKQ=="],
15951595

1596-
"nitrogen": ["nitrogen@0.30.0", "", { "dependencies": { "chalk": "^5.3.0", "react-native-nitro-modules": "^0.30.0", "ts-morph": "^27.0.0", "yargs": "^18.0.0", "zod": "^4.0.5" }, "bin": { "nitrogen": "lib/index.js" } }, "sha512-dM7GBwAOkf8FEILyzvio67Xjuwvbxa9FMMQdsj1PuIQon21et8Nw2ZY0F3xqQK7/osz7b/IWQ5EICPfUzhN3Ng=="],
1596+
"nitrogen": ["nitrogen@0.31.0", "", { "dependencies": { "chalk": "^5.3.0", "react-native-nitro-modules": "^0.31.0", "ts-morph": "^27.0.0", "yargs": "^18.0.0", "zod": "^4.0.5" }, "bin": { "nitrogen": "lib/index.js" } }, "sha512-qiZyjGJBEBh93w0Y6NfYWIsRH6hf+hmKpc2QAVs3qvRRC3F7n0Y1zE+4Vr6him4O0jmoijjdn8Jqqcu+4afyOQ=="],
15971597

15981598
"nocache": ["[email protected]", "", {}, "sha512-WDD0bdg9mbq6F4mRxEYcPWwfA1vxd0mrvKOyxI7Xj/atfRHVeutzuWByG//jfm4uPzp0y4Kj051EORCBSQMycw=="],
15991599

@@ -1767,7 +1767,7 @@
17671767

17681768
"react-native-mmkv": ["react-native-mmkv@workspace:packages/react-native-mmkv"],
17691769

1770-
"react-native-nitro-modules": ["react-native-nitro-modules@0.30.0", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-DHFSEbM7cwVHmpbGvmd+b5iqy67My0In9oBc8eSMvjTkLWrDkkiE5jLdt6ZJyDF7Fn3C5Tr6Lq2bUa596VSW2g=="],
1770+
"react-native-nitro-modules": ["react-native-nitro-modules@0.31.0", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-2sZBj6ap32DE5N9WHD4sFldpSqv1FgTVDNyeWRpIw9kW7YBBQ/cmDGASX0EyK7R8ZzevfOoIQ1BPuN3Q/2jg8g=="],
17711771

17721772
"react-native-safe-area-context": ["[email protected]", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-/wJE58HLEAkATzhhX1xSr+fostLsK8Q97EfpfMDKo8jlOc1QKESSX/FQrhk7HhQH/2uSaox4Y86sNaI02kteiA=="],
17731773

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"react": "19.1.0",
1919
"react-native": "0.81.0",
2020
"react-native-mmkv": "*",
21-
"react-native-nitro-modules": "^0.30.0",
21+
"react-native-nitro-modules": "0.31.0",
2222
"react-native-safe-area-context": "^5.5.2"
2323
},
2424
"devDependencies": {

packages/react-native-mmkv/cpp/HybridMMKV.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,28 @@ struct overloaded : Ts... {
7070
template <class... Ts>
7171
overloaded(Ts...) -> overloaded<Ts...>;
7272

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) {
7474
if (key.empty()) [[unlikely]] {
7575
throw std::runtime_error("Cannot set a value for an empty key!");
7676
}
7777

7878
// Pattern-match each potential value in std::variant
79-
bool didSet = std::visit(overloaded{[&](const std::string& string) {
80-
// string
81-
return instance->set(string, key);
82-
},
83-
[&](double number) {
84-
// number
85-
return instance->set(number, key);
86-
},
87-
[&](bool b) {
79+
bool didSet = std::visit(overloaded{[&](bool b) {
8880
// boolean
8981
return instance->set(b, key);
9082
},
9183
[&](const std::shared_ptr<ArrayBuffer>& buf) {
9284
// ArrayBuffer
9385
MMBuffer buffer(buf->data(), buf->size(), MMBufferCopyFlag::MMBufferNoCopy);
9486
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);
9595
}},
9696
value);
9797
if (!didSet) {

packages/react-native-mmkv/cpp/HybridMMKV.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class HybridMMKV final : public HybridMMKVSpec {
2424

2525
public:
2626
// 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;
2828
std::optional<bool> getBoolean(const std::string& key) override;
2929
std::optional<std::string> getString(const std::string& key) override;
3030
std::optional<double> getNumber(const std::string& key) override;

packages/react-native-mmkv/nitrogen/generated/android/kotlin/com/margelo/nitro/mmkv/HybridMMKVPlatformContextSpec.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package com.margelo.nitro.mmkv
1010
import androidx.annotation.Keep
1111
import com.facebook.jni.HybridData
1212
import com.facebook.proguard.annotations.DoNotStrip
13-
import com.margelo.nitro.core.*
13+
import com.margelo.nitro.core.HybridObject
1414

1515
/**
1616
* A Kotlin class representing the MMKVPlatformContext HybridObject.
@@ -51,6 +51,6 @@ abstract class HybridMMKVPlatformContextSpec: HybridObject() {
5151
private external fun initHybrid(): HybridData
5252

5353
companion object {
54-
private const val TAG = "HybridMMKVPlatformContextSpec"
54+
protected const val TAG = "HybridMMKVPlatformContextSpec"
5555
}
5656
}

packages/react-native-mmkv/nitrogen/generated/shared/c++/HybridMMKVSpec.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
1414
#endif
1515

16-
// Forward declaration of `ArrayBuffer` to properly resolve imports.
17-
namespace NitroModules { class ArrayBuffer; }
1816
// Forward declaration of `Listener` to properly resolve imports.
1917
namespace margelo::nitro::mmkv { struct Listener; }
2018

@@ -58,7 +56,7 @@ namespace margelo::nitro::mmkv {
5856

5957
public:
6058
// 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;
6260
virtual std::optional<bool> getBoolean(const std::string& key) = 0;
6361
virtual std::optional<std::string> getString(const std::string& key) = 0;
6462
virtual std::optional<double> getNumber(const std::string& key) = 0;

packages/react-native-mmkv/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@
6868
"eslint": "^8.57.0",
6969
"eslint-config-prettier": "^9.1.0",
7070
"eslint-plugin-prettier": "^5.2.1",
71-
"nitrogen": "^0.30.0",
71+
"nitrogen": "0.31.0",
7272
"prettier": "^3.3.3",
7373
"react": "19.1.0",
7474
"react-native": "0.81.0",
75-
"react-native-nitro-modules": "^0.30.0",
75+
"react-native-nitro-modules": "0.31.0",
7676
"typescript": "^5.8.3"
7777
},
7878
"peerDependencies": {

0 commit comments

Comments
 (0)