capacitor-camera-view 2.0.2 → 2.2.0-rc.1
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/README.md +215 -19
- package/android/build.gradle +9 -5
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraView.kt +491 -116
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraViewPlugin.kt +181 -31
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/CameraResult.kt +47 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/CameraSessionConfiguration.kt +11 -1
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/VideoRecordingQuality.kt +10 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/utils.kt +114 -5
- package/dist/docs.json +281 -8
- package/dist/esm/definitions.d.ts +128 -6
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +26 -4
- package/dist/esm/web.js +218 -18
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +219 -18
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +219 -18
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CameraViewPlugin/CameraError.swift +125 -2
- package/ios/Sources/CameraViewPlugin/CameraEvents.swift +109 -0
- package/ios/Sources/CameraViewPlugin/CameraSessionConfiguration.swift +28 -1
- package/ios/Sources/CameraViewPlugin/CameraViewManager+BarcodeScan.swift +30 -41
- package/ios/Sources/CameraViewPlugin/CameraViewManager+PhotoCapture.swift +38 -7
- package/ios/Sources/CameraViewPlugin/CameraViewManager+VideoDataOutput.swift +4 -3
- package/ios/Sources/CameraViewPlugin/CameraViewManager+VideoRecording.swift +302 -0
- package/ios/Sources/CameraViewPlugin/CameraViewManager.swift +246 -166
- package/ios/Sources/CameraViewPlugin/CameraViewPlugin.swift +194 -96
- package/ios/Sources/CameraViewPlugin/TempFileManager.swift +215 -0
- package/ios/Sources/CameraViewPlugin/Utils.swift +102 -0
- package/package.json +17 -17
package/dist/docs.json
CHANGED
|
@@ -147,6 +147,58 @@
|
|
|
147
147
|
],
|
|
148
148
|
"slug": "capturesample"
|
|
149
149
|
},
|
|
150
|
+
{
|
|
151
|
+
"name": "startRecording",
|
|
152
|
+
"signature": "(options?: VideoRecordingOptions | undefined) => Promise<void>",
|
|
153
|
+
"parameters": [
|
|
154
|
+
{
|
|
155
|
+
"name": "options",
|
|
156
|
+
"docs": "- Optional recording configuration",
|
|
157
|
+
"type": "VideoRecordingOptions | undefined"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"returns": "Promise<void>",
|
|
161
|
+
"tags": [
|
|
162
|
+
{
|
|
163
|
+
"name": "param",
|
|
164
|
+
"text": "options - Optional recording configuration"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"name": "returns",
|
|
168
|
+
"text": "A promise that resolves when recording has started"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "since",
|
|
172
|
+
"text": "2.2.0"
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"docs": "Start recording video from the current camera.\nCamera must be running. Throws if already recording.",
|
|
176
|
+
"complexTypes": [
|
|
177
|
+
"VideoRecordingOptions"
|
|
178
|
+
],
|
|
179
|
+
"slug": "startrecording"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"name": "stopRecording",
|
|
183
|
+
"signature": "() => Promise<VideoRecordingResponse>",
|
|
184
|
+
"parameters": [],
|
|
185
|
+
"returns": "Promise<VideoRecordingResponse>",
|
|
186
|
+
"tags": [
|
|
187
|
+
{
|
|
188
|
+
"name": "returns",
|
|
189
|
+
"text": "A promise that resolves with the recorded video file path"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "since",
|
|
193
|
+
"text": "2.2.0"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
"docs": "Stop the current video recording and return the result.\nThrows if no recording is in progress.",
|
|
197
|
+
"complexTypes": [
|
|
198
|
+
"VideoRecordingResponse"
|
|
199
|
+
],
|
|
200
|
+
"slug": "stoprecording"
|
|
201
|
+
},
|
|
150
202
|
{
|
|
151
203
|
"name": "flipCamera",
|
|
152
204
|
"signature": "() => Promise<void>",
|
|
@@ -429,14 +481,14 @@
|
|
|
429
481
|
"tags": [
|
|
430
482
|
{
|
|
431
483
|
"name": "returns",
|
|
432
|
-
"text": "A promise that resolves with an object containing the camera permission status"
|
|
484
|
+
"text": "A promise that resolves with an object containing the camera and microphone permission status"
|
|
433
485
|
},
|
|
434
486
|
{
|
|
435
487
|
"name": "since",
|
|
436
488
|
"text": "1.0.0"
|
|
437
489
|
}
|
|
438
490
|
],
|
|
439
|
-
"docs": "Check camera permission status without requesting permissions.",
|
|
491
|
+
"docs": "Check camera and microphone permission status without requesting permissions.",
|
|
440
492
|
"complexTypes": [
|
|
441
493
|
"PermissionStatus"
|
|
442
494
|
],
|
|
@@ -444,22 +496,33 @@
|
|
|
444
496
|
},
|
|
445
497
|
{
|
|
446
498
|
"name": "requestPermissions",
|
|
447
|
-
"signature": "() => Promise<PermissionStatus>",
|
|
448
|
-
"parameters": [
|
|
499
|
+
"signature": "(options?: { permissions?: CameraPermissionType[] | undefined; } | undefined) => Promise<PermissionStatus>",
|
|
500
|
+
"parameters": [
|
|
501
|
+
{
|
|
502
|
+
"name": "options",
|
|
503
|
+
"docs": "- Optional object specifying which permissions to request",
|
|
504
|
+
"type": "{ permissions?: CameraPermissionType[] | undefined; } | undefined"
|
|
505
|
+
}
|
|
506
|
+
],
|
|
449
507
|
"returns": "Promise<PermissionStatus>",
|
|
450
508
|
"tags": [
|
|
509
|
+
{
|
|
510
|
+
"name": "param",
|
|
511
|
+
"text": "options - Optional object specifying which permissions to request"
|
|
512
|
+
},
|
|
451
513
|
{
|
|
452
514
|
"name": "returns",
|
|
453
|
-
"text": "A promise that resolves with an object containing the camera permission status"
|
|
515
|
+
"text": "A promise that resolves with an object containing the camera and microphone permission status"
|
|
454
516
|
},
|
|
455
517
|
{
|
|
456
518
|
"name": "since",
|
|
457
519
|
"text": "1.0.0"
|
|
458
520
|
}
|
|
459
521
|
],
|
|
460
|
-
"docs": "Request camera
|
|
522
|
+
"docs": "Request camera and/or microphone permissions from the user.\n\nBy default, only camera permission is requested. To also request microphone\npermission (needed for video recording with audio), pass `{ permissions: ['camera', 'microphone'] }`.",
|
|
461
523
|
"complexTypes": [
|
|
462
|
-
"PermissionStatus"
|
|
524
|
+
"PermissionStatus",
|
|
525
|
+
"CameraPermissionType"
|
|
463
526
|
],
|
|
464
527
|
"slug": "requestpermissions"
|
|
465
528
|
},
|
|
@@ -561,6 +624,28 @@
|
|
|
561
624
|
"complexTypes": [],
|
|
562
625
|
"type": "boolean | undefined"
|
|
563
626
|
},
|
|
627
|
+
{
|
|
628
|
+
"name": "barcodeTypes",
|
|
629
|
+
"tags": [
|
|
630
|
+
{
|
|
631
|
+
"text": "['qr', 'code128'] // Only detect QR codes and Code 128 barcodes",
|
|
632
|
+
"name": "example"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"text": "undefined - all supported types are detected",
|
|
636
|
+
"name": "default"
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
"text": "2.1.0",
|
|
640
|
+
"name": "since"
|
|
641
|
+
}
|
|
642
|
+
],
|
|
643
|
+
"docs": "Specific barcode types to detect. If not provided, all supported types are detected.\nSpecifying only the types you need can significantly improve performance and reduce\nbattery consumption, especially on mobile devices.",
|
|
644
|
+
"complexTypes": [
|
|
645
|
+
"BarcodeType"
|
|
646
|
+
],
|
|
647
|
+
"type": "BarcodeType[] | undefined"
|
|
648
|
+
},
|
|
564
649
|
{
|
|
565
650
|
"name": "position",
|
|
566
651
|
"tags": [
|
|
@@ -701,6 +786,80 @@
|
|
|
701
786
|
}
|
|
702
787
|
]
|
|
703
788
|
},
|
|
789
|
+
{
|
|
790
|
+
"name": "VideoRecordingOptions",
|
|
791
|
+
"slug": "videorecordingoptions",
|
|
792
|
+
"docs": "Configuration options for video recording.",
|
|
793
|
+
"tags": [
|
|
794
|
+
{
|
|
795
|
+
"text": "2.2.0",
|
|
796
|
+
"name": "since"
|
|
797
|
+
}
|
|
798
|
+
],
|
|
799
|
+
"methods": [],
|
|
800
|
+
"properties": [
|
|
801
|
+
{
|
|
802
|
+
"name": "enableAudio",
|
|
803
|
+
"tags": [
|
|
804
|
+
{
|
|
805
|
+
"text": "false",
|
|
806
|
+
"name": "default"
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
"text": "2.2.0",
|
|
810
|
+
"name": "since"
|
|
811
|
+
}
|
|
812
|
+
],
|
|
813
|
+
"docs": "Whether to record audio with the video.\nRequires microphone permission.",
|
|
814
|
+
"complexTypes": [],
|
|
815
|
+
"type": "boolean | undefined"
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
"name": "videoQuality",
|
|
819
|
+
"tags": [
|
|
820
|
+
{
|
|
821
|
+
"text": "'highest'",
|
|
822
|
+
"name": "default"
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
"text": "2.2.0",
|
|
826
|
+
"name": "since"
|
|
827
|
+
}
|
|
828
|
+
],
|
|
829
|
+
"docs": "Video recording quality preset.\nNative platforms only (iOS/Android). Ignored on web.",
|
|
830
|
+
"complexTypes": [
|
|
831
|
+
"VideoRecordingQuality"
|
|
832
|
+
],
|
|
833
|
+
"type": "VideoRecordingQuality"
|
|
834
|
+
}
|
|
835
|
+
]
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
"name": "VideoRecordingResponse",
|
|
839
|
+
"slug": "videorecordingresponse",
|
|
840
|
+
"docs": "Response from stopping a video recording.",
|
|
841
|
+
"tags": [
|
|
842
|
+
{
|
|
843
|
+
"text": "2.2.0",
|
|
844
|
+
"name": "since"
|
|
845
|
+
}
|
|
846
|
+
],
|
|
847
|
+
"methods": [],
|
|
848
|
+
"properties": [
|
|
849
|
+
{
|
|
850
|
+
"name": "webPath",
|
|
851
|
+
"tags": [
|
|
852
|
+
{
|
|
853
|
+
"text": "2.2.0",
|
|
854
|
+
"name": "since"
|
|
855
|
+
}
|
|
856
|
+
],
|
|
857
|
+
"docs": "Web-accessible path to the recorded video file.\nOn web, this is a blob URL.\nOn iOS/Android, this is a path accessible via Capacitor's filesystem.",
|
|
858
|
+
"complexTypes": [],
|
|
859
|
+
"type": "string"
|
|
860
|
+
}
|
|
861
|
+
]
|
|
862
|
+
},
|
|
704
863
|
{
|
|
705
864
|
"name": "GetAvailableDevicesResponse",
|
|
706
865
|
"slug": "getavailabledevicesresponse",
|
|
@@ -903,7 +1062,7 @@
|
|
|
903
1062
|
{
|
|
904
1063
|
"name": "PermissionStatus",
|
|
905
1064
|
"slug": "permissionstatus",
|
|
906
|
-
"docs": "Response for the camera permission status.",
|
|
1065
|
+
"docs": "Response for the camera and microphone permission status.",
|
|
907
1066
|
"tags": [
|
|
908
1067
|
{
|
|
909
1068
|
"text": "1.0.0",
|
|
@@ -920,6 +1079,15 @@
|
|
|
920
1079
|
"PermissionState"
|
|
921
1080
|
],
|
|
922
1081
|
"type": "PermissionState"
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
"name": "microphone",
|
|
1085
|
+
"tags": [],
|
|
1086
|
+
"docs": "The state of the microphone permission",
|
|
1087
|
+
"complexTypes": [
|
|
1088
|
+
"PermissionState"
|
|
1089
|
+
],
|
|
1090
|
+
"type": "PermissionState"
|
|
923
1091
|
}
|
|
924
1092
|
]
|
|
925
1093
|
},
|
|
@@ -1028,6 +1196,65 @@
|
|
|
1028
1196
|
],
|
|
1029
1197
|
"enums": [],
|
|
1030
1198
|
"typeAliases": [
|
|
1199
|
+
{
|
|
1200
|
+
"name": "BarcodeType",
|
|
1201
|
+
"slug": "barcodetype",
|
|
1202
|
+
"docs": "Supported barcode types for detection.\nSpecifying only the barcode types you need can improve performance\nand reduce battery consumption.",
|
|
1203
|
+
"types": [
|
|
1204
|
+
{
|
|
1205
|
+
"text": "'qr'",
|
|
1206
|
+
"complexTypes": []
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
"text": "'code128'",
|
|
1210
|
+
"complexTypes": []
|
|
1211
|
+
},
|
|
1212
|
+
{
|
|
1213
|
+
"text": "'code39'",
|
|
1214
|
+
"complexTypes": []
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
"text": "'code39Mod43'",
|
|
1218
|
+
"complexTypes": []
|
|
1219
|
+
},
|
|
1220
|
+
{
|
|
1221
|
+
"text": "'code93'",
|
|
1222
|
+
"complexTypes": []
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
"text": "'ean8'",
|
|
1226
|
+
"complexTypes": []
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
"text": "'ean13'",
|
|
1230
|
+
"complexTypes": []
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
"text": "'interleaved2of5'",
|
|
1234
|
+
"complexTypes": []
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
"text": "'itf14'",
|
|
1238
|
+
"complexTypes": []
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
"text": "'pdf417'",
|
|
1242
|
+
"complexTypes": []
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
"text": "'aztec'",
|
|
1246
|
+
"complexTypes": []
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
"text": "'dataMatrix'",
|
|
1250
|
+
"complexTypes": []
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
"text": "'upce'",
|
|
1254
|
+
"complexTypes": []
|
|
1255
|
+
}
|
|
1256
|
+
]
|
|
1257
|
+
},
|
|
1031
1258
|
{
|
|
1032
1259
|
"name": "CameraPosition",
|
|
1033
1260
|
"slug": "cameraposition",
|
|
@@ -1091,6 +1318,37 @@
|
|
|
1091
1318
|
}
|
|
1092
1319
|
]
|
|
1093
1320
|
},
|
|
1321
|
+
{
|
|
1322
|
+
"name": "VideoRecordingQuality",
|
|
1323
|
+
"slug": "videorecordingquality",
|
|
1324
|
+
"docs": "Video recording quality presets.",
|
|
1325
|
+
"types": [
|
|
1326
|
+
{
|
|
1327
|
+
"text": "'lowest'",
|
|
1328
|
+
"complexTypes": []
|
|
1329
|
+
},
|
|
1330
|
+
{
|
|
1331
|
+
"text": "'sd'",
|
|
1332
|
+
"complexTypes": []
|
|
1333
|
+
},
|
|
1334
|
+
{
|
|
1335
|
+
"text": "'hd'",
|
|
1336
|
+
"complexTypes": []
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
"text": "'fhd'",
|
|
1340
|
+
"complexTypes": []
|
|
1341
|
+
},
|
|
1342
|
+
{
|
|
1343
|
+
"text": "'uhd'",
|
|
1344
|
+
"complexTypes": []
|
|
1345
|
+
},
|
|
1346
|
+
{
|
|
1347
|
+
"text": "'highest'",
|
|
1348
|
+
"complexTypes": []
|
|
1349
|
+
}
|
|
1350
|
+
]
|
|
1351
|
+
},
|
|
1094
1352
|
{
|
|
1095
1353
|
"name": "FlashMode",
|
|
1096
1354
|
"slug": "flashmode",
|
|
@@ -1132,6 +1390,21 @@
|
|
|
1132
1390
|
"complexTypes": []
|
|
1133
1391
|
}
|
|
1134
1392
|
]
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
"name": "CameraPermissionType",
|
|
1396
|
+
"slug": "camerapermissiontype",
|
|
1397
|
+
"docs": "Permission types that can be requested.\n- 'camera': Camera access permission\n- 'microphone': Microphone access permission (needed for video recording with audio)",
|
|
1398
|
+
"types": [
|
|
1399
|
+
{
|
|
1400
|
+
"text": "'camera'",
|
|
1401
|
+
"complexTypes": []
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
"text": "'microphone'",
|
|
1405
|
+
"complexTypes": []
|
|
1406
|
+
}
|
|
1407
|
+
]
|
|
1135
1408
|
}
|
|
1136
1409
|
],
|
|
1137
1410
|
"pluginConfigs": []
|
|
@@ -56,6 +56,25 @@ export interface CameraViewPlugin {
|
|
|
56
56
|
* @since 1.0.0
|
|
57
57
|
*/
|
|
58
58
|
captureSample<T extends CaptureOptions>(options: T): Promise<CaptureResponse<T>>;
|
|
59
|
+
/**
|
|
60
|
+
* Start recording video from the current camera.
|
|
61
|
+
* Camera must be running. Throws if already recording.
|
|
62
|
+
*
|
|
63
|
+
* @param options - Optional recording configuration
|
|
64
|
+
* @returns A promise that resolves when recording has started
|
|
65
|
+
*
|
|
66
|
+
* @since 2.2.0
|
|
67
|
+
*/
|
|
68
|
+
startRecording(options?: VideoRecordingOptions): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Stop the current video recording and return the result.
|
|
71
|
+
* Throws if no recording is in progress.
|
|
72
|
+
*
|
|
73
|
+
* @returns A promise that resolves with the recorded video file path
|
|
74
|
+
*
|
|
75
|
+
* @since 2.2.0
|
|
76
|
+
*/
|
|
77
|
+
stopRecording(): Promise<VideoRecordingResponse>;
|
|
59
78
|
/**
|
|
60
79
|
* Switch between front and back camera.
|
|
61
80
|
*
|
|
@@ -177,21 +196,27 @@ export interface CameraViewPlugin {
|
|
|
177
196
|
level?: number;
|
|
178
197
|
}): Promise<void>;
|
|
179
198
|
/**
|
|
180
|
-
* Check camera permission status without requesting permissions.
|
|
199
|
+
* Check camera and microphone permission status without requesting permissions.
|
|
181
200
|
*
|
|
182
|
-
* @returns A promise that resolves with an object containing the camera permission status
|
|
201
|
+
* @returns A promise that resolves with an object containing the camera and microphone permission status
|
|
183
202
|
*
|
|
184
203
|
* @since 1.0.0
|
|
185
204
|
*/
|
|
186
205
|
checkPermissions(): Promise<PermissionStatus>;
|
|
187
206
|
/**
|
|
188
|
-
* Request camera
|
|
207
|
+
* Request camera and/or microphone permissions from the user.
|
|
208
|
+
*
|
|
209
|
+
* By default, only camera permission is requested. To also request microphone
|
|
210
|
+
* permission (needed for video recording with audio), pass `{ permissions: ['camera', 'microphone'] }`.
|
|
189
211
|
*
|
|
190
|
-
* @
|
|
212
|
+
* @param options - Optional object specifying which permissions to request
|
|
213
|
+
* @returns A promise that resolves with an object containing the camera and microphone permission status
|
|
191
214
|
*
|
|
192
215
|
* @since 1.0.0
|
|
193
216
|
*/
|
|
194
|
-
requestPermissions(
|
|
217
|
+
requestPermissions(options?: {
|
|
218
|
+
permissions?: CameraPermissionType[];
|
|
219
|
+
}): Promise<PermissionStatus>;
|
|
195
220
|
/**
|
|
196
221
|
* Listen for barcode detection events.
|
|
197
222
|
* This event is emitted when a barcode is detected in the camera preview.
|
|
@@ -230,6 +255,16 @@ export type CameraPosition = 'front' | 'back';
|
|
|
230
255
|
* @since 1.0.0
|
|
231
256
|
*/
|
|
232
257
|
export type FlashMode = 'off' | 'on' | 'auto';
|
|
258
|
+
/**
|
|
259
|
+
* Video recording quality presets.
|
|
260
|
+
*
|
|
261
|
+
* @remarks
|
|
262
|
+
* On iOS this maps to `AVCaptureSession.Preset` values.
|
|
263
|
+
* On Android this maps to CameraX `QualitySelector` values.
|
|
264
|
+
*
|
|
265
|
+
* @since 2.2.0
|
|
266
|
+
*/
|
|
267
|
+
export type VideoRecordingQuality = 'lowest' | 'sd' | 'hd' | 'fhd' | 'uhd' | 'highest';
|
|
233
268
|
/**
|
|
234
269
|
* Represents a physical camera device on the device.
|
|
235
270
|
*
|
|
@@ -268,6 +303,40 @@ export type CameraDeviceType =
|
|
|
268
303
|
| 'triple'
|
|
269
304
|
/** builtInTrueDepthCamera - front-facing camera with depth sensing */
|
|
270
305
|
| 'trueDepth';
|
|
306
|
+
/**
|
|
307
|
+
* Supported barcode types for detection.
|
|
308
|
+
* Specifying only the barcode types you need can improve performance
|
|
309
|
+
* and reduce battery consumption.
|
|
310
|
+
*
|
|
311
|
+
* @since 2.1.0
|
|
312
|
+
*/
|
|
313
|
+
export type BarcodeType =
|
|
314
|
+
/** QR Code */
|
|
315
|
+
'qr'
|
|
316
|
+
/** Code 128 barcode */
|
|
317
|
+
| 'code128'
|
|
318
|
+
/** Code 39 barcode */
|
|
319
|
+
| 'code39'
|
|
320
|
+
/** Code 39 Mod 43 barcode */
|
|
321
|
+
| 'code39Mod43'
|
|
322
|
+
/** Code 93 barcode */
|
|
323
|
+
| 'code93'
|
|
324
|
+
/** EAN-8 barcode */
|
|
325
|
+
| 'ean8'
|
|
326
|
+
/** EAN-13 barcode */
|
|
327
|
+
| 'ean13'
|
|
328
|
+
/** Interleaved 2 of 5 barcode */
|
|
329
|
+
| 'interleaved2of5'
|
|
330
|
+
/** ITF-14 barcode */
|
|
331
|
+
| 'itf14'
|
|
332
|
+
/** PDF417 barcode */
|
|
333
|
+
| 'pdf417'
|
|
334
|
+
/** Aztec code */
|
|
335
|
+
| 'aztec'
|
|
336
|
+
/** Data Matrix code */
|
|
337
|
+
| 'dataMatrix'
|
|
338
|
+
/** UPC-E barcode */
|
|
339
|
+
| 'upce';
|
|
271
340
|
/**
|
|
272
341
|
* Configuration options for starting a camera session.
|
|
273
342
|
*
|
|
@@ -279,6 +348,16 @@ export interface CameraSessionConfiguration {
|
|
|
279
348
|
* @default false
|
|
280
349
|
*/
|
|
281
350
|
enableBarcodeDetection?: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* Specific barcode types to detect. If not provided, all supported types are detected.
|
|
353
|
+
* Specifying only the types you need can significantly improve performance and reduce
|
|
354
|
+
* battery consumption, especially on mobile devices.
|
|
355
|
+
*
|
|
356
|
+
* @example ['qr', 'code128'] // Only detect QR codes and Code 128 barcodes
|
|
357
|
+
* @default undefined - all supported types are detected
|
|
358
|
+
* @since 2.1.0
|
|
359
|
+
*/
|
|
360
|
+
barcodeTypes?: BarcodeType[];
|
|
282
361
|
/**
|
|
283
362
|
* Position of the camera to use
|
|
284
363
|
* @default 'back'
|
|
@@ -339,6 +418,39 @@ export interface CaptureOptions {
|
|
|
339
418
|
*/
|
|
340
419
|
saveToFile?: boolean;
|
|
341
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* Configuration options for video recording.
|
|
423
|
+
* @since 2.2.0
|
|
424
|
+
*/
|
|
425
|
+
export interface VideoRecordingOptions {
|
|
426
|
+
/**
|
|
427
|
+
* Whether to record audio with the video.
|
|
428
|
+
* Requires microphone permission.
|
|
429
|
+
* @default false
|
|
430
|
+
* @since 2.2.0
|
|
431
|
+
*/
|
|
432
|
+
enableAudio?: boolean;
|
|
433
|
+
/**
|
|
434
|
+
* Video recording quality preset.
|
|
435
|
+
* Native platforms only (iOS/Android). Ignored on web.
|
|
436
|
+
* @default 'highest'
|
|
437
|
+
* @since 2.2.0
|
|
438
|
+
*/
|
|
439
|
+
videoQuality?: VideoRecordingQuality;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Response from stopping a video recording.
|
|
443
|
+
* @since 2.2.0
|
|
444
|
+
*/
|
|
445
|
+
export interface VideoRecordingResponse {
|
|
446
|
+
/**
|
|
447
|
+
* Web-accessible path to the recorded video file.
|
|
448
|
+
* On web, this is a blob URL.
|
|
449
|
+
* On iOS/Android, this is a path accessible via Capacitor's filesystem.
|
|
450
|
+
* @since 2.2.0
|
|
451
|
+
*/
|
|
452
|
+
webPath: string;
|
|
453
|
+
}
|
|
342
454
|
/**
|
|
343
455
|
* Response for checking if the camera view is running.
|
|
344
456
|
*
|
|
@@ -453,11 +565,21 @@ export interface BoundingRect {
|
|
|
453
565
|
height: number;
|
|
454
566
|
}
|
|
455
567
|
/**
|
|
456
|
-
*
|
|
568
|
+
* Permission types that can be requested.
|
|
569
|
+
* - 'camera': Camera access permission
|
|
570
|
+
* - 'microphone': Microphone access permission (needed for video recording with audio)
|
|
571
|
+
*
|
|
572
|
+
* @since 2.2.0
|
|
573
|
+
*/
|
|
574
|
+
export type CameraPermissionType = 'camera' | 'microphone';
|
|
575
|
+
/**
|
|
576
|
+
* Response for the camera and microphone permission status.
|
|
457
577
|
*
|
|
458
578
|
* @since 1.0.0
|
|
459
579
|
*/
|
|
460
580
|
export interface PermissionStatus {
|
|
461
581
|
/** The state of the camera permission */
|
|
462
582
|
camera: PermissionState;
|
|
583
|
+
/** The state of the microphone permission */
|
|
584
|
+
microphone: PermissionState;
|
|
463
585
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PermissionState, PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Main plugin interface for Capacitor Camera View functionality.\n *\n * @since 1.0.0\n */\nexport interface CameraViewPlugin {\n /**\n * Start the camera view with optional configuration.\n *\n * @param options - Configuration options for the camera session\n * @returns A promise that resolves when the camera has started\n *\n * @since 1.0.0\n */\n start(options?: CameraSessionConfiguration): Promise<void>;\n\n /**\n * Stop the camera view and release resources.\n *\n * @returns A promise that resolves when the camera has stopped\n *\n * @since 1.0.0\n */\n stop(): Promise<void>;\n\n /**\n * Check if the camera view is currently running.\n *\n * @returns A promise that resolves with an object containing the running state of the camera\n *\n * @since 1.0.0\n */\n isRunning(): Promise<IsRunningResponse>;\n\n /**\n * Capture a photo using the current camera configuration.\n *\n * @param options - Capture configuration options\n * @returns A promise that resolves with an object containing either a base64 encoded string or file path of the captured photo\n *\n * @since 1.0.0\n */\n capture<T extends CaptureOptions>(options: T): Promise<CaptureResponse<T>>;\n\n /**\n * Captures a frame from the current camera preview without using the full camera capture pipeline.\n *\n * Unlike `capture()` which may trigger hardware-level photo capture on native platforms,\n * this method quickly samples the current video stream. This is suitable computer vision or\n * simple snapshots where high fidelity is not required.\n *\n * On web this method does exactly the same as `capture()` as it only captures a frame from the video stream\n * because unfortunately [ImageCapture API](https://developer.mozilla.org/en-US/docs/Web/API/ImageCapture) is\n * not yet well supported on the web.\n *\n * @param options - Capture configuration options\n * @returns A promise that resolves with an object containing either a base64 encoded string or file path of the captured sample\n *\n * @since 1.0.0\n */\n captureSample<T extends CaptureOptions>(options: T): Promise<CaptureResponse<T>>;\n\n /**\n * Switch between front and back camera.\n *\n * @returns A promise that resolves when the camera has been flipped\n *\n * @since 1.0.0\n */\n flipCamera(): Promise<void>;\n\n /**\n * Get available camera devices for capturing photos.\n *\n * @returns A promise that resolves with an object containing an array of available capture devices\n *\n * @since 1.0.0\n */\n getAvailableDevices(): Promise<GetAvailableDevicesResponse>;\n\n /**\n * Get current zoom level information and available range.\n *\n * @remarks\n * Make sure the camera is properly initialized before calling this method. Otherwise, this might\n * lead to returning default values on android.\n *\n * @returns A promise that resolves with an object containing min, max and current zoom levels\n *\n * @since 1.0.0\n */\n getZoom(): Promise<GetZoomResponse>;\n\n /**\n * Set the camera zoom level.\n *\n * @param options - Zoom configuration options\n * @param options.level - The zoom level to set\n * @param options.ramp - Whether to animate the zoom level change, defaults to false (iOS only)\n * @returns A promise that resolves when the zoom level has been set\n *\n * @remarks\n * On web platforms, zoom functionality may be limited by browser support.\n * When native zoom is not available, a CSS-based zoom simulation is applied.\n *\n * @since 1.0.0\n */\n setZoom(options: { level: number; ramp?: boolean }): Promise<void>;\n\n /**\n * Get current flash mode setting.\n *\n * @returns A promise that resolves with an object containing the current flash mode\n *\n * @since 1.0.0\n */\n getFlashMode(): Promise<GetFlashModeResponse>;\n\n /**\n * Get supported flash modes for the current camera.\n *\n * @returns A promise that resolves with an object containing an array of supported flash modes\n *\n * @since 1.0.0\n */\n getSupportedFlashModes(): Promise<GetSupportedFlashModesResponse>;\n\n /**\n * Set the camera flash mode.\n *\n * @param options - Flash mode configuration options\n * @param options.mode - The flash mode to set\n * @returns A promise that resolves when the flash mode has been set\n *\n * @since 1.0.0\n */\n setFlashMode(options: { mode: FlashMode }): Promise<void>;\n\n /**\n * Check if the device supports torch (flashlight) functionality.\n *\n * @remarks\n * **Important**: You must call this method and verify torch availability before using\n * `setTorchMode()` or `getTorchMode()`. Calling torch methods on devices without\n * torch support will throw an exception.\n *\n * @returns A promise that resolves with an object containing torch availability status\n *\n * @since 1.2.0\n */\n isTorchAvailable(): Promise<IsTorchAvailableResponse>;\n\n /**\n * Get the current torch (flashlight) state.\n *\n * @remarks\n * **Important**: Call `isTorchAvailable()` first to ensure the device supports torch\n * functionality. This method will throw an exception if torch is not supported.\n *\n * @returns A promise that resolves with an object containing the current torch state\n *\n * @since 1.2.0\n */\n getTorchMode(): Promise<GetTorchModeResponse>;\n\n /**\n * Set the torch (flashlight) mode and intensity.\n *\n * @remarks\n * **Important**: Call `isTorchAvailable()` first to ensure the device supports torch\n * functionality. This method will throw an exception if torch is not supported.\n *\n * The torch provides continuous illumination, unlike flash which only activates during photo capture.\n * On iOS, you can control the torch intensity level. On Android, the torch is either on or off.\n *\n * @param options - Torch configuration options\n * @param options.enabled - Whether to enable or disable the torch\n * @param options.level - The torch intensity level (0.0 to 1.0, iOS only). Defaults to 1.0 when enabled\n * @returns A promise that resolves when the torch mode has been set\n *\n * @since 1.2.0\n */\n setTorchMode(options: { enabled: boolean; level?: number }): Promise<void>;\n\n /**\n * Check camera permission status without requesting permissions.\n *\n * @returns A promise that resolves with an object containing the camera permission status\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request camera permission from the user.\n *\n * @returns A promise that resolves with an object containing the camera permission status\n *\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Listen for barcode detection events.\n * This event is emitted when a barcode is detected in the camera preview.\n *\n * @param eventName - The name of the event to listen for ('barcodeDetected')\n * @param listenerFunc - The callback function to execute when a barcode is detected\n * @returns A promise that resolves with an event subscription\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'barcodeDetected',\n listenerFunc: (data: BarcodeDetectionData) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @param eventName - Optional event name to remove listeners for\n * @returns A promise that resolves when the listeners are removed\n *\n * @since 1.0.0\n */\n removeAllListeners(eventName?: string): Promise<void>;\n}\n\n// ------------------------------------------------------------------------------\n// Camera Configuration Types\n// ------------------------------------------------------------------------------\n\n/**\n * Position options for the camera.\n * - 'front': Front-facing camera\n * - 'back': Rear-facing camera\n *\n * @since 1.0.0\n */\nexport type CameraPosition = 'front' | 'back';\n\n/**\n * Flash mode options for the camera.\n * - 'off': Flash disabled\n * - 'on': Flash always on\n * - 'auto': Flash automatically enabled in low-light conditions\n *\n * @since 1.0.0\n */\nexport type FlashMode = 'off' | 'on' | 'auto';\n\n/**\n * Represents a physical camera device on the device.\n *\n * @since 1.0.0\n */\nexport interface CameraDevice {\n /** The unique identifier of the camera device */\n id: string;\n\n /** The human-readable name of the camera device */\n name: string;\n\n /** The position of the camera device (front or back) */\n position: CameraPosition;\n\n /** The type of the camera device (e.g., wide, ultra-wide, telephoto) - iOS only */\n deviceType?: CameraDeviceType;\n}\n\n/**\n * Available camera device types for iOS.\n * Maps to AVCaptureDevice DeviceTypes in iOS.\n *\n * @see https://developer.apple.com/documentation/avfoundation/avcapturedevice/devicetype-swift.struct\n *\n * @since 1.0.0\n */\nexport type CameraDeviceType =\n /** builtInWideAngleCamera - standard camera */\n | 'wideAngle'\n /** builtInUltraWideCamera - 0.5x zoom level */\n | 'ultraWide'\n /** builtInTelephotoCamera - 2x/3x zoom level */\n | 'telephoto'\n /** builtInDualCamera - wide + telephoto combination */\n | 'dual'\n /** builtInDualWideCamera - wide + ultraWide combination */\n | 'dualWide'\n /** builtInTripleCamera - wide + ultraWide + telephoto */\n | 'triple'\n /** builtInTrueDepthCamera - front-facing camera with depth sensing */\n | 'trueDepth';\n\n/**\n * Configuration options for starting a camera session.\n *\n * @since 1.0.0\n */\nexport interface CameraSessionConfiguration {\n /**\n * Enables the barcode detection functionality\n * @default false\n */\n enableBarcodeDetection?: boolean;\n\n /**\n * Position of the camera to use\n * @default 'back'\n */\n position?: CameraPosition;\n\n /**\n * Specific device ID of the camera to use\n * If provided, takes precedence over position\n */\n deviceId?: string;\n\n /**\n * Whether to use the triple camera if available (iPhone Pro models only)\n * @default false\n */\n useTripleCameraIfAvailable?: boolean;\n\n /**\n * Ordered list of preferred camera device types to use (iOS only).\n * The system will attempt to use the first available camera type in the list.\n * If position is also provided, the system will use the first available camera type\n * that matches the position and is in the list.\n *\n * This will fallback to the default camera type if none of the preferred types are available.\n *\n * @example [CameraDeviceType.WideAngle, CameraDeviceType.UltraWide, CameraDeviceType.Telephoto]\n * @default undefined - system will decide based on position/deviceId\n */\n preferredCameraDeviceTypes?: CameraDeviceType[];\n\n /**\n * The initial zoom factor to use\n * @default 1.0\n */\n zoomFactor?: number;\n\n /**\n * Optional HTML ID of the container element where the camera view should be rendered.\n * If not provided, the camera view will be appended to the document body. Web only.\n * @example 'cameraContainer'\n */\n containerElementId?: string;\n}\n\n/**\n * Configuration options for capturing photos and samples.\n *\n * @since 1.1.0\n */\nexport interface CaptureOptions {\n /**\n * The JPEG quality of the captured photo/sample on a scale of 0-100\n * @since 1.1.0\n */\n quality: number;\n\n /**\n * If true, saves to a temporary file and returns the web path instead of base64.\n * The web path can be used to set the src attribute of an image for efficient loading and rendering.\n * This reduces the data that needs to be transferred over the bridge, which can improve performance\n * especially for high-resolution images.\n * @default false\n * @since 1.1.0\n */\n saveToFile?: boolean;\n}\n\n// ------------------------------------------------------------------------------\n// Response Interfaces\n// ------------------------------------------------------------------------------\n\n/**\n * Response for checking if the camera view is running.\n *\n * @since 1.0.0\n */\nexport interface IsRunningResponse {\n /** Indicates if the camera view is currently active and running */\n isRunning: boolean;\n}\n\n/**\n * Response for capturing a photo\n * This will contain either a base64 encoded string or a web path to the captured photo,\n * depending on the `saveToFile` option in the CaptureOptions.\n * @since 1.0.0\n */\nexport type CaptureResponse<T extends CaptureOptions = CaptureOptions> = T['saveToFile'] extends true\n ? {\n /** The web path to the captured photo that can be used to set the src attribute of an image for efficient loading and rendering (when saveToFile is true) */\n webPath: string;\n }\n : {\n /** The base64 encoded string of the captured photo (when saveToFile is false or undefined) */\n photo: string;\n };\n\n/**\n * Response for getting available camera devices.\n *\n * @since 1.0.0\n */\nexport interface GetAvailableDevicesResponse {\n /** An array of available camera devices */\n devices: CameraDevice[];\n}\n\n/**\n * Response for getting zoom level information.\n *\n * @since 1.0.0\n */\nexport interface GetZoomResponse {\n /** The minimum zoom level supported */\n min: number;\n\n /** The maximum zoom level supported */\n max: number;\n\n /** The current zoom level */\n current: number;\n}\n\n/**\n * Response for getting the current flash mode.\n *\n * @since 1.0.0\n */\nexport interface GetFlashModeResponse {\n /** The current flash mode setting */\n flashMode: FlashMode;\n}\n\n/**\n * Response for getting supported flash modes.\n *\n * @since 1.0.0\n */\nexport interface GetSupportedFlashModesResponse {\n /** An array of flash modes supported by the current camera */\n flashModes: FlashMode[];\n}\n\n/**\n * Response for checking torch availability.\n *\n * @since 1.2.0\n */\nexport interface IsTorchAvailableResponse {\n /** Indicates if the device supports torch (flashlight) functionality */\n available: boolean;\n}\n\n/**\n * Response for getting the current torch mode.\n *\n * @since 1.2.0\n */\nexport interface GetTorchModeResponse {\n /** Indicates if the torch is currently enabled */\n enabled: boolean;\n /** The current torch intensity level (0.0 to 1.0, iOS only). Always 1.0 on Android when enabled */\n level: number;\n}\n\n/**\n * Data for a detected barcode.\n *\n * @since 1.0.0\n */\nexport interface BarcodeDetectionData {\n /** The decoded string value of the barcode */\n value: string;\n\n /** The display value of the barcode (may differ from the raw value) */\n displayValue?: string;\n\n /** The type/format of the barcode (e.g., 'qr', 'code128', etc.) */\n type: string;\n\n /** The bounding rectangle of the barcode in the camera frame. */\n boundingRect: BoundingRect;\n}\n\n/**\n * Rectangle defining the boundary of the barcode in the camera frame.\n * Coordinates are normalized between 0 and 1 relative to the camera frame.\n *\n * @since 1.0.0\n */\nexport interface BoundingRect {\n /** X-coordinate of the top-left corner */\n x: number;\n /** Y-coordinate of the top-left corner */\n y: number;\n /** Width of the bounding rectangle (should match the actual width of the barcode) */\n width: number;\n /** Height of the bounding rectangle (should match the actual height of the barcode) */\n height: number;\n}\n\n/**\n * Response for the camera permission status.\n *\n * @since 1.0.0\n */\nexport interface PermissionStatus {\n /** The state of the camera permission */\n camera: PermissionState;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PermissionState, PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Main plugin interface for Capacitor Camera View functionality.\n *\n * @since 1.0.0\n */\nexport interface CameraViewPlugin {\n /**\n * Start the camera view with optional configuration.\n *\n * @param options - Configuration options for the camera session\n * @returns A promise that resolves when the camera has started\n *\n * @since 1.0.0\n */\n start(options?: CameraSessionConfiguration): Promise<void>;\n\n /**\n * Stop the camera view and release resources.\n *\n * @returns A promise that resolves when the camera has stopped\n *\n * @since 1.0.0\n */\n stop(): Promise<void>;\n\n /**\n * Check if the camera view is currently running.\n *\n * @returns A promise that resolves with an object containing the running state of the camera\n *\n * @since 1.0.0\n */\n isRunning(): Promise<IsRunningResponse>;\n\n /**\n * Capture a photo using the current camera configuration.\n *\n * @param options - Capture configuration options\n * @returns A promise that resolves with an object containing either a base64 encoded string or file path of the captured photo\n *\n * @since 1.0.0\n */\n capture<T extends CaptureOptions>(options: T): Promise<CaptureResponse<T>>;\n\n /**\n * Captures a frame from the current camera preview without using the full camera capture pipeline.\n *\n * Unlike `capture()` which may trigger hardware-level photo capture on native platforms,\n * this method quickly samples the current video stream. This is suitable computer vision or\n * simple snapshots where high fidelity is not required.\n *\n * On web this method does exactly the same as `capture()` as it only captures a frame from the video stream\n * because unfortunately [ImageCapture API](https://developer.mozilla.org/en-US/docs/Web/API/ImageCapture) is\n * not yet well supported on the web.\n *\n * @param options - Capture configuration options\n * @returns A promise that resolves with an object containing either a base64 encoded string or file path of the captured sample\n *\n * @since 1.0.0\n */\n captureSample<T extends CaptureOptions>(options: T): Promise<CaptureResponse<T>>;\n\n /**\n * Start recording video from the current camera.\n * Camera must be running. Throws if already recording.\n *\n * @param options - Optional recording configuration\n * @returns A promise that resolves when recording has started\n *\n * @since 2.2.0\n */\n startRecording(options?: VideoRecordingOptions): Promise<void>;\n\n /**\n * Stop the current video recording and return the result.\n * Throws if no recording is in progress.\n *\n * @returns A promise that resolves with the recorded video file path\n *\n * @since 2.2.0\n */\n stopRecording(): Promise<VideoRecordingResponse>;\n\n /**\n * Switch between front and back camera.\n *\n * @returns A promise that resolves when the camera has been flipped\n *\n * @since 1.0.0\n */\n flipCamera(): Promise<void>;\n\n /**\n * Get available camera devices for capturing photos.\n *\n * @returns A promise that resolves with an object containing an array of available capture devices\n *\n * @since 1.0.0\n */\n getAvailableDevices(): Promise<GetAvailableDevicesResponse>;\n\n /**\n * Get current zoom level information and available range.\n *\n * @remarks\n * Make sure the camera is properly initialized before calling this method. Otherwise, this might\n * lead to returning default values on android.\n *\n * @returns A promise that resolves with an object containing min, max and current zoom levels\n *\n * @since 1.0.0\n */\n getZoom(): Promise<GetZoomResponse>;\n\n /**\n * Set the camera zoom level.\n *\n * @param options - Zoom configuration options\n * @param options.level - The zoom level to set\n * @param options.ramp - Whether to animate the zoom level change, defaults to false (iOS only)\n * @returns A promise that resolves when the zoom level has been set\n *\n * @remarks\n * On web platforms, zoom functionality may be limited by browser support.\n * When native zoom is not available, a CSS-based zoom simulation is applied.\n *\n * @since 1.0.0\n */\n setZoom(options: { level: number; ramp?: boolean }): Promise<void>;\n\n /**\n * Get current flash mode setting.\n *\n * @returns A promise that resolves with an object containing the current flash mode\n *\n * @since 1.0.0\n */\n getFlashMode(): Promise<GetFlashModeResponse>;\n\n /**\n * Get supported flash modes for the current camera.\n *\n * @returns A promise that resolves with an object containing an array of supported flash modes\n *\n * @since 1.0.0\n */\n getSupportedFlashModes(): Promise<GetSupportedFlashModesResponse>;\n\n /**\n * Set the camera flash mode.\n *\n * @param options - Flash mode configuration options\n * @param options.mode - The flash mode to set\n * @returns A promise that resolves when the flash mode has been set\n *\n * @since 1.0.0\n */\n setFlashMode(options: { mode: FlashMode }): Promise<void>;\n\n /**\n * Check if the device supports torch (flashlight) functionality.\n *\n * @remarks\n * **Important**: You must call this method and verify torch availability before using\n * `setTorchMode()` or `getTorchMode()`. Calling torch methods on devices without\n * torch support will throw an exception.\n *\n * @returns A promise that resolves with an object containing torch availability status\n *\n * @since 1.2.0\n */\n isTorchAvailable(): Promise<IsTorchAvailableResponse>;\n\n /**\n * Get the current torch (flashlight) state.\n *\n * @remarks\n * **Important**: Call `isTorchAvailable()` first to ensure the device supports torch\n * functionality. This method will throw an exception if torch is not supported.\n *\n * @returns A promise that resolves with an object containing the current torch state\n *\n * @since 1.2.0\n */\n getTorchMode(): Promise<GetTorchModeResponse>;\n\n /**\n * Set the torch (flashlight) mode and intensity.\n *\n * @remarks\n * **Important**: Call `isTorchAvailable()` first to ensure the device supports torch\n * functionality. This method will throw an exception if torch is not supported.\n *\n * The torch provides continuous illumination, unlike flash which only activates during photo capture.\n * On iOS, you can control the torch intensity level. On Android, the torch is either on or off.\n *\n * @param options - Torch configuration options\n * @param options.enabled - Whether to enable or disable the torch\n * @param options.level - The torch intensity level (0.0 to 1.0, iOS only). Defaults to 1.0 when enabled\n * @returns A promise that resolves when the torch mode has been set\n *\n * @since 1.2.0\n */\n setTorchMode(options: { enabled: boolean; level?: number }): Promise<void>;\n\n /**\n * Check camera and microphone permission status without requesting permissions.\n *\n * @returns A promise that resolves with an object containing the camera and microphone permission status\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request camera and/or microphone permissions from the user.\n *\n * By default, only camera permission is requested. To also request microphone\n * permission (needed for video recording with audio), pass `{ permissions: ['camera', 'microphone'] }`.\n *\n * @param options - Optional object specifying which permissions to request\n * @returns A promise that resolves with an object containing the camera and microphone permission status\n *\n * @since 1.0.0\n */\n requestPermissions(options?: { permissions?: CameraPermissionType[] }): Promise<PermissionStatus>;\n\n /**\n * Listen for barcode detection events.\n * This event is emitted when a barcode is detected in the camera preview.\n *\n * @param eventName - The name of the event to listen for ('barcodeDetected')\n * @param listenerFunc - The callback function to execute when a barcode is detected\n * @returns A promise that resolves with an event subscription\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'barcodeDetected',\n listenerFunc: (data: BarcodeDetectionData) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @param eventName - Optional event name to remove listeners for\n * @returns A promise that resolves when the listeners are removed\n *\n * @since 1.0.0\n */\n removeAllListeners(eventName?: string): Promise<void>;\n}\n\n// ------------------------------------------------------------------------------\n// Camera Configuration Types\n// ------------------------------------------------------------------------------\n\n/**\n * Position options for the camera.\n * - 'front': Front-facing camera\n * - 'back': Rear-facing camera\n *\n * @since 1.0.0\n */\nexport type CameraPosition = 'front' | 'back';\n\n/**\n * Flash mode options for the camera.\n * - 'off': Flash disabled\n * - 'on': Flash always on\n * - 'auto': Flash automatically enabled in low-light conditions\n *\n * @since 1.0.0\n */\nexport type FlashMode = 'off' | 'on' | 'auto';\n\n/**\n * Video recording quality presets.\n *\n * @remarks\n * On iOS this maps to `AVCaptureSession.Preset` values.\n * On Android this maps to CameraX `QualitySelector` values.\n *\n * @since 2.2.0\n */\nexport type VideoRecordingQuality = 'lowest' | 'sd' | 'hd' | 'fhd' | 'uhd' | 'highest';\n\n/**\n * Represents a physical camera device on the device.\n *\n * @since 1.0.0\n */\nexport interface CameraDevice {\n /** The unique identifier of the camera device */\n id: string;\n\n /** The human-readable name of the camera device */\n name: string;\n\n /** The position of the camera device (front or back) */\n position: CameraPosition;\n\n /** The type of the camera device (e.g., wide, ultra-wide, telephoto) - iOS only */\n deviceType?: CameraDeviceType;\n}\n\n/**\n * Available camera device types for iOS.\n * Maps to AVCaptureDevice DeviceTypes in iOS.\n *\n * @see https://developer.apple.com/documentation/avfoundation/avcapturedevice/devicetype-swift.struct\n *\n * @since 1.0.0\n */\nexport type CameraDeviceType =\n /** builtInWideAngleCamera - standard camera */\n | 'wideAngle'\n /** builtInUltraWideCamera - 0.5x zoom level */\n | 'ultraWide'\n /** builtInTelephotoCamera - 2x/3x zoom level */\n | 'telephoto'\n /** builtInDualCamera - wide + telephoto combination */\n | 'dual'\n /** builtInDualWideCamera - wide + ultraWide combination */\n | 'dualWide'\n /** builtInTripleCamera - wide + ultraWide + telephoto */\n | 'triple'\n /** builtInTrueDepthCamera - front-facing camera with depth sensing */\n | 'trueDepth';\n\n/**\n * Supported barcode types for detection.\n * Specifying only the barcode types you need can improve performance\n * and reduce battery consumption.\n *\n * @since 2.1.0\n */\nexport type BarcodeType =\n /** QR Code */\n | 'qr'\n /** Code 128 barcode */\n | 'code128'\n /** Code 39 barcode */\n | 'code39'\n /** Code 39 Mod 43 barcode */\n | 'code39Mod43'\n /** Code 93 barcode */\n | 'code93'\n /** EAN-8 barcode */\n | 'ean8'\n /** EAN-13 barcode */\n | 'ean13'\n /** Interleaved 2 of 5 barcode */\n | 'interleaved2of5'\n /** ITF-14 barcode */\n | 'itf14'\n /** PDF417 barcode */\n | 'pdf417'\n /** Aztec code */\n | 'aztec'\n /** Data Matrix code */\n | 'dataMatrix'\n /** UPC-E barcode */\n | 'upce';\n\n/**\n * Configuration options for starting a camera session.\n *\n * @since 1.0.0\n */\nexport interface CameraSessionConfiguration {\n /**\n * Enables the barcode detection functionality\n * @default false\n */\n enableBarcodeDetection?: boolean;\n\n /**\n * Specific barcode types to detect. If not provided, all supported types are detected.\n * Specifying only the types you need can significantly improve performance and reduce\n * battery consumption, especially on mobile devices.\n *\n * @example ['qr', 'code128'] // Only detect QR codes and Code 128 barcodes\n * @default undefined - all supported types are detected\n * @since 2.1.0\n */\n barcodeTypes?: BarcodeType[];\n\n /**\n * Position of the camera to use\n * @default 'back'\n */\n position?: CameraPosition;\n\n /**\n * Specific device ID of the camera to use\n * If provided, takes precedence over position\n */\n deviceId?: string;\n\n /**\n * Whether to use the triple camera if available (iPhone Pro models only)\n * @default false\n */\n useTripleCameraIfAvailable?: boolean;\n\n /**\n * Ordered list of preferred camera device types to use (iOS only).\n * The system will attempt to use the first available camera type in the list.\n * If position is also provided, the system will use the first available camera type\n * that matches the position and is in the list.\n *\n * This will fallback to the default camera type if none of the preferred types are available.\n *\n * @example [CameraDeviceType.WideAngle, CameraDeviceType.UltraWide, CameraDeviceType.Telephoto]\n * @default undefined - system will decide based on position/deviceId\n */\n preferredCameraDeviceTypes?: CameraDeviceType[];\n\n /**\n * The initial zoom factor to use\n * @default 1.0\n */\n zoomFactor?: number;\n\n /**\n * Optional HTML ID of the container element where the camera view should be rendered.\n * If not provided, the camera view will be appended to the document body. Web only.\n * @example 'cameraContainer'\n */\n containerElementId?: string;\n}\n\n/**\n * Configuration options for capturing photos and samples.\n *\n * @since 1.1.0\n */\nexport interface CaptureOptions {\n /**\n * The JPEG quality of the captured photo/sample on a scale of 0-100\n * @since 1.1.0\n */\n quality: number;\n\n /**\n * If true, saves to a temporary file and returns the web path instead of base64.\n * The web path can be used to set the src attribute of an image for efficient loading and rendering.\n * This reduces the data that needs to be transferred over the bridge, which can improve performance\n * especially for high-resolution images.\n * @default false\n * @since 1.1.0\n */\n saveToFile?: boolean;\n}\n\n/**\n * Configuration options for video recording.\n * @since 2.2.0\n */\nexport interface VideoRecordingOptions {\n /**\n * Whether to record audio with the video.\n * Requires microphone permission.\n * @default false\n * @since 2.2.0\n */\n enableAudio?: boolean;\n\n /**\n * Video recording quality preset.\n * Native platforms only (iOS/Android). Ignored on web.\n * @default 'highest'\n * @since 2.2.0\n */\n videoQuality?: VideoRecordingQuality;\n}\n\n/**\n * Response from stopping a video recording.\n * @since 2.2.0\n */\nexport interface VideoRecordingResponse {\n /**\n * Web-accessible path to the recorded video file.\n * On web, this is a blob URL.\n * On iOS/Android, this is a path accessible via Capacitor's filesystem.\n * @since 2.2.0\n */\n webPath: string;\n}\n\n// ------------------------------------------------------------------------------\n// Response Interfaces\n// ------------------------------------------------------------------------------\n\n/**\n * Response for checking if the camera view is running.\n *\n * @since 1.0.0\n */\nexport interface IsRunningResponse {\n /** Indicates if the camera view is currently active and running */\n isRunning: boolean;\n}\n\n/**\n * Response for capturing a photo\n * This will contain either a base64 encoded string or a web path to the captured photo,\n * depending on the `saveToFile` option in the CaptureOptions.\n * @since 1.0.0\n */\nexport type CaptureResponse<T extends CaptureOptions = CaptureOptions> = T['saveToFile'] extends true\n ? {\n /** The web path to the captured photo that can be used to set the src attribute of an image for efficient loading and rendering (when saveToFile is true) */\n webPath: string;\n }\n : {\n /** The base64 encoded string of the captured photo (when saveToFile is false or undefined) */\n photo: string;\n };\n\n/**\n * Response for getting available camera devices.\n *\n * @since 1.0.0\n */\nexport interface GetAvailableDevicesResponse {\n /** An array of available camera devices */\n devices: CameraDevice[];\n}\n\n/**\n * Response for getting zoom level information.\n *\n * @since 1.0.0\n */\nexport interface GetZoomResponse {\n /** The minimum zoom level supported */\n min: number;\n\n /** The maximum zoom level supported */\n max: number;\n\n /** The current zoom level */\n current: number;\n}\n\n/**\n * Response for getting the current flash mode.\n *\n * @since 1.0.0\n */\nexport interface GetFlashModeResponse {\n /** The current flash mode setting */\n flashMode: FlashMode;\n}\n\n/**\n * Response for getting supported flash modes.\n *\n * @since 1.0.0\n */\nexport interface GetSupportedFlashModesResponse {\n /** An array of flash modes supported by the current camera */\n flashModes: FlashMode[];\n}\n\n/**\n * Response for checking torch availability.\n *\n * @since 1.2.0\n */\nexport interface IsTorchAvailableResponse {\n /** Indicates if the device supports torch (flashlight) functionality */\n available: boolean;\n}\n\n/**\n * Response for getting the current torch mode.\n *\n * @since 1.2.0\n */\nexport interface GetTorchModeResponse {\n /** Indicates if the torch is currently enabled */\n enabled: boolean;\n /** The current torch intensity level (0.0 to 1.0, iOS only). Always 1.0 on Android when enabled */\n level: number;\n}\n\n/**\n * Data for a detected barcode.\n *\n * @since 1.0.0\n */\nexport interface BarcodeDetectionData {\n /** The decoded string value of the barcode */\n value: string;\n\n /** The display value of the barcode (may differ from the raw value) */\n displayValue?: string;\n\n /** The type/format of the barcode (e.g., 'qr', 'code128', etc.) */\n type: string;\n\n /** The bounding rectangle of the barcode in the camera frame. */\n boundingRect: BoundingRect;\n}\n\n/**\n * Rectangle defining the boundary of the barcode in the camera frame.\n * Coordinates are normalized between 0 and 1 relative to the camera frame.\n *\n * @since 1.0.0\n */\nexport interface BoundingRect {\n /** X-coordinate of the top-left corner */\n x: number;\n /** Y-coordinate of the top-left corner */\n y: number;\n /** Width of the bounding rectangle (should match the actual width of the barcode) */\n width: number;\n /** Height of the bounding rectangle (should match the actual height of the barcode) */\n height: number;\n}\n\n/**\n * Permission types that can be requested.\n * - 'camera': Camera access permission\n * - 'microphone': Microphone access permission (needed for video recording with audio)\n *\n * @since 2.2.0\n */\nexport type CameraPermissionType = 'camera' | 'microphone';\n\n/**\n * Response for the camera and microphone permission status.\n *\n * @since 1.0.0\n */\nexport interface PermissionStatus {\n /** The state of the camera permission */\n camera: PermissionState;\n /** The state of the microphone permission */\n microphone: PermissionState;\n}\n"]}
|