@kobe-brants/react-native-keep-awake 1.0.6

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 (37) hide show
  1. package/KeepAwake.podspec +41 -0
  2. package/LICENSE +20 -0
  3. package/README.md +33 -0
  4. package/android/CMakeLists.txt +15 -0
  5. package/android/build.gradle +139 -0
  6. package/android/cpp-adapter.cpp +8 -0
  7. package/android/generated/jni/CMakeLists.txt +36 -0
  8. package/android/generated/jni/RNKeepAwakeSpec-generated.cpp +22 -0
  9. package/android/generated/jni/RNKeepAwakeSpec.h +24 -0
  10. package/android/generated/jni/react/renderer/components/RNKeepAwakeSpec/RNKeepAwakeSpecJSI-generated.cpp +17 -0
  11. package/android/generated/jni/react/renderer/components/RNKeepAwakeSpec/RNKeepAwakeSpecJSI.h +19 -0
  12. package/android/gradle.properties +5 -0
  13. package/android/src/main/AndroidManifest.xml +3 -0
  14. package/android/src/main/AndroidManifestNew.xml +2 -0
  15. package/android/src/main/java/com/keepawake/KeepAwakeModule.kt +43 -0
  16. package/android/src/main/java/com/keepawake/KeepAwakePackage.kt +33 -0
  17. package/cpp/react-native-keep-awake.cpp +7 -0
  18. package/cpp/react-native-keep-awake.h +8 -0
  19. package/ios/KeepAwake.h +9 -0
  20. package/ios/KeepAwake.mm +20 -0
  21. package/ios/generated/RNKeepAwakeSpec/RNKeepAwakeSpec-generated.mm +16 -0
  22. package/ios/generated/RNKeepAwakeSpec/RNKeepAwakeSpec.h +38 -0
  23. package/ios/generated/RNKeepAwakeSpecJSI-generated.cpp +17 -0
  24. package/ios/generated/RNKeepAwakeSpecJSI.h +19 -0
  25. package/lib/commonjs/index.js +31 -0
  26. package/lib/commonjs/index.js.map +1 -0
  27. package/lib/module/index.js +26 -0
  28. package/lib/module/index.js.map +1 -0
  29. package/lib/typescript/commonjs/package.json +1 -0
  30. package/lib/typescript/commonjs/src/index.d.ts +13 -0
  31. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  32. package/lib/typescript/module/package.json +1 -0
  33. package/lib/typescript/module/src/index.d.ts +13 -0
  34. package/lib/typescript/module/src/index.d.ts.map +1 -0
  35. package/package.json +204 -0
  36. package/react-native.config.js +12 -0
  37. package/src/index.tsx +26 -0
