|
@@ -34,6 +34,7 @@ export default class ViewSystem {
|
|
|
this.CoreSystem = CS;
|
|
|
this.ModuleSystem = CS.ModuleSystem;
|
|
|
this.EventSystem = CS.EventSystem;
|
|
|
+ this.ghosts = {};
|
|
|
}
|
|
|
|
|
|
getNode(ViewId, NodeId) {
|
|
@@ -58,6 +59,27 @@ export default class ViewSystem {
|
|
|
return this.views[name].render(this.CoreSystem);
|
|
|
}
|
|
|
|
|
|
+ renderModule(mod, id) {
|
|
|
+ let selfView = this.CoreSystem.getCurrentView();
|
|
|
+ let nodeId = "___"+id+"Node";
|
|
|
+ let {
|
|
|
+ value,
|
|
|
+ props,
|
|
|
+ namespace
|
|
|
+ } = mod;
|
|
|
+ if(!selfView.ghosts[nodeId]) {
|
|
|
+ let viewNode = new ViewNode(id, value, props, namespace);
|
|
|
+ let node = new Node(nodeId, {}, viewNode);
|
|
|
+ selfView.ghosts[nodeId] = node;
|
|
|
+ }
|
|
|
+ let vn = selfView.ghosts[nodeId].content;
|
|
|
+ vn.value = value;
|
|
|
+ vn.namespace = namespace;
|
|
|
+
|
|
|
+ let ViewNodeReact = renderContent(selfView.ghosts[nodeId], this.CoreSystem, selfView);
|
|
|
+ return renderNode(selfView.ghosts[nodeId], this.CoreSystem, ViewNodeReact);
|
|
|
+ }
|
|
|
+
|
|
|
export() {
|
|
|
let views = {};
|
|
|
|
|
@@ -92,6 +114,8 @@ export class View {
|
|
|
let rootNode = new Node(Math.random(), {stretchContainer: false, selected: true}); // row
|
|
|
this.addViewNode(rootNode);
|
|
|
this.defaultContainer = rootNode;
|
|
|
+
|
|
|
+ this.ghosts = {};
|
|
|
}
|
|
|
|
|
|
getDefaultContainer() {
|
|
@@ -102,7 +126,7 @@ export class View {
|
|
|
return this.ViewTree.root;
|
|
|
}
|
|
|
getNode(id) {
|
|
|
- return this.ViewTree.getNode(id);
|
|
|
+ return this.ghosts[id] || this.ViewTree.getNode(id);
|
|
|
}
|
|
|
|
|
|
has(node) {
|
|
@@ -126,6 +150,7 @@ export class View {
|
|
|
}
|
|
|
|
|
|
getParent(node) {
|
|
|
+ if(!this.has(node)) return false;
|
|
|
return this.getNode(this.ViewTree.getParent(node));
|
|
|
}
|
|
|
|
|
@@ -222,12 +247,15 @@ export class View {
|
|
|
}
|
|
|
|
|
|
import(data, parentNode) {
|
|
|
- let { tree } = data;
|
|
|
+ let { tree, ghosts } = data;
|
|
|
if(!parentNode)
|
|
|
this.ViewTree = new Tree();
|
|
|
try {
|
|
|
this.ViewTree.import(tree, Node, parentNode);
|
|
|
this.defaultContainer = this.ViewTree.root;
|
|
|
+ for(var i in ghosts) {
|
|
|
+ this.ghosts[i] = new Node().import(ghosts[i]);
|
|
|
+ }
|
|
|
} catch(e) {
|
|
|
log(e);
|
|
|
throw new Error("ViewSystem import error : ", e);
|
|
@@ -237,8 +265,15 @@ export class View {
|
|
|
|
|
|
export(node) {
|
|
|
let tree = this.ViewTree.export(node);
|
|
|
+
|
|
|
+ let ghostsExported = {};
|
|
|
+ for(var i in this.ghosts) {
|
|
|
+ ghostsExported[i] = this.ghosts[i].export();
|
|
|
+ }
|
|
|
+
|
|
|
return {
|
|
|
- tree
|
|
|
+ tree,
|
|
|
+ ghosts: ghostsExported
|
|
|
};
|
|
|
}
|
|
|
}
|
|
@@ -266,26 +301,14 @@ let Renderer = (props) => {
|
|
|
let ViewNodeReact;
|
|
|
// IF CONTENT
|
|
|
if(viewNode) {
|
|
|
- // Create ref
|
|
|
- ModuleSystem.createRef(viewNode.id);
|
|
|
- // Crete element
|
|
|
- ViewNodeReact = ModuleSystem.createElement(
|
|
|
- viewNode.value,
|
|
|
- {
|
|
|
- ...viewNode.props,
|
|
|
- ModuleID: viewNode.id,
|
|
|
- NodeID: node.id,
|
|
|
- EventSystem: EventSystem,
|
|
|
- CoreSystem: CoreSystem,
|
|
|
- View: selfView
|
|
|
- },
|
|
|
- null, // children
|
|
|
- viewNode.namespace,
|
|
|
- viewNode.id
|
|
|
- );
|
|
|
- }
|
|
|
- ModuleSystem.createRef(node.id);
|
|
|
- return ModuleSystem.createElementCtor(
|
|
|
+ ViewNodeReact = renderContent(node, CoreSystem, selfView);
|
|
|
+ }
|
|
|
+ return renderNode(node, CoreSystem, ViewNodeReact, childrenReact);
|
|
|
+}
|
|
|
+
|
|
|
+let renderNode = (node, CoreSystem, ViewNodeReact, childrenReact) => {
|
|
|
+ CoreSystem.ModuleSystem.createRef(node.id);
|
|
|
+ return CoreSystem.ModuleSystem.createElementCtor(
|
|
|
node.ctor,
|
|
|
{
|
|
|
...node.props,
|
|
@@ -298,7 +321,26 @@ let Renderer = (props) => {
|
|
|
node.id
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
+let renderContent = (node, CoreSystem, selfView) => {
|
|
|
+ let viewNode = node.content;
|
|
|
+ // Create ref
|
|
|
+ CoreSystem.ModuleSystem.createRef(viewNode.id);
|
|
|
+ // Crete element
|
|
|
+ return CoreSystem.ModuleSystem.createElement(
|
|
|
+ viewNode.value,
|
|
|
+ {
|
|
|
+ ...viewNode.props,
|
|
|
+ ModuleID: viewNode.id,
|
|
|
+ NodeID: node.id,
|
|
|
+ EventSystem: CoreSystem.EventSystem,
|
|
|
+ CoreSystem: CoreSystem,
|
|
|
+ View: selfView
|
|
|
+ },
|
|
|
+ null, // children
|
|
|
+ viewNode.namespace,
|
|
|
+ viewNode.id
|
|
|
+ );
|
|
|
+}
|
|
|
const styles = StyleSheet.create({
|
|
|
colWrapper: {
|
|
|
"position": "absolute",
|