@gachlab/capacitor-keep-awake-plugin 2.0.2 → 2.2.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/Package.swift +1 -1
- package/android/src/main/java/com/gachlab/capacitor/keepawake/KeepAwake.java +6 -19
- package/android/src/main/java/com/gachlab/capacitor/keepawake/KeepAwakePlugin.java +3 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/web-BNfo7bz7.js.map +1 -1
- package/dist/web-CFH8HkZO.mjs.map +1 -1
- package/ios/Sources/KeepAwakePlugin/KeepAwake.swift +4 -4
- package/package.json +17 -20
package/Package.swift
CHANGED
|
@@ -10,7 +10,7 @@ let package = Package(
|
|
|
10
10
|
targets: ["KeepAwakePlugin"])
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
|
-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git",
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", branch: "main")
|
|
14
14
|
],
|
|
15
15
|
targets: [
|
|
16
16
|
.target(
|
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
package com.gachlab.capacitor.keepawake;
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
|
-
import android.util.Log;
|
|
5
4
|
import android.view.WindowManager;
|
|
6
5
|
|
|
7
|
-
import androidx.appcompat.app.AppCompatActivity;
|
|
8
|
-
|
|
9
6
|
public class KeepAwake {
|
|
10
7
|
|
|
11
|
-
public boolean dontAllowSleep(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@Override
|
|
15
|
-
public void run() {
|
|
16
|
-
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
17
|
-
}
|
|
8
|
+
public boolean dontAllowSleep(Activity activity) {
|
|
9
|
+
activity.runOnUiThread(() -> {
|
|
10
|
+
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
18
11
|
});
|
|
19
|
-
Log.i("KeepAwake", "Sleep Disabled");
|
|
20
12
|
return false;
|
|
21
13
|
}
|
|
22
14
|
|
|
23
|
-
public boolean allowSleep(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@Override
|
|
27
|
-
public void run() {
|
|
28
|
-
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
29
|
-
}
|
|
15
|
+
public boolean allowSleep(Activity activity) {
|
|
16
|
+
activity.runOnUiThread(() -> {
|
|
17
|
+
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
30
18
|
});
|
|
31
|
-
Log.i("KeepAwake", "Sleep Enabled");
|
|
32
19
|
return true;
|
|
33
20
|
}
|
|
34
21
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
package com.gachlab.capacitor.keepawake;
|
|
2
2
|
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.util.Log;
|
|
5
|
-
import android.view.WindowManager;
|
|
6
|
-
|
|
7
|
-
import androidx.appcompat.app.AppCompatActivity;
|
|
8
|
-
|
|
9
3
|
import com.getcapacitor.JSObject;
|
|
10
4
|
import com.getcapacitor.Plugin;
|
|
11
5
|
import com.getcapacitor.PluginCall;
|
|
@@ -19,18 +13,15 @@ public class KeepAwakePlugin extends Plugin {
|
|
|
19
13
|
|
|
20
14
|
@PluginMethod
|
|
21
15
|
public void dontAllowSleep(PluginCall call) {
|
|
22
|
-
String value = call.getString("value");
|
|
23
|
-
AppCompatActivity activity=getActivity();
|
|
24
16
|
JSObject ret = new JSObject();
|
|
25
|
-
ret.put("
|
|
17
|
+
ret.put("isAllowdSleep", implementation.dontAllowSleep(getActivity()));
|
|
26
18
|
call.resolve(ret);
|
|
27
19
|
}
|
|
20
|
+
|
|
28
21
|
@PluginMethod
|
|
29
22
|
public void allowSleep(PluginCall call) {
|
|
30
|
-
String value = call.getString("value");
|
|
31
|
-
AppCompatActivity activity=getActivity();
|
|
32
23
|
JSObject ret = new JSObject();
|
|
33
|
-
ret.put("
|
|
24
|
+
ret.put("isAllowdSleep", implementation.allowSleep(getActivity()));
|
|
34
25
|
call.resolve(ret);
|
|
35
26
|
}
|
|
36
27
|
}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nconst KeepAwake = registerPlugin<KeepAwakePlugin>('KeepAwake', {\n web: () => import('./web').then(m => new m.KeepAwakeWeb()),\n});\n\nexport * from './definitions';\nexport { KeepAwake };\n"],"names":["KeepAwake","registerPlugin","m"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nconst KeepAwake = registerPlugin<KeepAwakePlugin>('KeepAwake', {\n web: () => import('./web').then(m => new m.KeepAwakeWeb()),\n});\n\nexport * from './definitions';\nexport { KeepAwake };\n"],"names":["KeepAwake","registerPlugin","m"],"mappings":";AAIA,MAAMA,IAAYC,EAAgC,aAAa;AAAA,EAC7D,KAAK,MAAM,OAAO,qBAAO,EAAE,KAAK,CAAAC,MAAK,IAAIA,EAAE,aAAA,CAAc;AAC3D,CAAC;"}
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["../src/index.ts"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nconst KeepAwake = registerPlugin<KeepAwakePlugin>('KeepAwake', {\n web: () => import('./web').then(m => new m.KeepAwakeWeb()),\n});\n\nexport * from './definitions';\nexport { KeepAwake };\n"],"names":["KeepAwake","registerPlugin","m"],"mappings":"mHAIMA,EAAYC,
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["../src/index.ts"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nconst KeepAwake = registerPlugin<KeepAwakePlugin>('KeepAwake', {\n web: () => import('./web').then(m => new m.KeepAwakeWeb()),\n});\n\nexport * from './definitions';\nexport { KeepAwake };\n"],"names":["KeepAwake","registerPlugin","m"],"mappings":"mHAIMA,EAAYC,EAAAA,eAAgC,YAAa,CAC7D,IAAK,IAAM,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,mBAAO,GAAE,KAAKC,GAAK,IAAIA,EAAE,YAAc,CAC3D,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var capacitorKeepAwake=function(e,t){"use strict";const r=t.registerPlugin("KeepAwake",{web:()=>Promise.resolve().then(()=>l).then(o=>new o.KeepAwakeWeb)});class n extends t.WebPlugin{dontAllowSleep(){throw new Error("Method not implemented for Web.")}allowSleep(){throw new Error("Method not implemented for Web.")}}const l=Object.freeze(Object.defineProperty({__proto__:null,KeepAwakeWeb:n},Symbol.toStringTag,{value:"Module"}));return e.KeepAwake=r,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({},capacitorExports);
|
|
1
|
+
var capacitorKeepAwake=(function(e,t){"use strict";const r=t.registerPlugin("KeepAwake",{web:()=>Promise.resolve().then(()=>l).then(o=>new o.KeepAwakeWeb)});class n extends t.WebPlugin{dontAllowSleep(){throw new Error("Method not implemented for Web.")}allowSleep(){throw new Error("Method not implemented for Web.")}}const l=Object.freeze(Object.defineProperty({__proto__:null,KeepAwakeWeb:n},Symbol.toStringTag,{value:"Module"}));return e.KeepAwake=r,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e})({},capacitorExports);
|
|
2
2
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../src/index.ts","../src/web.ts"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nconst KeepAwake = registerPlugin<KeepAwakePlugin>('KeepAwake', {\n web: () => import('./web').then(m => new m.KeepAwakeWeb()),\n});\n\nexport * from './definitions';\nexport { KeepAwake };\n","import { WebPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nexport class KeepAwakeWeb extends WebPlugin implements KeepAwakePlugin {\n dontAllowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n allowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n \n}\n"],"names":["KeepAwake","registerPlugin","web","m","KeepAwakeWeb","WebPlugin"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../src/index.ts","../src/web.ts"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nconst KeepAwake = registerPlugin<KeepAwakePlugin>('KeepAwake', {\n web: () => import('./web').then(m => new m.KeepAwakeWeb()),\n});\n\nexport * from './definitions';\nexport { KeepAwake };\n","import { WebPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nexport class KeepAwakeWeb extends WebPlugin implements KeepAwakePlugin {\n dontAllowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n allowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n \n}\n"],"names":["KeepAwake","registerPlugin","web","m","KeepAwakeWeb","WebPlugin"],"mappings":"mDAIA,MAAMA,EAAYC,EAAAA,eAAgC,YAAa,CAC7D,IAAK,IAAM,QAAA,QAAA,EAAA,KAAA,IAAAC,CAAA,EAAgB,KAAKC,GAAK,IAAIA,EAAE,YAAc,CAC3D,CAAC,ECFM,MAAMC,UAAqBC,EAAAA,SAAqC,CACrE,gBAAuD,CACrD,MAAM,IAAI,MAAM,iCAAiC,CACnD,CACA,YAAmD,CACjD,MAAM,IAAI,MAAM,iCAAiC,CACnD,CAEF"}
|
package/dist/web-BNfo7bz7.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-BNfo7bz7.js","sources":["../src/web.ts"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nexport class KeepAwakeWeb extends WebPlugin implements KeepAwakePlugin {\n dontAllowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n allowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n \n}\n"],"names":["KeepAwakeWeb","WebPlugin"],"mappings":"mHAIO,MAAMA,UAAqBC,EAAAA,SAAqC,CACrE,gBAAuD,
|
|
1
|
+
{"version":3,"file":"web-BNfo7bz7.js","sources":["../src/web.ts"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nexport class KeepAwakeWeb extends WebPlugin implements KeepAwakePlugin {\n dontAllowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n allowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n \n}\n"],"names":["KeepAwakeWeb","WebPlugin"],"mappings":"mHAIO,MAAMA,UAAqBC,EAAAA,SAAqC,CACrE,gBAAuD,CACrD,MAAM,IAAI,MAAM,iCAAiC,CACnD,CACA,YAAmD,CACjD,MAAM,IAAI,MAAM,iCAAiC,CACnD,CAEF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-CFH8HkZO.mjs","sources":["../src/web.ts"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nexport class KeepAwakeWeb extends WebPlugin implements KeepAwakePlugin {\n dontAllowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n allowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n \n}\n"],"names":["KeepAwakeWeb","WebPlugin"],"mappings":";AAIO,MAAMA,UAAqBC,EAAqC;AAAA,EACrE,iBAAuD;
|
|
1
|
+
{"version":3,"file":"web-CFH8HkZO.mjs","sources":["../src/web.ts"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { KeepAwakePlugin } from './definitions';\n\nexport class KeepAwakeWeb extends WebPlugin implements KeepAwakePlugin {\n dontAllowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n allowSleep(): Promise<{ isAllowdSleep: boolean; }> {\n throw new Error('Method not implemented for Web.');\n }\n \n}\n"],"names":["KeepAwakeWeb","WebPlugin"],"mappings":";AAIO,MAAMA,UAAqBC,EAAqC;AAAA,EACrE,iBAAuD;AACrD,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAAA,EACA,aAAmD;AACjD,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEF;"}
|
|
@@ -3,15 +3,15 @@ import UIKit
|
|
|
3
3
|
|
|
4
4
|
@objc public class KeepAwake: NSObject {
|
|
5
5
|
@objc public func dontAllowSleep() -> Bool {
|
|
6
|
-
DispatchQueue.main.
|
|
6
|
+
DispatchQueue.main.sync {
|
|
7
7
|
UIApplication.shared.isIdleTimerDisabled = true
|
|
8
8
|
}
|
|
9
|
-
return
|
|
9
|
+
return false
|
|
10
10
|
}
|
|
11
11
|
@objc public func allowSleep() -> Bool {
|
|
12
|
-
DispatchQueue.main.
|
|
12
|
+
DispatchQueue.main.sync {
|
|
13
13
|
UIApplication.shared.isIdleTimerDisabled = false
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return true
|
|
16
16
|
}
|
|
17
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gachlab/capacitor-keep-awake-plugin",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A plugin to keep awake the device screen",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,9 +34,8 @@
|
|
|
34
34
|
"verify:ios": "xcodebuild -scheme GachlabCapacitorKeepAwakePlugin -destination generic/platform=iOS",
|
|
35
35
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
36
36
|
"verify:web": "npm run build",
|
|
37
|
-
"lint": "
|
|
38
|
-
"fmt": "
|
|
39
|
-
"eslint": "eslint . --ext ts",
|
|
37
|
+
"lint": "eslint . && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
38
|
+
"fmt": "eslint . --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
40
39
|
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
41
40
|
"swiftlint": "node-swiftlint",
|
|
42
41
|
"docgen": "docgen --api KeepAwakePlugin --output-readme README.md --output-json dist/docs.json",
|
|
@@ -47,30 +46,28 @@
|
|
|
47
46
|
"prepublishOnly": "npm run build"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@capacitor/android": "^
|
|
51
|
-
"@capacitor/core": "^
|
|
52
|
-
"@capacitor/docgen": "^0.3.
|
|
53
|
-
"@capacitor/ios": "^
|
|
54
|
-
"@ionic/eslint-config": "^0.4.0",
|
|
49
|
+
"@capacitor/android": "^8.0.1",
|
|
50
|
+
"@capacitor/core": "^8.0.1",
|
|
51
|
+
"@capacitor/docgen": "^0.3.1",
|
|
52
|
+
"@capacitor/ios": "^8.0.1",
|
|
55
53
|
"@ionic/prettier-config": "^4.0.0",
|
|
56
54
|
"@ionic/swiftlint-config": "^2.0.0",
|
|
57
|
-
"eslint": "^8.
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^8.53.0",
|
|
56
|
+
"@typescript-eslint/parser": "^8.53.0",
|
|
57
|
+
"eslint": "^9.39.2",
|
|
58
|
+
"prettier": "^3.8.0",
|
|
59
|
+
"prettier-plugin-java": "^2.8.1",
|
|
60
|
+
"rimraf": "^6.1.2",
|
|
61
61
|
"swiftlint": "^2.0.0",
|
|
62
|
-
"typescript": "
|
|
63
|
-
"vite": "^
|
|
64
|
-
"vite-plugin-dts": "^
|
|
62
|
+
"typescript": "^5.9.3",
|
|
63
|
+
"vite": "^7.3.1",
|
|
64
|
+
"vite-plugin-dts": "^4.4.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@capacitor/core": "
|
|
67
|
+
"@capacitor/core": "^8.0.1"
|
|
68
68
|
},
|
|
69
69
|
"prettier": "@ionic/prettier-config",
|
|
70
70
|
"swiftlint": "@ionic/swiftlint-config",
|
|
71
|
-
"eslintConfig": {
|
|
72
|
-
"extends": "@ionic/eslint-config/recommended"
|
|
73
|
-
},
|
|
74
71
|
"capacitor": {
|
|
75
72
|
"ios": {
|
|
76
73
|
"src": "ios"
|