capacitor-camera-view 2.2.0-rc.1 → 2.2.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/README.md +17 -202
- package/android/build.gradle +0 -1
- package/android/src/main/AndroidManifest.xml +0 -1
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraView.kt +4 -287
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraViewPlugin.kt +8 -112
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/BarcodeDetectionResult.kt +1 -0
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/utils.kt +1 -21
- package/dist/docs.json +21 -201
- package/dist/esm/definitions.d.ts +23 -85
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +4 -20
- package/dist/esm/web.js +16 -151
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +16 -151
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +16 -151
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CameraViewPlugin/CameraError.swift +0 -28
- package/ios/Sources/CameraViewPlugin/CameraEvents.swift +27 -3
- package/ios/Sources/CameraViewPlugin/CameraSessionConfiguration.swift +8 -8
- package/ios/Sources/CameraViewPlugin/CameraViewManager+BarcodeScan.swift +34 -3
- package/ios/Sources/CameraViewPlugin/CameraViewManager+PhotoCapture.swift +14 -13
- package/ios/Sources/CameraViewPlugin/CameraViewManager.swift +150 -159
- package/ios/Sources/CameraViewPlugin/CameraViewPlugin.swift +15 -114
- package/ios/Sources/CameraViewPlugin/TempFileManager.swift +34 -68
- package/package.json +12 -12
- package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/VideoRecordingQuality.kt +0 -10
- package/ios/Sources/CameraViewPlugin/CameraViewManager+VideoRecording.swift +0 -302
package/dist/docs.json
CHANGED
|
@@ -147,58 +147,6 @@
|
|
|
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
|
-
},
|
|
202
150
|
{
|
|
203
151
|
"name": "flipCamera",
|
|
204
152
|
"signature": "() => Promise<void>",
|
|
@@ -481,14 +429,14 @@
|
|
|
481
429
|
"tags": [
|
|
482
430
|
{
|
|
483
431
|
"name": "returns",
|
|
484
|
-
"text": "A promise that resolves with an object containing the camera
|
|
432
|
+
"text": "A promise that resolves with an object containing the camera permission status"
|
|
485
433
|
},
|
|
486
434
|
{
|
|
487
435
|
"name": "since",
|
|
488
436
|
"text": "1.0.0"
|
|
489
437
|
}
|
|
490
438
|
],
|
|
491
|
-
"docs": "Check camera
|
|
439
|
+
"docs": "Check camera permission status without requesting permissions.",
|
|
492
440
|
"complexTypes": [
|
|
493
441
|
"PermissionStatus"
|
|
494
442
|
],
|
|
@@ -496,33 +444,22 @@
|
|
|
496
444
|
},
|
|
497
445
|
{
|
|
498
446
|
"name": "requestPermissions",
|
|
499
|
-
"signature": "(
|
|
500
|
-
"parameters": [
|
|
501
|
-
{
|
|
502
|
-
"name": "options",
|
|
503
|
-
"docs": "- Optional object specifying which permissions to request",
|
|
504
|
-
"type": "{ permissions?: CameraPermissionType[] | undefined; } | undefined"
|
|
505
|
-
}
|
|
506
|
-
],
|
|
447
|
+
"signature": "() => Promise<PermissionStatus>",
|
|
448
|
+
"parameters": [],
|
|
507
449
|
"returns": "Promise<PermissionStatus>",
|
|
508
450
|
"tags": [
|
|
509
|
-
{
|
|
510
|
-
"name": "param",
|
|
511
|
-
"text": "options - Optional object specifying which permissions to request"
|
|
512
|
-
},
|
|
513
451
|
{
|
|
514
452
|
"name": "returns",
|
|
515
|
-
"text": "A promise that resolves with an object containing the camera
|
|
453
|
+
"text": "A promise that resolves with an object containing the camera permission status"
|
|
516
454
|
},
|
|
517
455
|
{
|
|
518
456
|
"name": "since",
|
|
519
457
|
"text": "1.0.0"
|
|
520
458
|
}
|
|
521
459
|
],
|
|
522
|
-
"docs": "Request camera
|
|
460
|
+
"docs": "Request camera permission from the user.",
|
|
523
461
|
"complexTypes": [
|
|
524
|
-
"PermissionStatus"
|
|
525
|
-
"CameraPermissionType"
|
|
462
|
+
"PermissionStatus"
|
|
526
463
|
],
|
|
527
464
|
"slug": "requestpermissions"
|
|
528
465
|
},
|
|
@@ -786,80 +723,6 @@
|
|
|
786
723
|
}
|
|
787
724
|
]
|
|
788
725
|
},
|
|
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
|
-
},
|
|
863
726
|
{
|
|
864
727
|
"name": "GetAvailableDevicesResponse",
|
|
865
728
|
"slug": "getavailabledevicesresponse",
|
|
@@ -1062,7 +925,7 @@
|
|
|
1062
925
|
{
|
|
1063
926
|
"name": "PermissionStatus",
|
|
1064
927
|
"slug": "permissionstatus",
|
|
1065
|
-
"docs": "Response for the camera
|
|
928
|
+
"docs": "Response for the camera permission status.",
|
|
1066
929
|
"tags": [
|
|
1067
930
|
{
|
|
1068
931
|
"text": "1.0.0",
|
|
@@ -1079,15 +942,6 @@
|
|
|
1079
942
|
"PermissionState"
|
|
1080
943
|
],
|
|
1081
944
|
"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"
|
|
1091
945
|
}
|
|
1092
946
|
]
|
|
1093
947
|
},
|
|
@@ -1126,10 +980,22 @@
|
|
|
1126
980
|
"complexTypes": [],
|
|
1127
981
|
"type": "string"
|
|
1128
982
|
},
|
|
983
|
+
{
|
|
984
|
+
"name": "rawBytes",
|
|
985
|
+
"tags": [
|
|
986
|
+
{
|
|
987
|
+
"text": "2.2.0",
|
|
988
|
+
"name": "since"
|
|
989
|
+
}
|
|
990
|
+
],
|
|
991
|
+
"docs": "Raw bytes as they were encoded in the barcode.\n\nOn Android, this is forwarded from ML Kit.\nOn iOS, this is available for descriptor-backed formats such as QR, Aztec, PDF417, and Data Matrix.\nOn web, this is not available because the Barcode Detection API only exposes the decoded string value.",
|
|
992
|
+
"complexTypes": [],
|
|
993
|
+
"type": "number[] | undefined"
|
|
994
|
+
},
|
|
1129
995
|
{
|
|
1130
996
|
"name": "displayValue",
|
|
1131
997
|
"tags": [],
|
|
1132
|
-
"docs": "The display value of the barcode
|
|
998
|
+
"docs": "The display value of the barcode on Android.\n\nThis is forwarded from ML Kit and may contain a formatted, human-readable\nrepresentation that differs from the raw decoded value. iOS and web do not\nexpose a separate display value, so this property is only emitted on Android.",
|
|
1133
999
|
"complexTypes": [],
|
|
1134
1000
|
"type": "string | undefined"
|
|
1135
1001
|
},
|
|
@@ -1318,37 +1184,6 @@
|
|
|
1318
1184
|
}
|
|
1319
1185
|
]
|
|
1320
1186
|
},
|
|
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
|
-
},
|
|
1352
1187
|
{
|
|
1353
1188
|
"name": "FlashMode",
|
|
1354
1189
|
"slug": "flashmode",
|
|
@@ -1390,21 +1225,6 @@
|
|
|
1390
1225
|
"complexTypes": []
|
|
1391
1226
|
}
|
|
1392
1227
|
]
|
|
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
|
-
]
|
|
1408
1228
|
}
|
|
1409
1229
|
],
|
|
1410
1230
|
"pluginConfigs": []
|
|
@@ -56,25 +56,6 @@ 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>;
|
|
78
59
|
/**
|
|
79
60
|
* Switch between front and back camera.
|
|
80
61
|
*
|
|
@@ -196,27 +177,21 @@ export interface CameraViewPlugin {
|
|
|
196
177
|
level?: number;
|
|
197
178
|
}): Promise<void>;
|
|
198
179
|
/**
|
|
199
|
-
* Check camera
|
|
180
|
+
* Check camera permission status without requesting permissions.
|
|
200
181
|
*
|
|
201
|
-
* @returns A promise that resolves with an object containing the camera
|
|
182
|
+
* @returns A promise that resolves with an object containing the camera permission status
|
|
202
183
|
*
|
|
203
184
|
* @since 1.0.0
|
|
204
185
|
*/
|
|
205
186
|
checkPermissions(): Promise<PermissionStatus>;
|
|
206
187
|
/**
|
|
207
|
-
* Request camera
|
|
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'] }`.
|
|
188
|
+
* Request camera permission from the user.
|
|
211
189
|
*
|
|
212
|
-
* @
|
|
213
|
-
* @returns A promise that resolves with an object containing the camera and microphone permission status
|
|
190
|
+
* @returns A promise that resolves with an object containing the camera permission status
|
|
214
191
|
*
|
|
215
192
|
* @since 1.0.0
|
|
216
193
|
*/
|
|
217
|
-
requestPermissions(
|
|
218
|
-
permissions?: CameraPermissionType[];
|
|
219
|
-
}): Promise<PermissionStatus>;
|
|
194
|
+
requestPermissions(): Promise<PermissionStatus>;
|
|
220
195
|
/**
|
|
221
196
|
* Listen for barcode detection events.
|
|
222
197
|
* This event is emitted when a barcode is detected in the camera preview.
|
|
@@ -255,16 +230,6 @@ export type CameraPosition = 'front' | 'back';
|
|
|
255
230
|
* @since 1.0.0
|
|
256
231
|
*/
|
|
257
232
|
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';
|
|
268
233
|
/**
|
|
269
234
|
* Represents a physical camera device on the device.
|
|
270
235
|
*
|
|
@@ -418,39 +383,6 @@ export interface CaptureOptions {
|
|
|
418
383
|
*/
|
|
419
384
|
saveToFile?: boolean;
|
|
420
385
|
}
|
|
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
|
-
}
|
|
454
386
|
/**
|
|
455
387
|
* Response for checking if the camera view is running.
|
|
456
388
|
*
|
|
@@ -541,7 +473,23 @@ export interface GetTorchModeResponse {
|
|
|
541
473
|
export interface BarcodeDetectionData {
|
|
542
474
|
/** The decoded string value of the barcode */
|
|
543
475
|
value: string;
|
|
544
|
-
/**
|
|
476
|
+
/**
|
|
477
|
+
* Raw bytes as they were encoded in the barcode.
|
|
478
|
+
*
|
|
479
|
+
* On Android, this is forwarded from ML Kit.
|
|
480
|
+
* On iOS, this is available for descriptor-backed formats such as QR, Aztec, PDF417, and Data Matrix.
|
|
481
|
+
* On web, this is not available because the Barcode Detection API only exposes the decoded string value.
|
|
482
|
+
*
|
|
483
|
+
* @since 2.2.0
|
|
484
|
+
*/
|
|
485
|
+
rawBytes?: number[];
|
|
486
|
+
/**
|
|
487
|
+
* The display value of the barcode on Android.
|
|
488
|
+
*
|
|
489
|
+
* This is forwarded from ML Kit and may contain a formatted, human-readable
|
|
490
|
+
* representation that differs from the raw decoded value. iOS and web do not
|
|
491
|
+
* expose a separate display value, so this property is only emitted on Android.
|
|
492
|
+
*/
|
|
545
493
|
displayValue?: string;
|
|
546
494
|
/** The type/format of the barcode (e.g., 'qr', 'code128', etc.) */
|
|
547
495
|
type: string;
|
|
@@ -565,21 +513,11 @@ export interface BoundingRect {
|
|
|
565
513
|
height: number;
|
|
566
514
|
}
|
|
567
515
|
/**
|
|
568
|
-
*
|
|
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.
|
|
516
|
+
* Response for the camera permission status.
|
|
577
517
|
*
|
|
578
518
|
* @since 1.0.0
|
|
579
519
|
*/
|
|
580
520
|
export interface PermissionStatus {
|
|
581
521
|
/** The state of the camera permission */
|
|
582
522
|
camera: PermissionState;
|
|
583
|
-
/** The state of the microphone permission */
|
|
584
|
-
microphone: PermissionState;
|
|
585
523
|
}
|
|
@@ -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 * 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"]}
|
|
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 * 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// 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 /**\n * Raw bytes as they were encoded in the barcode.\n *\n * On Android, this is forwarded from ML Kit.\n * On iOS, this is available for descriptor-backed formats such as QR, Aztec, PDF417, and Data Matrix.\n * On web, this is not available because the Barcode Detection API only exposes the decoded string value.\n *\n * @since 2.2.0\n */\n rawBytes?: number[];\n\n /**\n * The display value of the barcode on Android.\n *\n * This is forwarded from ML Kit and may contain a formatted, human-readable\n * representation that differs from the raw decoded value. iOS and web do not\n * expose a separate display value, so this property is only emitted on Android.\n */\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"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { CameraSessionConfiguration, CameraViewPlugin,
|
|
2
|
+
import type { CameraSessionConfiguration, CameraViewPlugin, GetAvailableDevicesResponse, GetFlashModeResponse, GetSupportedFlashModesResponse, GetTorchModeResponse, GetZoomResponse, IsTorchAvailableResponse, IsRunningResponse, PermissionStatus, CaptureResponse, FlashMode, CaptureOptions, BarcodeType } from './definitions';
|
|
3
3
|
export declare const BARCODE_TYPE_TO_WEB_FORMAT: Readonly<Record<BarcodeType, BarcodeFormat | null>>;
|
|
4
4
|
/**
|
|
5
5
|
* Web implementation of the CameraViewPlugin.
|
|
@@ -15,11 +15,6 @@ export declare class CameraViewWeb extends WebPlugin implements CameraViewPlugin
|
|
|
15
15
|
private currentFlashMode;
|
|
16
16
|
private barcodeDetectionSupported;
|
|
17
17
|
private barcodeDetector;
|
|
18
|
-
private mediaRecorder;
|
|
19
|
-
private recordedChunks;
|
|
20
|
-
private recordingAudioTrack;
|
|
21
|
-
private recordingResolve;
|
|
22
|
-
private recordingReject;
|
|
23
18
|
constructor();
|
|
24
19
|
/**
|
|
25
20
|
* Start the camera with the given configuration
|
|
@@ -42,14 +37,6 @@ export declare class CameraViewWeb extends WebPlugin implements CameraViewPlugin
|
|
|
42
37
|
* Web implementation already uses images from the video stream, so this is the same as `capture()`
|
|
43
38
|
*/
|
|
44
39
|
captureSample<T extends CaptureOptions>(options: T): Promise<CaptureResponse<T>>;
|
|
45
|
-
/**
|
|
46
|
-
* Start recording video using MediaRecorder API
|
|
47
|
-
*/
|
|
48
|
-
startRecording(options?: VideoRecordingOptions): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* Stop the current video recording
|
|
51
|
-
*/
|
|
52
|
-
stopRecording(): Promise<VideoRecordingResponse>;
|
|
53
40
|
/**
|
|
54
41
|
* Flip between front and back camera
|
|
55
42
|
*/
|
|
@@ -96,16 +83,13 @@ export declare class CameraViewWeb extends WebPlugin implements CameraViewPlugin
|
|
|
96
83
|
*/
|
|
97
84
|
setTorchMode(): Promise<void>;
|
|
98
85
|
/**
|
|
99
|
-
* Check camera
|
|
86
|
+
* Check camera permission without requesting
|
|
100
87
|
*/
|
|
101
88
|
checkPermissions(): Promise<PermissionStatus>;
|
|
102
89
|
/**
|
|
103
|
-
* Request camera
|
|
104
|
-
* By default, only camera permission is requested.
|
|
90
|
+
* Request camera permission from the user
|
|
105
91
|
*/
|
|
106
|
-
requestPermissions(
|
|
107
|
-
permissions?: CameraPermissionType[];
|
|
108
|
-
}): Promise<PermissionStatus>;
|
|
92
|
+
requestPermissions(): Promise<PermissionStatus>;
|
|
109
93
|
/**
|
|
110
94
|
* Start barcode detection if supported
|
|
111
95
|
*/
|