|
@@ -32,29 +32,7 @@ export default class BrowserCapabilities extends BrowserDetection {
|
32
|
32
|
* @returns {boolean}
|
33
|
33
|
*/
|
34
|
34
|
isAndroidBrowser() {
|
35
|
|
- const { userAgent } = navigator;
|
36
|
|
-
|
37
|
|
- return !this.isReactNative() && userAgent.match(/Android/i);
|
38
|
|
- }
|
39
|
|
-
|
40
|
|
- /**
|
41
|
|
- * Checks if the current browser is Chromium based, i.e., it's either Chrome / Chromium or uses it as its engine,
|
42
|
|
- * but doesn't identify as Chrome.
|
43
|
|
- *
|
44
|
|
- * This includes the following browsers:
|
45
|
|
- * - Chrome and Chromium.
|
46
|
|
- * - Other browsers which use the Chrome engine, but are detected as Chrome, such as Brave and Vivaldi.
|
47
|
|
- * - Browsers which are NOT Chrome but use it as their engine, and have custom detection code: Opera, Electron
|
48
|
|
- * and NW.JS.
|
49
|
|
- * This excludes
|
50
|
|
- * - Chrome on iOS since it uses WKWebView.
|
51
|
|
- */
|
52
|
|
- isChromiumBased() {
|
53
|
|
- return (this.isChrome()
|
54
|
|
- || this.isElectron()
|
55
|
|
- || this.isNWJS()
|
56
|
|
- || this.isOpera())
|
57
|
|
- && !this.isWebKitBased();
|
|
35
|
+ return !this.isReactNative() && this.getOS() === 'Android';
|
58
|
36
|
}
|
59
|
37
|
|
60
|
38
|
/**
|
|
@@ -63,10 +41,7 @@ export default class BrowserCapabilities extends BrowserDetection {
|
63
|
41
|
* @returns {boolean}
|
64
|
42
|
*/
|
65
|
43
|
isIosBrowser() {
|
66
|
|
- const { userAgent, maxTouchPoints, platform } = navigator;
|
67
|
|
-
|
68
|
|
- return Boolean(userAgent.match(/iP(ad|hone|od)/i))
|
69
|
|
- || (maxTouchPoints && maxTouchPoints > 2 && /MacIntel/.test(platform));
|
|
44
|
+ return !this.isReactNative() && this.getOS() === 'iOS';
|
70
|
45
|
}
|
71
|
46
|
|
72
|
47
|
/**
|
|
@@ -76,24 +51,6 @@ export default class BrowserCapabilities extends BrowserDetection {
|
76
|
51
|
return this.isAndroidBrowser() || this.isIosBrowser() || this.isReactNative();
|
77
|
52
|
}
|
78
|
53
|
|
79
|
|
- /**
|
80
|
|
- * Checks if the current browser is WebKit based. It's either
|
81
|
|
- * Safari or uses WebKit as its engine.
|
82
|
|
- *
|
83
|
|
- * This includes Chrome and Firefox on iOS
|
84
|
|
- *
|
85
|
|
- * @returns {boolean}
|
86
|
|
- */
|
87
|
|
- isWebKitBased() {
|
88
|
|
- // https://trac.webkit.org/changeset/236144/webkit/trunk/LayoutTests/webrtc/video-addLegacyTransceiver.html
|
89
|
|
- return this._bowser.isEngine('webkit')
|
90
|
|
- && typeof navigator.mediaDevices !== 'undefined'
|
91
|
|
- && typeof navigator.mediaDevices.getUserMedia !== 'undefined'
|
92
|
|
- && typeof window.RTCRtpTransceiver !== 'undefined'
|
93
|
|
- // eslint-disable-next-line no-undef
|
94
|
|
- && Object.keys(RTCRtpTransceiver.prototype).indexOf('currentDirection') > -1;
|
95
|
|
- }
|
96
|
|
-
|
97
|
54
|
/**
|
98
|
55
|
* Checks whether current running context is a Trusted Web Application.
|
99
|
56
|
*
|
|
@@ -113,7 +70,7 @@ export default class BrowserCapabilities extends BrowserDetection {
|
113
|
70
|
return false;
|
114
|
71
|
}
|
115
|
72
|
|
116
|
|
- return (this.isChromiumBased() && this._getChromiumBasedVersion() >= MIN_REQUIRED_CHROME_VERSION)
|
|
73
|
+ return (this.isChromiumBased() && this.isEngineVersionGreaterThan(MIN_REQUIRED_CHROME_VERSION - 1))
|
117
|
74
|
|| this.isFirefox()
|
118
|
75
|
|| this.isReactNative()
|
119
|
76
|
|| this.isWebKitBased();
|
|
@@ -232,7 +189,7 @@ export default class BrowserCapabilities extends BrowserDetection {
|
232
|
189
|
* @returns {boolean}
|
233
|
190
|
*/
|
234
|
191
|
supportsTrackBasedStats() {
|
235
|
|
- return this.isChromiumBased() && this.isVersionLessThan(112);
|
|
192
|
+ return this.isChromiumBased() && this.isEngineVersionLessThan(112);
|
236
|
193
|
}
|
237
|
194
|
|
238
|
195
|
/**
|
|
@@ -328,7 +285,7 @@ export default class BrowserCapabilities extends BrowserDetection {
|
328
|
285
|
supportsUnifiedPlan() {
|
329
|
286
|
// We do not want to enable unified plan on Electron clients that have Chromium version < 96 because of
|
330
|
287
|
// performance and screensharing issues.
|
331
|
|
- return !(this.isElectron() && (this._getChromiumBasedVersion() < 96));
|
|
288
|
+ return !(this.isElectron() && this.isEngineVersionLessThan(96));
|
332
|
289
|
}
|
333
|
290
|
|
334
|
291
|
/**
|
|
@@ -351,37 +308,6 @@ export default class BrowserCapabilities extends BrowserDetection {
|
351
|
308
|
return !(this.isFirefox() && this.isVersionLessThan('96'));
|
352
|
309
|
}
|
353
|
310
|
|
354
|
|
- /**
|
355
|
|
- * Returns the version of a Chromium based browser.
|
356
|
|
- *
|
357
|
|
- * @returns {Number}
|
358
|
|
- */
|
359
|
|
- _getChromiumBasedVersion() {
|
360
|
|
- if (this.isChromiumBased()) {
|
361
|
|
- // NW.JS doesn't expose the Chrome version in the UA string.
|
362
|
|
- if (this.isNWJS()) {
|
363
|
|
- // eslint-disable-next-line no-undef
|
364
|
|
- return Number.parseInt(process.versions.chromium, 10);
|
365
|
|
- }
|
366
|
|
-
|
367
|
|
- // Here we process all browsers which use the Chrome engine but
|
368
|
|
- // don't necessarily identify as Chrome. We cannot use the version
|
369
|
|
- // comparing functions because the Electron, Opera and NW.JS
|
370
|
|
- // versions are inconsequential here, as we need to know the actual
|
371
|
|
- // Chrome engine version.
|
372
|
|
- const ua = navigator.userAgent;
|
373
|
|
-
|
374
|
|
- if (ua.match(/Chrome/)) {
|
375
|
|
- const version
|
376
|
|
- = Number.parseInt(ua.match(/Chrome\/([\d.]+)/)[1], 10);
|
377
|
|
-
|
378
|
|
- return version;
|
379
|
|
- }
|
380
|
|
- }
|
381
|
|
-
|
382
|
|
- return -1;
|
383
|
|
- }
|
384
|
|
-
|
385
|
311
|
/**
|
386
|
312
|
* Returns the version of a Safari browser.
|
387
|
313
|
*
|
|
@@ -402,7 +328,7 @@ export default class BrowserCapabilities extends BrowserDetection {
|
402
|
328
|
*/
|
403
|
329
|
_getIOSVersion() {
|
404
|
330
|
if (this.isWebKitBased()) {
|
405
|
|
- return Number.parseInt(this.getVersion(), 10);
|
|
331
|
+ return Number.parseInt(this.getOSVersion(), 10);
|
406
|
332
|
}
|
407
|
333
|
|
408
|
334
|
return -1;
|