let Types = { Boolean: 0, Text: 1, Integer: 2, URL: 3, somethingelse: 4, Link: 5, Array: 6, View: 7, Object: 8, Real: 9, Float: 10, Modules: 11, Whatever: 12, Action: 13, Module: 14 } class Type { constructor(type) { this.type = type; } getType() { return Object.keys(Types)[this.type]; } parse(value) { return value; } resolve(value) { console.log("Called resolve on base super Type component"); return true; } default(value) { this.defaultValue = value; return this; } require() { this.isRequired = true; return this; } } class Bool extends Type { constructor() { super(Types.Boolean); } resolve(value) { if((value !== undefined || this.isRequired) && value !== true && value !== false) return false; return true; } parse(value) { return value === 'true' || value === "1" || value === 1 || value === true; } } class Action extends Type { constructor() { super(Types.Action); } resolve(value) { if(typeof value !== "object") return false; if(typeof value.type !== "string") return false; return true; } parse(value) { if(!value) return { _Action: {empty: true}}; let { type, data } = value; return { _Action: {initial: value}, type, data }; } } class Text extends Type { constructor() { super(Types.Text); } color() { this.isColor = true; return this; } resolve(value) { if(typeof value === "string") return true; else if ((value === undefined || value === null) && !this.isRequired) return true return true; } } class Integer extends Type { constructor() { super(Types.Integer); } parse(value) { try{ return parseInt(value); }catch(e) { return this.defaultValue || 0; } } resolve(value) { if (typeof value === "number" && parseInt(value) === value) return true; else if ((value === undefined || value === null) && !this.isRequired) return true; return false; } } class Real extends Type { constructor() { super(Types.Real); } parse(value) { try{ return parseFloat(value); }catch(e) { return this.defaultValue || 0; } } resolve(value) { if (typeof value === "number" && parseFloat(value) === value) return true; else if ((value === undefined || value === null) && !this.isRequired) return true; return false; } } class JSObject extends Type { constructor() { super(Types.Object); } resolve(value) { if (typeof value === "object") return true; else if ((value === undefined || value === null) && !this.isRequired) return true; return false; } } class JSArray extends Type{ constructor(Template){ super(Types.Array); this.Template = Template; } resolve(value){ if(Array.isArray(value)) { for(var i=0;i