@privateid/ultra-web-sdk-alpha
Version:
CryptoNets WebAssembly SDK
33 lines • 1.54 kB
JavaScript
/* eslint-disable import/prefer-default-export */
import { detect } from 'detect-browser';
import { isMobilePlatform } from '../../global/shared.utils';
import { FirefoxCameraService } from './services/FirefoxCameraService';
import { MobileCameraService } from './services/MobileCameraService';
import { MacSafariCameraService } from './services/MacSafariCameraService';
import { DesktopCameraService } from './services/DesktopCameraService';
export class CameraServiceFactory {
/**
* Creates the appropriate camera service based on the current browser and platform
* @returns Camera service instance optimized for the current environment
*/
static create() {
const browser = detect();
const browserName = (browser === null || browser === void 0 ? void 0 : browser.name) || 'unknown';
const os = (browser === null || browser === void 0 ? void 0 : browser.os) || 'unknown';
// Firefox - has specific video constraints handling
if (browserName === 'firefox') {
return new FirefoxCameraService();
}
// Mobile devices (iOS and Android)
if (isMobilePlatform()) {
return new MobileCameraService();
}
// Mac Safari - needs special device selection logic
if (os === 'Mac OS' && browserName === 'safari') {
return new MacSafariCameraService();
}
// Default desktop (Chrome, Edge, etc.)
return new DesktopCameraService();
}
}
//# sourceMappingURL=CameraServiceFactory.js.map