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,129 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridVersionCheckSpec.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 "JHybridVersionCheckSpec.hpp"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <NitroModules/Promise.hpp>
|
|
15
|
+
#include <NitroModules/JPromise.hpp>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nitroversioncheck {
|
|
18
|
+
|
|
19
|
+
jni::local_ref<JHybridVersionCheckSpec::jhybriddata> JHybridVersionCheckSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
20
|
+
return makeCxxInstance(jThis);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void JHybridVersionCheckSpec::registerNatives() {
|
|
24
|
+
registerHybrid({
|
|
25
|
+
makeNativeMethod("initHybrid", JHybridVersionCheckSpec::initHybrid),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
size_t JHybridVersionCheckSpec::getExternalMemorySize() noexcept {
|
|
30
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
31
|
+
return method(_javaPart);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
bool JHybridVersionCheckSpec::equals(const std::shared_ptr<HybridObject>& other) {
|
|
35
|
+
if (auto otherCast = std::dynamic_pointer_cast<JHybridVersionCheckSpec>(other)) {
|
|
36
|
+
return _javaPart == otherCast->_javaPart;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
void JHybridVersionCheckSpec::dispose() noexcept {
|
|
42
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
43
|
+
method(_javaPart);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
std::string JHybridVersionCheckSpec::toString() {
|
|
47
|
+
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
48
|
+
auto javaString = method(_javaPart);
|
|
49
|
+
return javaString->toStdString();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Properties
|
|
53
|
+
std::string JHybridVersionCheckSpec::getVersion() {
|
|
54
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getVersion");
|
|
55
|
+
auto __result = method(_javaPart);
|
|
56
|
+
return __result->toStdString();
|
|
57
|
+
}
|
|
58
|
+
std::string JHybridVersionCheckSpec::getBuildNumber() {
|
|
59
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getBuildNumber");
|
|
60
|
+
auto __result = method(_javaPart);
|
|
61
|
+
return __result->toStdString();
|
|
62
|
+
}
|
|
63
|
+
std::string JHybridVersionCheckSpec::getPackageName() {
|
|
64
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getPackageName");
|
|
65
|
+
auto __result = method(_javaPart);
|
|
66
|
+
return __result->toStdString();
|
|
67
|
+
}
|
|
68
|
+
std::optional<std::string> JHybridVersionCheckSpec::getInstallSource() {
|
|
69
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getInstallSource");
|
|
70
|
+
auto __result = method(_javaPart);
|
|
71
|
+
return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Methods
|
|
75
|
+
std::string JHybridVersionCheckSpec::getCountry() {
|
|
76
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getCountry");
|
|
77
|
+
auto __result = method(_javaPart);
|
|
78
|
+
return __result->toStdString();
|
|
79
|
+
}
|
|
80
|
+
std::shared_ptr<Promise<std::string>> JHybridVersionCheckSpec::getStoreUrl() {
|
|
81
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getStoreUrl");
|
|
82
|
+
auto __result = method(_javaPart);
|
|
83
|
+
return [&]() {
|
|
84
|
+
auto __promise = Promise<std::string>::create();
|
|
85
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
86
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
87
|
+
__promise->resolve(__result->toStdString());
|
|
88
|
+
});
|
|
89
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
90
|
+
jni::JniException __jniError(__throwable);
|
|
91
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
92
|
+
});
|
|
93
|
+
return __promise;
|
|
94
|
+
}();
|
|
95
|
+
}
|
|
96
|
+
std::shared_ptr<Promise<std::string>> JHybridVersionCheckSpec::getLatestVersion() {
|
|
97
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getLatestVersion");
|
|
98
|
+
auto __result = method(_javaPart);
|
|
99
|
+
return [&]() {
|
|
100
|
+
auto __promise = Promise<std::string>::create();
|
|
101
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
102
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
103
|
+
__promise->resolve(__result->toStdString());
|
|
104
|
+
});
|
|
105
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
106
|
+
jni::JniException __jniError(__throwable);
|
|
107
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
108
|
+
});
|
|
109
|
+
return __promise;
|
|
110
|
+
}();
|
|
111
|
+
}
|
|
112
|
+
std::shared_ptr<Promise<bool>> JHybridVersionCheckSpec::needsUpdate() {
|
|
113
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("needsUpdate");
|
|
114
|
+
auto __result = method(_javaPart);
|
|
115
|
+
return [&]() {
|
|
116
|
+
auto __promise = Promise<bool>::create();
|
|
117
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
118
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
119
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
120
|
+
});
|
|
121
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
122
|
+
jni::JniException __jniError(__throwable);
|
|
123
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
124
|
+
});
|
|
125
|
+
return __promise;
|
|
126
|
+
}();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
} // namespace margelo::nitro::nitroversioncheck
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridVersionCheckSpec.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 <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridVersionCheckSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nitroversioncheck {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridVersionCheckSpec: public jni::HybridClass<JHybridVersionCheckSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridVersionCheckSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitroversioncheck/HybridVersionCheckSpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridVersionCheckSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridVersionCheckSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridVersionCheckSpec() override {
|
|
37
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override;
|
|
44
|
+
void dispose() noexcept override;
|
|
45
|
+
std::string toString() override;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
inline const jni::global_ref<JHybridVersionCheckSpec::javaobject>& getJavaPart() const noexcept {
|
|
49
|
+
return _javaPart;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Properties
|
|
54
|
+
std::string getVersion() override;
|
|
55
|
+
std::string getBuildNumber() override;
|
|
56
|
+
std::string getPackageName() override;
|
|
57
|
+
std::optional<std::string> getInstallSource() override;
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
// Methods
|
|
61
|
+
std::string getCountry() override;
|
|
62
|
+
std::shared_ptr<Promise<std::string>> getStoreUrl() override;
|
|
63
|
+
std::shared_ptr<Promise<std::string>> getLatestVersion() override;
|
|
64
|
+
std::shared_ptr<Promise<bool>> needsUpdate() override;
|
|
65
|
+
|
|
66
|
+
private:
|
|
67
|
+
friend HybridBase;
|
|
68
|
+
using HybridBase::HybridBase;
|
|
69
|
+
jni::global_ref<JHybridVersionCheckSpec::javaobject> _javaPart;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
} // namespace margelo::nitro::nitroversioncheck
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridVersionCheckSpec.kt
|
|
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
|
+
package com.margelo.nitro.nitroversioncheck
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.Promise
|
|
14
|
+
import com.margelo.nitro.core.HybridObject
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A Kotlin class representing the VersionCheck HybridObject.
|
|
18
|
+
* Implement this abstract class to create Kotlin-based instances of VersionCheck.
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress(
|
|
23
|
+
"KotlinJniMissingFunction", "unused",
|
|
24
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
25
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
26
|
+
)
|
|
27
|
+
abstract class HybridVersionCheckSpec: HybridObject() {
|
|
28
|
+
@DoNotStrip
|
|
29
|
+
private var mHybridData: HybridData = initHybrid()
|
|
30
|
+
|
|
31
|
+
init {
|
|
32
|
+
super.updateNative(mHybridData)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override fun updateNative(hybridData: HybridData) {
|
|
36
|
+
mHybridData = hybridData
|
|
37
|
+
super.updateNative(hybridData)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Default implementation of `HybridObject.toString()`
|
|
41
|
+
override fun toString(): String {
|
|
42
|
+
return "[HybridObject VersionCheck]"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Properties
|
|
46
|
+
@get:DoNotStrip
|
|
47
|
+
@get:Keep
|
|
48
|
+
abstract val version: String
|
|
49
|
+
|
|
50
|
+
@get:DoNotStrip
|
|
51
|
+
@get:Keep
|
|
52
|
+
abstract val buildNumber: String
|
|
53
|
+
|
|
54
|
+
@get:DoNotStrip
|
|
55
|
+
@get:Keep
|
|
56
|
+
abstract val packageName: String
|
|
57
|
+
|
|
58
|
+
@get:DoNotStrip
|
|
59
|
+
@get:Keep
|
|
60
|
+
abstract val installSource: String?
|
|
61
|
+
|
|
62
|
+
// Methods
|
|
63
|
+
@DoNotStrip
|
|
64
|
+
@Keep
|
|
65
|
+
abstract fun getCountry(): String
|
|
66
|
+
|
|
67
|
+
@DoNotStrip
|
|
68
|
+
@Keep
|
|
69
|
+
abstract fun getStoreUrl(): Promise<String>
|
|
70
|
+
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
abstract fun getLatestVersion(): Promise<String>
|
|
74
|
+
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
abstract fun needsUpdate(): Promise<Boolean>
|
|
78
|
+
|
|
79
|
+
private external fun initHybrid(): HybridData
|
|
80
|
+
|
|
81
|
+
companion object {
|
|
82
|
+
protected const val TAG = "HybridVersionCheckSpec"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVersionCheckOnLoad.kt
|
|
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
|
+
package com.margelo.nitro.nitroversioncheck
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class NitroVersionCheckOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "NitroVersionCheckOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "NitroVersionCheck".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading NitroVersionCheck C++ library...")
|
|
25
|
+
System.loadLibrary("NitroVersionCheck")
|
|
26
|
+
Log.i(TAG, "Successfully loaded NitroVersionCheck C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load NitroVersionCheck C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NitroVersionCheck+autolinking.rb
|
|
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
|
+
# This is a Ruby script that adds all files generated by Nitrogen
|
|
9
|
+
# to the given podspec.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your .podspec:
|
|
12
|
+
# ```ruby
|
|
13
|
+
# Pod::Spec.new do |spec|
|
|
14
|
+
# # ...
|
|
15
|
+
#
|
|
16
|
+
# # Add all files generated by Nitrogen
|
|
17
|
+
# load 'nitrogen/generated/ios/NitroVersionCheck+autolinking.rb'
|
|
18
|
+
# add_nitrogen_files(spec)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
|
|
22
|
+
def add_nitrogen_files(spec)
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 NitroVersionCheck is boosted by nitro!"
|
|
24
|
+
|
|
25
|
+
spec.dependency "NitroModules"
|
|
26
|
+
|
|
27
|
+
current_source_files = Array(spec.attributes_hash['source_files'])
|
|
28
|
+
spec.source_files = current_source_files + [
|
|
29
|
+
# Generated cross-platform specs
|
|
30
|
+
"nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
|
|
31
|
+
# Generated bridges for the cross-platform specs
|
|
32
|
+
"nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
current_public_header_files = Array(spec.attributes_hash['public_header_files'])
|
|
36
|
+
spec.public_header_files = current_public_header_files + [
|
|
37
|
+
# Generated specs
|
|
38
|
+
"nitrogen/generated/shared/**/*.{h,hpp}",
|
|
39
|
+
# Swift to C++ bridging helpers
|
|
40
|
+
"nitrogen/generated/ios/NitroVersionCheck-Swift-Cxx-Bridge.hpp"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
current_private_header_files = Array(spec.attributes_hash['private_header_files'])
|
|
44
|
+
spec.private_header_files = current_private_header_files + [
|
|
45
|
+
# iOS specific specs
|
|
46
|
+
"nitrogen/generated/ios/c++/**/*.{h,hpp}",
|
|
47
|
+
# Views are framework-specific and should be private
|
|
48
|
+
"nitrogen/generated/shared/**/views/**/*"
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
|
|
52
|
+
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
|
+
# Use C++ 20
|
|
54
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only ObjC)
|
|
56
|
+
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
|
+
# Enables stricter modular headers
|
|
58
|
+
"DEFINES_MODULE" => "YES",
|
|
59
|
+
})
|
|
60
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVersionCheck-Swift-Cxx-Bridge.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 "NitroVersionCheck-Swift-Cxx-Bridge.hpp"
|
|
9
|
+
|
|
10
|
+
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridVersionCheckSpecSwift.hpp"
|
|
12
|
+
#include "NitroVersionCheck-Swift-Cxx-Umbrella.hpp"
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::nitroversioncheck::bridge::swift {
|
|
16
|
+
|
|
17
|
+
// pragma MARK: std::function<void(const std::string& /* result */)>
|
|
18
|
+
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
19
|
+
auto swiftClosure = NitroVersionCheck::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
|
|
20
|
+
return [swiftClosure = std::move(swiftClosure)](const std::string& result) mutable -> void {
|
|
21
|
+
swiftClosure.call(result);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
26
|
+
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
27
|
+
auto swiftClosure = NitroVersionCheck::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
|
|
28
|
+
return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
|
|
29
|
+
swiftClosure.call(error);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// pragma MARK: std::function<void(bool /* result */)>
|
|
34
|
+
Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
35
|
+
auto swiftClosure = NitroVersionCheck::Func_void_bool::fromUnsafe(swiftClosureWrapper);
|
|
36
|
+
return [swiftClosure = std::move(swiftClosure)](bool result) mutable -> void {
|
|
37
|
+
swiftClosure.call(result);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// pragma MARK: std::shared_ptr<HybridVersionCheckSpec>
|
|
42
|
+
std::shared_ptr<HybridVersionCheckSpec> create_std__shared_ptr_HybridVersionCheckSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
43
|
+
NitroVersionCheck::HybridVersionCheckSpec_cxx swiftPart = NitroVersionCheck::HybridVersionCheckSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
44
|
+
return std::make_shared<margelo::nitro::nitroversioncheck::HybridVersionCheckSpecSwift>(swiftPart);
|
|
45
|
+
}
|
|
46
|
+
void* NON_NULL get_std__shared_ptr_HybridVersionCheckSpec_(std__shared_ptr_HybridVersionCheckSpec_ cppType) {
|
|
47
|
+
std::shared_ptr<margelo::nitro::nitroversioncheck::HybridVersionCheckSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitroversioncheck::HybridVersionCheckSpecSwift>(cppType);
|
|
48
|
+
#ifdef NITRO_DEBUG
|
|
49
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
50
|
+
throw std::runtime_error("Class \"HybridVersionCheckSpec\" is not implemented in Swift!");
|
|
51
|
+
}
|
|
52
|
+
#endif
|
|
53
|
+
NitroVersionCheck::HybridVersionCheckSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
54
|
+
return swiftPart.toUnsafe();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::nitroversioncheck::bridge::swift
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVersionCheck-Swift-Cxx-Bridge.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
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridVersionCheckSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::nitroversioncheck { class HybridVersionCheckSpec; }
|
|
13
|
+
|
|
14
|
+
// Forward declarations of Swift defined types
|
|
15
|
+
// Forward declaration of `HybridVersionCheckSpec_cxx` to properly resolve imports.
|
|
16
|
+
namespace NitroVersionCheck { class HybridVersionCheckSpec_cxx; }
|
|
17
|
+
|
|
18
|
+
// Include C++ defined types
|
|
19
|
+
#include "HybridVersionCheckSpec.hpp"
|
|
20
|
+
#include <NitroModules/Promise.hpp>
|
|
21
|
+
#include <NitroModules/PromiseHolder.hpp>
|
|
22
|
+
#include <NitroModules/Result.hpp>
|
|
23
|
+
#include <exception>
|
|
24
|
+
#include <functional>
|
|
25
|
+
#include <memory>
|
|
26
|
+
#include <optional>
|
|
27
|
+
#include <string>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
31
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
32
|
+
*/
|
|
33
|
+
namespace margelo::nitro::nitroversioncheck::bridge::swift {
|
|
34
|
+
|
|
35
|
+
// pragma MARK: std::optional<std::string>
|
|
36
|
+
/**
|
|
37
|
+
* Specialized version of `std::optional<std::string>`.
|
|
38
|
+
*/
|
|
39
|
+
using std__optional_std__string_ = std::optional<std::string>;
|
|
40
|
+
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
41
|
+
return std::optional<std::string>(value);
|
|
42
|
+
}
|
|
43
|
+
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
44
|
+
return optional.has_value();
|
|
45
|
+
}
|
|
46
|
+
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
47
|
+
return optional.value();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// pragma MARK: std::shared_ptr<Promise<std::string>>
|
|
51
|
+
/**
|
|
52
|
+
* Specialized version of `std::shared_ptr<Promise<std::string>>`.
|
|
53
|
+
*/
|
|
54
|
+
using std__shared_ptr_Promise_std__string__ = std::shared_ptr<Promise<std::string>>;
|
|
55
|
+
inline std::shared_ptr<Promise<std::string>> create_std__shared_ptr_Promise_std__string__() noexcept {
|
|
56
|
+
return Promise<std::string>::create();
|
|
57
|
+
}
|
|
58
|
+
inline PromiseHolder<std::string> wrap_std__shared_ptr_Promise_std__string__(std::shared_ptr<Promise<std::string>> promise) noexcept {
|
|
59
|
+
return PromiseHolder<std::string>(std::move(promise));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// pragma MARK: std::function<void(const std::string& /* result */)>
|
|
63
|
+
/**
|
|
64
|
+
* Specialized version of `std::function<void(const std::string&)>`.
|
|
65
|
+
*/
|
|
66
|
+
using Func_void_std__string = std::function<void(const std::string& /* result */)>;
|
|
67
|
+
/**
|
|
68
|
+
* Wrapper class for a `std::function<void(const std::string& / * result * /)>`, this can be used from Swift.
|
|
69
|
+
*/
|
|
70
|
+
class Func_void_std__string_Wrapper final {
|
|
71
|
+
public:
|
|
72
|
+
explicit Func_void_std__string_Wrapper(std::function<void(const std::string& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* result */)>>(std::move(func))) {}
|
|
73
|
+
inline void call(std::string result) const noexcept {
|
|
74
|
+
_function->operator()(result);
|
|
75
|
+
}
|
|
76
|
+
private:
|
|
77
|
+
std::unique_ptr<std::function<void(const std::string& /* result */)>> _function;
|
|
78
|
+
} SWIFT_NONCOPYABLE;
|
|
79
|
+
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
80
|
+
inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) noexcept {
|
|
81
|
+
return Func_void_std__string_Wrapper(std::move(value));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
85
|
+
/**
|
|
86
|
+
* Specialized version of `std::function<void(const std::exception_ptr&)>`.
|
|
87
|
+
*/
|
|
88
|
+
using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
|
|
89
|
+
/**
|
|
90
|
+
* Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
|
|
91
|
+
*/
|
|
92
|
+
class Func_void_std__exception_ptr_Wrapper final {
|
|
93
|
+
public:
|
|
94
|
+
explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
|
|
95
|
+
inline void call(std::exception_ptr error) const noexcept {
|
|
96
|
+
_function->operator()(error);
|
|
97
|
+
}
|
|
98
|
+
private:
|
|
99
|
+
std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
|
|
100
|
+
} SWIFT_NONCOPYABLE;
|
|
101
|
+
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
102
|
+
inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
|
|
103
|
+
return Func_void_std__exception_ptr_Wrapper(std::move(value));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// pragma MARK: std::shared_ptr<Promise<bool>>
|
|
107
|
+
/**
|
|
108
|
+
* Specialized version of `std::shared_ptr<Promise<bool>>`.
|
|
109
|
+
*/
|
|
110
|
+
using std__shared_ptr_Promise_bool__ = std::shared_ptr<Promise<bool>>;
|
|
111
|
+
inline std::shared_ptr<Promise<bool>> create_std__shared_ptr_Promise_bool__() noexcept {
|
|
112
|
+
return Promise<bool>::create();
|
|
113
|
+
}
|
|
114
|
+
inline PromiseHolder<bool> wrap_std__shared_ptr_Promise_bool__(std::shared_ptr<Promise<bool>> promise) noexcept {
|
|
115
|
+
return PromiseHolder<bool>(std::move(promise));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// pragma MARK: std::function<void(bool /* result */)>
|
|
119
|
+
/**
|
|
120
|
+
* Specialized version of `std::function<void(bool)>`.
|
|
121
|
+
*/
|
|
122
|
+
using Func_void_bool = std::function<void(bool /* result */)>;
|
|
123
|
+
/**
|
|
124
|
+
* Wrapper class for a `std::function<void(bool / * result * /)>`, this can be used from Swift.
|
|
125
|
+
*/
|
|
126
|
+
class Func_void_bool_Wrapper final {
|
|
127
|
+
public:
|
|
128
|
+
explicit Func_void_bool_Wrapper(std::function<void(bool /* result */)>&& func): _function(std::make_unique<std::function<void(bool /* result */)>>(std::move(func))) {}
|
|
129
|
+
inline void call(bool result) const noexcept {
|
|
130
|
+
_function->operator()(result);
|
|
131
|
+
}
|
|
132
|
+
private:
|
|
133
|
+
std::unique_ptr<std::function<void(bool /* result */)>> _function;
|
|
134
|
+
} SWIFT_NONCOPYABLE;
|
|
135
|
+
Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
136
|
+
inline Func_void_bool_Wrapper wrap_Func_void_bool(Func_void_bool value) noexcept {
|
|
137
|
+
return Func_void_bool_Wrapper(std::move(value));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// pragma MARK: std::shared_ptr<HybridVersionCheckSpec>
|
|
141
|
+
/**
|
|
142
|
+
* Specialized version of `std::shared_ptr<HybridVersionCheckSpec>`.
|
|
143
|
+
*/
|
|
144
|
+
using std__shared_ptr_HybridVersionCheckSpec_ = std::shared_ptr<HybridVersionCheckSpec>;
|
|
145
|
+
std::shared_ptr<HybridVersionCheckSpec> create_std__shared_ptr_HybridVersionCheckSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
146
|
+
void* NON_NULL get_std__shared_ptr_HybridVersionCheckSpec_(std__shared_ptr_HybridVersionCheckSpec_ cppType);
|
|
147
|
+
|
|
148
|
+
// pragma MARK: std::weak_ptr<HybridVersionCheckSpec>
|
|
149
|
+
using std__weak_ptr_HybridVersionCheckSpec_ = std::weak_ptr<HybridVersionCheckSpec>;
|
|
150
|
+
inline std__weak_ptr_HybridVersionCheckSpec_ weakify_std__shared_ptr_HybridVersionCheckSpec_(const std::shared_ptr<HybridVersionCheckSpec>& strong) noexcept { return strong; }
|
|
151
|
+
|
|
152
|
+
// pragma MARK: Result<std::string>
|
|
153
|
+
using Result_std__string_ = Result<std::string>;
|
|
154
|
+
inline Result_std__string_ create_Result_std__string_(const std::string& value) noexcept {
|
|
155
|
+
return Result<std::string>::withValue(value);
|
|
156
|
+
}
|
|
157
|
+
inline Result_std__string_ create_Result_std__string_(const std::exception_ptr& error) noexcept {
|
|
158
|
+
return Result<std::string>::withError(error);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// pragma MARK: Result<std::shared_ptr<Promise<std::string>>>
|
|
162
|
+
using Result_std__shared_ptr_Promise_std__string___ = Result<std::shared_ptr<Promise<std::string>>>;
|
|
163
|
+
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::shared_ptr<Promise<std::string>>& value) noexcept {
|
|
164
|
+
return Result<std::shared_ptr<Promise<std::string>>>::withValue(value);
|
|
165
|
+
}
|
|
166
|
+
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::exception_ptr& error) noexcept {
|
|
167
|
+
return Result<std::shared_ptr<Promise<std::string>>>::withError(error);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// pragma MARK: Result<std::shared_ptr<Promise<bool>>>
|
|
171
|
+
using Result_std__shared_ptr_Promise_bool___ = Result<std::shared_ptr<Promise<bool>>>;
|
|
172
|
+
inline Result_std__shared_ptr_Promise_bool___ create_Result_std__shared_ptr_Promise_bool___(const std::shared_ptr<Promise<bool>>& value) noexcept {
|
|
173
|
+
return Result<std::shared_ptr<Promise<bool>>>::withValue(value);
|
|
174
|
+
}
|
|
175
|
+
inline Result_std__shared_ptr_Promise_bool___ create_Result_std__shared_ptr_Promise_bool___(const std::exception_ptr& error) noexcept {
|
|
176
|
+
return Result<std::shared_ptr<Promise<bool>>>::withError(error);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
} // namespace margelo::nitro::nitroversioncheck::bridge::swift
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVersionCheck-Swift-Cxx-Umbrella.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
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridVersionCheckSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::nitroversioncheck { class HybridVersionCheckSpec; }
|
|
13
|
+
|
|
14
|
+
// Include C++ defined types
|
|
15
|
+
#include "HybridVersionCheckSpec.hpp"
|
|
16
|
+
#include <NitroModules/Promise.hpp>
|
|
17
|
+
#include <NitroModules/Result.hpp>
|
|
18
|
+
#include <exception>
|
|
19
|
+
#include <memory>
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <string>
|
|
22
|
+
|
|
23
|
+
// C++ helpers for Swift
|
|
24
|
+
#include "NitroVersionCheck-Swift-Cxx-Bridge.hpp"
|
|
25
|
+
|
|
26
|
+
// Common C++ types used in Swift
|
|
27
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
28
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
29
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
30
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
31
|
+
|
|
32
|
+
// Forward declarations of Swift defined types
|
|
33
|
+
// Forward declaration of `HybridVersionCheckSpec_cxx` to properly resolve imports.
|
|
34
|
+
namespace NitroVersionCheck { class HybridVersionCheckSpec_cxx; }
|
|
35
|
+
|
|
36
|
+
// Include Swift defined types
|
|
37
|
+
#if __has_include("NitroVersionCheck-Swift.h")
|
|
38
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
39
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroVersionCheck".
|
|
40
|
+
#include "NitroVersionCheck-Swift.h"
|
|
41
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
42
|
+
#elif __has_include(<NitroVersionCheck/NitroVersionCheck-Swift.h>)
|
|
43
|
+
#include <NitroVersionCheck/NitroVersionCheck-Swift.h>
|
|
44
|
+
#else
|
|
45
|
+
#error NitroVersionCheck's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroVersionCheck", and try building the app first.
|
|
46
|
+
#endif
|