capacitor-camera-view 1.0.4 → 1.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/utils.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n/**\n * The main Capacitor Camera View plugin instance.\n */\nconst CameraView = registerPlugin('CameraView', {\n web: () => import('./web').then((m) => new m.CameraViewWeb()),\n});\nexport * from './definitions';\nexport { CameraView };\n//# sourceMappingURL=index.js.map","/**\n * Converts canvas to base64 string\n */\nexport function canvasToBase64(canvas, quality) {\n const dataUrl = canvas.toDataURL('image/jpeg', quality);\n return dataUrl.split(',')[1];\n}\n/**\n * Calculates the visible area of the video based on object-fit: cover\n */\nexport function calculateVisibleArea(video) {\n // Get the displayed dimensions of the video element\n const videoRect = video.getBoundingClientRect();\n const displayWidth = videoRect.width;\n const displayHeight = videoRect.height;\n // Get the intrinsic dimensions of the video\n const videoWidth = video.videoWidth;\n const videoHeight = video.videoHeight;\n // Calculate which portion of the video is visible (for object-fit: cover)\n const videoAspect = videoWidth / videoHeight;\n const displayAspect = displayWidth / displayHeight;\n let sourceX = 0;\n let sourceY = 0;\n let sourceWidth = videoWidth;\n let sourceHeight = videoHeight;\n // If video aspect ratio is greater than display aspect ratio,\n // the video is cropped on the sides\n if (videoAspect > displayAspect) {\n sourceWidth = videoHeight * displayAspect;\n sourceX = (videoWidth - sourceWidth) / 2;\n }\n // Otherwise the video is cropped on the top and bottom\n else {\n sourceHeight = videoWidth / displayAspect;\n sourceY = (videoHeight - sourceHeight) / 2;\n }\n return {\n sourceX,\n sourceY,\n sourceWidth,\n sourceHeight,\n displayWidth,\n displayHeight,\n };\n}\n/**\n * Draws the visible area of the video to the canvas\n */\nexport function drawVisibleAreaToCanvas(canvas, videoElement, area) {\n const { sourceX, sourceY, sourceWidth, sourceHeight, displayWidth, displayHeight } = area;\n // Set canvas size to match the displayed dimensions\n canvas.width = displayWidth;\n canvas.height = displayHeight;\n const ctx = canvas.getContext('2d', { alpha: false });\n if (!ctx) {\n throw new Error('Could not get canvas context');\n }\n // Draw only the visible portion of the video to match what the user sees\n ctx.drawImage(videoElement, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, displayWidth, displayHeight);\n}\n/**\n * Transforms barcode coordinates from the video source space to display space\n * accounting for object-fit: cover scaling and cropping.\n *\n * @param barcodeBoundingBox The original barcode bounding box from the detector\n * @param videoElement The video element with the camera stream\n * @returns The transformed bounding box coordinates in display space\n */\nexport function transformBarcodeBoundingBox(barcodeBoundingBox, videoElement) {\n // Get the video element's displayed dimensions\n const videoRect = videoElement.getBoundingClientRect();\n const displayWidth = videoRect.width;\n const displayHeight = videoRect.height;\n // Get original video dimensions\n const videoWidth = videoElement.videoWidth;\n const videoHeight = videoElement.videoHeight;\n // Calculate scaling and positioning for object-fit: cover\n const videoAspect = videoWidth / videoHeight;\n const displayAspect = displayWidth / displayHeight;\n let scaledX, scaledY, scaledWidth, scaledHeight;\n if (videoAspect > displayAspect) {\n // Video is wider than display area - height matches, width is centered and cropped\n const scale = displayHeight / videoHeight;\n const scaledVideoWidth = videoWidth * scale;\n const cropX = (scaledVideoWidth - displayWidth) / 2;\n scaledWidth = barcodeBoundingBox.width * scale;\n scaledHeight = barcodeBoundingBox.height * scale;\n scaledX = barcodeBoundingBox.x * scale - cropX;\n scaledY = barcodeBoundingBox.y * scale;\n }\n else {\n // Video is taller than display area - width matches, height is centered and cropped\n const scale = displayWidth / videoWidth;\n const scaledVideoHeight = videoHeight * scale;\n const cropY = (scaledVideoHeight - displayHeight) / 2;\n scaledWidth = barcodeBoundingBox.width * scale;\n scaledHeight = barcodeBoundingBox.height * scale;\n scaledX = barcodeBoundingBox.x * scale;\n scaledY = barcodeBoundingBox.y * scale - cropY;\n }\n return {\n x: scaledX,\n y: scaledY,\n width: scaledWidth,\n height: scaledHeight,\n };\n}\n//# sourceMappingURL=utils.js.map","var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n return privateMap.get(receiver);\n};\nvar __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to set private field on non-instance\");\n }\n privateMap.set(receiver, value);\n return value;\n};\nvar _isRunning;\nimport { WebPlugin } from '@capacitor/core';\nimport { calculateVisibleArea, canvasToBase64, drawVisibleAreaToCanvas, transformBarcodeBoundingBox } from './utils';\n/**\n * Web implementation of the CameraViewPlugin.\n * Optimized for performance and battery efficiency.\n */\nexport class CameraViewWeb extends WebPlugin {\n constructor() {\n super();\n // DOM elements\n this.videoElement = null;\n this.canvasElement = null;\n // Stream state\n this.stream = null;\n _isRunning.set(this, false);\n // Configuration state\n this.currentCamera = 'environment'; // Default to back camera\n this.currentZoom = 1.0;\n this.currentFlashMode = 'off';\n // Barcode detection support\n this.barcodeDetectionSupported = false;\n this.barcodeDetector = null;\n this.checkBarcodeDetectionSupport();\n }\n /**\n * Start the camera with the given configuration\n */\n async start(options) {\n if (__classPrivateFieldGet(this, _isRunning)) {\n return;\n }\n const permissionStatus = await this.requestPermissions();\n if (permissionStatus.camera !== 'granted') {\n throw new Error('Camera permission was not granted');\n }\n try {\n // Set up video element if it doesn't exist\n if (!this.videoElement) {\n await this.setupVideoElement(options === null || options === void 0 ? void 0 : options.containerElementId);\n }\n // Set up video constraints based on options\n const videoConstraints = {};\n // Prefer deviceId if specified\n if (options === null || options === void 0 ? void 0 : options.deviceId) {\n videoConstraints.deviceId = { exact: options.deviceId };\n // Remember the current camera mode (though we're using a specific device)\n this.currentCamera = (options === null || options === void 0 ? void 0 : options.position) === 'front' ? 'user' : 'environment';\n }\n else {\n // Fall back to facing mode\n const facingMode = (options === null || options === void 0 ? void 0 : options.position) === 'front' ? 'user' : 'environment';\n this.currentCamera = facingMode;\n videoConstraints.facingMode = facingMode;\n }\n const constraints = {\n video: videoConstraints,\n audio: false,\n };\n this.stream = await navigator.mediaDevices.getUserMedia(constraints);\n if (this.videoElement) {\n this.videoElement.srcObject = this.stream;\n this.videoElement.play();\n __classPrivateFieldSet(this, _isRunning, true);\n // If barcode detection is enabled and supported, start detection\n if ((options === null || options === void 0 ? void 0 : options.enableBarcodeDetection) && this.barcodeDetectionSupported) {\n this.startBarcodeDetection();\n }\n }\n }\n catch (err) {\n throw new Error(`Failed to start camera: ${this.formatError(err)}`);\n }\n }\n /**\n * Stop the camera and release resources\n */\n async stop() {\n if (!__classPrivateFieldGet(this, _isRunning)) {\n return;\n }\n try {\n // Stop all tracks in the stream\n if (this.stream) {\n this.stream.getTracks().forEach((track) => track.stop());\n this.stream = null;\n }\n // Clear video source\n if (this.videoElement) {\n this.videoElement = null;\n }\n __classPrivateFieldSet(this, _isRunning, false);\n }\n catch (err) {\n throw new Error(`Failed to stop camera: ${this.formatError(err)}`);\n }\n }\n /**\n * Check if the camera is currently running\n */\n async isRunning() {\n return { isRunning: __classPrivateFieldGet(this, _isRunning) };\n }\n /**\n * Capture a photo using the camera and return it as a base64-encoded JPEG image.\n * Preserves what the user actually sees in the UI, including cropping from object-fit: cover.\n */\n async capture(options) {\n const videoElement = this.videoElement;\n if (!__classPrivateFieldGet(this, _isRunning) || !videoElement) {\n throw new Error('Camera is not running');\n }\n try {\n const canvas = this.getCanvasElement();\n const visibleArea = calculateVisibleArea(videoElement);\n drawVisibleAreaToCanvas(canvas, videoElement, visibleArea);\n const quality = Math.min(1.0, Math.max(0.1, options.quality / 100));\n const base64Data = canvasToBase64(canvas, quality);\n return { photo: base64Data };\n }\n catch (err) {\n throw new Error(`Failed to capture photo: ${this.formatError(err)}`);\n }\n }\n /**\n * Web implementation already uses images from the video stream, so this is the same as `capture()`\n */\n async captureSample(options) {\n return this.capture(options);\n }\n /**\n * Flip between front and back camera\n */\n async flipCamera() {\n if (!__classPrivateFieldGet(this, _isRunning)) {\n throw new Error('Camera is not running');\n }\n try {\n // Switch current camera\n this.currentCamera = this.currentCamera === 'user' ? 'environment' : 'user';\n // Stop current stream\n if (this.stream) {\n this.stream.getTracks().forEach((track) => track.stop());\n }\n // Restart with new facing mode\n const constraints = {\n video: {\n facingMode: this.currentCamera,\n },\n audio: false,\n };\n this.stream = await navigator.mediaDevices.getUserMedia(constraints);\n if (this.videoElement) {\n this.videoElement.srcObject = this.stream;\n }\n }\n catch (err) {\n throw new Error(`Failed to flip camera: ${this.formatError(err)}`);\n }\n }\n /**\n * Get available camera devices\n */\n async getAvailableDevices() {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n const videoDevices = devices.filter((device) => device.kind === 'videoinput');\n return {\n devices: videoDevices.map((device) => ({\n id: device.deviceId,\n name: device.label || `Camera ${device.deviceId.substring(0, 5)}`,\n position: device.label.toLowerCase().includes('front') ? 'front' : 'back',\n })),\n };\n }\n catch (err) {\n console.error('Failed to get available devices', err);\n return { devices: [] };\n }\n }\n /**\n * Get current zoom information (web has limited zoom support)\n */\n async getZoom() {\n // Web has limited zoom capabilities in most browsers,\n // we fake zoomin by scaling the video element\n return {\n min: 1.0,\n max: 3.0,\n current: this.currentZoom,\n };\n }\n /**\n * Set zoom level (limited support in web)\n */\n async setZoom(options) {\n // Store the requested zoom level\n this.currentZoom = options.level;\n // Apply visual zoom using CSS transform when native zoom isn't supported\n if (this.videoElement) {\n this.videoElement.style.transition = options.ramp ? 'transform 0.2s ease-in-out' : 'none';\n const scale = Math.max(1.0, Math.min(options.level, 3.0)); // Limit scale to reasonable bounds\n this.videoElement.style.transform = `scale(${scale})`;\n this.videoElement.style.transformOrigin = 'center';\n }\n }\n /**\n * Get current flash mode\n */\n async getFlashMode() {\n return { flashMode: this.currentFlashMode };\n }\n /**\n * Get supported flash modes\n */\n async getSupportedFlashModes() {\n // Web has limited flash control\n return { flashModes: ['off'] };\n }\n /**\n * Set flash mode (limited support in web)\n */\n async setFlashMode(options) {\n this.currentFlashMode = options.mode;\n console.warn('Flash mode control is not fully supported in the web implementation');\n }\n /**\n * Check camera permission without requesting\n */\n async checkPermissions() {\n try {\n // Use Permissions API if available\n if (navigator.permissions) {\n const result = await navigator.permissions.query({ name: 'camera' });\n return {\n camera: result.state === 'granted' ? 'granted' : result.state === 'denied' ? 'denied' : 'prompt',\n };\n }\n // If Permissions API is not available, check if we have an active stream\n return {\n camera: this.stream ? 'granted' : 'prompt',\n };\n }\n catch (err) {\n // If permissions API is not supported or fails\n return {\n camera: 'prompt',\n };\n }\n }\n /**\n * Request camera permission from the user\n */\n async requestPermissions() {\n try {\n // Try to access the camera to trigger the permission prompt\n const stream = await navigator.mediaDevices.getUserMedia({ video: true });\n // If we get here, permission was granted\n // Clean up the test stream\n stream.getTracks().forEach((track) => track.stop());\n return { camera: 'granted' };\n }\n catch (err) {\n // Permission denied or other error\n return { camera: 'denied' };\n }\n }\n /**\n * Start barcode detection if supported\n */\n async startBarcodeDetection() {\n const barcodeDetector = this.barcodeDetector;\n const videoElement = this.videoElement;\n if (!this.barcodeDetectionSupported || !barcodeDetector || !videoElement) {\n return;\n }\n // Make sure video is fully loaded before starting detection\n if (videoElement.readyState < 2) {\n await new Promise((resolve) => {\n const loadHandler = () => {\n videoElement.removeEventListener('loadeddata', loadHandler);\n resolve();\n };\n videoElement.addEventListener('loadeddata', loadHandler);\n });\n }\n // Add throttling to reduce CPU usage\n let lastDetectionTime = 0;\n const minTimeBetweenDetections = 100; // ms\n // Set up periodic frame analysis for barcode detection\n const detectFrame = async () => {\n if (!__classPrivateFieldGet(this, _isRunning) || !videoElement || !barcodeDetector) {\n return;\n }\n const now = Date.now();\n if (now - lastDetectionTime >= minTimeBetweenDetections) {\n try {\n const barcodes = await barcodeDetector.detect(videoElement);\n lastDetectionTime = now;\n if (barcodes.length > 0) {\n const barcode = barcodes[0];\n // Transform barcode coordinates using the utility function\n const boundingRect = transformBarcodeBoundingBox(barcode.boundingBox, videoElement);\n this.notifyListeners('barcodeDetected', {\n value: barcode.rawValue,\n type: barcode.format.toLowerCase(),\n boundingRect,\n });\n }\n }\n catch (err) {\n console.error('Barcode detection error', err);\n }\n }\n if (__classPrivateFieldGet(this, _isRunning)) {\n requestAnimationFrame(detectFrame);\n }\n };\n requestAnimationFrame(detectFrame);\n }\n /**\n * Clean up resources when the plugin is disposed\n */\n async handleOnDestroy() {\n var _a;\n await this.stop();\n // Remove elements from DOM\n if ((_a = this.videoElement) === null || _a === void 0 ? void 0 : _a.parentNode) {\n this.videoElement.parentNode.removeChild(this.videoElement);\n this.videoElement = null;\n }\n if (this.canvasElement) {\n this.canvasElement = null;\n }\n this.barcodeDetector = null;\n }\n /**\n * Check if barcode detection is supported in this browser\n */\n async checkBarcodeDetectionSupport() {\n if ('BarcodeDetector' in window) {\n try {\n this.barcodeDetector = new BarcodeDetector();\n this.barcodeDetectionSupported = true;\n }\n catch (e) {\n console.warn('BarcodeDetector is not supported by this browser.');\n this.barcodeDetectionSupported = false;\n }\n }\n }\n /**\n * Set up the video element for the camera view\n */\n async setupVideoElement(containerElementId) {\n this.videoElement = document.createElement('video');\n this.videoElement.playsInline = true;\n this.videoElement.autoplay = true;\n this.videoElement.muted = true;\n this.videoElement.style.width = '100%';\n this.videoElement.style.height = '100%';\n this.videoElement.style.objectFit = 'cover';\n // If a container ID is provided, find that element and append the video to it\n if (containerElementId) {\n const container = document.getElementById(containerElementId);\n if (!container) {\n throw new Error(`Container element with ID ${containerElementId} not found`);\n }\n container.appendChild(this.videoElement);\n }\n else {\n // Otherwise, append to body as fallback\n document.body.appendChild(this.videoElement);\n }\n }\n /**\n * Ensures canvas element exists and returns it\n */\n getCanvasElement() {\n if (!this.canvasElement) {\n this.canvasElement = document.createElement('canvas');\n }\n return this.canvasElement;\n }\n /**\n * Format error message\n */\n formatError(err) {\n return err instanceof Error ? err.message : String(err);\n }\n}\n_isRunning = new WeakMap();\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","this","WebPlugin"],"mappings":";;;IACA;IACA;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QAAQ,CAAC,cAAc,CAAC,kBAAkB,CAAC;IACzE,YAAY,IAAI,CAAC,SAAS,EAAE;IAC5B,gBAAgB,MAAM,IAAI,KAAK,CAAC,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC5F;IACA,YAAY,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;IACpD;IACA,aAAa;IACb;IACA,YAAY,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;IACxD;IACA;IACA;IACA;IACA;IACA,IAAI,gBAAgB,GAAG;IACvB,QAAQ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;IACjC,YAAY,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC;IACjE;IACA,QAAQ,OAAO,IAAI,CAAC,aAAa;IACjC;IACA;IACA;IACA;IACA,IAAI,WAAW,CAAC,GAAG,EAAE;IACrB,QAAQ,OAAO,GAAG,YAAY,KAAK,GAAG,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC;IAC/D;IACA;IACA,UAAU,GAAG,IAAI,OAAO,EAAE;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/utils.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n/**\n * The main Capacitor Camera View plugin instance.\n */\nconst CameraView = registerPlugin('CameraView', {\n web: () => import('./web').then((m) => new m.CameraViewWeb()),\n});\nexport * from './definitions';\nexport { CameraView };\n//# sourceMappingURL=index.js.map","/**\n * Converts canvas to base64 string\n */\nexport function canvasToBase64(canvas, quality) {\n const dataUrl = canvas.toDataURL('image/jpeg', quality);\n return dataUrl.split(',')[1];\n}\n/**\n * Calculates the visible area of the video based on object-fit: cover\n */\nexport function calculateVisibleArea(video) {\n // Get the displayed dimensions of the video element\n const videoRect = video.getBoundingClientRect();\n const displayWidth = videoRect.width;\n const displayHeight = videoRect.height;\n // Get the intrinsic dimensions of the video\n const videoWidth = video.videoWidth;\n const videoHeight = video.videoHeight;\n // Calculate which portion of the video is visible (for object-fit: cover)\n const videoAspect = videoWidth / videoHeight;\n const displayAspect = displayWidth / displayHeight;\n let sourceX = 0;\n let sourceY = 0;\n let sourceWidth = videoWidth;\n let sourceHeight = videoHeight;\n // If video aspect ratio is greater than display aspect ratio,\n // the video is cropped on the sides\n if (videoAspect > displayAspect) {\n sourceWidth = videoHeight * displayAspect;\n sourceX = (videoWidth - sourceWidth) / 2;\n }\n // Otherwise the video is cropped on the top and bottom\n else {\n sourceHeight = videoWidth / displayAspect;\n sourceY = (videoHeight - sourceHeight) / 2;\n }\n return {\n sourceX,\n sourceY,\n sourceWidth,\n sourceHeight,\n displayWidth,\n displayHeight,\n };\n}\n/**\n * Draws the visible area of the video to the canvas\n */\nexport function drawVisibleAreaToCanvas(canvas, videoElement, area) {\n const { sourceX, sourceY, sourceWidth, sourceHeight, displayWidth, displayHeight } = area;\n // Set canvas size to match the displayed dimensions\n canvas.width = displayWidth;\n canvas.height = displayHeight;\n const ctx = canvas.getContext('2d', { alpha: false });\n if (!ctx) {\n throw new Error('Could not get canvas context');\n }\n // Draw only the visible portion of the video to match what the user sees\n ctx.drawImage(videoElement, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, displayWidth, displayHeight);\n}\n/**\n * Transforms barcode coordinates from the video source space to display space\n * accounting for object-fit: cover scaling and cropping.\n *\n * @param barcodeBoundingBox The original barcode bounding box from the detector\n * @param videoElement The video element with the camera stream\n * @returns The transformed bounding box coordinates in display space\n */\nexport function transformBarcodeBoundingBox(barcodeBoundingBox, videoElement) {\n // Get the video element's displayed dimensions\n const videoRect = videoElement.getBoundingClientRect();\n const displayWidth = videoRect.width;\n const displayHeight = videoRect.height;\n // Get original video dimensions\n const videoWidth = videoElement.videoWidth;\n const videoHeight = videoElement.videoHeight;\n // Calculate scaling and positioning for object-fit: cover\n const videoAspect = videoWidth / videoHeight;\n const displayAspect = displayWidth / displayHeight;\n let scaledX, scaledY, scaledWidth, scaledHeight;\n if (videoAspect > displayAspect) {\n // Video is wider than display area - height matches, width is centered and cropped\n const scale = displayHeight / videoHeight;\n const scaledVideoWidth = videoWidth * scale;\n const cropX = (scaledVideoWidth - displayWidth) / 2;\n scaledWidth = barcodeBoundingBox.width * scale;\n scaledHeight = barcodeBoundingBox.height * scale;\n scaledX = barcodeBoundingBox.x * scale - cropX;\n scaledY = barcodeBoundingBox.y * scale;\n }\n else {\n // Video is taller than display area - width matches, height is centered and cropped\n const scale = displayWidth / videoWidth;\n const scaledVideoHeight = videoHeight * scale;\n const cropY = (scaledVideoHeight - displayHeight) / 2;\n scaledWidth = barcodeBoundingBox.width * scale;\n scaledHeight = barcodeBoundingBox.height * scale;\n scaledX = barcodeBoundingBox.x * scale;\n scaledY = barcodeBoundingBox.y * scale - cropY;\n }\n return {\n x: scaledX,\n y: scaledY,\n width: scaledWidth,\n height: scaledHeight,\n };\n}\n//# sourceMappingURL=utils.js.map","var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n return privateMap.get(receiver);\n};\nvar __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to set private field on non-instance\");\n }\n privateMap.set(receiver, value);\n return value;\n};\nvar _isRunning;\nimport { WebPlugin } from '@capacitor/core';\nimport { calculateVisibleArea, canvasToBase64, drawVisibleAreaToCanvas, transformBarcodeBoundingBox } from './utils';\n/**\n * Web implementation of the CameraViewPlugin.\n * Optimized for performance and battery efficiency.\n */\nexport class CameraViewWeb extends WebPlugin {\n constructor() {\n super();\n // DOM elements\n this.videoElement = null;\n this.canvasElement = null;\n // Stream state\n this.stream = null;\n _isRunning.set(this, false);\n // Configuration state\n this.currentCamera = 'environment'; // Default to back camera\n this.currentZoom = 1.0;\n this.currentFlashMode = 'off';\n // Barcode detection support\n this.barcodeDetectionSupported = false;\n this.barcodeDetector = null;\n this.checkBarcodeDetectionSupport();\n }\n /**\n * Start the camera with the given configuration\n */\n async start(options) {\n if (__classPrivateFieldGet(this, _isRunning)) {\n return;\n }\n const permissionStatus = await this.requestPermissions();\n if (permissionStatus.camera !== 'granted') {\n throw new Error('Camera permission was not granted');\n }\n try {\n // Set up video element if it doesn't exist\n if (!this.videoElement) {\n await this.setupVideoElement(options === null || options === void 0 ? void 0 : options.containerElementId);\n }\n // Set up video constraints based on options\n const videoConstraints = {};\n // Prefer deviceId if specified\n if (options === null || options === void 0 ? void 0 : options.deviceId) {\n videoConstraints.deviceId = { exact: options.deviceId };\n // Remember the current camera mode (though we're using a specific device)\n this.currentCamera = (options === null || options === void 0 ? void 0 : options.position) === 'front' ? 'user' : 'environment';\n }\n else {\n // Fall back to facing mode\n const facingMode = (options === null || options === void 0 ? void 0 : options.position) === 'front' ? 'user' : 'environment';\n this.currentCamera = facingMode;\n videoConstraints.facingMode = facingMode;\n }\n const constraints = {\n video: videoConstraints,\n audio: false,\n };\n this.stream = await navigator.mediaDevices.getUserMedia(constraints);\n if (this.videoElement) {\n this.videoElement.srcObject = this.stream;\n this.videoElement.play();\n __classPrivateFieldSet(this, _isRunning, true);\n // If barcode detection is enabled and supported, start detection\n if ((options === null || options === void 0 ? void 0 : options.enableBarcodeDetection) && this.barcodeDetectionSupported) {\n this.startBarcodeDetection();\n }\n }\n }\n catch (err) {\n throw new Error(`Failed to start camera: ${this.formatError(err)}`);\n }\n }\n /**\n * Stop the camera and release resources\n */\n async stop() {\n if (!__classPrivateFieldGet(this, _isRunning)) {\n return;\n }\n try {\n // Stop all tracks in the stream\n if (this.stream) {\n this.stream.getTracks().forEach((track) => track.stop());\n this.stream = null;\n }\n // Clear video source\n if (this.videoElement) {\n this.videoElement = null;\n }\n __classPrivateFieldSet(this, _isRunning, false);\n }\n catch (err) {\n throw new Error(`Failed to stop camera: ${this.formatError(err)}`);\n }\n }\n /**\n * Check if the camera is currently running\n */\n async isRunning() {\n return { isRunning: __classPrivateFieldGet(this, _isRunning) };\n }\n /**\n * Capture a photo using the camera and return it as a base64-encoded JPEG image.\n * Preserves what the user actually sees in the UI, including cropping from object-fit: cover.\n */\n async capture(options) {\n const videoElement = this.videoElement;\n if (!__classPrivateFieldGet(this, _isRunning) || !videoElement) {\n throw new Error('Camera is not running');\n }\n try {\n const canvas = this.getCanvasElement();\n const visibleArea = calculateVisibleArea(videoElement);\n drawVisibleAreaToCanvas(canvas, videoElement, visibleArea);\n const quality = Math.min(1.0, Math.max(0.1, options.quality / 100));\n if (options.saveToFile) {\n // Create a blob from canvas and return a blob URL\n return new Promise((resolve, reject) => {\n canvas.toBlob((blob) => {\n if (!blob) {\n reject(new Error('Failed to create blob from canvas'));\n return;\n }\n const url = URL.createObjectURL(blob);\n resolve({ webPath: url });\n }, 'image/jpeg', quality);\n });\n }\n else {\n // Return base64 data\n const base64Data = canvasToBase64(canvas, quality);\n return { photo: base64Data };\n }\n }\n catch (err) {\n throw new Error(`Failed to capture photo: ${this.formatError(err)}`);\n }\n }\n /**\n * Web implementation already uses images from the video stream, so this is the same as `capture()`\n */\n async captureSample(options) {\n return this.capture(options);\n }\n /**\n * Flip between front and back camera\n */\n async flipCamera() {\n if (!__classPrivateFieldGet(this, _isRunning)) {\n throw new Error('Camera is not running');\n }\n try {\n // Switch current camera\n this.currentCamera = this.currentCamera === 'user' ? 'environment' : 'user';\n // Stop current stream\n if (this.stream) {\n this.stream.getTracks().forEach((track) => track.stop());\n }\n // Restart with new facing mode\n const constraints = {\n video: {\n facingMode: this.currentCamera,\n },\n audio: false,\n };\n this.stream = await navigator.mediaDevices.getUserMedia(constraints);\n if (this.videoElement) {\n this.videoElement.srcObject = this.stream;\n }\n }\n catch (err) {\n throw new Error(`Failed to flip camera: ${this.formatError(err)}`);\n }\n }\n /**\n * Get available camera devices\n */\n async getAvailableDevices() {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n const videoDevices = devices.filter((device) => device.kind === 'videoinput');\n return {\n devices: videoDevices.map((device) => ({\n id: device.deviceId,\n name: device.label || `Camera ${device.deviceId.substring(0, 5)}`,\n position: device.label.toLowerCase().includes('front') ? 'front' : 'back',\n })),\n };\n }\n catch (err) {\n console.error('Failed to get available devices', err);\n return { devices: [] };\n }\n }\n /**\n * Get current zoom information (web has limited zoom support)\n */\n async getZoom() {\n // Web has limited zoom capabilities in most browsers,\n // we fake zoomin by scaling the video element\n return {\n min: 1.0,\n max: 3.0,\n current: this.currentZoom,\n };\n }\n /**\n * Set zoom level (limited support in web)\n */\n async setZoom(options) {\n // Store the requested zoom level\n this.currentZoom = options.level;\n // Apply visual zoom using CSS transform when native zoom isn't supported\n if (this.videoElement) {\n this.videoElement.style.transition = options.ramp ? 'transform 0.2s ease-in-out' : 'none';\n const scale = Math.max(1.0, Math.min(options.level, 3.0)); // Limit scale to reasonable bounds\n this.videoElement.style.transform = `scale(${scale})`;\n this.videoElement.style.transformOrigin = 'center';\n }\n }\n /**\n * Get current flash mode\n */\n async getFlashMode() {\n return { flashMode: this.currentFlashMode };\n }\n /**\n * Get supported flash modes\n */\n async getSupportedFlashModes() {\n // Web has limited flash control\n return { flashModes: ['off'] };\n }\n /**\n * Set flash mode (limited support in web)\n */\n async setFlashMode(options) {\n this.currentFlashMode = options.mode;\n console.warn('Flash mode control is not fully supported in the web implementation');\n }\n /**\n * Check camera permission without requesting\n */\n async checkPermissions() {\n try {\n // Use Permissions API if available\n if (navigator.permissions) {\n const result = await navigator.permissions.query({ name: 'camera' });\n return {\n camera: result.state === 'granted' ? 'granted' : result.state === 'denied' ? 'denied' : 'prompt',\n };\n }\n // If Permissions API is not available, check if we have an active stream\n return {\n camera: this.stream ? 'granted' : 'prompt',\n };\n }\n catch (err) {\n // If permissions API is not supported or fails\n return {\n camera: 'prompt',\n };\n }\n }\n /**\n * Request camera permission from the user\n */\n async requestPermissions() {\n try {\n // Try to access the camera to trigger the permission prompt\n const stream = await navigator.mediaDevices.getUserMedia({ video: true });\n // If we get here, permission was granted\n // Clean up the test stream\n stream.getTracks().forEach((track) => track.stop());\n return { camera: 'granted' };\n }\n catch (err) {\n // Permission denied or other error\n return { camera: 'denied' };\n }\n }\n /**\n * Start barcode detection if supported\n */\n async startBarcodeDetection() {\n const barcodeDetector = this.barcodeDetector;\n const videoElement = this.videoElement;\n if (!this.barcodeDetectionSupported || !barcodeDetector || !videoElement) {\n return;\n }\n // Make sure video is fully loaded before starting detection\n if (videoElement.readyState < 2) {\n await new Promise((resolve) => {\n const loadHandler = () => {\n videoElement.removeEventListener('loadeddata', loadHandler);\n resolve();\n };\n videoElement.addEventListener('loadeddata', loadHandler);\n });\n }\n // Add throttling to reduce CPU usage\n let lastDetectionTime = 0;\n const minTimeBetweenDetections = 100; // ms\n // Set up periodic frame analysis for barcode detection\n const detectFrame = async () => {\n if (!__classPrivateFieldGet(this, _isRunning) || !videoElement || !barcodeDetector) {\n return;\n }\n const now = Date.now();\n if (now - lastDetectionTime >= minTimeBetweenDetections) {\n try {\n const barcodes = await barcodeDetector.detect(videoElement);\n lastDetectionTime = now;\n if (barcodes.length > 0) {\n const barcode = barcodes[0];\n // Transform barcode coordinates using the utility function\n const boundingRect = transformBarcodeBoundingBox(barcode.boundingBox, videoElement);\n this.notifyListeners('barcodeDetected', {\n value: barcode.rawValue,\n type: barcode.format.toLowerCase(),\n boundingRect,\n });\n }\n }\n catch (err) {\n console.error('Barcode detection error', err);\n }\n }\n if (__classPrivateFieldGet(this, _isRunning)) {\n requestAnimationFrame(detectFrame);\n }\n };\n requestAnimationFrame(detectFrame);\n }\n /**\n * Clean up resources when the plugin is disposed\n */\n async handleOnDestroy() {\n var _a;\n await this.stop();\n // Remove elements from DOM\n if ((_a = this.videoElement) === null || _a === void 0 ? void 0 : _a.parentNode) {\n this.videoElement.parentNode.removeChild(this.videoElement);\n this.videoElement = null;\n }\n if (this.canvasElement) {\n this.canvasElement = null;\n }\n this.barcodeDetector = null;\n }\n /**\n * Check if barcode detection is supported in this browser\n */\n async checkBarcodeDetectionSupport() {\n if ('BarcodeDetector' in window) {\n try {\n this.barcodeDetector = new BarcodeDetector();\n this.barcodeDetectionSupported = true;\n }\n catch (e) {\n console.warn('BarcodeDetector is not supported by this browser.');\n this.barcodeDetectionSupported = false;\n }\n }\n }\n /**\n * Set up the video element for the camera view\n */\n async setupVideoElement(containerElementId) {\n this.videoElement = document.createElement('video');\n this.videoElement.playsInline = true;\n this.videoElement.autoplay = true;\n this.videoElement.muted = true;\n this.videoElement.style.width = '100%';\n this.videoElement.style.height = '100%';\n this.videoElement.style.objectFit = 'cover';\n // If a container ID is provided, find that element and append the video to it\n if (containerElementId) {\n const container = document.getElementById(containerElementId);\n if (!container) {\n throw new Error(`Container element with ID ${containerElementId} not found`);\n }\n container.appendChild(this.videoElement);\n }\n else {\n // Otherwise, append to body as fallback\n document.body.appendChild(this.videoElement);\n }\n }\n /**\n * Ensures canvas element exists and returns it\n */\n getCanvasElement() {\n if (!this.canvasElement) {\n this.canvasElement = document.createElement('canvas');\n }\n return this.canvasElement;\n }\n /**\n * Format error message\n */\n formatError(err) {\n return err instanceof Error ? err.message : String(err);\n }\n}\n_isRunning = new WeakMap();\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","this","WebPlugin"],"mappings":";;;IACA;IACA;IACA;AACK,UAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;IAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;IACjE,CAAC;;ICND;IACA;IACA;IACO,SAAS,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE;IAChD,IAAI,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC;IAC3D,IAAI,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;I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QAAQ;IACR,QAAQ,OAAO,IAAI,CAAC,aAAa;IACjC,IAAI;IACJ;IACA;IACA;IACA,IAAI,WAAW,CAAC,GAAG,EAAE;IACrB,QAAQ,OAAO,GAAG,YAAY,KAAK,GAAG,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC;IAC/D,IAAI;IACJ;IACA,UAAU,GAAG,IAAI,OAAO,EAAE;;;;;;;;;;;;;;;"}
@@ -18,7 +18,7 @@ public func sessionConfigFromPluginCall(_ call: CAPPluginCall) -> CameraSessionC
18
18
  let enableBarcodeDetection = call.getBool("enableBarcodeDetection", false)
