expo-keep-awake 10.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +4 -4
- package/android/build.gradle +38 -25
- package/build/ExpoKeepAwake.d.ts +1 -0
- package/build/ExpoKeepAwake.d.ts.map +1 -0
- package/build/ExpoKeepAwake.web.d.ts +1 -0
- package/build/ExpoKeepAwake.web.d.ts.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -0
- package/expo-module.config.json +6 -0
- package/ios/{EXKeepAwake.podspec → ExpoKeepAwake.podspec} +10 -3
- package/ios/KeepAwakeModule.swift +54 -0
- package/package.json +6 -2
- package/ios/EXKeepAwake/EXKeepAwake.h +0 -7
- package/ios/EXKeepAwake/EXKeepAwake.m +0 -92
- package/unimodule.json +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,26 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 10.1.0 — 2022-04-18
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Native module on iOS is now written in Swift using the new API. ([#15705](https://github.com/expo/expo/pull/15705) by [@tsapeta](https://github.com/tsapeta))
|
|
18
|
+
|
|
19
|
+
### ⚠️ Notices
|
|
20
|
+
|
|
21
|
+
- On Android bump `compileSdkVersion` to `31`, `targetSdkVersion` to `31` and `Java` version to `11`. ([#16941](https://github.com/expo/expo/pull/16941) by [@bbarthec](https://github.com/bbarthec))
|
|
22
|
+
|
|
23
|
+
## 10.0.2 - 2022-02-01
|
|
24
|
+
|
|
25
|
+
### 🐛 Bug fixes
|
|
26
|
+
|
|
27
|
+
- Fix `Plugin with id 'maven' not found` build error from Android Gradle 7. ([#16080](https://github.com/expo/expo/pull/16080) by [@kudo](https://github.com/kudo))
|
|
28
|
+
|
|
29
|
+
## 10.0.1 — 2021-11-17
|
|
30
|
+
|
|
31
|
+
_This version does not introduce any user-facing changes._
|
|
32
|
+
|
|
13
33
|
## 10.0.0 — 2021-09-28
|
|
14
34
|
|
|
15
35
|
### 🛠 Breaking changes
|
package/README.md
CHANGED
|
@@ -4,16 +4,16 @@ Provides a React component that prevents the screen sleeping when rendered. It a
|
|
|
4
4
|
|
|
5
5
|
# API documentation
|
|
6
6
|
|
|
7
|
-
- [Documentation for the
|
|
8
|
-
- [Documentation for the latest stable release](https://docs.expo.
|
|
7
|
+
- [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/keep-awake.md)
|
|
8
|
+
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/keep-awake/)
|
|
9
9
|
|
|
10
10
|
# Installation in managed Expo projects
|
|
11
11
|
|
|
12
|
-
For
|
|
12
|
+
For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/keep-awake/).
|
|
13
13
|
|
|
14
14
|
# Installation in bare React Native projects
|
|
15
15
|
|
|
16
|
-
For bare React Native projects, you must ensure that you have [installed and configured the `
|
|
16
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
17
17
|
|
|
18
18
|
### Add the package to your npm dependencies
|
|
19
19
|
|
package/android/build.gradle
CHANGED
|
@@ -1,67 +1,80 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
apply plugin: 'kotlin-android'
|
|
3
|
-
apply plugin: 'maven'
|
|
3
|
+
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '10.
|
|
6
|
+
version = '10.1.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
10
|
+
if (expoModulesCorePlugin.exists()) {
|
|
11
|
+
apply from: expoModulesCorePlugin
|
|
12
|
+
applyKotlinExpoModulesCorePlugin()
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
// Simple helper that allows the root project to override versions declared by this library.
|
|
10
16
|
ext.safeExtGet = { prop, fallback ->
|
|
11
17
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
12
18
|
}
|
|
13
19
|
|
|
20
|
+
// Ensures backward compatibility
|
|
21
|
+
ext.getKotlinVersion = {
|
|
22
|
+
if (ext.has("kotlinVersion")) {
|
|
23
|
+
ext.kotlinVersion()
|
|
24
|
+
} else {
|
|
25
|
+
ext.safeExtGet("kotlinVersion", "1.6.10")
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
14
29
|
repositories {
|
|
15
30
|
mavenCentral()
|
|
16
31
|
}
|
|
17
32
|
|
|
18
33
|
dependencies {
|
|
19
|
-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${
|
|
34
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
|
|
20
35
|
}
|
|
21
36
|
}
|
|
22
37
|
|
|
23
|
-
// Upload android library to maven with javadoc and android sources
|
|
24
|
-
configurations {
|
|
25
|
-
deployerJars
|
|
26
|
-
}
|
|
27
|
-
|
|
28
38
|
// Creating sources with comments
|
|
29
39
|
task androidSourcesJar(type: Jar) {
|
|
30
40
|
classifier = 'sources'
|
|
31
41
|
from android.sourceSets.main.java.srcDirs
|
|
32
42
|
}
|
|
33
43
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
afterEvaluate {
|
|
45
|
+
publishing {
|
|
46
|
+
publications {
|
|
47
|
+
release(MavenPublication) {
|
|
48
|
+
from components.release
|
|
49
|
+
// Add additional sourcesJar to artifacts
|
|
50
|
+
artifact(androidSourcesJar)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
repositories {
|
|
54
|
+
maven {
|
|
55
|
+
url = mavenLocal().url
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
android {
|
|
49
|
-
compileSdkVersion safeExtGet("compileSdkVersion",
|
|
62
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 31)
|
|
50
63
|
|
|
51
64
|
compileOptions {
|
|
52
|
-
sourceCompatibility JavaVersion.
|
|
53
|
-
targetCompatibility JavaVersion.
|
|
65
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
66
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
54
67
|
}
|
|
55
68
|
|
|
56
69
|
kotlinOptions {
|
|
57
|
-
jvmTarget =
|
|
70
|
+
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
defaultConfig {
|
|
61
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
62
|
-
targetSdkVersion safeExtGet("targetSdkVersion",
|
|
75
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
63
76
|
versionCode 16
|
|
64
|
-
versionName "10.
|
|
77
|
+
versionName "10.1.0"
|
|
65
78
|
}
|
|
66
79
|
lintOptions {
|
|
67
80
|
abortOnError false
|
|
@@ -71,5 +84,5 @@ android {
|
|
|
71
84
|
dependencies {
|
|
72
85
|
implementation project(':expo-modules-core')
|
|
73
86
|
|
|
74
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${
|
|
87
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
75
88
|
}
|
package/build/ExpoKeepAwake.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoKeepAwake.d.ts","sourceRoot":"","sources":["../src/ExpoKeepAwake.ts"],"names":[],"mappings":";AACA,wBAAgD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoKeepAwake.web.d.ts","sourceRoot":"","sources":["../src/ExpoKeepAwake.web.ts"],"names":[],"mappings":";AAAA,wBAAkB"}
|
package/build/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,GAAE,MAAyB,GAAG,IAAI,CAKjE;AAGD;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAyB,GAAG,IAAI,CAEtE;AAGD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAAyB,GAAG,IAAI,CAExE"}
|
|
@@ -3,7 +3,7 @@ require 'json'
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name = '
|
|
6
|
+
s.name = 'ExpoKeepAwake'
|
|
7
7
|
s.version = package['version']
|
|
8
8
|
s.summary = package['description']
|
|
9
9
|
s.description = package['description']
|
|
@@ -11,15 +11,22 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.homepage = package['homepage']
|
|
13
13
|
s.platform = :ios, '12.0'
|
|
14
|
+
s.swift_version = '5.4'
|
|
14
15
|
s.source = { git: 'https://github.com/expo/expo.git' }
|
|
15
16
|
s.static_framework = true
|
|
16
17
|
|
|
17
18
|
s.dependency 'ExpoModulesCore'
|
|
18
19
|
|
|
20
|
+
# Swift/Objective-C compatibility
|
|
21
|
+
s.pod_target_xcconfig = {
|
|
22
|
+
'DEFINES_MODULE' => 'YES',
|
|
23
|
+
'SWIFT_COMPILATION_MODE' => 'wholemodule'
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
|
|
20
|
-
s.source_files = "
|
|
27
|
+
s.source_files = "**/*.h"
|
|
21
28
|
s.vendored_frameworks = "#{s.name}.xcframework"
|
|
22
29
|
else
|
|
23
|
-
s.source_files = "
|
|
30
|
+
s.source_files = "**/*.{h,m,swift}"
|
|
24
31
|
end
|
|
25
32
|
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright 2021-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import ExpoModulesCore
|
|
4
|
+
|
|
5
|
+
public final class KeepAwakeModule: Module {
|
|
6
|
+
private var activeTags = Set<String>()
|
|
7
|
+
|
|
8
|
+
public func definition() -> ModuleDefinition {
|
|
9
|
+
name("ExpoKeepAwake")
|
|
10
|
+
|
|
11
|
+
function("activate", activate)
|
|
12
|
+
function("deactivate", deactivate)
|
|
13
|
+
function("isActivated", isActivated)
|
|
14
|
+
|
|
15
|
+
onAppEntersForeground {
|
|
16
|
+
if !self.activeTags.isEmpty {
|
|
17
|
+
setActivated(true)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
onAppEntersBackground {
|
|
21
|
+
if !self.activeTags.isEmpty {
|
|
22
|
+
setActivated(false)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private func activate(tag: String) -> Bool {
|
|
28
|
+
if activeTags.isEmpty {
|
|
29
|
+
setActivated(true)
|
|
30
|
+
}
|
|
31
|
+
activeTags.insert(tag)
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private func deactivate(tag: String) -> Bool {
|
|
36
|
+
activeTags.remove(tag)
|
|
37
|
+
if activeTags.isEmpty {
|
|
38
|
+
setActivated(false)
|
|
39
|
+
}
|
|
40
|
+
return true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private func isActivated() -> Bool {
|
|
45
|
+
return DispatchQueue.main.sync {
|
|
46
|
+
return UIApplication.shared.isIdleTimerDisabled
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private func setActivated(_ activated: Bool) {
|
|
51
|
+
DispatchQueue.main.async {
|
|
52
|
+
UIApplication.shared.isIdleTimerDisabled = activated
|
|
53
|
+
}
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-keep-awake",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "Provides a React component that prevents the screen sleeping when rendered. It also exposes static methods to control the behavior imperatively.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -31,8 +31,12 @@
|
|
|
31
31
|
"author": "650 Industries, Inc.",
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"homepage": "https://docs.expo.dev/versions/latest/sdk/keep-awake/",
|
|
34
|
+
"dependencies": {},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"expo-module-scripts": "^2.0.0"
|
|
36
37
|
},
|
|
37
|
-
"
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"expo": "*"
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "22dce752354bb429c84851bc4389abe47a766b1f"
|
|
38
42
|
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-present 650 Industries. All rights reserved.
|
|
2
|
-
|
|
3
|
-
#import <ExpoModulesCore/EXModuleRegistry.h>
|
|
4
|
-
#import <EXKeepAwake/EXKeepAwake.h>
|
|
5
|
-
#import <ExpoModulesCore/EXAppLifecycleService.h>
|
|
6
|
-
#import <ExpoModulesCore/EXUtilities.h>
|
|
7
|
-
|
|
8
|
-
@interface EXKeepAwake () <EXAppLifecycleListener>
|
|
9
|
-
|
|
10
|
-
@property (nonatomic, weak) id<EXAppLifecycleService> lifecycleManager;
|
|
11
|
-
@property (nonatomic, weak) EXModuleRegistry *moduleRegistry;
|
|
12
|
-
|
|
13
|
-
@end
|
|
14
|
-
|
|
15
|
-
@implementation EXKeepAwake {
|
|
16
|
-
NSMutableSet *_activeTags;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
- (instancetype)init {
|
|
20
|
-
self = [super init];
|
|
21
|
-
_activeTags = [NSMutableSet set];
|
|
22
|
-
return self;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
EX_EXPORT_MODULE(ExpoKeepAwake);
|
|
26
|
-
|
|
27
|
-
# pragma mark - EXModuleRegistryConsumer
|
|
28
|
-
|
|
29
|
-
- (void)setModuleRegistry:(EXModuleRegistry *)moduleRegistry
|
|
30
|
-
{
|
|
31
|
-
if (_moduleRegistry) {
|
|
32
|
-
[_lifecycleManager unregisterAppLifecycleListener:self];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
_lifecycleManager = nil;
|
|
36
|
-
|
|
37
|
-
if (moduleRegistry) {
|
|
38
|
-
_lifecycleManager = [moduleRegistry getModuleImplementingProtocol:@protocol(EXAppLifecycleService)];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (_lifecycleManager) {
|
|
42
|
-
[_lifecycleManager registerAppLifecycleListener:self];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
EX_EXPORT_METHOD_AS(activate, activate:(NSString *)tag
|
|
47
|
-
resolve:(EXPromiseResolveBlock)resolve
|
|
48
|
-
reject:(EXPromiseRejectBlock)reject)
|
|
49
|
-
{
|
|
50
|
-
if(![self shouldBeActive]) {
|
|
51
|
-
[EXUtilities performSynchronouslyOnMainThread:^{
|
|
52
|
-
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
|
|
53
|
-
}];
|
|
54
|
-
}
|
|
55
|
-
[_activeTags addObject:tag];
|
|
56
|
-
resolve(@YES);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
EX_EXPORT_METHOD_AS(deactivate, deactivate:(NSString *)tag
|
|
60
|
-
resolve:(EXPromiseResolveBlock)resolve
|
|
61
|
-
reject:(EXPromiseRejectBlock)reject)
|
|
62
|
-
{
|
|
63
|
-
[_activeTags removeObject:tag];
|
|
64
|
-
if (![self shouldBeActive]) {
|
|
65
|
-
[EXUtilities performSynchronouslyOnMainThread:^{
|
|
66
|
-
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
67
|
-
}];
|
|
68
|
-
}
|
|
69
|
-
resolve(@YES);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
# pragma mark - EXAppLifecycleListener
|
|
73
|
-
|
|
74
|
-
- (void)onAppBackgrounded {
|
|
75
|
-
[EXUtilities performSynchronouslyOnMainThread:^{
|
|
76
|
-
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
77
|
-
}];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
- (void)onAppForegrounded {
|
|
81
|
-
if ([self shouldBeActive]) {
|
|
82
|
-
[EXUtilities performSynchronouslyOnMainThread:^{
|
|
83
|
-
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
|
|
84
|
-
}];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
- (BOOL)shouldBeActive {
|
|
89
|
-
return [_activeTags count] > 0;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
@end
|
package/unimodule.json
DELETED