Browse Source

chore(deps): Add Capacitor camera and filesystem plugins

- Add @capacitor/camera@6.0.0 for cross-platform photo capture
- Add @capacitor/filesystem@6.0.0 for file system operations
- Maintain compatibility with existing Capacitor core v6.2.1

These plugins enable native camera access and file system operations
for the Capacitor platform implementation.
cross-platform-factory
Matthew Raymer 3 months ago
parent
commit
073ce24f43
  1. 20
      package-lock.json
  2. 2
      package.json
  3. 30
      src/components/PhotoDialog.vue
  4. 6
      src/services/platforms/CapacitorPlatformService.ts
  5. 10
      src/services/platforms/ElectronPlatformService.ts
  6. 10
      src/services/platforms/PyWebViewPlatformService.ts
  7. 10
      src/services/platforms/WebPlatformService.ts

20
package-lock.json

@ -10,8 +10,10 @@
"dependencies": { "dependencies": {
"@capacitor/android": "^6.2.0", "@capacitor/android": "^6.2.0",
"@capacitor/app": "^6.0.0", "@capacitor/app": "^6.0.0",
"@capacitor/camera": "^6.0.0",
"@capacitor/cli": "^6.2.0", "@capacitor/cli": "^6.2.0",
"@capacitor/core": "^6.2.0", "@capacitor/core": "^6.2.0",
"@capacitor/filesystem": "^6.0.0",
"@capacitor/ios": "^6.2.0", "@capacitor/ios": "^6.2.0",
"@dicebear/collection": "^5.4.1", "@dicebear/collection": "^5.4.1",
"@dicebear/core": "^5.4.1", "@dicebear/core": "^5.4.1",
@ -2768,6 +2770,15 @@
"url": "https://github.com/sponsors/isaacs" "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": { "node_modules/@capacitor/cli": {
"version": "6.2.1", "version": "6.2.1",
"resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-6.2.1.tgz", "resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-6.2.1.tgz",
@ -2878,6 +2889,15 @@
"tslib": "^2.1.0" "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": { "node_modules/@capacitor/ios": {
"version": "6.2.1", "version": "6.2.1",
"resolved": "https://registry.npmjs.org/@capacitor/ios/-/ios-6.2.1.tgz", "resolved": "https://registry.npmjs.org/@capacitor/ios/-/ios-6.2.1.tgz",

2
package.json

@ -44,8 +44,10 @@
"dependencies": { "dependencies": {
"@capacitor/android": "^6.2.0", "@capacitor/android": "^6.2.0",
"@capacitor/app": "^6.0.0", "@capacitor/app": "^6.0.0",
"@capacitor/camera": "^6.0.0",
"@capacitor/cli": "^6.2.0", "@capacitor/cli": "^6.2.0",
"@capacitor/core": "^6.2.0", "@capacitor/core": "^6.2.0",
"@capacitor/filesystem": "^6.0.0",
"@capacitor/ios": "^6.2.0", "@capacitor/ios": "^6.2.0",
"@dicebear/collection": "^5.4.1", "@dicebear/collection": "^5.4.1",
"@dicebear/core": "^5.4.1", "@dicebear/core": "^5.4.1",

30
src/components/PhotoDialog.vue

@ -186,12 +186,15 @@ export default class PhotoDialog extends Vue {
this.fileName = result.fileName; this.fileName = result.fileName;
} catch (error) { } catch (error) {
logger.error("Error taking picture:", error); logger.error("Error taking picture:", error);
this.$notify({ this.$notify(
group: "alert", {
type: "danger", group: "alert",
title: "Error", type: "danger",
text: "Failed to take picture. Please try again.", title: "Error",
}, 5000); text: "Failed to take picture. Please try again.",
},
5000,
);
} }
} }
@ -202,12 +205,15 @@ export default class PhotoDialog extends Vue {
this.fileName = result.fileName; this.fileName = result.fileName;
} catch (error) { } catch (error) {
logger.error("Error picking image:", error); logger.error("Error picking image:", error);
this.$notify({ this.$notify(
group: "alert", {
type: "danger", group: "alert",
title: "Error", type: "danger",
text: "Failed to pick image. Please try again.", title: "Error",
}, 5000); text: "Failed to pick image. Please try again.",
},
5000,
);
} }
} }

6
src/services/platforms/CapacitorPlatformService.ts

@ -49,7 +49,7 @@ export class CapacitorPlatformService implements PlatformService {
const blob = await this.processImageData(image.base64String); const blob = await this.processImageData(image.base64String);
return { return {
blob, blob,
fileName: `photo_${Date.now()}.${image.format || 'jpg'}` fileName: `photo_${Date.now()}.${image.format || "jpg"}`,
}; };
} catch (error) { } catch (error) {
logger.error("Error taking picture with Capacitor:", 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); const blob = await this.processImageData(image.base64String);
return { return {
blob, blob,
fileName: `photo_${Date.now()}.${image.format || 'jpg'}` fileName: `photo_${Date.now()}.${image.format || "jpg"}`,
}; };
} catch (error) { } catch (error) {
logger.error("Error picking image with Capacitor:", error); logger.error("Error picking image with Capacitor:", error);
@ -94,7 +94,7 @@ export class CapacitorPlatformService implements PlatformService {
const byteArray = new Uint8Array(byteNumbers); const byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray); byteArrays.push(byteArray);
} }
return new Blob(byteArrays, { type: 'image/jpeg' }); return new Blob(byteArrays, { type: "image/jpeg" });
} }
isCapacitor(): boolean { isCapacitor(): boolean {

10
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 { export class ElectronPlatformService implements PlatformService {
async readFile(path: string): Promise<string> { async readFile(path: string): Promise<string> {
@ -17,11 +18,13 @@ export class ElectronPlatformService implements PlatformService {
throw new Error("Not implemented"); 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"); 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"); throw new Error("Not implemented");
} }
@ -42,6 +45,7 @@ export class ElectronPlatformService implements PlatformService {
} }
async handleDeepLink(url: string): Promise<void> { async handleDeepLink(url: string): Promise<void> {
logger.error("handleDeepLink not implemented in Electron platform");
throw new Error("Not implemented"); throw new Error("Not implemented");
} }
} }

10
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 { export class PyWebViewPlatformService implements PlatformService {
async readFile(path: string): Promise<string> { async readFile(path: string): Promise<string> {
@ -17,11 +18,13 @@ export class PyWebViewPlatformService implements PlatformService {
throw new Error("Not implemented"); 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"); 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"); throw new Error("Not implemented");
} }
@ -42,6 +45,7 @@ export class PyWebViewPlatformService implements PlatformService {
} }
async handleDeepLink(url: string): Promise<void> { async handleDeepLink(url: string): Promise<void> {
logger.error("handleDeepLink not implemented in PyWebView platform");
throw new Error("Not implemented"); throw new Error("Not implemented");
} }
} }

