@capacitor-community/camera-preview 7.0.5 → 8.0.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/CapacitorCommunityCameraPreview.podspec +1 -1
- package/Package.swift +3 -3
- package/README.md +5 -3
- package/android/build.gradle +28 -21
- package/ios/Sources/CameraPreviewPlugin/CameraController.swift +17 -10
- package/ios/Sources/CameraPreviewPlugin/CameraPreviewPlugin.swift +71 -59
- package/package.json +34 -34
- /package/ios/Tests/CameraPreviewPluginTests/{CameraPreviewPluginTests.swift → CameraPreviewTests.swift} +0 -0
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => 'https://github.com/capacitor-community/camera-preview.git', :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '15.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
package/Package.swift
CHANGED
|
@@ -3,14 +3,14 @@ import PackageDescription
|
|
|
3
3
|
|
|
4
4
|
let package = Package(
|
|
5
5
|
name: "CapacitorCommunityCameraPreview",
|
|
6
|
-
platforms: [.iOS(.
|
|
6
|
+
platforms: [.iOS(.v15)],
|
|
7
7
|
products: [
|
|
8
8
|
.library(
|
|
9
9
|
name: "CapacitorCommunityCameraPreviewPlugin",
|
|
10
10
|
targets: ["CameraPreviewPlugin"])
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
|
-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.2")
|
|
14
14
|
],
|
|
15
15
|
targets: [
|
|
16
16
|
.target(
|
|
@@ -25,4 +25,4 @@ let package = Package(
|
|
|
25
25
|
dependencies: ["CameraPreviewPlugin"],
|
|
26
26
|
path: "ios/Tests/CameraPreviewPluginTests")
|
|
27
27
|
]
|
|
28
|
-
)
|
|
28
|
+
)
|
package/README.md
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
<h3 align="center">Capacitor Camera Preview</h3>
|
|
3
3
|
<p align="center"><strong><code>@capacitor-community/camera-preview</code></strong></p>
|
|
4
4
|
<br>
|
|
5
|
-
<p align="center"><strong>CAPACITOR
|
|
5
|
+
<p align="center"><strong>CAPACITOR 8</strong></p><br>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
Capacitor plugin that allows camera interaction from Javascript and HTML<br>(based on cordova-plugin-camera-preview).
|
|
9
9
|
</p>
|
|
10
10
|
<br>
|
|
11
|
-
Version
|
|
11
|
+
Version 8 of this plugin requires Capacitor 8.
|
|
12
12
|
|
|
13
|
-
If you are using Capacitor
|
|
13
|
+
If you are using Capacitor 7, use [version 7.0.5](https://github.com/capacitor-community/camera-preview/releases/tag/v7.0.5)
|
|
14
|
+
|
|
15
|
+
If you are using Capacitor 6, use [version 6.0.1](https://github.com/capacitor-community/camera-preview/releases/tag/v6.0.1)
|
|
14
16
|
|
|
15
17
|
If you are using Capacitor 5, use [version 5](https://github.com/capacitor-community/camera-preview/releases/tag/v5.0.0)
|
|
16
18
|
|
package/android/build.gradle
CHANGED
|
@@ -1,42 +1,49 @@
|
|
|
1
|
-
ext {
|
|
2
|
-
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
-
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
-
androidxExifInterfaceVersion = project.hasProperty('androidxExifInterfaceVersion') ? rootProject.ext.androidxExifInterfaceVersion : '1.3.7'
|
|
5
|
-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
6
|
-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
7
|
-
}
|
|
8
|
-
|
|
9
1
|
buildscript {
|
|
2
|
+
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '2.2.20'
|
|
3
|
+
|
|
10
4
|
repositories {
|
|
11
|
-
mavenCentral()
|
|
12
5
|
google()
|
|
6
|
+
mavenCentral()
|
|
13
7
|
}
|
|
14
8
|
dependencies {
|
|
15
|
-
classpath 'com.android.tools.build:gradle:8.
|
|
9
|
+
classpath 'com.android.tools.build:gradle:8.13.0'
|
|
16
10
|
}
|
|
17
11
|
}
|
|
18
12
|
|
|
13
|
+
ext {
|
|
14
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
15
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
|
|
16
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
|
|
17
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
|
|
18
|
+
androidxExifInterfaceVersion = project.hasProperty('androidxExifInterfaceVersion') ? rootProject.ext.androidxExifInterfaceVersion : '1.4.2'
|
|
19
|
+
}
|
|
20
|
+
|
|
19
21
|
apply plugin: 'com.android.library'
|
|
20
22
|
|
|
21
23
|
android {
|
|
22
|
-
namespace "com.ahm.capacitor.camera.preview.capacitorcamerapreview"
|
|
23
|
-
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
24
|
+
namespace = "com.ahm.capacitor.camera.preview.capacitorcamerapreview"
|
|
25
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion as Integer : 36
|
|
26
|
+
|
|
24
27
|
defaultConfig {
|
|
25
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
26
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
27
|
-
versionCode 1
|
|
28
|
-
versionName "1.0"
|
|
29
|
-
|
|
28
|
+
minSdkVersion = project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion as Integer : 24
|
|
29
|
+
targetSdkVersion = project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion as Integer : 36
|
|
30
|
+
versionCode = 1
|
|
31
|
+
versionName = "1.0.0"
|
|
32
|
+
|
|
33
|
+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
30
34
|
}
|
|
35
|
+
|
|
31
36
|
buildTypes {
|
|
32
37
|
release {
|
|
33
|
-
minifyEnabled false
|
|
38
|
+
minifyEnabled = false
|
|
34
39
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
|
|
43
|
+
lint {
|
|
44
|
+
abortOnError = false
|
|
39
45
|
}
|
|
46
|
+
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
repositories {
|
|
@@ -44,12 +51,12 @@ repositories {
|
|
|
44
51
|
mavenCentral()
|
|
45
52
|
}
|
|
46
53
|
|
|
47
|
-
|
|
48
54
|
dependencies {
|
|
49
55
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
50
56
|
implementation project(':capacitor-android')
|
|
51
57
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
52
58
|
implementation "androidx.exifinterface:exifinterface:$androidxExifInterfaceVersion"
|
|
59
|
+
|
|
53
60
|
testImplementation "junit:junit:$junitVersion"
|
|
54
61
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
55
62
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -185,10 +185,14 @@ extension CameraController {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
func updateVideoOrientation() {
|
|
188
|
-
assert(Thread.isMainThread) //
|
|
188
|
+
assert(Thread.isMainThread) // UIKit access requires main thread
|
|
189
|
+
|
|
190
|
+
let currentOrientation = UIApplication.shared.connectedScenes
|
|
191
|
+
.first(where: { $0 is UIWindowScene })
|
|
192
|
+
.flatMap({ $0 as? UIWindowScene })?.interfaceOrientation ?? .unknown
|
|
189
193
|
|
|
190
194
|
let videoOrientation: AVCaptureVideoOrientation
|
|
191
|
-
switch
|
|
195
|
+
switch currentOrientation {
|
|
192
196
|
case .portrait:
|
|
193
197
|
videoOrientation = .portrait
|
|
194
198
|
case .landscapeLeft:
|
|
@@ -484,10 +488,13 @@ extension CameraController: UIGestureRecognizerDelegate {
|
|
|
484
488
|
}
|
|
485
489
|
|
|
486
490
|
extension CameraController: AVCapturePhotoCaptureDelegate {
|
|
487
|
-
public func photoOutput(_
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
+
public func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
|
|
492
|
+
if let error = error {
|
|
493
|
+
self.photoCaptureCompletionBlock?(nil, error)
|
|
494
|
+
return
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if let data = photo.fileDataRepresentation(), let image = UIImage(data: data) {
|
|
491
498
|
self.photoCaptureCompletionBlock?(image.fixedOrientation(), nil)
|
|
492
499
|
} else {
|
|
493
500
|
self.photoCaptureCompletionBlock?(nil, CameraControllerError.unknown)
|
|
@@ -610,11 +617,11 @@ extension UIImage {
|
|
|
610
617
|
// Flip image one more time if needed to, this is to prevent flipped image
|
|
611
618
|
switch imageOrientation {
|
|
612
619
|
case .upMirrored, .downMirrored:
|
|
613
|
-
transform.translatedBy(x: size.width, y: 0)
|
|
614
|
-
transform.scaledBy(x: -1, y: 1)
|
|
620
|
+
transform = transform.translatedBy(x: size.width, y: 0)
|
|
621
|
+
transform = transform.scaledBy(x: -1, y: 1)
|
|
615
622
|
case .leftMirrored, .rightMirrored:
|
|
616
|
-
transform.translatedBy(x: size.height, y: 0)
|
|
617
|
-
transform.scaledBy(x: -1, y: 1)
|
|
623
|
+
transform = transform.translatedBy(x: size.height, y: 0)
|
|
624
|
+
transform = transform.scaledBy(x: -1, y: 1)
|
|
618
625
|
case .up, .down, .left, .right:
|
|
619
626
|
break
|
|
620
627
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import Capacitor
|
|
3
3
|
import AVFoundation
|
|
4
|
+
import UIKit
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
8
|
* here: https://capacitor.ionicframework.com/docs/plugins/ios
|
|
@@ -40,6 +42,13 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
40
42
|
var highResolutionOutput: Bool = false
|
|
41
43
|
var disableAudio: Bool = false
|
|
42
44
|
|
|
45
|
+
// Helper to get the current interface orientation via connectedScenes (iOS 15+)
|
|
46
|
+
private func getInterfaceOrientation() -> UIInterfaceOrientation {
|
|
47
|
+
return UIApplication.shared.connectedScenes
|
|
48
|
+
.first(where: { $0 is UIWindowScene })
|
|
49
|
+
.flatMap({ $0 as? UIWindowScene })?.interfaceOrientation ?? .unknown
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
@objc func rotated() {
|
|
44
53
|
guard let previewView = self.previewView,
|
|
45
54
|
let x = self.x,
|
|
@@ -50,13 +59,14 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
50
59
|
}
|
|
51
60
|
|
|
52
61
|
let adjustedHeight = self.paddingBottom != nil ? height - self.paddingBottom! : height
|
|
62
|
+
let orientation = getInterfaceOrientation()
|
|
53
63
|
|
|
54
|
-
if
|
|
64
|
+
if orientation.isLandscape {
|
|
55
65
|
previewView.frame = CGRect(x: y, y: x, width: max(adjustedHeight, width), height: min(adjustedHeight, width))
|
|
56
66
|
self.cameraController.previewLayer?.frame = previewView.frame
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
if
|
|
69
|
+
if orientation.isPortrait {
|
|
60
70
|
previewView.frame = CGRect(x: x, y: y, width: min(adjustedHeight, width), height: max(adjustedHeight, width))
|
|
61
71
|
self.cameraController.previewLayer?.frame = previewView.frame
|
|
62
72
|
}
|
|
@@ -91,52 +101,51 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
91
101
|
self.enableZoom = call.getBool("enableZoom") ?? false
|
|
92
102
|
self.disableAudio = call.getBool("disableAudio") ?? false
|
|
93
103
|
|
|
94
|
-
AVCaptureDevice.requestAccess(for: .video
|
|
95
|
-
guard
|
|
96
|
-
|
|
104
|
+
AVCaptureDevice.requestAccess(for: .video) { [weak self] granted in
|
|
105
|
+
guard let self = self else { return }
|
|
106
|
+
if !granted {
|
|
107
|
+
call.reject("Camera permission denied")
|
|
97
108
|
return
|
|
98
109
|
}
|
|
99
110
|
|
|
100
111
|
DispatchQueue.main.async {
|
|
101
112
|
if self.cameraController.captureSession?.isRunning ?? false {
|
|
102
113
|
call.reject("camera already started")
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if self.rotateWhenOrientationChanged == true {
|
|
130
|
-
NotificationCenter.default.addObserver(self, selector: #selector(CameraPreview.rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
call.resolve()
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
self.cameraController.prepare(cameraPosition: self.cameraPosition, disableAudio: self.disableAudio) {error in
|
|
117
|
+
if let error = error {
|
|
118
|
+
print(error)
|
|
119
|
+
call.reject(error.localizedDescription)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
guard let height = self.height, let width = self.width else {
|
|
123
|
+
call.reject("Invalid dimensions")
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let adjustedHeight = self.paddingBottom != nil ? height - self.paddingBottom! : height
|
|
128
|
+
self.previewView = UIView(frame: CGRect(x: self.x ?? 0, y: self.y ?? 0, width: width, height: adjustedHeight))
|
|
129
|
+
self.webView?.isOpaque = false
|
|
130
|
+
self.webView?.backgroundColor = UIColor.clear
|
|
131
|
+
self.webView?.scrollView.backgroundColor = UIColor.clear
|
|
132
|
+
self.webView?.superview?.addSubview(self.previewView)
|
|
133
|
+
if let toBack = self.toBack, toBack {
|
|
134
|
+
self.webView?.superview?.bringSubviewToFront(self.webView!)
|
|
135
|
+
}
|
|
136
|
+
try? self.cameraController.displayPreview(on: self.previewView)
|
|
137
|
+
|
|
138
|
+
let frontView = (self.toBack ?? false) ? self.webView : self.previewView
|
|
139
|
+
self.cameraController.setupGestures(target: frontView ?? self.previewView, enableZoom: self.enableZoom ?? false)
|
|
134
140
|
|
|
141
|
+
if self.rotateWhenOrientationChanged == true {
|
|
142
|
+
NotificationCenter.default.addObserver(self, selector: #selector(CameraPreview.rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
|
|
135
143
|
}
|
|
144
|
+
|
|
145
|
+
call.resolve()
|
|
136
146
|
}
|
|
137
147
|
}
|
|
138
|
-
}
|
|
139
|
-
|
|
148
|
+
}
|
|
140
149
|
}
|
|
141
150
|
|
|
142
151
|
@objc func flip(_ call: CAPPluginCall) {
|
|
@@ -175,9 +184,9 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
175
184
|
let identifier = UUID()
|
|
176
185
|
let randomIdentifier = identifier.uuidString.replacingOccurrences(of: "-", with: "")
|
|
177
186
|
let finalIdentifier = String(randomIdentifier.prefix(8))
|
|
178
|
-
let fileName="cpcp_capture_"+finalIdentifier+".jpg"
|
|
179
|
-
|
|
180
|
-
return
|
|
187
|
+
let fileName = "cpcp_capture_" + finalIdentifier + ".jpg"
|
|
188
|
+
|
|
189
|
+
return path.appendingPathComponent(fileName)
|
|
181
190
|
}
|
|
182
191
|
|
|
183
192
|
@objc func capture(_ call: CAPPluginCall) {
|
|
@@ -185,15 +194,16 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
185
194
|
|
|
186
195
|
let quality: Int? = call.getInt("quality", 85)
|
|
187
196
|
|
|
188
|
-
self.cameraController.captureImage { (image, error) in
|
|
197
|
+
self.cameraController.captureImage { [weak self] (image, error) in
|
|
198
|
+
guard let self = self else { return }
|
|
199
|
+
|
|
200
|
+
if let error = error {
|
|
201
|
+
call.reject(error.localizedDescription)
|
|
202
|
+
return
|
|
203
|
+
}
|
|
189
204
|
|
|
190
205
|
guard let image = image else {
|
|
191
|
-
|
|
192
|
-
guard let error = error else {
|
|
193
|
-
call.reject("Image capture error")
|
|
194
|
-
return
|
|
195
|
-
}
|
|
196
|
-
call.reject(error.localizedDescription)
|
|
206
|
+
call.reject("Image capture failed: no data received")
|
|
197
207
|
return
|
|
198
208
|
}
|
|
199
209
|
let imageData: Data?
|
|
@@ -209,7 +219,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
209
219
|
call.resolve(["value": imageBase64!])
|
|
210
220
|
} else {
|
|
211
221
|
do {
|
|
212
|
-
let fileUrl=self.getTempFilePath()
|
|
222
|
+
let fileUrl = self.getTempFilePath()
|
|
213
223
|
try imageData?.write(to: fileUrl)
|
|
214
224
|
call.resolve(["value": fileUrl.absoluteString])
|
|
215
225
|
} catch {
|
|
@@ -222,7 +232,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
222
232
|
|
|
223
233
|
@objc func captureSample(_ call: CAPPluginCall) {
|
|
224
234
|
DispatchQueue.main.async {
|
|
225
|
-
let quality
|
|
235
|
+
let quality = call.getInt("quality", 85)
|
|
226
236
|
|
|
227
237
|
self.cameraController.captureSample { image, error in
|
|
228
238
|
guard let image = image else {
|
|
@@ -232,11 +242,13 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
232
242
|
}
|
|
233
243
|
|
|
234
244
|
let imageData: Data?
|
|
245
|
+
let compression = CGFloat(quality) / 100.0
|
|
246
|
+
|
|
235
247
|
if self.cameraPosition == "front" {
|
|
236
248
|
let flippedImage = image.withHorizontallyFlippedOrientation()
|
|
237
|
-
imageData = flippedImage.jpegData(compressionQuality:
|
|
249
|
+
imageData = flippedImage.jpegData(compressionQuality: compression)
|
|
238
250
|
} else {
|
|
239
|
-
imageData = image.jpegData(compressionQuality:
|
|
251
|
+
imageData = image.jpegData(compressionQuality: compression)
|
|
240
252
|
}
|
|
241
253
|
|
|
242
254
|
if self.storeToFile == false {
|
|
@@ -266,22 +278,23 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
266
278
|
|
|
267
279
|
@objc func setFlashMode(_ call: CAPPluginCall) {
|
|
268
280
|
guard let flashMode = call.getString("flashMode") else {
|
|
269
|
-
call.reject("
|
|
281
|
+
call.reject("flashMode parameter is required")
|
|
270
282
|
return
|
|
271
283
|
}
|
|
272
284
|
do {
|
|
273
285
|
var flashModeAsEnum: AVCaptureDevice.FlashMode?
|
|
274
286
|
switch flashMode {
|
|
275
287
|
case "off":
|
|
276
|
-
flashModeAsEnum =
|
|
288
|
+
flashModeAsEnum = .off
|
|
277
289
|
case "on":
|
|
278
|
-
flashModeAsEnum =
|
|
290
|
+
flashModeAsEnum = .on
|
|
279
291
|
case "auto":
|
|
280
|
-
flashModeAsEnum =
|
|
292
|
+
flashModeAsEnum = .auto
|
|
281
293
|
default: break
|
|
282
294
|
}
|
|
283
|
-
|
|
284
|
-
|
|
295
|
+
|
|
296
|
+
if let mode = flashModeAsEnum {
|
|
297
|
+
try self.cameraController.setFlashMode(flashMode: mode)
|
|
285
298
|
} else if flashMode == "torch" {
|
|
286
299
|
try self.cameraController.setTorchMode()
|
|
287
300
|
} else {
|
|
@@ -334,5 +347,4 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
334
347
|
}
|
|
335
348
|
}
|
|
336
349
|
}
|
|
337
|
-
|
|
338
350
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/camera-preview",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Camera preview",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/esm/index.d.ts",
|
|
8
8
|
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Sources",
|
|
14
|
+
"ios/Tests",
|
|
15
|
+
"Package.swift",
|
|
16
|
+
"CapacitorCommunityCameraPreview.podspec",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"author": "Ariel Hernandez Musa",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/capacitor-community/camera-preview.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/capacitor-community/camera-preview/issues"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"capacitor",
|
|
30
|
+
"plugin",
|
|
31
|
+
"native",
|
|
32
|
+
"ios",
|
|
33
|
+
"android"
|
|
34
|
+
],
|
|
9
35
|
"scripts": {
|
|
10
36
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
11
37
|
"verify:ios": "xcodebuild -scheme CapacitorCommunityCameraPreview -destination generic/platform=iOS",
|
|
@@ -22,12 +48,10 @@
|
|
|
22
48
|
"prepublishOnly": "npm run build",
|
|
23
49
|
"prepare": "husky install && npm run build"
|
|
24
50
|
},
|
|
25
|
-
"author": "Ariel Hernandez Musa",
|
|
26
|
-
"license": "MIT",
|
|
27
51
|
"devDependencies": {
|
|
28
|
-
"@capacitor/android": "^
|
|
29
|
-
"@capacitor/core": "^
|
|
30
|
-
"@capacitor/ios": "^
|
|
52
|
+
"@capacitor/android": "^8.0.2",
|
|
53
|
+
"@capacitor/core": "^8.0.2",
|
|
54
|
+
"@capacitor/ios": "^8.0.2",
|
|
31
55
|
"@ionic/eslint-config": "^0.4.0",
|
|
32
56
|
"@ionic/prettier-config": "^4.0.0",
|
|
33
57
|
"@ionic/swiftlint-config": "^2.0.0",
|
|
@@ -36,39 +60,22 @@
|
|
|
36
60
|
"concurrently": "^9.2.1",
|
|
37
61
|
"eslint": "^9.39.2",
|
|
38
62
|
"husky": "^9.1.7",
|
|
39
|
-
"prettier": "^3.
|
|
40
|
-
"prettier-plugin-java": "^2.
|
|
63
|
+
"prettier": "^3.6.2",
|
|
64
|
+
"prettier-plugin-java": "^2.7.7",
|
|
41
65
|
"pretty-quick": "^4.1.1",
|
|
42
66
|
"rimraf": "^6.1.2",
|
|
43
|
-
"rollup": "^4.57.
|
|
67
|
+
"rollup": "^4.57.1",
|
|
44
68
|
"swiftlint": "^2.0.0",
|
|
45
69
|
"typescript": "^5.9.3"
|
|
46
70
|
},
|
|
47
71
|
"peerDependencies": {
|
|
48
|
-
"@capacitor/core": ">=
|
|
72
|
+
"@capacitor/core": ">=8.0.2"
|
|
49
73
|
},
|
|
50
74
|
"husky": {
|
|
51
75
|
"hooks": {
|
|
52
76
|
"pre-commit": "pretty-quick --staged"
|
|
53
77
|
}
|
|
54
78
|
},
|
|
55
|
-
"files": [
|
|
56
|
-
"android/src/main/",
|
|
57
|
-
"android/build.gradle",
|
|
58
|
-
"dist/",
|
|
59
|
-
"ios/Sources",
|
|
60
|
-
"ios/Tests",
|
|
61
|
-
"Package.swift",
|
|
62
|
-
"CapacitorCommunityCameraPreview.podspec",
|
|
63
|
-
"LICENSE"
|
|
64
|
-
],
|
|
65
|
-
"keywords": [
|
|
66
|
-
"capacitor",
|
|
67
|
-
"plugin",
|
|
68
|
-
"native",
|
|
69
|
-
"ios",
|
|
70
|
-
"android"
|
|
71
|
-
],
|
|
72
79
|
"capacitor": {
|
|
73
80
|
"ios": {
|
|
74
81
|
"src": "ios"
|
|
@@ -82,13 +89,6 @@
|
|
|
82
89
|
"eslintConfig": {
|
|
83
90
|
"extends": "@ionic/eslint-config/recommended"
|
|
84
91
|
},
|
|
85
|
-
"repository": {
|
|
86
|
-
"type": "git",
|
|
87
|
-
"url": "https://github.com/capacitor-community/camera-preview.git"
|
|
88
|
-
},
|
|
89
|
-
"bugs": {
|
|
90
|
-
"url": "https://github.com/capacitor-community/camera-preview/issues"
|
|
91
|
-
},
|
|
92
92
|
"engines": {
|
|
93
93
|
"node": ">=18.0.0",
|
|
94
94
|
"npm": ">=9.0.0"
|
|
File without changes
|