Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"react": "19.1.0",
"react-native": "0.81.0",
"react-native-mmkv": "*",
"react-native-nitro-modules": "^0.30.0",
"react-native-nitro-modules": "0.31.0",
"react-native-safe-area-context": "^5.5.2",
},
"devDependencies": {
Expand Down Expand Up @@ -60,11 +60,11 @@
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"nitrogen": "^0.30.0",
"nitrogen": "0.31.0",
"prettier": "^3.3.3",
"react": "19.1.0",
"react-native": "0.81.0",
"react-native-nitro-modules": "^0.30.0",
"react-native-nitro-modules": "0.31.0",
"typescript": "^5.8.3",
},
"peerDependencies": {
Expand Down Expand Up @@ -1593,7 +1593,7 @@

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

"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=="],
"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=="],

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

Expand Down Expand Up @@ -1767,7 +1767,7 @@

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"react": "19.1.0",
"react-native": "0.81.0",
"react-native-mmkv": "*",
"react-native-nitro-modules": "^0.30.0",
"react-native-nitro-modules": "0.31.0",
"react-native-safe-area-context": "^5.5.2"
},
"devDependencies": {
Expand Down
20 changes: 10 additions & 10 deletions packages/react-native-mmkv/cpp/HybridMMKV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,28 @@ struct overloaded : Ts... {
template <class... Ts>
overloaded(Ts...) -> overloaded<Ts...>;

void HybridMMKV::set(const std::string& key, const std::variant<std::string, double, bool, std::shared_ptr<ArrayBuffer>>& value) {
void HybridMMKV::set(const std::string& key, const std::variant<bool, std::shared_ptr<ArrayBuffer>, std::string, double>& value) {
if (key.empty()) [[unlikely]] {
throw std::runtime_error("Cannot set a value for an empty key!");
}

// Pattern-match each potential value in std::variant
bool didSet = std::visit(overloaded{[&](const std::string& string) {
// string
return instance->set(string, key);
},
[&](double number) {
// number
return instance->set(number, key);
},
[&](bool b) {
bool didSet = std::visit(overloaded{[&](bool b) {
// boolean
return instance->set(b, key);
},
[&](const std::shared_ptr<ArrayBuffer>& buf) {
// ArrayBuffer
MMBuffer buffer(buf->data(), buf->size(), MMBufferCopyFlag::MMBufferNoCopy);
return instance->set(std::move(buffer), key);
},
[&](const std::string& string) {
// string
return instance->set(string, key);
},
[&](double number) {
// number
return instance->set(number, key);
}},
value);
if (!didSet) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-mmkv/cpp/HybridMMKV.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class HybridMMKV final : public HybridMMKVSpec {

public:
// Methods
void set(const std::string& key, const std::variant<std::string, double, bool, std::shared_ptr<ArrayBuffer>>& value) override;
void set(const std::string& key, const std::variant<bool, std::shared_ptr<ArrayBuffer>, std::string, double>& value) override;
std::optional<bool> getBoolean(const std::string& key) override;
std::optional<std::string> getString(const std::string& key) override;
std::optional<double> getNumber(const std::string& key) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package com.margelo.nitro.mmkv
import androidx.annotation.Keep
import com.facebook.jni.HybridData
import com.facebook.proguard.annotations.DoNotStrip
import com.margelo.nitro.core.*
import com.margelo.nitro.core.HybridObject

/**
* A Kotlin class representing the MMKVPlatformContext HybridObject.
Expand Down Expand Up @@ -51,6 +51,6 @@ abstract class HybridMMKVPlatformContextSpec: HybridObject() {
private external fun initHybrid(): HybridData

companion object {
private const val TAG = "HybridMMKVPlatformContextSpec"
protected const val TAG = "HybridMMKVPlatformContextSpec"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

// Forward declaration of `ArrayBuffer` to properly resolve imports.
namespace NitroModules { class ArrayBuffer; }
// Forward declaration of `Listener` to properly resolve imports.
namespace margelo::nitro::mmkv { struct Listener; }

Expand Down Expand Up @@ -58,7 +56,7 @@ namespace margelo::nitro::mmkv {

public:
// Methods
virtual void set(const std::string& key, const std::variant<std::string, double, bool, std::shared_ptr<ArrayBuffer>>& value) = 0;
virtual void set(const std::string& key, const std::variant<bool, std::shared_ptr<ArrayBuffer>, std::string, double>& value) = 0;
virtual std::optional<bool> getBoolean(const std::string& key) = 0;
virtual std::optional<std::string> getString(const std::string& key) = 0;
virtual std::optional<double> getNumber(const std::string& key) = 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-mmkv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"nitrogen": "^0.30.0",
"nitrogen": "0.31.0",
"prettier": "^3.3.3",
"react": "19.1.0",
"react-native": "0.81.0",
"react-native-nitro-modules": "^0.30.0",
"react-native-nitro-modules": "0.31.0",
"typescript": "^5.8.3"
},
"peerDependencies": {
Expand Down
Loading