expo-keep-awake 10.0.2 → 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 +11 -1
- package/README.md +3 -3
- package/android/build.gradle +24 -9
- 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 +2 -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,7 +10,17 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
## 10.0
|
|
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
|
|
14
24
|
|
|
15
25
|
### 🐛 Bug fixes
|
|
16
26
|
|
package/README.md
CHANGED
|
@@ -4,12 +4,12 @@ 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
|
|
package/android/build.gradle
CHANGED
|
@@ -3,20 +3,35 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '10.0
|
|
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
|
|
|
@@ -44,22 +59,22 @@ afterEvaluate {
|
|
|
44
59
|
}
|
|
45
60
|
|
|
46
61
|
android {
|
|
47
|
-
compileSdkVersion safeExtGet("compileSdkVersion",
|
|
62
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 31)
|
|
48
63
|
|
|
49
64
|
compileOptions {
|
|
50
|
-
sourceCompatibility JavaVersion.
|
|
51
|
-
targetCompatibility JavaVersion.
|
|
65
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
66
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
52
67
|
}
|
|
53
68
|
|
|
54
69
|
kotlinOptions {
|
|
55
|
-
jvmTarget =
|
|
70
|
+
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
56
71
|
}
|
|
57
72
|
|
|
58
73
|
defaultConfig {
|
|
59
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
60
|
-
targetSdkVersion safeExtGet("targetSdkVersion",
|
|
75
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
61
76
|
versionCode 16
|
|
62
|
-
versionName "10.0
|
|
77
|
+
versionName "10.1.0"
|
|
63
78
|
}
|
|
64
79
|
lintOptions {
|
|
65
80
|
abortOnError false
|
|
@@ -69,5 +84,5 @@ android {
|
|
|
69
84
|
dependencies {
|
|
70
85
|
implementation project(':expo-modules-core')
|
|
71
86
|
|
|
72
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${
|
|
87
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
73
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.0
|
|
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",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"expo": "*"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "22dce752354bb429c84851bc4389abe47a766b1f"
|
|
42
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