react-native-nitro-version-check 0.0.1
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/NitroVersionCheck.podspec +31 -0
- package/README.md +117 -0
- package/android/CMakeLists.txt +29 -0
- package/android/build.gradle +142 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/android/src/main/java/com/margelo/nitro/nitroversioncheck/HybridVersionCheck.kt +74 -0
- package/android/src/main/java/com/margelo/nitro/nitroversioncheck/NitroVersionCheckPackage.kt +18 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridVersionCheck.swift +71 -0
- package/lib/index.d.ts +168 -0
- package/lib/index.js +174 -0
- package/lib/semver.d.ts +22 -0
- package/lib/semver.js +51 -0
- package/lib/specs/Version.nitro.d.ts +14 -0
- package/lib/specs/Version.nitro.js +1 -0
- package/lib/types/UpdateResult.d.ts +6 -0
- package/lib/types/UpdateResult.js +1 -0
- package/nitro.json +18 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroVersionCheck+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroVersionCheck+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroVersionCheckOnLoad.cpp +47 -0
- package/nitrogen/generated/android/NitroVersionCheckOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JHybridVersionCheckSpec.cpp +129 -0
- package/nitrogen/generated/android/c++/JHybridVersionCheckSpec.hpp +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroversioncheck/HybridVersionCheckSpec.kt +84 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroversioncheck/NitroVersionCheckOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroVersionCheck+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroVersionCheck-Swift-Cxx-Bridge.cpp +57 -0
- package/nitrogen/generated/ios/NitroVersionCheck-Swift-Cxx-Bridge.hpp +179 -0
- package/nitrogen/generated/ios/NitroVersionCheck-Swift-Cxx-Umbrella.hpp +46 -0
- package/nitrogen/generated/ios/NitroVersionCheckAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroVersionCheckAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridVersionCheckSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridVersionCheckSpecSwift.hpp +123 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridVersionCheckSpec.swift +61 -0
- package/nitrogen/generated/ios/swift/HybridVersionCheckSpec_cxx.swift +227 -0
- package/nitrogen/generated/shared/c++/HybridVersionCheckSpec.cpp +28 -0
- package/nitrogen/generated/shared/c++/HybridVersionCheckSpec.hpp +70 -0
- package/package.json +116 -0
- package/react-native.config.js +16 -0
- package/src/index.ts +185 -0
- package/src/semver.ts +54 -0
- package/src/specs/Version.nitro.ts +16 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVersionCheckAutolinking.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
#import "NitroVersionCheck-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridVersionCheckSpecSwift.hpp"
|
|
14
|
+
|
|
15
|
+
@interface NitroVersionCheckAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation NitroVersionCheckAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::nitroversioncheck;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"VersionCheck",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
std::shared_ptr<HybridVersionCheckSpec> hybridObject = NitroVersionCheck::NitroVersionCheckAutolinking::createVersionCheck();
|
|
28
|
+
return hybridObject;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVersionCheckAutolinking.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
// TODO: Use empty enums once Swift supports exporting them as namespaces
|
|
11
|
+
// See: https://github.com/swiftlang/swift/pull/83616
|
|
12
|
+
public final class NitroVersionCheckAutolinking {
|
|
13
|
+
public typealias bridge = margelo.nitro.nitroversioncheck.bridge.swift
|
|
14
|
+
|
|
15
|
+
public static func createVersionCheck() -> bridge.std__shared_ptr_HybridVersionCheckSpec_ {
|
|
16
|
+
let hybridObject = HybridVersionCheck()
|
|
17
|
+
return { () -> bridge.std__shared_ptr_HybridVersionCheckSpec_ in
|
|
18
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
19
|
+
return __cxxWrapped.getCxxPart()
|
|
20
|
+
}()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static func isVersionCheckRecyclable() -> Bool {
|
|
24
|
+
return HybridVersionCheck.self is any RecyclableView.Type
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridVersionCheckSpecSwift.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridVersionCheckSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitroversioncheck {
|
|
11
|
+
} // namespace margelo::nitro::nitroversioncheck
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridVersionCheckSpecSwift.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridVersionCheckSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridVersionCheckSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroVersionCheck { class HybridVersionCheckSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <optional>
|
|
19
|
+
#include <NitroModules/Promise.hpp>
|
|
20
|
+
|
|
21
|
+
#include "NitroVersionCheck-Swift-Cxx-Umbrella.hpp"
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::nitroversioncheck {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The C++ part of HybridVersionCheckSpec_cxx.swift.
|
|
27
|
+
*
|
|
28
|
+
* HybridVersionCheckSpecSwift (C++) accesses HybridVersionCheckSpec_cxx (Swift), and might
|
|
29
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
30
|
+
*
|
|
31
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
32
|
+
* the future, HybridVersionCheckSpec_cxx can directly inherit from the C++ class HybridVersionCheckSpec
|
|
33
|
+
* to simplify the whole structure and memory management.
|
|
34
|
+
*/
|
|
35
|
+
class HybridVersionCheckSpecSwift: public virtual HybridVersionCheckSpec {
|
|
36
|
+
public:
|
|
37
|
+
// Constructor from a Swift instance
|
|
38
|
+
explicit HybridVersionCheckSpecSwift(const NitroVersionCheck::HybridVersionCheckSpec_cxx& swiftPart):
|
|
39
|
+
HybridObject(HybridVersionCheckSpec::TAG),
|
|
40
|
+
_swiftPart(swiftPart) { }
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
// Get the Swift part
|
|
44
|
+
inline NitroVersionCheck::HybridVersionCheckSpec_cxx& getSwiftPart() noexcept {
|
|
45
|
+
return _swiftPart;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
50
|
+
return _swiftPart.getMemorySize();
|
|
51
|
+
}
|
|
52
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
53
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridVersionCheckSpecSwift>(other)) {
|
|
54
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
void dispose() noexcept override {
|
|
59
|
+
_swiftPart.dispose();
|
|
60
|
+
}
|
|
61
|
+
std::string toString() override {
|
|
62
|
+
return _swiftPart.toString();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
// Properties
|
|
67
|
+
inline std::string getVersion() noexcept override {
|
|
68
|
+
auto __result = _swiftPart.getVersion();
|
|
69
|
+
return __result;
|
|
70
|
+
}
|
|
71
|
+
inline std::string getBuildNumber() noexcept override {
|
|
72
|
+
auto __result = _swiftPart.getBuildNumber();
|
|
73
|
+
return __result;
|
|
74
|
+
}
|
|
75
|
+
inline std::string getPackageName() noexcept override {
|
|
76
|
+
auto __result = _swiftPart.getPackageName();
|
|
77
|
+
return __result;
|
|
78
|
+
}
|
|
79
|
+
inline std::optional<std::string> getInstallSource() noexcept override {
|
|
80
|
+
auto __result = _swiftPart.getInstallSource();
|
|
81
|
+
return __result;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public:
|
|
85
|
+
// Methods
|
|
86
|
+
inline std::string getCountry() override {
|
|
87
|
+
auto __result = _swiftPart.getCountry();
|
|
88
|
+
if (__result.hasError()) [[unlikely]] {
|
|
89
|
+
std::rethrow_exception(__result.error());
|
|
90
|
+
}
|
|
91
|
+
auto __value = std::move(__result.value());
|
|
92
|
+
return __value;
|
|
93
|
+
}
|
|
94
|
+
inline std::shared_ptr<Promise<std::string>> getStoreUrl() override {
|
|
95
|
+
auto __result = _swiftPart.getStoreUrl();
|
|
96
|
+
if (__result.hasError()) [[unlikely]] {
|
|
97
|
+
std::rethrow_exception(__result.error());
|
|
98
|
+
}
|
|
99
|
+
auto __value = std::move(__result.value());
|
|
100
|
+
return __value;
|
|
101
|
+
}
|
|
102
|
+
inline std::shared_ptr<Promise<std::string>> getLatestVersion() override {
|
|
103
|
+
auto __result = _swiftPart.getLatestVersion();
|
|
104
|
+
if (__result.hasError()) [[unlikely]] {
|
|
105
|
+
std::rethrow_exception(__result.error());
|
|
106
|
+
}
|
|
107
|
+
auto __value = std::move(__result.value());
|
|
108
|
+
return __value;
|
|
109
|
+
}
|
|
110
|
+
inline std::shared_ptr<Promise<bool>> needsUpdate() override {
|
|
111
|
+
auto __result = _swiftPart.needsUpdate();
|
|
112
|
+
if (__result.hasError()) [[unlikely]] {
|
|
113
|
+
std::rethrow_exception(__result.error());
|
|
114
|
+
}
|
|
115
|
+
auto __value = std::move(__result.value());
|
|
116
|
+
return __value;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private:
|
|
120
|
+
NitroVersionCheck::HybridVersionCheckSpec_cxx _swiftPart;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
} // namespace margelo::nitro::nitroversioncheck
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_bool.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ value: Bool) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_bool {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitroversioncheck.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: Bool) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: Bool) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: Bool) -> Void {
|
|
25
|
+
self.closure(value)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_bool`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_bool>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool {
|
|
44
|
+
return Unmanaged<Func_void_bool>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__exception_ptr.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ error: Error) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__exception_ptr {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitroversioncheck.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ error: Error) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ error: Error) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(error: std.exception_ptr) -> Void {
|
|
25
|
+
self.closure(RuntimeError.from(cppError: error))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
|
|
44
|
+
return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__string.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ value: String) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__string {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitroversioncheck.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: String) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: String) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: std.string) -> Void {
|
|
25
|
+
self.closure(String(value))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__string`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
|
|
44
|
+
return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridVersionCheckSpec.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/// See ``HybridVersionCheckSpec``
|
|
11
|
+
public protocol HybridVersionCheckSpec_protocol: HybridObject {
|
|
12
|
+
// Properties
|
|
13
|
+
var version: String { get }
|
|
14
|
+
var buildNumber: String { get }
|
|
15
|
+
var packageName: String { get }
|
|
16
|
+
var installSource: String? { get }
|
|
17
|
+
|
|
18
|
+
// Methods
|
|
19
|
+
func getCountry() throws -> String
|
|
20
|
+
func getStoreUrl() throws -> Promise<String>
|
|
21
|
+
func getLatestVersion() throws -> Promise<String>
|
|
22
|
+
func needsUpdate() throws -> Promise<Bool>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public extension HybridVersionCheckSpec_protocol {
|
|
26
|
+
/// Default implementation of ``HybridObject.toString``
|
|
27
|
+
func toString() -> String {
|
|
28
|
+
return "[HybridObject VersionCheck]"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/// See ``HybridVersionCheckSpec``
|
|
33
|
+
open class HybridVersionCheckSpec_base {
|
|
34
|
+
private weak var cxxWrapper: HybridVersionCheckSpec_cxx? = nil
|
|
35
|
+
public init() { }
|
|
36
|
+
public func getCxxWrapper() -> HybridVersionCheckSpec_cxx {
|
|
37
|
+
#if DEBUG
|
|
38
|
+
guard self is any HybridVersionCheckSpec else {
|
|
39
|
+
fatalError("`self` is not a `HybridVersionCheckSpec`! Did you accidentally inherit from `HybridVersionCheckSpec_base` instead of `HybridVersionCheckSpec`?")
|
|
40
|
+
}
|
|
41
|
+
#endif
|
|
42
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
43
|
+
return cxxWrapper
|
|
44
|
+
} else {
|
|
45
|
+
let cxxWrapper = HybridVersionCheckSpec_cxx(self as! any HybridVersionCheckSpec)
|
|
46
|
+
self.cxxWrapper = cxxWrapper
|
|
47
|
+
return cxxWrapper
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A Swift base-protocol representing the VersionCheck HybridObject.
|
|
54
|
+
* Implement this protocol to create Swift-based instances of VersionCheck.
|
|
55
|
+
* ```swift
|
|
56
|
+
* class HybridVersionCheck : HybridVersionCheckSpec {
|
|
57
|
+
* // ...
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
public typealias HybridVersionCheckSpec = HybridVersionCheckSpec_protocol & HybridVersionCheckSpec_base
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridVersionCheckSpec_cxx.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A class implementation that bridges HybridVersionCheckSpec over to C++.
|
|
12
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
13
|
+
*
|
|
14
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
15
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
16
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
17
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
18
|
+
*/
|
|
19
|
+
open class HybridVersionCheckSpec_cxx {
|
|
20
|
+
/**
|
|
21
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::nitroversioncheck::bridge::swift`)
|
|
22
|
+
* from `NitroVersionCheck-Swift-Cxx-Bridge.hpp`.
|
|
23
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
24
|
+
*/
|
|
25
|
+
public typealias bridge = margelo.nitro.nitroversioncheck.bridge.swift
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Holds an instance of the `HybridVersionCheckSpec` Swift protocol.
|
|
29
|
+
*/
|
|
30
|
+
private var __implementation: any HybridVersionCheckSpec
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
34
|
+
*/
|
|
35
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridVersionCheckSpec_
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new `HybridVersionCheckSpec_cxx` that wraps the given `HybridVersionCheckSpec`.
|
|
39
|
+
* All properties and methods bridge to C++ types.
|
|
40
|
+
*/
|
|
41
|
+
public init(_ implementation: any HybridVersionCheckSpec) {
|
|
42
|
+
self.__implementation = implementation
|
|
43
|
+
self.__cxxPart = .init()
|
|
44
|
+
/* no base class */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the actual `HybridVersionCheckSpec` instance this class wraps.
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public func getHybridVersionCheckSpec() -> any HybridVersionCheckSpec {
|
|
52
|
+
return __implementation
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
57
|
+
* This acquires one additional strong reference on the object!
|
|
58
|
+
*/
|
|
59
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
60
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Casts an unsafe pointer to a `HybridVersionCheckSpec_cxx`.
|
|
65
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridVersionCheckSpec_cxx>`.
|
|
66
|
+
* This removes one strong reference from the object!
|
|
67
|
+
*/
|
|
68
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridVersionCheckSpec_cxx {
|
|
69
|
+
return Unmanaged<HybridVersionCheckSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
74
|
+
* The C++ part is a `std::shared_ptr<HybridVersionCheckSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridVersionCheckSpec_ {
|
|
77
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
+
return cachedCxxPart
|
|
80
|
+
} else {
|
|
81
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridVersionCheckSpec_(self.toUnsafe())
|
|
82
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridVersionCheckSpec_(newCxxPart)
|
|
83
|
+
return newCxxPart
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
91
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
92
|
+
*/
|
|
93
|
+
@inline(__always)
|
|
94
|
+
public var memorySize: Int {
|
|
95
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Compares this object with the given [other] object for reference equality.
|
|
100
|
+
*/
|
|
101
|
+
@inline(__always)
|
|
102
|
+
public func equals(other: HybridVersionCheckSpec_cxx) -> Bool {
|
|
103
|
+
return self.__implementation === other.__implementation
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Call dispose() on the Swift class.
|
|
108
|
+
* This _may_ be called manually from JS.
|
|
109
|
+
*/
|
|
110
|
+
@inline(__always)
|
|
111
|
+
public func dispose() {
|
|
112
|
+
self.__implementation.dispose()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Call toString() on the Swift class.
|
|
117
|
+
*/
|
|
118
|
+
@inline(__always)
|
|
119
|
+
public func toString() -> String {
|
|
120
|
+
return self.__implementation.toString()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Properties
|
|
124
|
+
public final var version: std.string {
|
|
125
|
+
@inline(__always)
|
|
126
|
+
get {
|
|
127
|
+
return std.string(self.__implementation.version)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public final var buildNumber: std.string {
|
|
132
|
+
@inline(__always)
|
|
133
|
+
get {
|
|
134
|
+
return std.string(self.__implementation.buildNumber)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public final var packageName: std.string {
|
|
139
|
+
@inline(__always)
|
|
140
|
+
get {
|
|
141
|
+
return std.string(self.__implementation.packageName)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public final var installSource: bridge.std__optional_std__string_ {
|
|
146
|
+
@inline(__always)
|
|
147
|
+
get {
|
|
148
|
+
return { () -> bridge.std__optional_std__string_ in
|
|
149
|
+
if let __unwrappedValue = self.__implementation.installSource {
|
|
150
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
151
|
+
} else {
|
|
152
|
+
return .init()
|
|
153
|
+
}
|
|
154
|
+
}()
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Methods
|
|
159
|
+
@inline(__always)
|
|
160
|
+
public final func getCountry() -> bridge.Result_std__string_ {
|
|
161
|
+
do {
|
|
162
|
+
let __result = try self.__implementation.getCountry()
|
|
163
|
+
let __resultCpp = std.string(__result)
|
|
164
|
+
return bridge.create_Result_std__string_(__resultCpp)
|
|
165
|
+
} catch (let __error) {
|
|
166
|
+
let __exceptionPtr = __error.toCpp()
|
|
167
|
+
return bridge.create_Result_std__string_(__exceptionPtr)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@inline(__always)
|
|
172
|
+
public final func getStoreUrl() -> bridge.Result_std__shared_ptr_Promise_std__string___ {
|
|
173
|
+
do {
|
|
174
|
+
let __result = try self.__implementation.getStoreUrl()
|
|
175
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
|
|
176
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
|
|
177
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
|
|
178
|
+
__result
|
|
179
|
+
.then({ __result in __promiseHolder.resolve(std.string(__result)) })
|
|
180
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
181
|
+
return __promise
|
|
182
|
+
}()
|
|
183
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
|
|
184
|
+
} catch (let __error) {
|
|
185
|
+
let __exceptionPtr = __error.toCpp()
|
|
186
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@inline(__always)
|
|
191
|
+
public final func getLatestVersion() -> bridge.Result_std__shared_ptr_Promise_std__string___ {
|
|
192
|
+
do {
|
|
193
|
+
let __result = try self.__implementation.getLatestVersion()
|
|
194
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
|
|
195
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
|
|
196
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
|
|
197
|
+
__result
|
|
198
|
+
.then({ __result in __promiseHolder.resolve(std.string(__result)) })
|
|
199
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
200
|
+
return __promise
|
|
201
|
+
}()
|
|
202
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
|
|
203
|
+
} catch (let __error) {
|
|
204
|
+
let __exceptionPtr = __error.toCpp()
|
|
205
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@inline(__always)
|
|
210
|
+
public final func needsUpdate() -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
211
|
+
do {
|
|
212
|
+
let __result = try self.__implementation.needsUpdate()
|
|
213
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
214
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
215
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
216
|
+
__result
|
|
217
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
218
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
219
|
+
return __promise
|
|
220
|
+
}()
|
|
221
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
222
|
+
} catch (let __error) {
|
|
223
|
+
let __exceptionPtr = __error.toCpp()
|
|
224
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridVersionCheckSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridVersionCheckSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitroversioncheck {
|
|
11
|
+
|
|
12
|
+
void HybridVersionCheckSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("version", &HybridVersionCheckSpec::getVersion);
|
|
18
|
+
prototype.registerHybridGetter("buildNumber", &HybridVersionCheckSpec::getBuildNumber);
|
|
19
|
+
prototype.registerHybridGetter("packageName", &HybridVersionCheckSpec::getPackageName);
|
|
20
|
+
prototype.registerHybridGetter("installSource", &HybridVersionCheckSpec::getInstallSource);
|
|
21
|
+
prototype.registerHybridMethod("getCountry", &HybridVersionCheckSpec::getCountry);
|
|
22
|
+
prototype.registerHybridMethod("getStoreUrl", &HybridVersionCheckSpec::getStoreUrl);
|
|
23
|
+
prototype.registerHybridMethod("getLatestVersion", &HybridVersionCheckSpec::getLatestVersion);
|
|
24
|
+
prototype.registerHybridMethod("needsUpdate", &HybridVersionCheckSpec::needsUpdate);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
} // namespace margelo::nitro::nitroversioncheck
|