@carviz/capacitor-camera-preview 7.2.4 → 7.4.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.
@@ -630,16 +630,14 @@ public class CameraActivity extends Fragment {
630
630
 
631
631
  if (difference < bestDifference - aspectTolerance) {
632
632
  // better aspectRatio found
633
- if ((width != 0 && height != 0) || (supportedSize.width * supportedSize.height < 2048 * 1024)) {
634
- size.width = supportedSize.width;
635
- size.height = supportedSize.height;
636
- bestDifference = difference;
637
- }
633
+ size.width = supportedSize.width;
634
+ size.height = supportedSize.height;
635
+ bestDifference = difference;
638
636
  } else if (difference < bestDifference + aspectTolerance) {
639
637
  // same aspectRatio found (within tolerance)
640
638
  if (width == 0 || height == 0) {
641
- // set highest supported resolution below 2 Megapixel
642
- if ((size.width < supportedSize.width) && (supportedSize.width * supportedSize.height < 2048 * 1024)) {
639
+ // set highest supported resolution
640
+ if (size.width < supportedSize.width) {
643
641
  size.width = supportedSize.width;
644
642
  size.height = supportedSize.height;
645
643
  }
@@ -794,6 +792,9 @@ public class CameraActivity extends Fragment {
794
792
  mCamera.cancelAutoFocus();
795
793
 
796
794
  Camera.Parameters parameters = mCamera.getParameters();
795
+
796
+ // Store the original focus mode to restore it later
797
+ final String originalFocusMode = parameters.getFocusMode();
797
798
 
798
799
  Rect focusRect = calculateTapArea(pointX, pointY, 1f);
799
800
  parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
@@ -806,10 +807,39 @@ public class CameraActivity extends Fragment {
806
807
 
807
808
  try {
808
809
  setCameraParameters(parameters);
809
- mCamera.autoFocus(callback);
810
+
811
+ // Wrap the callback to restore focus mode after autofocus completes
812
+ mCamera.autoFocus(new Camera.AutoFocusCallback() {
813
+ @Override
814
+ public void onAutoFocus(boolean success, Camera camera) {
815
+ // Restore the original focus mode
816
+ try {
817
+ Camera.Parameters params = camera.getParameters();
818
+ List<String> supportedFocusModes = params.getSupportedFocusModes();
819
+
820
+ // Only restore if the original mode is still supported
821
+ if (supportedFocusModes != null && supportedFocusModes.contains(originalFocusMode)) {
822
+ params.setFocusMode(originalFocusMode);
823
+ params.setFocusAreas(null);
824
+ params.setMeteringAreas(null);
825
+ camera.setParameters(params);
826
+ Log.d(TAG, "Focus mode restored to: " + originalFocusMode);
827
+ }
828
+ } catch (Exception e) {
829
+ Log.e(TAG, "Error restoring focus mode: " + e.getMessage());
830
+ }
831
+
832
+ // Call the original callback if provided
833
+ if (callback != null) {
834
+ callback.onAutoFocus(success, camera);
835
+ }
836
+ }
837
+ });
810
838
  } catch (Exception e) {
811
839
  Log.d(TAG, e.getMessage());
812
- callback.onAutoFocus(false, this.mCamera);
840
+ if (callback != null) {
841
+ callback.onAutoFocus(false, this.mCamera);
842
+ }
813
843
  }
814
844
  }
815
845
  }
@@ -228,6 +228,50 @@ public class CameraPreview extends Plugin implements CameraActivity.CameraPrevie
228
228
  call.resolve(result);
229
229
  }
230
230
 
231
+ @PluginMethod
232
+ public void getPreviewPosition(PluginCall call) {
233
+ if (!this.hasView(call)) {
234
+ call.reject("Camera preview is not running");
235
+ return;
236
+ }
237
+
238
+ DisplayMetrics metrics = getBridge().getActivity().getResources().getDisplayMetrics();
239
+
240
+ // Get the raw pixel values that were set
241
+ final int x = fragment.x;
242
+ final int y = fragment.y;
243
+ final int width = fragment.width;
244
+ final int height = fragment.height;
245
+
246
+ // Get screen dimensions
247
+ Display defaultDisplay = getBridge().getActivity().getWindowManager().getDefaultDisplay();
248
+ final Point size = new Point();
249
+ defaultDisplay.getSize(size);
250
+
251
+ // Convert pixels back to dp for consistency
252
+ float dpX = x / metrics.density;
253
+ float dpY = y / metrics.density;
254
+ float dpWidth = width / metrics.density;
255
+ float dpHeight = height / metrics.density;
256
+ float dpScreenWidth = size.x / metrics.density;
257
+ float dpScreenHeight = size.y / metrics.density;
258
+
259
+ JSObject result = new JSObject();
260
+ result.put("x", dpX);
261
+ result.put("y", dpY);
262
+ result.put("width", dpWidth);
263
+ result.put("height", dpHeight);
264
+ result.put("pixelX", x);
265
+ result.put("pixelY", y);
266
+ result.put("pixelWidth", width);
267
+ result.put("pixelHeight", height);
268
+ result.put("scale", metrics.density);
269
+ result.put("screenWidth", dpScreenWidth);
270
+ result.put("screenHeight", dpScreenHeight);
271
+
272
+ call.resolve(result);
273
+ }
274
+
231
275
  @PermissionCallback
232
276
  private void handleCameraPermissionResult(PluginCall call) {
233
277
  if (PermissionState.GRANTED.equals(getPermissionState(CAMERA_PERMISSION_ALIAS))) {
@@ -62,6 +62,30 @@ export interface CameraZoomChangeEvent {
62
62
  /** The new zoom level */
63
63
  zoom: number;
64
64
  }
65
+ export interface CameraPreviewPosition {
66
+ /** The x position in points (iOS) or dp (Android) */
67
+ x: number;
68
+ /** The y position in points (iOS) or dp (Android) */
69
+ y: number;
70
+ /** The width in points (iOS) or dp (Android) */
71
+ width: number;
72
+ /** The height in points (iOS) or dp (Android) */
73
+ height: number;
74
+ /** The x position in physical pixels */
75
+ pixelX: number;
76
+ /** The y position in physical pixels */
77
+ pixelY: number;
78
+ /** The width in physical pixels */
79
+ pixelWidth: number;
80
+ /** The height in physical pixels */
81
+ pixelHeight: number;
82
+ /** The device scale factor (pixel density) */
83
+ scale: number;
84
+ /** The screen width in points (iOS) or dp (Android) */
85
+ screenWidth: number;
86
+ /** The screen height in points (iOS) or dp (Android) */
87
+ screenHeight: number;
88
+ }
65
89
  export interface CameraPreviewPlugin {
66
90
  /** Starts the camera preview instance */
67
91
  start(options: CameraPreviewOptions): Promise<{}>;
@@ -93,6 +117,8 @@ export interface CameraPreviewPlugin {
93
117
  getZoom(): Promise<{
94
118
  zoom: number;
95
119
  }>;
120
+ /** Get the preview position and dimensions - Android / iOS only */
121
+ getPreviewPosition(): Promise<CameraPreviewPosition>;
96
122
  /** Check camera permission */
97
123
  checkPermissions(): Promise<PermissionState>;
98
124
  /** Request camera permission */
package/dist/esm/web.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
2
  import type { PluginListenerHandle } from '@capacitor/core';
3
- import type { CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewPlugin, CameraPreviewFlashMode, CameraSampleOptions, CameraOpacityOptions, CameraZoomOptions } from './definitions';
3
+ import type { CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewPlugin, CameraPreviewFlashMode, CameraSampleOptions, CameraOpacityOptions, CameraZoomOptions, CameraPreviewPosition } from './definitions';
4
4
  export declare class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {
5
5
  /**
6
6
  * track which camera is used based on start options
@@ -22,6 +22,7 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
22
22
  setOpacity(_options: CameraOpacityOptions): Promise<any>;
23
23
  setZoom(_options: CameraZoomOptions): Promise<any>;
24
24
  getZoom(): Promise<any>;
25
+ getPreviewPosition(): Promise<CameraPreviewPosition>;
25
26
  checkPermissions(): Promise<PermissionState>;
26
27
  requestPermissions(): Promise<PermissionState>;
27
28
  addListener(_eventName: string, _listenerFunc: (info: any) => void): Promise<PluginListenerHandle>;
package/dist/esm/web.js CHANGED
@@ -116,6 +116,9 @@ export class CameraPreviewWeb extends WebPlugin {
116
116
  async getZoom() {
117
117
  throw new Error('getZoom not supported under the web platform');
118
118
  }
119
+ async getPreviewPosition() {
120
+ throw new Error('getPreviewPosition not supported under the web platform');
121
+ }
119
122
  async checkPermissions() {
120
123
  throw new Error('checkPermissions not supported under the web platform');
121
124
  }
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAa5C,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAO7C;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAA6B;;QACvC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAA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AAK,CAAC,OAAO;QACX,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,UAAkB,EAAE,aAAkC;QACtE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;CACF"}
@@ -38,7 +38,7 @@ class CameraPreviewWeb extends core.WebPlugin {
38
38
  videoElement.setAttribute('playsinline', 'true');
39
39
  }
40
40
  parent.appendChild(videoElement);
41
- if (!((_a = navigator.mediaDevices) === null || _a === undefined ? undefined : _a.getUserMedia)) {
41
+ if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {
42
42
  throw new Error('No media devices available');
43
43
  }
44
44
  const constraints = {
@@ -123,6 +123,9 @@ class CameraPreviewWeb extends core.WebPlugin {
123
123
  async getZoom() {
124
124
  throw new Error('getZoom not supported under the web platform');
125
125
  }
126
+ async getPreviewPosition() {
127
+ throw new Error('getPreviewPosition not supported under the web platform');
128
+ }
126
129
  async checkPermissions() {
127
130
  throw new Error('checkPermissions not supported under the web platform');
128
131
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super();\n }\n async start(options) {\n var _a;\n const stream = await navigator.mediaDevices.getUserMedia({ video: true });\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (video) {\n throw new Error('camera already started');\n }\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n throw new Error('No media devices available');\n }\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n videoElement.srcObject = await navigator.mediaDevices.getUserMedia(constraints);\n videoElement.play();\n return {};\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n const st = video.srcObject;\n const tracks = st.getTracks();\n for (let i = 0; i < tracks.length; i++) {\n const track = tracks[i];\n track.stop();\n }\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, _) => {\n const video = document.getElementById('video');\n const canvas = document.createElement('canvas');\n // video.width = video.offsetWidth;\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n let base64EncodedImage;\n if (options.quality != undefined) {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', options.quality / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform');\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n async setZoom(_options) {\n throw new Error('setZoom not supported under the web platform');\n }\n async getZoom() {\n throw new Error('getZoom not supported under the web platform');\n }\n async checkPermissions() {\n throw new Error('checkPermissions not supported under the web platform');\n }\n async requestPermissions() {\n throw new Error('requestPermissions not supported under the web platform');\n }\n async addListener(_eventName, _listenerFunc) {\n throw new Error('addListener not supported under the web platform');\n }\n async removeAllListeners() {\n throw new Error('removeAllListeners not supported under the web platform');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;AACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACpE,CAAC;;ACFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;AAChD,IAAI,WAAW,GAAG;AAClB,QAAQ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C;AAClF;AACA,IAAI,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE;AACjD,QAAQ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC;AAC3E;AACA,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;AAClF;AACA;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super();\n }\n async start(options) {\n var _a;\n const stream = await navigator.mediaDevices.getUserMedia({ video: true });\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (video) {\n throw new Error('camera already started');\n }\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n throw new Error('No media devices available');\n }\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n videoElement.srcObject = await navigator.mediaDevices.getUserMedia(constraints);\n videoElement.play();\n return {};\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n const st = video.srcObject;\n const tracks = st.getTracks();\n for (let i = 0; i < tracks.length; i++) {\n const track = tracks[i];\n track.stop();\n }\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, _) => {\n const video = document.getElementById('video');\n const canvas = document.createElement('canvas');\n // video.width = video.offsetWidth;\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n let base64EncodedImage;\n if (options.quality != undefined) {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', options.quality / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform');\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n async setZoom(_options) {\n throw new Error('setZoom not supported under the web platform');\n }\n async getZoom() {\n throw new Error('getZoom not supported under the web platform');\n }\n async getPreviewPosition() {\n throw new Error('getPreviewPosition not supported under the web platform');\n }\n async checkPermissions() {\n throw new Error('checkPermissions not supported under the web platform');\n }\n async requestPermissions() {\n throw new Error('requestPermissions not supported under the web platform');\n }\n async addListener(_eventName, _listenerFunc) {\n throw new Error('addListener not supported under the web platform');\n }\n async removeAllListeners() {\n throw new Error('removeAllListeners not supported under the web platform');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;AACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACpE,CAAC;;ACFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;AAChD,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,EAAE;AACf,IAAI;AACJ,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,EAAE;AACd,QAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACjF;AACA,QAAQ,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;AAC3D,QAAQ,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC;AACtD,QAAQ,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC;AAC9D,QAAQ,IAAI,KAAK,EAAE;AACnB,YAAY,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC;AACrD,QAAQ;AACR,QAAQ,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAC5D,QAAQ,YAAY,CAAC,EAAE,GAAG,OAAO;AACjC,QAAQ,YAAY,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;AACnE;AACA,QAAQ,IAAI,OAAO,CA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Ac,CAAC,OAAO,CAAC;AACtD,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC9C,YAAY,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC9E,QAAQ;AACR,IAAI;AACJ,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;AAC5B,QAAQ,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC;AACvE,IAAI;AACJ,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC;AACvE,IAAI;AACJ,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;AAClF,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC;AAChF,IAAI;AACJ,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;AAClF,IAAI;AACJ,IAAI,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE;AACjD,QAAQ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC;AAC3E,IAAI;AACJ,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;AAClF,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -37,7 +37,7 @@ var capacitorSplashScreen = (function (exports, core) {
37
37
  videoElement.setAttribute('playsinline', 'true');
38
38
  }
39
39
  parent.appendChild(videoElement);
40
- if (!((_a = navigator.mediaDevices) === null || _a === undefined ? undefined : _a.getUserMedia)) {
40
+ if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {
41
41
  throw new Error('No media devices available');
42
42
  }
43
43
  const constraints = {
@@ -122,6 +122,9 @@ var capacitorSplashScreen = (function (exports, core) {
122
122
  async getZoom() {
123
123
  throw new Error('getZoom not supported under the web platform');
124
124
  }
125
+ async getPreviewPosition() {
126
+ throw new Error('getPreviewPosition not supported under the web platform');
127
+ }
125
128
  async checkPermissions() {
126
129
  throw new Error('checkPermissions not supported under the web platform');
127
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super();\n }\n async start(options) {\n var _a;\n const stream = await navigator.mediaDevices.getUserMedia({ video: true });\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (video) {\n throw new Error('camera already started');\n }\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n throw new Error('No media devices available');\n }\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n videoElement.srcObject = await navigator.mediaDevices.getUserMedia(constraints);\n videoElement.play();\n return {};\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n const st = video.srcObject;\n const tracks = st.getTracks();\n for (let i = 0; i < tracks.length; i++) {\n const track = tracks[i];\n track.stop();\n }\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, _) => {\n const video = document.getElementById('video');\n const canvas = document.createElement('canvas');\n // video.width = video.offsetWidth;\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n let base64EncodedImage;\n if (options.quality != undefined) {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', options.quality / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform');\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n async setZoom(_options) {\n throw new Error('setZoom not supported under the web platform');\n }\n async getZoom() {\n throw new Error('getZoom not supported under the web platform');\n }\n async checkPermissions() {\n throw new Error('checkPermissions not supported under the web platform');\n }\n async requestPermissions() {\n throw new Error('requestPermissions not supported under the web platform');\n }\n async addListener(_eventName, _listenerFunc) {\n throw new Error('addListener not supported under the web platform');\n }\n async removeAllListeners() {\n throw new Error('removeAllListeners not supported under the web platform');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;IACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACpE,CAAC;;ICFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;IAChD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,EAAE;IACf;IACA,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,EAAE;IACd,QAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACjF;IACA,QAAQ,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;IAC3D,QAAQ,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC;IACtD,QAAQ,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC;IAC9D,QAAQ,IAAI,KAAK,EAAE;IACnB,YAAY,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC;IACrD;IACA,QAAQ,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;IAC5D,QAAQ,YAAY,CAAC,EAAE,GAAG,OAAO;IACjC,QAAQ,YAAY,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;IACnE;IACA,QAAQ,IAAI,OAAO,CAAC,QAAQ,KAAK,MAAM,EAAE;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AAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9E;IACA;IACA,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;IAC5B,QAAQ,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC;IACvE;IACA,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC;IACvE;IACA,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC;IAChF;IACA,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;IAClF;IACA,IAAI,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE;IACjD,QAAQ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC;IAC3E;IACA,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;IAClF;IACA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super();\n }\n async start(options) {\n var _a;\n const stream = await navigator.mediaDevices.getUserMedia({ video: true });\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (video) {\n throw new Error('camera already started');\n }\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n throw new Error('No media devices available');\n }\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n videoElement.srcObject = await navigator.mediaDevices.getUserMedia(constraints);\n videoElement.play();\n return {};\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n const st = video.srcObject;\n const tracks = st.getTracks();\n for (let i = 0; i < tracks.length; i++) {\n const track = tracks[i];\n track.stop();\n }\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, _) => {\n const video = document.getElementById('video');\n const canvas = document.createElement('canvas');\n // video.width = video.offsetWidth;\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n let base64EncodedImage;\n if (options.quality != undefined) {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', options.quality / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform');\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n async setZoom(_options) {\n throw new Error('setZoom not supported under the web platform');\n }\n async getZoom() {\n throw new Error('getZoom not supported under the web platform');\n }\n async getPreviewPosition() {\n throw new Error('getPreviewPosition not supported under the web platform');\n }\n async checkPermissions() {\n throw new Error('checkPermissions not supported under the web platform');\n }\n async requestPermissions() {\n throw new Error('requestPermissions not supported under the web platform');\n }\n async addListener(_eventName, _listenerFunc) {\n throw new Error('addListener not supported under the web platform');\n }\n async removeAllListeners() {\n throw new Error('removeAllListeners not supported under the web platform');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;IACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACpE,CAAC;;ICFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;IAChD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,EAAE;IACf,IAAI;IACJ,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,EAAE;IACd,QAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACjF;IACA,QAAQ,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;IAC3D,QAAQ,MAAM,KAAK,GAAG,QAAQ,CA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D,QAAQ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC;IAC3E,IAAI;IACJ,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;IAClF,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -15,4 +15,5 @@ CAP_PLUGIN(CameraPreview, "CameraPreview",
15
15
  CAP_PLUGIN_METHOD(getZoom, CAPPluginReturnPromise);
16
16
  CAP_PLUGIN_METHOD(checkPermissions, CAPPluginReturnPromise);
17
17
  CAP_PLUGIN_METHOD(requestPermissions, CAPPluginReturnPromise);
18
+ CAP_PLUGIN_METHOD(getPreviewPosition, CAPPluginReturnPromise);
18
19
  )
@@ -256,6 +256,41 @@ public class CameraPreview: CAPPlugin, CameraControllerDelegate {
256
256
  }
257
257
  }
258
258
 
259
+ /**
260
+ Get the preview position and dimensions
261
+ */
262
+ @objc public func getPreviewPosition(_ call: CAPPluginCall) {
263
+ guard let previewView = self.previewView else {
264
+ call.reject("camera preview is not running")
265
+ return
266
+ }
267
+
268
+ DispatchQueue.main.async {
269
+ let frame = previewView.frame
270
+
271
+ // Get the scale factor to convert points to pixels
272
+ let scale = UIScreen.main.scale
273
+
274
+ // Get screen dimensions in points
275
+ let screenWidth = UIScreen.main.bounds.width
276
+ let screenHeight = UIScreen.main.bounds.height
277
+
278
+ call.resolve([
279
+ "x": frame.origin.x,
280
+ "y": frame.origin.y,
281
+ "width": frame.size.width,
282
+ "height": frame.size.height,
283
+ "pixelX": frame.origin.x * scale,
284
+ "pixelY": frame.origin.y * scale,
285
+ "pixelWidth": frame.size.width * scale,
286
+ "pixelHeight": frame.size.height * scale,
287
+ "scale": scale,
288
+ "screenWidth": screenWidth,
289
+ "screenHeight": screenHeight
290
+ ])
291
+ }
292
+ }
293
+
259
294
  /**
260
295
  Helper method for initializing the plugin settings based on the Capacitor call
261
296
  */
@@ -274,8 +309,8 @@ public class CameraPreview: CAPPlugin, CameraControllerDelegate {
274
309
  self.previewHeight = UIScreen.main.bounds.size.height
275
310
  }
276
311
 
277
- self.x = CGFloat(call.getInt("x", 0)) / 2
278
- self.y = CGFloat(call.getInt("y", 0)) / 2
312
+ self.x = CGFloat(call.getInt("x", 0))
313
+ self.y = CGFloat(call.getInt("y", 0))
279
314
 
280
315
  self.paddingBottom = CGFloat(call.getInt("paddingBottom", 0))
281
316
 
package/ios/Podfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PODS:
2
- - Capacitor (7.0.1):
2
+ - Capacitor (8.0.0):
3
3
  - CapacitorCordova
4
- - CapacitorCordova (7.0.1)
4
+ - CapacitorCordova (8.0.0)
5
5
 
6
6
  DEPENDENCIES:
7
7
  - "Capacitor (from `../node_modules/@capacitor/ios`)"
@@ -14,8 +14,8 @@ EXTERNAL SOURCES:
14
14
  :path: "../node_modules/@capacitor/ios"
15
15
 
16
16
  SPEC CHECKSUMS:
17
- Capacitor: 23fff43571a4d1e3ee7d67b5a3588c6e757c2913
18
- CapacitorCordova: 63d476958d5022d76f197031e8b7ea3519988c64
17
+ Capacitor: 79e40e5e76f852965dce30406c65253fa154e24a
18
+ CapacitorCordova: 5dc3912d25ef770a3fe0f431bb65c9fbfa2e92f9
19
19
 
20
20
  PODFILE CHECKSUM: 67f8d0d29925a47d3223356b6b7813c3a09347fc
21
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carviz/capacitor-camera-preview",
3
- "version": "7.2.4",
3
+ "version": "7.4.0",
4
4
  "description": "Fork of the capacitor-community/camera-preview plugin focusing on high resolution photos without bloating up the code.",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.cjs.js",
@@ -26,22 +26,23 @@
26
26
  "author": "Evan Barberousse",
27
27
  "license": "MIT",
28
28
  "devDependencies": {
29
- "@capacitor/android": "^7.0.1",
30
- "@capacitor/core": "^7.0.1",
31
- "@capacitor/ios": "^7.0.1",
29
+ "@capacitor/android": "^8.0.0",
30
+ "@capacitor/cli": "^8.0.0",
31
+ "@capacitor/core": "^8.0.0",
32
+ "@capacitor/ios": "^8.0.0",
32
33
  "@ionic/eslint-config": "^0.4.0",
33
34
  "@ionic/prettier-config": "^4.0.0",
34
35
  "@ionic/swiftlint-config": "^1.1.2",
35
36
  "concurrently": "^8.2.2",
36
- "eslint": "^8.57.0",
37
- "husky": "^9.1.4",
38
- "prettier": "^3.3.3",
39
- "prettier-plugin-java": "^2.6.4",
40
- "pretty-quick": "^4.0.0",
41
- "rimraf": "^6.0.1",
42
- "rollup": "^4.20.0",
37
+ "eslint": "^8.57.1",
38
+ "husky": "^9.1.7",
39
+ "prettier": "^3.7.4",
40
+ "prettier-plugin-java": "^2.7.7",
41
+ "pretty-quick": "^4.2.2",
42
+ "rimraf": "^6.1.2",
43
+ "rollup": "^4.53.5",
43
44
  "swiftlint": "^1.0.2",
44
- "typescript": "^5.5.4"
45
+ "typescript": "^5.9.3"
45
46
  },
46
47
  "peerDependencies": {
47
48
  "@capacitor/core": "^7.0.1"