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:
@@ -9,13 +9,38 @@ export interface ImageResult {
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform capabilities interface defining what features are available
|
||||
* on the current platform implementation
|
||||
*/
|
||||
export interface PlatformCapabilities {
|
||||
/** Whether the platform supports native file system access */
|
||||
hasFileSystem: boolean;
|
||||
/** Whether the platform supports native camera access */
|
||||
hasCamera: boolean;
|
||||
/** Whether the platform is a mobile device */
|
||||
isMobile: boolean;
|
||||
/** Whether the platform is iOS specifically */
|
||||
isIOS: boolean;
|
||||
/** Whether the platform supports native file download */
|
||||
hasFileDownload: boolean;
|
||||
/** Whether the platform requires special file handling instructions */
|
||||
needsFileHandlingInstructions: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform-agnostic interface for handling platform-specific operations.
|
||||
* Provides a common API for file system operations, camera interactions,
|
||||
* platform detection, and deep linking across different platforms
|
||||
* (web, mobile, desktop).
|
||||
* and platform detection across different platforms (web, mobile, desktop).
|
||||
*/
|
||||
export interface PlatformService {
|
||||
// Platform capabilities
|
||||
/**
|
||||
* Gets the current platform's capabilities
|
||||
* @returns Object describing what features are available on this platform
|
||||
*/
|
||||
getCapabilities(): PlatformCapabilities;
|
||||
|
||||
// File system operations
|
||||
/**
|
||||
* Reads the contents of a file at the specified path.
|
||||
@@ -59,32 +84,6 @@ export interface PlatformService {
|
||||
*/
|
||||
pickImage(): Promise<ImageResult>;
|
||||
|
||||
// Platform specific features
|
||||
/**
|
||||
* Checks if the current platform is Capacitor (mobile).
|
||||
* @returns true if running on Capacitor
|
||||
*/
|
||||
isCapacitor(): boolean;
|
||||
|
||||
/**
|
||||
* Checks if the current platform is Electron (desktop).
|
||||
* @returns true if running on Electron
|
||||
*/
|
||||
isElectron(): boolean;
|
||||
|
||||
/**
|
||||
* Checks if the current platform is PyWebView.
|
||||
* @returns true if running on PyWebView
|
||||
*/
|
||||
isPyWebView(): boolean;
|
||||
|
||||
/**
|
||||
* Checks if the current platform is web browser.
|
||||
* @returns true if running in a web browser
|
||||
*/
|
||||
isWeb(): boolean;
|
||||
|
||||
// Deep linking
|
||||
/**
|
||||
* Handles deep link URLs for the application.
|
||||
* @param url - The deep link URL to handle
|
||||
|
||||
Reference in New Issue
Block a user