capacitor-camera-view 1.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 +17 -0
- package/LICENSE +201 -0
- package/Package.swift +28 -0
- package/README.md +654 -0
- package/android/build.gradle +79 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraView.kt +555 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraViewPlugin.kt +227 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/BarcodeDetectionResult.kt +11 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/CameraDevice.kt +14 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/CameraSessionConfiguration.kt +10 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/WebBoundingRect.kt +16 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/ZoomFactors.kt +14 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/utils.kt +86 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +968 -0
- package/dist/esm/definitions.d.ts +378 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/utils.d.ts +45 -0
- package/dist/esm/utils.js +108 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/web.d.ts +108 -0
- package/dist/esm/web.js +406 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +530 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +533 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/CameraViewPlugin/CameraError.swift +39 -0
- package/ios/Sources/CameraViewPlugin/CameraSessionConfiguration.swift +32 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager+BarcodeScan.swift +91 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager+PhotoCapture.swift +52 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager+VideoDataOutput.swift +78 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager.swift +633 -0
- package/ios/Sources/CameraViewPlugin/CameraViewPlugin.swift +295 -0
- package/ios/Sources/CameraViewPlugin/Utils.swift +56 -0
- package/ios/Tests/CameraViewPluginTests/CameraViewPluginTests.swift +15 -0
- package/package.json +94 -0
package/README.md
ADDED
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./docs/banner.png" alt="Capacitor Camera View Banner" width="100%">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Capacitor Camera View</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<b>A Capacitor plugin for embedding a live camera feed directly into your app.</b>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/capacitor-camera-view">
|
|
13
|
+
<img src="https://img.shields.io/npm/v/capacitor-camera-view?color=blue&label=npm&logo=npm&style=flat-square" alt="npm version">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://github.com/michaelwolz/capacitor-camera-view/actions">
|
|
16
|
+
<img src="https://img.shields.io/github/actions/workflow/status/michaelwolz/capacitor-camera-view/ci.yml?branch=main&logo=github&style=flat-square" alt="Build Status">
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://capacitorjs.com/">
|
|
19
|
+
<img src="https://img.shields.io/badge/Capacitor-Plugin-blue?logo=capacitor&style=flat-square" alt="Capacitor Plugin">
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://opensource.org/license/apache-2-0">
|
|
22
|
+
<img src="https://img.shields.io/badge/license-Apache%202.0-green?&style=flat-square" alt="License">
|
|
23
|
+
</a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🚀 Features
|
|
29
|
+
|
|
30
|
+
- 📹 Embed a **live camera feed** directly into your app.
|
|
31
|
+
- 📸 Capture photos or frames from the camera preview.
|
|
32
|
+
- 🔍 **Barcode detection** support.
|
|
33
|
+
- 📱 **Virtual device support** for automatic lens selection based on zoom level and focus (iOS only).
|
|
34
|
+
- 🔎 Control **zoom** and **flash** modes programmatically.
|
|
35
|
+
- ⚡ **High performance** with optimized native implementations.
|
|
36
|
+
- 🎯 **Simple to use** with a clean and intuitive API.
|
|
37
|
+
- 🌐 Works seamlessly on **iOS**, **Android**, and **Web**.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🪧 Demo
|
|
42
|
+
|
|
43
|
+
<img src="https://github.com/user-attachments/assets/77fc4689-ac8b-4572-8f35-09826671683b" alt="Capacitor Camera View Demo" height="500">
|
|
44
|
+
|
|
45
|
+
## 📦 Installation
|
|
46
|
+
|
|
47
|
+
Install the plugin using npm:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install capacitor-camera-view
|
|
51
|
+
npx cap sync
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Platform Configuration
|
|
55
|
+
|
|
56
|
+
#### iOS
|
|
57
|
+
|
|
58
|
+
Add the following keys to your app's `Info.plist` file:
|
|
59
|
+
|
|
60
|
+
```xml
|
|
61
|
+
<key>NSCameraUsageDescription</key>
|
|
62
|
+
<string>To capture photos and videos</string>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Android
|
|
66
|
+
|
|
67
|
+
The `CAMERA` permission is automatically added by Capacitor. Ensure your `AndroidManifest.xml` includes it if needed for specific configurations:
|
|
68
|
+
|
|
69
|
+
```xml
|
|
70
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## ▶️ Basic Usage
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { CameraView } from 'capacitor-camera-view';
|
|
77
|
+
|
|
78
|
+
// Start the camera preview
|
|
79
|
+
const startCamera = async () => {
|
|
80
|
+
try {
|
|
81
|
+
await CameraView.start();
|
|
82
|
+
console.log('Camera started');
|
|
83
|
+
// Add the CSS class to make the WebView transparent
|
|
84
|
+
document.body.classList.add('camera-running');
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.error('Error starting camera:', e);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Stop the camera preview
|
|
91
|
+
const stopCamera = async () => {
|
|
92
|
+
try {
|
|
93
|
+
document.body.classList.remove('camera-running');
|
|
94
|
+
await CameraView.stop();
|
|
95
|
+
console.log('Camera stopped');
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error('Error stopping camera:', e);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Capture a photo
|
|
102
|
+
const capturePhoto = async () => {
|
|
103
|
+
try {
|
|
104
|
+
const result = await CameraView.capture();
|
|
105
|
+
console.log('Photo captured:', result.photo); // Base64 encoded string
|
|
106
|
+
} catch (e) {
|
|
107
|
+
console.error('Error capturing photo:', e);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### ⚠️ Make the WebView transparent when starting the camera view
|
|
113
|
+
|
|
114
|
+
To display the camera view through your app, you need to ensure that the WebView is made transparent. For Ionic applications, this can be done by adding the following styles to your global CSS file and applying the respective class to the body element as soon as you start the camera (see example app on how to do this in Angular):
|
|
115
|
+
|
|
116
|
+
```css
|
|
117
|
+
body.camera-running {
|
|
118
|
+
visibility: hidden;
|
|
119
|
+
--background: transparent;
|
|
120
|
+
--ion-background-color: transparent;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.camera-modal {
|
|
124
|
+
visibility: visible;
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 📸 Virtual Camera Support for iOS
|
|
129
|
+
|
|
130
|
+
On supported iPhone models (like the Pro series), this plugin can utilize the [**virtual triple camera**](https://developer.apple.com/documentation/avfoundation/avcapturedevice/devicetype-swift.struct/builtintriplecamera). This feature combines the ultra-wide, wide, and telephoto cameras into a single virtual device. iOS will then automatically switch between the physical cameras based on factors like zoom level and lighting conditions, providing seamless transitions and optimal image quality across a wider zoom range. You can enable this by setting the `useTripleCameraIfAvailable` option to `true` when calling `start()`.
|
|
131
|
+
|
|
132
|
+
**Pros:**
|
|
133
|
+
* Smoother zooming experience across different focal lengths.
|
|
134
|
+
* Automatic selection of the best lens for the current scene and zoom factor.
|
|
135
|
+
|
|
136
|
+
**Cons:**
|
|
137
|
+
* Slightly higher resource usage compared to using a single physical camera (the camera view will take a little longer until initialized).
|
|
138
|
+
* Only available on specific iPhone models with triple camera systems.
|
|
139
|
+
|
|
140
|
+
For more details on the underlying technology, refer to Apple's documentation on [AVCaptureDevice.builtInTripleCamera](https://developer.apple.com/documentation/avfoundation/avcapturedevice/devicetype-swift.struct/builtintriplecamera).
|
|
141
|
+
|
|
142
|
+
Alternatively, you can specify the `preferredCameraDeviceTypes` option in the <code><a href="#camerasessionconfiguration">CameraSessionConfiguration</a></code> to prioritize specific virtual cameras, such as the [dual camera system](https://developer.apple.com/documentation/avfoundation/avcapturedevice/devicetype-swift.struct/builtindualcamera). While this provides similar functionality, the `useTripleCameraIfAvailable` option offers the advantage of a smoother transition during camera initialization and lens switching (blurred overlay).
|
|
143
|
+
|
|
144
|
+
## 🔍 Barcode Detection
|
|
145
|
+
|
|
146
|
+
This plugin supports real-time barcode detection directly from the live camera feed.
|
|
147
|
+
|
|
148
|
+
**How it works:**
|
|
149
|
+
* **iOS:** Utilizes the native [`AVCaptureMetadataOutput`](https://developer.apple.com/documentation/avfoundation/avcapturemetadataoutput).
|
|
150
|
+
* **Android:** Utilizes Google's [**ML Kit Barcode Scanning**](https://developers.google.com/ml-kit/vision/barcode-scanning).
|
|
151
|
+
* **Web:** Uses the [**Barcode Detection API**](https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API) where available in the browser.
|
|
152
|
+
|
|
153
|
+
**Enabling Barcode Detection:**
|
|
154
|
+
To enable this feature, set the `enableBarcodeDetection` option to `true` when calling the `start()` method:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
await CameraView.start({ enableBarcodeDetection: true });
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Listening for Barcodes:**
|
|
161
|
+
Once enabled, you can listen for the `barcodeDetected` event to receive data about scanned barcodes:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import { CameraView } from 'capacitor-camera-view';
|
|
165
|
+
|
|
166
|
+
CameraView.addListener('barcodeDetected', (data) => {
|
|
167
|
+
console.log('Barcode detected:', data.value, data.type);
|
|
168
|
+
// Handle the detected barcode data (e.g., display it, navigate)
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
See the [`BarcodeDetectionData`](#barcodedetectiondata) interface for details on the event payload.
|
|
173
|
+
|
|
174
|
+
## 🧪 Example App
|
|
175
|
+
|
|
176
|
+
To see the plugin in action, check out the example app in the `example-app` folder. The app demonstrates how to integrate and use the Capacitor Camera View plugin in an Ionic Angular project.
|
|
177
|
+
|
|
178
|
+
## Semantic Release
|
|
179
|
+
|
|
180
|
+
This project uses [semantic-release](https://github.com/semantic-release/semantic-release) for automated versioning and changelog generation based on conventional commits.
|
|
181
|
+
|
|
182
|
+
## Conventional Commits
|
|
183
|
+
|
|
184
|
+
Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification for your commit messages. Example:
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
feat(camera): add autofocus support
|
|
188
|
+
fix(android): resolve crash on startup
|
|
189
|
+
chore: update dependencies
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Resources
|
|
193
|
+
- [semantic-release documentation](https://semantic-release.gitbook.io/semantic-release/)
|
|
194
|
+
- [Conventional Commits](https://www.conventionalcommits.org/)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
## API
|
|
198
|
+
|
|
199
|
+
<docgen-index>
|
|
200
|
+
|
|
201
|
+
* [`start(...)`](#start)
|
|
202
|
+
* [`stop()`](#stop)
|
|
203
|
+
* [`isRunning()`](#isrunning)
|
|
204
|
+
* [`capture(...)`](#capture)
|
|
205
|
+
* [`captureSample(...)`](#capturesample)
|
|
206
|
+
* [`flipCamera()`](#flipcamera)
|
|
207
|
+
* [`getAvailableDevices()`](#getavailabledevices)
|
|
208
|
+
* [`getZoom()`](#getzoom)
|
|
209
|
+
* [`setZoom(...)`](#setzoom)
|
|
210
|
+
* [`getFlashMode()`](#getflashmode)
|
|
211
|
+
* [`getSupportedFlashModes()`](#getsupportedflashmodes)
|
|
212
|
+
* [`setFlashMode(...)`](#setflashmode)
|
|
213
|
+
* [`checkPermissions()`](#checkpermissions)
|
|
214
|
+
* [`requestPermissions()`](#requestpermissions)
|
|
215
|
+
* [`addListener('barcodeDetected', ...)`](#addlistenerbarcodedetected-)
|
|
216
|
+
* [`removeAllListeners(...)`](#removealllisteners)
|
|
217
|
+
* [Interfaces](#interfaces)
|
|
218
|
+
* [Type Aliases](#type-aliases)
|
|
219
|
+
|
|
220
|
+
</docgen-index>
|
|
221
|
+
|
|
222
|
+
<docgen-api>
|
|
223
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
224
|
+
|
|
225
|
+
Main plugin interface for Capacitor Camera View functionality.
|
|
226
|
+
|
|
227
|
+
### start(...)
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
start(options?: CameraSessionConfiguration | undefined) => Promise<void>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Start the camera view with optional configuration.
|
|
234
|
+
|
|
235
|
+
| Param | Type | Description |
|
|
236
|
+
| ------------- | --------------------------------------------------------------------------------- | ---------------------------------------------- |
|
|
237
|
+
| **`options`** | <code><a href="#camerasessionconfiguration">CameraSessionConfiguration</a></code> | - Configuration options for the camera session |
|
|
238
|
+
|
|
239
|
+
**Since:** 1.0.0
|
|
240
|
+
|
|
241
|
+
--------------------
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
### stop()
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
stop() => Promise<void>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Stop the camera view and release resources.
|
|
251
|
+
|
|
252
|
+
**Since:** 1.0.0
|
|
253
|
+
|
|
254
|
+
--------------------
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
### isRunning()
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
isRunning() => Promise<IsRunningResponse>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Check if the camera view is currently running.
|
|
264
|
+
|
|
265
|
+
**Returns:** <code>Promise<<a href="#isrunningresponse">IsRunningResponse</a>></code>
|
|
266
|
+
|
|
267
|
+
**Since:** 1.0.0
|
|
268
|
+
|
|
269
|
+
--------------------
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
### capture(...)
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
capture(options: { quality: number; }) => Promise<CaptureResponse>
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Capture a photo using the current camera configuration.
|
|
279
|
+
|
|
280
|
+
| Param | Type | Description |
|
|
281
|
+
| ------------- | --------------------------------- | ------------------------------- |
|
|
282
|
+
| **`options`** | <code>{ quality: number; }</code> | - Capture configuration options |
|
|
283
|
+
|
|
284
|
+
**Returns:** <code>Promise<<a href="#captureresponse">CaptureResponse</a>></code>
|
|
285
|
+
|
|
286
|
+
**Since:** 1.0.0
|
|
287
|
+
|
|
288
|
+
--------------------
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
### captureSample(...)
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
captureSample(options: { quality: number; }) => Promise<CaptureResponse>
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Captures a frame from the current camera preview without using the full camera capture pipeline.
|
|
298
|
+
|
|
299
|
+
Unlike `capture()` which may trigger hardware-level photo capture on native platforms,
|
|
300
|
+
this method quickly samples the current video stream. This is suitable computer vision or
|
|
301
|
+
simple snapshots where high fidelity is not required.
|
|
302
|
+
|
|
303
|
+
On web this method does exactly the same as `capture()` as it only captures a frame from the video stream
|
|
304
|
+
because unfortunately [ImageCapture API](https://developer.mozilla.org/en-US/docs/Web/API/ImageCapture) is
|
|
305
|
+
not yet well supported on the web.
|
|
306
|
+
|
|
307
|
+
| Param | Type | Description |
|
|
308
|
+
| ------------- | --------------------------------- | ------------------------------- |
|
|
309
|
+
| **`options`** | <code>{ quality: number; }</code> | - Capture configuration options |
|
|
310
|
+
|
|
311
|
+
**Returns:** <code>Promise<<a href="#captureresponse">CaptureResponse</a>></code>
|
|
312
|
+
|
|
313
|
+
**Since:** 1.0.0
|
|
314
|
+
|
|
315
|
+
--------------------
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
### flipCamera()
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
flipCamera() => Promise<void>
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Switch between front and back camera.
|
|
325
|
+
|
|
326
|
+
**Since:** 1.0.0
|
|
327
|
+
|
|
328
|
+
--------------------
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
### getAvailableDevices()
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
getAvailableDevices() => Promise<GetAvailableDevicesResponse>
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Get available camera devices for capturing photos.
|
|
338
|
+
|
|
339
|
+
**Returns:** <code>Promise<<a href="#getavailabledevicesresponse">GetAvailableDevicesResponse</a>></code>
|
|
340
|
+
|
|
341
|
+
**Since:** 1.0.0
|
|
342
|
+
|
|
343
|
+
--------------------
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
### getZoom()
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
getZoom() => Promise<GetZoomResponse>
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Get current zoom level information and available range.
|
|
353
|
+
|
|
354
|
+
**Returns:** <code>Promise<<a href="#getzoomresponse">GetZoomResponse</a>></code>
|
|
355
|
+
|
|
356
|
+
**Since:** 1.0.0
|
|
357
|
+
|
|
358
|
+
--------------------
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
### setZoom(...)
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
setZoom(options: { level: number; ramp?: boolean; }) => Promise<void>
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Set the camera zoom level.
|
|
368
|
+
|
|
369
|
+
| Param | Type | Description |
|
|
370
|
+
| ------------- | ----------------------------------------------- | ---------------------------- |
|
|
371
|
+
| **`options`** | <code>{ level: number; ramp?: boolean; }</code> | - Zoom configuration options |
|
|
372
|
+
|
|
373
|
+
**Since:** 1.0.0
|
|
374
|
+
|
|
375
|
+
--------------------
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
### getFlashMode()
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
getFlashMode() => Promise<GetFlashModeResponse>
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Get current flash mode setting.
|
|
385
|
+
|
|
386
|
+
**Returns:** <code>Promise<<a href="#getflashmoderesponse">GetFlashModeResponse</a>></code>
|
|
387
|
+
|
|
388
|
+
**Since:** 1.0.0
|
|
389
|
+
|
|
390
|
+
--------------------
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
### getSupportedFlashModes()
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
getSupportedFlashModes() => Promise<GetSupportedFlashModesResponse>
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Get supported flash modes for the current camera.
|
|
400
|
+
|
|
401
|
+
**Returns:** <code>Promise<<a href="#getsupportedflashmodesresponse">GetSupportedFlashModesResponse</a>></code>
|
|
402
|
+
|
|
403
|
+
**Since:** 1.0.0
|
|
404
|
+
|
|
405
|
+
--------------------
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
### setFlashMode(...)
|
|
409
|
+
|
|
410
|
+
```typescript
|
|
411
|
+
setFlashMode(options: { mode: FlashMode; }) => Promise<void>
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Set the camera flash mode.
|
|
415
|
+
|
|
416
|
+
| Param | Type | Description |
|
|
417
|
+
| ------------- | ---------------------------------------------------------- | ---------------------------------- |
|
|
418
|
+
| **`options`** | <code>{ mode: <a href="#flashmode">FlashMode</a>; }</code> | - Flash mode configuration options |
|
|
419
|
+
|
|
420
|
+
**Since:** 1.0.0
|
|
421
|
+
|
|
422
|
+
--------------------
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
### checkPermissions()
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
checkPermissions() => Promise<PermissionStatus>
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Check camera permission status without requesting permissions.
|
|
432
|
+
|
|
433
|
+
**Returns:** <code>Promise<<a href="#permissionstatus">PermissionStatus</a>></code>
|
|
434
|
+
|
|
435
|
+
**Since:** 1.0.0
|
|
436
|
+
|
|
437
|
+
--------------------
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
### requestPermissions()
|
|
441
|
+
|
|
442
|
+
```typescript
|
|
443
|
+
requestPermissions() => Promise<PermissionStatus>
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Request camera permission from the user.
|
|
447
|
+
|
|
448
|
+
**Returns:** <code>Promise<<a href="#permissionstatus">PermissionStatus</a>></code>
|
|
449
|
+
|
|
450
|
+
**Since:** 1.0.0
|
|
451
|
+
|
|
452
|
+
--------------------
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
### addListener('barcodeDetected', ...)
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
addListener(eventName: 'barcodeDetected', listenerFunc: (data: BarcodeDetectionData) => void) => Promise<PluginListenerHandle>
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
Listen for barcode detection events.
|
|
462
|
+
This event is emitted when a barcode is detected in the camera preview.
|
|
463
|
+
|
|
464
|
+
| Param | Type | Description |
|
|
465
|
+
| ------------------ | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
466
|
+
| **`eventName`** | <code>'barcodeDetected'</code> | - The name of the event to listen for ('barcodeDetected') |
|
|
467
|
+
| **`listenerFunc`** | <code>(data: <a href="#barcodedetectiondata">BarcodeDetectionData</a>) => void</code> | - The callback function to execute when a barcode is detected |
|
|
468
|
+
|
|
469
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
470
|
+
|
|
471
|
+
**Since:** 1.0.0
|
|
472
|
+
|
|
473
|
+
--------------------
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
### removeAllListeners(...)
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
removeAllListeners(eventName?: string | undefined) => Promise<void>
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
Remove all listeners for this plugin.
|
|
483
|
+
|
|
484
|
+
| Param | Type | Description |
|
|
485
|
+
| --------------- | ------------------- | --------------------------------------------- |
|
|
486
|
+
| **`eventName`** | <code>string</code> | - Optional event name to remove listeners for |
|
|
487
|
+
|
|
488
|
+
**Since:** 1.0.0
|
|
489
|
+
|
|
490
|
+
--------------------
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
### Interfaces
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
#### CameraSessionConfiguration
|
|
497
|
+
|
|
498
|
+
Configuration options for starting a camera session.
|
|
499
|
+
|
|
500
|
+
| Prop | Type | Description | Default |
|
|
501
|
+
| -------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- |
|
|
502
|
+
| **`enableBarcodeDetection`** | <code>boolean</code> | Enables the barcode detection functionality | <code>false</code> |
|
|
503
|
+
| **`position`** | <code><a href="#cameraposition">CameraPosition</a></code> | Position of the camera to use | <code>'back'</code> |
|
|
504
|
+
| **`deviceId`** | <code>string</code> | Specific device ID of the camera to use If provided, takes precedence over position | |
|
|
505
|
+
| **`useTripleCameraIfAvailable`** | <code>boolean</code> | Whether to use the triple camera if available (iPhone Pro models only) | <code>false</code> |
|
|
506
|
+
| **`preferredCameraDeviceTypes`** | <code>CameraDeviceType[]</code> | Ordered list of preferred camera device types to use (iOS only). The system will attempt to use the first available camera type in the list. If position is also provided, the system will use the first available camera type that matches the position and is in the list. This will fallback to the default camera type if none of the preferred types are available. | <code>undefined - system will decide based on position/deviceId</code> |
|
|
507
|
+
| **`zoomFactor`** | <code>number</code> | The initial zoom factor to use | <code>1.0</code> |
|
|
508
|
+
| **`containerElementId`** | <code>string</code> | Optional HTML ID of the container element where the camera view should be rendered. If not provided, the camera view will be appended to the document body. Web only. | |
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
#### IsRunningResponse
|
|
512
|
+
|
|
513
|
+
Response for checking if the camera view is running.
|
|
514
|
+
|
|
515
|
+
| Prop | Type | Description |
|
|
516
|
+
| --------------- | -------------------- | ------------------------------------------------------------ |
|
|
517
|
+
| **`isRunning`** | <code>boolean</code> | Indicates if the camera view is currently active and running |
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
#### CaptureResponse
|
|
521
|
+
|
|
522
|
+
Response for capturing a photo.
|
|
523
|
+
|
|
524
|
+
| Prop | Type | Description |
|
|
525
|
+
| ----------- | ------------------- | ----------------------------------------------- |
|
|
526
|
+
| **`photo`** | <code>string</code> | The base64 encoded string of the captured photo |
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
#### GetAvailableDevicesResponse
|
|
530
|
+
|
|
531
|
+
Response for getting available camera devices.
|
|
532
|
+
|
|
533
|
+
| Prop | Type | Description |
|
|
534
|
+
| ------------- | --------------------------- | ------------------------------------ |
|
|
535
|
+
| **`devices`** | <code>CameraDevice[]</code> | An array of available camera devices |
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
#### CameraDevice
|
|
539
|
+
|
|
540
|
+
Represents a physical camera device on the device.
|
|
541
|
+
|
|
542
|
+
| Prop | Type | Description |
|
|
543
|
+
| ---------------- | ------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
544
|
+
| **`id`** | <code>string</code> | The unique identifier of the camera device |
|
|
545
|
+
| **`name`** | <code>string</code> | The human-readable name of the camera device |
|
|
546
|
+
| **`position`** | <code><a href="#cameraposition">CameraPosition</a></code> | The position of the camera device (front or back) |
|
|
547
|
+
| **`deviceType`** | <code><a href="#cameradevicetype">CameraDeviceType</a></code> | The type of the camera device (e.g., wide, ultra-wide, telephoto) - iOS only |
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
#### GetZoomResponse
|
|
551
|
+
|
|
552
|
+
Response for getting zoom level information.
|
|
553
|
+
|
|
554
|
+
| Prop | Type | Description |
|
|
555
|
+
| ------------- | ------------------- | -------------------------------- |
|
|
556
|
+
| **`min`** | <code>number</code> | The minimum zoom level supported |
|
|
557
|
+
| **`max`** | <code>number</code> | The maximum zoom level supported |
|
|
558
|
+
| **`current`** | <code>number</code> | The current zoom level |
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
#### GetFlashModeResponse
|
|
562
|
+
|
|
563
|
+
Response for getting the current flash mode.
|
|
564
|
+
|
|
565
|
+
| Prop | Type | Description |
|
|
566
|
+
| --------------- | ----------------------------------------------- | ------------------------------ |
|
|
567
|
+
| **`flashMode`** | <code><a href="#flashmode">FlashMode</a></code> | The current flash mode setting |
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
#### GetSupportedFlashModesResponse
|
|
571
|
+
|
|
572
|
+
Response for getting supported flash modes.
|
|
573
|
+
|
|
574
|
+
| Prop | Type | Description |
|
|
575
|
+
| ---------------- | ------------------------ | ------------------------------------------------------- |
|
|
576
|
+
| **`flashModes`** | <code>FlashMode[]</code> | An array of flash modes supported by the current camera |
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
#### PermissionStatus
|
|
580
|
+
|
|
581
|
+
Response for the camera permission status.
|
|
582
|
+
|
|
583
|
+
| Prop | Type | Description |
|
|
584
|
+
| ------------ | ----------------------------------------------------------- | ---------------------------------- |
|
|
585
|
+
| **`camera`** | <code><a href="#permissionstate">PermissionState</a></code> | The state of the camera permission |
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
#### PluginListenerHandle
|
|
589
|
+
|
|
590
|
+
| Prop | Type |
|
|
591
|
+
| ------------ | ----------------------------------------- |
|
|
592
|
+
| **`remove`** | <code>() => Promise<void></code> |
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
#### BarcodeDetectionData
|
|
596
|
+
|
|
597
|
+
Data for a detected barcode.
|
|
598
|
+
|
|
599
|
+
| Prop | Type | Description |
|
|
600
|
+
| ------------------ | ----------------------------------------------------- | ---------------------------------------------------------------- |
|
|
601
|
+
| **`value`** | <code>string</code> | The decoded string value of the barcode |
|
|
602
|
+
| **`displayValue`** | <code>string</code> | The display value of the barcode (may differ from the raw value) |
|
|
603
|
+
| **`type`** | <code>string</code> | The type/format of the barcode (e.g., 'qr', 'code128', etc.) |
|
|
604
|
+
| **`boundingRect`** | <code><a href="#boundingrect">BoundingRect</a></code> | The bounding rectangle of the barcode in the camera frame. |
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
#### BoundingRect
|
|
608
|
+
|
|
609
|
+
Rectangle defining the boundary of the barcode in the camera frame.
|
|
610
|
+
Coordinates are normalized between 0 and 1 relative to the camera frame.
|
|
611
|
+
|
|
612
|
+
| Prop | Type | Description |
|
|
613
|
+
| ------------ | ------------------- | -------------------------------------------------------------------------------- |
|
|
614
|
+
| **`x`** | <code>number</code> | X-coordinate of the top-left corner |
|
|
615
|
+
| **`y`** | <code>number</code> | Y-coordinate of the top-left corner |
|
|
616
|
+
| **`width`** | <code>number</code> | Width of the bounding rectangle (should match the actual width of the barcode) |
|
|
617
|
+
| **`height`** | <code>number</code> | Height of the bounding rectangle (should match the actual height of the barcode) |
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
### Type Aliases
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
#### CameraPosition
|
|
624
|
+
|
|
625
|
+
Position options for the camera.
|
|
626
|
+
- 'front': Front-facing camera
|
|
627
|
+
- 'back': Rear-facing camera
|
|
628
|
+
|
|
629
|
+
<code>'front' | 'back'</code>
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
#### CameraDeviceType
|
|
633
|
+
|
|
634
|
+
Available camera device types for iOS.
|
|
635
|
+
Maps to AVCaptureDevice DeviceTypes in iOS.
|
|
636
|
+
|
|
637
|
+
<code>'wideAngle' | 'ultraWide' | 'telephoto' | 'dual' | 'dualWide' | 'triple' | 'trueDepth'</code>
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
#### FlashMode
|
|
641
|
+
|
|
642
|
+
Flash mode options for the camera.
|
|
643
|
+
- 'off': Flash disabled
|
|
644
|
+
- 'on': Flash always on
|
|
645
|
+
- 'auto': Flash automatically enabled in low-light conditions
|
|
646
|
+
|
|
647
|
+
<code>'off' | 'on' | 'auto'</code>
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
#### PermissionState
|
|
651
|
+
|
|
652
|
+
<code>'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'</code>
|
|
653
|
+
|
|
654
|
+
</docgen-api>
|