10
src/services/platforms/WebPlatformService.ts

@ -32,7 +32,7 @@ export class WebPlatformService implements PlatformService {
const blob = await this.processImageFile(file); const blob = await this.processImageFile(file);
resolve({ resolve({
blob, blob,
fileName: file.name || "photo.jpg" fileName: file.name || "photo.jpg",
}); });
} catch (error) { } catch (error) {
logger.error("Error processing camera image:", error); logger.error("Error processing camera image:", error);
@ -60,7 +60,7 @@ export class WebPlatformService implements PlatformService {
const blob = await this.processImageFile(file); const blob = await this.processImageFile(file);
resolve({ resolve({
blob, blob,
fileName: file.name || "photo.jpg" fileName: file.name || "photo.jpg",
}); });
} catch (error) { } catch (error) {
logger.error("Error processing picked image:", error); logger.error("Error processing picked image:", error);
@ -82,9 +82,9 @@ export class WebPlatformService implements PlatformService {
const dataUrl = event.target?.result as string; const dataUrl = event.target?.result as string;
// Convert to blob to ensure consistent format // Convert to blob to ensure consistent format
fetch(dataUrl) fetch(dataUrl)
.then(res => res.blob()) .then((res) => res.blob())
.then(blob => resolve(blob)) .then((blob) => resolve(blob))
.catch(error => { .catch((error) => {
logger.error("Error converting data URL to blob:", error); logger.error("Error converting data URL to blob:", error);
reject(error); reject(error);
}); });

Loading…
Cancel
Save