rolesMap.js 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3. var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4. _Object$defineProperty(exports, "__esModule", {
  5. value: true
  6. });
  7. exports.default = void 0;
  8. var _getIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/get-iterator"));
  9. var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  10. var _getIteratorMethod2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/get-iterator-method"));
  11. var _symbol = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/symbol"));
  12. var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
  13. var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  14. var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
  15. var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
  16. var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
  17. var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  18. var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
  19. var _ariaAbstractRoles = _interopRequireDefault(require("./etc/roles/ariaAbstractRoles"));
  20. var _ariaLiteralRoles = _interopRequireDefault(require("./etc/roles/ariaLiteralRoles"));
  21. var _ariaDpubRoles = _interopRequireDefault(require("./etc/roles/ariaDpubRoles"));
  22. var _context;
  23. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof _symbol.default === "undefined" || (0, _getIteratorMethod2.default)(o) == null) { if ((0, _isArray.default)(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = (0, _getIterator2.default)(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  24. function _unsupportedIterableToArray(o, minLen) { var _context2; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = (0, _slice.default)(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return (0, _from.default)(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  25. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  26. var rolesMap = new _map.default([]);
  27. (0, _forEach.default)(_context = [_ariaAbstractRoles.default, _ariaLiteralRoles.default, _ariaDpubRoles.default]).call(_context, function (roleSet) {
  28. (0, _forEach.default)(roleSet).call(roleSet, function (roleDefinition, name) {
  29. return rolesMap.set(name, roleDefinition);
  30. });
  31. });
  32. (0, _forEach.default)(rolesMap).call(rolesMap, function (roleDefinition, name) {
  33. // Conglomerate the properties
  34. var _iterator = _createForOfIteratorHelper(roleDefinition.superClass),
  35. _step;
  36. try {
  37. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  38. var superClassIter = _step.value;
  39. var _iterator2 = _createForOfIteratorHelper(superClassIter),
  40. _step2;
  41. try {
  42. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  43. var superClassName = _step2.value;
  44. var superClassDefinition = rolesMap.get(superClassName);
  45. if (superClassDefinition) {
  46. for (var _i = 0, _Object$keys = (0, _keys.default)(superClassDefinition.props); _i < _Object$keys.length; _i++) {
  47. var prop = _Object$keys[_i];
  48. if (!Object.prototype.hasOwnProperty.call(roleDefinition.props, prop)) {
  49. (0, _assign.default)(roleDefinition.props, (0, _defineProperty2.default)({}, prop, superClassDefinition.props[prop]));
  50. }
  51. }
  52. }
  53. }
  54. } catch (err) {
  55. _iterator2.e(err);
  56. } finally {
  57. _iterator2.f();
  58. }
  59. }
  60. } catch (err) {
  61. _iterator.e(err);
  62. } finally {
  63. _iterator.f();
  64. }
  65. });
  66. var _default = rolesMap;
  67. exports.default = _default;