@capgo/capacitor-flash 1.2.11 → 1.2.17

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.
@@ -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 = '12.0'
14
+ s.ios.deployment_target = '13.0'
15
15
  s.dependency 'Capacitor'
16
16
  s.swift_version = '5.1'
17
17
  end
@@ -1,27 +1,27 @@
1
1
  ext {
2
- junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
4
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
5
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
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:4.2.1'
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 : 30
21
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
22
22
  defaultConfig {
23
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
24
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
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
- import android.Manifest;
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
- private String cameraId;
33
- boolean isFlashStateOn = false;
34
-
35
- private CameraManager cameraManager;
36
-
37
-
38
- @Override
39
- public void load() {
40
- cameraManager = (CameraManager) this.bridge.getContext().getSystemService(Context.CAMERA_SERVICE);
41
- try {
42
-
43
- if (cameraManager != null) {
44
- cameraId = cameraManager.getCameraIdList()[0];
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
- @PluginMethod
54
- public void isAvailable(PluginCall call) {
55
- if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M && getPermissionState("camera") != PermissionState.GRANTED) {
56
- requestPermissionForAlias("camera", call, "cameraPermsCallback");
57
- } else {
58
- getAvailibility(call);
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
- @PermissionCallback
63
- private void getAvailibility(PluginCall call) {
64
- JSObject ret = new JSObject();
65
- if (cameraManager == null) {
66
- ret.put("value", false);
67
- call.resolve(ret);
68
- return;
69
- }
70
- try {
71
- boolean flashAvailable = cameraManager
72
- .getCameraCharacteristics(cameraId)
73
- .get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
74
- ret.put("value", flashAvailable);
75
- } catch (CameraAccessException e) {
76
- e.printStackTrace();
77
- ret.put("value", false);
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
- @RequiresApi(api = Build.VERSION_CODES.M)
83
- @PluginMethod
84
- public void switchOn(PluginCall call) {
85
- String value = call.getString("instensity"); // cannot be use in android
86
- JSObject ret = new JSObject();
87
- if (cameraManager == null) {
88
- ret.put("value", false);
89
- call.resolve(ret);
90
- return;
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
- @RequiresApi(api = Build.VERSION_CODES.M)
104
- @PluginMethod
105
- public void switchOff(PluginCall call) {
106
- JSObject ret = new JSObject();
107
- if (cameraManager == null) {
108
- ret.put("value", false);
109
- call.resolve(ret);
110
- return;
111
- }
112
- try {
113
- cameraManager.setTorchMode(cameraId, false);
114
- isFlashStateOn = false;
115
- ret.put("value", true);
116
- } catch (Exception e) {
117
- e.printStackTrace();
118
- ret.put("value", false);
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
- @PluginMethod
124
- public void isSwitchedOn(PluginCall call) {
125
- JSObject ret = new JSObject();
126
- ret.put("value", isFlashStateOn);
127
- call.resolve(ret);
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 };
@@ -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,CACnC,gBAAgB,EAChB;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;CAChE,CACF,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,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("Method not implemented.");
8
+ throw new Error('Method not implemented.');
10
9
  }
11
- ;
12
10
  switchOff() {
13
- throw new Error("Method not implemented.");
11
+ throw new Error('Method not implemented.');
14
12
  }
15
- ;
16
13
  isSwitchedOn() {
17
- throw new Error("Method not implemented.");
14
+ throw new Error('Method not implemented.');
18
15
  }
19
- ;
20
16
  toggle() {
21
- throw new Error("Method not implemented.");
17
+ throw new Error('Method not implemented.');
22
18
  }
23
- ;
24
19
  }
25
20
  //# sourceMappingURL=web.js.map
@@ -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,iBACX,SAAQ,SAAS;IAGjB,WAAW;QACT,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,CAAA;IACzC,CAAC;IAAA,CAAC;IAEF,6DAA6D;IAC7D,QAAQ,CAAC,QAAgC;QACrC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAAA,CAAC;IAEJ,SAAS;QACL,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAAA,CAAC;IAEJ,YAAY;QACR,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAAA,CAAC;IAEJ,MAAM;QACF,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAAA,CAAC;CACL"}
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"}
@@ -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("Method not implemented.");
15
+ throw new Error('Method not implemented.');
19
16
  }
20
- ;
21
17
  switchOff() {
22
- throw new Error("Method not implemented.");
18
+ throw new Error('Method not implemented.');
23
19
  }
24
- ;
25
20
  isSwitchedOn() {
26
- throw new Error("Method not implemented.");
21
+ throw new Error('Method not implemented.');
27
22
  }
28
- ;
29
23
  toggle() {
30
- throw new Error("Method not implemented.");
24
+ throw new Error('Method not implemented.');
31
25
  }
32
- ;
33
26
  }
34
27
 
35
28
  var web = /*#__PURE__*/Object.freeze({
@@ -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 ;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n switchOn(_options) {\n throw new Error(\"Method not implemented.\");\n }\n ;\n switchOff() {\n throw new Error(\"Method not implemented.\");\n }\n ;\n isSwitchedOn() {\n throw new Error(\"Method not implemented.\");\n }\n ;\n toggle() {\n throw new Error(\"Method not implemented.\");\n }\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,IAAI,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACnE,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;AACA,IAAI,QAAQ,CAAC,QAAQ,EAAE;AACvB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;AACA,IAAI,SAAS,GAAG;AAChB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;AACA,IAAI,YAAY,GAAG;AACnB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;AACA,IAAI,MAAM,GAAG;AACb,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;AACA;;;;;;;;;"}
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("Method not implemented.");
14
+ throw new Error('Method not implemented.');
16
15
  }
17
- ;
18
16
  switchOff() {
19
- throw new Error("Method not implemented.");
17
+ throw new Error('Method not implemented.');
20
18
  }
21
- ;
22
19
  isSwitchedOn() {
23
- throw new Error("Method not implemented.");
20
+ throw new Error('Method not implemented.');
24
21
  }
25
- ;
26
22
  toggle() {
27
- throw new Error("Method not implemented.");
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);
@@ -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 ;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n switchOn(_options) {\n throw new Error(\"Method not implemented.\");\n }\n ;\n switchOff() {\n throw new Error(\"Method not implemented.\");\n }\n ;\n isSwitchedOn() {\n throw new Error(\"Method not implemented.\");\n }\n ;\n toggle() {\n throw new Error(\"Method not implemented.\");\n }\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,IAAI,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACnE,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;IACA,IAAI,QAAQ,CAAC,QAAQ,EAAE;IACvB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;IACA,IAAI,SAAS,GAAG;IAChB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;IACA,IAAI,YAAY,GAAG;IACnB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;IACA,IAAI,MAAM,GAAG;IACb,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;IACA;;;;;;;;;;;;;;;;;"}
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
- @objc public class CapacitorFlash: NSObject {
4
+ public class CapacitorFlash: NSObject {
5
5
 
6
- @objc public func isAvailable() -> Bool {
6
+ public func isAvailable() -> Bool {
7
7
  let device = AVCaptureDevice.default(for: AVMediaType.video)
8
8
  return ((device?.hasTorch) != nil)
9
9
  }
10
-
11
- @objc public func switchOn(intensity: Float = 1.0) -> Bool {
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
- @objc public func switchOff() -> Bool {
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
- @objc public func isSwitchedOn() -> Bool {
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
- @objc public func toggle() -> Bool {
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 (device?.torchMode == AVCaptureDevice.TorchMode.on) {
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.11",
3
+ "version": "1.2.17",
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.js",
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": "^3.0.0",
51
- "@capacitor/core": "^3.0.0",
52
- "@capacitor/docgen": "0.0.18",
53
- "@capacitor/ios": "^3.0.0",
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": "^1.0.1",
56
+ "@ionic/prettier-config": "^2.0.0",
56
57
  "@ionic/swiftlint-config": "^1.1.2",
57
- "eslint": "^7.11.0",
58
- "prettier": "~2.2.0",
59
- "prettier-plugin-java": "~1.0.0",
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.32.0",
66
+ "rollup": "^3.2.5",
62
67
  "swiftlint": "^1.0.1",
63
- "typescript": "~4.0.3"
68
+ "typescript": "^4.8.4"
64
69
  },
65
70
  "peerDependencies": {
66
- "@capacitor/core": "^3.0.0 || ^4.0.0"
71
+ "@capacitor/core": "^4.0.0"
67
72
  },
68
73
  "prettier": "@ionic/prettier-config",
69
74
  "swiftlint": "@ionic/swiftlint-config",