refactor(platform): replace platform checks with capability-based system

- Add PlatformCapabilities interface to define available features
- Remove isWeb(), isCapacitor(), isElectron(), isPyWebView() methods
- Update platform services to implement getCapabilities()
- Refactor DataExportSection to use capability checks instead of platform checks
- Improve platform abstraction and separation of concerns
- Make platform-specific logic more maintainable and extensible

This change decouples components from specific platform implementations,
making the codebase more maintainable and easier to extend with new platforms.
This commit is contained in:
Matthew Raymer
2025-04-08 11:29:39 +00:00
parent 4853d0a7d0
commit 08fcccc528
8 changed files with 105 additions and 152 deletions

View File

@@ -1,4 +1,4 @@
import { ImageResult, PlatformService } from "../PlatformService";
import { ImageResult, PlatformService, PlatformCapabilities } from "../PlatformService";
import { logger } from "../../utils/logger";
/**
@@ -15,6 +15,21 @@ import { logger } from "../../utils/logger";
* due to browser security restrictions. These methods throw appropriate errors.
*/
export class WebPlatformService implements PlatformService {
/**
* Gets the capabilities of the web platform
* @returns Platform capabilities object
*/
getCapabilities(): PlatformCapabilities {
return {
hasFileSystem: false,
hasCamera: true, // Through file input with capture
isMobile: /iPhone|iPad|iPod|Android/i.test(navigator.userAgent),
isIOS: /iPad|iPhone|iPod/.test(navigator.userAgent),
hasFileDownload: true,
needsFileHandlingInstructions: false
};
}
/**
* Not supported in web platform.
* @param _path - Unused path parameter