Systems.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireDefault(require("react"));
  7. var _Logger = _interopRequireDefault(require("./Logger"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12. var Systems =
  13. /*#__PURE__*/
  14. function () {
  15. function Systems() {
  16. _classCallCheck(this, Systems);
  17. this.CoreSystem = null;
  18. this.subSystems = {
  19. core: null
  20. };
  21. this.modules = {};
  22. this.services = {};
  23. }
  24. _createClass(Systems, [{
  25. key: "setCore",
  26. value: function setCore(core) {
  27. this.subSystems.core = core;
  28. this.CoreSystem = core;
  29. core.LinkManager.disableCore();
  30. this.decorate('core', core.ModuleSystem);
  31. this.decorate('core', core.ServiceSystem);
  32. this.decorate('core', core.LinkManager);
  33. this.decorate('core', core.RoutingSystem);
  34. return core;
  35. }
  36. }, {
  37. key: "getCore",
  38. value: function getCore() {
  39. return this.CoreSystem;
  40. }
  41. }, {
  42. key: "addSystem",
  43. value: function addSystem(core) {
  44. var id = core.id;
  45. if (!id) {
  46. _Logger.default.error("Cannot addSystem core.id is not defined!", core, id);
  47. return;
  48. }
  49. this.subSystems[id] = core;
  50. this.decorate(id, core.ModuleSystem);
  51. this.decorate(id, core.ServiceSystem);
  52. this.decorate(id, core.LinkManager);
  53. this.decorate(id, core.RoutingSystem);
  54. }
  55. }, {
  56. key: "getSystem",
  57. value: function getSystem(id) {
  58. return this.subSystems[id];
  59. }
  60. }, {
  61. key: "decorate",
  62. value: function decorate(id, obj) {
  63. obj.CoreSystem = this.subSystems[id];
  64. obj.ModuleSystem = this.subSystems[id].ModuleSystem;
  65. obj.ServiceSystem = this.subSystems[id].ServiceSystem;
  66. obj.RoutingSystem = this.subSystems[id].RoutingSystem;
  67. obj.LinkManager = this.subSystems[id].LinkManager;
  68. }
  69. }, {
  70. key: "systemAdmin",
  71. value: function systemAdmin(id) {
  72. // ?
  73. var LM = this.subSystems[id].LinkManager;
  74. }
  75. }, {
  76. key: "addService",
  77. value: function addService(ser) {
  78. this.services[(ser.Namespace || 'General') + (ser.Category || 'Uncategorized') + ser.name] = ser;
  79. }
  80. }, {
  81. key: "addModule",
  82. value: function addModule(mod) {
  83. this.modules[(mod.Namespace || 'General') + (mod.Category || 'Uncategorized') + mod.name] = mod;
  84. }
  85. }, {
  86. key: "addServices",
  87. value: function addServices(sers) {
  88. for (var i in sers) {
  89. this.addService(sers[i]);
  90. }
  91. }
  92. }, {
  93. key: "addModules",
  94. value: function addModules(mods) {
  95. console.log("Adding Modules");
  96. for (var i in mods) {
  97. console.log(mods[i]);
  98. this.addModule(mods[i]);
  99. }
  100. }
  101. }, {
  102. key: "getModule",
  103. value: function getModule(name) {
  104. var Category = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Uncategorized';
  105. var Namespace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'General';
  106. return this.modules[Namespace + Category + name];
  107. }
  108. }, {
  109. key: "getService",
  110. value: function getService(name) {
  111. var Category = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Uncategorized';
  112. var Namespace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'General';
  113. return this.services[Namespace + Category + name];
  114. }
  115. }, {
  116. key: "getModules",
  117. value: function getModules() {
  118. return this.modules;
  119. }
  120. }, {
  121. key: "getServices",
  122. value: function getServices() {
  123. return this.services;
  124. }
  125. }]);
  126. return Systems;
  127. }();
  128. var _default = new Systems();
  129. exports.default = _default;