@dualbox/editor 1.0.39 → 1.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/html/editor.html +114 -109
- package/js/dist/GraphEditor.js +301 -269
- package/js/dist/GraphEditor.min.js +300 -268
- package/js/src/GraphEditor.js +3 -3
- package/js/src/m/GraphModel.js +160 -157
- package/js/src/v/Selector.js +56 -44
- package/js/src/v/templates/addNode.vue +1 -1
- package/js/src/v/templates/editMainSettings.vue +23 -5
- package/js/src/v/templates/editNodeSettings.vue +29 -16
- package/js/src/v/templates/graphNode.vue +17 -6
- package/js/src/v/templates/main.vue +1 -2
- package/lib/draco/1.3.5/draco_decoder.js +31 -0
- package/lib/draco/1.3.5/draco_decoder.wasm +0 -0
- package/lib/draco/1.3.5/draco_decoder_gltf.js +31 -0
- package/lib/draco/1.3.5/draco_decoder_gltf.wasm +0 -0
- package/lib/draco/1.3.5/draco_encoder.js +33 -0
- package/lib/draco/1.3.5/draco_wasm_wrapper.js +117 -0
- package/lib/draco/1.3.5/draco_wasm_wrapper_gltf.js +117 -0
- package/package.json +1 -1
package/js/src/m/GraphModel.js
CHANGED
|
@@ -41,7 +41,9 @@ class GraphModel {
|
|
|
41
41
|
windows: null
|
|
42
42
|
};
|
|
43
43
|
this.data.app = this.data.root;
|
|
44
|
-
this.data.windows = [
|
|
44
|
+
this.data.windows = [
|
|
45
|
+
[this.e.rootAppName, this.data.app]
|
|
46
|
+
];
|
|
45
47
|
|
|
46
48
|
// An object to save/restore different states of this.data (ctrl-z/ctrl-y)
|
|
47
49
|
this.history = new History(this);
|
|
@@ -60,7 +62,9 @@ class GraphModel {
|
|
|
60
62
|
|
|
61
63
|
this.data.root = json;
|
|
62
64
|
this.data.app = this.data.root; // reset ptr
|
|
63
|
-
this.data.windows = [
|
|
65
|
+
this.data.windows = [
|
|
66
|
+
[this.e.rootAppName, this.data.app]
|
|
67
|
+
];
|
|
64
68
|
|
|
65
69
|
await this.addNativeTypes();
|
|
66
70
|
|
|
@@ -336,24 +340,21 @@ class GraphModel {
|
|
|
336
340
|
return false;
|
|
337
341
|
}
|
|
338
342
|
var node = this.data.app.modules[id] = desc;
|
|
339
|
-
}
|
|
340
|
-
else if (utils.isUI(pkg.name)) {
|
|
343
|
+
} else if (utils.isUI(pkg.name)) {
|
|
341
344
|
this.ensure('ui');
|
|
342
345
|
if (this.data.app.ui[id]) {
|
|
343
346
|
console.error('Could not add ui ' + id + ': already exists');
|
|
344
347
|
return false;
|
|
345
348
|
}
|
|
346
349
|
var node = this.data.app.ui[id] = desc;
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
350
|
+
} else {
|
|
349
351
|
// may be a metanode
|
|
350
352
|
var nodeDef = idx(this.data.app, o => o.metanodes[pkg.name]);
|
|
351
353
|
if (nodeDef) {
|
|
352
354
|
this.ensure('modules');
|
|
353
355
|
var node = this.data.app.modules[id] = desc;
|
|
354
356
|
return node;
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
+
} else {
|
|
357
358
|
throw pkg.name + " is not module or ui, can't add node !";
|
|
358
359
|
}
|
|
359
360
|
}
|
|
@@ -468,8 +469,7 @@ class GraphModel {
|
|
|
468
469
|
try {
|
|
469
470
|
var n = this.getNode(id);
|
|
470
471
|
return true;
|
|
471
|
-
}
|
|
472
|
-
catch (e) {
|
|
472
|
+
} catch (e) {
|
|
473
473
|
return false;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
@@ -501,8 +501,7 @@ class GraphModel {
|
|
|
501
501
|
.concat(_.map(_.keys(this.data.app.output), k => this.outputPrefix + k))
|
|
502
502
|
.concat(_.keys(this.data.app.modules))
|
|
503
503
|
.concat(_.keys(this.data.app.ui));
|
|
504
|
-
}
|
|
505
|
-
else {
|
|
504
|
+
} else {
|
|
506
505
|
throw new Error('unknown node type: ' + type);
|
|
507
506
|
}
|
|
508
507
|
}
|
|
@@ -549,11 +548,9 @@ class GraphModel {
|
|
|
549
548
|
node.graphId = id; // for UIs and modules
|
|
550
549
|
if (pkgName.startsWith('@dualbox/dualbox-module-') || pkgName.startsWith('dualbox-core')) {
|
|
551
550
|
node.type = "module";
|
|
552
|
-
}
|
|
553
|
-
else if (pkgName.startsWith('@dualbox/dualbox-ui-')) {
|
|
551
|
+
} else if (pkgName.startsWith('@dualbox/dualbox-ui-')) {
|
|
554
552
|
node.type = "ui";
|
|
555
|
-
}
|
|
556
|
-
else {
|
|
553
|
+
} else {
|
|
557
554
|
throw "pkg " + pkgName + " does not appear to be a module or ui";
|
|
558
555
|
}
|
|
559
556
|
|
|
@@ -585,11 +582,9 @@ class GraphModel {
|
|
|
585
582
|
prefixId(id, type) {
|
|
586
583
|
if (type == "input" && !id.startsWith('in-')) {
|
|
587
584
|
return this.inputPrefix + id;
|
|
588
|
-
}
|
|
589
|
-
else if (type == "output" && !id.startsWith('out-')) {
|
|
585
|
+
} else if (type == "output" && !id.startsWith('out-')) {
|
|
590
586
|
return this.outputPrefix + id;
|
|
591
|
-
}
|
|
592
|
-
else {
|
|
587
|
+
} else {
|
|
593
588
|
return id;
|
|
594
589
|
}
|
|
595
590
|
}
|
|
@@ -598,8 +593,7 @@ class GraphModel {
|
|
|
598
593
|
if (typeof v == "string" && v.startsWith('____dualbox_storage')) {
|
|
599
594
|
var id = v.replace("____dualbox_storage(", "").slice(0, -1);
|
|
600
595
|
return this.data.root.snapshotObjects[id];
|
|
601
|
-
}
|
|
602
|
-
else {
|
|
596
|
+
} else {
|
|
603
597
|
return v;
|
|
604
598
|
}
|
|
605
599
|
}
|
|
@@ -621,27 +615,22 @@ class GraphNode {
|
|
|
621
615
|
this.type = "input";
|
|
622
616
|
this.graphId = id.substring(3); // the id to identify it in the dualbox graph
|
|
623
617
|
this.def = this.app.input[this.graphId];
|
|
624
|
-
}
|
|
625
|
-
else if (id.startsWith(this.m.outputPrefix)) {
|
|
618
|
+
} else if (id.startsWith(this.m.outputPrefix)) {
|
|
626
619
|
this.type = "output";
|
|
627
620
|
this.graphId = id.substring(4);
|
|
628
621
|
this.def = this.app.output[this.graphId];
|
|
629
|
-
}
|
|
630
|
-
else if (this.app.modules && this.app.modules[id]) {
|
|
622
|
+
} else if (this.app.modules && this.app.modules[id]) {
|
|
631
623
|
this.graphId = id;
|
|
632
624
|
this.type = "module";
|
|
633
625
|
this.def = this.app.modules[this.graphId];
|
|
634
|
-
}
|
|
635
|
-
else if (this.app.ui && this.app.ui[id]) {
|
|
626
|
+
} else if (this.app.ui && this.app.ui[id]) {
|
|
636
627
|
this.graphId = id;
|
|
637
628
|
this.type = "ui";
|
|
638
629
|
this.def = this.app.ui[this.graphId];
|
|
639
|
-
}
|
|
640
|
-
else {
|
|
630
|
+
} else {
|
|
641
631
|
throw "Cant find node " + id;
|
|
642
632
|
}
|
|
643
|
-
}
|
|
644
|
-
else {
|
|
633
|
+
} else {
|
|
645
634
|
this.def = null;
|
|
646
635
|
this.graphId = null;
|
|
647
636
|
}
|
|
@@ -687,8 +676,9 @@ class GraphNode {
|
|
|
687
676
|
|
|
688
677
|
// return the input links for a node
|
|
689
678
|
getNormalizeLinksDef() {
|
|
690
|
-
return this.type == "input" || this.type == "output" ?
|
|
691
|
-
|
|
679
|
+
return this.type == "input" || this.type == "output" ? {
|
|
680
|
+
"value": this.def.link
|
|
681
|
+
} :
|
|
692
682
|
this.def.links;
|
|
693
683
|
}
|
|
694
684
|
|
|
@@ -730,8 +720,7 @@ class GraphNode {
|
|
|
730
720
|
}
|
|
731
721
|
}
|
|
732
722
|
return r;
|
|
733
|
-
}
|
|
734
|
-
else {
|
|
723
|
+
} else {
|
|
735
724
|
switch (this.type) {
|
|
736
725
|
case "input":
|
|
737
726
|
case "output":
|
|
@@ -753,25 +742,59 @@ class GraphNode {
|
|
|
753
742
|
// return the assigned input type if there is one. Else, return the module's definition type for this input
|
|
754
743
|
// Also, take loops into account
|
|
755
744
|
getInputType(inputName) {
|
|
756
|
-
var assignedType =
|
|
745
|
+
var assignedType = this.getInputAssignedType(inputName);
|
|
757
746
|
var t = assignedType ? assignedType : this.getDefinitionInputType(inputName);
|
|
758
747
|
return this.hasIterator(inputName) ? "Array<" + t + ">" : t;
|
|
759
748
|
}
|
|
760
749
|
|
|
761
750
|
// return the assigned input type if there is one. Else, return the module's definition type for this input
|
|
762
|
-
getAttributeType(
|
|
763
|
-
var assignedType =
|
|
751
|
+
getAttributeType(attrName) {
|
|
752
|
+
var assignedType = this.getAttributeAssignedType(attrName);
|
|
764
753
|
return assignedType ? assignedType : this.getDefinitionAttributeType(inputName);
|
|
765
754
|
}
|
|
766
755
|
|
|
756
|
+
getInputAssignedType(inputName) {
|
|
757
|
+
return _.get(this.def, ["assignedTypes", "input", inputName]);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
getAttributeAssignedType(attrName) {
|
|
761
|
+
return _.get(this.def, ["assignedTypes", "attr", attrName]);
|
|
762
|
+
}
|
|
763
|
+
|
|
767
764
|
getDefinitionInputType(inputName) {
|
|
768
765
|
if ((this.isInput() || this.isOutput()) && inputName == "value") {
|
|
769
766
|
return this.getType();
|
|
770
|
-
}
|
|
771
|
-
else {
|
|
767
|
+
} else {
|
|
772
768
|
var pkg = this.getPackage();
|
|
773
|
-
var type = pkg
|
|
774
|
-
|
|
769
|
+
var type = _.get(pkg, ["dualbox", "input", inputName, "type"]) || "*";
|
|
770
|
+
|
|
771
|
+
if (type === "*") {
|
|
772
|
+
return this.getLinkedType(inputName);
|
|
773
|
+
} else {
|
|
774
|
+
return type;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// resolve typelinks, if some other linked input has user-assigned type already
|
|
780
|
+
getLinkedType(inputName) {
|
|
781
|
+
var linkedType = "*";
|
|
782
|
+
var inputsDescription = _.get(this.getPackage(), ["dualbox", "input"]);
|
|
783
|
+
var inputDef = inputsDescription[inputName];
|
|
784
|
+
if (inputDef.typeLink) {
|
|
785
|
+
var typeLink = inputDef.typeLink;
|
|
786
|
+
var linkedInputs = _.pickBy(inputsDescription, v => v.typeLink === typeLink); // linked inputs
|
|
787
|
+
_.each(linkedInputs, (linkedInputDef, linkedInputName) => {
|
|
788
|
+
var assignedType = this.getInputAssignedType(linkedInputName);
|
|
789
|
+
if (assignedType !== undefined && assignedType !== null) {
|
|
790
|
+
linkedType = assignedType;
|
|
791
|
+
return false; // eol
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
return linkedType;
|
|
796
|
+
} else {
|
|
797
|
+
return inputDef.type; // should be "*"
|
|
775
798
|
}
|
|
776
799
|
}
|
|
777
800
|
|
|
@@ -815,8 +838,7 @@ class GraphNode {
|
|
|
815
838
|
getDescription() {
|
|
816
839
|
if (this.def.desc) {
|
|
817
840
|
return this.def.desc;
|
|
818
|
-
}
|
|
819
|
-
else {
|
|
841
|
+
} else {
|
|
820
842
|
var pkg = this.getPackage();
|
|
821
843
|
return pkg && pkg.description;
|
|
822
844
|
}
|
|
@@ -827,9 +849,11 @@ class GraphNode {
|
|
|
827
849
|
var pkgDefault = pkg && pkg.dualbox && pkg.dualbox.input && pkg.dualbox.input[inputName] && pkg.dualbox.input[inputName].value;
|
|
828
850
|
var appDefault = this.def.defaultInputs && this.def.defaultInputs[inputName];
|
|
829
851
|
|
|
830
|
-
if (appDefault !== undefined) {
|
|
831
|
-
|
|
832
|
-
else
|
|
852
|
+
if (appDefault !== undefined) {
|
|
853
|
+
return appDefault;
|
|
854
|
+
} else if (pkgDefault !== undefined) {
|
|
855
|
+
return pkgDefault;
|
|
856
|
+
} else return undefined;
|
|
833
857
|
}
|
|
834
858
|
|
|
835
859
|
setInputDefaultValue(inputName, val) {
|
|
@@ -853,15 +877,13 @@ class GraphNode {
|
|
|
853
877
|
getOutputType(outputName) {
|
|
854
878
|
if ((this.isInput() || this.isOutput()) && outputName == "value") {
|
|
855
879
|
return this.getType();
|
|
856
|
-
}
|
|
857
|
-
else {
|
|
880
|
+
} else {
|
|
858
881
|
var pkg = this.getPackage();
|
|
859
882
|
var type = idx(pkg, o => o.dualbox.output[outputName].type) || "*";
|
|
860
883
|
if (this.hasLoop()) {
|
|
861
884
|
// if this output is not a feedback, "arrayize" it
|
|
862
885
|
return this.hasFeedback(outputName) ? type : "Array<" + type + ">";
|
|
863
|
-
}
|
|
864
|
-
else {
|
|
886
|
+
} else {
|
|
865
887
|
return type;
|
|
866
888
|
}
|
|
867
889
|
}
|
|
@@ -901,9 +923,11 @@ class GraphNode {
|
|
|
901
923
|
var pkg = this.getPackage();
|
|
902
924
|
var pkgDefault = pkg && pkg.dualbox && pkg.dualbox.attr && pkg.dualbox.attr[attrName].value;
|
|
903
925
|
var appDefault = this.def.attr && this.def.attr[attrName];
|
|
904
|
-
if (appDefault !== undefined) {
|
|
905
|
-
|
|
906
|
-
else
|
|
926
|
+
if (appDefault !== undefined) {
|
|
927
|
+
return appDefault;
|
|
928
|
+
} else if (pkgDefault !== undefined) {
|
|
929
|
+
return pkgDefault;
|
|
930
|
+
} else return undefined;
|
|
907
931
|
}
|
|
908
932
|
|
|
909
933
|
setAttributeValue(attrName, val) {
|
|
@@ -930,17 +954,14 @@ class GraphNode {
|
|
|
930
954
|
// it's a get
|
|
931
955
|
if (srcType === "input") {
|
|
932
956
|
return this.getInputDefaultValue(name);
|
|
933
|
-
}
|
|
934
|
-
else if (srcType === "attr") {
|
|
957
|
+
} else if (srcType === "attr") {
|
|
935
958
|
return this.getAttributeValue(name);
|
|
936
959
|
}
|
|
937
|
-
}
|
|
938
|
-
else {
|
|
960
|
+
} else {
|
|
939
961
|
// it's a set
|
|
940
962
|
if (srcType === "input") {
|
|
941
963
|
return this.setInputDefaultValue(name, val);
|
|
942
|
-
}
|
|
943
|
-
else if (srcType === "attr") {
|
|
964
|
+
} else if (srcType === "attr") {
|
|
944
965
|
return this.setAttributeValue(name, val);
|
|
945
966
|
}
|
|
946
967
|
}
|
|
@@ -957,8 +978,7 @@ class GraphNode {
|
|
|
957
978
|
getValueType(srcType, name) {
|
|
958
979
|
if (srcType === "input") {
|
|
959
980
|
return this.getInputType(name);
|
|
960
|
-
}
|
|
961
|
-
else if (srcType === "attr") {
|
|
981
|
+
} else if (srcType === "attr") {
|
|
962
982
|
return this.getAttributeType(name);
|
|
963
983
|
}
|
|
964
984
|
}
|
|
@@ -1221,17 +1241,14 @@ class GraphNode {
|
|
|
1221
1241
|
isInputVisible(inputName) {
|
|
1222
1242
|
if (this.isInput() || this.isOutput()) {
|
|
1223
1243
|
return true;
|
|
1224
|
-
}
|
|
1225
|
-
else {
|
|
1244
|
+
} else {
|
|
1226
1245
|
if (this.isInputConnected(inputName)) {
|
|
1227
1246
|
return true;
|
|
1228
|
-
}
|
|
1229
|
-
else {
|
|
1247
|
+
} else {
|
|
1230
1248
|
var val = idx(this.def, o => o.graph.in.visible[inputName]);
|
|
1231
1249
|
if (val !== undefined) {
|
|
1232
1250
|
return val !== false;
|
|
1233
|
-
}
|
|
1234
|
-
else {
|
|
1251
|
+
} else {
|
|
1235
1252
|
// check if the app did set a default value for this input
|
|
1236
1253
|
var defaultVal = idx(this.def, o => o.defaultInputs[inputName]);
|
|
1237
1254
|
if (defaultVal !== undefined) {
|
|
@@ -1244,15 +1261,12 @@ class GraphNode {
|
|
|
1244
1261
|
if (pkgDef) {
|
|
1245
1262
|
if (pkgDef.visible === false) {
|
|
1246
1263
|
return false;
|
|
1247
|
-
}
|
|
1248
|
-
else if (pkgDef.value !== undefined) {
|
|
1264
|
+
} else if (pkgDef.value !== undefined) {
|
|
1249
1265
|
return false;
|
|
1250
|
-
}
|
|
1251
|
-
else {
|
|
1266
|
+
} else {
|
|
1252
1267
|
return true;
|
|
1253
1268
|
}
|
|
1254
|
-
}
|
|
1255
|
-
else {
|
|
1269
|
+
} else {
|
|
1256
1270
|
return true;
|
|
1257
1271
|
}
|
|
1258
1272
|
}
|
|
@@ -1263,17 +1277,14 @@ class GraphNode {
|
|
|
1263
1277
|
isOutputVisible(outputName) {
|
|
1264
1278
|
if (this.isInput() || this.isOutput()) {
|
|
1265
1279
|
return true;
|
|
1266
|
-
}
|
|
1267
|
-
else {
|
|
1280
|
+
} else {
|
|
1268
1281
|
if (this.isOutputConnected(outputName)) {
|
|
1269
1282
|
return true;
|
|
1270
|
-
}
|
|
1271
|
-
else {
|
|
1283
|
+
} else {
|
|
1272
1284
|
var val = idx(this.def, o => o.graph.out.visible[outputName]);
|
|
1273
1285
|
if (val === false) {
|
|
1274
1286
|
return false;
|
|
1275
|
-
}
|
|
1276
|
-
else {
|
|
1287
|
+
} else {
|
|
1277
1288
|
var pkg = this.getPackage();
|
|
1278
1289
|
var pkgDef = idx(pkg, o => o.dualbox.output[outputName]);
|
|
1279
1290
|
return pkgDef.visible !== false;
|
|
@@ -1348,11 +1359,9 @@ class GraphNode {
|
|
|
1348
1359
|
isInputResolvable(input) {
|
|
1349
1360
|
if (this.hasDefaultValue(input)) {
|
|
1350
1361
|
return true;
|
|
1351
|
-
}
|
|
1352
|
-
else if (this.isInputConnected(input)) {
|
|
1362
|
+
} else if (this.isInputConnected(input)) {
|
|
1353
1363
|
return true;
|
|
1354
|
-
}
|
|
1355
|
-
else {
|
|
1364
|
+
} else {
|
|
1356
1365
|
return false;
|
|
1357
1366
|
}
|
|
1358
1367
|
}
|
|
@@ -1436,8 +1445,7 @@ class GraphNode {
|
|
|
1436
1445
|
if ((this.isInput() || this.isOutput()) && inputName === "value") {
|
|
1437
1446
|
var targetId = this.isInput() ? "input" : "output";
|
|
1438
1447
|
var targetInput = this.graphId;
|
|
1439
|
-
}
|
|
1440
|
-
else {
|
|
1448
|
+
} else {
|
|
1441
1449
|
var targetId = this.graphId;
|
|
1442
1450
|
var targetInput = inputName;
|
|
1443
1451
|
}
|
|
@@ -1457,8 +1465,7 @@ class GraphNode {
|
|
|
1457
1465
|
if ((this.isInput() || this.isOutput()) && outputName === "value") {
|
|
1458
1466
|
var sourceId = this.isInput() ? "input" : "output";
|
|
1459
1467
|
var sourceOutput = this.graphId;
|
|
1460
|
-
}
|
|
1461
|
-
else {
|
|
1468
|
+
} else {
|
|
1462
1469
|
var sourceId = this.graphId;
|
|
1463
1470
|
var sourceOutput = outputName;
|
|
1464
1471
|
}
|
|
@@ -1548,7 +1555,10 @@ class GraphNode {
|
|
|
1548
1555
|
}
|
|
1549
1556
|
|
|
1550
1557
|
getPosition() {
|
|
1551
|
-
var pos = this.def.graph && this.def.graph.position || {
|
|
1558
|
+
var pos = this.def.graph && this.def.graph.position || {
|
|
1559
|
+
left: 0,
|
|
1560
|
+
top: 0
|
|
1561
|
+
};
|
|
1552
1562
|
pos.top = parseInt(pos.top);
|
|
1553
1563
|
pos.left = parseInt(pos.left);
|
|
1554
1564
|
return pos;
|
|
@@ -1569,8 +1579,7 @@ class GraphNode {
|
|
|
1569
1579
|
if (nodeId == id) {
|
|
1570
1580
|
if (this.isInput() || this.isOutput()) {
|
|
1571
1581
|
delete this.def.link;
|
|
1572
|
-
}
|
|
1573
|
-
else {
|
|
1582
|
+
} else {
|
|
1574
1583
|
delete this.def.links[inputName];
|
|
1575
1584
|
}
|
|
1576
1585
|
}
|
|
@@ -1615,10 +1624,18 @@ class GraphNode {
|
|
|
1615
1624
|
|
|
1616
1625
|
addTo(app) {
|
|
1617
1626
|
switch (this.type) {
|
|
1618
|
-
case "module":
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
case "
|
|
1627
|
+
case "module":
|
|
1628
|
+
app.modules[this.graphId] = this.def;
|
|
1629
|
+
break;
|
|
1630
|
+
case "ui":
|
|
1631
|
+
app.ui[this.graphId] = this.def;
|
|
1632
|
+
break;
|
|
1633
|
+
case "input":
|
|
1634
|
+
app.input[this.graphId] = this.def;
|
|
1635
|
+
break;
|
|
1636
|
+
case "output":
|
|
1637
|
+
app.output[this.graphId] = this.def;
|
|
1638
|
+
break;
|
|
1622
1639
|
default:
|
|
1623
1640
|
throw "wtf";
|
|
1624
1641
|
}
|
|
@@ -1629,8 +1646,12 @@ class GraphNode {
|
|
|
1629
1646
|
this.detachEvents();
|
|
1630
1647
|
|
|
1631
1648
|
switch (this.type) {
|
|
1632
|
-
case "module":
|
|
1633
|
-
|
|
1649
|
+
case "module":
|
|
1650
|
+
delete app.modules[this.graphId];
|
|
1651
|
+
break;
|
|
1652
|
+
case "ui":
|
|
1653
|
+
delete app.ui[this.graphId];
|
|
1654
|
+
break;
|
|
1634
1655
|
case "input":
|
|
1635
1656
|
delete app.input[this.graphId];
|
|
1636
1657
|
if (!this.m.isRootApp(app)) {
|
|
@@ -1732,22 +1753,18 @@ class GraphNode {
|
|
|
1732
1753
|
if (this.isInput()) {
|
|
1733
1754
|
if (newId.startsWith(this.m.inputPrefix)) {
|
|
1734
1755
|
newGraphId = newId.substring(3);
|
|
1735
|
-
}
|
|
1736
|
-
else {
|
|
1756
|
+
} else {
|
|
1737
1757
|
newGraphId = newId;
|
|
1738
1758
|
newId = this.m.inputPrefix + newId;
|
|
1739
1759
|
}
|
|
1740
|
-
}
|
|
1741
|
-
else if (this.isOutput()) {
|
|
1760
|
+
} else if (this.isOutput()) {
|
|
1742
1761
|
if (newId.startsWith(this.m.outputPrefix)) {
|
|
1743
1762
|
newGraphId = newId.substring(4);
|
|
1744
|
-
}
|
|
1745
|
-
else {
|
|
1763
|
+
} else {
|
|
1746
1764
|
newGraphId = newId;
|
|
1747
1765
|
newId = this.m.outputPrefix + newId;
|
|
1748
1766
|
}
|
|
1749
|
-
}
|
|
1750
|
-
else {
|
|
1767
|
+
} else {
|
|
1751
1768
|
newGraphId = newId;
|
|
1752
1769
|
}
|
|
1753
1770
|
|
|
@@ -1803,8 +1820,7 @@ class GraphNode {
|
|
|
1803
1820
|
}
|
|
1804
1821
|
});
|
|
1805
1822
|
});
|
|
1806
|
-
}
|
|
1807
|
-
else if (this.isOutput()) {
|
|
1823
|
+
} else if (this.isOutput()) {
|
|
1808
1824
|
// get inboundLinks of this node that target this input, and detach them
|
|
1809
1825
|
_.each(parentNodes, (n) => {
|
|
1810
1826
|
_.each(n.getOutboundLinks(), (l) => {
|
|
@@ -1847,8 +1863,7 @@ class GraphNode {
|
|
|
1847
1863
|
_.each(links2node, (link) => {
|
|
1848
1864
|
if (link.sourceId == "input" || link.sourceId == "output") {
|
|
1849
1865
|
link.sourceOutput = newId;
|
|
1850
|
-
}
|
|
1851
|
-
else {
|
|
1866
|
+
} else {
|
|
1852
1867
|
link.sourceId = newId;
|
|
1853
1868
|
}
|
|
1854
1869
|
link.attach();
|
|
@@ -1911,8 +1926,7 @@ class DataLink {
|
|
|
1911
1926
|
if (sourceNode.isInput()) {
|
|
1912
1927
|
this.sourceId = "input";
|
|
1913
1928
|
this.sourceOutput = this.m.inputPrefix + sourceNode.graphId;
|
|
1914
|
-
}
|
|
1915
|
-
else if (sourceNode.isOutput()) {
|
|
1929
|
+
} else if (sourceNode.isOutput()) {
|
|
1916
1930
|
this.sourceId = "output";
|
|
1917
1931
|
this.sourceOutput = this.m.outputPrefix + sourceNode.graphId;
|
|
1918
1932
|
}
|
|
@@ -1921,8 +1935,7 @@ class DataLink {
|
|
|
1921
1935
|
if (targetNode.isInput()) {
|
|
1922
1936
|
this.targetId = "input";
|
|
1923
1937
|
this.targetInput = this.m.inputPrefix + targetNode.graphId;
|
|
1924
|
-
}
|
|
1925
|
-
else if (targetNode.isOutput()) {
|
|
1938
|
+
} else if (targetNode.isOutput()) {
|
|
1926
1939
|
this.targetId = "output";
|
|
1927
1940
|
this.targetInput = this.m.outputPrefix + targetNode.graphId;
|
|
1928
1941
|
}
|
|
@@ -1932,20 +1945,16 @@ class DataLink {
|
|
|
1932
1945
|
if (this.sourceId === "input") {
|
|
1933
1946
|
if (this.sourceOutput.startsWith(this.m.inputPrefix)) {
|
|
1934
1947
|
return this.m.getNode(this.sourceOutput);
|
|
1935
|
-
}
|
|
1936
|
-
else {
|
|
1948
|
+
} else {
|
|
1937
1949
|
return this.m.getNode(this.m.inputPrefix + this.sourceOutput);
|
|
1938
1950
|
}
|
|
1939
|
-
}
|
|
1940
|
-
else if (this.sourceId === "output") {
|
|
1951
|
+
} else if (this.sourceId === "output") {
|
|
1941
1952
|
if (this.sourceOutput.startsWith(this.m.outputPrefix)) {
|
|
1942
1953
|
return this.m.getNode(this.sourceOutput);
|
|
1943
|
-
}
|
|
1944
|
-
else {
|
|
1954
|
+
} else {
|
|
1945
1955
|
return this.m.getNode(this.m.outputPrefix + this.sourceOutput);
|
|
1946
1956
|
}
|
|
1947
|
-
}
|
|
1948
|
-
else {
|
|
1957
|
+
} else {
|
|
1949
1958
|
return this.m.getNode(this.sourceId);
|
|
1950
1959
|
}
|
|
1951
1960
|
}
|
|
@@ -1954,20 +1963,16 @@ class DataLink {
|
|
|
1954
1963
|
if (this.targetId === "input") {
|
|
1955
1964
|
if (this.targetInput.startsWith(this.m.inputPrefix)) {
|
|
1956
1965
|
return this.m.getNode(this.targetInput);
|
|
1957
|
-
}
|
|
1958
|
-
else {
|
|
1966
|
+
} else {
|
|
1959
1967
|
return this.m.getNode(this.m.inputPrefix + this.targetInput);
|
|
1960
1968
|
}
|
|
1961
|
-
}
|
|
1962
|
-
else if (this.targetId == "output") {
|
|
1969
|
+
} else if (this.targetId == "output") {
|
|
1963
1970
|
if (this.targetInput.startsWith(this.m.outputPrefix)) {
|
|
1964
1971
|
return this.m.getNode(this.targetInput);
|
|
1965
|
-
}
|
|
1966
|
-
else {
|
|
1972
|
+
} else {
|
|
1967
1973
|
return this.m.getNode(this.m.outputPrefix + this.targetInput);
|
|
1968
1974
|
}
|
|
1969
|
-
}
|
|
1970
|
-
else {
|
|
1975
|
+
} else {
|
|
1971
1976
|
return this.m.getNode(this.targetId);
|
|
1972
1977
|
}
|
|
1973
1978
|
}
|
|
@@ -1989,8 +1994,7 @@ class DataLink {
|
|
|
1989
1994
|
def.graph = def.graph || {};
|
|
1990
1995
|
def.graph.path = def.graph.path || [];
|
|
1991
1996
|
def.graph.path.unshift(pos);
|
|
1992
|
-
}
|
|
1993
|
-
else {
|
|
1997
|
+
} else {
|
|
1994
1998
|
// we need to find pos1 in the array to add pos at the right location
|
|
1995
1999
|
var index;
|
|
1996
2000
|
_.each(def.graph.path, (p, i) => {
|
|
@@ -2038,11 +2042,9 @@ class DataLink {
|
|
|
2038
2042
|
var targetNode = this.getTargetNode();
|
|
2039
2043
|
if (targetNode.isInput()) {
|
|
2040
2044
|
return targetNode.def.link;
|
|
2041
|
-
}
|
|
2042
|
-
else if (targetNode.isOutput()) {
|
|
2045
|
+
} else if (targetNode.isOutput()) {
|
|
2043
2046
|
return targetNode.def.link;
|
|
2044
|
-
}
|
|
2045
|
-
else {
|
|
2047
|
+
} else {
|
|
2046
2048
|
return targetNode.def.links && targetNode.def.links[this.targetInput] || {};
|
|
2047
2049
|
}
|
|
2048
2050
|
}
|
|
@@ -2055,11 +2057,9 @@ class DataLink {
|
|
|
2055
2057
|
var targetNode = this.getTargetNode();
|
|
2056
2058
|
if (targetNode.isInput()) {
|
|
2057
2059
|
targetNode.def.link = def;
|
|
2058
|
-
}
|
|
2059
|
-
else if (targetNode.isOutput()) {
|
|
2060
|
+
} else if (targetNode.isOutput()) {
|
|
2060
2061
|
targetNode.def.link = def;
|
|
2061
|
-
}
|
|
2062
|
-
else {
|
|
2062
|
+
} else {
|
|
2063
2063
|
targetNode.def.links = targetNode.def.links || {};
|
|
2064
2064
|
targetNode.def.links[this.targetInput] = def;
|
|
2065
2065
|
}
|
|
@@ -2077,12 +2077,14 @@ class DataLink {
|
|
|
2077
2077
|
// build the connection object
|
|
2078
2078
|
var sourceNode = this.getSourceNode();
|
|
2079
2079
|
if (sourceNode.isInput()) {
|
|
2080
|
-
var connection = {
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2080
|
+
var connection = {
|
|
2081
|
+
"input": sourceNode.graphId
|
|
2082
|
+
}
|
|
2083
|
+
} else if (sourceNode.isOutput()) {
|
|
2084
|
+
var connection = {
|
|
2085
|
+
"output": sourceNode.graphId
|
|
2086
|
+
}
|
|
2087
|
+
} else {
|
|
2086
2088
|
var connection = {};
|
|
2087
2089
|
connection[sourceNode.graphId] = this.sourceOutput;
|
|
2088
2090
|
}
|
|
@@ -2097,7 +2099,7 @@ class DataLink {
|
|
|
2097
2099
|
var l = new DataLink(this.m, key, val, this.targetId, this.targetInput);
|
|
2098
2100
|
if (!this.equals(l)) {
|
|
2099
2101
|
throw "Can not add link " + this.sourceId + ":" + this.sourceOutput + " -> " +
|
|
2100
|
-
|
|
2102
|
+
this.targetId + ":" + this.targetInput + " : a link already exist to target input";
|
|
2101
2103
|
}
|
|
2102
2104
|
}
|
|
2103
2105
|
|
|
@@ -2109,8 +2111,7 @@ class DataLink {
|
|
|
2109
2111
|
var targetNode = this.getTargetNode();
|
|
2110
2112
|
if (targetNode.isInput() || targetNode.isOutput()) {
|
|
2111
2113
|
delete targetNode.def.link;
|
|
2112
|
-
}
|
|
2113
|
-
else {
|
|
2114
|
+
} else {
|
|
2114
2115
|
delete targetNode.def.links[this.targetInput];
|
|
2115
2116
|
}
|
|
2116
2117
|
}
|
|
@@ -2162,8 +2163,7 @@ class EventLink {
|
|
|
2162
2163
|
|
|
2163
2164
|
if (index) {
|
|
2164
2165
|
n.def.events[index] = def;
|
|
2165
|
-
}
|
|
2166
|
-
else {
|
|
2166
|
+
} else {
|
|
2167
2167
|
n.def.events.push(def);
|
|
2168
2168
|
}
|
|
2169
2169
|
}
|
|
@@ -2198,8 +2198,7 @@ class EventLink {
|
|
|
2198
2198
|
def.graph = def.graph || {};
|
|
2199
2199
|
def.graph.path = def.graph.path || [];
|
|
2200
2200
|
def.graph.path.unshift(pos);
|
|
2201
|
-
}
|
|
2202
|
-
else {
|
|
2201
|
+
} else {
|
|
2203
2202
|
// we need to find pos1 in the array to add pos at the right location
|
|
2204
2203
|
var index;
|
|
2205
2204
|
_.each(def.graph.path, (p, i) => {
|
|
@@ -2332,7 +2331,10 @@ class Application {
|
|
|
2332
2331
|
addSubEvent(name, nodeName, evtName) {
|
|
2333
2332
|
var inputEvents = _.get(this.json.events, [name, "in"]);
|
|
2334
2333
|
if (!inputEvents) inputEvents = [];
|
|
2335
|
-
inputEvents.push({
|
|
2334
|
+
inputEvents.push({
|
|
2335
|
+
"node": nodeName,
|
|
2336
|
+
"event": evtName
|
|
2337
|
+
});
|
|
2336
2338
|
}
|
|
2337
2339
|
|
|
2338
2340
|
addCallback(name) {
|
|
@@ -2348,9 +2350,10 @@ class Application {
|
|
|
2348
2350
|
}
|
|
2349
2351
|
|
|
2350
2352
|
addAppEvent(name) {
|
|
2351
|
-
this.json.events[name] = {
|
|
2353
|
+
this.json.events[name] = {
|
|
2354
|
+
"in": []
|
|
2355
|
+
};
|
|
2352
2356
|
}
|
|
2353
2357
|
}
|
|
2354
2358
|
|
|
2355
|
-
export default GraphModel;
|
|
2356
|
-
|
|
2359
|
+
export default GraphModel;
|