19
19
  let position: AVCaptureDevice.Position = call.getString("position") == "front" ? .front : .back
20
20
  let preferredCameraDeviceTypes = call.getArray("preferredCameraDeviceTypes") as? [String]
21
- let useTripleCameraIfAvailable = call.getBool("useTripleCameraIfAvailable", false)
21
+ let useTripleCameraIfAvailable = call.getBool("useTripleCameraIfAvailable", false)
22
22
  let zoomFactor = call.getDouble("zoomFactor").map { CGFloat($0) }
23
23
 
24
24
  return CameraSessionConfiguration(
@@ -36,7 +36,7 @@ extension CameraViewManager: AVCaptureMetadataOutputObjectsDelegate {
36
36
  .pdf417,
37
37
  .aztec,
38
38
  .dataMatrix,
39
- .upce,
39
+ .upce
40
40
  ]
41
41
  }
42
42
 
@@ -67,15 +67,15 @@ extension CameraViewManager: AVCaptureMetadataOutputObjectsDelegate {
67
67
  // Which in our case should always equal to the device's screen
68
68
  // This way we can simply use pixel coordinates to get the bounding box of the detected barcode and easily show it in the webview
69
69
  guard let transformedMetadataObject = videoPreviewLayer.transformedMetadataObject(for: metadataObject)
70
- else {
71
- return
70
+ else {
71
+ return
72
72
  }
73
73
 
74
74
  let boundingRect: [String: Double] = [
75
75
  "x": Double(transformedMetadataObject.bounds.origin.x),
76
76
  "y": Double(transformedMetadataObject.bounds.origin.y),
77
77
  "width": Double(transformedMetadataObject.bounds.width),
78
- "height": Double(transformedMetadataObject.bounds.height),
78
+ "height": Double(transformedMetadataObject.bounds.height)
79
79
  ]
80
80
 
81
81
  NotificationCenter.default.post(
@@ -84,7 +84,7 @@ extension CameraViewManager: AVCaptureMetadataOutputObjectsDelegate {
84
84
  userInfo: [
85
85
  "value": barcodeValue,
86
86
  "type": barcodeType,
87
- "boundingRect": boundingRect,
87
+ "boundingRect": boundingRect
88
88
  ]
89
89
  )
90
90
  }
@@ -49,4 +49,3 @@ extension CameraViewManager: AVCapturePhotoCaptureDelegate {
49
49
  }
50
50
 
51
51
  }
52
-
@@ -10,7 +10,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
10
10
  .builtInDualCamera,
11
11
  .builtInDualWideCamera,
12
12
  .builtInTripleCamera,
13
- .builtInTrueDepthCamera,
13
+ .builtInTrueDepthCamera
14
14
  ]
