123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _react = _interopRequireDefault(require("react"));
- var _Types = _interopRequireDefault(require("./Types"));
- var _ModuleUtilities = require("./ModuleUtilities");
- var _AdminModule2 = _interopRequireDefault(require("./AdminModule.js"));
- var _Systems = _interopRequireDefault(require("../systems/Systems"));
- require("./Module.css");
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
- window.ModuleRefs = {};
- var Module =
- /*#__PURE__*/
- function (_AdminModule) {
- _inherits(Module, _AdminModule);
- // we need reference
- function Module(props) {
- var _this;
- _classCallCheck(this, Module);
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Module).call(this, props));
- _this.decorate(props.systemID, _assertThisInitialized(_this));
- _this.__id = props.id || _this.__genRandom();
- _this._finalInputs = {};
- _this._finalOutputs = {};
- _this._loadInputs(props.inrefs || {});
- _this._loadOutputs(props.outrefs || {});
- _this._loadChildren(props.children);
- return _this;
- }
- _createClass(Module, [{
- key: "setState",
- value: function setState(data) {
- if (this._ismounted) {
- _get(_getPrototypeOf(Module.prototype), "setState", this).call(this, data);
- }
- }
- }, {
- key: "decorate",
- value: function decorate() {
- var systemid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "core";
- _Systems.default.decorate(systemid, this);
- }
- }, {
- key: "forceUpdate",
- value: function forceUpdate() {
- if (this._ismounted) {
- _get(_getPrototypeOf(Module.prototype), "forceUpdate", this).call(this);
- }
- }
- }, {
- key: "componentDidMount",
- value: function componentDidMount() {
- this._ismounted = true;
- }
- }, {
- key: "componentWillUnmount",
- value: function componentWillUnmount() {
- this._ismounted = false;
- }
- }, {
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(props) {
- for (var i in props) {
- if (this.constructor.Inputs[i] && this[i] && this[i].value !== props[i]) {
- this[i].update(props[i]);
- }
- } // this._loadInputs(props.inrefs || {});
- // this._loadOutputs(props.outrefs || {});
- this.forceUpdate();
- }
- }, {
- key: "_loadChildren",
- value: function _loadChildren(children) {//this.props.children = children;
- }
- }, {
- key: "_loadInputs",
- value: function _loadInputs(inputs) {
- for (var i in this.constructor.Inputs) {
- this.generateInput(inputs[i], i, false);
- }
- }
- }, {
- key: "generateInput",
- value: function generateInput(input, i) {
- var _this2 = this;
- var dynamic = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- this[i] = input || this.LinkManager.ghostInputRef((this.props.inputs || {})[i] || this._defaultInput(i), true, this.props);
- this[i].onUpdate(function () {
- return _this2.forceUpdate();
- });
- if (dynamic) {
- this.properties.Inputs[i] = input;
- this.props.inrefs[i] = this[i];
- this.props.inputs[i] = this[i];
- }
- }
- }, {
- key: "_loadOutputs",
- value: function _loadOutputs(outputs) {
- for (var i in this.constructor.Outputs) {
- this.generateOutput(outputs[i], i, false);
- }
- }
- }, {
- key: "generateOutput",
- value: function generateOutput(output, i) {
- var dynamic = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- this[i] = output || this.LinkManager.ghostOutputRef((this.props.outputs || {})[i] || this._defaultOutput(i), true, this.props);
- if (this[i].value !== undefined) this[i].set(this[i].value);
- if (dynamic) {
- this.properties.Outputs[i] = output;
- this.props.outputs[i] = this[i];
- }
- }
- }, {
- key: "__genRandom",
- value: function __genRandom() {
- return '' + parseInt(Math.random() * 123456) % 56921;
- }
- }, {
- key: "_defaultInput",
- value: function _defaultInput(name) {
- return {
- name: name,
- value: this.props[name] || this.constructor.Inputs[name].defaultValue,
- type: this.constructor.Inputs[name].type
- };
- }
- }, {
- key: "_defaultOutput",
- value: function _defaultOutput(name) {
- return {
- name: name,
- value: this.constructor.Outputs[name].defaultValue
- };
- }
- }, {
- key: "getId",
- value: function getId() {
- return this.__id;
- }
- }, {
- key: "getRef",
- value: function getRef() {
- return this.__ref;
- }
- }, {
- key: "render",
- value: function render() {
- var withChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
- var res = [];
- if (localStorage.getItem('AdminMode') === "admin" && this.props.systemID === 'core') res[0] = _get(_getPrototypeOf(Module.prototype), "render", this).call(this);
- if (Array.isArray(this.props.children) && withChildren) res = [res[0]].concat(_toConsumableArray(this.props.children));else if (this.props.children && withChildren) res.push(this.props.children);
- return res;
- }
- }]);
- return Module;
- }(_AdminModule2.default);
- Module.Inputs = {// view: {
- // type: Types.View
- // }
- };
- Module.Category = "Base";
- Module.Types = _Types.default;
- Module.InputMarker = _ModuleUtilities.InputMarker;
- Module.RemoveMarker = _ModuleUtilities.RemoveMarker;
- Module.OutputMarker = _ModuleUtilities.OutputMarker;
- var _default = Module;
- exports.default = _default;
|