forked from jsnbuchanan/crowd-funder-for-time-pwa
- Add proper unknown type for error handling in PhotoDialog - Remove any type in favor of unknown for better type safety - Fix error message access with type guards
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { PlatformService } from "./PlatformService";
|
|
import { WebPlatformService } from "./platforms/WebPlatformService";
|
|
import { CapacitorPlatformService } from "./platforms/CapacitorPlatformService";
|
|
import { ElectronPlatformService } from "./platforms/ElectronPlatformService";
|
|
import { PyWebViewPlatformService } from "./platforms/PyWebViewPlatformService";
|
|
|
|
export class PlatformServiceFactory {
|
|
private static instance: PlatformService | null = null;
|
|
|
|
public static getInstance(): PlatformService {
|
|
if (PlatformServiceFactory.instance) {
|
|
return PlatformServiceFactory.instance;
|
|
}
|
|
|
|
const platform = process.env.VITE_PLATFORM || "web";
|
|
|
|
switch (platform) {
|
|
case "capacitor":
|
|
PlatformServiceFactory.instance = new CapacitorPlatformService();
|
|
break;
|
|
case "electron":
|
|
PlatformServiceFactory.instance = new ElectronPlatformService();
|
|
break;
|
|
case "pywebview":
|
|
PlatformServiceFactory.instance = new PyWebViewPlatformService();
|
|
break;
|
|
case "web":
|
|
default:
|
|
PlatformServiceFactory.instance = new WebPlatformService();
|
|
break;
|
|
}
|
|
|
|
return PlatformServiceFactory.instance;
|
|
}
|
|
}
|