@dawidzawada/bonjour-zeroconf 1.0.0
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/BonjourZeroconf.podspec +30 -0
- package/LICENSE +20 -0
- package/README.md +35 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +128 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf+AddressResolver.kt +182 -0
- package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf+Listeners.kt +45 -0
- package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf.kt +183 -0
- package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconfPackage.kt +22 -0
- package/ios/AddressResolverError.swift +20 -0
- package/ios/BonjourZeroconf+AddressResolver.swift +133 -0
- package/ios/BonjourZeroconf+Listeners.swift +26 -0
- package/ios/BonjourZeroconf.swift +201 -0
- package/ios/LocalNetworkAuthorization.swift +66 -0
- package/ios/LocalNetworkPermission+Listeners.swift +14 -0
- package/ios/LocalNetworkPermission.swift +41 -0
- package/ios/ServiceCache.swift +30 -0
- package/ios/Utils/Loggy.swift +37 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/permissions.ios.js +23 -0
- package/lib/module/permissions.ios.js.map +1 -0
- package/lib/module/permissions.js +9 -0
- package/lib/module/permissions.js.map +1 -0
- package/lib/module/specs/BonjourFail.js +9 -0
- package/lib/module/specs/BonjourFail.js.map +1 -0
- package/lib/module/specs/BonjourListener.js +2 -0
- package/lib/module/specs/BonjourListener.js.map +1 -0
- package/lib/module/specs/BonjourZeroconf.nitro.js +4 -0
- package/lib/module/specs/BonjourZeroconf.nitro.js.map +1 -0
- package/lib/module/specs/LocalNetworkPermission.nitro.js +4 -0
- package/lib/module/specs/LocalNetworkPermission.nitro.js.map +1 -0
- package/lib/module/specs/ScanResult.js +2 -0
- package/lib/module/specs/ScanResult.js.map +1 -0
- package/lib/module/useIsScanning.js +19 -0
- package/lib/module/useIsScanning.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/permissions.d.ts +3 -0
- package/lib/typescript/src/permissions.d.ts.map +1 -0
- package/lib/typescript/src/permissions.ios.d.ts +3 -0
- package/lib/typescript/src/permissions.ios.d.ts.map +1 -0
- package/lib/typescript/src/specs/BonjourFail.d.ts +6 -0
- package/lib/typescript/src/specs/BonjourFail.d.ts.map +1 -0
- package/lib/typescript/src/specs/BonjourListener.d.ts +4 -0
- package/lib/typescript/src/specs/BonjourListener.d.ts.map +1 -0
- package/lib/typescript/src/specs/BonjourZeroconf.nitro.d.ts +19 -0
- package/lib/typescript/src/specs/BonjourZeroconf.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/LocalNetworkPermission.nitro.d.ts +9 -0
- package/lib/typescript/src/specs/LocalNetworkPermission.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/ScanResult.d.ts +8 -0
- package/lib/typescript/src/specs/ScanResult.d.ts.map +1 -0
- package/lib/typescript/src/useIsScanning.d.ts +2 -0
- package/lib/typescript/src/useIsScanning.d.ts.map +1 -0
- package/nitro.json +20 -0
- package/nitrogen/generated/android/c++/JBonjourFail.hpp +62 -0
- package/nitrogen/generated/android/c++/JBonjourListener.hpp +68 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
- package/nitrogen/generated/android/c++/JFunc_void_BonjourFail.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +74 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_ScanResult_.hpp +97 -0
- package/nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.cpp +96 -0
- package/nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JScanOptions.hpp +57 -0
- package/nitrogen/generated/android/c++/JScanResult.hpp +74 -0
- package/nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.cmake +82 -0
- package/nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.gradle +27 -0
- package/nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.cpp +52 -0
- package/nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.hpp +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourFail.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourListener.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_BonjourFail.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_bool.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_std__vector_ScanResult_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/HybridBonjourZeroconfSpec.kt +90 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/ScanOptions.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/ScanResult.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/dawidzawada_bonjourzeroconfOnLoad.kt +35 -0
- package/nitrogen/generated/ios/BonjourZeroconf+autolinking.rb +60 -0
- package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Bridge.cpp +90 -0
- package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Bridge.hpp +282 -0
- package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Umbrella.hpp +65 -0
- package/nitrogen/generated/ios/BonjourZeroconfAutolinking.mm +41 -0
- package/nitrogen/generated/ios/BonjourZeroconfAutolinking.swift +40 -0
- package/nitrogen/generated/ios/c++/HybridBonjourZeroconfSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridBonjourZeroconfSpecSwift.hpp +120 -0
- package/nitrogen/generated/ios/c++/HybridLocalNetworkPermissionSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridLocalNetworkPermissionSpecSwift.hpp +87 -0
- package/nitrogen/generated/ios/swift/BonjourFail.swift +44 -0
- package/nitrogen/generated/ios/swift/BonjourListener.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_BonjourFail.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_ScanResult_.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridBonjourZeroconfSpec.swift +60 -0
- package/nitrogen/generated/ios/swift/HybridBonjourZeroconfSpec_cxx.swift +203 -0
- package/nitrogen/generated/ios/swift/HybridLocalNetworkPermissionSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridLocalNetworkPermissionSpec_cxx.swift +155 -0
- package/nitrogen/generated/ios/swift/ScanOptions.swift +48 -0
- package/nitrogen/generated/ios/swift/ScanResult.swift +149 -0
- package/nitrogen/generated/shared/c++/BonjourFail.hpp +63 -0
- package/nitrogen/generated/shared/c++/BonjourListener.hpp +75 -0
- package/nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.hpp +80 -0
- package/nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.hpp +66 -0
- package/nitrogen/generated/shared/c++/ScanOptions.hpp +75 -0
- package/nitrogen/generated/shared/c++/ScanResult.hpp +92 -0
- package/package.json +169 -0
- package/src/index.ts +22 -0
- package/src/permissions.ios.ts +27 -0
- package/src/permissions.ts +7 -0
- package/src/specs/BonjourFail.ts +5 -0
- package/src/specs/BonjourListener.ts +3 -0
- package/src/specs/BonjourZeroconf.nitro.ts +20 -0
- package/src/specs/LocalNetworkPermission.nitro.ts +7 -0
- package/src/specs/ScanResult.ts +7 -0
- package/src/useIsScanning.ts +17 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridBonjourZeroconfSpec.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 "JHybridBonjourZeroconfSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `BonjourListener` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct BonjourListener; }
|
|
12
|
+
// Forward declaration of `ScanOptions` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct ScanOptions; }
|
|
14
|
+
// Forward declaration of `ScanResult` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct ScanResult; }
|
|
16
|
+
// Forward declaration of `BonjourFail` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::dawidzawada_bonjourzeroconf { enum class BonjourFail; }
|
|
18
|
+
|
|
19
|
+
#include "BonjourListener.hpp"
|
|
20
|
+
#include "JBonjourListener.hpp"
|
|
21
|
+
#include <functional>
|
|
22
|
+
#include "JFunc_void.hpp"
|
|
23
|
+
#include <string>
|
|
24
|
+
#include "ScanOptions.hpp"
|
|
25
|
+
#include <optional>
|
|
26
|
+
#include "JScanOptions.hpp"
|
|
27
|
+
#include "ScanResult.hpp"
|
|
28
|
+
#include <vector>
|
|
29
|
+
#include "JFunc_void_std__vector_ScanResult_.hpp"
|
|
30
|
+
#include "JScanResult.hpp"
|
|
31
|
+
#include "JFunc_void_bool.hpp"
|
|
32
|
+
#include "BonjourFail.hpp"
|
|
33
|
+
#include "JFunc_void_BonjourFail.hpp"
|
|
34
|
+
#include "JBonjourFail.hpp"
|
|
35
|
+
|
|
36
|
+
namespace margelo::nitro::dawidzawada_bonjourzeroconf {
|
|
37
|
+
|
|
38
|
+
jni::local_ref<JHybridBonjourZeroconfSpec::jhybriddata> JHybridBonjourZeroconfSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
39
|
+
return makeCxxInstance(jThis);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void JHybridBonjourZeroconfSpec::registerNatives() {
|
|
43
|
+
registerHybrid({
|
|
44
|
+
makeNativeMethod("initHybrid", JHybridBonjourZeroconfSpec::initHybrid),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
size_t JHybridBonjourZeroconfSpec::getExternalMemorySize() noexcept {
|
|
49
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
50
|
+
return method(_javaPart);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void JHybridBonjourZeroconfSpec::dispose() noexcept {
|
|
54
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
55
|
+
method(_javaPart);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
std::string JHybridBonjourZeroconfSpec::toString() {
|
|
59
|
+
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
60
|
+
auto javaString = method(_javaPart);
|
|
61
|
+
return javaString->toStdString();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Properties
|
|
65
|
+
bool JHybridBonjourZeroconfSpec::getIsScanning() {
|
|
66
|
+
static const auto method = javaClassStatic()->getMethod<jboolean()>("isScanning");
|
|
67
|
+
auto __result = method(_javaPart);
|
|
68
|
+
return static_cast<bool>(__result);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Methods
|
|
72
|
+
void JHybridBonjourZeroconfSpec::scan(const std::string& type, const std::string& domain, const std::optional<ScanOptions>& options) {
|
|
73
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* type */, jni::alias_ref<jni::JString> /* domain */, jni::alias_ref<JScanOptions> /* options */)>("scan");
|
|
74
|
+
method(_javaPart, jni::make_jstring(type), jni::make_jstring(domain), options.has_value() ? JScanOptions::fromCpp(options.value()) : nullptr);
|
|
75
|
+
}
|
|
76
|
+
void JHybridBonjourZeroconfSpec::stop() {
|
|
77
|
+
static const auto method = javaClassStatic()->getMethod<void()>("stop");
|
|
78
|
+
method(_javaPart);
|
|
79
|
+
}
|
|
80
|
+
BonjourListener JHybridBonjourZeroconfSpec::listenForScanResults(const std::function<void(const std::vector<ScanResult>& /* results */)>& onResult) {
|
|
81
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JBonjourListener>(jni::alias_ref<JFunc_void_std__vector_ScanResult_::javaobject> /* onResult */)>("listenForScanResults_cxx");
|
|
82
|
+
auto __result = method(_javaPart, JFunc_void_std__vector_ScanResult__cxx::fromCpp(onResult));
|
|
83
|
+
return __result->toCpp();
|
|
84
|
+
}
|
|
85
|
+
BonjourListener JHybridBonjourZeroconfSpec::listenForScanState(const std::function<void(bool /* isScanning */)>& onChange) {
|
|
86
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JBonjourListener>(jni::alias_ref<JFunc_void_bool::javaobject> /* onChange */)>("listenForScanState_cxx");
|
|
87
|
+
auto __result = method(_javaPart, JFunc_void_bool_cxx::fromCpp(onChange));
|
|
88
|
+
return __result->toCpp();
|
|
89
|
+
}
|
|
90
|
+
BonjourListener JHybridBonjourZeroconfSpec::listenForScanFail(const std::function<void(BonjourFail /* fail */)>& onFail) {
|
|
91
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JBonjourListener>(jni::alias_ref<JFunc_void_BonjourFail::javaobject> /* onFail */)>("listenForScanFail_cxx");
|
|
92
|
+
auto __result = method(_javaPart, JFunc_void_BonjourFail_cxx::fromCpp(onFail));
|
|
93
|
+
return __result->toCpp();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
} // namespace margelo::nitro::dawidzawada_bonjourzeroconf
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridBonjourZeroconfSpec.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 <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridBonjourZeroconfSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::dawidzawada_bonjourzeroconf {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridBonjourZeroconfSpec: public jni::HybridClass<JHybridBonjourZeroconfSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridBonjourZeroconfSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/HybridBonjourZeroconfSpec;";
|
|
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 JHybridBonjourZeroconfSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridBonjourZeroconfSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridBonjourZeroconfSpec() 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
|
+
void dispose() noexcept override;
|
|
44
|
+
std::string toString() override;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridBonjourZeroconfSpec::javaobject>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
bool getIsScanning() override;
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
void scan(const std::string& type, const std::string& domain, const std::optional<ScanOptions>& options) override;
|
|
58
|
+
void stop() override;
|
|
59
|
+
BonjourListener listenForScanResults(const std::function<void(const std::vector<ScanResult>& /* results */)>& onResult) override;
|
|
60
|
+
BonjourListener listenForScanState(const std::function<void(bool /* isScanning */)>& onChange) override;
|
|
61
|
+
BonjourListener listenForScanFail(const std::function<void(BonjourFail /* fail */)>& onFail) override;
|
|
62
|
+
|
|
63
|
+
private:
|
|
64
|
+
friend HybridBase;
|
|
65
|
+
using HybridBase::HybridBase;
|
|
66
|
+
jni::global_ref<JHybridBonjourZeroconfSpec::javaobject> _javaPart;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
} // namespace margelo::nitro::dawidzawada_bonjourzeroconf
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JScanOptions.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "ScanOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::dawidzawada_bonjourzeroconf {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "ScanOptions" and the the Kotlin data class "ScanOptions".
|
|
21
|
+
*/
|
|
22
|
+
struct JScanOptions final: public jni::JavaClass<JScanOptions> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/ScanOptions;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ScanOptions by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
ScanOptions toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldAddressResolveTimeout = clazz->getField<jni::JDouble>("addressResolveTimeout");
|
|
35
|
+
jni::local_ref<jni::JDouble> addressResolveTimeout = this->getFieldValue(fieldAddressResolveTimeout);
|
|
36
|
+
return ScanOptions(
|
|
37
|
+
addressResolveTimeout != nullptr ? std::make_optional(addressResolveTimeout->value()) : std::nullopt
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
/**
|
|
43
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
44
|
+
*/
|
|
45
|
+
[[maybe_unused]]
|
|
46
|
+
static jni::local_ref<JScanOptions::javaobject> fromCpp(const ScanOptions& value) {
|
|
47
|
+
using JSignature = JScanOptions(jni::alias_ref<jni::JDouble>);
|
|
48
|
+
static const auto clazz = javaClassStatic();
|
|
49
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
50
|
+
return create(
|
|
51
|
+
clazz,
|
|
52
|
+
value.addressResolveTimeout.has_value() ? jni::JDouble::valueOf(value.addressResolveTimeout.value()) : nullptr
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::dawidzawada_bonjourzeroconf
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JScanResult.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "ScanResult.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <string>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::dawidzawada_bonjourzeroconf {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The C++ JNI bridge between the C++ struct "ScanResult" and the the Kotlin data class "ScanResult".
|
|
22
|
+
*/
|
|
23
|
+
struct JScanResult final: public jni::JavaClass<JScanResult> {
|
|
24
|
+
public:
|
|
25
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/ScanResult;";
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ScanResult by copying all values to C++.
|
|
30
|
+
*/
|
|
31
|
+
[[maybe_unused]]
|
|
32
|
+
[[nodiscard]]
|
|
33
|
+
ScanResult toCpp() const {
|
|
34
|
+
static const auto clazz = javaClassStatic();
|
|
35
|
+
static const auto fieldName = clazz->getField<jni::JString>("name");
|
|
36
|
+
jni::local_ref<jni::JString> name = this->getFieldValue(fieldName);
|
|
37
|
+
static const auto fieldIpv4 = clazz->getField<jni::JString>("ipv4");
|
|
38
|
+
jni::local_ref<jni::JString> ipv4 = this->getFieldValue(fieldIpv4);
|
|
39
|
+
static const auto fieldIpv6 = clazz->getField<jni::JString>("ipv6");
|
|
40
|
+
jni::local_ref<jni::JString> ipv6 = this->getFieldValue(fieldIpv6);
|
|
41
|
+
static const auto fieldHostname = clazz->getField<jni::JString>("hostname");
|
|
42
|
+
jni::local_ref<jni::JString> hostname = this->getFieldValue(fieldHostname);
|
|
43
|
+
static const auto fieldPort = clazz->getField<jni::JDouble>("port");
|
|
44
|
+
jni::local_ref<jni::JDouble> port = this->getFieldValue(fieldPort);
|
|
45
|
+
return ScanResult(
|
|
46
|
+
name->toStdString(),
|
|
47
|
+
ipv4 != nullptr ? std::make_optional(ipv4->toStdString()) : std::nullopt,
|
|
48
|
+
ipv6 != nullptr ? std::make_optional(ipv6->toStdString()) : std::nullopt,
|
|
49
|
+
hostname != nullptr ? std::make_optional(hostname->toStdString()) : std::nullopt,
|
|
50
|
+
port != nullptr ? std::make_optional(port->value()) : std::nullopt
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
/**
|
|
56
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
57
|
+
*/
|
|
58
|
+
[[maybe_unused]]
|
|
59
|
+
static jni::local_ref<JScanResult::javaobject> fromCpp(const ScanResult& value) {
|
|
60
|
+
using JSignature = JScanResult(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>);
|
|
61
|
+
static const auto clazz = javaClassStatic();
|
|
62
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
63
|
+
return create(
|
|
64
|
+
clazz,
|
|
65
|
+
jni::make_jstring(value.name),
|
|
66
|
+
value.ipv4.has_value() ? jni::make_jstring(value.ipv4.value()) : nullptr,
|
|
67
|
+
value.ipv6.has_value() ? jni::make_jstring(value.ipv6.value()) : nullptr,
|
|
68
|
+
value.hostname.has_value() ? jni::make_jstring(value.hostname.value()) : nullptr,
|
|
69
|
+
value.port.has_value() ? jni::JDouble::valueOf(value.port.value()) : nullptr
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
} // namespace margelo::nitro::dawidzawada_bonjourzeroconf
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#
|
|
2
|
+
# dawidzawada_bonjourzeroconf+autolinking.cmake
|
|
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
|
+
# This is a CMake file that adds all files generated by Nitrogen
|
|
9
|
+
# to the current CMake project.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your CMakeLists.txt:
|
|
12
|
+
# ```cmake
|
|
13
|
+
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.cmake)
|
|
14
|
+
# ```
|
|
15
|
+
|
|
16
|
+
# Define a flag to check if we are building properly
|
|
17
|
+
add_definitions(-DBUILDING_DAWIDZAWADABONJOURZEROCONF_WITH_GENERATED_CMAKE_PROJECT)
|
|
18
|
+
|
|
19
|
+
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
20
|
+
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
21
|
+
|
|
22
|
+
# Add all headers that were generated by Nitrogen
|
|
23
|
+
include_directories(
|
|
24
|
+
"../nitrogen/generated/shared/c++"
|
|
25
|
+
"../nitrogen/generated/android/c++"
|
|
26
|
+
"../nitrogen/generated/android/"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Add all .cpp sources that were generated by Nitrogen
|
|
30
|
+
target_sources(
|
|
31
|
+
# CMake project name (Android C++ library name)
|
|
32
|
+
dawidzawada_bonjourzeroconf PRIVATE
|
|
33
|
+
# Autolinking Setup
|
|
34
|
+
../nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.cpp
|
|
35
|
+
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.cpp
|
|
37
|
+
../nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.cpp
|
|
38
|
+
# Android-specific Nitrogen C++ sources
|
|
39
|
+
../nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.cpp
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
43
|
+
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
44
|
+
target_compile_definitions(
|
|
45
|
+
dawidzawada_bonjourzeroconf PRIVATE
|
|
46
|
+
-DFOLLY_NO_CONFIG=1
|
|
47
|
+
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
48
|
+
-DFOLLY_USE_LIBCPP=1
|
|
49
|
+
-DFOLLY_CFG_NO_COROUTINES=1
|
|
50
|
+
-DFOLLY_MOBILE=1
|
|
51
|
+
-DFOLLY_HAVE_RECVMMSG=1
|
|
52
|
+
-DFOLLY_HAVE_PTHREAD=1
|
|
53
|
+
# Once we target android-23 above, we can comment
|
|
54
|
+
# the following line. NDK uses GNU style stderror_r() after API 23.
|
|
55
|
+
-DFOLLY_HAVE_XSI_STRERROR_R=1
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Add all libraries required by the generated specs
|
|
59
|
+
find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
|
|
60
|
+
find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
|
|
61
|
+
find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
|
|
62
|
+
|
|
63
|
+
# Link all libraries together
|
|
64
|
+
target_link_libraries(
|
|
65
|
+
dawidzawada_bonjourzeroconf
|
|
66
|
+
fbjni::fbjni # <-- Facebook C++ JNI helpers
|
|
67
|
+
ReactAndroid::jsi # <-- RN: JSI
|
|
68
|
+
react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Link react-native (different prefab between RN 0.75 and RN 0.76)
|
|
72
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
73
|
+
target_link_libraries(
|
|
74
|
+
dawidzawada_bonjourzeroconf
|
|
75
|
+
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
76
|
+
)
|
|
77
|
+
else()
|
|
78
|
+
target_link_libraries(
|
|
79
|
+
dawidzawada_bonjourzeroconf
|
|
80
|
+
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
81
|
+
)
|
|
82
|
+
endif()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// dawidzawada_bonjourzeroconf+autolinking.gradle
|
|
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
|
+
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
9
|
+
/// to the current Gradle project.
|
|
10
|
+
///
|
|
11
|
+
/// To use it, add this to your build.gradle:
|
|
12
|
+
/// ```gradle
|
|
13
|
+
/// apply from: '../nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.gradle'
|
|
14
|
+
/// ```
|
|
15
|
+
|
|
16
|
+
logger.warn("[NitroModules] 🔥 dawidzawada_bonjourzeroconf is boosted by nitro!")
|
|
17
|
+
|
|
18
|
+
android {
|
|
19
|
+
sourceSets {
|
|
20
|
+
main {
|
|
21
|
+
java.srcDirs += [
|
|
22
|
+
// Nitrogen files
|
|
23
|
+
"${project.projectDir}/../nitrogen/generated/android/kotlin"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// dawidzawada_bonjourzeroconfOnLoad.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
|
+
#ifndef BUILDING_DAWIDZAWADABONJOURZEROCONF_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
+
#error dawidzawada_bonjourzeroconfOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "dawidzawada_bonjourzeroconfOnLoad.hpp"
|
|
13
|
+
|
|
14
|
+
#include <jni.h>
|
|
15
|
+
#include <fbjni/fbjni.h>
|
|
16
|
+
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
+
|
|
18
|
+
#include "JHybridBonjourZeroconfSpec.hpp"
|
|
19
|
+
#include "JFunc_void.hpp"
|
|
20
|
+
#include "JFunc_void_std__vector_ScanResult_.hpp"
|
|
21
|
+
#include "JFunc_void_bool.hpp"
|
|
22
|
+
#include "JFunc_void_BonjourFail.hpp"
|
|
23
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::dawidzawada_bonjourzeroconf {
|
|
26
|
+
|
|
27
|
+
int initialize(JavaVM* vm) {
|
|
28
|
+
using namespace margelo::nitro;
|
|
29
|
+
using namespace margelo::nitro::dawidzawada_bonjourzeroconf;
|
|
30
|
+
using namespace facebook;
|
|
31
|
+
|
|
32
|
+
return facebook::jni::initialize(vm, [] {
|
|
33
|
+
// Register native JNI methods
|
|
34
|
+
margelo::nitro::dawidzawada_bonjourzeroconf::JHybridBonjourZeroconfSpec::registerNatives();
|
|
35
|
+
margelo::nitro::dawidzawada_bonjourzeroconf::JFunc_void_cxx::registerNatives();
|
|
36
|
+
margelo::nitro::dawidzawada_bonjourzeroconf::JFunc_void_std__vector_ScanResult__cxx::registerNatives();
|
|
37
|
+
margelo::nitro::dawidzawada_bonjourzeroconf::JFunc_void_bool_cxx::registerNatives();
|
|
38
|
+
margelo::nitro::dawidzawada_bonjourzeroconf::JFunc_void_BonjourFail_cxx::registerNatives();
|
|
39
|
+
|
|
40
|
+
// Register Nitro Hybrid Objects
|
|
41
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
42
|
+
"BonjourZeroconf",
|
|
43
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
44
|
+
static DefaultConstructableObject<JHybridBonjourZeroconfSpec::javaobject> object("com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf");
|
|
45
|
+
auto instance = object.create();
|
|
46
|
+
return instance->cthis()->shared();
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
} // namespace margelo::nitro::dawidzawada_bonjourzeroconf
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// dawidzawada_bonjourzeroconfOnLoad.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
|
+
#include <jni.h>
|
|
9
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
10
|
+
|
|
11
|
+
namespace margelo::nitro::dawidzawada_bonjourzeroconf {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the native (C++) part of dawidzawada_bonjourzeroconf, and autolinks all Hybrid Objects.
|
|
15
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
|
|
16
|
+
* Example:
|
|
17
|
+
* ```cpp (cpp-adapter.cpp)
|
|
18
|
+
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
+
* return margelo::nitro::dawidzawada_bonjourzeroconf::initialize(vm);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
int initialize(JavaVM* vm);
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::dawidzawada_bonjourzeroconf
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// BonjourFail.kt
|
|
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
|
+
package com.margelo.nitro.dawidzawada.bonjourzeroconf
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "BonjourFail".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class BonjourFail(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
RESOLVE_FAILED(0),
|
|
20
|
+
EXTRACTION_FAILED(1),
|
|
21
|
+
DISCOVERY_FAILED(2);
|
|
22
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// BonjourListener.kt
|
|
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
|
+
package com.margelo.nitro.dawidzawada.bonjourzeroconf
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "BonjourListener".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class BonjourListener(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val remove: Func_void
|
|
23
|
+
) {
|
|
24
|
+
/**
|
|
25
|
+
* Create a new instance of BonjourListener from Kotlin
|
|
26
|
+
*/
|
|
27
|
+
constructor(remove: () -> Unit):
|
|
28
|
+
this(Func_void_java(remove))
|
|
29
|
+
|
|
30
|
+
private companion object {
|
|
31
|
+
/**
|
|
32
|
+
* Constructor called from C++
|
|
33
|
+
*/
|
|
34
|
+
@DoNotStrip
|
|
35
|
+
@Keep
|
|
36
|
+
@Suppress("unused")
|
|
37
|
+
@JvmStatic
|
|
38
|
+
private fun fromCpp(remove: Func_void): BonjourListener {
|
|
39
|
+
return BonjourListener(remove)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void.kt
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void.kt
|
|
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
|
+
package com.margelo.nitro.dawidzawada.bonjourzeroconf
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the JavaScript callback `() => void`.
|
|
18
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
+
fun interface Func_void: () -> Unit {
|
|
25
|
+
/**
|
|
26
|
+
* Call the given JS callback.
|
|
27
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
+
*/
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
override fun invoke(): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `() => void`.
|
|
36
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
+
* The callback might be coming from JS.
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress(
|
|
42
|
+
"KotlinJniMissingFunction", "unused",
|
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
+
)
|
|
46
|
+
class Func_void_cxx: Func_void {
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
private val mHybridData: HybridData
|
|
50
|
+
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
private constructor(hybridData: HybridData) {
|
|
54
|
+
mHybridData = hybridData
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
override fun invoke(): Unit
|
|
60
|
+
= invoke_cxx()
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `() => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `() -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_java(private val function: () -> Unit): Func_void {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(): Unit {
|
|
78
|
+
return this.function()
|
|
79
|
+
}
|
|
80
|
+
}
|