@capgo/camera-preview 7.4.0-beta.5 → 7.4.0-beta.7

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.
Files changed (39) hide show
  1. package/README.md +40 -6
  2. package/android/.gradle/8.14.2/checksums/checksums.lock +0 -0
  3. package/android/.gradle/8.14.2/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/8.14.2/checksums/sha1-checksums.bin +0 -0
  5. package/android/.gradle/8.14.2/executionHistory/executionHistory.lock +0 -0
  6. package/android/.gradle/8.14.2/fileHashes/fileHashes.bin +0 -0
  7. package/android/.gradle/8.14.2/fileHashes/fileHashes.lock +0 -0
  8. package/android/.gradle/8.14.2/fileHashes/resourceHashesCache.bin +0 -0
  9. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  10. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  11. package/android/.gradle/config.properties +2 -0
  12. package/android/.idea/AndroidProjectSystem.xml +6 -0
  13. package/android/.idea/caches/deviceStreaming.xml +811 -0
  14. package/android/.idea/compiler.xml +6 -0
  15. package/android/.idea/gradle.xml +18 -0
  16. package/android/.idea/migrations.xml +10 -0
  17. package/android/.idea/misc.xml +10 -0
  18. package/android/.idea/runConfigurations.xml +17 -0
  19. package/android/.idea/vcs.xml +6 -0
  20. package/android/.idea/workspace.xml +55 -0
  21. package/android/local.properties +8 -0
  22. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +45 -18
  23. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +54 -9
  24. package/dist/docs.json +56 -4
  25. package/dist/esm/definitions.d.ts +23 -4
  26. package/dist/esm/definitions.js.map +1 -1
  27. package/dist/esm/web.d.ts +9 -3
  28. package/dist/esm/web.js +13 -7
  29. package/dist/esm/web.js.map +1 -1
  30. package/dist/plugin.cjs.js +13 -7
  31. package/dist/plugin.cjs.js.map +1 -1
  32. package/dist/plugin.js +13 -7
  33. package/dist/plugin.js.map +1 -1
  34. package/ios/Sources/CapgoCameraPreview/CameraController.swift +35 -13
  35. package/ios/Sources/CapgoCameraPreview/Plugin.swift +101 -26
  36. package/package.json +1 -1
  37. package/android/.gradle/8.14.2/executionHistory/executionHistory.bin +0 -0
  38. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  39. package/android/.gradle/file-system.probe +0 -0
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="CompilerConfiguration">
4
+ <bytecodeTargetLevel target="21" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GradleSettings">
4
+ <option name="linkedExternalProjectsSettings">
5
+ <GradleProjectSettings>
6
+ <option name="testRunner" value="CHOOSE_PER_TEST" />
7
+ <option name="externalProjectPath" value="$PROJECT_DIR$" />
8
+ <option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
9
+ <option name="modules">
10
+ <set>
11
+ <option value="$PROJECT_DIR$" />
12
+ <option value="$PROJECT_DIR$/../node_modules/@capacitor/android/capacitor" />
13
+ </set>
14
+ </option>
15
+ </GradleProjectSettings>
16
+ </option>
17
+ </component>
18
+ </project>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectMigrations">
4
+ <option name="MigrateToGradleLocalJavaHome">
5
+ <set>
6
+ <option value="$PROJECT_DIR$" />
7
+ </set>
8
+ </option>
9
+ </component>
10
+ </project>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ExternalStorageConfigurationManager" enabled="true" />
4
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
5
+ <output url="file://$PROJECT_DIR$/build/classes" />
6
+ </component>
7
+ <component name="ProjectType">
8
+ <option name="id" value="Android" />
9
+ </component>
10
+ </project>
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="RunConfigurationProducerService">
4
+ <option name="ignoredProducers">
5
+ <set>
6
+ <option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
7
+ <option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
8
+ <option value="com.intellij.execution.junit.PatternConfigurationProducer" />
9
+ <option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
10
+ <option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
11
+ <option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
12
+ <option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
13
+ <option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
14
+ </set>
15
+ </option>
16
+ </component>
17
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,55 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="NONE" />
5
+ </component>
6
+ <component name="ChangeListManager">
7
+ <list default="true" id="efc1e8b5-2740-4c0f-b831-4f6f2b0bdaeb" name="Changes" comment="" />
8
+ <option name="SHOW_DIALOG" value="false" />
9
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
11
+ <option name="LAST_RESOLUTION" value="IGNORE" />
12
+ </component>
13
+ <component name="ClangdSettings">
14
+ <option name="formatViaClangd" value="false" />
15
+ </component>
16
+ <component name="ExternalProjectsData">
17
+ <projectState path="$PROJECT_DIR$">
18
+ <ProjectState />
19
+ </projectState>
20
+ </component>
21
+ <component name="Git.Settings">
22
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
23
+ </component>
24
+ <component name="ProjectColorInfo"><![CDATA[{
25
+ "associatedIndex": 1
26
+ }]]></component>
27
+ <component name="ProjectId" id="2zHB1qt0m9CGa9U3RkvrpAi2v5T" />
28
+ <component name="ProjectViewState">
29
+ <option name="hideEmptyMiddlePackages" value="true" />
30
+ <option name="showLibraryContents" value="true" />
31
+ </component>
32
+ <component name="PropertiesComponent"><![CDATA[{
33
+ "keyToString": {
34
+ "RunOnceActivity.ShowReadmeOnStart": "true",
35
+ "RunOnceActivity.cidr.known.project.marker": "true",
36
+ "RunOnceActivity.git.unshallow": "true",
37
+ "RunOnceActivity.readMode.enableVisualFormatting": "true",
38
+ "cf.first.check.clang-format": "false",
39
+ "cidr.known.project.marker": "true",
40
+ "git-widget-placeholder": "v2",
41
+ "kotlin-language-version-configured": "true"
42
+ }
43
+ }]]></component>
44
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
45
+ <component name="TaskManager">
46
+ <task active="true" id="Default" summary="Default task">
47
+ <changelist id="efc1e8b5-2740-4c0f-b831-4f6f2b0bdaeb" name="Changes" comment="" />
48
+ <created>1751377906492</created>
49
+ <option name="number" value="Default" />
50
+ <option name="presentableId" value="Default" />
51
+ <updated>1751377906492</updated>
52
+ </task>
53
+ <servers />
54
+ </component>
55
+ </project>
@@ -0,0 +1,8 @@
1
+ ## This file must *NOT* be checked into Version Control Systems,
2
+ # as it contains information specific to your local configuration.
3
+ #
4
+ # Location of the SDK. This is only used by Gradle.
5
+ # For customization when using a Version Control System, please read the
6
+ # header note.
7
+ #Tue Jul 01 15:51:45 CEST 2025
8
+ sdk.dir=/Users/jordanlorho/Library/Android/sdk
@@ -30,13 +30,6 @@ import org.json.JSONObject;
30
30
  import android.location.Location;
