1
1
"use strict" ;
2
2
3
- Object . defineProperty ( exports , "__esModule" , {
4
- value : true
5
- } ) ;
6
- exports . default = exports . supportedBrowsers = void 0 ;
3
+ function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
7
4
8
- require ( "core-js/modules/es6.regexp.match.js" ) ;
5
+ function _defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } }
9
6
10
- require ( "core-js/modules/es6.regexp.constructor.js" ) ;
7
+ function _createClass ( Constructor , protoProps , staticProps ) { if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) _defineProperties ( Constructor , staticProps ) ; return Constructor ; }
11
8
12
- require ( "core-js/modules/es6.object.keys.js" ) ;
9
+ function _defineProperty ( obj , key , value ) { if ( key in obj ) { Object . defineProperty ( obj , key , { value : value , enumerable : true , configurable : true , writable : true } ) ; } else { obj [ key ] = value ; } return obj ; }
13
10
14
- var userAgent = function userAgent ( ) {
15
- return ( navigator && navigator . userAgent || "" ) . toLowerCase ( ) ;
16
- } ;
11
+ var IsSupported = /*#__PURE__*/ function ( ) {
12
+ function IsSupported ( ) {
13
+ var supportedBrowsers = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
17
14
18
- var vendor = function vendor ( ) {
19
- return ( navigator && navigator . vendor || "" ) . toLowerCase ( ) ;
20
- } ;
15
+ _classCallCheck ( this , IsSupported ) ;
16
+
17
+ _defineProperty ( this , "userAgent" , function ( ) {
18
+ return ( navigator && navigator . userAgent || "" ) . toLowerCase ( ) ;
19
+ } ) ;
20
+
21
+ _defineProperty ( this , "vendor" , function ( ) {
22
+ return ( navigator && navigator . vendor || "" ) . toLowerCase ( ) ;
23
+ } ) ;
24
+
25
+ this . supportedBrowsers = supportedBrowsers ;
26
+ this . browsersRegex = new RegExp ( Object . keys ( supportedBrowsers ) . join ( "|" ) ) ;
27
+ }
28
+
29
+ _createClass ( IsSupported , [ {
30
+ key : "isSupported" ,
31
+ value : function isSupported ( ) {
32
+ var browser = this . getBrowser ( ) ;
33
+ var version = this . supportedBrowsers [ browser ] ;
34
+ if ( ! version || version == "none" ) return false ;
35
+ if ( version == "any" ) return true ;
36
+
37
+ switch ( browser ) {
38
+ case "msie" :
39
+ case "trident" :
40
+ return this . isIe ( version ) ;
41
+
42
+ case "edge" :
43
+ return this . isEdge ( version ) ;
44
+
45
+ case "firefox" :
46
+ return this . isFirefox ( version ) ;
47
+
48
+ case "chrome" :
49
+ return this . isChrome ( version ) ;
50
+ }
51
+ }
52
+ } , {
53
+ key : "compareVersion" ,
54
+ value : function compareVersion ( version , range ) {
55
+ var string = range + "" ;
56
+ var n = + ( string . match ( / \d + / ) || NaN ) ;
57
+ var op = string . match ( / ^ [ < > ] = ? | / ) [ 0 ] ;
58
+ return comparator [ op ] ? comparator [ op ] ( version , n ) : version == n || n !== n ;
59
+ }
60
+ } , {
61
+ key : "getBrowser" ,
62
+ value : function getBrowser ( ) {
63
+ var match = this . userAgent ( ) . match ( this . browsersRegex ) ;
64
+ if ( ! match ) return null ;
65
+ return match [ 0 ] ;
66
+ }
67
+ } , {
68
+ key : "isChrome" ,
69
+ value : function isChrome ( range ) {
70
+ var match = / g o o g l e i n c / . test ( this . vendor ( ) ) ? this . userAgent ( ) . match ( / (?: c h r o m e | c r i o s ) \/ ( \d + ) / ) : null ;
71
+ return match !== null && this . compareVersion ( match [ 1 ] , range ) ;
72
+ }
73
+ } , {
74
+ key : "isIe" ,
75
+ value : function isIe ( range ) {
76
+ var match = this . userAgent ( ) . match ( / (?: m s i e | t r i d e n t .+ ?; r v : ) ( \d + ) / ) ;
77
+ return match !== null && this . compareVersion ( match [ 1 ] , range ) ;
78
+ }
79
+ } , {
80
+ key : "isEdge" ,
81
+ value : function isEdge ( range ) {
82
+ var match = this . userAgent ( ) . match ( / e d g e \/ ( \d + ) / ) ;
83
+ return match !== null && this . compareVersion ( match [ 1 ] , range ) ;
84
+ }
85
+ } , {
86
+ key : "isFirefox" ,
87
+ value : function isFirefox ( range ) {
88
+ var match = this . userAgent ( ) . match ( / (?: f i r e f o x | f x i o s ) \/ ( \d + ) / ) ;
89
+ return match !== null && this . compareVersion ( match [ 1 ] , range ) ;
90
+ }
91
+ } ] ) ;
92
+
93
+ return IsSupported ;
94
+ } ( ) ;
21
95
22
96
var comparator = {
23
97
"<" : function _ ( a , b ) {
@@ -33,87 +107,3 @@ var comparator = {
33
107
return a >= b ;
34
108
}
35
109
} ;
36
-
37
- function compareVersion ( version , range ) {
38
- var string = range + "" ;
39
- var n = + ( string . match ( / \d + / ) || NaN ) ;
40
- var op = string . match ( / ^ [ < > ] = ? | / ) [ 0 ] ;
41
- return comparator [ op ] ? comparator [ op ] ( version , n ) : version == n || n !== n ;
42
- }
43
-
44
- var supportedBrowsers = {
45
- msie : "none" ,
46
- //ie / internet explorer
47
- trident : "none" ,
48
- //ie / internet explorer
49
- edge : ">1" ,
50
- // example version range for now
51
- chrome : "any" ,
52
- firefox : "any" ,
53
- opera : "none"
54
- } ;
55
- exports . supportedBrowsers = supportedBrowsers ;
56
-
57
- function isSupported ( ) {
58
- var browsers = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : supportedBrowsers ;
59
- var browser = getBrowser ( ) ;
60
- var version = browsers [ browser ] ;
61
- if ( ! version || version == "none" ) return false ;
62
- if ( version == "any" ) return true ;
63
-
64
- switch ( browser ) {
65
- case "msie" :
66
- case "trident" :
67
- return isIe ( version ) ;
68
-
69
- case "edge" :
70
- return isEdge ( version ) ;
71
-
72
- case "firefox" :
73
- return isFirefox ( version ) ;
74
-
75
- case "chrome" :
76
- return isChrome ( version ) ;
77
- }
78
- }
79
-
80
- var browsersRegex = new RegExp ( Object . keys ( supportedBrowsers ) . join ( "|" ) ) ;
81
-
82
- function getBrowser ( ) {
83
- var match = userAgent ( ) . match ( browsersRegex ) ;
84
- if ( ! match ) return null ;
85
- return match [ 0 ] ;
86
- } // can take a number or a string. Can also take a string prefixed with a comparable like, > or >=
87
- // example, chrome('>=90')
88
-
89
-
90
- function isChrome ( range ) {
91
- var match = / g o o g l e i n c / . test ( vendor ( ) ) ? userAgent ( ) . match ( / (?: c h r o m e | c r i o s ) \/ ( \d + ) / ) : null ;
92
- return match !== null && compareVersion ( match [ 1 ] , range ) ;
93
- }
94
-
95
- function isIe ( range ) {
96
- var match = userAgent ( ) . match ( / (?: m s i e | t r i d e n t .+ ?; r v : ) ( \d + ) / ) ;
97
- return match !== null && compareVersion ( match [ 1 ] , range ) ;
98
- }
99
-
100
- function isEdge ( range ) {
101
- var match = userAgent ( ) . match ( / e d g e \/ ( \d + ) / ) ;
102
- return match !== null && compareVersion ( match [ 1 ] , range ) ;
103
- }
104
-
105
- function isFirefox ( range ) {
106
- var match = userAgent ( ) . match ( / (?: f i r e f o x | f x i o s ) \/ ( \d + ) / ) ;
107
- return match !== null && compareVersion ( match [ 1 ] , range ) ;
108
- }
109
-
110
- var _default = {
111
- supportedBrowsers : supportedBrowsers ,
112
- compareVersion : compareVersion ,
113
- isSupported : isSupported ,
114
- isChrome : isChrome ,
115
- isIe : isIe ,
116
- isEdge : isEdge ,
117
- isFirefox : isFirefox
118
- } ;
119
- exports . default = _default ;
0 commit comments