@onekeyfe/react-native-capture-protection 0.0.0-stage → 3.0.166
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/ACKNOWLEDGEMENTS.md +18 -0
- package/LICENSE +22 -0
- package/LICENSE.upstream +20 -0
- package/README.md +25 -2
- package/ReactNativeCaptureProtection.podspec +37 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +130 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/reactnativecaptureprotection/ReactNativeCaptureProtection.kt +285 -0
- package/android/src/main/java/com/margelo/nitro/reactnativecaptureprotection/ReactNativeCaptureProtectionPackage.kt +22 -0
- package/docs/SPEC.md +117 -0
- package/ios/ReactNativeCaptureProtection.swift +251 -0
- package/ios/tests/CaptureProtectionTests.swift +50 -0
- package/lib/module/ReactNativeCaptureProtection.nitro.js +4 -0
- package/lib/module/ReactNativeCaptureProtection.nitro.js.map +1 -0
- package/lib/module/index.js +61 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ReactNativeCaptureProtection.nitro.d.ts +10 -0
- package/lib/typescript/src/ReactNativeCaptureProtection.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +22 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeCaptureProtectionSpec.cpp +88 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeCaptureProtectionSpec.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecaptureprotection/Func_void_double.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecaptureprotection/HybridReactNativeCaptureProtectionSpec.kt +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecaptureprotection/reactnativecaptureprotectionOnLoad.kt +35 -0
- package/nitrogen/generated/android/reactnativecaptureprotection+autolinking.cmake +81 -0
- package/nitrogen/generated/android/reactnativecaptureprotection+autolinking.gradle +27 -0
- package/nitrogen/generated/android/reactnativecaptureprotectionOnLoad.cpp +56 -0
- package/nitrogen/generated/android/reactnativecaptureprotectionOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/ReactNativeCaptureProtection+autolinking.rb +62 -0
- package/nitrogen/generated/ios/ReactNativeCaptureProtection-Swift-Cxx-Bridge.cpp +57 -0
- package/nitrogen/generated/ios/ReactNativeCaptureProtection-Swift-Cxx-Bridge.hpp +157 -0
- package/nitrogen/generated/ios/ReactNativeCaptureProtection-Swift-Cxx-Umbrella.hpp +46 -0
- package/nitrogen/generated/ios/ReactNativeCaptureProtectionAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ReactNativeCaptureProtectionAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeCaptureProtectionSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeCaptureProtectionSpecSwift.hpp +98 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeCaptureProtectionSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeCaptureProtectionSpec_cxx.swift +187 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeCaptureProtectionSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeCaptureProtectionSpec.hpp +66 -0
- package/package.json +173 -4
- package/src/ReactNativeCaptureProtection.nitro.ts +8 -0
- package/src/index.tsx +65 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridReactNativeCaptureProtectionSpec.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 "JHybridReactNativeCaptureProtectionSpec.hpp"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
#include <NitroModules/Promise.hpp>
|
|
13
|
+
#include <NitroModules/JPromise.hpp>
|
|
14
|
+
#include <NitroModules/JUnit.hpp>
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <optional>
|
|
17
|
+
#include "JFunc_void_double.hpp"
|
|
18
|
+
#include <NitroModules/JNICallable.hpp>
|
|
19
|
+
|
|
20
|
+
namespace margelo::nitro::reactnativecaptureprotection {
|
|
21
|
+
|
|
22
|
+
std::shared_ptr<JHybridReactNativeCaptureProtectionSpec> JHybridReactNativeCaptureProtectionSpec::JavaPart::getJHybridReactNativeCaptureProtectionSpec() {
|
|
23
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
24
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridReactNativeCaptureProtectionSpec>(hybridObject);
|
|
25
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
26
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridReactNativeCaptureProtectionSpec!");
|
|
27
|
+
}
|
|
28
|
+
return castHybridObject;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
jni::local_ref<JHybridReactNativeCaptureProtectionSpec::CxxPart::jhybriddata> JHybridReactNativeCaptureProtectionSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
32
|
+
return makeCxxInstance(jThis);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
std::shared_ptr<JHybridObject> JHybridReactNativeCaptureProtectionSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
36
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridReactNativeCaptureProtectionSpec::JavaPart>(javaPart);
|
|
37
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
38
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridReactNativeCaptureProtectionSpec::JavaPart!");
|
|
39
|
+
}
|
|
40
|
+
return std::make_shared<JHybridReactNativeCaptureProtectionSpec>(castJavaPart);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void JHybridReactNativeCaptureProtectionSpec::CxxPart::registerNatives() {
|
|
44
|
+
registerHybrid({
|
|
45
|
+
makeNativeMethod("initHybrid", JHybridReactNativeCaptureProtectionSpec::CxxPart::initHybrid),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Properties
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// Methods
|
|
53
|
+
std::shared_ptr<Promise<void>> JHybridReactNativeCaptureProtectionSpec::prevent() {
|
|
54
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("prevent");
|
|
55
|
+
auto __result = method(_javaPart);
|
|
56
|
+
return [&]() {
|
|
57
|
+
auto __promise = Promise<void>::create();
|
|
58
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
59
|
+
__promise->resolve();
|
|
60
|
+
});
|
|
61
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
62
|
+
jni::JniException __jniError(__throwable);
|
|
63
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
64
|
+
});
|
|
65
|
+
return __promise;
|
|
66
|
+
}();
|
|
67
|
+
}
|
|
68
|
+
std::shared_ptr<Promise<void>> JHybridReactNativeCaptureProtectionSpec::allow() {
|
|
69
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("allow");
|
|
70
|
+
auto __result = method(_javaPart);
|
|
71
|
+
return [&]() {
|
|
72
|
+
auto __promise = Promise<void>::create();
|
|
73
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
74
|
+
__promise->resolve();
|
|
75
|
+
});
|
|
76
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
77
|
+
jni::JniException __jniError(__throwable);
|
|
78
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
79
|
+
});
|
|
80
|
+
return __promise;
|
|
81
|
+
}();
|
|
82
|
+
}
|
|
83
|
+
void JHybridReactNativeCaptureProtectionSpec::setListener(const std::optional<std::function<void(double /* event */)>>& callback) {
|
|
84
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_double::javaobject> /* callback */)>("setListener_cxx");
|
|
85
|
+
method(_javaPart, callback.has_value() ? JFunc_void_double_cxx::fromCpp(callback.value()) : nullptr);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
} // namespace margelo::nitro::reactnativecaptureprotection
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativeCaptureProtectionSpec.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 "HybridReactNativeCaptureProtectionSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::reactnativecaptureprotection {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridReactNativeCaptureProtectionSpec: public virtual HybridReactNativeCaptureProtectionSpec, public virtual JHybridObject {
|
|
22
|
+
public:
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativecaptureprotection/HybridReactNativeCaptureProtectionSpec;";
|
|
25
|
+
std::shared_ptr<JHybridReactNativeCaptureProtectionSpec> getJHybridReactNativeCaptureProtectionSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativecaptureprotection/HybridReactNativeCaptureProtectionSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
explicit JHybridReactNativeCaptureProtectionSpec(const jni::local_ref<JHybridReactNativeCaptureProtectionSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridReactNativeCaptureProtectionSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
41
|
+
~JHybridReactNativeCaptureProtectionSpec() override {
|
|
42
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
43
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridReactNativeCaptureProtectionSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
std::shared_ptr<Promise<void>> prevent() override;
|
|
58
|
+
std::shared_ptr<Promise<void>> allow() override;
|
|
59
|
+
void setListener(const std::optional<std::function<void(double /* event */)>>& callback) override;
|
|
60
|
+
|
|
61
|
+
private:
|
|
62
|
+
jni::global_ref<JHybridReactNativeCaptureProtectionSpec::JavaPart> _javaPart;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace margelo::nitro::reactnativecaptureprotection
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_double.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.reactnativecaptureprotection
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript callback `(event: number) => void`.
|
|
17
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
18
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
23
|
+
fun interface Func_void_double: (Double) -> Unit {
|
|
24
|
+
/**
|
|
25
|
+
* Call the given JS callback.
|
|
26
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
27
|
+
*/
|
|
28
|
+
@DoNotStrip
|
|
29
|
+
@Keep
|
|
30
|
+
override fun invoke(event: Double): Unit
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents the JavaScript callback `(event: number) => void`.
|
|
35
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
36
|
+
* The callback might be coming from JS.
|
|
37
|
+
*/
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
@Keep
|
|
40
|
+
@Suppress(
|
|
41
|
+
"KotlinJniMissingFunction", "unused",
|
|
42
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
43
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
44
|
+
)
|
|
45
|
+
class Func_void_double_cxx: Func_void_double {
|
|
46
|
+
@DoNotStrip
|
|
47
|
+
@Keep
|
|
48
|
+
private val mHybridData: HybridData
|
|
49
|
+
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
@Keep
|
|
52
|
+
private constructor(hybridData: HybridData) {
|
|
53
|
+
mHybridData = hybridData
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
@Keep
|
|
58
|
+
override fun invoke(event: Double): Unit
|
|
59
|
+
= invoke_cxx(event)
|
|
60
|
+
|
|
61
|
+
private external fun invoke_cxx(event: Double): Unit
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Represents the JavaScript callback `(event: number) => void`.
|
|
66
|
+
* This is implemented in Java/Kotlin, via a `(Double) -> Unit`.
|
|
67
|
+
* The callback is always coming from native.
|
|
68
|
+
*/
|
|
69
|
+
@DoNotStrip
|
|
70
|
+
@Keep
|
|
71
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
72
|
+
class Func_void_double_java(private val function: (Double) -> Unit): Func_void_double {
|
|
73
|
+
@DoNotStrip
|
|
74
|
+
@Keep
|
|
75
|
+
override fun invoke(event: Double): Unit {
|
|
76
|
+
return this.function(event)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativeCaptureProtectionSpec.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.reactnativecaptureprotection
|
|
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
|
+
import com.margelo.nitro.core.Promise
|
|
15
|
+
import com.margelo.nitro.core.HybridObject
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A Kotlin class representing the ReactNativeCaptureProtection HybridObject.
|
|
19
|
+
* Implement this abstract class to create Kotlin-based instances of ReactNativeCaptureProtection.
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress(
|
|
24
|
+
"KotlinJniMissingFunction", "unused",
|
|
25
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
26
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
27
|
+
)
|
|
28
|
+
abstract class HybridReactNativeCaptureProtectionSpec: HybridObject() {
|
|
29
|
+
// Properties
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// Methods
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
abstract fun prevent(): Promise<Unit>
|
|
36
|
+
|
|
37
|
+
@DoNotStrip
|
|
38
|
+
@Keep
|
|
39
|
+
abstract fun allow(): Promise<Unit>
|
|
40
|
+
|
|
41
|
+
abstract fun setListener(callback: ((event: Double) -> Unit)?): Unit
|
|
42
|
+
|
|
43
|
+
@DoNotStrip
|
|
44
|
+
@Keep
|
|
45
|
+
private fun setListener_cxx(callback: Func_void_double?): Unit {
|
|
46
|
+
val __result = setListener(callback?.let { it })
|
|
47
|
+
return __result
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Default implementation of `HybridObject.toString()`
|
|
51
|
+
override fun toString(): String {
|
|
52
|
+
return "[HybridObject ReactNativeCaptureProtection]"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// C++ backing class
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
@Keep
|
|
58
|
+
protected open class CxxPart(javaPart: HybridReactNativeCaptureProtectionSpec): HybridObject.CxxPart(javaPart) {
|
|
59
|
+
// C++ JHybridReactNativeCaptureProtectionSpec::CxxPart::initHybrid(...)
|
|
60
|
+
@FastNative
|
|
61
|
+
external override fun initHybrid(): HybridData
|
|
62
|
+
}
|
|
63
|
+
override fun createCxxPart(): CxxPart {
|
|
64
|
+
return CxxPart(this)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
companion object {
|
|
68
|
+
protected const val TAG = "HybridReactNativeCaptureProtectionSpec"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// reactnativecaptureprotectionOnLoad.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.reactnativecaptureprotection
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class reactnativecaptureprotectionOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "reactnativecaptureprotectionOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "reactnativecaptureprotection".
|
|
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 reactnativecaptureprotection C++ library...")
|
|
25
|
+
System.loadLibrary("reactnativecaptureprotection")
|
|
26
|
+
Log.i(TAG, "Successfully loaded reactnativecaptureprotection C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load reactnativecaptureprotection 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,81 @@
|
|
|
1
|
+
#
|
|
2
|
+
# reactnativecaptureprotection+autolinking.cmake
|
|
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 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/reactnativecaptureprotection+autolinking.cmake)
|
|
14
|
+
# ```
|
|
15
|
+
|
|
16
|
+
# Define a flag to check if we are building properly
|
|
17
|
+
add_definitions(-DBUILDING_REACTNATIVECAPTUREPROTECTION_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
|
+
reactnativecaptureprotection PRIVATE
|
|
33
|
+
# Autolinking Setup
|
|
34
|
+
../nitrogen/generated/android/reactnativecaptureprotectionOnLoad.cpp
|
|
35
|
+
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridReactNativeCaptureProtectionSpec.cpp
|
|
37
|
+
# Android-specific Nitrogen C++ sources
|
|
38
|
+
../nitrogen/generated/android/c++/JHybridReactNativeCaptureProtectionSpec.cpp
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
42
|
+
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
43
|
+
target_compile_definitions(
|
|
44
|
+
reactnativecaptureprotection PRIVATE
|
|
45
|
+
-DFOLLY_NO_CONFIG=1
|
|
46
|
+
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
47
|
+
-DFOLLY_USE_LIBCPP=1
|
|
48
|
+
-DFOLLY_CFG_NO_COROUTINES=1
|
|
49
|
+
-DFOLLY_MOBILE=1
|
|
50
|
+
-DFOLLY_HAVE_RECVMMSG=1
|
|
51
|
+
-DFOLLY_HAVE_PTHREAD=1
|
|
52
|
+
# Once we target android-23 above, we can comment
|
|
53
|
+
# the following line. NDK uses GNU style stderror_r() after API 23.
|
|
54
|
+
-DFOLLY_HAVE_XSI_STRERROR_R=1
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Add all libraries required by the generated specs
|
|
58
|
+
find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
|
|
59
|
+
find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
|
|
60
|
+
find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
|
|
61
|
+
|
|
62
|
+
# Link all libraries together
|
|
63
|
+
target_link_libraries(
|
|
64
|
+
reactnativecaptureprotection
|
|
65
|
+
fbjni::fbjni # <-- Facebook C++ JNI helpers
|
|
66
|
+
ReactAndroid::jsi # <-- RN: JSI
|
|
67
|
+
react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Link react-native (different prefab between RN 0.75 and RN 0.76)
|
|
71
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
72
|
+
target_link_libraries(
|
|
73
|
+
reactnativecaptureprotection
|
|
74
|
+
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
75
|
+
)
|
|
76
|
+
else()
|
|
77
|
+
target_link_libraries(
|
|
78
|
+
reactnativecaptureprotection
|
|
79
|
+
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
80
|
+
)
|
|
81
|
+
endif()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// reactnativecaptureprotection+autolinking.gradle
|
|
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 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/reactnativecaptureprotection+autolinking.gradle'
|
|
14
|
+
/// ```
|
|
15
|
+
|
|
16
|
+
logger.warn("[NitroModules] 🔥 reactnativecaptureprotection 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,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// reactnativecaptureprotectionOnLoad.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
|
+
#ifndef BUILDING_REACTNATIVECAPTUREPROTECTION_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
+
#error reactnativecaptureprotectionOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "reactnativecaptureprotectionOnLoad.hpp"
|
|
13
|
+
|
|
14
|
+
#include <jni.h>
|
|
15
|
+
#include <fbjni/fbjni.h>
|
|
16
|
+
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
+
|
|
18
|
+
#include "JHybridReactNativeCaptureProtectionSpec.hpp"
|
|
19
|
+
#include "JFunc_void_double.hpp"
|
|
20
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::reactnativecaptureprotection {
|
|
23
|
+
|
|
24
|
+
int initialize(JavaVM* vm) {
|
|
25
|
+
return facebook::jni::initialize(vm, []() {
|
|
26
|
+
::margelo::nitro::reactnativecaptureprotection::registerAllNatives();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
struct JHybridReactNativeCaptureProtectionSpecImpl: public jni::JavaClass<JHybridReactNativeCaptureProtectionSpecImpl, JHybridReactNativeCaptureProtectionSpec::JavaPart> {
|
|
31
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativecaptureprotection/ReactNativeCaptureProtection;";
|
|
32
|
+
static std::shared_ptr<JHybridReactNativeCaptureProtectionSpec> create() {
|
|
33
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridReactNativeCaptureProtectionSpecImpl::javaobject()>();
|
|
34
|
+
jni::local_ref<JHybridReactNativeCaptureProtectionSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
35
|
+
return javaPart->getJHybridReactNativeCaptureProtectionSpec();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
void registerAllNatives() {
|
|
40
|
+
using namespace margelo::nitro;
|
|
41
|
+
using namespace margelo::nitro::reactnativecaptureprotection;
|
|
42
|
+
|
|
43
|
+
// Register native JNI methods
|
|
44
|
+
margelo::nitro::reactnativecaptureprotection::JHybridReactNativeCaptureProtectionSpec::CxxPart::registerNatives();
|
|
45
|
+
margelo::nitro::reactnativecaptureprotection::JFunc_void_double_cxx::registerNatives();
|
|
46
|
+
|
|
47
|
+
// Register Nitro Hybrid Objects
|
|
48
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
49
|
+
"ReactNativeCaptureProtection",
|
|
50
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
51
|
+
return JHybridReactNativeCaptureProtectionSpecImpl::create();
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::reactnativecaptureprotection
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// reactnativecaptureprotectionOnLoad.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
|
+
#include <jni.h>
|
|
9
|
+
#include <functional>
|
|
10
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
11
|
+
|
|
12
|
+
namespace margelo::nitro::reactnativecaptureprotection {
|
|
13
|
+
|
|
14
|
+
[[deprecated("Use registerNatives() instead.")]]
|
|
15
|
+
int initialize(JavaVM* vm);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Register the native (C++) part of reactnativecaptureprotection, and autolinks all Hybrid Objects.
|
|
19
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
|
|
20
|
+
* inside a `facebook::jni::initialize(vm, ...)` call.
|
|
21
|
+
* Example:
|
|
22
|
+
* ```cpp (cpp-adapter.cpp)
|
|
23
|
+
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
24
|
+
* return facebook::jni::initialize(vm, []() {
|
|
25
|
+
* // register all reactnativecaptureprotection HybridObjects
|
|
26
|
+
* margelo::nitro::reactnativecaptureprotection::registerNatives();
|
|
27
|
+
* // any other custom registrations go here.
|
|
28
|
+
* });
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
void registerAllNatives();
|
|
33
|
+
|
|
34
|
+
} // namespace margelo::nitro::reactnativecaptureprotection
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ReactNativeCaptureProtection+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/ReactNativeCaptureProtection+autolinking.rb'
|
|
18
|
+
# add_nitrogen_files(spec)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
|
|
22
|
+
def add_nitrogen_files(spec)
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 ReactNativeCaptureProtection 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/ReactNativeCaptureProtection-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
|
+
# Disable auto-generated ObjC header for Swift (Static linkage on Xcode 26.4 breaks here)
|
|
60
|
+
"SWIFT_INSTALL_OBJC_HEADER" => "NO",
|
|
61
|
+
})
|
|
62
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReactNativeCaptureProtection-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 "ReactNativeCaptureProtection-Swift-Cxx-Bridge.hpp"
|
|
9
|
+
|
|
10
|
+
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridReactNativeCaptureProtectionSpecSwift.hpp"
|
|
12
|
+
#include "ReactNativeCaptureProtection-Swift-Cxx-Umbrella.hpp"
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::reactnativecaptureprotection::bridge::swift {
|
|
16
|
+
|
|
17
|
+
// pragma MARK: std::function<void()>
|
|
18
|
+
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
19
|
+
auto swiftClosure = ReactNativeCaptureProtection::Func_void::fromUnsafe(swiftClosureWrapper);
|
|
20
|
+
return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
|
|
21
|
+
swiftClosure.call();
|
|
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 = ReactNativeCaptureProtection::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(double /* event */)>
|
|
34
|
+
Func_void_double create_Func_void_double(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
35
|
+
auto swiftClosure = ReactNativeCaptureProtection::Func_void_double::fromUnsafe(swiftClosureWrapper);
|
|
36
|
+
return [swiftClosure = std::move(swiftClosure)](double event) mutable -> void {
|
|
37
|
+
swiftClosure.call(event);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// pragma MARK: std::shared_ptr<HybridReactNativeCaptureProtectionSpec>
|
|
42
|
+
std::shared_ptr<HybridReactNativeCaptureProtectionSpec> create_std__shared_ptr_HybridReactNativeCaptureProtectionSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
43
|
+
ReactNativeCaptureProtection::HybridReactNativeCaptureProtectionSpec_cxx swiftPart = ReactNativeCaptureProtection::HybridReactNativeCaptureProtectionSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
44
|
+
return std::make_shared<margelo::nitro::reactnativecaptureprotection::HybridReactNativeCaptureProtectionSpecSwift>(swiftPart);
|
|
45
|
+
}
|
|
46
|
+
void* NON_NULL get_std__shared_ptr_HybridReactNativeCaptureProtectionSpec_(std__shared_ptr_HybridReactNativeCaptureProtectionSpec_ cppType) {
|
|
47
|
+
std::shared_ptr<margelo::nitro::reactnativecaptureprotection::HybridReactNativeCaptureProtectionSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::reactnativecaptureprotection::HybridReactNativeCaptureProtectionSpecSwift>(cppType);
|
|
48
|
+
#ifdef NITRO_DEBUG
|
|
49
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
50
|
+
throw std::runtime_error("Class \"HybridReactNativeCaptureProtectionSpec\" is not implemented in Swift!");
|
|
51
|
+
}
|
|
52
|
+
#endif
|
|
53
|
+
ReactNativeCaptureProtection::HybridReactNativeCaptureProtectionSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
54
|
+
return swiftPart.toUnsafe();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::reactnativecaptureprotection::bridge::swift
|