浏览代码

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

release-8443
Gabriel Borlea 2 年前
父节点
当前提交
a01453438e
没有帐户链接到提交者的电子邮件
共有 5 个文件被更改,包括 45 次插入139 次删除
  1. 1
    36
      modules/RTC/ScreenObtainer.js
  2. 1
    1
      modules/RTC/TraceablePeerConnection.js
  3. 6
    80
      modules/browser/BrowserCapabilities.js
  4. 36
    21
      package-lock.json
  5. 1
    1
      package.json

+ 1
- 36
modules/RTC/ScreenObtainer.js 查看文件

46
      * @private
46
      * @private
47
      */
47
      */
48
     _createObtainStreamMethod() {
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
             return this.obtainScreenOnElectron;
50
             return this.obtainScreenOnElectron;
86
         } else if (browser.isReactNative() && browser.supportsGetDisplayMedia()) {
51
         } else if (browser.isReactNative() && browser.supportsGetDisplayMedia()) {
87
             return this.obtainScreenFromGetDisplayMediaRN;
52
             return this.obtainScreenFromGetDisplayMediaRN;

+ 1
- 1
modules/RTC/TraceablePeerConnection.js 查看文件

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

+ 6
- 80
modules/browser/BrowserCapabilities.js 查看文件

32
      * @returns {boolean}
32
      * @returns {boolean}
33
      */
33
      */
34
     isAndroidBrowser() {
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
      * @returns {boolean}
41
      * @returns {boolean}
64
      */
42
      */
65
     isIosBrowser() {
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
         return this.isAndroidBrowser() || this.isIosBrowser() || this.isReactNative();
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
      * Checks whether current running context is a Trusted Web Application.
55
      * Checks whether current running context is a Trusted Web Application.
99
      *
56
      *
113
             return false;
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
             || this.isFirefox()
74
             || this.isFirefox()
118
             || this.isReactNative()
75
             || this.isReactNative()
119
             || this.isWebKitBased();
76
             || this.isWebKitBased();
232
      * @returns {boolean}
189
      * @returns {boolean}
233
      */
190
      */
234
     supportsTrackBasedStats() {
191
     supportsTrackBasedStats() {
235
-        return this.isChromiumBased() && this.isVersionLessThan(112);
192
+        return this.isChromiumBased() && this.isEngineVersionLessThan(112);
236
     }
193
     }
237
 
194
 
238
     /**
195
     /**
328
     supportsUnifiedPlan() {
285
     supportsUnifiedPlan() {
329
         // We do not want to enable unified plan on Electron clients that have Chromium version < 96 because of
286
         // We do not want to enable unified plan on Electron clients that have Chromium version < 96 because of
330
         // performance and screensharing issues.
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
         return !(this.isFirefox() && this.isVersionLessThan('96'));
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
      * Returns the version of a Safari browser.
312
      * Returns the version of a Safari browser.
387
      *
313
      *
402
      */
328
      */
403
     _getIOSVersion() {
329
     _getIOSVersion() {
404
         if (this.isWebKitBased()) {
330
         if (this.isWebKitBased()) {
405
-            return Number.parseInt(this.getVersion(), 10);
331
+            return Number.parseInt(this.getOSVersion(), 10);
406
         }
332
         }
407
 
333
 
408
         return -1;
334
         return -1;

+ 36
- 21
package-lock.json 查看文件

10
       "hasInstallScript": true,
10
       "hasInstallScript": true,
11
       "license": "Apache-2.0",
11
       "license": "Apache-2.0",
12
       "dependencies": {
12
       "dependencies": {
13
-        "@jitsi/js-utils": "2.1.3",
13
+        "@jitsi/js-utils": "2.2.0",
14
         "@jitsi/logger": "2.0.2",
14
         "@jitsi/logger": "2.0.2",
15
         "@jitsi/rtcstats": "9.5.1",
15
         "@jitsi/rtcstats": "9.5.1",
16
         "@jitsi/sdp-interop": "git+https://github.com/jitsi/sdp-interop#3d49eb4aa26863a3f8d32d7581cdb4321244266b",
16
         "@jitsi/sdp-interop": "git+https://github.com/jitsi/sdp-interop#3d49eb4aa26863a3f8d32d7581cdb4321244266b",
1998
       }
1998
       }
1999
     },
1999
     },
2000
     "node_modules/@jitsi/js-utils": {
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
       "dependencies": {
2004
       "dependencies": {
2005
         "@hapi/bourne": "^3.0.0",
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
     "node_modules/@jitsi/logger": {
2028
     "node_modules/@jitsi/logger": {
2677
       "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
2695
       "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
2678
       "dev": true
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
     "node_modules/brace-expansion": {
2698
     "node_modules/brace-expansion": {
2686
       "version": "1.1.11",
2699
       "version": "1.1.11",
2687
       "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
2700
       "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
8757
       "requires": {}
8770
       "requires": {}
8758
     },
8771
     },
8759
     "@jitsi/js-utils": {
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
       "requires": {
8776
       "requires": {
8764
         "@hapi/bourne": "^3.0.0",
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
     "@jitsi/logger": {
8789
     "@jitsi/logger": {
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
     "brace-expansion": {
9372
     "brace-expansion": {
9358
       "version": "1.1.11",
9373
       "version": "1.1.11",
9359
       "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
9374
       "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",

+ 1
- 1
package.json 查看文件

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

正在加载...
取消
保存