@capgo/capacitor-flash 8.0.41 → 8.0.42
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/android/src/main/java/ee/forgr/plugin/capacitor_flash/CapacitorFlashPlugin.java +1 -1
- package/dist/esm/web.js +6 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +6 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +6 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorFlashPlugin/CapacitorFlashPlugin.swift +1 -1
- package/package.json +5 -7
|
@@ -15,7 +15,7 @@ import com.getcapacitor.annotation.CapacitorPlugin;
|
|
|
15
15
|
@CapacitorPlugin(name = "CapacitorFlash")
|
|
16
16
|
public class CapacitorFlashPlugin extends Plugin {
|
|
17
17
|
|
|
18
|
-
private final String pluginVersion = "8.0.
|
|
18
|
+
private final String pluginVersion = "8.0.42";
|
|
19
19
|
|
|
20
20
|
private String cameraId;
|
|
21
21
|
boolean isFlashStateOn = false;
|
package/dist/esm/web.js
CHANGED
|
@@ -47,7 +47,9 @@ export class CapacitorFlashWeb extends WebPlugin {
|
|
|
47
47
|
this.torchOn = true;
|
|
48
48
|
}
|
|
49
49
|
catch (e) {
|
|
50
|
-
|
|
50
|
+
const error = new Error(`Failed to switch on torch: ${e}`);
|
|
51
|
+
error.cause = e;
|
|
52
|
+
throw error;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
async switchOff() {
|
|
@@ -63,7 +65,9 @@ export class CapacitorFlashWeb extends WebPlugin {
|
|
|
63
65
|
this.torchOn = false;
|
|
64
66
|
}
|
|
65
67
|
catch (e) {
|
|
66
|
-
|
|
68
|
+
const error = new Error(`Failed to switch off torch: ${e}`);
|
|
69
|
+
error.cause = e;
|
|
70
|
+
throw error;
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
async isSwitchedOn() {
|
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,iBAAkB,SAAQ,SAAS;IAAhD;;QACU,WAAM,GAAuB,IAAI,CAAC;QAClC,UAAK,GAA4B,IAAI,CAAC;QACtC,YAAO,GAAG,KAAK,CAAC;
|
|
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;IAAhD;;QACU,WAAM,GAAuB,IAAI,CAAC;QAClC,UAAK,GAA4B,IAAI,CAAC;QACtC,YAAO,GAAG,KAAK,CAAC;IAqF1B,CAAC;IAnFC,KAAK,CAAC,WAAW;;QACf,IAAI,CAAC;YACH,IAAI,CAAC,CAAA,MAAA,SAAS,CAAC,YAAY,0CAAE,YAAY,CAAA,EAAE,CAAC;gBAC1C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;YAC1B,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC;gBACvD,KAAK,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE;aACrC,CAAC,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC;YACzC,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,eAAe,qDAAoD,CAAC;YAC/F,MAAM,QAAQ,GAAG,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,MAAK,IAAI,CAAC;YAE9C,uBAAuB;YACvB,KAAK,CAAC,IAAI,EAAE,CAAC;YAEb,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QAC7B,CAAC;QAAC,WAAM,CAAC;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C;YACrB,CAAC;YACD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAC;YAC3D,KAAqC,CAAC,KAAK,GAAG,CAAC,CAAC;YACjD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -54,7 +54,9 @@ class CapacitorFlashWeb extends core.WebPlugin {
|
|
|
54
54
|
this.torchOn = true;
|
|
55
55
|
}
|
|
56
56
|
catch (e) {
|
|
57
|
-
|
|
57
|
+
const error = new Error(`Failed to switch on torch: ${e}`);
|
|
58
|
+
error.cause = e;
|
|
59
|
+
throw error;
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
async switchOff() {
|
|
@@ -70,7 +72,9 @@ class CapacitorFlashWeb extends core.WebPlugin {
|
|
|
70
72
|
this.torchOn = false;
|
|
71
73
|
}
|
|
72
74
|
catch (e) {
|
|
73
|
-
|
|
75
|
+
const error = new Error(`Failed to switch off torch: ${e}`);
|
|
76
|
+
error.cause = e;
|
|
77
|
+
throw error;
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
async isSwitchedOn() {
|
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 constructor() {\n super(...arguments);\n this.stream = null;\n this.track = null;\n this.torchOn = false;\n }\n async isAvailable() {\n var _a, _b;\n try {\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n return { value: false };\n }\n const stream = await navigator.mediaDevices.getUserMedia({\n video: { facingMode: 'environment' },\n });\n const track = stream.getVideoTracks()[0];\n const capabilities = (_b = track.getCapabilities) === null || _b === void 0 ? void 0 : _b.call(track);\n const hasTorch = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.torch) === true;\n // Stop the test stream\n track.stop();\n return { value: hasTorch };\n }\n catch (_c) {\n return { value: false };\n }\n }\n async switchOn(_options) {\n var _a;\n try {\n // If we already have a stream with torch on, just return\n if (this.stream && this.torchOn) {\n return;\n }\n // Get camera stream if we don't have one\n if (!this.stream) {\n this.stream = await navigator.mediaDevices.getUserMedia({\n video: { facingMode: 'environment' },\n });\n this.track = this.stream.getVideoTracks()[0];\n }\n // Apply torch constraint\n await ((_a = this.track) === null || _a === void 0 ? void 0 : _a.applyConstraints({\n advanced: [{ torch: true }],\n }));\n this.torchOn = true;\n }\n catch (e) {\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 constructor() {\n super(...arguments);\n this.stream = null;\n this.track = null;\n this.torchOn = false;\n }\n async isAvailable() {\n var _a, _b;\n try {\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n return { value: false };\n }\n const stream = await navigator.mediaDevices.getUserMedia({\n video: { facingMode: 'environment' },\n });\n const track = stream.getVideoTracks()[0];\n const capabilities = (_b = track.getCapabilities) === null || _b === void 0 ? void 0 : _b.call(track);\n const hasTorch = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.torch) === true;\n // Stop the test stream\n track.stop();\n return { value: hasTorch };\n }\n catch (_c) {\n return { value: false };\n }\n }\n async switchOn(_options) {\n var _a;\n try {\n // If we already have a stream with torch on, just return\n if (this.stream && this.torchOn) {\n return;\n }\n // Get camera stream if we don't have one\n if (!this.stream) {\n this.stream = await navigator.mediaDevices.getUserMedia({\n video: { facingMode: 'environment' },\n });\n this.track = this.stream.getVideoTracks()[0];\n }\n // Apply torch constraint\n await ((_a = this.track) === null || _a === void 0 ? void 0 : _a.applyConstraints({\n advanced: [{ torch: true }],\n }));\n this.torchOn = true;\n }\n catch (e) {\n const error = new Error(`Failed to switch on torch: ${e}`);\n error.cause = e;\n throw error;\n }\n }\n async switchOff() {\n try {\n if (this.track) {\n // Turn off torch by stopping the track\n this.track.stop();\n this.track = null;\n }\n if (this.stream) {\n this.stream = null;\n }\n this.torchOn = false;\n }\n catch (e) {\n const error = new Error(`Failed to switch off torch: ${e}`);\n error.cause = e;\n throw error;\n }\n }\n async isSwitchedOn() {\n return { value: this.torchOn };\n }\n async toggle() {\n if (this.torchOn) {\n await this.switchOff();\n }\n else {\n await this.switchOn({});\n }\n return { value: this.torchOn };\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names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54
|
}
|
|
55
55
|
catch (e) {
|
|
56
|
-
|
|
56
|
+
const error = new Error(`Failed to switch on torch: ${e}`);
|
|
57
|
+
error.cause = e;
|
|
58
|
+
throw error;
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
async switchOff() {
|
|
@@ -69,7 +71,9 @@ var capacitorCapacitorFlash = (function (exports, core) {
|
|
|
69
71
|
this.torchOn = false;
|
|
70
72
|
}
|
|
71
73
|
catch (e) {
|
|
72
|
-
|
|
74
|
+
const error = new Error(`Failed to switch off torch: ${e}`);
|
|
75
|
+
error.cause = e;
|
|
76
|
+
throw error;
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
async isSwitchedOn() {
|
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 constructor() {\n super(...arguments);\n this.stream = null;\n this.track = null;\n this.torchOn = false;\n }\n async isAvailable() {\n var _a, _b;\n try {\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n return { value: false };\n }\n const stream = await navigator.mediaDevices.getUserMedia({\n video: { facingMode: 'environment' },\n });\n const track = stream.getVideoTracks()[0];\n const capabilities = (_b = track.getCapabilities) === null || _b === void 0 ? void 0 : _b.call(track);\n const hasTorch = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.torch) === true;\n // Stop the test stream\n track.stop();\n return { value: hasTorch };\n }\n catch (_c) {\n return { value: false };\n }\n }\n async switchOn(_options) {\n var _a;\n try {\n // If we already have a stream with torch on, just return\n if (this.stream && this.torchOn) {\n return;\n }\n // Get camera stream if we don't have one\n if (!this.stream) {\n this.stream = await navigator.mediaDevices.getUserMedia({\n video: { facingMode: 'environment' },\n });\n this.track = this.stream.getVideoTracks()[0];\n }\n // Apply torch constraint\n await ((_a = this.track) === null || _a === void 0 ? void 0 : _a.applyConstraints({\n advanced: [{ torch: true }],\n }));\n this.torchOn = true;\n }\n catch (e) {\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 constructor() {\n super(...arguments);\n this.stream = null;\n this.track = null;\n this.torchOn = false;\n }\n async isAvailable() {\n var _a, _b;\n try {\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n return { value: false };\n }\n const stream = await navigator.mediaDevices.getUserMedia({\n video: { facingMode: 'environment' },\n });\n const track = stream.getVideoTracks()[0];\n const capabilities = (_b = track.getCapabilities) === null || _b === void 0 ? void 0 : _b.call(track);\n const hasTorch = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.torch) === true;\n // Stop the test stream\n track.stop();\n return { value: hasTorch };\n }\n catch (_c) {\n return { value: false };\n }\n }\n async switchOn(_options) {\n var _a;\n try {\n // If we already have a stream with torch on, just return\n if (this.stream && this.torchOn) {\n return;\n }\n // Get camera stream if we don't have one\n if (!this.stream) {\n this.stream = await navigator.mediaDevices.getUserMedia({\n video: { facingMode: 'environment' },\n });\n this.track = this.stream.getVideoTracks()[0];\n }\n // Apply torch constraint\n await ((_a = this.track) === null || _a === void 0 ? void 0 : _a.applyConstraints({\n advanced: [{ torch: true }],\n }));\n this.torchOn = true;\n }\n catch (e) {\n const error = new Error(`Failed to switch on torch: ${e}`);\n error.cause = e;\n throw error;\n }\n }\n async switchOff() {\n try {\n if (this.track) {\n // Turn off torch by stopping the track\n this.track.stop();\n this.track = null;\n }\n if (this.stream) {\n this.stream = null;\n }\n this.torchOn = false;\n }\n catch (e) {\n const error = new Error(`Failed to switch off torch: ${e}`);\n error.cause = e;\n throw error;\n }\n }\n async isSwitchedOn() {\n return { value: this.torchOn };\n }\n async toggle() {\n if (this.torchOn) {\n await this.switchOff();\n }\n else {\n await this.switchOn({});\n }\n return { value: this.torchOn };\n }\n async getPluginVersion() {\n return { version: 'web' };\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,KAAK,CAAC,GAAG,SAAS,CAAC;IAC3B,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAI;IAC1B,QAAQ,IAAI,CAAC,KAAK,GAAG,IAAI;IACzB,QAAQ,IAAI,CAAC,OAAO,GAAG,KAAK;IAC5B,IAAI;IACJ,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,IAAI,EAAE,EAAE,EAAE;IAClB,QAAQ,IAAI;IACZ,YAAY,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,YAAY,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE;IACvG,gBAAgB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;IACvC,YAAY;IACZ,YAAY,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC;IACrE,gB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AE;IAClC,QAAQ;IACR,aAAa;IACb,YAAY,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnC,QAAQ;IACR,QAAQ,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE;IACtC,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;"}
|
|
@@ -7,7 +7,7 @@ import Capacitor
|
|
|
7
7
|
*/
|
|
8
8
|
@objc(CapacitorFlashPlugin)
|
|
9
9
|
public class CapacitorFlashPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
-
private let pluginVersion: String = "8.0.
|
|
10
|
+
private let pluginVersion: String = "8.0.42"
|
|
11
11
|
public let identifier = "CapacitorFlashPlugin"
|
|
12
12
|
public let jsName = "CapacitorFlash"
|
|
13
13
|
public let pluginMethods: [CAPPluginMethod] = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-flash",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.42",
|
|
4
4
|
"description": "Switch the Flashlight / Torch of your device.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -60,12 +60,13 @@
|
|
|
60
60
|
"@capacitor/core": "^8.0.0",
|
|
61
61
|
"@capacitor/docgen": "^0.3.1",
|
|
62
62
|
"@capacitor/ios": "^8.0.0",
|
|
63
|
-
"@ionic/eslint-config": "^0.
|
|
63
|
+
"@ionic/eslint-config": "^0.5.0",
|
|
64
64
|
"@ionic/prettier-config": "^4.0.0",
|
|
65
65
|
"@ionic/swiftlint-config": "^2.0.0",
|
|
66
66
|
"@types/node": "^24.10.1",
|
|
67
|
-
"eslint": "^8.
|
|
68
|
-
"eslint
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^8.70.0",
|
|
68
|
+
"@typescript-eslint/parser": "^8.70.0",
|
|
69
|
+
"eslint": "^10.0.0",
|
|
69
70
|
"husky": "^9.1.7",
|
|
70
71
|
"prettier": "^3.6.2",
|
|
71
72
|
"prettier-plugin-java": "^2.7.7",
|
|
@@ -78,9 +79,6 @@
|
|
|
78
79
|
"peerDependencies": {
|
|
79
80
|
"@capacitor/core": ">=8.0.0"
|
|
80
81
|
},
|
|
81
|
-
"eslintConfig": {
|
|
82
|
-
"extends": "@ionic/eslint-config/recommended"
|
|
83
|
-
},
|
|
84
82
|
"prettier": "@ionic/prettier-config",
|
|
85
83
|
"swiftlint": "@ionic/swiftlint-config",
|
|
86
84
|
"capacitor": {
|