12345678 |
- import React from'react';import Types from'./Types';import{InputMarker,OutputMarker,RemoveMarker}from'./ModuleUtilities';import AdminModule from'./AdminModule.js';import Systems from'../systems/Systems';import'./Module.css';window.ModuleRefs={};class Module extends AdminModule{// we need reference
- constructor(a){super(a),this.decorate(a.systemID,this),this.__id=a.id||this.__genRandom(),this._finalInputs={},this._finalOutputs={},this._loadInputs(a.inrefs||{}),this._loadOutputs(a.outrefs||{}),this._loadChildren(a.children)}setState(a){this._ismounted&&super.setState(a)}decorate(a='core'){Systems.decorate(a,this)}forceUpdate(){this._ismounted&&super.forceUpdate()}componentDidMount(){this._ismounted=!0}componentWillUnmount(){this._ismounted=!1}componentWillReceiveProps(a){for(var b in a)this.constructor.Inputs[b]&&this[b]&&this[b].value!==a[b]&&this[b].update(a[b]);// this._loadInputs(props.inrefs || {});
- // this._loadOutputs(props.outrefs || {});
- this.forceUpdate()}_loadChildren(){//this.props.children = children;
- }_loadInputs(a){for(var b in this.constructor.Inputs)this.generateInput(a[b],b,!1)}generateInput(a,b,c=!0){this[b]=a||this.LinkManager.ghostInputRef((this.props.inputs||{})[b]||this._defaultInput(b),!0,this.props),this[b].onUpdate(()=>this.forceUpdate()),c&&(this.properties.Inputs[b]=a,this.props.inrefs[b]=this[b],this.props.inputs[b]=this[b])}_loadOutputs(a){for(var b in this.constructor.Outputs)this.generateOutput(a[b],b,!1)}generateOutput(a,b,c=!0){this[b]=a||this.LinkManager.ghostOutputRef((this.props.outputs||{})[b]||this._defaultOutput(b),!0,this.props),this[b].value!==void 0&&this[b].set(this[b].value),c&&(this.properties.Outputs[b]=a,this.props.outputs[b]=this[b])}__genRandom(){return''+parseInt(123456*Math.random())%56921}_defaultInput(a){return{name:a,value:this.props[a]||this.constructor.Inputs[a].defaultValue,type:this.constructor.Inputs[a].type}}_defaultOutput(a){return{name:a,value:this.constructor.Outputs[a].defaultValue}}getId(){return this.__id}getRef(){return this.__ref}render(a=!0){let b=[];return'admin'===localStorage.getItem('AdminMode')&&'core'===this.props.systemID&&(b[0]=super.render()),Array.isArray(this.props.children)&&a?b=[b[0],...this.props.children]:this.props.children&&a&&b.push(this.props.children),b}}Module.Inputs={// view: {
- // type: Types.View
- // }
- },Module.Category='Base',Module.Types=Types,Module.InputMarker=InputMarker,Module.RemoveMarker=RemoveMarker,Module.OutputMarker=OutputMarker;export default Module;
|