react-native-mmkv 4.0.0-beta.0 → 4.0.0-beta.10
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 +44 -0
- package/README.md +1 -3
- package/android/CMakeLists.txt +31 -30
- package/android/build.gradle +65 -20
- 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/app.plugin.js +1 -0
- package/cpp/HybridMMKV.cpp +184 -0
- package/cpp/HybridMMKV.hpp +47 -0
- package/cpp/HybridMMKVFactory.cpp +33 -0
- package/cpp/HybridMMKVFactory.hpp +24 -0
- package/cpp/{MmkvTypes.h → MMKVTypes.hpp} +1 -1
- package/cpp/MMKVValueChangedListenerRegistry.cpp +58 -0
- package/cpp/MMKVValueChangedListenerRegistry.hpp +43 -0
- package/cpp/{ManagedMMBuffer.h → ManagedMMBuffer.hpp} +13 -5
- package/ios/HybridMMKVPlatformContext.swift +43 -0
- package/lib/__tests__/hooks.test.d.ts +1 -0
- package/lib/__tests__/hooks.test.js +69 -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 +74 -0
- package/lib/createMMKV/createMMKV.web.d.ts +3 -0
- package/lib/createMMKV/createMMKV.web.js +117 -0
- package/lib/createMMKV/createMockMMKV.d.ts +5 -0
- package/lib/createMMKV/createMockMMKV.js +74 -0
- package/lib/createMMKV/getDefaultMMKVInstance.d.ts +2 -0
- package/lib/createMMKV/getDefaultMMKVInstance.js +8 -0
- package/lib/expo-plugin/withMMKV.cjs +26 -0
- package/lib/expo-plugin/withMMKV.d.cts +3 -0
- package/lib/expo-plugin/withMMKV.d.ts +3 -0
- package/lib/expo-plugin/withMMKV.js +17 -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 +94 -0
- package/lib/specs/MMKV.nitro.js +1 -0
- package/lib/{typescript/src/NativeMmkv.d.ts → specs/MMKVFactory.nitro.d.ts} +26 -33
- package/lib/specs/MMKVFactory.nitro.js +1 -0
- package/lib/specs/MMKVPlatformContext.nitro.d.ts +18 -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 +28 -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 +54 -0
- package/nitrogen/generated/android/NitroMmkvOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JHybridMMKVPlatformContextSpec.cpp +52 -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 +77 -0
- package/nitrogen/generated/ios/NitroMmkv-Swift-Cxx-Umbrella.hpp +45 -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 +82 -0
- package/nitrogen/generated/ios/swift/HybridMMKVPlatformContextSpec.swift +50 -0
- package/nitrogen/generated/ios/swift/HybridMMKVPlatformContextSpec_cxx.swift +141 -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 +64 -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 +78 -125
- package/react-native.config.js +2 -15
- package/src/__tests__/hooks.test.tsx +39 -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.ts +51 -0
- package/src/{createMMKV.web.ts → createMMKV/createMMKV.web.ts} +58 -46
- package/src/createMMKV/createMockMMKV.ts +78 -0
- package/src/createMMKV/getDefaultMMKVInstance.ts +10 -0
- package/src/expo-plugin/withMMKV.cts +31 -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 +93 -0
- package/src/specs/MMKVFactory.nitro.ts +87 -0
- package/src/specs/MMKVPlatformContext.nitro.ts +17 -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/MmkvHostObject.cpp +0 -360
- package/cpp/MmkvHostObject.h +0 -31
- package/cpp/MmkvLogger.h +0 -35
- 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/react-native-mmkv.podspec +0 -32
- 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,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,82 @@
|
|
|
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
|
+
#include <optional>
|
|
19
|
+
|
|
20
|
+
#include "NitroMmkv-Swift-Cxx-Umbrella.hpp"
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::mmkv {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The C++ part of HybridMMKVPlatformContextSpec_cxx.swift.
|
|
26
|
+
*
|
|
27
|
+
* HybridMMKVPlatformContextSpecSwift (C++) accesses HybridMMKVPlatformContextSpec_cxx (Swift), and might
|
|
28
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
29
|
+
*
|
|
30
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
31
|
+
* the future, HybridMMKVPlatformContextSpec_cxx can directly inherit from the C++ class HybridMMKVPlatformContextSpec
|
|
32
|
+
* to simplify the whole structure and memory management.
|
|
33
|
+
*/
|
|
34
|
+
class HybridMMKVPlatformContextSpecSwift: public virtual HybridMMKVPlatformContextSpec {
|
|
35
|
+
public:
|
|
36
|
+
// Constructor from a Swift instance
|
|
37
|
+
explicit HybridMMKVPlatformContextSpecSwift(const NitroMmkv::HybridMMKVPlatformContextSpec_cxx& swiftPart):
|
|
38
|
+
HybridObject(HybridMMKVPlatformContextSpec::TAG),
|
|
39
|
+
_swiftPart(swiftPart) { }
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
// Get the Swift part
|
|
43
|
+
inline NitroMmkv::HybridMMKVPlatformContextSpec_cxx& getSwiftPart() noexcept {
|
|
44
|
+
return _swiftPart;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
49
|
+
return _swiftPart.getMemorySize();
|
|
50
|
+
}
|
|
51
|
+
void dispose() noexcept override {
|
|
52
|
+
_swiftPart.dispose();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Properties
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
// Methods
|
|
61
|
+
inline std::string getBaseDirectory() override {
|
|
62
|
+
auto __result = _swiftPart.getBaseDirectory();
|
|
63
|
+
if (__result.hasError()) [[unlikely]] {
|
|
64
|
+
std::rethrow_exception(__result.error());
|
|
65
|
+
}
|
|
66
|
+
auto __value = std::move(__result.value());
|
|
67
|
+
return __value;
|
|
68
|
+
}
|
|
69
|
+
inline std::optional<std::string> getAppGroupDirectory() override {
|
|
70
|
+
auto __result = _swiftPart.getAppGroupDirectory();
|
|
71
|
+
if (__result.hasError()) [[unlikely]] {
|
|
72
|
+
std::rethrow_exception(__result.error());
|
|
73
|
+
}
|
|
74
|
+
auto __value = std::move(__result.value());
|
|
75
|
+
return __value;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private:
|
|
79
|
+
NitroMmkv::HybridMMKVPlatformContextSpec_cxx _swiftPart;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
} // 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,141 @@
|
|
|
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__optional_std__string__ {
|
|
126
|
+
do {
|
|
127
|
+
let __result = try self.__implementation.getAppGroupDirectory()
|
|
128
|
+
let __resultCpp = { () -> bridge.std__optional_std__string_ in
|
|
129
|
+
if let __unwrappedValue = __result {
|
|
130
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
131
|
+
} else {
|
|
132
|
+
return .init()
|
|
133
|
+
}
|
|
134
|
+
}()
|
|
135
|
+
return bridge.create_Result_std__optional_std__string__(__resultCpp)
|
|
136
|
+
} catch (let __error) {
|
|
137
|
+
let __exceptionPtr = __error.toCpp()
|
|
138
|
+
return bridge.create_Result_std__optional_std__string__(__exceptionPtr)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -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
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMMKVPlatformContextSpec.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
|
+
|
|
17
|
+
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <optional>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::mmkv {
|
|
22
|
+
|
|
23
|
+
using namespace margelo::nitro;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An abstract base class for `MMKVPlatformContext`
|
|
27
|
+
* Inherit this class to create instances of `HybridMMKVPlatformContextSpec` in C++.
|
|
28
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
29
|
+
* @example
|
|
30
|
+
* ```cpp
|
|
31
|
+
* class HybridMMKVPlatformContext: public HybridMMKVPlatformContextSpec {
|
|
32
|
+
* public:
|
|
33
|
+
* HybridMMKVPlatformContext(...): HybridObject(TAG) { ... }
|
|
34
|
+
* // ...
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
class HybridMMKVPlatformContextSpec: public virtual HybridObject {
|
|
39
|
+
public:
|
|
40
|
+
// Constructor
|
|
41
|
+
explicit HybridMMKVPlatformContextSpec(): HybridObject(TAG) { }
|
|
42
|
+
|
|
43
|
+
// Destructor
|
|
44
|
+
~HybridMMKVPlatformContextSpec() override = default;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
// Properties
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
// Methods
|
|
52
|
+
virtual std::string getBaseDirectory() = 0;
|
|
53
|
+
virtual std::optional<std::string> getAppGroupDirectory() = 0;
|
|
54
|
+
|
|
55
|
+
protected:
|
|
56
|
+
// Hybrid Setup
|
|
57
|
+
void loadHybridMethods() override;
|
|
58
|
+
|
|
59
|
+
protected:
|
|
60
|
+
// Tag for logging
|
|
61
|
+
static constexpr auto TAG = "MMKVPlatformContext";
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro::mmkv
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMMKVSpec.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 "HybridMMKVSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::mmkv {
|
|
11
|
+
|
|
12
|
+
void HybridMMKVSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("size", &HybridMMKVSpec::getSize);
|
|
18
|
+
prototype.registerHybridGetter("isReadOnly", &HybridMMKVSpec::getIsReadOnly);
|
|
19
|
+
prototype.registerHybridMethod("set", &HybridMMKVSpec::set);
|
|
20
|
+
prototype.registerHybridMethod("getBoolean", &HybridMMKVSpec::getBoolean);
|
|
21
|
+
prototype.registerHybridMethod("getString", &HybridMMKVSpec::getString);
|
|
22
|
+
prototype.registerHybridMethod("getNumber", &HybridMMKVSpec::getNumber);
|
|
23
|
+
prototype.registerHybridMethod("getBuffer", &HybridMMKVSpec::getBuffer);
|
|
24
|
+
prototype.registerHybridMethod("contains", &HybridMMKVSpec::contains);
|
|
25
|
+
prototype.registerHybridMethod("remove", &HybridMMKVSpec::remove);
|
|
26
|
+
prototype.registerHybridMethod("getAllKeys", &HybridMMKVSpec::getAllKeys);
|
|
27
|
+
prototype.registerHybridMethod("clearAll", &HybridMMKVSpec::clearAll);
|
|
28
|
+
prototype.registerHybridMethod("recrypt", &HybridMMKVSpec::recrypt);
|
|
29
|
+
prototype.registerHybridMethod("trim", &HybridMMKVSpec::trim);
|
|
30
|
+
prototype.registerHybridMethod("addOnValueChangedListener", &HybridMMKVSpec::addOnValueChangedListener);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
} // namespace margelo::nitro::mmkv
|