15
15
 
16
16
  /// A camera implementation that handles camera session management and photo capture.
@@ -41,7 +41,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
41
41
  /// Callback for when snapshot capture completes.
42
42
  internal var snapshotCompletionHandler: ((UIImage?, Error?) -> Void)?
43
43
 
44
- public override init() {
44
+ override public init() {
45
45
  super.init()
46
46
  setupOrientationObserver()
47
47
  setupAppLifecycleObservers()
@@ -52,7 +52,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
52
52
  NotificationCenter.default.removeObserver(self)
53
53
  }
54
54
 
55
- /// MARK: - Plugin API
55
+ // MARK: - Plugin API
56
56
 
57
57
  /// Starts capture session for the specified camera position.
58
58
  /// This will reuse the existing capture session if it is already running.
@@ -152,7 +152,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
152
152
 
153
153
  // Ensure proper orientation
154
154
  if let photoConnection = avPhotoOutput.connection(with: .video),
155
- let previewConnection = videoPreviewLayer.connection {
155
+ let previewConnection = videoPreviewLayer.connection {
156
156
  if photoConnection.isVideoOrientationSupported {
157
157
  photoConnection.videoOrientation = previewConnection.videoOrientation
158
158
  }
@@ -178,7 +178,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
178
178
 
179
179
  // Ensure proper orientation
180
180
  if let videoConnection = avVideoDataOutput.connection(with: .video),
181
- let previewConnection = videoPreviewLayer.connection {
181
+ let previewConnection = videoPreviewLayer.connection {
182
182
  if videoConnection.isVideoOrientationSupported {
183
183
  videoConnection.videoOrientation = previewConnection.videoOrientation
184
184
  }
@@ -371,7 +371,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
371
371
  /// Returns a list of available camera devices based on the preferences by the user
372
372
  ///
373
373
  /// - Returns: a list of camera devices based on the preferredCameraDeviceTypes
374
- private func getPreferredCameraDevices() -> [AVCaptureDevice] {
374
+ private func getPreferredCameraDevices() -> [AVCaptureDevice] {
375
375
  return AVCaptureDevice.DiscoverySession(
376
376
  deviceTypes: self.preferredCameraDeviceTypes,
377
377
  mediaType: .video,
@@ -387,8 +387,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
387
387
  /// - position: The position of the camera device to get
388
388
  /// - Returns: The camera device for the specified position
389
389
  /// - Throws: An error if no camera device is found.
390
- private func getCameraDevice(for position: AVCaptureDevice.Position?) throws -> AVCaptureDevice
391
- {
390
+ private func getCameraDevice(for position: AVCaptureDevice.Position?) throws -> AVCaptureDevice {
392
391
  let preferredDevices = getPreferredCameraDevices()
393
392
 
394
393
  // First try to get the best match based on the users preferred camera device types
@@ -430,7 +429,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
430
429
  return device
431
430
  }
432
431
 
433
- /// MARK: - UI Preview Layer
432
+ // MARK: - UI Preview Layer
434
433
 
435
434
  /// Sets up the preview layer for the capture session which will
436
435
  /// display the camera feed in the view.
@@ -465,7 +464,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
465
464
  }
466
465
  }
467
466
 
468
- /// MARK: - Triple Camera
467
+ // MARK: - Triple Camera
469
468
 
470
469
  /// Upgrades the camera to the triple camera if available.
471
470
  /// Initializing the triple camera is an expensive operation and takes some time.
@@ -549,7 +548,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
549
548
  }
550
549
  }
551
550
 
552
- /// MARK: - Orientation Observer
551
+ // MARK: - Orientation Observer
553
552
 
554
553
  /// Sets up an observer for device orientation changes to update the preview layer orientation.
555
554
  private func setupOrientationObserver() {
@@ -593,7 +592,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
593
592
  }
594
593
  }
595
594
 
596
- /// MARK: - App Lifecycle Observers
595
+ // MARK: - App Lifecycle Observers
597
596
 
598
597
  /// Sets up observers for app lifecycle events to pause and resume the camera session.
599
598
  private func setupAppLifecycleObservers() {
@@ -13,14 +13,14 @@ public class CameraViewPlugin: CAPPlugin, CAPBridgedPlugin {
13
13
  private let strToFlashModeMap: [String: AVCaptureDevice.FlashMode] = [
14
14
  "off": .off,
15
15
  "on": .on,
16
- "auto": .auto,
16
+ "auto": .auto
17
17
  ]
18
18
 
19
19
  /// Maps AVCaptureDevice.FlashMode enum values to string values.
20
20
  private let flashModeToStrMap: [AVCaptureDevice.FlashMode: String] = [
21
21
  .off: "off",
22
22
  .on: "on",
23
- .auto: "auto",
23
+ .auto: "auto"
24
24
  ]
25
25
 
26
26
  public let pluginMethods: [CAPPluginMethod] = [
@@ -37,7 +37,7 @@ public class CameraViewPlugin: CAPPlugin, CAPBridgedPlugin {
37
37
  CAPPluginMethod(name: "getSupportedFlashModes", returnType: CAPPluginReturnPromise),
38
38
  CAPPluginMethod(name: "setFlashMode", returnType: CAPPluginReturnPromise),
39
39
  CAPPluginMethod(name: "checkPermissions", returnType: CAPPluginReturnPromise),
40
- CAPPluginMethod(name: "requestPermissions", returnType: CAPPluginReturnPromise),
40
+ CAPPluginMethod(name: "requestPermissions", returnType: CAPPluginReturnPromise)
41
41
  ]
42
42
 
43
43
  private let implementation = CameraViewManager()
@@ -104,6 +104,7 @@ public class CameraViewPlugin: CAPPlugin, CAPBridgedPlugin {
104
104
 
105
105
  @objc func capture(_ call: CAPPluginCall) {
106
106
  let quality = call.getDouble("quality", 90.0)
107
+ let saveToFile = call.getBool("saveToFile", false)
107
108
 
108
109
  guard quality >= 0.0 && quality <= 100.0 else {
109
110
  call.reject("Quality must be between 0 and 100")
@@ -117,48 +118,85 @@ public class CameraViewPlugin: CAPPlugin, CAPBridgedPlugin {
117
118
  }
118
119
 
119
120
  guard let image = image else {
120
- call.reject("No image data", nil, nil)
121
+ call.reject("No image data")
121
122
  return
122
123
  }
123
124
 
124
125
  guard let imageData = image.jpegData(compressionQuality: quality / 100.0) else {
125
- call.reject("Failed to compress image", nil, nil)
126
+ call.reject("Failed to compress image")
126
127
  return
127
128
  }
128
129
 
129
- call.resolve([
130
- "photo": imageData.base64EncodedString()
131
- ])
130
+ if saveToFile {
131
+ do {
132
+ let tempFileURL = try createTempImageFile()
133
+ try imageData.write(to: tempFileURL)
134
+
135
+ // Convert file URL to webView-accessible path using Capacitor bridge
136
+ guard let webPath = self.bridge?.portablePath(fromLocalURL: tempFileURL)?.absoluteString else {
137
+ call.reject("Failed to create web-accessible path")
138
+ return
139
+ }
140
+
141
+ call.resolve(["webPath": webPath])
142
+ } catch {
143
+ call.reject("Failed to save image to file", nil, error)
144
+ }
145
+ } else {
146
+ // Return as base64
147
+ call.resolve([
148
+ "photo": imageData.base64EncodedString()
149
+ ])
150
+ }
132
151
  })
133
152
  }
134
153
 
135
154
  @objc func captureSample(_ call: CAPPluginCall) {
136
155
  let quality = call.getDouble("quality", 90.0)
156
+ let saveToFile = call.getBool("saveToFile", false)
137
157
 
138
158
  guard quality >= 0.0 && quality <= 100.0 else {
139
159
  call.reject("Quality must be between 0 and 100")
140
160
  return
141
161
  }
142
162
 
143
- implementation.captureSnapshot() { (image, error) in
163
+ implementation.captureSnapshot { (image, error) in
144
164
  if let error = error {
145
165
  call.reject("Failed to capture frame", nil, error)
146
166
  return
147
167
  }
148
168
 
149
169
  guard let image = image else {
150
- call.reject("No frame data", nil, nil)
170
+ call.reject("No frame data")
151
171
  return
152
172
  }
153
173
 
154
174
  guard let imageData = image.jpegData(compressionQuality: quality / 100.0) else {
155
- call.reject("Failed to compress image", nil, nil)
175
+ call.reject("Failed to compress image")
156
176
  return
157
177
  }
158
178
 
159
- call.resolve([
160
- "photo": imageData.base64EncodedString()
161
- ])
179
+ if saveToFile {
180
+ do {
181
+ let tempFileURL = try createTempImageFile()
182
+ try imageData.write(to: tempFileURL)
183
+
184
+ // Convert file URL to webView-accessible path using Capacitor bridge
185
+ guard let webPath = self.bridge?.portablePath(fromLocalURL: tempFileURL)?.absoluteString else {
186
+ call.reject("Failed to create web-accessible path")
187
+ return
188
+ }
189
+
190
+ call.resolve(["webPath": webPath])
191
+ } catch {
192
+ call.reject("Failed to save sample to file", nil, error)
193
+ }
194
+ } else {
195
+ // Return as base64
196
+ call.resolve([
197
+ "photo": imageData.base64EncodedString()
198
+ ])
199
+ }
162
200
  }
163
201
  }
164
202
 
@@ -196,7 +234,7 @@ public class CameraViewPlugin: CAPPlugin, CAPBridgedPlugin {
196
234
  call.resolve([
197
235
  "min": zoom.min,
198
236
  "max": zoom.max,
199
- "current": zoom.current,
237
+ "current": zoom.current
200
238
  ])
201
239
  }
202
240
 
@@ -54,3 +54,11 @@ public func convertToStringCameraType(_ deviceType: AVCaptureDevice.DeviceType)
54
54
  public func convertToNativeCameraTypes(_ stringTypes: [String]) -> [AVCaptureDevice.DeviceType] {
55
55
  return stringTypes.compactMap { convertToNativeCameraType($0) }
56
56
  }
57
+
58
+ /// Creates a temporary file URL for storing captured images
59
+ public func createTempImageFile() throws -> URL {
60
+ let timestamp = Int(Date().timeIntervalSince1970 * 1000)
61
+ let fileName = "camera_capture_\(timestamp).jpg"
62
+ let tempDir = FileManager.default.temporaryDirectory
63
+ return tempDir.appendingPathComponent(fileName)
64
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-camera-view",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "A Capacitor plugin for embedding a live camera feed directly into your app.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -48,10 +48,10 @@
48
48
  "prepublishOnly": "npm run build"
49
49
  },
50
50
  "devDependencies": {
51
- "@capacitor/android": "^7.3.0",
52
- "@capacitor/core": "^7.3.0",
51
+ "@capacitor/android": "^7.4.2",
52
+ "@capacitor/core": "^7.4.2",
53
53
  "@capacitor/docgen": "^0.3.0",
54
- "@capacitor/ios": "^7.3.0",
54
+ "@capacitor/ios": "^7.4.2",
55
55
  "@commitlint/config-conventional": "^19.8.1",
56
56
  "@ionic/eslint-config": "^0.4.0",
57
57
  "@ionic/prettier-config": "^4.0.0",
@@ -60,18 +60,19 @@
60
60
  "@semantic-release/commit-analyzer": "^13.0.1",
61
61
  "@semantic-release/git": "^10.0.1",
62
62
  "@semantic-release/github": "^11.0.3",
63
- "@semantic-release/npm": "^12.0.1",
63
+ "@semantic-release/npm": "^12.0.2",
64
64
  "@semantic-release/release-notes-generator": "^14.0.3",
65
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
65
66
  "commitlint": "^19.8.1",
66
67
  "eslint": "^8.57.0",
67
68
  "husky": "^9.1.7",
68
- "prettier": "^3.5.3",
69
- "prettier-plugin-java": "^2.6.8",
69
+ "prettier": "^3.6.2",
70
+ "prettier-plugin-java": "^2.7.3",
70
71
  "prettier-plugin-organize-imports": "^4.1.0",
71
- "prettier-plugin-packagejson": "^2.5.15",
72
+ "prettier-plugin-packagejson": "^2.5.18",
72
73
  "rimraf": "^6.0.1",
73
- "rollup": "^4.41.1",
74
- "semantic-release": "^24.2.5",
74
+ "rollup": "^4.45.1",
75
+ "semantic-release": "^24.2.7",
75
76
  "swiftlint": "^2.0.0",
76
77
  "typescript": "~4.1.5"
77
78
  },