31
31
  import com.getcapacitor.Logger;
32
32
 
33
- interface CameraPreviewListener {
34
- void onPictureTaken(String base64, JSONObject exif);
35
- void onPictureTakenError(String message);
36
- void onCameraStarted(int width, int height, int x, int y);
37
- void onCameraStopped();
38
- void onCaptureStarted();
39
- }
40
33
 
41
34
  @CapacitorPlugin(
42
35
  name = "CameraPreview",
@@ -57,7 +50,7 @@ interface CameraPreviewListener {
57
50
  )
58
51
  public class CameraPreview
59
52
  extends Plugin
60
- implements CameraPreviewListener {
53
+ implements CameraXView.CameraXViewListener {
61
54
 
62
55
  static final String CAMERA_WITH_AUDIO_PERMISSION_ALIAS = "cameraWithAudio";
63
56
  static final String CAMERA_ONLY_PERMISSION_ALIAS = "cameraOnly";
@@ -397,7 +390,7 @@ public class CameraPreview
397
390
  final boolean disableExifHeaderStripping = Boolean.TRUE.equals(call.getBoolean("disableExifHeaderStripping", false));
398
391
  final boolean lockOrientation = Boolean.TRUE.equals(call.getBoolean("lockAndroidOrientation", false));
399
392
  final boolean disableAudio = Boolean.TRUE.equals(call.getBoolean("disableAudio", true));
400
- final String aspectRatio = call.getString("aspectRatio", "fill");
393
+ final String aspectRatio = call.getString("aspectRatio", "4:3");
401
394
  final String gridMode = call.getString("gridMode", "none");
402
395
 
403
396
  float targetZoom = 1.0f;
@@ -422,7 +415,7 @@ public class CameraPreview
422
415
 
423
416
  previousOrientationRequest = getBridge().getActivity().getRequestedOrientation();
424
417
  cameraXView = new CameraXView(getContext(), getBridge().getWebView());
425
- cameraXView.setListener((CameraXView.CameraXViewListener) this);
418
+ cameraXView.setListener(this);
426
419
 
427
420
  String finalDeviceId = deviceId;
428
421
  float finalTargetZoom = targetZoom;
@@ -472,11 +465,6 @@ public class CameraPreview
472
465
  bridge.releaseCall(pluginCall);
473
466
  }
474
467
 
475
- @Override
476
- public void onCaptureStarted() {
477
- Log.i("CameraPreview", "Capture started");
478
- }
479
-
480
468
  @Override
481
469
  public void onCameraStarted(int width, int height, int x, int y) {
482
470
  PluginCall call = bridge.getSavedCall(cameraStartCallbackId);
@@ -493,8 +481,25 @@ public class CameraPreview
493
481
  }
494
482
 
495
483
  @Override
496
- public void onCameraStopped() {
497
- // This method is no longer needed as onCameraStarted handles the promise resolution.
484
+ public void onSampleTaken(String result) {
485
+ // Handle sample taken if needed
486
+ Log.i("CameraPreview", "Sample taken: " + result);
487
+ }
488
+
489
+ @Override
490
+ public void onSampleTakenError(String message) {
491
+ // Handle sample taken error if needed
492
+ Log.e("CameraPreview", "Sample taken error: " + message);
493
+ }
494
+
495
+ @Override
496
+ public void onCameraStartError(String message) {
497
+ PluginCall call = bridge.getSavedCall(cameraStartCallbackId);
498
+ if (call != null) {
499
+ call.reject(message);
500
+ bridge.releaseCall(call);
501
+ cameraStartCallbackId = null;
502
+ }
498
503
  }
499
504
 
500
505
  @PluginMethod
@@ -503,7 +508,7 @@ public class CameraPreview
503
508
  call.reject("Camera is not running");
504
509
  return;
505
510
  }
506
- String aspectRatio = call.getString("aspectRatio", "fill");
511
+ String aspectRatio = call.getString("aspectRatio", "4:3");
507
512
  cameraXView.setAspectRatio(aspectRatio);
508
513
  call.resolve();
509
514
  }
@@ -519,4 +524,26 @@ public class CameraPreview
519
524
  ret.put("aspectRatio", aspectRatio);
520
525
  call.resolve(ret);
521
526
  }
527
+
528
+ @PluginMethod
529
+ public void setGridMode(PluginCall call) {
530
+ if (cameraXView == null || !cameraXView.isRunning()) {
531
+ call.reject("Camera is not running");
532
+ return;
533
+ }
534
+ String gridMode = call.getString("gridMode", "none");
535
+ cameraXView.setGridMode(gridMode);
536
+ call.resolve();
537
+ }
538
+
539
+ @PluginMethod
540
+ public void getGridMode(PluginCall call) {
541
+ if (cameraXView == null || !cameraXView.isRunning()) {
542
+ call.reject("Camera is not running");
543
+ return;
544
+ }
545
+ JSObject ret = new JSObject();
546
+ ret.put("gridMode", cameraXView.getGridMode());
547
+ call.resolve(ret);
548
+ }
522
549
  }
@@ -77,7 +77,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
77
77
  void onPictureTakenError(String message);
78
78
  void onSampleTaken(String result);
79
79
  void onSampleTakenError(String message);
80
- void onCameraStarted();
80
+ void onCameraStarted(int width, int height, int x, int y);
81
81
  void onCameraStartError(String message);
82
82
  }
83
83
 
@@ -194,7 +194,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
194
194
 
195
195
  // Create and setup the preview view
196
196
  previewView = new PreviewView(context);
