@capgo/camera-preview 7.3.12 → 7.4.0-alpha.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/CapgoCameraPreview.podspec +16 -13
- package/README.md +492 -73
- package/android/build.gradle +11 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/AndroidManifest.xml +5 -3
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +968 -505
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +3017 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/GridOverlayView.java +119 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraDevice.java +63 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraLens.java +79 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraSessionConfiguration.java +167 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/LensInfo.java +40 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/ZoomFactors.java +35 -0
- package/dist/docs.json +1041 -161
- package/dist/esm/definitions.d.ts +484 -84
- package/dist/esm/definitions.js +10 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +78 -3
- package/dist/esm/web.js +813 -68
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +819 -68
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +819 -68
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCameraPreviewPlugin/CameraController.swift +1663 -0
- package/ios/Sources/CapgoCameraPreviewPlugin/GridOverlayView.swift +65 -0
- package/ios/Sources/CapgoCameraPreviewPlugin/Plugin.swift +1550 -0
- package/ios/Tests/CameraPreviewPluginTests/CameraPreviewPluginTests.swift +15 -0
- package/package.json +2 -2
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +0 -1279
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomSurfaceView.java +0 -29
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomTextureView.java +0 -39
- package/android/src/main/java/com/ahm/capacitor/camera/preview/Preview.java +0 -461
- package/android/src/main/java/com/ahm/capacitor/camera/preview/TapGestureDetector.java +0 -24
- package/ios/Plugin/CameraController.swift +0 -809
- package/ios/Plugin/Info.plist +0 -24
- package/ios/Plugin/Plugin.h +0 -10
- package/ios/Plugin/Plugin.m +0 -18
- package/ios/Plugin/Plugin.swift +0 -511
- package/ios/Plugin.xcodeproj/project.pbxproj +0 -593
- package/ios/Plugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/Plugin.xcworkspace/contents.xcworkspacedata +0 -10
- package/ios/Plugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/PluginTests/Info.plist +0 -22
- package/ios/PluginTests/PluginTests.swift +0 -83
- package/ios/Podfile +0 -13
- package/ios/Podfile.lock +0 -23
|
@@ -1,175 +1,575 @@
|
|
|
1
1
|
export type CameraPosition = "rear" | "front";
|
|
2
|
+
export type FlashMode = CameraPreviewFlashMode;
|
|
3
|
+
export type GridMode = "none" | "3x3" | "4x4";
|
|
4
|
+
export type CameraPositioning = "center" | "top" | "bottom";
|
|
5
|
+
export declare enum DeviceType {
|
|
6
|
+
ULTRA_WIDE = "ultraWide",
|
|
7
|
+
WIDE_ANGLE = "wideAngle",
|
|
8
|
+
TELEPHOTO = "telephoto",
|
|
9
|
+
TRUE_DEPTH = "trueDepth",
|
|
10
|
+
DUAL = "dual",
|
|
11
|
+
DUAL_WIDE = "dualWide",
|
|
12
|
+
TRIPLE = "triple"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Represents a single camera lens on a device. A {@link CameraDevice} can have multiple lenses.
|
|
16
|
+
*/
|
|
17
|
+
export interface CameraLens {
|
|
18
|
+
/** A human-readable name for the lens, e.g., "Ultra-Wide". */
|
|
19
|
+
label: string;
|
|
20
|
+
/** The type of the camera lens. */
|
|
21
|
+
deviceType: DeviceType;
|
|
22
|
+
/** The focal length of the lens in millimeters. */
|
|
23
|
+
focalLength: number;
|
|
24
|
+
/** The base zoom factor for this lens (e.g., 0.5 for ultra-wide, 1.0 for wide). */
|
|
25
|
+
baseZoomRatio: number;
|
|
26
|
+
/** The minimum zoom factor supported by this specific lens. */
|
|
27
|
+
minZoom: number;
|
|
28
|
+
/** The maximum zoom factor supported by this specific lens. */
|
|
29
|
+
maxZoom: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Represents a physical camera on the device (e.g., the front-facing camera).
|
|
33
|
+
*/
|
|
34
|
+
export interface CameraDevice {
|
|
35
|
+
/** A unique identifier for the camera device. */
|
|
36
|
+
deviceId: string;
|
|
37
|
+
/** A human-readable name for the camera device. */
|
|
38
|
+
label: string;
|
|
39
|
+
/** The physical position of the camera on the device. */
|
|
40
|
+
position: CameraPosition;
|
|
41
|
+
/** A list of all available lenses for this camera device. */
|
|
42
|
+
lenses: CameraLens[];
|
|
43
|
+
/** The overall minimum zoom factor available across all lenses on this device. */
|
|
44
|
+
minZoom: number;
|
|
45
|
+
/** The overall maximum zoom factor available across all lenses on this device. */
|
|
46
|
+
maxZoom: number;
|
|
47
|
+
/** Identifies whether the device is a logical camera (composed of multiple physical lenses). */
|
|
48
|
+
isLogical: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Represents the detailed information of the currently active lens.
|
|
52
|
+
*/
|
|
53
|
+
export interface LensInfo {
|
|
54
|
+
/** The focal length of the active lens in millimeters. */
|
|
55
|
+
focalLength: number;
|
|
56
|
+
/** The device type of the active lens. */
|
|
57
|
+
deviceType: DeviceType;
|
|
58
|
+
/** The base zoom ratio of the active lens (e.g., 0.5x, 1.0x). */
|
|
59
|
+
baseZoomRatio: number;
|
|
60
|
+
/** The current digital zoom factor applied on top of the base zoom. */
|
|
61
|
+
digitalZoom: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Defines the configuration options for starting the camera preview.
|
|
65
|
+
*/
|
|
2
66
|
export interface CameraPreviewOptions {
|
|
3
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* The parent element to attach the video preview to.
|
|
69
|
+
* @platform web
|
|
70
|
+
*/
|
|
4
71
|
parent?: string;
|
|
5
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* A CSS class name to add to the preview element.
|
|
74
|
+
* @platform web
|
|
75
|
+
*/
|
|
6
76
|
className?: string;
|
|
7
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* The width of the preview in pixels. Defaults to the screen width.
|
|
79
|
+
* @platform android, ios, web
|
|
80
|
+
*/
|
|
8
81
|
width?: number;
|
|
9
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* The height of the preview in pixels. Defaults to the screen height.
|
|
84
|
+
* @platform android, ios, web
|
|
85
|
+
*/
|
|
10
86
|
height?: number;
|
|
11
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* The horizontal origin of the preview, in pixels.
|
|
89
|
+
* @platform android, ios
|
|
90
|
+
*/
|
|
12
91
|
x?: number;
|
|
13
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* The vertical origin of the preview, in pixels.
|
|
94
|
+
* @platform android, ios
|
|
95
|
+
*/
|
|
14
96
|
y?: number;
|
|
15
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* The aspect ratio of the camera preview, '4:3' or '16:9' or 'fill'.
|
|
99
|
+
* Cannot be set if width or height is provided, otherwise the call will be rejected.
|
|
100
|
+
* Use setPreviewSize to adjust size after starting.
|
|
101
|
+
*
|
|
102
|
+
* @since 2.0.0
|
|
103
|
+
*/
|
|
104
|
+
aspectRatio?: "4:3" | "16:9";
|
|
105
|
+
/**
|
|
106
|
+
* The grid overlay to display on the camera preview.
|
|
107
|
+
* @default "none"
|
|
108
|
+
* @since 2.1.0
|
|
109
|
+
*/
|
|
110
|
+
gridMode?: GridMode;
|
|
111
|
+
/**
|
|
112
|
+
* Adjusts the y-position to account for safe areas (e.g., notches).
|
|
113
|
+
* @platform ios
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
16
116
|
includeSafeAreaInsets?: boolean;
|
|
17
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* If true, places the preview behind the webview.
|
|
119
|
+
* @platform android
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
18
122
|
toBack?: boolean;
|
|
19
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Bottom padding for the preview, in pixels.
|
|
125
|
+
* @platform android, ios
|
|
126
|
+
*/
|
|
20
127
|
paddingBottom?: number;
|
|
21
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* Whether to rotate the preview when the device orientation changes.
|
|
130
|
+
* @platform ios
|
|
131
|
+
* @default true
|
|
132
|
+
*/
|
|
22
133
|
rotateWhenOrientationChanged?: boolean;
|
|
23
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* The camera to use.
|
|
136
|
+
* @default "rear"
|
|
137
|
+
*/
|
|
24
138
|
position?: CameraPosition | string;
|
|
25
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* If true, saves the captured image to a file and returns the file path.
|
|
141
|
+
* If false, returns a base64 encoded string.
|
|
142
|
+
* @default false
|
|
143
|
+
*/
|
|
26
144
|
storeToFile?: boolean;
|
|
27
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* If true, prevents the plugin from rotating the image based on EXIF data.
|
|
147
|
+
* @platform android
|
|
148
|
+
* @default false
|
|
149
|
+
*/
|
|
28
150
|
disableExifHeaderStripping?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
151
|
+
/**
|
|
152
|
+
* If true, disables the audio stream, preventing audio permission requests.
|
|
153
|
+
* @default true
|
|
154
|
+
*/
|
|
32
155
|
disableAudio?: boolean;
|
|
33
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* If true, locks the device orientation while the camera is active.
|
|
158
|
+
* @platform android
|
|
159
|
+
* @default false
|
|
160
|
+
*/
|
|
34
161
|
lockAndroidOrientation?: boolean;
|
|
35
|
-
/**
|
|
162
|
+
/**
|
|
163
|
+
* If true, allows the camera preview's opacity to be changed.
|
|
164
|
+
* @platform android, web
|
|
165
|
+
* @default false
|
|
166
|
+
*/
|
|
36
167
|
enableOpacity?: boolean;
|
|
37
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* If true, enables pinch-to-zoom functionality on the preview.
|
|
170
|
+
* @platform android
|
|
171
|
+
* @default false
|
|
172
|
+
*/
|
|
38
173
|
enableZoom?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
|
|
174
|
+
/**
|
|
175
|
+
* If true, uses the video-optimized preset for the camera session.
|
|
176
|
+
* @platform ios
|
|
177
|
+
* @default false
|
|
178
|
+
*/
|
|
179
|
+
enableVideoMode?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* The `deviceId` of the camera to use. If provided, `position` is ignored.
|
|
182
|
+
* @platform ios
|
|
183
|
+
*/
|
|
184
|
+
deviceId?: string;
|
|
185
|
+
/**
|
|
186
|
+
* The initial zoom level when starting the camera preview.
|
|
187
|
+
* If the requested zoom level is not available, the native plugin will reject.
|
|
188
|
+
* @default 1.0
|
|
189
|
+
* @platform android, ios
|
|
190
|
+
* @since 2.2.0
|
|
191
|
+
*/
|
|
192
|
+
initialZoomLevel?: number;
|
|
193
|
+
/**
|
|
194
|
+
* The vertical positioning of the camera preview.
|
|
195
|
+
* @default "center"
|
|
196
|
+
* @platform android, ios, web
|
|
197
|
+
* @since 2.3.0
|
|
198
|
+
*/
|
|
199
|
+
positioning?: CameraPositioning;
|
|
41
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* Defines the options for capturing a picture.
|
|
203
|
+
*/
|
|
42
204
|
export interface CameraPreviewPictureOptions {
|
|
43
|
-
/**
|
|
205
|
+
/** @deprecated,
|
|
206
|
+
* The desired height of the picture in pixels.
|
|
207
|
+
* If not specified and no aspectRatio is provided, the captured image will match the preview's visible area.
|
|
208
|
+
*/
|
|
44
209
|
height?: number;
|
|
45
|
-
/**
|
|
210
|
+
/** @deprecated,
|
|
211
|
+
* The desired width of the picture in pixels.
|
|
212
|
+
* If not specified and no aspectRatio is provided, the captured image will match the preview's visible area.
|
|
213
|
+
*/
|
|
46
214
|
width?: number;
|
|
47
|
-
/**
|
|
215
|
+
/** @deprecated,
|
|
216
|
+
* The desired aspect ratio of the captured image (e.g., '4:3', '16:9').
|
|
217
|
+
* If not specified and no width/height is provided, the aspect ratio from the camera start will be used.
|
|
218
|
+
* If no aspect ratio was set at start, defaults to '4:3'.
|
|
219
|
+
* Cannot be used together with width or height - the capture will be rejected with an error.
|
|
220
|
+
* @since 7.7.0
|
|
221
|
+
*/
|
|
222
|
+
aspectRatio?: string;
|
|
223
|
+
/**
|
|
224
|
+
* The quality of the captured image, from 0 to 100.
|
|
225
|
+
* Does not apply to `png` format.
|
|
226
|
+
* @default 85
|
|
227
|
+
*/
|
|
48
228
|
quality?: number;
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
229
|
+
/**
|
|
230
|
+
* The format of the captured image.
|
|
231
|
+
* @default "jpeg"
|
|
232
|
+
*/
|
|
52
233
|
format?: PictureFormat;
|
|
234
|
+
/**
|
|
235
|
+
* If true, the captured image will be saved to the user's gallery.
|
|
236
|
+
* @default false
|
|
237
|
+
* @since 7.5.0
|
|
238
|
+
*/
|
|
239
|
+
saveToGallery?: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* If true, the plugin will attempt to add GPS location data to the image's EXIF metadata.
|
|
242
|
+
* This may prompt the user for location permissions.
|
|
243
|
+
* @default false
|
|
244
|
+
* @since 7.6.0
|
|
245
|
+
*/
|
|
246
|
+
withExifLocation?: boolean;
|
|
247
|
+
}
|
|
248
|
+
/** Represents EXIF data extracted from an image. */
|
|
249
|
+
export interface ExifData {
|
|
250
|
+
[key: string]: any;
|
|
53
251
|
}
|
|
54
252
|
export type PictureFormat = "jpeg" | "png";
|
|
253
|
+
/** Defines a standard picture size with width and height. */
|
|
254
|
+
export interface PictureSize {
|
|
255
|
+
/** The width of the picture in pixels. */
|
|
256
|
+
width: number;
|
|
257
|
+
/** The height of the picture in pixels. */
|
|
258
|
+
height: number;
|
|
259
|
+
}
|
|
260
|
+
/** Represents the supported picture sizes for a camera facing a certain direction. */
|
|
261
|
+
export interface SupportedPictureSizes {
|
|
262
|
+
/** The camera direction ("front" or "rear"). */
|
|
263
|
+
facing: string;
|
|
264
|
+
/** A list of supported picture sizes for this camera. */
|
|
265
|
+
supportedPictureSizes: PictureSize[];
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Defines the options for capturing a sample frame from the camera preview.
|
|
269
|
+
*/
|
|
55
270
|
export interface CameraSampleOptions {
|
|
56
|
-
/**
|
|
271
|
+
/**
|
|
272
|
+
* The quality of the captured sample, from 0 to 100.
|
|
273
|
+
* @default 85
|
|
274
|
+
*/
|
|
57
275
|
quality?: number;
|
|
58
276
|
}
|
|
59
|
-
|
|
277
|
+
/**
|
|
278
|
+
* The available flash modes for the camera.
|
|
279
|
+
* 'torch' is a continuous light mode.
|
|
280
|
+
*/
|
|
281
|
+
export type CameraPreviewFlashMode = "off" | "on" | "auto" | "torch";
|
|
282
|
+
/**
|
|
283
|
+
* Defines the options for setting the camera preview's opacity.
|
|
284
|
+
*/
|
|
60
285
|
export interface CameraOpacityOptions {
|
|
61
|
-
/**
|
|
286
|
+
/**
|
|
287
|
+
* The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque).
|
|
288
|
+
* @default 1.0
|
|
289
|
+
*/
|
|
62
290
|
opacity?: number;
|
|
63
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* The main interface for the CameraPreview plugin.
|
|
294
|
+
*/
|
|
64
295
|
export interface CameraPreviewPlugin {
|
|
65
296
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @
|
|
69
|
-
* @
|
|
297
|
+
* Starts the camera preview.
|
|
298
|
+
*
|
|
299
|
+
* @param {CameraPreviewOptions} options - The configuration for the camera preview.
|
|
300
|
+
* @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the preview dimensions.
|
|
70
301
|
* @since 0.0.1
|
|
71
302
|
*/
|
|
72
|
-
start(options: CameraPreviewOptions): Promise<
|
|
303
|
+
start(options: CameraPreviewOptions): Promise<{
|
|
304
|
+
/** The width of the preview in pixels. */
|
|
305
|
+
width: number;
|
|
306
|
+
/** The height of the preview in pixels. */
|
|
307
|
+
height: number;
|
|
308
|
+
/** The horizontal origin of the preview, in pixels. */
|
|
309
|
+
x: number;
|
|
310
|
+
/** The vertical origin of the preview, in pixels. */
|
|
311
|
+
y: number;
|
|
312
|
+
}>;
|
|
73
313
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* @
|
|
314
|
+
* Stops the camera preview.
|
|
315
|
+
*
|
|
316
|
+
* @returns {Promise<void>} A promise that resolves when the camera preview is stopped.
|
|
77
317
|
* @since 0.0.1
|
|
78
318
|
*/
|
|
79
319
|
stop(): Promise<void>;
|
|
80
320
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
84
|
-
* @
|
|
321
|
+
* Captures a picture from the camera.
|
|
322
|
+
*
|
|
323
|
+
* @param {CameraPreviewPictureOptions} options - The options for capturing the picture.
|
|
324
|
+
* @returns {Promise<{ value: string }>} A promise that resolves with the captured image data.
|
|
325
|
+
* The `value` is a base64 encoded string unless `storeToFile` is true, in which case it's a file path.
|
|
85
326
|
* @since 0.0.1
|
|
86
327
|
*/
|
|
87
328
|
capture(options: CameraPreviewPictureOptions): Promise<{
|
|
88
329
|
value: string;
|
|
330
|
+
exif: ExifData;
|
|
89
331
|
}>;
|
|
90
332
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* @
|
|
94
|
-
* @
|
|
333
|
+
* Captures a single frame from the camera preview stream.
|
|
334
|
+
*
|
|
335
|
+
* @param {CameraSampleOptions} options - The options for capturing the sample.
|
|
336
|
+
* @returns {Promise<{ value: string }>} A promise that resolves with the sample image as a base64 encoded string.
|
|
95
337
|
* @since 0.0.1
|
|
96
338
|
*/
|
|
97
339
|
captureSample(options: CameraSampleOptions): Promise<{
|
|
98
340
|
value: string;
|
|
99
341
|
}>;
|
|
100
342
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* @
|
|
343
|
+
* Gets the flash modes supported by the active camera.
|
|
344
|
+
*
|
|
345
|
+
* @returns {Promise<{ result: CameraPreviewFlashMode[] }>} A promise that resolves with an array of supported flash modes.
|
|
104
346
|
* @since 0.0.1
|
|
105
347
|
*/
|
|
106
348
|
getSupportedFlashModes(): Promise<{
|
|
107
349
|
result: CameraPreviewFlashMode[];
|
|
108
350
|
}>;
|
|
109
351
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* @
|
|
352
|
+
* Set the aspect ratio of the camera preview.
|
|
353
|
+
*
|
|
354
|
+
* @param {{ aspectRatio: '4:3' | '16:9'; x?: number; y?: number }} options - The desired aspect ratio and optional position.
|
|
355
|
+
* - aspectRatio: The desired aspect ratio ('4:3' or '16:9')
|
|
356
|
+
* - x: Optional x coordinate for positioning. If not provided, view will be auto-centered horizontally.
|
|
357
|
+
* - y: Optional y coordinate for positioning. If not provided, view will be auto-centered vertically.
|
|
358
|
+
* @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the actual preview dimensions and position.
|
|
359
|
+
* @since 7.4.0
|
|
360
|
+
*/
|
|
361
|
+
setAspectRatio(options: {
|
|
362
|
+
aspectRatio: "4:3" | "16:9";
|
|
363
|
+
x?: number;
|
|
364
|
+
y?: number;
|
|
365
|
+
}): Promise<{
|
|
366
|
+
width: number;
|
|
367
|
+
height: number;
|
|
368
|
+
x: number;
|
|
369
|
+
y: number;
|
|
370
|
+
}>;
|
|
371
|
+
/**
|
|
372
|
+
* Gets the current aspect ratio of the camera preview.
|
|
373
|
+
*
|
|
374
|
+
* @returns {Promise<{ aspectRatio: '4:3' | '16:9' }>} A promise that resolves with the current aspect ratio.
|
|
375
|
+
* @since 7.4.0
|
|
376
|
+
*/
|
|
377
|
+
getAspectRatio(): Promise<{
|
|
378
|
+
aspectRatio: "4:3" | "16:9";
|
|
379
|
+
}>;
|
|
380
|
+
/**
|
|
381
|
+
* Sets the grid mode of the camera preview overlay.
|
|
382
|
+
*
|
|
383
|
+
* @param {{ gridMode: GridMode }} options - The desired grid mode ('none', '3x3', or '4x4').
|
|
384
|
+
* @returns {Promise<void>} A promise that resolves when the grid mode is set.
|
|
385
|
+
* @since 8.0.0
|
|
386
|
+
*/
|
|
387
|
+
setGridMode(options: {
|
|
388
|
+
gridMode: GridMode;
|
|
389
|
+
}): Promise<void>;
|
|
390
|
+
/**
|
|
391
|
+
* Gets the current grid mode of the camera preview overlay.
|
|
392
|
+
*
|
|
393
|
+
* @returns {Promise<{ gridMode: GridMode }>} A promise that resolves with the current grid mode.
|
|
394
|
+
* @since 8.0.0
|
|
395
|
+
*/
|
|
396
|
+
getGridMode(): Promise<{
|
|
397
|
+
gridMode: GridMode;
|
|
398
|
+
}>;
|
|
399
|
+
/**
|
|
400
|
+
* Gets the horizontal field of view (FoV) for the active camera.
|
|
401
|
+
* Note: This can be an estimate on some devices.
|
|
402
|
+
*
|
|
403
|
+
* @returns {Promise<{ result: number }>} A promise that resolves with the horizontal field of view in degrees.
|
|
113
404
|
* @since 0.0.1
|
|
114
405
|
*/
|
|
115
406
|
getHorizontalFov(): Promise<{
|
|
116
|
-
result:
|
|
407
|
+
result: number;
|
|
117
408
|
}>;
|
|
118
409
|
/**
|
|
119
|
-
* Gets the supported picture sizes for
|
|
120
|
-
*
|
|
121
|
-
* @
|
|
410
|
+
* Gets the supported picture sizes for all cameras.
|
|
411
|
+
*
|
|
412
|
+
* @returns {Promise<{ supportedPictureSizes: SupportedPictureSizes[] }>} A promise that resolves with the list of supported sizes.
|
|
413
|
+
* @since 7.4.0
|
|
122
414
|
*/
|
|
123
415
|
getSupportedPictureSizes(): Promise<{
|
|
124
|
-
supportedPictureSizes:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}>;
|
|
132
|
-
/**
|
|
133
|
-
* Set flash mode.
|
|
134
|
-
* @param options the options to set the flash mode with
|
|
135
|
-
* @returns {Promise<void>} an Promise that resolves when the flash mode is set
|
|
136
|
-
* @throws An error if the something went wrong
|
|
416
|
+
supportedPictureSizes: SupportedPictureSizes[];
|
|
417
|
+
}>;
|
|
418
|
+
/**
|
|
419
|
+
* Sets the flash mode for the active camera.
|
|
420
|
+
*
|
|
421
|
+
* @param {{ flashMode: CameraPreviewFlashMode | string }} options - The desired flash mode.
|
|
422
|
+
* @returns {Promise<void>} A promise that resolves when the flash mode is set.
|
|
137
423
|
* @since 0.0.1
|
|
138
424
|
*/
|
|
139
425
|
setFlashMode(options: {
|
|
140
426
|
flashMode: CameraPreviewFlashMode | string;
|
|
141
427
|
}): Promise<void>;
|
|
142
428
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* @
|
|
429
|
+
* Toggles between the front and rear cameras.
|
|
430
|
+
*
|
|
431
|
+
* @returns {Promise<void>} A promise that resolves when the camera is flipped.
|
|
146
432
|
* @since 0.0.1
|
|
147
433
|
*/
|
|
148
434
|
flip(): Promise<void>;
|
|
149
435
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* @
|
|
153
|
-
* @
|
|
436
|
+
* Sets the opacity of the camera preview.
|
|
437
|
+
*
|
|
438
|
+
* @param {CameraOpacityOptions} options - The opacity options.
|
|
439
|
+
* @returns {Promise<void>} A promise that resolves when the opacity is set.
|
|
154
440
|
* @since 0.0.1
|
|
155
441
|
*/
|
|
156
442
|
setOpacity(options: CameraOpacityOptions): Promise<void>;
|
|
157
443
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* @returns {Promise<{videoFilePath: string}>}
|
|
161
|
-
* @throws An error if the something went wrong
|
|
444
|
+
* Stops an ongoing video recording.
|
|
445
|
+
*
|
|
446
|
+
* @returns {Promise<{ videoFilePath: string }>} A promise that resolves with the path to the recorded video file.
|
|
162
447
|
* @since 0.0.1
|
|
163
448
|
*/
|
|
164
449
|
stopRecordVideo(): Promise<{
|
|
165
450
|
videoFilePath: string;
|
|
166
451
|
}>;
|
|
167
452
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* @
|
|
171
|
-
* @
|
|
453
|
+
* Starts recording a video.
|
|
454
|
+
*
|
|
455
|
+
* @param {CameraPreviewOptions} options - The options for video recording.
|
|
456
|
+
* @returns {Promise<void>} A promise that resolves when video recording starts.
|
|
172
457
|
* @since 0.0.1
|
|
173
458
|
*/
|
|
174
459
|
startRecordVideo(options: CameraPreviewOptions): Promise<void>;
|
|
460
|
+
/**
|
|
461
|
+
* Checks if the camera preview is currently running.
|
|
462
|
+
*
|
|
463
|
+
* @returns {Promise<{ isRunning: boolean }>} A promise that resolves with the running state.
|
|
464
|
+
* @since 7.4.0
|
|
465
|
+
*/
|
|
466
|
+
isRunning(): Promise<{
|
|
467
|
+
isRunning: boolean;
|
|
468
|
+
}>;
|
|
469
|
+
/**
|
|
470
|
+
* Gets all available camera devices.
|
|
471
|
+
*
|
|
472
|
+
* @returns {Promise<{ devices: CameraDevice[] }>} A promise that resolves with the list of available camera devices.
|
|
473
|
+
* @since 7.4.0
|
|
474
|
+
*/
|
|
475
|
+
getAvailableDevices(): Promise<{
|
|
476
|
+
devices: CameraDevice[];
|
|
477
|
+
}>;
|
|
478
|
+
/**
|
|
479
|
+
* Gets the current zoom state, including min/max and current lens info.
|
|
480
|
+
*
|
|
481
|
+
* @returns {Promise<{ min: number; max: number; current: number; lens: LensInfo }>} A promise that resolves with the zoom state.
|
|
482
|
+
* @since 7.4.0
|
|
483
|
+
*/
|
|
484
|
+
getZoom(): Promise<{
|
|
485
|
+
min: number;
|
|
486
|
+
max: number;
|
|
487
|
+
current: number;
|
|
488
|
+
lens: LensInfo;
|
|
489
|
+
}>;
|
|
490
|
+
/**
|
|
491
|
+
* Sets the zoom level of the camera.
|
|
492
|
+
*
|
|
493
|
+
* @param {{ level: number; ramp?: boolean; autoFocus?: boolean }} options - The desired zoom level. `ramp` is currently unused. `autoFocus` defaults to true.
|
|
494
|
+
* @returns {Promise<void>} A promise that resolves when the zoom level is set.
|
|
495
|
+
* @since 7.4.0
|
|
496
|
+
*/
|
|
497
|
+
setZoom(options: {
|
|
498
|
+
level: number;
|
|
499
|
+
ramp?: boolean;
|
|
500
|
+
autoFocus?: boolean;
|
|
501
|
+
}): Promise<void>;
|
|
502
|
+
/**
|
|
503
|
+
* Gets the current flash mode.
|
|
504
|
+
*
|
|
505
|
+
* @returns {Promise<{ flashMode: FlashMode }>} A promise that resolves with the current flash mode.
|
|
506
|
+
* @since 7.4.0
|
|
507
|
+
*/
|
|
508
|
+
getFlashMode(): Promise<{
|
|
509
|
+
flashMode: FlashMode;
|
|
510
|
+
}>;
|
|
511
|
+
/**
|
|
512
|
+
* Removes all registered listeners.
|
|
513
|
+
*
|
|
514
|
+
* @since 7.4.0
|
|
515
|
+
*/
|
|
516
|
+
removeAllListeners(): Promise<void>;
|
|
517
|
+
/**
|
|
518
|
+
* Switches the active camera to the one with the specified `deviceId`.
|
|
519
|
+
*
|
|
520
|
+
* @param {{ deviceId: string }} options - The ID of the device to switch to.
|
|
521
|
+
* @returns {Promise<void>} A promise that resolves when the camera is switched.
|
|
522
|
+
* @since 7.4.0
|
|
523
|
+
*/
|
|
524
|
+
setDeviceId(options: {
|
|
525
|
+
deviceId: string;
|
|
526
|
+
}): Promise<void>;
|
|
527
|
+
/**
|
|
528
|
+
* Gets the ID of the currently active camera device.
|
|
529
|
+
*
|
|
530
|
+
* @returns {Promise<{ deviceId: string }>} A promise that resolves with the current device ID.
|
|
531
|
+
* @since 7.4.0
|
|
532
|
+
*/
|
|
533
|
+
getDeviceId(): Promise<{
|
|
534
|
+
deviceId: string;
|
|
535
|
+
}>;
|
|
536
|
+
/**
|
|
537
|
+
* Gets the current preview size and position.
|
|
538
|
+
* @returns {Promise<{x: number, y: number, width: number, height: number}>}
|
|
539
|
+
*/
|
|
540
|
+
getPreviewSize(): Promise<{
|
|
541
|
+
x: number;
|
|
542
|
+
y: number;
|
|
543
|
+
width: number;
|
|
544
|
+
height: number;
|
|
545
|
+
}>;
|
|
546
|
+
/**
|
|
547
|
+
* Sets the preview size and position.
|
|
548
|
+
* @param options The new position and dimensions.
|
|
549
|
+
* @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the actual preview dimensions and position.
|
|
550
|
+
*/
|
|
551
|
+
setPreviewSize(options: {
|
|
552
|
+
x?: number;
|
|
553
|
+
y?: number;
|
|
554
|
+
width: number;
|
|
555
|
+
height: number;
|
|
556
|
+
}): Promise<{
|
|
557
|
+
width: number;
|
|
558
|
+
height: number;
|
|
559
|
+
x: number;
|
|
560
|
+
y: number;
|
|
561
|
+
}>;
|
|
562
|
+
/**
|
|
563
|
+
* Sets the camera focus to a specific point in the preview.
|
|
564
|
+
*
|
|
565
|
+
* @param {Object} options - The focus options.
|
|
566
|
+
* @param {number} options.x - The x coordinate in the preview view to focus on (0-1 normalized).
|
|
567
|
+
* @param {number} options.y - The y coordinate in the preview view to focus on (0-1 normalized).
|
|
568
|
+
* @returns {Promise<void>} A promise that resolves when the focus is set.
|
|
569
|
+
* @since 8.1.0
|
|
570
|
+
*/
|
|
571
|
+
setFocus(options: {
|
|
572
|
+
x: number;
|
|
573
|
+
y: number;
|
|
574
|
+
}): Promise<void>;
|
|
175
575
|
}
|
package/dist/esm/definitions.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var DeviceType;
|
|
2
|
+
(function (DeviceType) {
|
|
3
|
+
DeviceType["ULTRA_WIDE"] = "ultraWide";
|
|
4
|
+
DeviceType["WIDE_ANGLE"] = "wideAngle";
|
|
5
|
+
DeviceType["TELEPHOTO"] = "telephoto";
|
|
6
|
+
DeviceType["TRUE_DEPTH"] = "trueDepth";
|
|
7
|
+
DeviceType["DUAL"] = "dual";
|
|
8
|
+
DeviceType["DUAL_WIDE"] = "dualWide";
|
|
9
|
+
DeviceType["TRIPLE"] = "triple";
|
|
10
|
+
})(DeviceType || (DeviceType = {}));
|
|
2
11
|
//# sourceMappingURL=definitions.js.map
|