UNPKG

@dfsol/platform-detector

Version:

Universal platform detector for web, PWA, TWA, Telegram Mini Apps, Capacitor.js, and native mobile applications with @tma.js SDK support

87 lines 2.41 kB
import type { PlatformInfo, PlatformDetectorOptions, TMAAvailability } from './types.js'; /** * Detects the current platform and environment */ export declare class PlatformDetector { private options; constructor(options?: PlatformDetectorOptions); /** * Detect platform information */ detect(): PlatformInfo; /** * Detect operating system from user agent */ private detectOS; /** * Detect device type from user agent and OS */ private detectDevice; /** * Detect domain mode (app.* vs tg.*) */ private detectDomainMode; /** * Detect environment (development vs production) */ private detectEnvironment; /** * Detect if running as native mobile app (Capacitor/Cordova) */ private detectNative; /** * Detect if running in Telegram Mini App with strict checks * Supports both native Telegram SDK and @tma.js SDK */ private detectTelegram; /** * Validate Telegram WebApp with flexible checks for native app compatibility */ private validateTelegramWebApp; /** * Detect if running as PWA (installed) */ private detectPWA; /** * Detect if running as TWA (Trusted Web Activity on Android) */ private detectTWA; /** * Get detailed Capacitor information from native API */ private getCapacitorInfo; /** * Get detailed Telegram information from WebApp SDK * Supports both native Telegram SDK and @tma.js SDK */ private getTelegramInfo; /** * Get Telegram information from @tma.js SDK */ private getTelegramInfoFromTmaJs; /** * Get screen information */ private getScreenInfo; /** * Create server-side platform info (SSR) */ private createServerSideInfo; /** * Check TMA availability and generate deep link */ checkTMAAvailability(botUsername: string): TMAAvailability; /** * Attempt to open URL in Telegram */ openInTelegram(botUsername: string): boolean; } /** * Create a platform detector instance */ export declare function createPlatformDetector(options?: PlatformDetectorOptions): PlatformDetector; /** * Quick platform detection (convenience function) */ export declare function detectPlatform(options?: PlatformDetectorOptions): PlatformInfo; //# sourceMappingURL=detector.d.ts.map