197
- previewView.setScaleType(PreviewView.ScaleType.FILL_CENTER);
197
+ previewView.setScaleType(PreviewView.ScaleType.FIT_CENTER);
198
198
  previewContainer.addView(previewView, new FrameLayout.LayoutParams(
199
199
  FrameLayout.LayoutParams.MATCH_PARENT,
200
200
  FrameLayout.LayoutParams.MATCH_PARENT
@@ -305,7 +305,12 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
305
305
 
306
306
  isRunning = true;
307
307
  Log.d(TAG, "bindCameraUseCases: Camera bound successfully");
308
- if (listener != null) listener.onCameraStarted();
308
+ if (listener != null) listener.onCameraStarted(
309
+ sessionConfig.getWidth(),
310
+ sessionConfig.getHeight(),
311
+ sessionConfig.getX(),
312
+ sessionConfig.getY()
313
+ );
309
314
  } catch (Exception e) {
310
315
  if (listener != null) listener.onCameraStartError("Error binding camera: " + e.getMessage());
311
316
  }
@@ -398,7 +403,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
398
403
  java.io.FileInputStream fis = new java.io.FileInputStream(tempFile);
399
404
  fis.read(bytes);
400
405
  fis.close();
401
-
406
+
402
407
  ExifInterface exifInterface = new ExifInterface(tempFile.getAbsolutePath());
403
408
 
404
409
  if (location != null) {
@@ -1051,7 +1056,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
1051
1056
  layoutParams.leftMargin = sessionConfig.getX();
1052
1057
  layoutParams.topMargin = sessionConfig.getY();
1053
1058
 
1054
- if (sessionConfig.getAspectRatio() != null && !sessionConfig.getAspectRatio().equals("fill")) {
1059
+ if (sessionConfig.getAspectRatio() != null) {
1055
1060
  String[] ratios = sessionConfig.getAspectRatio().split(":");
1056
1061
  float ratio = Float.parseFloat(ratios[0]) / Float.parseFloat(ratios[1]);
1057
1062
  if (sessionConfig.getWidth() > 0) {
@@ -1059,14 +1064,17 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
1059
1064
  } else if (sessionConfig.getHeight() > 0) {
1060
1065
  layoutParams.width = (int) (sessionConfig.getHeight() * ratio);
1061
1066
  }
1062
- } else {
1063
- previewView.setScaleType(PreviewView.ScaleType.FILL_CENTER);
1064
1067
  }
1065
1068
 
1066
1069
  previewView.setLayoutParams(layoutParams);
1067
1070
 
1068
1071
  if (listener != null) {
1069
- listener.onCameraStarted();
1072
+ listener.onCameraStarted(
1073
+ sessionConfig.getWidth(),
1074
+ sessionConfig.getHeight(),
1075
+ sessionConfig.getX(),
1076
+ sessionConfig.getY()
1077
+ );
1070
1078
  }
1071
1079
  }
1072
1080
 
@@ -1074,7 +1082,14 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
1074
1082
  if (sessionConfig != null) {
1075
1083
  return sessionConfig.getAspectRatio();
1076
1084
  }
1077
- return "fill";
1085
+ return "4:3";
1086
+ }
1087
+
1088
+ public String getGridMode() {
1089
+ if (sessionConfig != null) {
1090
+ return sessionConfig.getGridMode();
1091
+ }
1092
+ return "none";
1078
1093
  }
1079
1094
 
1080
1095
  public void setAspectRatio(String aspectRatio) {
@@ -1100,4 +1115,34 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
1100
1115
  updateLayoutParams();
1101
1116
  }
1102
1117
  }
1118
+
1119
+ public void setGridMode(String gridMode) {
1120
+ if (sessionConfig != null) {
1121
+ sessionConfig = new CameraSessionConfiguration(
1122
+ sessionConfig.getDeviceId(),
1123
+ sessionConfig.getPosition(),
1124
+ sessionConfig.getX(),
1125
+ sessionConfig.getY(),
1126
+ sessionConfig.getWidth(),
1127
+ sessionConfig.getHeight(),
1128
+ sessionConfig.getPaddingBottom(),
1129
+ sessionConfig.getToBack(),
1130
+ sessionConfig.getStoreToFile(),
1131
+ sessionConfig.getEnableOpacity(),
1132
+ sessionConfig.getEnableZoom(),
1133
+ sessionConfig.getDisableExifHeaderStripping(),
1134
+ sessionConfig.getDisableAudio(),
1135
+ sessionConfig.getZoomFactor(),
1136
+ sessionConfig.getAspectRatio(),
1137
+ gridMode
1138
+ );
1139
+
1140
+ // Update the grid overlay immediately
1141
+ if (gridOverlayView != null) {
1142
+ gridOverlayView.post(() -> {
1143
+ gridOverlayView.setGridMode(gridMode);
1144
+ });
1145
+ }
1146
+ }
1147
+ }
1103
1148
  }
package/dist/docs.json CHANGED
@@ -141,12 +141,12 @@
141
141
  },
142
142
  {
143
143
  "name": "setAspectRatio",
144
- "signature": "(options: { aspectRatio: '4:3' | '16:9' | 'fill'; }) => Promise<void>",
144
+ "signature": "(options: { aspectRatio: '4:3' | '16:9'; }) => Promise<void>",
145
145
  "parameters": [
146
146
  {
147
147
  "name": "options",
148
148
  "docs": "- The desired aspect ratio.",
149
- "type": "{ aspectRatio: '4:3' | '16:9' | 'fill'; }"
149
+ "type": "{ aspectRatio: '4:3' | '16:9'; }"
150
150
  }
151
151
  ],
152
152
  "returns": "Promise<void>",
@@ -170,9 +170,9 @@
170
170
  },