@@ -0,0 +1,41 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "KeepAwake"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => min_ios_version_supported }
15
+ s.source = { :git => "https://github.com/Kobe-Brants/react-native-keep-awake.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}"
18
+
19
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21
+ if respond_to?(:install_modules_dependencies, true)
22
+ install_modules_dependencies(s)
23
+ else
24
+ s.dependency "React-Core"
25
+
26
+ # Don't install the dependencies when we run `pod install` in the old architecture.
27
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
28
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
29
+ s.pod_target_xcconfig = {
30
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
31
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
32
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
33
+ }
34
+ s.dependency "React-Codegen"
35
+ s.dependency "RCT-Folly"
36
+ s.dependency "RCTRequired"
37
+ s.dependency "RCTTypeSafety"
38
+ s.dependency "ReactCommon/turbomodule/core"
39
+ end
40
+ end
41
+ end
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kobe Brants
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,33 @@
1
+ # react-native-keep-awake
2
+
3
+ Keep device screen awake for React Native
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install react-native-keep-awake
9
+ ```
10
+
11
+ ## Usage
12
+
13
+
14
+ ```js
15
+ import { multiply } from 'react-native-keep-awake';
16
+
17
+ // ...
18
+
19
+ const result = multiply(3, 7);
20
+ ```
21
+
22
+
23
+ ## Contributing
24
+
25
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
26
+
27
+ ## License
28
+
29
+ MIT
30
+
31
+ ---
32
+
33
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -0,0 +1,15 @@
1
+ cmake_minimum_required(VERSION 3.4.1)
2
+ project(KeepAwake)
3
+
4
+ set (CMAKE_VERBOSE_MAKEFILE ON)
5
+ set (CMAKE_CXX_STANDARD 14)
6
+
7
+ add_library(react-native-keep-awake SHARED
8
+ ../cpp/react-native-keep-awake.cpp
9
+ cpp-adapter.cpp
10
+ )
11
+
12
+ # Specifies a path to native header files.
13
+ include_directories(
14
+ ../cpp
15
+ )
@@ -0,0 +1,139 @@
1
+ buildscript {
2
+ ext.getExtOrDefault = {name ->
3
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['KeepAwake_' + name]
4
+ }
5
+
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ }
10
+
11
+ dependencies {
12
+ classpath "com.android.tools.build:gradle:8.7.2"
13
+ // noinspection DifferentKotlinGradleVersion
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15
+ }
16
+ }
17
+
18
+ def reactNativeArchitectures() {
19
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
20
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
21
+ }
22
+
23
+ def isNewArchitectureEnabled() {
24
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
25
+ }
26
+
27
+ apply plugin: "com.android.library"
28
+ apply plugin: "kotlin-android"
29
+
30
+ if (isNewArchitectureEnabled()) {
31
+ apply plugin: "com.facebook.react"
32
+ }
33
+
34
+ def getExtOrIntegerDefault(name) {
35
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["KeepAwake_" + name]).toInteger()
36
+ }
37
+
38
+ def supportsNamespace() {
39
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
40
+ def major = parsed[0].toInteger()
41
+ def minor = parsed[1].toInteger()
42
+
43
+ // Namespace support was added in 7.3.0
44
+ return (major == 7 && minor >= 3) || major >= 8
45
+ }
46
+
47
+ android {
48
+ if (supportsNamespace()) {
49
+ namespace "com.keepawake"
50
+
51
+ sourceSets {
52
+ main {
53
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
54
+ }
55
+ }
56
+ }
57
+
58
+ ndkVersion getExtOrDefault("ndkVersion")
59
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
60
+
61
+ defaultConfig {
62
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
63
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
64
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
65
+
66
+ externalNativeBuild {
67
+ cmake {
68
+ cppFlags "-frtti -fexceptions -Wall -fstack-protector-all"
69
+ arguments "-DANDROID_STL=c++_shared"
70
+ abiFilters (*reactNativeArchitectures())
71
+
72
+ buildTypes {
73
+ debug {
74
+ cppFlags "-O1 -g"
75
+ }
76
+ release {
77
+ cppFlags "-O2"
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+
84
+ externalNativeBuild {
85
+ cmake {
86
+ path "CMakeLists.txt"
87
+ }
88
+ }
89
+
90
+ buildFeatures {
91
+ buildConfig true
92
+ }
93
+
94
+ buildTypes {
95
+ release {
96
+ minifyEnabled false
97
+ }
98
+ }
99
+
100
+ lintOptions {
101
+ disable "GradleCompatible"
102
+ }
103
+
104
+ compileOptions {
105
+ sourceCompatibility JavaVersion.VERSION_1_8
106
+ targetCompatibility JavaVersion.VERSION_1_8
107
+ }
108
+
109
+ sourceSets {
110
+ main {
111
+ if (isNewArchitectureEnabled()) {
112
+ java.srcDirs += [
113
+ "generated/java",
114
+ "generated/jni"
115
+ ]
116
+ }
117
+ }
118
+ }
119
+ }
120
+
121
+ repositories {
122
+ mavenCentral()
123
+ google()
124
+ }
125
+
126
+ def kotlin_version = getExtOrDefault("kotlinVersion")
127
+
128
+ dependencies {
129
+ implementation "com.facebook.react:react-android"
130
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
131
+ }
132
+
133
+ if (isNewArchitectureEnabled()) {
134
+ react {
135
+ jsRootDir = file("../src/")
136
+ libraryName = "KeepAwake"
137
+ codegenJavaPackageName = "com.keepawake"
138
+ }
139
+ }
@@ -0,0 +1,8 @@
1
+ #include <jni.h>
2
+ #include "react-native-keep-awake.h"
3
+
4
+ extern "C"
5
+ JNIEXPORT jdouble JNICALL
6
+ Java_com_keepawake_KeepAwakeModule_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) {
7
+ return keepawake::multiply(a, b);
8
+ }
@@ -0,0 +1,36 @@
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/RNKeepAwakeSpec/*.cpp)
10
+
11
+ add_library(
12
+ react_codegen_RNKeepAwakeSpec
13
+ OBJECT
14
+ ${react_codegen_SRCS}
15
+ )
16
+
17
+ target_include_directories(react_codegen_RNKeepAwakeSpec PUBLIC . react/renderer/components/RNKeepAwakeSpec)
18
+
19
+ target_link_libraries(
20
+ react_codegen_RNKeepAwakeSpec
21
+ fbjni
22
+ jsi
23
+ # We need to link different libraries based on whether we are building rncore or not, that's necessary
24
+ # because we want to break a circular dependency between react_codegen_rncore and reactnative
25
+ reactnative
26
+ )
27
+
28
+ target_compile_options(
29
+ react_codegen_RNKeepAwakeSpec
30
+ PRIVATE
31
+ -DLOG_TAG=\"ReactNative\"
32
+ -fexceptions
33
+ -frtti
34
+ -std=c++20
35
+ -Wall
36
+ )
@@ -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: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "RNKeepAwakeSpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+
16
+
17
+ std::shared_ptr<TurboModule> RNKeepAwakeSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
18
+
19
+ return nullptr;
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: 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
+
21
+ JSI_EXPORT
22
+ std::shared_ptr<TurboModule> RNKeepAwakeSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
23
+
24
+ } // namespace facebook::react
@@ -0,0 +1,17 @@
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 "RNKeepAwakeSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+
15
+
16
+
17
+ } // namespace facebook::react
@@ -0,0 +1,19 @@
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
+
19
+ } // namespace facebook::react
@@ -0,0 +1,5 @@
1
+ KeepAwake_kotlinVersion=2.0.21
2
+ KeepAwake_minSdkVersion=24
3
+ KeepAwake_targetSdkVersion=34
4
+ KeepAwake_compileSdkVersion=35
5
+ KeepAwake_ndkVersion=27.1.12297006
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.keepawake">
3
+ </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,43 @@
1
+ package com.keepawake
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.module.annotations.ReactModule
5
+
6
+ @ReactModule(name = KeepAwakeModule.NAME)
7
+ class KeepAwakeModule(reactContext: ReactApplicationContext) :
8
+ NativeKeepAwakeSpec(reactContext) {
9
+
10
+ override fun getName(): String {
11
+ return NAME
12
+ }
13
+
14
+ @ReactMethod
15
+ public void activate() {
16
+ final Activity activity = getCurrentActivity();
17
+ if (activity != null) {
18
+ activity.runOnUiThread(new Runnable() {
19
+ @Override
20
+ public void run() {
21
+ activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
22
+ }
23
+ });
24
+ }
25
+ }
26
+
27
+ @ReactMethod
28
+ public void deactivate() {
29
+ final Activity activity = getCurrentActivity();
30
+ if (activity != null) {
31
+ activity.runOnUiThread(new Runnable() {
32
+ @Override
33
+ public void run() {
34
+ activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
35
+ }
36
+ });
37
+ }
38
+ }
39
+
40
+ companion object {
41
+ const val NAME = "KeepAwake"
42
+ }
43
+ }
@@ -0,0 +1,33 @@
1
+ package com.keepawake
2
+
3
+ import com.facebook.react.BaseReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.model.ReactModuleInfo
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
8
+ import java.util.HashMap
9
+
10
+ class KeepAwakePackage : BaseReactPackage() {
11
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
+ return if (name == KeepAwakeModule.NAME) {
13
+ KeepAwakeModule(reactContext)
14
+ } else {
15
+ null
16
+ }
17
+ }
18
+
19
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
20
+ return ReactModuleInfoProvider {
21
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
22
+ moduleInfos[KeepAwakeModule.NAME] = ReactModuleInfo(
23
+ KeepAwakeModule.NAME,
24
+ KeepAwakeModule.NAME,
25
+ false, // canOverrideExistingModule
26
+ false, // needsEagerInit
27
+ false, // isCxxModule
28
+ true // isTurboModule
29
+ )
30
+ moduleInfos
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,7 @@
1
+ #include "react-native-keep-awake.h"
2
+
3
+ namespace keepawake {
4
+ double multiply(double a, double b) {
5
+ return a * b;
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef KEEPAWAKE_H
2
+ #define KEEPAWAKE_H
3
+
4
+ namespace keepawake {
5
+ double multiply(double a, double b);
6
+ }
7
+
8
+ #endif /* KEEPAWAKE_H */
@@ -0,0 +1,9 @@
1
+ #ifdef __cplusplus
2
+ #import "react-native-keep-awake.h"
3
+ #endif
4
+
5
+ #import "generated/RNKeepAwakeSpec/RNKeepAwakeSpec.h"
6
+
7
+ @interface KeepAwake : NSObject <NativeKeepAwakeSpec>
8
+
9
+ @end
@@ -0,0 +1,20 @@
1
+ #import "KeepAwake.h"
2
+
3
+ @implementation KeepAwake
4
+ RCT_EXPORT_MODULE()
5
+
6
+ RCT_EXPORT_METHOD(activate)
7
+ {
8
+ dispatch_async(dispatch_get_main_queue(), ^{
9
+ [UIApplication sharedApplication].idleTimerDisabled = YES;
10
+ });
11
+ }
12
+
13
+ RCT_EXPORT_METHOD(deactivate)
14
+ {
15
+ dispatch_async(dispatch_get_main_queue(), ^{
16
+ [UIApplication sharedApplication].idleTimerDisabled = NO;
17
+ });
18
+ }
19
+
20
+ @end
@@ -0,0 +1,16 @@
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: GenerateModuleObjCpp
8
+ *
9
+ * We create an umbrella header (and corresponding implementation) here since
10
+ * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
11
+ * must have a single output. More files => more genrule()s => slower builds.
12
+ */
13
+
14
+ #import "RNKeepAwakeSpec.h"
15
+
16
+
@@ -0,0 +1,38 @@
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: GenerateModuleObjCpp
8
+ *
9
+ * We create an umbrella header (and corresponding implementation) here since
10
+ * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
11
+ * must have a single output. More files => more genrule()s => slower builds.
12
+ */
13
+
14
+ #ifndef __cplusplus
15
+ #error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
16
+ #endif
17
+
18
+ // Avoid multiple includes of RNKeepAwakeSpec symbols
19
+ #ifndef RNKeepAwakeSpec_H
20
+ #define RNKeepAwakeSpec_H
21
+
22
+ #import <Foundation/Foundation.h>
23
+ #import <RCTRequired/RCTRequired.h>
24
+ #import <RCTTypeSafety/RCTConvertHelpers.h>
25
+ #import <RCTTypeSafety/RCTTypedModuleConstants.h>
26
+ #import <React/RCTBridgeModule.h>
27
+ #import <React/RCTCxxConvert.h>
28
+ #import <React/RCTManagedPointer.h>
29
+ #import <ReactCommon/RCTTurboModule.h>
30
+ #import <optional>
31
+ #import <vector>
32
+
33
+
34
+ NS_ASSUME_NONNULL_BEGIN
35
+
36
+
37
+ NS_ASSUME_NONNULL_END
38
+ #endif // RNKeepAwakeSpec_H
@@ -0,0 +1,17 @@
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 "RNKeepAwakeSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+
15
+
16
+
17
+ } // namespace facebook::react
@@ -0,0 +1,19 @@
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
+
19
+ } // namespace facebook::react
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _react = require("react");
9
+ const {
10
+ MyKeepAwake
11
+ } = _reactNative.NativeModules;
12
+
13
+ // Create a React component for declarative usage
14
+
15
+ class KeepAwake extends _react.Component {
16
+ componentDidMount() {
17
+ MyKeepAwake.activate();
18
+ }
19
+ componentWillUnmount() {
20
+ MyKeepAwake.deactivate();
21
+ }
22
+ render() {
23
+ return null;
24
+ }
25
+ }
26
+ var _default = exports.default = {
27
+ activate: () => MyKeepAwake.activate(),
28
+ deactivate: () => MyKeepAwake.deactivate(),
29
+ KeepAwake
30
+ };
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_react","MyKeepAwake","NativeModules","KeepAwake","Component","componentDidMount","activate","componentWillUnmount","deactivate","render","_default","exports","default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AAHA,MAAM;EAAEE;AAAY,CAAC,GAAGC,0BAAa;;AAErC;;AAGA,MAAMC,SAAS,SAASC,gBAAS,CAAC;EAChCC,iBAAiBA,CAAA,EAAG;IAClBJ,WAAW,CAACK,QAAQ,CAAC,CAAC;EACxB;EAEAC,oBAAoBA,CAAA,EAAG;IACrBN,WAAW,CAACO,UAAU,CAAC,CAAC;EAC1B;EAEAC,MAAMA,CAAA,EAAG;IACP,OAAO,IAAI;EACb;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc;EACbN,QAAQ,EAAEA,CAAA,KAAML,WAAW,CAACK,QAAQ,CAAC,CAAC;EACtCE,UAAU,EAAEA,CAAA,KAAMP,WAAW,CAACO,UAAU,CAAC,CAAC;EAC1CL;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ import { NativeModules } from 'react-native';
4
+ const {
5
+ MyKeepAwake
6
+ } = NativeModules;
7
+
8
+ // Create a React component for declarative usage
9
+ import { Component } from 'react';
10
+ class KeepAwake extends Component {
11
+ componentDidMount() {
12
+ MyKeepAwake.activate();
13
+ }
14
+ componentWillUnmount() {
15
+ MyKeepAwake.deactivate();
16
+ }
17
+ render() {
18
+ return null;
19
+ }
20
+ }
21
+ export default {
22
+ activate: () => MyKeepAwake.activate(),
23
+ deactivate: () => MyKeepAwake.deactivate(),
24
+ KeepAwake
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","MyKeepAwake","Component","KeepAwake","componentDidMount","activate","componentWillUnmount","deactivate","render"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AAE5C,MAAM;EAAEC;AAAY,CAAC,GAAGD,aAAa;;AAErC;AACA,SAASE,SAAS,QAAQ,OAAO;AAEjC,MAAMC,SAAS,SAASD,SAAS,CAAC;EAChCE,iBAAiBA,CAAA,EAAG;IAClBH,WAAW,CAACI,QAAQ,CAAC,CAAC;EACxB;EAEAC,oBAAoBA,CAAA,EAAG;IACrBL,WAAW,CAACM,UAAU,CAAC,CAAC;EAC1B;EAEAC,MAAMA,CAAA,EAAG;IACP,OAAO,IAAI;EACb;AACF;AAEA,eAAe;EACbH,QAAQ,EAAEA,CAAA,KAAMJ,WAAW,CAACI,QAAQ,CAAC,CAAC;EACtCE,UAAU,EAAEA,CAAA,KAAMN,WAAW,CAACM,UAAU,CAAC,CAAC;EAC1CJ;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,13 @@
1
+ import { Component } from 'react';
2
+ declare class KeepAwake extends Component {
3
+ componentDidMount(): void;
4
+ componentWillUnmount(): void;
5
+ render(): null;
6
+ }
7
+ declare const _default: {
8
+ activate: () => any;
9
+ deactivate: () => any;
10
+ KeepAwake: typeof KeepAwake;
11
+ };
12
+ export default _default;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,cAAM,SAAU,SAAQ,SAAS;IAC/B,iBAAiB;IAIjB,oBAAoB;IAIpB,MAAM;CAGP;;;;;;AAED,wBAIE"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,13 @@
1
+ import { Component } from 'react';
2
+ declare class KeepAwake extends Component {
3
+ componentDidMount(): void;
4
+ componentWillUnmount(): void;
5
+ render(): null;
6
+ }
7
+ declare const _default: {
8
+ activate: () => any;
9
+ deactivate: () => any;
10
+ KeepAwake: typeof KeepAwake;
11
+ };
12
+ export default _default;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,cAAM,SAAU,SAAQ,SAAS;IAC/B,iBAAiB;IAIjB,oBAAoB;IAIpB,MAAM;CAGP;;;;;;AAED,wBAIE"}
package/package.json ADDED
@@ -0,0 +1,204 @@
1
+ {
2
+ "name": "@kobe-brants/react-native-keep-awake",
3
+ "version": "1.0.6",
4
+ "description": "Keep device screen awake for React Native",
5
+ "source": "./src/index.tsx",
6
+ "main": "./lib/commonjs/index.js",
7
+ "module": "./lib/module/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./lib/typescript/module/src/index.d.ts",
12
+ "default": "./lib/module/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
16
+ "default": "./lib/commonjs/index.js"
17
+ }
18
+ }
19
+ },
20
+ "files": [
21
+ "src",
22
+ "lib",
23
+ "android",
24
+ "ios",
25
+ "cpp",
26
+ "*.podspec",
27
+ "react-native.config.js",
28
+ "!ios/build",
29
+ "!android/build",
30
+ "!android/gradle",
31
+ "!android/gradlew",
32
+ "!android/gradlew.bat",
33
+ "!android/local.properties",
34
+ "!**/__tests__",
35
+ "!**/__fixtures__",
36
+ "!**/__mocks__",
37
+ "!**/.*"
38
+ ],
39
+ "scripts": {
40
+ "example": "yarn workspace react-native-keep-awake-example",
41
+ "test": "jest",
42
+ "typecheck": "tsc",
43
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
44
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
45
+ "prepare": "bob build",
46
+ "release": "release-it",
47
+ "publish": "npm publish --access public"
48
+ },
49
+ "keywords": [
50
+ "react-native",
51
+ "ios",
52
+ "android"
53
+ ],
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/Kobe-Brants/react-native-keep-awake.git"
57
+ },
58
+ "author": "Kobe Brants <kobe.brants@telenet.be> (https://github.com/Kobe-Brants)",
59
+ "license": "MIT",
60
+ "bugs": {
61
+ "url": "https://github.com/Kobe-Brants/react-native-keep-awake/issues"
62
+ },
63
+ "homepage": "https://github.com/Kobe-Brants/react-native-keep-awake#readme",
64
+ "publishConfig": {
65
+ "registry": "https://registry.npmjs.org/"
66
+ },
67
+ "devDependencies": {
68
+ "@commitlint/config-conventional": "^17.0.2",
69
+ "@evilmartians/lefthook": "^1.5.0",
70
+ "@react-native-community/cli": "15.0.1",
71
+ "@react-native/eslint-config": "^0.73.1",
72
+ "@release-it/conventional-changelog": "^9.0.2",
73
+ "@types/jest": "^29.5.5",
74
+ "@types/react": "^18.2.44",
75
+ "commitlint": "^17.0.2",
76
+ "del-cli": "^5.1.0",
77
+ "eslint": "^8.51.0",
78
+ "eslint-config-prettier": "^9.0.0",
79
+ "eslint-plugin-prettier": "^5.0.1",
80
+ "jest": "^29.7.0",
81
+ "prettier": "^3.0.3",
82
+ "react": "18.3.1",
83
+ "react-native": "0.77.1",
84
+ "react-native-builder-bob": "^0.37.0",
85
+ "release-it": "^17.10.0",
86
+ "turbo": "^1.10.7",
87
+ "typescript": "^5.2.2"
88
+ },
89
+ "resolutions": {
90
+ "@types/react": "^18.2.44"
91
+ },
92
+ "peerDependencies": {
93
+ "react": "*",
94
+ "react-native": "*"
95
+ },
96
+ "workspaces": [
97
+ "example"
98
+ ],
99
+ "packageManager": "yarn@3.6.1",
100
+ "jest": {
101
+ "preset": "react-native",
102
+ "modulePathIgnorePatterns": [
103
+ "<rootDir>/example/node_modules",
104
+ "<rootDir>/lib/"
105
+ ]
106
+ },
107
+ "commitlint": {
108
+ "extends": [
109
+ "@commitlint/config-conventional"
110
+ ]
111
+ },
112
+ "release-it": {
113
+ "git": {
114
+ "commitMessage": "chore: release ${version}",
115
+ "tagName": "v${version}"
116
+ },
117
+ "npm": {
118
+ "publish": true
119
+ },
120
+ "github": {
121
+ "release": true
122
+ },
123
+ "plugins": {
124
+ "@release-it/conventional-changelog": {
125
+ "preset": "angular"
126
+ }
127
+ }
128
+ },
129
+ "eslintConfig": {
130
+ "root": true,
131
+ "extends": [
132
+ "@react-native",
133
+ "prettier"
134
+ ],
135
+ "rules": {
136
+ "react/react-in-jsx-scope": "off",
137
+ "prettier/prettier": [
138
+ "error",
139
+ {
140
+ "quoteProps": "consistent",
141
+ "singleQuote": true,
142
+ "tabWidth": 2,
143
+ "trailingComma": "es5",
144
+ "useTabs": false
145
+ }
146
+ ]
147
+ }
148
+ },
149
+ "eslintIgnore": [
150
+ "node_modules/",
151
+ "lib/"
152
+ ],
153
+ "prettier": {
154
+ "quoteProps": "consistent",
155
+ "singleQuote": true,
156
+ "tabWidth": 2,
157
+ "trailingComma": "es5",
158
+ "useTabs": false
159
+ },
160
+ "react-native-builder-bob": {
161
+ "source": "src",
162
+ "output": "lib",
163
+ "targets": [
164
+ "codegen",
165
+ [
166
+ "commonjs",
167
+ {
168
+ "esm": true
169
+ }
170
+ ],
171
+ [
172
+ "module",
173
+ {
174
+ "esm": true
175
+ }
176
+ ],
177
+ [
178
+ "typescript",
179
+ {
180
+ "project": "tsconfig.build.json",
181
+ "esm": true
182
+ }
183
+ ]
184
+ ]
185
+ },
186
+ "codegenConfig": {
187
+ "name": "RNKeepAwakeSpec",
188
+ "type": "modules",
189
+ "jsSrcsDir": "src",
190
+ "outputDir": {
191
+ "ios": "ios/generated",
192
+ "android": "android/generated"
193
+ },
194
+ "android": {
195
+ "javaPackageName": "com.keepawake"
196
+ },
197
+ "includesGeneratedCode": true
198
+ },
199
+ "create-react-native-library": {
200
+ "type": "turbo-module",
201
+ "languages": "cpp",
202
+ "version": "0.48.3"
203
+ }
204
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @type {import('@react-native-community/cli-types').UserDependencyConfig}
3
+ */
4
+ module.exports = {
5
+ dependency: {
6
+ platforms: {
7
+ android: {
8
+ cmakeListsPath: 'generated/jni/CMakeLists.txt',
9
+ },
10
+ },
11
+ },
12
+ };
package/src/index.tsx ADDED
@@ -0,0 +1,26 @@
1
+ import { NativeModules } from 'react-native';
2
+
3
+ const { MyKeepAwake } = NativeModules;
4
+
5
+ // Create a React component for declarative usage
6
+ import { Component } from 'react';
7
+
8
+ class KeepAwake extends Component {
9
+ componentDidMount() {
10
+ MyKeepAwake.activate();
11
+ }
12
+
13
+ componentWillUnmount() {
14
+ MyKeepAwake.deactivate();
15
+ }
16
+
17
+ render() {
18
+ return null;
19
+ }
20
+ }
21
+
22
+ export default {
23
+ activate: () => MyKeepAwake.activate(),
24
+ deactivate: () => MyKeepAwake.deactivate(),
25
+ KeepAwake,
26
+ };