accessibility.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var accessibility_exports = {};
  20. __export(accessibility_exports, {
  21. Accessibility: () => Accessibility
  22. });
  23. module.exports = __toCommonJS(accessibility_exports);
  24. function axNodeFromProtocol(axNode) {
  25. const result = {
  26. ...axNode,
  27. value: axNode.valueNumber !== void 0 ? axNode.valueNumber : axNode.valueString,
  28. checked: axNode.checked === "checked" ? true : axNode.checked === "unchecked" ? false : axNode.checked,
  29. pressed: axNode.pressed === "pressed" ? true : axNode.pressed === "released" ? false : axNode.pressed,
  30. children: axNode.children ? axNode.children.map(axNodeFromProtocol) : void 0
  31. };
  32. delete result.valueNumber;
  33. delete result.valueString;
  34. return result;
  35. }
  36. class Accessibility {
  37. constructor(channel) {
  38. this._channel = channel;
  39. }
  40. async snapshot(options = {}) {
  41. const root = options.root ? options.root._elementChannel : void 0;
  42. const result = await this._channel.accessibilitySnapshot({ interestingOnly: options.interestingOnly, root });
  43. return result.rootAXNode ? axNodeFromProtocol(result.rootAXNode) : null;
  44. }
  45. }
  46. // Annotate the CommonJS export names for ESM import in node:
  47. 0 && (module.exports = {
  48. Accessibility
  49. });