From 15afd7e23ef8278e0e3a8cddcef13c8b55d8a8a3 Mon Sep 17 00:00:00 2001 From: Khoa Nguyen Date: Tue, 19 Dec 2023 16:38:33 +0800 Subject: [PATCH 1/2] Add support for crios (chrome on iOS) --- capabilities.js | 57 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/capabilities.js b/capabilities.js index c0fb013..a148b53 100644 --- a/capabilities.js +++ b/capabilities.js @@ -1,35 +1,54 @@ -'use strict'; +"use strict" -var browser = require('detect-browser').detect(); -var compareVersions = require('compare-versions') +const browser = require("detect-browser").detect() +const compareVersions = require("compare-versions") -var capabilities = module.exports = { - moz: typeof navigator != 'undefined' && !!navigator.mozGetUserMedia, - browser: browser.name, - browserVersion: browser.version -}; +const capabilities = (module.exports = { + moz: typeof navigator != "undefined" && !!navigator.mozGetUserMedia, + browser: browser.name, + browserVersion: browser.version, +}) + +const getConstraintsType = (condition: boolean) => + condition ? "standard" : "legacy" // Mozilla constraings handling if (capabilities.moz) { - capabilities.constraintsType = (compareVersions(browser.version, '38.0.0') >= 0 ? 'standard' : 'legacy'); + capabilities.constraintsType = getConstraintsType( + compareVersions(browser.version, "38.0.0") >= 0 + ) } // Chrome constraints handling -else if (browser.name === 'chrome') { - capabilities.constraintsType = (compareVersions(browser.version, '53.0.0') >= 0 ? 'standard' : 'legacy'); +else if (browser.name === "chrome") { + capabilities.constraintsType = getConstraintsType( + compareVersions(browser.version, "53.0.0") >= 0 + ) +} +// Chrome on iOS constraints handling +else if (browser.name === "crios") { + capabilities.constraintsType = getConstraintsType( + compareVersions(browser.version, "56.0.0") >= 0 + ) } // Safari constraints handling -else if (browser.name === 'safari') { - capabilities.constraintsType = (compareVersions(browser.version, '12.0.0') >= 0 ? 'standard' : 'legacy'); +else if (browser.name === "safari") { + capabilities.constraintsType = getConstraintsType( + compareVersions(browser.version, "12.0.0") >= 0 + ) } // Edge constraints handling -else if ((/^edge.*$/).test(browser.name)) { - capabilities.constraintsType = (compareVersions(browser.version, '79.0.0') >= 0 ? 'standard' : 'legacy'); +else if (/^edge.*$/.test(browser.name)) { + capabilities.constraintsType = getConstraintsType( + compareVersions(browser.version, "79.0.0") >= 0 + ) } // iOS Safari constraints handling -else if (browser.name === 'ios') { - capabilities.constraintsType = (compareVersions(browser.version, '11.0.0') >= 0 ? 'standard' : 'legacy'); +else if (browser.name === "ios") { + capabilities.constraintsType = getConstraintsType( + compareVersions(browser.version, "11.0.0") >= 0 + ) } // Default constraints handling else { - capabilities.constraintsType = 'legacy'; -} \ No newline at end of file + capabilities.constraintsType = "legacy" +} From 3d5c43e8e4c81533233d9ea197fc2259767feb54 Mon Sep 17 00:00:00 2001 From: Khoa Nguyen Date: Tue, 19 Dec 2023 16:41:22 +0800 Subject: [PATCH 2/2] 4.4.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6424244..a8bcb5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rtc-captureconfig", - "version": "4.4.1", + "version": "4.4.2", "description": "Simple string definition -> WebRTC constraints", "main": "index.js", "scripts": {