react-native-mmkv 4.0.0-beta.1 → 4.0.0-beta.2
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/{react-native-mmkv.podspec → NitroMmkv.podspec} +17 -13
- package/README.md +1 -3
- package/android/CMakeLists.txt +31 -30
- package/android/build.gradle +64 -19
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -5
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/mmkv/HybridMMKVPlatformContext.kt +19 -0
- package/android/src/main/java/com/margelo/nitro/mmkv/NitroMmkvPackage.java +33 -0
- package/ios/HybridMMKVPlatformContext.swift +32 -0
- package/lib/__tests__/hooks.test.d.ts +1 -0
- package/lib/__tests__/hooks.test.js +66 -0
- package/lib/addMemoryWarningListener/addMemoryWarningListener.d.ts +2 -0
- package/lib/addMemoryWarningListener/addMemoryWarningListener.js +25 -0
- package/lib/addMemoryWarningListener/addMemoryWarningListener.mock.d.ts +2 -0
- package/lib/addMemoryWarningListener/addMemoryWarningListener.mock.js +3 -0
- package/lib/addMemoryWarningListener/addMemoryWarningListener.web.d.ts +2 -0
- package/lib/addMemoryWarningListener/addMemoryWarningListener.web.js +3 -0
- package/lib/createMMKV/createMMKV.d.ts +3 -0
- package/lib/createMMKV/createMMKV.js +40 -0
- package/lib/createMMKV/createMMKV.mock.d.ts +5 -0
- package/lib/createMMKV/createMMKV.mock.js +53 -0
- package/lib/createMMKV/createMMKV.web.d.ts +3 -0
- package/lib/createMMKV/createMMKV.web.js +117 -0
- package/lib/createMMKV/getDefaultMMKVInstance.d.ts +2 -0
- package/lib/createMMKV/getDefaultMMKVInstance.js +8 -0
- package/lib/hooks/createMMKVHook.d.ts +2 -0
- package/lib/hooks/createMMKVHook.js +49 -0
- package/lib/hooks/useMMKV.d.ts +11 -0
- package/lib/hooks/useMMKV.js +23 -0
- package/lib/hooks/useMMKVBoolean.d.ts +11 -0
- package/lib/hooks/useMMKVBoolean.js +12 -0
- package/lib/hooks/useMMKVBuffer.d.ts +11 -0
- package/lib/hooks/useMMKVBuffer.js +12 -0
- package/lib/hooks/useMMKVKeys.d.ts +12 -0
- package/lib/hooks/useMMKVKeys.js +33 -0
- package/lib/hooks/useMMKVListener.d.ts +15 -0
- package/lib/hooks/useMMKVListener.js +26 -0
- package/lib/hooks/useMMKVNumber.d.ts +11 -0
- package/lib/hooks/useMMKVNumber.js +12 -0
- package/lib/hooks/useMMKVObject.d.ts +17 -0
- package/lib/hooks/useMMKVObject.js +38 -0
- package/lib/hooks/useMMKVString.d.ts +11 -0
- package/lib/hooks/useMMKVString.js +12 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +11 -0
- package/lib/isTest.d.ts +1 -0
- package/lib/isTest.js +7 -0
- package/lib/specs/MMKV.nitro.d.ts +93 -0
- package/lib/specs/MMKV.nitro.js +1 -0
- package/lib/{typescript/src/NativeMmkv.d.ts → specs/MMKVFactory.nitro.d.ts} +22 -29
- package/lib/specs/MMKVFactory.nitro.js +1 -0
- package/lib/specs/MMKVPlatformContext.nitro.d.ts +15 -0
- package/lib/specs/MMKVPlatformContext.nitro.js +1 -0
- package/lib/{typescript/src → web}/createTextEncoder.d.ts +0 -1
- package/lib/web/createTextEncoder.js +17 -0
- package/nitro.json +27 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroMmkv+autolinking.cmake +80 -0
- package/nitrogen/generated/android/NitroMmkv+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroMmkvOnLoad.cpp +55 -0
- package/nitrogen/generated/android/NitroMmkvOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JHybridMMKVPlatformContextSpec.cpp +51 -0
- package/nitrogen/generated/android/c++/JHybridMMKVPlatformContextSpec.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/mmkv/HybridMMKVPlatformContextSpec.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/mmkv/NitroMmkvOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroMmkv+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroMmkv-Swift-Cxx-Bridge.cpp +32 -0
- package/nitrogen/generated/ios/NitroMmkv-Swift-Cxx-Bridge.hpp +52 -0
- package/nitrogen/generated/ios/NitroMmkv-Swift-Cxx-Umbrella.hpp +44 -0
- package/nitrogen/generated/ios/NitroMmkvAutolinking.mm +43 -0
- package/nitrogen/generated/ios/NitroMmkvAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridMMKVPlatformContextSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridMMKVPlatformContextSpecSwift.hpp +81 -0
- package/nitrogen/generated/ios/swift/HybridMMKVPlatformContextSpec.swift +50 -0
- package/nitrogen/generated/ios/swift/HybridMMKVPlatformContextSpec_cxx.swift +135 -0
- package/nitrogen/generated/shared/c++/Configuration.hpp +86 -0
- package/nitrogen/generated/shared/c++/HybridMMKVFactorySpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridMMKVFactorySpec.hpp +69 -0
- package/nitrogen/generated/shared/c++/HybridMMKVPlatformContextSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridMMKVPlatformContextSpec.hpp +63 -0
- package/nitrogen/generated/shared/c++/HybridMMKVSpec.cpp +34 -0
- package/nitrogen/generated/shared/c++/HybridMMKVSpec.hpp +83 -0
- package/nitrogen/generated/shared/c++/Listener.hpp +67 -0
- package/nitrogen/generated/shared/c++/Mode.hpp +76 -0
- package/package.json +71 -122
- package/react-native.config.js +2 -15
- package/src/__tests__/hooks.test.tsx +34 -34
- package/src/addMemoryWarningListener/addMemoryWarningListener.mock.ts +5 -0
- package/src/{MemoryWarningListener.ts → addMemoryWarningListener/addMemoryWarningListener.ts} +12 -12
- package/src/addMemoryWarningListener/addMemoryWarningListener.web.ts +5 -0
- package/src/createMMKV/createMMKV.mock.ts +56 -0
- package/src/createMMKV/createMMKV.ts +51 -0
- package/src/{createMMKV.web.ts → createMMKV/createMMKV.web.ts} +56 -46
- package/src/createMMKV/getDefaultMMKVInstance.ts +10 -0
- package/src/hooks/createMMKVHook.ts +66 -0
- package/src/hooks/useMMKV.ts +45 -0
- package/src/hooks/useMMKVBoolean.ts +15 -0
- package/src/hooks/useMMKVBuffer.ts +15 -0
- package/src/hooks/useMMKVKeys.ts +36 -0
- package/src/hooks/useMMKVListener.ts +33 -0
- package/src/hooks/useMMKVNumber.ts +15 -0
- package/src/hooks/useMMKVObject.ts +53 -0
- package/src/hooks/useMMKVString.ts +15 -0
- package/src/index.ts +15 -3
- package/src/{PlatformChecker.ts → isTest.ts} +2 -2
- package/src/specs/MMKV.nitro.ts +92 -0
- package/src/specs/MMKVFactory.nitro.ts +87 -0
- package/src/specs/MMKVPlatformContext.nitro.ts +14 -0
- package/src/{createTextEncoder.ts → web/createTextEncoder.ts} +7 -7
- package/android/src/main/cpp/AndroidLogger.cpp +0 -16
- package/android/src/main/java/com/mrousavy/mmkv/MmkvPackage.java +0 -44
- package/android/src/main/java/com/mrousavy/mmkv/MmkvPlatformContextModule.java +0 -26
- package/cpp/ManagedMMBuffer.h +0 -32
- package/cpp/MmkvHostObject.cpp +0 -360
- package/cpp/MmkvHostObject.h +0 -31
- package/cpp/MmkvLogger.h +0 -35
- package/cpp/MmkvTypes.h +0 -50
- package/cpp/NativeMmkvModule.cpp +0 -43
- package/cpp/NativeMmkvModule.h +0 -31
- package/ios/AppleLogger.mm +0 -16
- package/ios/MmkvOnLoad.mm +0 -25
- package/ios/MmkvPlatformContext.h +0 -19
- package/ios/MmkvPlatformContextModule.mm +0 -55
- package/lib/commonjs/MMKV.js +0 -124
- package/lib/commonjs/MMKV.js.map +0 -1
- package/lib/commonjs/MemoryWarningListener.js +0 -31
- package/lib/commonjs/MemoryWarningListener.js.map +0 -1
- package/lib/commonjs/MemoryWarningListener.web.js +0 -11
- package/lib/commonjs/MemoryWarningListener.web.js.map +0 -1
- package/lib/commonjs/ModuleNotFoundError.js +0 -75
- package/lib/commonjs/ModuleNotFoundError.js.map +0 -1
- package/lib/commonjs/NativeMmkv.js +0 -47
- package/lib/commonjs/NativeMmkv.js.map +0 -1
- package/lib/commonjs/NativeMmkvPlatformContext.js +0 -22
- package/lib/commonjs/NativeMmkvPlatformContext.js.map +0 -1
- package/lib/commonjs/PlatformChecker.js +0 -14
- package/lib/commonjs/PlatformChecker.js.map +0 -1
- package/lib/commonjs/Types.js +0 -26
- package/lib/commonjs/Types.js.map +0 -1
- package/lib/commonjs/createMMKV.js +0 -43
- package/lib/commonjs/createMMKV.js.map +0 -1
- package/lib/commonjs/createMMKV.mock.js +0 -43
- package/lib/commonjs/createMMKV.mock.js.map +0 -1
- package/lib/commonjs/createMMKV.web.js +0 -110
- package/lib/commonjs/createMMKV.web.js.map +0 -1
- package/lib/commonjs/createTextEncoder.js +0 -23
- package/lib/commonjs/createTextEncoder.js.map +0 -1
- package/lib/commonjs/hooks.js +0 -198
- package/lib/commonjs/hooks.js.map +0 -1
- package/lib/commonjs/index.js +0 -40
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/package.json +0 -1
- package/lib/module/MMKV.js +0 -119
- package/lib/module/MMKV.js.map +0 -1
- package/lib/module/MemoryWarningListener.js +0 -27
- package/lib/module/MemoryWarningListener.js.map +0 -1
- package/lib/module/MemoryWarningListener.web.js +0 -6
- package/lib/module/MemoryWarningListener.web.js.map +0 -1
- package/lib/module/ModuleNotFoundError.js +0 -70
- package/lib/module/ModuleNotFoundError.js.map +0 -1
- package/lib/module/NativeMmkv.js +0 -45
- package/lib/module/NativeMmkv.js.map +0 -1
- package/lib/module/NativeMmkvPlatformContext.js +0 -18
- package/lib/module/NativeMmkvPlatformContext.js.map +0 -1
- package/lib/module/PlatformChecker.js +0 -10
- package/lib/module/PlatformChecker.js.map +0 -1
- package/lib/module/Types.js +0 -25
- package/lib/module/Types.js.map +0 -1
- package/lib/module/createMMKV.js +0 -38
- package/lib/module/createMMKV.js.map +0 -1
- package/lib/module/createMMKV.mock.js +0 -38
- package/lib/module/createMMKV.mock.js.map +0 -1
- package/lib/module/createMMKV.web.js +0 -105
- package/lib/module/createMMKV.web.js.map +0 -1
- package/lib/module/createTextEncoder.js +0 -19
- package/lib/module/createTextEncoder.js.map +0 -1
- package/lib/module/hooks.js +0 -189
- package/lib/module/hooks.js.map +0 -1
- package/lib/module/index.js +0 -6
- package/lib/module/index.js.map +0 -1
- package/lib/module/package.json +0 -1
- package/lib/typescript/src/MMKV.d.ts +0 -34
- package/lib/typescript/src/MMKV.d.ts.map +0 -1
- package/lib/typescript/src/MemoryWarningListener.d.ts +0 -3
- package/lib/typescript/src/MemoryWarningListener.d.ts.map +0 -1
- package/lib/typescript/src/MemoryWarningListener.web.d.ts +0 -3
- package/lib/typescript/src/MemoryWarningListener.web.d.ts.map +0 -1
- package/lib/typescript/src/ModuleNotFoundError.d.ts +0 -7
- package/lib/typescript/src/ModuleNotFoundError.d.ts.map +0 -1
- package/lib/typescript/src/NativeMmkv.d.ts.map +0 -1
- package/lib/typescript/src/NativeMmkvPlatformContext.d.ts +0 -20
- package/lib/typescript/src/NativeMmkvPlatformContext.d.ts.map +0 -1
- package/lib/typescript/src/PlatformChecker.d.ts +0 -2
- package/lib/typescript/src/PlatformChecker.d.ts.map +0 -1
- package/lib/typescript/src/Types.d.ts +0 -172
- package/lib/typescript/src/Types.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/hooks.test.d.ts +0 -2
- package/lib/typescript/src/__tests__/hooks.test.d.ts.map +0 -1
- package/lib/typescript/src/createMMKV.d.ts +0 -3
- package/lib/typescript/src/createMMKV.d.ts.map +0 -1
- package/lib/typescript/src/createMMKV.mock.d.ts +0 -3
- package/lib/typescript/src/createMMKV.mock.d.ts.map +0 -1
- package/lib/typescript/src/createMMKV.web.d.ts +0 -3
- package/lib/typescript/src/createMMKV.web.d.ts.map +0 -1
- package/lib/typescript/src/createTextEncoder.d.ts.map +0 -1
- package/lib/typescript/src/hooks.d.ts +0 -86
- package/lib/typescript/src/hooks.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -4
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/src/MMKV.ts +0 -142
- package/src/MemoryWarningListener.web.ts +0 -5
- package/src/ModuleNotFoundError.ts +0 -95
- package/src/NativeMmkv.ts +0 -118
- package/src/NativeMmkvPlatformContext.ts +0 -38
- package/src/Types.ts +0 -178
- package/src/createMMKV.mock.ts +0 -38
- package/src/createMMKV.ts +0 -42
- package/src/hooks.ts +0 -247
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroMmkv-Swift-Cxx-Bridge.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridMMKVPlatformContextSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::mmkv { class HybridMMKVPlatformContextSpec; }
|
|
13
|
+
|
|
14
|
+
// Forward declarations of Swift defined types
|
|
15
|
+
// Forward declaration of `HybridMMKVPlatformContextSpec_cxx` to properly resolve imports.
|
|
16
|
+
namespace NitroMmkv { class HybridMMKVPlatformContextSpec_cxx; }
|
|
17
|
+
|
|
18
|
+
// Include C++ defined types
|
|
19
|
+
#include "HybridMMKVPlatformContextSpec.hpp"
|
|
20
|
+
#include <NitroModules/Result.hpp>
|
|
21
|
+
#include <exception>
|
|
22
|
+
#include <memory>
|
|
23
|
+
#include <string>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
27
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
28
|
+
*/
|
|
29
|
+
namespace margelo::nitro::mmkv::bridge::swift {
|
|
30
|
+
|
|
31
|
+
// pragma MARK: std::shared_ptr<HybridMMKVPlatformContextSpec>
|
|
32
|
+
/**
|
|
33
|
+
* Specialized version of `std::shared_ptr<HybridMMKVPlatformContextSpec>`.
|
|
34
|
+
*/
|
|
35
|
+
using std__shared_ptr_HybridMMKVPlatformContextSpec_ = std::shared_ptr<HybridMMKVPlatformContextSpec>;
|
|
36
|
+
std::shared_ptr<HybridMMKVPlatformContextSpec> create_std__shared_ptr_HybridMMKVPlatformContextSpec_(void* _Nonnull swiftUnsafePointer) noexcept;
|
|
37
|
+
void* _Nonnull get_std__shared_ptr_HybridMMKVPlatformContextSpec_(std__shared_ptr_HybridMMKVPlatformContextSpec_ cppType) noexcept;
|
|
38
|
+
|
|
39
|
+
// pragma MARK: std::weak_ptr<HybridMMKVPlatformContextSpec>
|
|
40
|
+
using std__weak_ptr_HybridMMKVPlatformContextSpec_ = std::weak_ptr<HybridMMKVPlatformContextSpec>;
|
|
41
|
+
inline std__weak_ptr_HybridMMKVPlatformContextSpec_ weakify_std__shared_ptr_HybridMMKVPlatformContextSpec_(const std::shared_ptr<HybridMMKVPlatformContextSpec>& strong) noexcept { return strong; }
|
|
42
|
+
|
|
43
|
+
// pragma MARK: Result<std::string>
|
|
44
|
+
using Result_std__string_ = Result<std::string>;
|
|
45
|
+
inline Result_std__string_ create_Result_std__string_(const std::string& value) noexcept {
|
|
46
|
+
return Result<std::string>::withValue(value);
|
|
47
|
+
}
|
|
48
|
+
inline Result_std__string_ create_Result_std__string_(const std::exception_ptr& error) noexcept {
|
|
49
|
+
return Result<std::string>::withError(error);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
} // namespace margelo::nitro::mmkv::bridge::swift
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroMmkv-Swift-Cxx-Umbrella.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridMMKVPlatformContextSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::mmkv { class HybridMMKVPlatformContextSpec; }
|
|
13
|
+
|
|
14
|
+
// Include C++ defined types
|
|
15
|
+
#include "HybridMMKVPlatformContextSpec.hpp"
|
|
16
|
+
#include <NitroModules/Result.hpp>
|
|
17
|
+
#include <exception>
|
|
18
|
+
#include <memory>
|
|
19
|
+
#include <string>
|
|
20
|
+
|
|
21
|
+
// C++ helpers for Swift
|
|
22
|
+
#include "NitroMmkv-Swift-Cxx-Bridge.hpp"
|
|
23
|
+
|
|
24
|
+
// Common C++ types used in Swift
|
|
25
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
26
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
27
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
28
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
29
|
+
|
|
30
|
+
// Forward declarations of Swift defined types
|
|
31
|
+
// Forward declaration of `HybridMMKVPlatformContextSpec_cxx` to properly resolve imports.
|
|
32
|
+
namespace NitroMmkv { class HybridMMKVPlatformContextSpec_cxx; }
|
|
33
|
+
|
|
34
|
+
// Include Swift defined types
|
|
35
|
+
#if __has_include("NitroMmkv-Swift.h")
|
|
36
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
37
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroMmkv".
|
|
38
|
+
#include "NitroMmkv-Swift.h"
|
|
39
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
40
|
+
#elif __has_include(<NitroMmkv/NitroMmkv-Swift.h>)
|
|
41
|
+
#include <NitroMmkv/NitroMmkv-Swift.h>
|
|
42
|
+
#else
|
|
43
|
+
#error NitroMmkv's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroMmkv", and try building the app first.
|
|
44
|
+
#endif
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroMmkvAutolinking.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
#import "NitroMmkv-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridMMKVFactory.hpp"
|
|
14
|
+
#include "HybridMMKVPlatformContextSpecSwift.hpp"
|
|
15
|
+
|
|
16
|
+
@interface NitroMmkvAutolinking : NSObject
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
@implementation NitroMmkvAutolinking
|
|
20
|
+
|
|
21
|
+
+ (void) load {
|
|
22
|
+
using namespace margelo::nitro;
|
|
23
|
+
using namespace margelo::nitro::mmkv;
|
|
24
|
+
|
|
25
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
26
|
+
"MMKVFactory",
|
|
27
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
28
|
+
static_assert(std::is_default_constructible_v<HybridMMKVFactory>,
|
|
29
|
+
"The HybridObject \"HybridMMKVFactory\" is not default-constructible! "
|
|
30
|
+
"Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
|
|
31
|
+
return std::make_shared<HybridMMKVFactory>();
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
35
|
+
"MMKVPlatformContext",
|
|
36
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
37
|
+
std::shared_ptr<HybridMMKVPlatformContextSpec> hybridObject = NitroMmkv::NitroMmkvAutolinking::createMMKVPlatformContext();
|
|
38
|
+
return hybridObject;
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroMmkvAutolinking.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
public final class NitroMmkvAutolinking {
|
|
9
|
+
public typealias bridge = margelo.nitro.mmkv.bridge.swift
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of a Swift class that implements `HybridMMKVPlatformContextSpec`,
|
|
13
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridMMKVPlatformContextSpec_cxx`)
|
|
14
|
+
*
|
|
15
|
+
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridMMKVPlatformContext`).
|
|
17
|
+
*/
|
|
18
|
+
public static func createMMKVPlatformContext() -> bridge.std__shared_ptr_HybridMMKVPlatformContextSpec_ {
|
|
19
|
+
let hybridObject = HybridMMKVPlatformContext()
|
|
20
|
+
return { () -> bridge.std__shared_ptr_HybridMMKVPlatformContextSpec_ in
|
|
21
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
|
+
return __cxxWrapped.getCxxPart()
|
|
23
|
+
}()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMMKVPlatformContextSpecSwift.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridMMKVPlatformContextSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::mmkv {
|
|
11
|
+
} // namespace margelo::nitro::mmkv
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMMKVPlatformContextSpecSwift.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridMMKVPlatformContextSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridMMKVPlatformContextSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroMmkv { class HybridMMKVPlatformContextSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
|
|
19
|
+
#include "NitroMmkv-Swift-Cxx-Umbrella.hpp"
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::mmkv {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The C++ part of HybridMMKVPlatformContextSpec_cxx.swift.
|
|
25
|
+
*
|
|
26
|
+
* HybridMMKVPlatformContextSpecSwift (C++) accesses HybridMMKVPlatformContextSpec_cxx (Swift), and might
|
|
27
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
28
|
+
*
|
|
29
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
30
|
+
* the future, HybridMMKVPlatformContextSpec_cxx can directly inherit from the C++ class HybridMMKVPlatformContextSpec
|
|
31
|
+
* to simplify the whole structure and memory management.
|
|
32
|
+
*/
|
|
33
|
+
class HybridMMKVPlatformContextSpecSwift: public virtual HybridMMKVPlatformContextSpec {
|
|
34
|
+
public:
|
|
35
|
+
// Constructor from a Swift instance
|
|
36
|
+
explicit HybridMMKVPlatformContextSpecSwift(const NitroMmkv::HybridMMKVPlatformContextSpec_cxx& swiftPart):
|
|
37
|
+
HybridObject(HybridMMKVPlatformContextSpec::TAG),
|
|
38
|
+
_swiftPart(swiftPart) { }
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
// Get the Swift part
|
|
42
|
+
inline NitroMmkv::HybridMMKVPlatformContextSpec_cxx& getSwiftPart() noexcept {
|
|
43
|
+
return _swiftPart;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
48
|
+
return _swiftPart.getMemorySize();
|
|
49
|
+
}
|
|
50
|
+
void dispose() noexcept override {
|
|
51
|
+
_swiftPart.dispose();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
// Properties
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
// Methods
|
|
60
|
+
inline std::string getBaseDirectory() override {
|
|
61
|
+
auto __result = _swiftPart.getBaseDirectory();
|
|
62
|
+
if (__result.hasError()) [[unlikely]] {
|
|
63
|
+
std::rethrow_exception(__result.error());
|
|
64
|
+
}
|
|
65
|
+
auto __value = std::move(__result.value());
|
|
66
|
+
return __value;
|
|
67
|
+
}
|
|
68
|
+
inline std::string getAppGroupDirectory() override {
|
|
69
|
+
auto __result = _swiftPart.getAppGroupDirectory();
|
|
70
|
+
if (__result.hasError()) [[unlikely]] {
|
|
71
|
+
std::rethrow_exception(__result.error());
|
|
72
|
+
}
|
|
73
|
+
auto __value = std::move(__result.value());
|
|
74
|
+
return __value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private:
|
|
78
|
+
NitroMmkv::HybridMMKVPlatformContextSpec_cxx _swiftPart;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
} // namespace margelo::nitro::mmkv
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMMKVPlatformContextSpec.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridMMKVPlatformContextSpec``
|
|
12
|
+
public protocol HybridMMKVPlatformContextSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func getBaseDirectory() throws -> String
|
|
18
|
+
func getAppGroupDirectory() throws -> String
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/// See ``HybridMMKVPlatformContextSpec``
|
|
22
|
+
open class HybridMMKVPlatformContextSpec_base {
|
|
23
|
+
private weak var cxxWrapper: HybridMMKVPlatformContextSpec_cxx? = nil
|
|
24
|
+
public init() { }
|
|
25
|
+
public func getCxxWrapper() -> HybridMMKVPlatformContextSpec_cxx {
|
|
26
|
+
#if DEBUG
|
|
27
|
+
guard self is HybridMMKVPlatformContextSpec else {
|
|
28
|
+
fatalError("`self` is not a `HybridMMKVPlatformContextSpec`! Did you accidentally inherit from `HybridMMKVPlatformContextSpec_base` instead of `HybridMMKVPlatformContextSpec`?")
|
|
29
|
+
}
|
|
30
|
+
#endif
|
|
31
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
32
|
+
return cxxWrapper
|
|
33
|
+
} else {
|
|
34
|
+
let cxxWrapper = HybridMMKVPlatformContextSpec_cxx(self as! HybridMMKVPlatformContextSpec)
|
|
35
|
+
self.cxxWrapper = cxxWrapper
|
|
36
|
+
return cxxWrapper
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A Swift base-protocol representing the MMKVPlatformContext HybridObject.
|
|
43
|
+
* Implement this protocol to create Swift-based instances of MMKVPlatformContext.
|
|
44
|
+
* ```swift
|
|
45
|
+
* class HybridMMKVPlatformContext : HybridMMKVPlatformContextSpec {
|
|
46
|
+
* // ...
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
public typealias HybridMMKVPlatformContextSpec = HybridMMKVPlatformContextSpec_protocol & HybridMMKVPlatformContextSpec_base
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMMKVPlatformContextSpec_cxx.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class implementation that bridges HybridMMKVPlatformContextSpec over to C++.
|
|
13
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
|
+
*
|
|
15
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
16
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
17
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
|
+
*/
|
|
20
|
+
open class HybridMMKVPlatformContextSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::mmkv::bridge::swift`)
|
|
23
|
+
* from `NitroMmkv-Swift-Cxx-Bridge.hpp`.
|
|
24
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
|
+
*/
|
|
26
|
+
public typealias bridge = margelo.nitro.mmkv.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridMMKVPlatformContextSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridMMKVPlatformContextSpec
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
|
+
*/
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridMMKVPlatformContextSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridMMKVPlatformContextSpec_cxx` that wraps the given `HybridMMKVPlatformContextSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridMMKVPlatformContextSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridMMKVPlatformContextSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridMMKVPlatformContextSpec() -> any HybridMMKVPlatformContextSpec {
|
|
53
|
+
return __implementation
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
58
|
+
* This acquires one additional strong reference on the object!
|
|
59
|
+
*/
|
|
60
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
61
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Casts an unsafe pointer to a `HybridMMKVPlatformContextSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridMMKVPlatformContextSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridMMKVPlatformContextSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridMMKVPlatformContextSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridMMKVPlatformContextSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridMMKVPlatformContextSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if cachedCxxPart.__convertToBool() {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridMMKVPlatformContextSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridMMKVPlatformContextSpec_(newCxxPart)
|
|
84
|
+
return newCxxPart
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
+
*/
|
|
94
|
+
@inline(__always)
|
|
95
|
+
public var memorySize: Int {
|
|
96
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Call dispose() on the Swift class.
|
|
101
|
+
* This _may_ be called manually from JS.
|
|
102
|
+
*/
|
|
103
|
+
@inline(__always)
|
|
104
|
+
public func dispose() {
|
|
105
|
+
self.__implementation.dispose()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Properties
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
// Methods
|
|
112
|
+
@inline(__always)
|
|
113
|
+
public final func getBaseDirectory() -> bridge.Result_std__string_ {
|
|
114
|
+
do {
|
|
115
|
+
let __result = try self.__implementation.getBaseDirectory()
|
|
116
|
+
let __resultCpp = std.string(__result)
|
|
117
|
+
return bridge.create_Result_std__string_(__resultCpp)
|
|
118
|
+
} catch (let __error) {
|
|
119
|
+
let __exceptionPtr = __error.toCpp()
|
|
120
|
+
return bridge.create_Result_std__string_(__exceptionPtr)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@inline(__always)
|
|
125
|
+
public final func getAppGroupDirectory() -> bridge.Result_std__string_ {
|
|
126
|
+
do {
|
|
127
|
+
let __result = try self.__implementation.getAppGroupDirectory()
|
|
128
|
+
let __resultCpp = std.string(__result)
|
|
129
|
+
return bridge.create_Result_std__string_(__resultCpp)
|
|
130
|
+
} catch (let __error) {
|
|
131
|
+
let __exceptionPtr = __error.toCpp()
|
|
132
|
+
return bridge.create_Result_std__string_(__exceptionPtr)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Configuration.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
// Forward declaration of `Mode` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::mmkv { enum class Mode; }
|
|
23
|
+
|
|
24
|
+
#include <string>
|
|
25
|
+
#include <optional>
|
|
26
|
+
#include "Mode.hpp"
|
|
27
|
+
|
|
28
|
+
namespace margelo::nitro::mmkv {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A struct which can be represented as a JavaScript object (Configuration).
|
|
32
|
+
*/
|
|
33
|
+
struct Configuration {
|
|
34
|
+
public:
|
|
35
|
+
std::string id SWIFT_PRIVATE;
|
|
36
|
+
std::optional<std::string> path SWIFT_PRIVATE;
|
|
37
|
+
std::optional<std::string> encryptionKey SWIFT_PRIVATE;
|
|
38
|
+
std::optional<Mode> mode SWIFT_PRIVATE;
|
|
39
|
+
std::optional<bool> readOnly SWIFT_PRIVATE;
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
Configuration() = default;
|
|
43
|
+
explicit Configuration(std::string id, std::optional<std::string> path, std::optional<std::string> encryptionKey, std::optional<Mode> mode, std::optional<bool> readOnly): id(id), path(path), encryptionKey(encryptionKey), mode(mode), readOnly(readOnly) {}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace margelo::nitro::mmkv
|
|
47
|
+
|
|
48
|
+
namespace margelo::nitro {
|
|
49
|
+
|
|
50
|
+
// C++ Configuration <> JS Configuration (object)
|
|
51
|
+
template <>
|
|
52
|
+
struct JSIConverter<margelo::nitro::mmkv::Configuration> final {
|
|
53
|
+
static inline margelo::nitro::mmkv::Configuration fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
54
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
55
|
+
return margelo::nitro::mmkv::Configuration(
|
|
56
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "id")),
|
|
57
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "path")),
|
|
58
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "encryptionKey")),
|
|
59
|
+
JSIConverter<std::optional<margelo::nitro::mmkv::Mode>>::fromJSI(runtime, obj.getProperty(runtime, "mode")),
|
|
60
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "readOnly"))
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::mmkv::Configuration& arg) {
|
|
64
|
+
jsi::Object obj(runtime);
|
|
65
|
+
obj.setProperty(runtime, "id", JSIConverter<std::string>::toJSI(runtime, arg.id));
|
|
66
|
+
obj.setProperty(runtime, "path", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.path));
|
|
67
|
+
obj.setProperty(runtime, "encryptionKey", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.encryptionKey));
|
|
68
|
+
obj.setProperty(runtime, "mode", JSIConverter<std::optional<margelo::nitro::mmkv::Mode>>::toJSI(runtime, arg.mode));
|
|
69
|
+
obj.setProperty(runtime, "readOnly", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.readOnly));
|
|
70
|
+
return obj;
|
|
71
|
+
}
|
|
72
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
73
|
+
if (!value.isObject()) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
jsi::Object obj = value.getObject(runtime);
|
|
77
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "id"))) return false;
|
|
78
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "path"))) return false;
|
|
79
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "encryptionKey"))) return false;
|
|
80
|
+
if (!JSIConverter<std::optional<margelo::nitro::mmkv::Mode>>::canConvert(runtime, obj.getProperty(runtime, "mode"))) return false;
|
|
81
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "readOnly"))) return false;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMMKVFactorySpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridMMKVFactorySpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::mmkv {
|
|
11
|
+
|
|
12
|
+
void HybridMMKVFactorySpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("defaultMMKVInstanceId", &HybridMMKVFactorySpec::getDefaultMMKVInstanceId);
|
|
18
|
+
prototype.registerHybridMethod("createMMKV", &HybridMMKVFactorySpec::createMMKV);
|
|
19
|
+
prototype.registerHybridMethod("initializeMMKV", &HybridMMKVFactorySpec::initializeMMKV);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
} // namespace margelo::nitro::mmkv
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMMKVFactorySpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `HybridMMKVSpec` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::mmkv { class HybridMMKVSpec; }
|
|
18
|
+
// Forward declaration of `Configuration` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::mmkv { struct Configuration; }
|
|
20
|
+
|
|
21
|
+
#include <string>
|
|
22
|
+
#include <memory>
|
|
23
|
+
#include "HybridMMKVSpec.hpp"
|
|
24
|
+
#include "Configuration.hpp"
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::mmkv {
|
|
27
|
+
|
|
28
|
+
using namespace margelo::nitro;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* An abstract base class for `MMKVFactory`
|
|
32
|
+
* Inherit this class to create instances of `HybridMMKVFactorySpec` in C++.
|
|
33
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
34
|
+
* @example
|
|
35
|
+
* ```cpp
|
|
36
|
+
* class HybridMMKVFactory: public HybridMMKVFactorySpec {
|
|
37
|
+
* public:
|
|
38
|
+
* HybridMMKVFactory(...): HybridObject(TAG) { ... }
|
|
39
|
+
* // ...
|
|
40
|
+
* };
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
class HybridMMKVFactorySpec: public virtual HybridObject {
|
|
44
|
+
public:
|
|
45
|
+
// Constructor
|
|
46
|
+
explicit HybridMMKVFactorySpec(): HybridObject(TAG) { }
|
|
47
|
+
|
|
48
|
+
// Destructor
|
|
49
|
+
~HybridMMKVFactorySpec() override = default;
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
virtual std::string getDefaultMMKVInstanceId() = 0;
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
virtual std::shared_ptr<HybridMMKVSpec> createMMKV(const Configuration& configuration) = 0;
|
|
58
|
+
virtual void initializeMMKV(const std::string& rootPath) = 0;
|
|
59
|
+
|
|
60
|
+
protected:
|
|
61
|
+
// Hybrid Setup
|
|
62
|
+
void loadHybridMethods() override;
|
|
63
|
+
|
|
64
|
+
protected:
|
|
65
|
+
// Tag for logging
|
|
66
|
+
static constexpr auto TAG = "MMKVFactory";
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
} // namespace margelo::nitro::mmkv
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMMKVPlatformContextSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridMMKVPlatformContextSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::mmkv {
|
|
11
|
+
|
|
12
|
+
void HybridMMKVPlatformContextSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("getBaseDirectory", &HybridMMKVPlatformContextSpec::getBaseDirectory);
|
|
18
|
+
prototype.registerHybridMethod("getAppGroupDirectory", &HybridMMKVPlatformContextSpec::getAppGroupDirectory);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
} // namespace margelo::nitro::mmkv
|