capacitor-camera-view 2.3.1 → 3.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/CapacitorCameraView.podspec +1 -1
- package/Package.swift +1 -1
- package/README.md +341 -48
- package/android/build.gradle +0 -1
- package/android/src/main/AndroidManifest.xml +0 -1
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraError.kt +42 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraView.kt +946 -205
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraViewPlugin.kt +87 -43
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/BarcodeDetectionResult.kt +28 -2
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/CameraDevice.kt +6 -1
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/CameraSessionConfiguration.kt +15 -1
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/TorchModeState.kt +15 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/WebBoundingRect.kt +1 -1
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/utils.kt +73 -19
- package/dist/docs.json +487 -30
- package/dist/esm/definitions.d.ts +494 -27
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/utils.d.ts +59 -15
- package/dist/esm/utils.js +79 -38
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/web.d.ts +191 -13
- package/dist/esm/web.js +626 -142
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +713 -180
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +713 -180
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CameraViewPlugin/CameraError.swift +147 -2
- package/ios/Sources/CameraViewPlugin/CameraEvents.swift +41 -19
- package/ios/Sources/CameraViewPlugin/CameraSessionConfiguration.swift +29 -1
- package/ios/Sources/CameraViewPlugin/CameraViewManager+BarcodeScan.swift +78 -23
- package/ios/Sources/CameraViewPlugin/CameraViewManager+DeferredStart.swift +37 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager+Focus.swift +131 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager+Lifecycle.swift +156 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager+PhotoCapture.swift +73 -41
- package/ios/Sources/CameraViewPlugin/CameraViewManager+ResolutionSelection.swift +57 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager+Rotation.swift +195 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager+VideoDataOutput.swift +24 -12
- package/ios/Sources/CameraViewPlugin/CameraViewManager+VideoRecording.swift +22 -73
- package/ios/Sources/CameraViewPlugin/CameraViewManager+Zoom.swift +113 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager.swift +450 -403
- package/ios/Sources/CameraViewPlugin/CameraViewPlugin.swift +111 -69
- package/ios/Sources/CameraViewPlugin/Utils.swift +61 -7
- package/package.json +25 -9
package/android/build.gradle
CHANGED
|
@@ -66,7 +66,6 @@ dependencies {
|
|
|
66
66
|
implementation project(':capacitor-android')
|
|
67
67
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
68
68
|
implementation 'androidx.core:core-ktx:1.16.0'
|
|
69
|
-
implementation 'androidx.compose.material3:material3-android:1.4.0'
|
|
70
69
|
testImplementation "junit:junit:$junitVersion"
|
|
71
70
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
72
71
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -6,4 +6,46 @@ sealed class CameraError(message: String) : Exception(message) {
|
|
|
6
6
|
class PreviewNotInitialized : CameraError("Camera preview not initialized")
|
|
7
7
|
class LifecycleOwnerMissing : CameraError("WebView context must be a LifecycleOwner")
|
|
8
8
|
class ZoomFactorOutOfRange : CameraError("The requested zoom factor is out of range.")
|
|
9
|
+
class FocusNotSupported : CameraError("The current camera does not support focus or exposure at a point of interest.")
|
|
10
|
+
class SessionAlreadyRunning : CameraError("Camera session is already running. Call stop() first.")
|
|
11
|
+
class RecordingAlreadyInProgress : CameraError("A video recording is already in progress")
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A stable, platform-independent string code identifying this error.
|
|
15
|
+
*
|
|
16
|
+
* This value is part of the plugin's public JS/TS contract: consumers can
|
|
17
|
+
* `switch` on `error.code` from a rejected promise. Where the same failure
|
|
18
|
+
* class exists on iOS, the string matches the one iOS emits.
|
|
19
|
+
*/
|
|
20
|
+
val code: String
|
|
21
|
+
get() = when (this) {
|
|
22
|
+
is TorchUnavailable -> "TORCH_UNAVAILABLE"
|
|
23
|
+
// Camera/preview not yet set up is the same user-facing failure as
|
|
24
|
+
// iOS's "session not running" - callers should call start() first.
|
|
25
|
+
is CameraNotInitialized -> "SESSION_NOT_RUNNING"
|
|
26
|
+
is PreviewNotInitialized -> "SESSION_NOT_RUNNING"
|
|
27
|
+
is LifecycleOwnerMissing -> "LIFECYCLE_OWNER_MISSING"
|
|
28
|
+
is ZoomFactorOutOfRange -> "ZOOM_FACTOR_OUT_OF_RANGE"
|
|
29
|
+
is FocusNotSupported -> "FOCUS_NOT_SUPPORTED"
|
|
30
|
+
is SessionAlreadyRunning -> "SESSION_ALREADY_RUNNING"
|
|
31
|
+
is RecordingAlreadyInProgress -> "RECORDING_ALREADY_IN_PROGRESS"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
companion object {
|
|
35
|
+
/** Camera or microphone access has been denied. Matches iOS's `permissionDenied`. */
|
|
36
|
+
const val PERMISSION_DENIED = "PERMISSION_DENIED"
|
|
37
|
+
|
|
38
|
+
/** An argument passed to the method call was missing or invalid. Matches iOS's `invalidArgument`. */
|
|
39
|
+
const val INVALID_ARGUMENT = "INVALID_ARGUMENT"
|
|
40
|
+
}
|
|
9
41
|
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The stable string code to surface in a Capacitor `call.reject`.
|
|
45
|
+
*
|
|
46
|
+
* Falls back to a generic code for errors that are not a [CameraError]
|
|
47
|
+
* (e.g. CameraX or ML Kit exceptions), mirroring the iOS `cameraErrorCode`
|
|
48
|
+
* extension.
|
|
49
|
+
*/
|
|
50
|
+
val Exception.cameraErrorCode: String
|
|
51
|
+
get() = (this as? CameraError)?.code ?: "UNKNOWN_ERROR"
|