@capgo/capacitor-flash 1.2.10 → 1.2.16
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/CapgoCapacitorFlash.podspec +1 -1
- package/README.md +5 -1
- package/android/build.gradle +9 -9
- package/android/src/main/java/ee/forgr/plugin/capacitor_flash/CapacitorFlashPlugin.java +107 -124
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.js +4 -9
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +5 -12
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +5 -12
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorFlash.swift +10 -10
- package/ios/Plugin/CapacitorFlashPlugin.swift +4 -4
- package/package.json +19 -14
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# capacitor-flash
|
|
2
2
|
<a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
<div align="center">
|
|
5
|
+
<h2><a href="https://capgo.app/">Check out: Capgo — Instant updates for capacitor</a></h2>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
4
8
|
Switch the Flashlight / Torch of your device.
|
|
5
9
|
|
|
6
10
|
## Install
|
package/android/build.gradle
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
ext {
|
|
2
|
-
junitVersion =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
|
|
4
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
|
|
5
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
repositories {
|
|
10
|
+
mavenCentral()
|
|
10
11
|
google()
|
|
11
|
-
jcenter()
|
|
12
12
|
}
|
|
13
13
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:
|
|
14
|
+
classpath 'com.android.tools.build:gradle:7.2.1'
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
apply plugin: 'com.android.library'
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
|
-
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
21
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
|
|
22
22
|
defaultConfig {
|
|
23
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
24
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
23
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
24
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
|
|
25
25
|
versionCode 1
|
|
26
26
|
versionName "1.0"
|
|
27
27
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
package ee.forgr.plugin.capacitor_flash;
|
|
2
2
|
|
|
3
|
+
import android.Manifest;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.hardware.camera2.CameraAccessException;
|
|
6
|
+
import android.hardware.camera2.CameraCharacteristics;
|
|
7
|
+
import android.hardware.camera2.CameraManager;
|
|
8
|
+
import android.os.Build;
|
|
9
|
+
import androidx.annotation.RequiresApi;
|
|
3
10
|
import com.getcapacitor.JSObject;
|
|
4
11
|
import com.getcapacitor.PermissionState;
|
|
5
12
|
import com.getcapacitor.Plugin;
|
|
@@ -9,142 +16,118 @@ import com.getcapacitor.annotation.CapacitorPlugin;
|
|
|
9
16
|
import com.getcapacitor.annotation.Permission;
|
|
10
17
|
import com.getcapacitor.annotation.PermissionCallback;
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
import android.content.Context;
|
|
14
|
-
import android.hardware.camera2.CameraAccessException;
|
|
15
|
-
import android.hardware.camera2.CameraCharacteristics;
|
|
16
|
-
import android.hardware.camera2.CameraManager;
|
|
17
|
-
import android.os.Build;
|
|
18
|
-
|
|
19
|
-
import androidx.annotation.RequiresApi;
|
|
20
|
-
|
|
21
|
-
@CapacitorPlugin(
|
|
22
|
-
name = "CapacitorFlash",
|
|
23
|
-
permissions = {
|
|
24
|
-
@Permission(
|
|
25
|
-
alias = "camera",
|
|
26
|
-
strings = { Manifest.permission.CAMERA }
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
)
|
|
19
|
+
@CapacitorPlugin(name = "CapacitorFlash", permissions = { @Permission(alias = "camera", strings = { Manifest.permission.CAMERA }) })
|
|
30
20
|
public class CapacitorFlashPlugin extends Plugin {
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} catch (CameraAccessException e) {
|
|
48
|
-
e.printStackTrace();
|
|
22
|
+
private String cameraId;
|
|
23
|
+
boolean isFlashStateOn = false;
|
|
24
|
+
|
|
25
|
+
private CameraManager cameraManager;
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
public void load() {
|
|
29
|
+
cameraManager = (CameraManager) this.bridge.getContext().getSystemService(Context.CAMERA_SERVICE);
|
|
30
|
+
try {
|
|
31
|
+
if (cameraManager != null) {
|
|
32
|
+
cameraId = cameraManager.getCameraIdList()[0];
|
|
33
|
+
}
|
|
34
|
+
} catch (CameraAccessException e) {
|
|
35
|
+
e.printStackTrace();
|
|
36
|
+
}
|
|
49
37
|
}
|
|
50
|
-
}
|
|
51
38
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
@PluginMethod
|
|
40
|
+
public void isAvailable(PluginCall call) {
|
|
41
|
+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M && getPermissionState("camera") != PermissionState.GRANTED) {
|
|
42
|
+
requestPermissionForAlias("camera", call, "cameraPermsCallback");
|
|
43
|
+
} else {
|
|
44
|
+
getAvailibility(call);
|
|
45
|
+
}
|
|
59
46
|
}
|
|
60
|
-
}
|
|
61
47
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
48
|
+
@PermissionCallback
|
|
49
|
+
private void getAvailibility(PluginCall call) {
|
|
50
|
+
JSObject ret = new JSObject();
|
|
51
|
+
if (cameraManager == null) {
|
|
52
|
+
ret.put("value", false);
|
|
53
|
+
call.resolve(ret);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
boolean flashAvailable = cameraManager.getCameraCharacteristics(cameraId).get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
|
|
58
|
+
ret.put("value", flashAvailable);
|
|
59
|
+
} catch (CameraAccessException e) {
|
|
60
|
+
e.printStackTrace();
|
|
61
|
+
ret.put("value", false);
|
|
62
|
+
}
|
|
63
|
+
call.resolve(ret);
|
|
78
64
|
}
|
|
79
|
-
call.resolve(ret);
|
|
80
|
-
}
|
|
81
65
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
66
|
+
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
67
|
+
@PluginMethod
|
|
68
|
+
public void switchOn(PluginCall call) {
|
|
69
|
+
String value = call.getString("instensity"); // cannot be use in android
|
|
70
|
+
JSObject ret = new JSObject();
|
|
71
|
+
if (cameraManager == null) {
|
|
72
|
+
ret.put("value", false);
|
|
73
|
+
call.resolve(ret);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
cameraManager.setTorchMode(cameraId, true);
|
|
78
|
+
isFlashStateOn = true;
|
|
79
|
+
ret.put("value", true);
|
|
80
|
+
} catch (Exception e) {
|
|
81
|
+
e.printStackTrace();
|
|
82
|
+
ret.put("value", false);
|
|
83
|
+
}
|
|
84
|
+
call.resolve(ret);
|
|
91
85
|
}
|
|
92
|
-
try {
|
|
93
|
-
cameraManager.setTorchMode(cameraId, true);
|
|
94
|
-
isFlashStateOn = true;
|
|
95
|
-
ret.put("value", true);
|
|
96
|
-
} catch (Exception e) {
|
|
97
|
-
e.printStackTrace();
|
|
98
|
-
ret.put("value", false);
|
|
99
|
-
}
|
|
100
|
-
call.resolve(ret);
|
|
101
|
-
}
|
|
102
86
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
87
|
+
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
88
|
+
@PluginMethod
|
|
89
|
+
public void switchOff(PluginCall call) {
|
|
90
|
+
JSObject ret = new JSObject();
|
|
91
|
+
if (cameraManager == null) {
|
|
92
|
+
ret.put("value", false);
|
|
93
|
+
call.resolve(ret);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
cameraManager.setTorchMode(cameraId, false);
|
|
98
|
+
isFlashStateOn = false;
|
|
99
|
+
ret.put("value", true);
|
|
100
|
+
} catch (Exception e) {
|
|
101
|
+
e.printStackTrace();
|
|
102
|
+
ret.put("value", false);
|
|
103
|
+
}
|
|
104
|
+
call.resolve(ret);
|
|
119
105
|
}
|
|
120
|
-
call.resolve(ret);
|
|
121
|
-
}
|
|
122
106
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
131
|
-
@PluginMethod
|
|
132
|
-
public void toggle(PluginCall call) {
|
|
133
|
-
JSObject ret = new JSObject();
|
|
134
|
-
if (cameraManager == null) {
|
|
135
|
-
ret.put("value", false);
|
|
136
|
-
call.resolve(ret);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
try {
|
|
140
|
-
isFlashStateOn = !isFlashStateOn;
|
|
141
|
-
cameraManager.setTorchMode(cameraId, isFlashStateOn);
|
|
142
|
-
ret.put("value", isFlashStateOn);
|
|
143
|
-
} catch (Exception e) {
|
|
144
|
-
e.printStackTrace();
|
|
145
|
-
ret.put("value", false);
|
|
107
|
+
@PluginMethod
|
|
108
|
+
public void isSwitchedOn(PluginCall call) {
|
|
109
|
+
JSObject ret = new JSObject();
|
|
110
|
+
ret.put("value", isFlashStateOn);
|
|
111
|
+
call.resolve(ret);
|
|
146
112
|
}
|
|
147
|
-
call.resolve(ret);
|
|
148
|
-
}
|
|
149
113
|
|
|
114
|
+
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
115
|
+
@PluginMethod
|
|
116
|
+
public void toggle(PluginCall call) {
|
|
117
|
+
JSObject ret = new JSObject();
|
|
118
|
+
if (cameraManager == null) {
|
|
119
|
+
ret.put("value", false);
|
|
120
|
+
call.resolve(ret);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
isFlashStateOn = !isFlashStateOn;
|
|
125
|
+
cameraManager.setTorchMode(cameraId, isFlashStateOn);
|
|
126
|
+
ret.put("value", isFlashStateOn);
|
|
127
|
+
} catch (Exception e) {
|
|
128
|
+
e.printStackTrace();
|
|
129
|
+
ret.put("value", false);
|
|
130
|
+
}
|
|
131
|
+
call.resolve(ret);
|
|
132
|
+
}
|
|
150
133
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { registerPlugin } from '@capacitor/core';
|
|
2
2
|
const CapacitorFlash = registerPlugin('CapacitorFlash', {
|
|
3
|
-
web: () => import('./web').then(m => new m.CapacitorFlashWeb()),
|
|
3
|
+
web: () => import('./web').then((m) => new m.CapacitorFlashWeb()),
|
|
4
4
|
});
|
|
5
5
|
export * from './definitions';
|
|
6
6
|
export { CapacitorFlash };
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,cAAc,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,cAAc,GAAG,cAAc,CAAuB,gBAAgB,EAAE;IAC5E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;CAClE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/esm/web.js
CHANGED
|
@@ -3,23 +3,18 @@ export class CapacitorFlashWeb extends WebPlugin {
|
|
|
3
3
|
isAvailable() {
|
|
4
4
|
return Promise.resolve({ value: false });
|
|
5
5
|
}
|
|
6
|
-
;
|
|
7
6
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
7
|
switchOn(_options) {
|
|
9
|
-
throw new Error(
|
|
8
|
+
throw new Error('Method not implemented.');
|
|
10
9
|
}
|
|
11
|
-
;
|
|
12
10
|
switchOff() {
|
|
13
|
-
throw new Error(
|
|
11
|
+
throw new Error('Method not implemented.');
|
|
14
12
|
}
|
|
15
|
-
;
|
|
16
13
|
isSwitchedOn() {
|
|
17
|
-
throw new Error(
|
|
14
|
+
throw new Error('Method not implemented.');
|
|
18
15
|
}
|
|
19
|
-
;
|
|
20
16
|
toggle() {
|
|
21
|
-
throw new Error(
|
|
17
|
+
throw new Error('Method not implemented.');
|
|
22
18
|
}
|
|
23
|
-
;
|
|
24
19
|
}
|
|
25
20
|
//# sourceMappingURL=web.js.map
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,WAAW;QACT,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,6DAA6D;IAC7D,QAAQ,CAAC,QAAgC;QACvC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,SAAS;QACP,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,YAAY;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var core = require('@capacitor/core');
|
|
6
4
|
|
|
7
5
|
const CapacitorFlash = core.registerPlugin('CapacitorFlash', {
|
|
8
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorFlashWeb()),
|
|
6
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapacitorFlashWeb()),
|
|
9
7
|
});
|
|
10
8
|
|
|
11
9
|
class CapacitorFlashWeb extends core.WebPlugin {
|
|
12
10
|
isAvailable() {
|
|
13
11
|
return Promise.resolve({ value: false });
|
|
14
12
|
}
|
|
15
|
-
;
|
|
16
13
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
14
|
switchOn(_options) {
|
|
18
|
-
throw new Error(
|
|
15
|
+
throw new Error('Method not implemented.');
|
|
19
16
|
}
|
|
20
|
-
;
|
|
21
17
|
switchOff() {
|
|
22
|
-
throw new Error(
|
|
18
|
+
throw new Error('Method not implemented.');
|
|
23
19
|
}
|
|
24
|
-
;
|
|
25
20
|
isSwitchedOn() {
|
|
26
|
-
throw new Error(
|
|
21
|
+
throw new Error('Method not implemented.');
|
|
27
22
|
}
|
|
28
|
-
;
|
|
29
23
|
toggle() {
|
|
30
|
-
throw new Error(
|
|
24
|
+
throw new Error('Method not implemented.');
|
|
31
25
|
}
|
|
32
|
-
;
|
|
33
26
|
}
|
|
34
27
|
|
|
35
28
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorFlash = registerPlugin('CapacitorFlash', {\n web: () => import('./web').then(m => new m.CapacitorFlashWeb()),\n});\nexport * from './definitions';\nexport { CapacitorFlash };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorFlashWeb extends WebPlugin {\n isAvailable() {\n return Promise.resolve({ value: false });\n }\n
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorFlash = registerPlugin('CapacitorFlash', {\n web: () => import('./web').then((m) => new m.CapacitorFlashWeb()),\n});\nexport * from './definitions';\nexport { CapacitorFlash };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorFlashWeb extends WebPlugin {\n isAvailable() {\n return Promise.resolve({ value: false });\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n switchOn(_options) {\n throw new Error('Method not implemented.');\n }\n switchOff() {\n throw new Error('Method not implemented.');\n }\n isSwitchedOn() {\n throw new Error('Method not implemented.');\n }\n toggle() {\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;AACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACrE,CAAC;;ACFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;AACjD,IAAI,WAAW,GAAG;AAClB,QAAQ,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AACjD,KAAK;AACL;AACA,IAAI,QAAQ,CAAC,QAAQ,EAAE;AACvB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,SAAS,GAAG;AAChB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,YAAY,GAAG;AACnB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,MAAM,GAAG;AACb,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -2,31 +2,26 @@ var capacitorCapacitorFlash = (function (exports, core) {
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const CapacitorFlash = core.registerPlugin('CapacitorFlash', {
|
|
5
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorFlashWeb()),
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapacitorFlashWeb()),
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
class CapacitorFlashWeb extends core.WebPlugin {
|
|
9
9
|
isAvailable() {
|
|
10
10
|
return Promise.resolve({ value: false });
|
|
11
11
|
}
|
|
12
|
-
;
|
|
13
12
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
13
|
switchOn(_options) {
|
|
15
|
-
throw new Error(
|
|
14
|
+
throw new Error('Method not implemented.');
|
|
16
15
|
}
|
|
17
|
-
;
|
|
18
16
|
switchOff() {
|
|
19
|
-
throw new Error(
|
|
17
|
+
throw new Error('Method not implemented.');
|
|
20
18
|
}
|
|
21
|
-
;
|
|
22
19
|
isSwitchedOn() {
|
|
23
|
-
throw new Error(
|
|
20
|
+
throw new Error('Method not implemented.');
|
|
24
21
|
}
|
|
25
|
-
;
|
|
26
22
|
toggle() {
|
|
27
|
-
throw new Error(
|
|
23
|
+
throw new Error('Method not implemented.');
|
|
28
24
|
}
|
|
29
|
-
;
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
var web = /*#__PURE__*/Object.freeze({
|
|
@@ -36,8 +31,6 @@ var capacitorCapacitorFlash = (function (exports, core) {
|
|
|
36
31
|
|
|
37
32
|
exports.CapacitorFlash = CapacitorFlash;
|
|
38
33
|
|
|
39
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
40
|
-
|
|
41
34
|
return exports;
|
|
42
35
|
|
|
43
36
|
})({}, capacitorExports);
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorFlash = registerPlugin('CapacitorFlash', {\n web: () => import('./web').then(m => new m.CapacitorFlashWeb()),\n});\nexport * from './definitions';\nexport { CapacitorFlash };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorFlashWeb extends WebPlugin {\n isAvailable() {\n return Promise.resolve({ value: false });\n }\n
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorFlash = registerPlugin('CapacitorFlash', {\n web: () => import('./web').then((m) => new m.CapacitorFlashWeb()),\n});\nexport * from './definitions';\nexport { CapacitorFlash };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorFlashWeb extends WebPlugin {\n isAvailable() {\n return Promise.resolve({ value: false });\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n switchOn(_options) {\n throw new Error('Method not implemented.');\n }\n switchOff() {\n throw new Error('Method not implemented.');\n }\n isSwitchedOn() {\n throw new Error('Method not implemented.');\n }\n toggle() {\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;IACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACrE,CAAC;;ICFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD,IAAI,WAAW,GAAG;IAClB,QAAQ,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACjD,KAAK;IACL;IACA,IAAI,QAAQ,CAAC,QAAQ,EAAE;IACvB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL,IAAI,SAAS,GAAG;IAChB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL,IAAI,YAAY,GAAG;IACnB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL,IAAI,MAAM,GAAG;IACb,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;;;;;;;;;;;;;;;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import AVFoundation
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
public class CapacitorFlash: NSObject {
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
public func isAvailable() -> Bool {
|
|
7
7
|
let device = AVCaptureDevice.default(for: AVMediaType.video)
|
|
8
8
|
return ((device?.hasTorch) != nil)
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
public func switchOn(intensity: Float = 1.0) -> Bool {
|
|
12
12
|
guard self.isAvailable()
|
|
13
13
|
else { return false }
|
|
14
14
|
|
|
@@ -25,8 +25,8 @@ import AVFoundation
|
|
|
25
25
|
return false
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
public func switchOff() -> Bool {
|
|
30
30
|
guard self.isAvailable()
|
|
31
31
|
else { return false }
|
|
32
32
|
|
|
@@ -42,8 +42,8 @@ import AVFoundation
|
|
|
42
42
|
return false
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
|
|
46
|
+
public func isSwitchedOn() -> Bool {
|
|
47
47
|
guard self.isAvailable()
|
|
48
48
|
else { return false }
|
|
49
49
|
|
|
@@ -51,12 +51,12 @@ import AVFoundation
|
|
|
51
51
|
return (device?.torchMode == AVCaptureDevice.TorchMode.on)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
public func toggle() -> Bool {
|
|
55
55
|
guard self.isAvailable()
|
|
56
56
|
else { return false }
|
|
57
57
|
|
|
58
58
|
let device = AVCaptureDevice.default(for: AVMediaType.video)
|
|
59
|
-
if
|
|
59
|
+
if device?.torchMode == AVCaptureDevice.TorchMode.on {
|
|
60
60
|
return self.switchOff()
|
|
61
61
|
} else {
|
|
62
62
|
return self.switchOn()
|
|
@@ -9,25 +9,25 @@ import Capacitor
|
|
|
9
9
|
public class CapacitorFlashPlugin: CAPPlugin {
|
|
10
10
|
private let implementation = CapacitorFlash()
|
|
11
11
|
|
|
12
|
-
@objc func isAvailable(_ call: CAPPluginCall) {
|
|
12
|
+
@objc func isAvailable(_ call: CAPPluginCall) {
|
|
13
13
|
call.resolve([
|
|
14
14
|
"value": implementation.isAvailable()
|
|
15
15
|
])
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
@objc func switchOn(_ call: CAPPluginCall) {
|
|
19
19
|
let intensity = call.getFloat("intensity") ?? 1.0
|
|
20
20
|
call.resolve([
|
|
21
21
|
"value": implementation.switchOn(intensity: intensity)
|
|
22
22
|
])
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
@objc func switchOff(_ call: CAPPluginCall) {
|
|
26
26
|
call.resolve([
|
|
27
27
|
"value": implementation.switchOff()
|
|
28
28
|
])
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
@objc func isSwitchedOn(_ call: CAPPluginCall) {
|
|
32
32
|
call.resolve([
|
|
33
33
|
"value": implementation.isSwitchedOn()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-flash",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.16",
|
|
4
4
|
"description": "Switch the Flashlight / Torch of your device.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
35
|
-
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
|
|
35
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -sdk iphoneos -scheme Plugin && cd ..",
|
|
36
36
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
37
37
|
"verify:web": "npm run build",
|
|
38
38
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
@@ -41,29 +41,34 @@
|
|
|
41
41
|
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
42
42
|
"swiftlint": "node-swiftlint",
|
|
43
43
|
"docgen": "docgen --api CapacitorFlashPlugin --output-readme README.md --output-json dist/docs.json",
|
|
44
|
-
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.
|
|
44
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
45
45
|
"clean": "rimraf ./dist",
|
|
46
46
|
"watch": "tsc --watch",
|
|
47
47
|
"prepublishOnly": "npm run build"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@capacitor/android": "^
|
|
51
|
-
"@capacitor/
|
|
52
|
-
"@capacitor/
|
|
53
|
-
"@capacitor/
|
|
50
|
+
"@capacitor/android": "^4.4.0",
|
|
51
|
+
"@capacitor/cli": "^4.4.0",
|
|
52
|
+
"@capacitor/core": "^4.4.0",
|
|
53
|
+
"@capacitor/docgen": "^0.2.0",
|
|
54
|
+
"@capacitor/ios": "^4.4.0",
|
|
54
55
|
"@ionic/eslint-config": "^0.3.0",
|
|
55
|
-
"@ionic/prettier-config": "^
|
|
56
|
+
"@ionic/prettier-config": "^2.0.0",
|
|
56
57
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
57
|
-
"eslint": "^
|
|
58
|
-
"
|
|
59
|
-
"
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
59
|
+
"@typescript-eslint/parser": "^5.42.1",
|
|
60
|
+
"eslint": "^8.27.0",
|
|
61
|
+
"eslint-plugin-import": "^2.26.0",
|
|
62
|
+
"husky": "^8.0.2",
|
|
63
|
+
"prettier": "^2.7.1",
|
|
64
|
+
"prettier-plugin-java": "^1.6.2",
|
|
60
65
|
"rimraf": "^3.0.2",
|
|
61
|
-
"rollup": "^2.
|
|
66
|
+
"rollup": "^3.2.5",
|
|
62
67
|
"swiftlint": "^1.0.1",
|
|
63
|
-
"typescript": "
|
|
68
|
+
"typescript": "^4.8.4"
|
|
64
69
|
},
|
|
65
70
|
"peerDependencies": {
|
|
66
|
-
"@capacitor/core": "^
|
|
71
|
+
"@capacitor/core": "^4.0.0"
|
|
67
72
|
},
|
|
68
73
|
"prettier": "@ionic/prettier-config",
|
|
69
74
|
"swiftlint": "@ionic/swiftlint-config",
|