171
171
  {
172
172
  "name": "getAspectRatio",
173
- "signature": "() => Promise<{ aspectRatio: '4:3' | '16:9' | 'fill'; }>",
173
+ "signature": "() => Promise<{ aspectRatio: '4:3' | '16:9'; }>",
174
174
  "parameters": [],
175
- "returns": "Promise<{ aspectRatio: '4:3' | '16:9' | 'fill'; }>",
175
+ "returns": "Promise<{ aspectRatio: '4:3' | '16:9'; }>",
176
176
  "tags": [
177
177
  {
178
178
  "name": "returns",
@@ -187,6 +187,58 @@
187
187
  "complexTypes": [],
188
188
  "slug": "getaspectratio"
189
189
  },
190
+ {
191
+ "name": "setGridMode",
192
+ "signature": "(options: { gridMode: GridMode; }) => Promise<void>",
193
+ "parameters": [
194
+ {
195
+ "name": "options",
196
+ "docs": "- The desired grid mode ('none', '3x3', or '4x4').",
197
+ "type": "{ gridMode: GridMode; }"
198
+ }
199
+ ],
200
+ "returns": "Promise<void>",
201
+ "tags": [
202
+ {
203
+ "name": "param",
204
+ "text": "options - The desired grid mode ('none', '3x3', or '4x4')."
205
+ },
206
+ {
207
+ "name": "returns",
208
+ "text": "A promise that resolves when the grid mode is set."
209
+ },
210
+ {
211
+ "name": "since",
212
+ "text": "8.0.0"
213
+ }
214
+ ],
215
+ "docs": "Sets the grid mode of the camera preview overlay.",
216
+ "complexTypes": [
217
+ "GridMode"
218
+ ],
219
+ "slug": "setgridmode"
220
+ },
221
+ {
222
+ "name": "getGridMode",
223
+ "signature": "() => Promise<{ gridMode: GridMode; }>",
224
+ "parameters": [],
225
+ "returns": "Promise<{ gridMode: GridMode; }>",
226
+ "tags": [
227
+ {
228
+ "name": "returns",
229
+ "text": "A promise that resolves with the current grid mode."
230
+ },
231
+ {
232
+ "name": "since",
233
+ "text": "8.0.0"
234
+ }
235
+ ],
236
+ "docs": "Gets the current grid mode of the camera preview overlay.",
237
+ "complexTypes": [
238
+ "GridMode"
239
+ ],
240
+ "slug": "getgridmode"
241
+ },
190
242
  {
191
243
  "name": "getHorizontalFov",
192
244
  "signature": "() => Promise<{ result: number; }>",
@@ -326,21 +326,40 @@ export interface CameraPreviewPlugin {
326
326
  /**
327
327
  * Set the aspect ratio of the camera preview.
328
328
  *
329
- * @param {{ aspectRatio: '4:3' | '16:9' | 'fill' }} options - The desired aspect ratio.
329
+ * @param {{ aspectRatio: '4:3' | '16:9' }} options - The desired aspect ratio.
330
330
  * @returns {Promise<void>} A promise that resolves when the aspect ratio is set.
331
331
  * @since 7.4.0
332
332
  */
333
333
  setAspectRatio(options: {
334
- aspectRatio: '4:3' | '16:9' | 'fill';
334
+ aspectRatio: '4:3' | '16:9';
335
335
  }): Promise<void>;
336
336
  /**
337
337
  * Gets the current aspect ratio of the camera preview.
338
338
  *
339
- * @returns {Promise<{ aspectRatio: '4:3' | '16:9' | 'fill' }>} A promise that resolves with the current aspect ratio.
339
+ * @returns {Promise<{ aspectRatio: '4:3' | '16:9' }>} A promise that resolves with the current aspect ratio.
340
340
  * @since 7.4.0
341
341
  */
342
342
  getAspectRatio(): Promise<{
343
- aspectRatio: '4:3' | '16:9' | 'fill';
343
+ aspectRatio: '4:3' | '16:9';
344
+ }>;
345
+ /**
346
+ * Sets the grid mode of the camera preview overlay.
347
+ *
348
+ * @param {{ gridMode: GridMode }} options - The desired grid mode ('none', '3x3', or '4x4').
349
+ * @returns {Promise<void>} A promise that resolves when the grid mode is set.
350
+ * @since 8.0.0
351
+ */
352
+ setGridMode(options: {
353
+ gridMode: GridMode;
354
+ }): Promise<void>;
355
+ /**
356
+ * Gets the current grid mode of the camera preview overlay.
357
+ *
358
+ * @returns {Promise<{ gridMode: GridMode }>} A promise that resolves with the current grid mode.
359
+ * @since 8.0.0
360
+ */
361
+ getGridMode(): Promise<{
362
+ gridMode: GridMode;
344
363
  }>;
345
364
  /**
346
365
  * Gets the horizontal field of view (FoV) for the active camera.
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,sCAAwB,CAAA;IACxB,sCAAwB,CAAA;IACxB,qCAAuB,CAAA;IACvB,sCAAwB,CAAA;IACxB,2BAAa,CAAA;IACb,oCAAsB,CAAA;IACtB,+BAAiB,CAAA;AACnB,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB","sourcesContent":["export type CameraPosition = \"rear\" | \"front\";\n\nexport type FlashMode = CameraPreviewFlashMode;\n\nexport type GridMode = \"none\" | \"3x3\" | \"4x4\";\n\nexport enum DeviceType {\n ULTRA_WIDE = \"ultraWide\",\n WIDE_ANGLE = \"wideAngle\",\n TELEPHOTO = \"telephoto\",\n TRUE_DEPTH = \"trueDepth\",\n DUAL = \"dual\",\n DUAL_WIDE = \"dualWide\",\n TRIPLE = \"triple\",\n}\n\n/**\n * Represents a single camera lens on a device. A {@link CameraDevice} can have multiple lenses.\n */\nexport interface CameraLens {\n /** A human-readable name for the lens, e.g., \"Ultra-Wide\". */\n label: string;\n /** The type of the camera lens. */\n deviceType: DeviceType;\n /** The focal length of the lens in millimeters. */\n focalLength: number;\n /** The base zoom factor for this lens (e.g., 0.5 for ultra-wide, 1.0 for wide). */\n baseZoomRatio: number;\n /** The minimum zoom factor supported by this specific lens. */\n minZoom: number;\n /** The maximum zoom factor supported by this specific lens. */\n maxZoom: number;\n}\n\n/**\n * Represents a physical camera on the device (e.g., the front-facing camera).\n */\nexport interface CameraDevice {\n /** A unique identifier for the camera device. */\n deviceId: string;\n /** A human-readable name for the camera device. */\n label: string;\n /** The physical position of the camera on the device. */\n position: CameraPosition;\n /** A list of all available lenses for this camera device. */\n lenses: CameraLens[];\n /** The overall minimum zoom factor available across all lenses on this device. */\n minZoom: number;\n /** The overall maximum zoom factor available across all lenses on this device. */\n maxZoom: number;\n /** Identifies whether the device is a logical camera (composed of multiple physical lenses). */\n isLogical: boolean;\n}\n\n/**\n * Represents the detailed information of the currently active lens.\n */\nexport interface LensInfo {\n /** The focal length of the active lens in millimeters. */\n focalLength: number;\n /** The device type of the active lens. */\n deviceType: DeviceType;\n /** The base zoom ratio of the active lens (e.g., 0.5x, 1.0x). */\n baseZoomRatio: number;\n /** The current digital zoom factor applied on top of the base zoom. */\n digitalZoom: number;\n}\n\n/**\n * Defines the configuration options for starting the camera preview.\n */\nexport interface CameraPreviewOptions {\n /**\n * The parent element to attach the video preview to.\n * @platform web\n */\n parent?: string;\n /**\n * A CSS class name to add to the preview element.\n * @platform web\n */\n className?: string;\n /**\n * The width of the preview in pixels. Defaults to the screen width.\n * @platform android, ios, web\n */\n width?: number;\n /**\n * The height of the preview in pixels. Defaults to the screen height.\n * @platform android, ios, web\n */\n height?: number;\n /**\n * The horizontal origin of the preview, in pixels.\n * @platform android, ios\n */\n x?: number;\n /**\n * The vertical origin of the preview, in pixels.\n * @platform android, ios\n */\n y?: number;\n /**\n * The aspect ratio of the camera preview, '4:3' or '16:9'.\n * If not set, the camera will use the default aspect ratio.\n *\n * @since 2.0.0\n */\n aspectRatio?: '4:3' | '16:9' | 'fill';\n /**\n * The grid overlay to display on the camera preview.\n * @default \"none\"\n * @since 2.1.0\n */\n gridMode?: GridMode;\n /**\n * Adjusts the y-position to account for safe areas (e.g., notches).\n * @platform ios\n * @default false\n */\n includeSafeAreaInsets?: boolean;\n /**\n * If true, places the preview behind the webview.\n * @platform android\n * @default true\n */\n toBack?: boolean;\n /**\n * Bottom padding for the preview, in pixels.\n * @platform android, ios\n */\n paddingBottom?: number;\n /**\n * Whether to rotate the preview when the device orientation changes.\n * @platform ios\n * @default true\n */\n rotateWhenOrientationChanged?: boolean;\n /**\n * The camera to use.\n * @default \"rear\"\n */\n position?: CameraPosition | string;\n /**\n * If true, saves the captured image to a file and returns the file path.\n * If false, returns a base64 encoded string.\n * @default false\n */\n storeToFile?: boolean;\n /**\n * If true, prevents the plugin from rotating the image based on EXIF data.\n * @platform android\n * @default false\n */\n disableExifHeaderStripping?: boolean;\n /**\n * If true, enables high-resolution image capture.\n * @platform ios\n * @default false\n */\n enableHighResolution?: boolean;\n /**\n * If true, disables the audio stream, preventing audio permission requests.\n * @default true\n */\n disableAudio?: boolean;\n /**\n * If true, locks the device orientation while the camera is active.\n * @platform android\n * @default false\n */\n lockAndroidOrientation?: boolean;\n /**\n * If true, allows the camera preview's opacity to be changed.\n * @platform android, web\n * @default false\n */\n enableOpacity?: boolean;\n /**\n * If true, enables pinch-to-zoom functionality on the preview.\n * @platform android\n * @default false\n */\n enableZoom?: boolean;\n /**\n * If true, uses the video-optimized preset for the camera session.\n * @platform ios\n * @default false\n */\n enableVideoMode?: boolean;\n /**\n * The `deviceId` of the camera to use. If provided, `position` is ignored.\n * @platform ios\n */\n deviceId?: string;\n}\n\n/**\n * Defines the options for capturing a picture.\n */\nexport interface CameraPreviewPictureOptions {\n /** The desired height of the picture in pixels. If not provided, the device default is used. */\n height?: number;\n /** The desired width of the picture in pixels. If not provided, the device default is used. */\n width?: number;\n /**\n * The quality of the captured image, from 0 to 100.\n * Does not apply to `png` format.\n * @default 85\n */\n quality?: number;\n /**\n * The format of the captured image.\n * @default \"jpeg\"\n */\n format?: PictureFormat;\n /**\n * If true, the captured image will be saved to the user's gallery.\n * @default false\n * @since 7.5.0\n */\n saveToGallery?: boolean;\n /**\n * If true, the plugin will attempt to add GPS location data to the image's EXIF metadata.\n * This may prompt the user for location permissions.\n * @default false\n * @since 7.6.0\n */\n withExifLocation?: boolean;\n}\n\n/** Represents EXIF data extracted from an image. */\nexport interface ExifData {\n [key: string]: any;\n}\n\nexport type PictureFormat = \"jpeg\" | \"png\";\n\n/** Defines a standard picture size with width and height. */\nexport interface PictureSize {\n /** The width of the picture in pixels. */\n width: number;\n /** The height of the picture in pixels. */\n height: number;\n}\n\n/** Represents the supported picture sizes for a camera facing a certain direction. */\nexport interface SupportedPictureSizes {\n /** The camera direction (\"front\" or \"rear\"). */\n facing: string;\n /** A list of supported picture sizes for this camera. */\n supportedPictureSizes: PictureSize[];\n}\n\n/**\n * Defines the options for capturing a sample frame from the camera preview.\n */\nexport interface CameraSampleOptions {\n /**\n * The quality of the captured sample, from 0 to 100.\n * @default 85\n */\n quality?: number;\n}\n\n/**\n * The available flash modes for the camera.\n * 'torch' is a continuous light mode.\n */\nexport type CameraPreviewFlashMode =\n | \"off\"\n | \"on\"\n | \"auto\"\n | \"torch\";\n\n/**\n * Defines the options for setting the camera preview's opacity.\n */\nexport interface CameraOpacityOptions {\n /**\n * The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque).\n * @default 1.0\n */\n opacity?: number;\n}\n\n/**\n * The main interface for the CameraPreview plugin.\n */\nexport interface CameraPreviewPlugin {\n /**\n * Starts the camera preview.\n *\n * @param {CameraPreviewOptions} options - The configuration for the camera preview.\n * @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the preview dimensions.\n * @since 0.0.1\n */\n start(options: CameraPreviewOptions): Promise<{\n /** The width of the preview in pixels. */\n width: number;\n /** The height of the preview in pixels. */\n height: number;\n /** The horizontal origin of the preview, in pixels. */\n x: number;\n /** The vertical origin of the preview, in pixels. */\n y: number;\n }>;\n\n /**\n * Stops the camera preview.\n *\n * @returns {Promise<void>} A promise that resolves when the camera preview is stopped.\n * @since 0.0.1\n */\n stop(): Promise<void>;\n\n /**\n * Captures a picture from the camera.\n *\n * @param {CameraPreviewPictureOptions} options - The options for capturing the picture.\n * @returns {Promise<{ value: string }>} A promise that resolves with the captured image data.\n * The `value` is a base64 encoded string unless `storeToFile` is true, in which case it's a file path.\n * @since 0.0.1\n */\n capture(\n options: CameraPreviewPictureOptions\n ): Promise<{ value: string; exif: ExifData }>;\n\n /**\n * Captures a single frame from the camera preview stream.\n *\n * @param {CameraSampleOptions} options - The options for capturing the sample.\n * @returns {Promise<{ value: string }>} A promise that resolves with the sample image as a base64 encoded string.\n * @since 0.0.1\n */\n captureSample(options: CameraSampleOptions): Promise<{ value: string }>;\n\n /**\n * Gets the flash modes supported by the active camera.\n *\n * @returns {Promise<{ result: CameraPreviewFlashMode[] }>} A promise that resolves with an array of supported flash modes.\n * @since 0.0.1\n */\n getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }>;\n\n /**\n * Set the aspect ratio of the camera preview.\n *\n * @param {{ aspectRatio: '4:3' | '16:9' | 'fill' }} options - The desired aspect ratio.\n * @returns {Promise<void>} A promise that resolves when the aspect ratio is set.\n * @since 7.4.0\n */\n setAspectRatio(options: { aspectRatio: '4:3' | '16:9' | 'fill' }): Promise<void>;\n\n /**\n * Gets the current aspect ratio of the camera preview.\n *\n * @returns {Promise<{ aspectRatio: '4:3' | '16:9' | 'fill' }>} A promise that resolves with the current aspect ratio.\n * @since 7.4.0\n */\n getAspectRatio(): Promise<{ aspectRatio: '4:3' | '16:9' | 'fill' }>;\n\n /**\n * Gets the horizontal field of view (FoV) for the active camera.\n * Note: This can be an estimate on some devices.\n *\n * @returns {Promise<{ result: number }>} A promise that resolves with the horizontal field of view in degrees.\n * @since 0.0.1\n */\n getHorizontalFov(): Promise<{\n result: number;\n }>;\n\n /**\n * Gets the supported picture sizes for all cameras.\n *\n * @returns {Promise<{ supportedPictureSizes: SupportedPictureSizes[] }>} A promise that resolves with the list of supported sizes.\n * @since 7.4.0\n */\n getSupportedPictureSizes(): Promise<{\n supportedPictureSizes: SupportedPictureSizes[];\n }>;\n\n /**\n * Sets the flash mode for the active camera.\n *\n * @param {{ flashMode: CameraPreviewFlashMode | string }} options - The desired flash mode.\n * @returns {Promise<void>} A promise that resolves when the flash mode is set.\n * @since 0.0.1\n */\n setFlashMode(options: {\n flashMode: CameraPreviewFlashMode | string;\n }): Promise<void>;\n\n /**\n * Toggles between the front and rear cameras.\n *\n * @returns {Promise<void>} A promise that resolves when the camera is flipped.\n * @since 0.0.1\n */\n flip(): Promise<void>;\n\n /**\n * Sets the opacity of the camera preview.\n *\n * @param {CameraOpacityOptions} options - The opacity options.\n * @returns {Promise<void>} A promise that resolves when the opacity is set.\n * @since 0.0.1\n */\n setOpacity(options: CameraOpacityOptions): Promise<void>;\n\n /**\n * Stops an ongoing video recording.\n *\n * @returns {Promise<{ videoFilePath: string }>} A promise that resolves with the path to the recorded video file.\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<{ videoFilePath: string }>;\n\n /**\n * Starts recording a video.\n *\n * @param {CameraPreviewOptions} options - The options for video recording.\n * @returns {Promise<void>} A promise that resolves when video recording starts.\n * @since 0.0.1\n */\n startRecordVideo(options: CameraPreviewOptions): Promise<void>;\n\n /**\n * Checks if the camera preview is currently running.\n *\n * @returns {Promise<{ isRunning: boolean }>} A promise that resolves with the running state.\n * @since 7.4.0\n */\n isRunning(): Promise<{ isRunning: boolean }>;\n\n /**\n * Gets all available camera devices.\n *\n * @returns {Promise<{ devices: CameraDevice[] }>} A promise that resolves with the list of available camera devices.\n * @since 7.4.0\n */\n getAvailableDevices(): Promise<{ devices: CameraDevice[] }>;\n\n /**\n * Gets the current zoom state, including min/max and current lens info.\n *\n * @returns {Promise<{ min: number; max: number; current: number; lens: LensInfo }>} A promise that resolves with the zoom state.\n * @since 7.4.0\n */\n getZoom(): Promise<{\n min: number;\n max: number;\n current: number;\n lens: LensInfo;\n }>;\n\n /**\n * Sets the camera's zoom level.\n *\n * @param {{ level: number; ramp?: boolean }} options - The desired zoom level. `ramp` is currently unused.\n * @returns {Promise<void>} A promise that resolves when the zoom level is set.\n * @since 7.4.0\n */\n setZoom(options: { level: number; ramp?: boolean }): Promise<void>;\n\n /**\n * Gets the current flash mode.\n *\n * @returns {Promise<{ flashMode: FlashMode }>} A promise that resolves with the current flash mode.\n * @since 7.4.0\n */\n getFlashMode(): Promise<{ flashMode: FlashMode }>;\n\n /**\n * Removes all registered listeners.\n *\n * @since 7.4.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Switches the active camera to the one with the specified `deviceId`.\n *\n * @param {{ deviceId: string }} options - The ID of the device to switch to.\n * @returns {Promise<void>} A promise that resolves when the camera is switched.\n * @since 7.4.0\n */\n setDeviceId(options: { deviceId: string }): Promise<void>;\n\n /**\n * Gets the ID of the currently active camera device.\n *\n * @returns {Promise<{ deviceId: string }>} A promise that resolves with the current device ID.\n * @since 7.4.0\n */\n getDeviceId(): Promise<{ deviceId: string }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,sCAAwB,CAAA;IACxB,sCAAwB,CAAA;IACxB,qCAAuB,CAAA;IACvB,sCAAwB,CAAA;IACxB,2BAAa,CAAA;IACb,oCAAsB,CAAA;IACtB,+BAAiB,CAAA;AACnB,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB","sourcesContent":["export type CameraPosition = \"rear\" | \"front\";\n\nexport type FlashMode = CameraPreviewFlashMode;\n\nexport type GridMode = \"none\" | \"3x3\" | \"4x4\";\n\nexport enum DeviceType {\n ULTRA_WIDE = \"ultraWide\",\n WIDE_ANGLE = \"wideAngle\",\n TELEPHOTO = \"telephoto\",\n TRUE_DEPTH = \"trueDepth\",\n DUAL = \"dual\",\n DUAL_WIDE = \"dualWide\",\n TRIPLE = \"triple\",\n}\n\n/**\n * Represents a single camera lens on a device. A {@link CameraDevice} can have multiple lenses.\n */\nexport interface CameraLens {\n /** A human-readable name for the lens, e.g., \"Ultra-Wide\". */\n label: string;\n /** The type of the camera lens. */\n deviceType: DeviceType;\n /** The focal length of the lens in millimeters. */\n focalLength: number;\n /** The base zoom factor for this lens (e.g., 0.5 for ultra-wide, 1.0 for wide). */\n baseZoomRatio: number;\n /** The minimum zoom factor supported by this specific lens. */\n minZoom: number;\n /** The maximum zoom factor supported by this specific lens. */\n maxZoom: number;\n}\n\n/**\n * Represents a physical camera on the device (e.g., the front-facing camera).\n */\nexport interface CameraDevice {\n /** A unique identifier for the camera device. */\n deviceId: string;\n /** A human-readable name for the camera device. */\n label: string;\n /** The physical position of the camera on the device. */\n position: CameraPosition;\n /** A list of all available lenses for this camera device. */\n lenses: CameraLens[];\n /** The overall minimum zoom factor available across all lenses on this device. */\n minZoom: number;\n /** The overall maximum zoom factor available across all lenses on this device. */\n maxZoom: number;\n /** Identifies whether the device is a logical camera (composed of multiple physical lenses). */\n isLogical: boolean;\n}\n\n/**\n * Represents the detailed information of the currently active lens.\n */\nexport interface LensInfo {\n /** The focal length of the active lens in millimeters. */\n focalLength: number;\n /** The device type of the active lens. */\n deviceType: DeviceType;\n /** The base zoom ratio of the active lens (e.g., 0.5x, 1.0x). */\n baseZoomRatio: number;\n /** The current digital zoom factor applied on top of the base zoom. */\n digitalZoom: number;\n}\n\n/**\n * Defines the configuration options for starting the camera preview.\n */\nexport interface CameraPreviewOptions {\n /**\n * The parent element to attach the video preview to.\n * @platform web\n */\n parent?: string;\n /**\n * A CSS class name to add to the preview element.\n * @platform web\n */\n className?: string;\n /**\n * The width of the preview in pixels. Defaults to the screen width.\n * @platform android, ios, web\n */\n width?: number;\n /**\n * The height of the preview in pixels. Defaults to the screen height.\n * @platform android, ios, web\n */\n height?: number;\n /**\n * The horizontal origin of the preview, in pixels.\n * @platform android, ios\n */\n x?: number;\n /**\n * The vertical origin of the preview, in pixels.\n * @platform android, ios\n */\n y?: number;\n /**\n * The aspect ratio of the camera preview, '4:3' or '16:9'.\n * If not set, the camera will use the default aspect ratio.\n *\n * @since 2.0.0\n */\n aspectRatio?: '4:3' | '16:9' | 'fill';\n /**\n * The grid overlay to display on the camera preview.\n * @default \"none\"\n * @since 2.1.0\n */\n gridMode?: GridMode;\n /**\n * Adjusts the y-position to account for safe areas (e.g., notches).\n * @platform ios\n * @default false\n */\n includeSafeAreaInsets?: boolean;\n /**\n * If true, places the preview behind the webview.\n * @platform android\n * @default true\n */\n toBack?: boolean;\n /**\n * Bottom padding for the preview, in pixels.\n * @platform android, ios\n */\n paddingBottom?: number;\n /**\n * Whether to rotate the preview when the device orientation changes.\n * @platform ios\n * @default true\n */\n rotateWhenOrientationChanged?: boolean;\n /**\n * The camera to use.\n * @default \"rear\"\n */\n position?: CameraPosition | string;\n /**\n * If true, saves the captured image to a file and returns the file path.\n * If false, returns a base64 encoded string.\n * @default false\n */\n storeToFile?: boolean;\n /**\n * If true, prevents the plugin from rotating the image based on EXIF data.\n * @platform android\n * @default false\n */\n disableExifHeaderStripping?: boolean;\n /**\n * If true, enables high-resolution image capture.\n * @platform ios\n * @default false\n */\n enableHighResolution?: boolean;\n /**\n * If true, disables the audio stream, preventing audio permission requests.\n * @default true\n */\n disableAudio?: boolean;\n /**\n * If true, locks the device orientation while the camera is active.\n * @platform android\n * @default false\n */\n lockAndroidOrientation?: boolean;\n /**\n * If true, allows the camera preview's opacity to be changed.\n * @platform android, web\n * @default false\n */\n enableOpacity?: boolean;\n /**\n * If true, enables pinch-to-zoom functionality on the preview.\n * @platform android\n * @default false\n */\n enableZoom?: boolean;\n /**\n * If true, uses the video-optimized preset for the camera session.\n * @platform ios\n * @default false\n */\n enableVideoMode?: boolean;\n /**\n * The `deviceId` of the camera to use. If provided, `position` is ignored.\n * @platform ios\n */\n deviceId?: string;\n}\n\n/**\n * Defines the options for capturing a picture.\n */\nexport interface CameraPreviewPictureOptions {\n /** The desired height of the picture in pixels. If not provided, the device default is used. */\n height?: number;\n /** The desired width of the picture in pixels. If not provided, the device default is used. */\n width?: number;\n /**\n * The quality of the captured image, from 0 to 100.\n * Does not apply to `png` format.\n * @default 85\n */\n quality?: number;\n /**\n * The format of the captured image.\n * @default \"jpeg\"\n */\n format?: PictureFormat;\n /**\n * If true, the captured image will be saved to the user's gallery.\n * @default false\n * @since 7.5.0\n */\n saveToGallery?: boolean;\n /**\n * If true, the plugin will attempt to add GPS location data to the image's EXIF metadata.\n * This may prompt the user for location permissions.\n * @default false\n * @since 7.6.0\n */\n withExifLocation?: boolean;\n}\n\n/** Represents EXIF data extracted from an image. */\nexport interface ExifData {\n [key: string]: any;\n}\n\nexport type PictureFormat = \"jpeg\" | \"png\";\n\n/** Defines a standard picture size with width and height. */\nexport interface PictureSize {\n /** The width of the picture in pixels. */\n width: number;\n /** The height of the picture in pixels. */\n height: number;\n}\n\n/** Represents the supported picture sizes for a camera facing a certain direction. */\nexport interface SupportedPictureSizes {\n /** The camera direction (\"front\" or \"rear\"). */\n facing: string;\n /** A list of supported picture sizes for this camera. */\n supportedPictureSizes: PictureSize[];\n}\n\n/**\n * Defines the options for capturing a sample frame from the camera preview.\n */\nexport interface CameraSampleOptions {\n /**\n * The quality of the captured sample, from 0 to 100.\n * @default 85\n */\n quality?: number;\n}\n\n/**\n * The available flash modes for the camera.\n * 'torch' is a continuous light mode.\n */\nexport type CameraPreviewFlashMode =\n | \"off\"\n | \"on\"\n | \"auto\"\n | \"torch\";\n\n/**\n * Defines the options for setting the camera preview's opacity.\n */\nexport interface CameraOpacityOptions {\n /**\n * The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque).\n * @default 1.0\n */\n opacity?: number;\n}\n\n/**\n * The main interface for the CameraPreview plugin.\n */\nexport interface CameraPreviewPlugin {\n /**\n * Starts the camera preview.\n *\n * @param {CameraPreviewOptions} options - The configuration for the camera preview.\n * @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the preview dimensions.\n * @since 0.0.1\n */\n start(options: CameraPreviewOptions): Promise<{\n /** The width of the preview in pixels. */\n width: number;\n /** The height of the preview in pixels. */\n height: number;\n /** The horizontal origin of the preview, in pixels. */\n x: number;\n /** The vertical origin of the preview, in pixels. */\n y: number;\n }>;\n\n /**\n * Stops the camera preview.\n *\n * @returns {Promise<void>} A promise that resolves when the camera preview is stopped.\n * @since 0.0.1\n */\n stop(): Promise<void>;\n\n /**\n * Captures a picture from the camera.\n *\n * @param {CameraPreviewPictureOptions} options - The options for capturing the picture.\n * @returns {Promise<{ value: string }>} A promise that resolves with the captured image data.\n * The `value` is a base64 encoded string unless `storeToFile` is true, in which case it's a file path.\n * @since 0.0.1\n */\n capture(\n options: CameraPreviewPictureOptions\n ): Promise<{ value: string; exif: ExifData }>;\n\n /**\n * Captures a single frame from the camera preview stream.\n *\n * @param {CameraSampleOptions} options - The options for capturing the sample.\n * @returns {Promise<{ value: string }>} A promise that resolves with the sample image as a base64 encoded string.\n * @since 0.0.1\n */\n captureSample(options: CameraSampleOptions): Promise<{ value: string }>;\n\n /**\n * Gets the flash modes supported by the active camera.\n *\n * @returns {Promise<{ result: CameraPreviewFlashMode[] }>} A promise that resolves with an array of supported flash modes.\n * @since 0.0.1\n */\n getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }>;\n\n /**\n * Set the aspect ratio of the camera preview.\n *\n * @param {{ aspectRatio: '4:3' | '16:9' }} options - The desired aspect ratio.\n * @returns {Promise<void>} A promise that resolves when the aspect ratio is set.\n * @since 7.4.0\n */\n setAspectRatio(options: { aspectRatio: '4:3' | '16:9' }): Promise<void>;\n\n /**\n * Gets the current aspect ratio of the camera preview.\n *\n * @returns {Promise<{ aspectRatio: '4:3' | '16:9' }>} A promise that resolves with the current aspect ratio.\n * @since 7.4.0\n */\n getAspectRatio(): Promise<{ aspectRatio: '4:3' | '16:9' }>;\n\n /**\n * Sets the grid mode of the camera preview overlay.\n *\n * @param {{ gridMode: GridMode }} options - The desired grid mode ('none', '3x3', or '4x4').\n * @returns {Promise<void>} A promise that resolves when the grid mode is set.\n * @since 8.0.0\n */\n setGridMode(options: { gridMode: GridMode }): Promise<void>;\n\n /**\n * Gets the current grid mode of the camera preview overlay.\n *\n * @returns {Promise<{ gridMode: GridMode }>} A promise that resolves with the current grid mode.\n * @since 8.0.0\n */\n getGridMode(): Promise<{ gridMode: GridMode }>;\n\n /**\n * Gets the horizontal field of view (FoV) for the active camera.\n * Note: This can be an estimate on some devices.\n *\n * @returns {Promise<{ result: number }>} A promise that resolves with the horizontal field of view in degrees.\n * @since 0.0.1\n */\n getHorizontalFov(): Promise<{\n result: number;\n }>;\n\n /**\n * Gets the supported picture sizes for all cameras.\n *\n * @returns {Promise<{ supportedPictureSizes: SupportedPictureSizes[] }>} A promise that resolves with the list of supported sizes.\n * @since 7.4.0\n */\n getSupportedPictureSizes(): Promise<{\n supportedPictureSizes: SupportedPictureSizes[];\n }>;\n\n /**\n * Sets the flash mode for the active camera.\n *\n * @param {{ flashMode: CameraPreviewFlashMode | string }} options - The desired flash mode.\n * @returns {Promise<void>} A promise that resolves when the flash mode is set.\n * @since 0.0.1\n */\n setFlashMode(options: {\n flashMode: CameraPreviewFlashMode | string;\n }): Promise<void>;\n\n /**\n * Toggles between the front and rear cameras.\n *\n * @returns {Promise<void>} A promise that resolves when the camera is flipped.\n * @since 0.0.1\n */\n flip(): Promise<void>;\n\n /**\n * Sets the opacity of the camera preview.\n *\n * @param {CameraOpacityOptions} options - The opacity options.\n * @returns {Promise<void>} A promise that resolves when the opacity is set.\n * @since 0.0.1\n */\n setOpacity(options: CameraOpacityOptions): Promise<void>;\n\n /**\n * Stops an ongoing video recording.\n *\n * @returns {Promise<{ videoFilePath: string }>} A promise that resolves with the path to the recorded video file.\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<{ videoFilePath: string }>;\n\n /**\n * Starts recording a video.\n *\n * @param {CameraPreviewOptions} options - The options for video recording.\n * @returns {Promise<void>} A promise that resolves when video recording starts.\n * @since 0.0.1\n */\n startRecordVideo(options: CameraPreviewOptions): Promise<void>;\n\n /**\n * Checks if the camera preview is currently running.\n *\n * @returns {Promise<{ isRunning: boolean }>} A promise that resolves with the running state.\n * @since 7.4.0\n */\n isRunning(): Promise<{ isRunning: boolean }>;\n\n /**\n * Gets all available camera devices.\n *\n * @returns {Promise<{ devices: CameraDevice[] }>} A promise that resolves with the list of available camera devices.\n * @since 7.4.0\n */\n getAvailableDevices(): Promise<{ devices: CameraDevice[] }>;\n\n /**\n * Gets the current zoom state, including min/max and current lens info.\n *\n * @returns {Promise<{ min: number; max: number; current: number; lens: LensInfo }>} A promise that resolves with the zoom state.\n * @since 7.4.0\n */\n getZoom(): Promise<{\n min: number;\n max: number;\n current: number;\n lens: LensInfo;\n }>;\n\n /**\n * Sets the camera's zoom level.\n *\n * @param {{ level: number; ramp?: boolean }} options - The desired zoom level. `ramp` is currently unused.\n * @returns {Promise<void>} A promise that resolves when the zoom level is set.\n * @since 7.4.0\n */\n setZoom(options: { level: number; ramp?: boolean }): Promise<void>;\n\n /**\n * Gets the current flash mode.\n *\n * @returns {Promise<{ flashMode: FlashMode }>} A promise that resolves with the current flash mode.\n * @since 7.4.0\n */\n getFlashMode(): Promise<{ flashMode: FlashMode }>;\n\n /**\n * Removes all registered listeners.\n *\n * @since 7.4.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Switches the active camera to the one with the specified `deviceId`.\n *\n * @param {{ deviceId: string }} options - The ID of the device to switch to.\n * @returns {Promise<void>} A promise that resolves when the camera is switched.\n * @since 7.4.0\n */\n setDeviceId(options: { deviceId: string }): Promise<void>;\n\n /**\n * Gets the ID of the currently active camera device.\n *\n * @returns {Promise<{ deviceId: string }>} A promise that resolves with the current device ID.\n * @since 7.4.0\n */\n getDeviceId(): Promise<{ deviceId: string }>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebPlugin } from "@capacitor/core";
2
- import type { CameraDevice, CameraOpacityOptions, CameraPreviewFlashMode, CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewPlugin, CameraSampleOptions, FlashMode, LensInfo } from "./definitions";
2
+ import type { CameraDevice, CameraOpacityOptions, CameraPreviewFlashMode, CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewPlugin, CameraSampleOptions, GridMode, FlashMode, LensInfo } from "./definitions";
3
3
  export declare class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {
4
4
  /**
5
5
  * track which camera is used based on start options
@@ -60,10 +60,16 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
60
60
  deviceId: string;
61
61
  }): Promise<void>;
62
62
  getAspectRatio(): Promise<{
63
- aspectRatio: '4:3' | '16:9' | 'fill';
63
+ aspectRatio: '4:3' | '16:9';
64
64
  }>;
65
65
  setAspectRatio(options: {
66
- aspectRatio: '4:3' | '16:9' | 'fill';
66
+ aspectRatio: '4:3' | '16:9';
67
67
  }): Promise<void>;
68
68
  private createGridOverlay;
69
+ setGridMode(options: {
70
+ gridMode: GridMode;
71
+ }): Promise<void>;
72
+ getGridMode(): Promise<{
73
+ gridMode: GridMode;
74
+ }>;
69
75
  }