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.

middlewares.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. exports.multiremoteHandler = exports.elementErrorHandler = void 0;
  7. const refetchElement_1 = __importDefault(require("./utils/refetchElement"));
  8. const implicitWait_1 = __importDefault(require("./utils/implicitWait"));
  9. const constants_1 = require("./constants");
  10. exports.elementErrorHandler = (fn) => (commandName, commandFn) => {
  11. return function elementErrorHandlerCallback(...args) {
  12. return fn(commandName, async function elementErrorHandlerCallbackFn() {
  13. const element = await implicitWait_1.default(this, commandName);
  14. this.elementId = element.elementId;
  15. this[constants_1.ELEMENT_KEY] = element.elementId;
  16. try {
  17. const result = await fn(commandName, commandFn).apply(this, args);
  18. if (result && result.error === 'no such element') {
  19. const err = new Error();
  20. err.name = 'stale element reference';
  21. throw err;
  22. }
  23. return result;
  24. }
  25. catch (error) {
  26. if (error.name === 'stale element reference') {
  27. const element = await refetchElement_1.default(this, commandName);
  28. this.elementId = element.elementId;
  29. this.parent = element.parent;
  30. return await fn(commandName, commandFn).apply(this, args);
  31. }
  32. throw error;
  33. }
  34. }).apply(this);
  35. };
  36. };
  37. exports.multiremoteHandler = (wrapCommand) => (commandName) => {
  38. return wrapCommand(commandName, function (...args) {
  39. const commandResults = this.instances.map((instanceName) => {
  40. return this[instanceName][commandName](...args);
  41. });
  42. return Promise.all(commandResults);
  43. });
  44. };