1- import {
2- os ,
3- device ,
4- browser ,
5- ua ,
6- engine ,
7- setDefaults ,
8- isIOS13Check
9- } from "./get-ua-data" ;
10- import { BROWSER_TYPES , DEVICE_TYPES , OS_TYPES } from "./types" ;
1+ import { os , device , browser , ua , engine , setDefaults , isIOS13Check , getNavigatorInstance } from './get-ua-data' ;
2+ import { BROWSER_TYPES , DEVICE_TYPES , OS_TYPES } from './types' ;
113
124const isMobileType = ( ) => device . type === DEVICE_TYPES . MOBILE ;
135const isTabletType = ( ) => device . type === DEVICE_TYPES . TABLET ;
@@ -34,31 +26,29 @@ const isFirefoxType = () => browser.name === BROWSER_TYPES.FIREFOX;
3426const isChromiumType = ( ) => browser . name === BROWSER_TYPES . CHROMIUM ;
3527const isEdgeType = ( ) => browser . name === BROWSER_TYPES . EDGE ;
3628const isYandexType = ( ) => browser . name === BROWSER_TYPES . YANDEX ;
37- const isSafariType = ( ) =>
38- browser . name === BROWSER_TYPES . SAFARI ||
39- browser . name === BROWSER_TYPES . MOBILE_SAFARI ;
29+ const isSafariType = ( ) => browser . name === BROWSER_TYPES . SAFARI || browser . name === BROWSER_TYPES . MOBILE_SAFARI ;
4030const isMobileSafariType = ( ) => browser . name === BROWSER_TYPES . MOBILE_SAFARI ;
4131const isOperaType = ( ) => browser . name === BROWSER_TYPES . OPERA ;
42- const isIEType = ( ) =>
43- browser . name === BROWSER_TYPES . INTERNET_EXPLORER ||
44- browser . name === BROWSER_TYPES . IE ;
32+ const isIEType = ( ) => browser . name === BROWSER_TYPES . INTERNET_EXPLORER || browser . name === BROWSER_TYPES . IE ;
4533const isElectronType = ( ) => {
46- const ua = navigator && navigator . userAgent . toLowerCase ( )
34+ const nav = getNavigatorInstance ( ) ;
35+ const ua = nav && nav . userAgent . toLowerCase ( ) ;
4736
48- return typeof ua === 'string' ? ua . includes ( 'electron' ) : false
49- }
37+ return typeof ua === 'string' ? ua . includes ( 'electron' ) : false ;
38+ } ;
5039
5140const getIOS13 = ( ) => {
52- return navigator && (
53- ( / i P a d | i P h o n e | i P o d / . test ( navigator . platform ) ||
54- ( navigator . platform === "MacIntel" && navigator . maxTouchPoints > 1 ) ) &&
55- ! window . MSStream
41+ const nav = getNavigatorInstance ( ) ;
42+ return (
43+ nav &&
44+ ( / i P a d | i P h o n e | i P o d / . test ( nav . platform ) || ( nav . platform === 'MacIntel' && nav . maxTouchPoints > 1 ) ) &&
45+ ! window . MSStream
5646 ) ;
5747} ;
5848
59- const getIPad13 = ( ) => isIOS13Check ( " iPad" ) ;
60- const getIphone13 = ( ) => isIOS13Check ( " iPhone" ) ;
61- const getIPod13 = ( ) => isIOS13Check ( " iPod" ) ;
49+ const getIPad13 = ( ) => isIOS13Check ( ' iPad' ) ;
50+ const getIphone13 = ( ) => isIOS13Check ( ' iPhone' ) ;
51+ const getIPod13 = ( ) => isIOS13Check ( ' iPod' ) ;
6252
6353const getBrowserFullVersion = ( ) => setDefaults ( browser . version ) ;
6454const getBrowserVersion = ( ) => setDefaults ( browser . major ) ;
@@ -70,7 +60,7 @@ const getMobileModel = () => setDefaults(device.model);
7060const getEngineName = ( ) => setDefaults ( engine . name ) ;
7161const getEngineVersion = ( ) => setDefaults ( engine . version ) ;
7262const getUseragent = ( ) => setDefaults ( ua ) ;
73- const getDeviceType = ( ) => setDefaults ( device . type , " browser" ) ;
63+ const getDeviceType = ( ) => setDefaults ( device . type , ' browser' ) ;
7464
7565export const isSmartTV = isSmartTVType ( ) ;
7666export const isConsole = isConsoleType ( ) ;
@@ -102,8 +92,8 @@ export const getUA = getUseragent();
10292export const isEdge = isEdgeType ( ) ;
10393export const isYandex = isYandexType ( ) ;
10494export const deviceType = getDeviceType ( ) ;
105- export const isIOS13 = getIOS13 ( )
106- export const isIPad13 = getIPad13 ( )
107- export const isIPhone13 = getIphone13 ( )
108- export const isIPod13 = getIPod13 ( )
109- export const isElectron = isElectronType ( )
95+ export const isIOS13 = getIOS13 ( ) ;
96+ export const isIPad13 = getIPad13 ( ) ;
97+ export const isIPhone13 = getIphone13 ( ) ;
98+ export const isIPod13 = getIPod13 ( ) ;
99+ export const isElectron = isElectronType ( ) ;
0 commit comments