2019-06-06 17:09:54 +00:00
|
|
|
import JitsiMeetJS from '../lib-jitsi-meet';
|
2022-11-10 08:45:56 +00:00
|
|
|
import Platform from '../react/Platform';
|
2020-05-20 10:57:03 +00:00
|
|
|
|
2020-01-29 12:30:17 +00:00
|
|
|
import { isMobileBrowser } from './utils';
|
2019-06-06 17:09:54 +00:00
|
|
|
|
2019-06-20 13:02:15 +00:00
|
|
|
const { browser } = JitsiMeetJS.util;
|
|
|
|
|
|
|
|
const DEFAULT_OPTIMAL_BROWSERS = [
|
|
|
|
'chrome',
|
|
|
|
'electron',
|
|
|
|
'firefox',
|
2020-04-30 21:27:42 +00:00
|
|
|
'nwjs',
|
|
|
|
'safari'
|
2019-06-20 13:02:15 +00:00
|
|
|
];
|
|
|
|
|
2022-07-29 13:18:14 +00:00
|
|
|
const DEFAULT_UNSUPPORTED_BROWSERS: string[] = [];
|
2019-06-20 13:02:15 +00:00
|
|
|
|
|
|
|
const browserNameToCheck = {
|
|
|
|
chrome: browser.isChrome.bind(browser),
|
2019-06-21 15:27:05 +00:00
|
|
|
chromium: browser.isChromiumBased.bind(browser),
|
2019-06-20 13:02:15 +00:00
|
|
|
electron: browser.isElectron.bind(browser),
|
|
|
|
firefox: browser.isFirefox.bind(browser),
|
|
|
|
nwjs: browser.isNWJS.bind(browser),
|
|
|
|
opera: browser.isOpera.bind(browser),
|
|
|
|
safari: browser.isSafari.bind(browser)
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not jitsi is optimized and targeted for the provided
|
|
|
|
* browser name.
|
|
|
|
*
|
|
|
|
* @param {string} browserName - The name of the browser to check.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isBrowsersOptimal(browserName: string) {
|
|
|
|
return (interfaceConfig.OPTIMAL_BROWSERS || DEFAULT_OPTIMAL_BROWSERS)
|
|
|
|
.includes(browserName);
|
|
|
|
}
|
|
|
|
|
2021-04-12 07:37:39 +00:00
|
|
|
/**
|
|
|
|
* Returns whether or not the current OS is Mac.
|
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isMacOS() {
|
|
|
|
return Platform.OS === 'macos';
|
|
|
|
}
|
|
|
|
|
2021-04-28 14:06:41 +00:00
|
|
|
/**
|
|
|
|
* Returns whether or not the current OS is Windows.
|
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isWindows() {
|
|
|
|
return Platform.OS === 'windows';
|
|
|
|
}
|
|
|
|
|
2019-06-20 13:02:15 +00:00
|
|
|
/**
|
|
|
|
* Returns whether or not the current browser or the list of passed in browsers
|
|
|
|
* is considered suboptimal. Suboptimal means it is a supported browser but has
|
|
|
|
* not been explicitly listed as being optimal, possibly due to functionality
|
|
|
|
* issues.
|
|
|
|
*
|
|
|
|
* @param {Array<string>} [browsers] - A list of browser names to check. Will
|
|
|
|
* default to a whitelist.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isSuboptimalBrowser() {
|
|
|
|
const optimalBrowsers
|
|
|
|
= interfaceConfig.OPTIMAL_BROWSERS || DEFAULT_OPTIMAL_BROWSERS;
|
|
|
|
|
|
|
|
return !_isCurrentBrowserInList(optimalBrowsers) && isSupportedBrowser();
|
|
|
|
}
|
2019-06-06 17:09:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the current browser should allow the app to display.
|
2019-06-20 13:02:15 +00:00
|
|
|
* A supported browser is assumed to be able to support WebRtc.
|
2019-06-06 17:09:54 +00:00
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isSupportedBrowser() {
|
2019-06-20 13:02:15 +00:00
|
|
|
if (navigator.product === 'ReactNative') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-06-20 15:43:31 +00:00
|
|
|
// Blacklists apply to desktop browsers only right now.
|
2020-01-29 12:30:17 +00:00
|
|
|
if (!isMobileBrowser() && _isCurrentBrowserInList(
|
2019-06-20 13:02:15 +00:00
|
|
|
interfaceConfig.UNSUPPORTED_BROWSERS || DEFAULT_UNSUPPORTED_BROWSERS
|
2019-06-20 15:43:31 +00:00
|
|
|
)) {
|
2019-06-06 17:09:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-09 11:16:08 +00:00
|
|
|
return isMobileBrowser() ? isSupportedMobileBrowser() : JitsiMeetJS.isWebRtcSupported();
|
2019-06-06 17:09:54 +00:00
|
|
|
}
|
2019-06-20 13:02:15 +00:00
|
|
|
|
2020-05-19 23:11:32 +00:00
|
|
|
/**
|
|
|
|
* Returns whether or not the current environment is a supported
|
|
|
|
* browser on a mobile device.
|
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isSupportedMobileBrowser() {
|
2021-12-09 11:16:08 +00:00
|
|
|
return (Platform.OS === 'android' && browser.isSupportedAndroidBrowser())
|
|
|
|
|| (Platform.OS === 'ios' && browser.isSupportedIOSBrowser());
|
2020-05-19 23:11:32 +00:00
|
|
|
}
|
|
|
|
|
2019-06-20 13:02:15 +00:00
|
|
|
/**
|
|
|
|
* Runs various browser checks to know if the current browser is found within
|
|
|
|
* the list.
|
|
|
|
*
|
|
|
|
* @param {Array<string>} list - Browser names to check. The names should be
|
|
|
|
* keys in {@link browserNameToCheck}.
|
|
|
|
* @private
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-07-29 13:18:14 +00:00
|
|
|
function _isCurrentBrowserInList(list: string[]) {
|
2019-06-20 13:02:15 +00:00
|
|
|
return Boolean(list.find(browserName => {
|
2022-07-29 13:18:14 +00:00
|
|
|
const checkFunction = browserNameToCheck[browserName as keyof typeof browserNameToCheck];
|
2019-06-20 13:02:15 +00:00
|
|
|
|
|
|
|
return checkFunction ? checkFunction.call(browser) : false;
|
|
|
|
}));
|
|
|
|
}
|