forked from jsnbuchanan/crowd-funder-for-time-pwa
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user