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.

getPuppeteer.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
  7. const constants_1 = require("../../constants");
  8. async function getPuppeteer() {
  9. var _a, _b, _c;
  10. if (this.puppeteer) {
  11. return this.puppeteer;
  12. }
  13. const chromiumOptions = this.capabilities['goog:chromeOptions'] || this.capabilities['ms:edgeOptions'];
  14. if (chromiumOptions && chromiumOptions.debuggerAddress) {
  15. this.puppeteer = await puppeteer_core_1.default.connect({
  16. browserURL: `http://${chromiumOptions.debuggerAddress}`,
  17. defaultViewport: null
  18. });
  19. return this.puppeteer;
  20. }
  21. if (((_a = this.capabilities.browserName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'firefox') {
  22. if (!this.capabilities.browserVersion) {
  23. throw new Error('Can\'t find "browserVersion" in capabilities');
  24. }
  25. const majorVersion = parseInt(this.capabilities.browserVersion.split('.').shift() || '', 10);
  26. if (majorVersion >= 79) {
  27. const ffOptions = this.capabilities['moz:firefoxOptions'];
  28. const ffArgs = (_b = this.requestedCapabilities['moz:firefoxOptions']) === null || _b === void 0 ? void 0 : _b.args;
  29. const rdPort = ffOptions && ffOptions.debuggerAddress
  30. ? ffOptions.debuggerAddress
  31. : (_c = ffArgs === null || ffArgs === void 0 ? void 0 : ffArgs[ffArgs.findIndex((arg) => arg === constants_1.FF_REMOTE_DEBUG_ARG) + 1]) !== null && _c !== void 0 ? _c : null;
  32. if (!rdPort) {
  33. throw new Error('Could\'t find remote debug port in Firefox options');
  34. }
  35. this.puppeteer = await puppeteer_core_1.default.connect({
  36. browserURL: `http://localhost:${rdPort}`,
  37. defaultViewport: null
  38. });
  39. return this.puppeteer;
  40. }
  41. }
  42. throw new Error('Using DevTools capabilities is not supported for this session. ' +
  43. 'This feature is only supported for local testing on Chrome, Firefox and Chromium Edge.');
  44. }
  45. exports.default = getPuppeteer;