diff --git a/package-lock.json b/package-lock.json index d5624b3e..aad6ee8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,10 @@ "dependencies": { "@capacitor/android": "^6.2.0", "@capacitor/app": "^6.0.0", + "@capacitor/camera": "^6.0.0", "@capacitor/cli": "^6.2.0", "@capacitor/core": "^6.2.0", + "@capacitor/filesystem": "^6.0.0", "@capacitor/ios": "^6.2.0", "@dicebear/collection": "^5.4.1", "@dicebear/core": "^5.4.1", @@ -2768,6 +2770,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@capacitor/camera": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@capacitor/camera/-/camera-6.0.0.tgz", + "integrity": "sha512-AZ/gfVPC3lsKbk9/yHI60ygNyOkN5jsCb4bHxXFbW0bss3XYtR/J1XWFJGkFNiRErNnTz6jnDrhsGCr7+JPfiA==", + "license": "MIT", + "peerDependencies": { + "@capacitor/core": "^6.0.0" + } + }, "node_modules/@capacitor/cli": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-6.2.1.tgz", @@ -2878,6 +2889,15 @@ "tslib": "^2.1.0" } }, + "node_modules/@capacitor/filesystem": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@capacitor/filesystem/-/filesystem-6.0.0.tgz", + "integrity": "sha512-GnC4CBfky7fvG9zSV/aQnZaGs6ZJ90AaQorr53z81ArTCqcrSUeBMuCxWmvti9HrdXLhBavyA1UOjvRGObOFjg==", + "license": "MIT", + "peerDependencies": { + "@capacitor/core": "^6.0.0" + } + }, "node_modules/@capacitor/ios": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/@capacitor/ios/-/ios-6.2.1.tgz", diff --git a/package.json b/package.json index 2a7e5e37..78e4eaec 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,10 @@ "dependencies": { "@capacitor/android": "^6.2.0", "@capacitor/app": "^6.0.0", + "@capacitor/camera": "^6.0.0", "@capacitor/cli": "^6.2.0", "@capacitor/core": "^6.2.0", + "@capacitor/filesystem": "^6.0.0", "@capacitor/ios": "^6.2.0", "@dicebear/collection": "^5.4.1", "@dicebear/core": "^5.4.1", diff --git a/src/components/PhotoDialog.vue b/src/components/PhotoDialog.vue index 9ffba49e..79e937a9 100644 --- a/src/components/PhotoDialog.vue +++ b/src/components/PhotoDialog.vue @@ -92,10 +92,10 @@ <script lang="ts"> /** * PhotoDialog.vue - Cross-platform photo capture and selection component - * + * * This component provides a unified interface for taking photos and selecting images * across different platforms using the PlatformService. - * + * * @author Matthew Raymer * @file PhotoDialog.vue */ @@ -186,12 +186,15 @@ export default class PhotoDialog extends Vue { this.fileName = result.fileName; } catch (error) { logger.error("Error taking picture:", error); - this.$notify({ - group: "alert", - type: "danger", - title: "Error", - text: "Failed to take picture. Please try again.", - }, 5000); + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: "Failed to take picture. Please try again.", + }, + 5000, + ); } } @@ -202,12 +205,15 @@ export default class PhotoDialog extends Vue { this.fileName = result.fileName; } catch (error) { logger.error("Error picking image:", error); - this.$notify({ - group: "alert", - type: "danger", - title: "Error", - text: "Failed to pick image. Please try again.", - }, 5000); + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: "Failed to pick image. Please try again.", + }, + 5000, + ); } } diff --git a/src/services/platforms/CapacitorPlatformService.ts b/src/services/platforms/CapacitorPlatformService.ts index ad232f3a..f4c62995 100644 --- a/src/services/platforms/CapacitorPlatformService.ts +++ b/src/services/platforms/CapacitorPlatformService.ts @@ -49,7 +49,7 @@ export class CapacitorPlatformService implements PlatformService { const blob = await this.processImageData(image.base64String); return { blob, - fileName: `photo_${Date.now()}.${image.format || 'jpg'}` + fileName: `photo_${Date.now()}.${image.format || "jpg"}`, }; } catch (error) { logger.error("Error taking picture with Capacitor:", error); @@ -69,7 +69,7 @@ export class CapacitorPlatformService implements PlatformService { const blob = await this.processImageData(image.base64String); return { blob, - fileName: `photo_${Date.now()}.${image.format || 'jpg'}` + fileName: `photo_${Date.now()}.${image.format || "jpg"}`, }; } catch (error) { logger.error("Error picking image with Capacitor:", error); @@ -94,7 +94,7 @@ export class CapacitorPlatformService implements PlatformService { const byteArray = new Uint8Array(byteNumbers); byteArrays.push(byteArray); } - return new Blob(byteArrays, { type: 'image/jpeg' }); + return new Blob(byteArrays, { type: "image/jpeg" }); } isCapacitor(): boolean { diff --git a/src/services/platforms/ElectronPlatformService.ts b/src/services/platforms/ElectronPlatformService.ts index 00d41174..10bd14fa 100644 --- a/src/services/platforms/ElectronPlatformService.ts +++ b/src/services/platforms/ElectronPlatformService.ts @@ -1,4 +1,5 @@ -import { PlatformService } from "../PlatformService"; +import { ImageResult, PlatformService } from "../PlatformService"; +import { logger } from "../../utils/logger"; export class ElectronPlatformService implements PlatformService { async readFile(path: string): Promise<string> { @@ -17,11 +18,13 @@ export class ElectronPlatformService implements PlatformService { throw new Error("Not implemented"); } - async takePicture(): Promise<string> { + async takePicture(): Promise<ImageResult> { + logger.error("takePicture not implemented in Electron platform"); throw new Error("Not implemented"); } - async pickImage(): Promise<string> { + async pickImage(): Promise<ImageResult> { + logger.error("pickImage not implemented in Electron platform"); throw new Error("Not implemented"); } @@ -42,6 +45,7 @@ export class ElectronPlatformService implements PlatformService { } async handleDeepLink(url: string): Promise<void> { + logger.error("handleDeepLink not implemented in Electron platform"); throw new Error("Not implemented"); } } diff --git a/src/services/platforms/PyWebViewPlatformService.ts b/src/services/platforms/PyWebViewPlatformService.ts index 907241fe..ad3dc53b 100644 --- a/src/services/platforms/PyWebViewPlatformService.ts +++ b/src/services/platforms/PyWebViewPlatformService.ts @@ -1,4 +1,5 @@ -import { PlatformService } from "../PlatformService"; +import { ImageResult, PlatformService } from "../PlatformService"; +import { logger } from "../../utils/logger"; export class PyWebViewPlatformService implements PlatformService { async readFile(path: string): Promise<string> { @@ -17,11 +18,13 @@ export class PyWebViewPlatformService implements PlatformService { throw new Error("Not implemented"); } - async takePicture(): Promise<string> { + async takePicture(): Promise<ImageResult> { + logger.error("takePicture not implemented in PyWebView platform"); throw new Error("Not implemented"); } - async pickImage(): Promise<string> { + async pickImage(): Promise<ImageResult> { + logger.error("pickImage not implemented in PyWebView platform"); throw new Error("Not implemented"); } @@ -42,6 +45,7 @@ export class PyWebViewPlatformService implements PlatformService { } async handleDeepLink(url: string): Promise<void> { + logger.error("handleDeepLink not implemented in PyWebView platform"); throw new Error("Not implemented"); } } diff --git a/src/services/platforms/WebPlatformService.ts b/src/services/platforms/WebPlatformService.ts index 9ae1de83..73220c25 100644 --- a/src/services/platforms/WebPlatformService.ts +++ b/src/services/platforms/WebPlatformService.ts @@ -32,7 +32,7 @@ export class WebPlatformService implements PlatformService { const blob = await this.processImageFile(file); resolve({ blob, - fileName: file.name || "photo.jpg" + fileName: file.name || "photo.jpg", }); } catch (error) { logger.error("Error processing camera image:", error); @@ -60,7 +60,7 @@ export class WebPlatformService implements PlatformService { const blob = await this.processImageFile(file); resolve({ blob, - fileName: file.name || "photo.jpg" + fileName: file.name || "photo.jpg", }); } catch (error) { logger.error("Error processing picked image:", error); @@ -82,9 +82,9 @@ export class WebPlatformService implements PlatformService { const dataUrl = event.target?.result as string; // Convert to blob to ensure consistent format fetch(dataUrl) - .then(res => res.blob()) - .then(blob => resolve(blob)) - .catch(error => { + .then((res) => res.blob()) + .then((blob) => resolve(blob)) + .catch((error) => { logger.error("Error converting data URL to blob:", error); reject(error); });