react-native-screenshot-aware 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.
Files changed (69) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +101 -0
  3. package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeScreenshotAwareSpec.java +38 -0
  4. package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +49 -0
  5. package/android/app/build/generated/source/codegen/jni/RNScreenshotAwareSpec-generated.cpp +32 -0
  6. package/android/app/build/generated/source/codegen/jni/RNScreenshotAwareSpec.h +31 -0
  7. package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNScreenshotAwareSpec/RNScreenshotAwareSpecJSI-generated.cpp +28 -0
  8. package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNScreenshotAwareSpec/RNScreenshotAwareSpecJSI.h +67 -0
  9. package/android/build.gradle +90 -0
  10. package/android/generated/java/com/screenshotaware/NativeScreenshotAwareSpec.java +41 -0
  11. package/android/generated/jni/CMakeLists.txt +49 -0
  12. package/android/generated/jni/RNScreenshotAwareSpec-generated.cpp +38 -0
  13. package/android/generated/jni/RNScreenshotAwareSpec.h +31 -0
  14. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/ComponentDescriptors.cpp +22 -0
  15. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/ComponentDescriptors.h +24 -0
  16. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/EventEmitters.cpp +16 -0
  17. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/EventEmitters.h +17 -0
  18. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/Props.cpp +19 -0
  19. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/Props.h +18 -0
  20. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/RNScreenshotAwareSpecJSI-generated.cpp +36 -0
  21. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/RNScreenshotAwareSpecJSI.h +76 -0
  22. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/ShadowNodes.cpp +17 -0
  23. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/ShadowNodes.h +23 -0
  24. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/States.cpp +16 -0
  25. package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/States.h +19 -0
  26. package/android/gradle.properties +5 -0
  27. package/android/src/main/AndroidManifest.xml +1 -0
  28. package/android/src/main/AndroidManifestNew.xml +2 -0
  29. package/android/src/main/java/com/screenshotaware/ScreenshotAwareModule.kt +54 -0
  30. package/android/src/main/java/com/screenshotaware/ScreenshotAwarePackage.kt +34 -0
  31. package/android/src/newarch/ScreenshotAwareSpec.kt +7 -0
  32. package/android/src/oldarch/ScreenshotAwareSpec.kt +11 -0
  33. package/ios/ScreenshotAware.h +13 -0
  34. package/ios/ScreenshotAware.mm +52 -0
  35. package/ios/ScreenshotAwareImpl.h +13 -0
  36. package/ios/ScreenshotAwareImpl.mm +35 -0
  37. package/ios/generated/RNScreenshotAwareSpec/ComponentDescriptors.cpp +22 -0
  38. package/ios/generated/RNScreenshotAwareSpec/ComponentDescriptors.h +24 -0
  39. package/ios/generated/RNScreenshotAwareSpec/EventEmitters.cpp +16 -0
  40. package/ios/generated/RNScreenshotAwareSpec/EventEmitters.h +17 -0
  41. package/ios/generated/RNScreenshotAwareSpec/Props.cpp +19 -0
  42. package/ios/generated/RNScreenshotAwareSpec/Props.h +18 -0
  43. package/ios/generated/RNScreenshotAwareSpec/RCTComponentViewHelpers.h +18 -0
  44. package/ios/generated/RNScreenshotAwareSpec/RNScreenshotAwareSpec-generated.mm +36 -0
  45. package/ios/generated/RNScreenshotAwareSpec/RNScreenshotAwareSpec.h +50 -0
  46. package/ios/generated/RNScreenshotAwareSpec/ShadowNodes.cpp +17 -0
  47. package/ios/generated/RNScreenshotAwareSpec/ShadowNodes.h +23 -0
  48. package/ios/generated/RNScreenshotAwareSpec/States.cpp +16 -0
  49. package/ios/generated/RNScreenshotAwareSpec/States.h +19 -0
  50. package/ios/generated/RNScreenshotAwareSpecJSI-generated.cpp +36 -0
  51. package/ios/generated/RNScreenshotAwareSpecJSI.h +76 -0
  52. package/lib/commonjs/NativeScreenshotAware.js +9 -0
  53. package/lib/commonjs/NativeScreenshotAware.js.map +1 -0
  54. package/lib/commonjs/index.js +25 -0
  55. package/lib/commonjs/index.js.map +1 -0
  56. package/lib/commonjs/package.json +1 -0
  57. package/lib/module/NativeScreenshotAware.js +5 -0
  58. package/lib/module/NativeScreenshotAware.js.map +1 -0
  59. package/lib/module/index.js +19 -0
  60. package/lib/module/index.js.map +1 -0
  61. package/lib/module/package.json +1 -0
  62. package/lib/typescript/NativeScreenshotAware.d.ts +8 -0
  63. package/lib/typescript/NativeScreenshotAware.d.ts.map +1 -0
  64. package/lib/typescript/index.d.ts +7 -0
  65. package/lib/typescript/index.d.ts.map +1 -0
  66. package/package.json +133 -0
  67. package/react-native-screenshot-aware.podspec +23 -0
  68. package/src/NativeScreenshotAware.ts +9 -0
  69. package/src/index.tsx +23 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Hugo EXTRAT
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # React Native Screenshot Aware
2
+
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/react-native-screenshot-aware"><img src="https://img.shields.io/npm/v/react-native-screenshot-aware.svg?style=flat-square" alt="npm version"></a>
5
+ <a href="https://www.npmjs.com/package/react-native-screenshot-aware"><img src="https://img.shields.io/npm/dm/react-native-screenshot-aware.svg?style=flat-square" alt="npm downloads"></a>
6
+ <a href="https://github.com/huextrat/react-native-screenshot-aware/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/react-native-screenshot-aware.svg?style=flat-square" alt="license"></a>
7
+ </p>
8
+
9
+ <h3 align="center">
10
+ Real-time screenshot detection for React Native apps
11
+ </h3>
12
+
13
+ ## Features
14
+
15
+ - 🚀 Real-time screenshot detection
16
+ - 🔄 Cross-platform support (iOS & Android)
17
+ - 🎣 Easy-to-use React hooks
18
+ - ⚡ Optimized for performance
19
+ - 📱 Supports Android 14+ (API level 34+) and iOS 14+
20
+ - 🏗️ Supports the new architecture for React Native
21
+
22
+ ## Installation
23
+
24
+ ```sh
25
+ yarn add react-native-screenshot-aware
26
+ ```
27
+ or
28
+ ```sh
29
+ npm install react-native-screenshot-aware
30
+ ```
31
+
32
+ ## Important Notes
33
+
34
+ ### Android
35
+ - Supports Android 14+ (API level 34 and above)
36
+ - Utilizes the latest Android API for efficient screenshot detection
37
+ - Leverages the new `DETECT_SCREEN_CAPTURE` permission introduced in Android 14
38
+ - Provides a more privacy-friendly and performant approach to screenshot detection
39
+
40
+ > **Note**: Callbacks will never be triggered on devices running Android versions below 14. This is due to the reliance on the new `DETECT_SCREEN_CAPTURE` permission and APIs introduced in Android 14, which are not available in earlier versions.
41
+
42
+ > **Note**: The decision to support only Android 14+ is based on the introduction of new, dedicated screenshot detection APIs. These APIs offer improved performance and respect user privacy better than previous methods. For more details, see the [Android 14 screenshot detection documentation](https://developer.android.com/about/versions/14/features/screenshot-detection).
43
+
44
+ ## API Reference
45
+
46
+ ### `useScreenshotAware(callback)`
47
+
48
+ This hook allows you to detect when a screenshot is taken on the device. It takes a callback function as an argument, which will be executed whenever a screenshot event is detected.
49
+
50
+ #### Parameters
51
+
52
+ - `callback` (function): A function to be called when a screenshot is detected. This function does not take any arguments.
53
+
54
+ #### Example
55
+
56
+ ```javascript
57
+ import { useScreenshotAware } from 'react-native-screenshot-aware';
58
+
59
+ useScreenshotAware(() => {
60
+ console.log('A screenshot was taken!');
61
+ });
62
+ ```
63
+
64
+ ### `addListener(callback)`
65
+
66
+ This function allows you to add a listener for the screenshot event. It takes a callback function as an argument, which will be executed whenever a screenshot event is detected.
67
+
68
+ #### Parameters
69
+
70
+ - `callback` (function): A function to be called when a screenshot is detected. This function does not take any arguments.
71
+
72
+ #### Example
73
+
74
+ ```javascript
75
+ import ScreenshotAware from 'react-native-screenshot-aware';
76
+
77
+ useEffect(() => {
78
+ const listener = ScreenshotAware.addListener(() => {
79
+ console.log('A screenshot was taken!');
80
+ });
81
+ return () => {
82
+ listener.remove();
83
+ }
84
+ }, [])
85
+ ```
86
+
87
+ ## Contributing
88
+
89
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for more details.
90
+
91
+ ## License
92
+
93
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
94
+
95
+ ## Support
96
+
97
+ If you like this project, please consider supporting it by giving it a ⭐️ on GitHub!
98
+
99
+ ## Acknowledgements
100
+
101
+ - [create-react-native-library](https://github.com/callstack/react-native-builder-bob) for the initial project setup
@@ -0,0 +1,38 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJavaSpec.js
9
+ *
10
+ * @nolint
11
+ */
12
+
13
+ package com.facebook.fbreact.specs;
14
+
15
+ import com.facebook.proguard.annotations.DoNotStrip;
16
+ import com.facebook.react.bridge.Promise;
17
+ import com.facebook.react.bridge.ReactApplicationContext;
18
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
19
+ import com.facebook.react.bridge.ReactMethod;
20
+ import com.facebook.react.turbomodule.core.interfaces.TurboModule;
21
+ import javax.annotation.Nonnull;
22
+
23
+ public abstract class NativeScreenshotAwareSpec extends ReactContextBaseJavaModule implements TurboModule {
24
+ public static final String NAME = "ScreenshotAware";
25
+
26
+ public NativeScreenshotAwareSpec(ReactApplicationContext reactContext) {
27
+ super(reactContext);
28
+ }
29
+
30
+ @Override
31
+ public @Nonnull String getName() {
32
+ return NAME;
33
+ }
34
+
35
+ @ReactMethod
36
+ @DoNotStrip
37
+ public abstract void multiply(double a, double b, Promise promise);
38
+ }
@@ -0,0 +1,49 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ cmake_minimum_required(VERSION 3.13)
7
+ set(CMAKE_VERBOSE_MAKEFILE on)
8
+
9
+ file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNScreenshotAwareSpec/*.cpp)
10
+
11
+ add_library(
12
+ react_codegen_RNScreenshotAwareSpec
13
+ SHARED
14
+ ${react_codegen_SRCS}
15
+ )
16
+
17
+ target_include_directories(react_codegen_RNScreenshotAwareSpec PUBLIC . react/renderer/components/RNScreenshotAwareSpec)
18
+
19
+ target_link_libraries(
20
+ react_codegen_RNScreenshotAwareSpec
21
+ fbjni
22
+ folly_runtime
23
+ glog
24
+ jsi
25
+ react_codegen_rncore
26
+ react_debug
27
+ react_nativemodule_core
28
+ react_render_componentregistry
29
+ react_render_core
30
+ react_render_debug
31
+ react_render_graphics
32
+ react_render_imagemanager
33
+ react_render_mapbuffer
34
+ react_utils
35
+ rrc_image
36
+ rrc_view
37
+ turbomodulejsijni
38
+ yoga
39
+ )
40
+
41
+ target_compile_options(
42
+ react_codegen_RNScreenshotAwareSpec
43
+ PRIVATE
44
+ -DLOG_TAG=\"ReactNative\"
45
+ -fexceptions
46
+ -frtti
47
+ -std=c++20
48
+ -Wall
49
+ )
@@ -0,0 +1,32 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "RNScreenshotAwareSpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+ static facebook::jsi::Value __hostFunction_NativeScreenshotAwareSpecJSI_multiply(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16
+ static jmethodID cachedMethodId = nullptr;
17
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "multiply", "(DDLcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
18
+ }
19
+
20
+ NativeScreenshotAwareSpecJSI::NativeScreenshotAwareSpecJSI(const JavaTurboModule::InitParams &params)
21
+ : JavaTurboModule(params) {
22
+ methodMap_["multiply"] = MethodMetadata {2, __hostFunction_NativeScreenshotAwareSpecJSI_multiply};
23
+ }
24
+
25
+ std::shared_ptr<TurboModule> RNScreenshotAwareSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
26
+ if (moduleName == "ScreenshotAware") {
27
+ return std::make_shared<NativeScreenshotAwareSpecJSI>(params);
28
+ }
29
+ return nullptr;
30
+ }
31
+
32
+ } // namespace facebook::react
@@ -0,0 +1,31 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <ReactCommon/JavaTurboModule.h>
14
+ #include <ReactCommon/TurboModule.h>
15
+ #include <jsi/jsi.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ /**
20
+ * JNI C++ class for module 'NativeScreenshotAware'
21
+ */
22
+ class JSI_EXPORT NativeScreenshotAwareSpecJSI : public JavaTurboModule {
23
+ public:
24
+ NativeScreenshotAwareSpecJSI(const JavaTurboModule::InitParams &params);
25
+ };
26
+
27
+
28
+ JSI_EXPORT
29
+ std::shared_ptr<TurboModule> RNScreenshotAwareSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
30
+
31
+ } // namespace facebook::react
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "RNScreenshotAwareSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+ static jsi::Value __hostFunction_NativeScreenshotAwareCxxSpecJSI_multiply(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
+ return static_cast<NativeScreenshotAwareCxxSpecJSI *>(&turboModule)->multiply(
16
+ rt,
17
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber(),
18
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asNumber()
19
+ );
20
+ }
21
+
22
+ NativeScreenshotAwareCxxSpecJSI::NativeScreenshotAwareCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
23
+ : TurboModule("ScreenshotAware", jsInvoker) {
24
+ methodMap_["multiply"] = MethodMetadata {2, __hostFunction_NativeScreenshotAwareCxxSpecJSI_multiply};
25
+ }
26
+
27
+
28
+ } // namespace facebook::react
@@ -0,0 +1,67 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleH.js
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include <ReactCommon/TurboModule.h>
13
+ #include <react/bridging/Bridging.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+ class JSI_EXPORT NativeScreenshotAwareCxxSpecJSI : public TurboModule {
19
+ protected:
20
+ NativeScreenshotAwareCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
21
+
22
+ public:
23
+ virtual jsi::Value multiply(jsi::Runtime &rt, double a, double b) = 0;
24
+
25
+ };
26
+
27
+ template <typename T>
28
+ class JSI_EXPORT NativeScreenshotAwareCxxSpec : public TurboModule {
29
+ public:
30
+ jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
31
+ return delegate_.get(rt, propName);
32
+ }
33
+
34
+ static constexpr std::string_view kModuleName = "ScreenshotAware";
35
+
36
+ protected:
37
+ NativeScreenshotAwareCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
38
+ : TurboModule(std::string{NativeScreenshotAwareCxxSpec::kModuleName}, jsInvoker),
39
+ delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
40
+
41
+
42
+ private:
43
+ class Delegate : public NativeScreenshotAwareCxxSpecJSI {
44
+ public:
45
+ Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
46
+ NativeScreenshotAwareCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
47
+
48
+ }
49
+
50
+ jsi::Value multiply(jsi::Runtime &rt, double a, double b) override {
51
+ static_assert(
52
+ bridging::getParameterCount(&T::multiply) == 3,
53
+ "Expected multiply(...) to have 3 parameters");
54
+
55
+ return bridging::callFromJs<jsi::Value>(
56
+ rt, &T::multiply, jsInvoker_, instance_, std::move(a), std::move(b));
57
+ }
58
+
59
+ private:
60
+ friend class NativeScreenshotAwareCxxSpec;
61
+ T *instance_;
62
+ };
63
+
64
+ Delegate delegate_;
65
+ };
66
+
67
+ } // namespace facebook::react
@@ -0,0 +1,90 @@
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["ScreenshotAware_kotlinVersion"]
4
+
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath "com.android.tools.build:gradle:7.2.1"
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
16
+
17
+ def isNewArchitectureEnabled() {
18
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19
+ }
20
+
21
+ apply plugin: "com.android.library"
22
+ apply plugin: "kotlin-android"
23
+
24
+ if (isNewArchitectureEnabled()) {
25
+ apply plugin: "com.facebook.react"
26
+ }
27
+
28
+ def getExtOrDefault(name) {
29
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ScreenshotAware_" + name]
30
+ }
31
+
32
+ def getExtOrIntegerDefault(name) {
33
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ScreenshotAware_" + name]).toInteger()
34
+ }
35
+
36
+ android {
37
+ def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
38
+ if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
39
+ namespace "com.screenshotaware"
40
+ }
41
+
42
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
43
+
44
+ defaultConfig {
45
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
46
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
47
+ }
48
+
49
+ buildFeatures {
50
+ buildConfig true
51
+ }
52
+
53
+ buildTypes {
54
+ release {
55
+ minifyEnabled false
56
+ }
57
+ }
58
+
59
+ lintOptions {
60
+ disable "GradleCompatible"
61
+ }
62
+
63
+ compileOptions {
64
+ sourceCompatibility JavaVersion.VERSION_1_8
65
+ targetCompatibility JavaVersion.VERSION_1_8
66
+ }
67
+
68
+ sourceSets {
69
+ main {
70
+ if (isNewArchitectureEnabled()) {
71
+ java.srcDirs += ["src/newarch"]
72
+ } else {
73
+ java.srcDirs += ["src/oldarch"]
74
+ }
75
+ }
76
+ }
77
+ }
78
+
79
+ repositories {
80
+ mavenCentral()
81
+ google()
82
+ }
83
+
84
+ def kotlin_version = getExtOrDefault("kotlinVersion")
85
+
86
+ dependencies {
87
+ //noinspection GradleDynamicVersion
88
+ implementation "com.facebook.react:react-native:+"
89
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
90
+ }
@@ -0,0 +1,41 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJavaSpec.js
9
+ *
10
+ * @nolint
11
+ */
12
+
13
+ package com.screenshotaware;
14
+
15
+ import com.facebook.proguard.annotations.DoNotStrip;
16
+ import com.facebook.react.bridge.ReactApplicationContext;
17
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
18
+ import com.facebook.react.bridge.ReactMethod;
19
+ import com.facebook.react.turbomodule.core.interfaces.TurboModule;
20
+ import javax.annotation.Nonnull;
21
+
22
+ public abstract class NativeScreenshotAwareSpec extends ReactContextBaseJavaModule implements TurboModule {
23
+ public static final String NAME = "ScreenshotAware";
24
+
25
+ public NativeScreenshotAwareSpec(ReactApplicationContext reactContext) {
26
+ super(reactContext);
27
+ }
28
+
29
+ @Override
30
+ public @Nonnull String getName() {
31
+ return NAME;
32
+ }
33
+
34
+ @ReactMethod
35
+ @DoNotStrip
36
+ public abstract void addListener(String eventName);
37
+
38
+ @ReactMethod
39
+ @DoNotStrip
40
+ public abstract void removeListeners(double count);
41
+ }
@@ -0,0 +1,49 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ cmake_minimum_required(VERSION 3.13)
7
+ set(CMAKE_VERBOSE_MAKEFILE on)
8
+
9
+ file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNScreenshotAwareSpec/*.cpp)
10
+
11
+ add_library(
12
+ react_codegen_RNScreenshotAwareSpec
13
+ SHARED
14
+ ${react_codegen_SRCS}
15
+ )
16
+
17
+ target_include_directories(react_codegen_RNScreenshotAwareSpec PUBLIC . react/renderer/components/RNScreenshotAwareSpec)
18
+
19
+ target_link_libraries(
20
+ react_codegen_RNScreenshotAwareSpec
21
+ fbjni
22
+ folly_runtime
23
+ glog
24
+ jsi
25
+ react_codegen_rncore
26
+ react_debug
27
+ react_nativemodule_core
28
+ react_render_componentregistry
29
+ react_render_core
30
+ react_render_debug
31
+ react_render_graphics
32
+ react_render_imagemanager
33
+ react_render_mapbuffer
34
+ react_utils
35
+ rrc_image
36
+ rrc_view
37
+ turbomodulejsijni
38
+ yoga
39
+ )
40
+
41
+ target_compile_options(
42
+ react_codegen_RNScreenshotAwareSpec
43
+ PRIVATE
44
+ -DLOG_TAG=\"ReactNative\"
45
+ -fexceptions
46
+ -frtti
47
+ -std=c++20
48
+ -Wall
49
+ )
@@ -0,0 +1,38 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "RNScreenshotAwareSpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+ static facebook::jsi::Value __hostFunction_NativeScreenshotAwareSpecJSI_addListener(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16
+ static jmethodID cachedMethodId = nullptr;
17
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "addListener", "(Ljava/lang/String;)V", args, count, cachedMethodId);
18
+ }
19
+
20
+ static facebook::jsi::Value __hostFunction_NativeScreenshotAwareSpecJSI_removeListeners(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
21
+ static jmethodID cachedMethodId = nullptr;
22
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "removeListeners", "(D)V", args, count, cachedMethodId);
23
+ }
24
+
25
+ NativeScreenshotAwareSpecJSI::NativeScreenshotAwareSpecJSI(const JavaTurboModule::InitParams &params)
26
+ : JavaTurboModule(params) {
27
+ methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeScreenshotAwareSpecJSI_addListener};
28
+ methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeScreenshotAwareSpecJSI_removeListeners};
29
+ }
30
+
31
+ std::shared_ptr<TurboModule> RNScreenshotAwareSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
32
+ if (moduleName == "ScreenshotAware") {
33
+ return std::make_shared<NativeScreenshotAwareSpecJSI>(params);
34
+ }
35
+ return nullptr;
36
+ }
37
+
38
+ } // namespace facebook::react
@@ -0,0 +1,31 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <ReactCommon/JavaTurboModule.h>
14
+ #include <ReactCommon/TurboModule.h>
15
+ #include <jsi/jsi.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ /**
20
+ * JNI C++ class for module 'NativeScreenshotAware'
21
+ */
22
+ class JSI_EXPORT NativeScreenshotAwareSpecJSI : public JavaTurboModule {
23
+ public:
24
+ NativeScreenshotAwareSpecJSI(const JavaTurboModule::InitParams &params);
25
+ };
26
+
27
+
28
+ JSI_EXPORT
29
+ std::shared_ptr<TurboModule> RNScreenshotAwareSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
30
+
31
+ } // namespace facebook::react
@@ -0,0 +1,22 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorCpp.js
9
+ */
10
+
11
+ #include "ComponentDescriptors.h"
12
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
13
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
14
+
15
+ namespace facebook::react {
16
+
17
+ void RNScreenshotAwareSpec_registerComponentDescriptorsFromCodegen(
18
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
19
+
20
+ }
21
+
22
+ } // namespace facebook::react
@@ -0,0 +1,24 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "ShadowNodes.h"
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
16
+
17
+ namespace facebook::react {
18
+
19
+
20
+
21
+ void RNScreenshotAwareSpec_registerComponentDescriptorsFromCodegen(
22
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
23
+
24
+ } // namespace facebook::react