Procházet zdrojové kódy

chore: update js-utils with new ua-parser (#2358)

release-8443
Gabriel Borlea před 2 roky
rodič
revize
a01453438e
Žádný účet není propojen s e-mailovou adresou tvůrce revize

+ 1
- 36
modules/RTC/ScreenObtainer.js Zobrazit soubor

@@ -46,42 +46,7 @@ const ScreenObtainer = {
46 46
      * @private
47 47
      */
48 48
     _createObtainStreamMethod() {
49
-        if (browser.isNWJS()) {
50
-            return (onSuccess, onFailure) => {
51
-                window.JitsiMeetNW.obtainDesktopStream(
52
-                    onSuccess,
53
-                    (error, constraints) => {
54
-                        let jitsiError;
55
-
56
-                        // FIXME:
57
-                        // This is very very dirty fix for recognising that the
58
-                        // user have clicked the cancel button from the Desktop
59
-                        // sharing pick window. The proper solution would be to
60
-                        // detect this in the NWJS application by checking the
61
-                        // streamId === "". Even better solution would be to
62
-                        // stop calling GUM from the NWJS app and just pass the
63
-                        // streamId to lib-jitsi-meet. This way the desktop
64
-                        // sharing implementation for NWJS and chrome extension
65
-                        // will be the same and lib-jitsi-meet will be able to
66
-                        // control the constraints, check the streamId, etc.
67
-                        //
68
-                        // I cannot find documentation about "InvalidStateError"
69
-                        // but this is what we are receiving from GUM when the
70
-                        // streamId for the desktop sharing is "".
71
-
72
-                        if (error && error.name === 'InvalidStateError') {
73
-                            jitsiError = new JitsiTrackError(
74
-                                JitsiTrackErrors.SCREENSHARING_USER_CANCELED
75
-                            );
76
-                        } else {
77
-                            jitsiError = new JitsiTrackError(
78
-                                error, constraints, [ 'desktop' ]);
79
-                        }
80
-                        (typeof onFailure === 'function')
81
-                            && onFailure(jitsiError);
82
-                    });
83
-            };
84
-        } else if (browser.isElectron()) {
49
+        if (browser.isElectron()) {
85 50
             return this.obtainScreenOnElectron;
86 51
         } else if (browser.isReactNative() && browser.supportsGetDisplayMedia()) {
87 52
             return this.obtainScreenFromGetDisplayMediaRN;

+ 1
- 1
modules/RTC/TraceablePeerConnection.js Zobrazit soubor

@@ -1424,7 +1424,7 @@ const normalizePlanB = function(desc) {
1424 1424
  * @returns {Array<Object>} ssrcLines with removed lines referencing msid "-".
1425 1425
  */
1426 1426
 function replaceDefaultUnifiedPlanMsid(ssrcLines = []) {
1427
-    if (!browser.isChrome() || !browser.isVersionGreaterThan(70)) {
1427
+    if (!browser.isChromiumBased()) {
1428 1428
         return ssrcLines;
1429 1429
     }
1430 1430
 

+ 6
- 80
modules/browser/BrowserCapabilities.js Zobrazit soubor

@@ -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;

+ 36
- 21
package-lock.json Zobrazit soubor

@@ -10,7 +10,7 @@
10 10
       "hasInstallScript": true,
11 11
       "license": "Apache-2.0",
12 12
       "dependencies": {
13
-        "@jitsi/js-utils": "2.1.3",
13
+        "@jitsi/js-utils": "2.2.0",
14 14
         "@jitsi/logger": "2.0.2",
15 15
         "@jitsi/rtcstats": "9.5.1",
16 16
         "@jitsi/sdp-interop": "git+https://github.com/jitsi/sdp-interop#3d49eb4aa26863a3f8d32d7581cdb4321244266b",
@@ -1998,13 +1998,31 @@
1998 1998
       }
1999 1999
     },
2000 2000
     "node_modules/@jitsi/js-utils": {
2001
-      "version": "2.1.3",
2002
-      "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-2.1.3.tgz",
2003
-      "integrity": "sha512-fXoNLu2JHQGPgzjCDG5qWPPStiXI+AxSzu1JIVY4dMULIFsw4a+doMgcjTIlSfB393J2xccKQYwZSejZUn9MEw==",
2001
+      "version": "2.2.0",
2002
+      "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-2.2.0.tgz",
2003
+      "integrity": "sha512-C1dZikxS899o49nclZe9TeehmDykxj1bMwmjcJidzzkq7lI593frHJRntPwV43zeZH5X0QslqeBnzOJq8B0ZIA==",
2004 2004
       "dependencies": {
2005 2005
         "@hapi/bourne": "^3.0.0",
2006
-        "bowser": "2.7.0",
2007
-        "js-md5": "0.7.3"
2006
+        "js-md5": "0.7.3",
2007
+        "ua-parser-js": "1.0.35"
2008
+      }
2009
+    },
2010
+    "node_modules/@jitsi/js-utils/node_modules/ua-parser-js": {
2011
+      "version": "1.0.35",
2012
+      "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.35.tgz",
2013
+      "integrity": "sha512-fKnGuqmTBnIE+/KXSzCn4db8RTigUzw1AN0DmdU6hJovUTbYJKyqj+8Mt1c4VfRDnOVJnENmfYkIPZ946UrSAA==",
2014
+      "funding": [
2015
+        {
2016
+          "type": "opencollective",
2017
+          "url": "https://opencollective.com/ua-parser-js"
2018
+        },
2019
+        {
2020
+          "type": "paypal",
2021
+          "url": "https://paypal.me/faisalman"
2022
+        }
2023
+      ],
2024
+      "engines": {
2025
+        "node": "*"
2008 2026
       }
2009 2027
     },
2010 2028
     "node_modules/@jitsi/logger": {
@@ -2677,11 +2695,6 @@
2677 2695
       "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
2678 2696
       "dev": true
2679 2697
     },
2680
-    "node_modules/bowser": {
2681
-      "version": "2.7.0",
2682
-      "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.7.0.tgz",
2683
-      "integrity": "sha512-aIlMvstvu8x+34KEiOHD3AsBgdrzg6sxALYiukOWhFvGMbQI6TRP/iY0LMhUrHs56aD6P1G0Z7h45PUJaa5m9w=="
2684
-    },
2685 2698
     "node_modules/brace-expansion": {
2686 2699
       "version": "1.1.11",
2687 2700
       "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -8757,13 +8770,20 @@
8757 8770
       "requires": {}
8758 8771
     },
8759 8772
     "@jitsi/js-utils": {
8760
-      "version": "2.1.3",
8761
-      "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-2.1.3.tgz",
8762
-      "integrity": "sha512-fXoNLu2JHQGPgzjCDG5qWPPStiXI+AxSzu1JIVY4dMULIFsw4a+doMgcjTIlSfB393J2xccKQYwZSejZUn9MEw==",
8773
+      "version": "2.2.0",
8774
+      "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-2.2.0.tgz",
8775
+      "integrity": "sha512-C1dZikxS899o49nclZe9TeehmDykxj1bMwmjcJidzzkq7lI593frHJRntPwV43zeZH5X0QslqeBnzOJq8B0ZIA==",
8763 8776
       "requires": {
8764 8777
         "@hapi/bourne": "^3.0.0",
8765
-        "bowser": "2.7.0",
8766
-        "js-md5": "0.7.3"
8778
+        "js-md5": "0.7.3",
8779
+        "ua-parser-js": "1.0.35"
8780
+      },
8781
+      "dependencies": {
8782
+        "ua-parser-js": {
8783
+          "version": "1.0.35",
8784
+          "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.35.tgz",
8785
+          "integrity": "sha512-fKnGuqmTBnIE+/KXSzCn4db8RTigUzw1AN0DmdU6hJovUTbYJKyqj+8Mt1c4VfRDnOVJnENmfYkIPZ946UrSAA=="
8786
+        }
8767 8787
       }
8768 8788
     },
8769 8789
     "@jitsi/logger": {
@@ -9349,11 +9369,6 @@
9349 9369
         }
9350 9370
       }
9351 9371
     },
9352
-    "bowser": {
9353
-      "version": "2.7.0",
9354
-      "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.7.0.tgz",
9355
-      "integrity": "sha512-aIlMvstvu8x+34KEiOHD3AsBgdrzg6sxALYiukOWhFvGMbQI6TRP/iY0LMhUrHs56aD6P1G0Z7h45PUJaa5m9w=="
9356
-    },
9357 9372
     "brace-expansion": {
9358 9373
       "version": "1.1.11",
9359 9374
       "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",

+ 1
- 1
package.json Zobrazit soubor

@@ -16,7 +16,7 @@
16 16
   "author": "",
17 17
   "readmeFilename": "README.md",
18 18
   "dependencies": {
19
-    "@jitsi/js-utils": "2.1.3",
19
+    "@jitsi/js-utils": "2.2.0",
20 20
     "@jitsi/logger": "2.0.2",
21 21
     "@jitsi/rtcstats": "9.5.1",
22 22
     "@jitsi/sdp-interop": "git+https://github.com/jitsi/sdp-interop#3d49eb4aa26863a3f8d32d7581cdb4321244266b",

Načítá se…
Zrušit
Uložit