Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

envDetector.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.webdriverEnvironmentDetector = exports.devtoolsEnvironmentDetector = exports.sessionEnvironmentDetector = exports.capabilitiesEnvironmentDetector = exports.isW3C = void 0;
  4. const MOBILE_BROWSER_NAMES = ['ipad', 'iphone', 'android'];
  5. const MOBILE_CAPABILITIES = [
  6. 'appium-version', 'appiumVersion', 'device-type', 'deviceType',
  7. 'device-orientation', 'deviceOrientation', 'deviceName'
  8. ];
  9. function isW3C(capabilities) {
  10. if (!capabilities) {
  11. return false;
  12. }
  13. const isAppium = Boolean(capabilities.automationName ||
  14. capabilities.deviceName ||
  15. capabilities.appiumVersion);
  16. const hasW3CCaps = Boolean(capabilities.platformName &&
  17. capabilities.browserVersion &&
  18. (capabilities.platformVersion || Object.prototype.hasOwnProperty.call(capabilities, 'setWindowRect')));
  19. return Boolean(hasW3CCaps || isAppium);
  20. }
  21. exports.isW3C = isW3C;
  22. function isChrome(capabilities) {
  23. if (!capabilities) {
  24. return false;
  25. }
  26. return Boolean(capabilities.chrome || capabilities['goog:chromeOptions']);
  27. }
  28. function isMobile(capabilities) {
  29. if (!capabilities) {
  30. return false;
  31. }
  32. const browserName = (capabilities.browserName || '').toLowerCase();
  33. return Boolean(Object.keys(capabilities).find((cap) => MOBILE_CAPABILITIES.includes(cap)) ||
  34. capabilities.browserName === '' ||
  35. MOBILE_BROWSER_NAMES.includes(browserName));
  36. }
  37. function isIOS(capabilities) {
  38. if (!capabilities) {
  39. return false;
  40. }
  41. return Boolean((capabilities.platformName && capabilities.platformName.match(/iOS/i)) ||
  42. (capabilities.deviceName && capabilities.deviceName.match(/(iPad|iPhone)/i)));
  43. }
  44. function isAndroid(capabilities) {
  45. if (!capabilities) {
  46. return false;
  47. }
  48. return Boolean((capabilities.platformName && capabilities.platformName.match(/Android/i)) ||
  49. (capabilities.browserName && capabilities.browserName.match(/Android/i)));
  50. }
  51. function isSauce(capabilities) {
  52. if (!capabilities) {
  53. return false;
  54. }
  55. const caps = capabilities.alwaysMatch
  56. ? capabilities.alwaysMatch
  57. : capabilities;
  58. return Boolean(caps.extendedDebugging ||
  59. (caps['sauce:options'] &&
  60. caps['sauce:options'].extendedDebugging));
  61. }
  62. function isSeleniumStandalone(capabilities) {
  63. if (!capabilities) {
  64. return false;
  65. }
  66. return Boolean(capabilities['webdriver.remote.sessionid']);
  67. }
  68. function capabilitiesEnvironmentDetector(capabilities, automationProtocol) {
  69. return automationProtocol === 'devtools'
  70. ? devtoolsEnvironmentDetector(capabilities)
  71. : webdriverEnvironmentDetector(capabilities);
  72. }
  73. exports.capabilitiesEnvironmentDetector = capabilitiesEnvironmentDetector;
  74. function sessionEnvironmentDetector({ capabilities, requestedCapabilities }) {
  75. return {
  76. isW3C: isW3C(capabilities),
  77. isChrome: isChrome(capabilities),
  78. isMobile: isMobile(capabilities),
  79. isIOS: isIOS(capabilities),
  80. isAndroid: isAndroid(capabilities),
  81. isSauce: isSauce(requestedCapabilities),
  82. isSeleniumStandalone: isSeleniumStandalone(capabilities)
  83. };
  84. }
  85. exports.sessionEnvironmentDetector = sessionEnvironmentDetector;
  86. function devtoolsEnvironmentDetector({ browserName }) {
  87. return {
  88. isDevTools: true,
  89. isW3C: true,
  90. isMobile: false,
  91. isIOS: false,
  92. isAndroid: false,
  93. isChrome: browserName === 'chrome',
  94. isSauce: false,
  95. isSeleniumStandalone: false,
  96. };
  97. }
  98. exports.devtoolsEnvironmentDetector = devtoolsEnvironmentDetector;
  99. function webdriverEnvironmentDetector(capabilities) {
  100. return {
  101. isChrome: isChrome(capabilities),
  102. isMobile: isMobile(capabilities),
  103. isIOS: isIOS(capabilities),
  104. isAndroid: isAndroid(capabilities),
  105. isSauce: isSauce(capabilities)
  106. };
  107. }
  108. exports.webdriverEnvironmentDetector = webdriverEnvironmentDetector;