UNPKG

@limetech/lime-elements

Version:
44 lines (43 loc) 1.27 kB
function getUserAgent() { var _a; return typeof navigator === 'undefined' ? '' : ((_a = navigator.userAgent) !== null && _a !== void 0 ? _a : ''); } function getPlatform() { var _a, _b, _c; if (typeof navigator === 'undefined') { return ''; } return ((_c = (_b = (_a = navigator.userAgentData) === null || _a === void 0 ? void 0 : _a.platform) !== null && _b !== void 0 ? _b : navigator.platform) !== null && _c !== void 0 ? _c : ''); } /** * */ export function isIOSDevice() { const userAgent = getUserAgent(); return /iPad|iPhone|iPod/i.test(userAgent) && !globalThis.MSStream; } /** * */ export function isAndroidDevice() { const userAgent = getUserAgent(); return /Android/i.test(userAgent); } /** * */ export function isMobileDevice() { return isAndroidDevice() || isIOSDevice(); } /** * Detects whether the user is on an Apple device (iOS/iPadOS/macOS). */ export function isAppleDevice() { const ua = getUserAgent(); const platform = getPlatform(); const isIPadIPhoneIPod = /iPad|iPhone|iPod/i.test(ua); // Note: iPadOS 13+ reports itself as Mac, so isMacLike covers both // macOS and iPadOS. const isMacLike = /Mac/i.test(platform); return isIPadIPhoneIPod || isMacLike; }