<commit_before>import { getLogger } from 'jitsi-meet-logger';
import { BrowserDetection } from 'js-utils';

const logger = getLogger(__filename);

// TODO: Move this code to js-utils.

// NOTE: Now we are extending BrowserDetection in order to preserve
// RTCBrowserType interface but maybe it worth exporting BrowserCapabilities
// and BrowserDetection as separate objects in future.

/**
 * Implements browser capabilities for lib-jitsi-meet.
 */
export default class BrowserCapabilities extends BrowserDetection {
    /**
     * Creates new BrowserCapabilities instance.
     */
    constructor() {
        super();
        logger.info(
            `This appears to be ${this.getName()}, ver: ${this.getVersion()}`);
    }

    /**
     * Tells whether or not the <tt>MediaStream/tt> is removed from
     * the <tt>PeerConnection</tt> and disposed on video mute (in order to turn
     * off the camera device).
     * @return {boolean} <tt>true</tt> if the current browser supports this
     * strategy or <tt>false</tt> otherwise.
     */
    doesVideoMuteByStreamRemove() {
        return !(
            this.isFirefox()
            || this.isEdge()
            || this.isReactNative()
            || this.isSafariWithWebrtc()
        );
    }

    /**
     * Check whether or not the current browser support peer to peer connections
     * @return {boolean} <tt>true</tt> if p2p is supported or <tt>false</tt>
     * otherwise.
     */
    supportsP2P() {
        return !this.isEdge() && !this.isFirefox();
    }

    /**
     * Checks if the current browser is Chromium based, that is, it's either
     * Chrome / Chromium or uses it as its engine, but doesn't identify as
     * Chrome.
     *
     * This includes the following browsers:
     * - Chrome and Chromium
     * - Other browsers which use the Chrome engine, but are detected as Chrome,
     *   such as Brave and Vivaldi
     * - Browsers which are NOT Chrome but use it as their engine, and have
     *   custom detection code: Opera, Electron and NW.JS
     */
    isChromiumBased() {
        return this.isChrome()
            || this.isElectron()
            || this.isNWJS()
            || this.isOpera();
    }

    /**
     * Checks if current browser is a Safari and a version of Safari that
     * supports native webrtc.
     *
     * @returns {boolean}
     */
    isSafariWithWebrtc() {
        return this.isSafari()
            && !this.isVersionLessThan('11');
    }

    /**
     * Checks if current browser is a Safari and a version of Safari that
     * supports VP8.
     *
     * @returns {boolean}
     */
    isSafariWithVP8() {
        return this.isSafari()
            && !this.isVersionLessThan('12.1');
    }

    /**
     * Checks if the current browser is supported.
     *
     * @returns {boolean} true if the browser is supported, false otherwise.
     */
    isSupported() {
        return this.isChromiumBased()
            || this.isFirefox()
            || this.isReactNative()
            || this.isSafariWithWebrtc();
    }

    /**
     * Checks if the current browser triggers 'onmute'/'onunmute' events when
     * user's connection is interrupted and the video stops playback.
     * @returns {*|boolean} 'true' if the event is supported or 'false'
     * otherwise.
     */
    supportsVideoMuteOnConnInterrupted() {
        return this.isChromiumBased() || this.isReactNative()
            || this.isSafariWithVP8();
    }

    /**
     * Checks if the current browser reports upload and download bandwidth
     * statistics.
     * @return {boolean}
     */
    supportsBandwidthStatistics() {
        // FIXME bandwidth stats are currently not implemented for FF on our
        // side, but not sure if not possible ?<commit_msg>feat(browsers): add check for env requiring interaction to unmute (#935)<commit_after>import { getLogger } from 'jitsi-meet-logger';
import { BrowserDetection } from 'js-utils';

const logger = getLogger(__filename);

// TODO: Move this code to js-utils.

// NOTE: Now we are extending BrowserDetection in order to preserve
// RTCBrowserType interface but maybe it worth exporting BrowserCapabilities
// and BrowserDetection as separate objects in future.

/**
 * Implements browser capabilities for lib-jitsi-meet.
 */
export default class BrowserCapabilities extends BrowserDetection {
    /**
     * Creates new BrowserCapabilities instance.
     */
    constructor() {
        super();
        logger.info(
            `This appears to be ${this.getName()}, ver: ${this.getVersion()}`);
    }

    /**
     * Tells whether or not the <tt>MediaStream/tt> is removed from
     * the <tt>PeerConnection</tt> and disposed on video mute (in order to turn
     * off the camera device).
     * @return {boolean} <tt>true</tt> if the current browser supports this
     * strategy or <tt>false</tt> otherwise.
     */
    doesVideoMuteByStreamRemove() {
        return !(
            this.isFirefox()
            || this.isEdge()
            || this.isReactNative()
            || this.isSafariWithWebrtc()
        );
    }

    /**
     * Check whether or not the current browser support peer to peer connections
     * @return {boolean} <tt>true</tt> if p2p is supported or <tt>false</tt>
     * otherwise.
     */
    supportsP2P() {
        return !this.isEdge() && !this.isFirefox();
    }

    /**
     * Checks if the current browser is Chromium based, that is, it's either
     * Chrome / Chromium or uses it as its engine, but doesn't identify as
     * Chrome.
     *
     * This includes the following browsers:
     * - Chrome and Chromium
     * - Other browsers which use the Chrome engine, but are detected as Chrome,
     *   such as Brave and Vivaldi
     * - Browsers which are NOT Chrome but use it as their engine, and have
     *   custom detection code: Opera, Electron and NW.JS
     */
    isChromiumBased() {
        return this.isChrome()
            || this.isElectron()
            || this.isNWJS()
            || this.isOpera();
    }

    /**
     * Checks if current browser is a Safari and a version of Safari that
     * supports native webrtc.
     *
     * @returns {boolean}
     */
    isSafariWithWebrtc() {
        return this.isSafari()
            && !this.isVersionLessThan('11');
    }

    /**
     * Checks if current browser is a Safari and a version of Safari that
     * supports VP8.
     *
     * @returns {boolean}
     */
    isSafariWithVP8() {
        return this.isSafari()
            && !this.isVersionLessThan('12.1');
    }

    /**
     * Checks if the current browser is supported.
     *
     * @returns {boolean} true if the browser is supported, false otherwise.
     */
    isSupported() {
        return this.isChromiumBased()
            || this.isFirefox()
            || this.isReactNative()
            || this.isSafariWithWebrtc();
    }

    /**
     * Returns whether or not the current environment needs a user interaction
     * with the page before any unmute can occur.
     *
     * @returns {boolean}
     */
    isUserInteractionRequiredForUnmute() {
        return this.isFirefox() || this.isSafari();
    }

    /**
     * Checks if the current browser triggers 'onmute'/'onunmute' events when
     * user's connection is interrupted and the video stops playback.
     * @returns {*|boolean} 'true' if the event is supported or 'false'
     * otherwise.
     */
    supportsVideoMuteOnConnInterrupted() {
        return this.isChromiumBased() || this.isReactNative()
            || this.isSafariWithVP8();
    }

    /**
     * Checks if the current browser reports upload and download bandwidth
     * statistics.
     * @return {boolean}
     */
    supportsBandwidthStatistics() {
        // FIXME bandwidth stats are currently not implemented for FF on our
        // side, but not sure if not possible ?
{'fraction_non_alphanumeric': 0.10417464572960551, 'fraction_numerical': 0.0029362951614962337, 'mean_word_length': 2.2519717725197177, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1995428', 'n_tokens_mistral': 2267, 'n_tokens_neox': 2200, 'n_words': 722}