@dfsol/platform-detector
Version:
Universal platform detector for web, PWA, Telegram Mini Apps, and native mobile applications with Client Hints API, feature detection, and enhanced accuracy
78 lines • 3.22 kB
TypeScript
/**
* @dfsol/platform-detector
* Universal platform detector for web, PWA, Telegram Mini Apps, and native mobile applications
*/
export { PlatformDetector, createPlatformDetector, detectPlatform, } from "./detector.js";
export { ClientHintsDetector } from "./client-hints.js";
export { FeatureDetector } from "./feature-detector.js";
export type { ClientHintsData, ClientHintsResult } from "./client-hints.js";
export type { DeviceFeatures, FeatureDetectionResult } from "./feature-detector.js";
import type { PlatformInfo, PlatformType, PlatformDetectorOptions as PlatformDetectorOptionsType } from "./types.js";
export { loadTelegramSDK, shouldLoadTelegramSDK, getTelegramWebApp, } from "./telegram-sdk.js";
export { verifyTelegramInitData } from "./telegram-init-data.js";
export { isTmaJsSdkAvailable, isTelegramViaTmaJs, getTmaJsSdk, getTelegramPlatformFromTmaJs, getTelegramInitDataFromTmaJs, getViewportFromTmaJs, getThemeParamsFromTmaJs, initializeTmaJs, } from "./tma-sdk.js";
export type { PlatformInfo, PlatformType, OSType, DeviceType, DomainMode, EnvironmentType, PlatformDetectorOptions, TMAAvailability, CapacitorInfo, TelegramInfo, TelegramPlatform, TelegramSDKSource, ScreenInfo, TelegramInitData, TelegramInitDataValidationOptions, TelegramInitDataValidationResult, TelegramInitDataValidationErrorCode, TelegramWebAppUser, TelegramWebAppChat, BrowserFamily, DetectionConfidence, } from "./types.js";
export type { TmaJsSdkInstance } from "./tma-sdk.js";
/**
* Quick utility functions for common detection needs
*/
/**
* Check if running on mobile device (iOS or Android)
*/
export declare function isMobileDevice(): boolean;
/**
* Check if running on iOS (any context)
*/
export declare function isIOS(): boolean;
/**
* Check if running on Android (any context)
*/
export declare function isAndroid(): boolean;
/**
* Check if running as PWA
*/
export declare function isPWA(): boolean;
/**
* Check if running in Telegram Mini App
*/
export declare function isTelegramMiniApp(): boolean;
/**
* Check if running as native app (Capacitor/Cordova)
*/
export declare function isNativeApp(): boolean;
/**
* Get current browser type
*/
export declare function getBrowserType(): string;
/**
* Get current platform type
*/
export declare function getPlatformType(): PlatformType;
/**
* Get display mode (for PWA)
*/
export declare function getDisplayMode(): string;
/**
* Check if app can be installed as PWA
*/
export declare function canInstallPWA(): boolean;
/**
* Monitor platform changes
*/
export declare function watchPlatformChanges(callback: (info: PlatformInfo) => void): () => void;
/**
* Async platform detection with Client Hints support
* Provides enhanced accuracy for OS version and device info on Chrome/Edge
*
* @param options - Detection options
* @returns Promise resolving to platform information
*
* @example
* ```typescript
* const platform = await detectPlatformAsync({ useClientHints: true });
* console.log('OS:', platform.os, platform.osVersion);
* console.log('Device:', platform.device);
* ```
*/
export declare function detectPlatformAsync(options?: PlatformDetectorOptionsType): Promise<PlatformInfo>;
//# sourceMappingURL=index.d.ts.map