@dualbox/editor 1.0.91 → 1.0.92
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 +3 -0
- package/js/dist/GraphEditor.js +17 -14
- package/js/dist/GraphEditor.min.js +16 -13
- package/js/src/c/GraphController.js +4 -4
- package/js/src/m/GraphModel.js +12 -9
- package/package.json +1 -1
|
@@ -43710,9 +43710,12 @@ class GraphModel {
|
|
|
43710
43710
|
// batch all changes in a function into one (for history save)
|
|
43711
43711
|
// if cb returns a Promise, return a Promise that will be resolved once it's all done
|
|
43712
43712
|
async batch(cb) {
|
|
43713
|
-
|
|
43714
|
-
if (
|
|
43715
|
-
|
|
43713
|
+
let diffChange = await this.history.batch(cb);
|
|
43714
|
+
if (diffChange && diffChange.diff && diffChange.hash) {
|
|
43715
|
+
let { diff, hash } = diffChange;
|
|
43716
|
+
if (this.onChangeCb) {
|
|
43717
|
+
this.onChangeCb(diff, hash);
|
|
43718
|
+
}
|
|
43716
43719
|
}
|
|
43717
43720
|
}
|
|
43718
43721
|
|
|
@@ -43897,8 +43900,8 @@ class GraphModel {
|
|
|
43897
43900
|
}
|
|
43898
43901
|
|
|
43899
43902
|
// add pkg dependencies (lib, types, etc) to app graph
|
|
43900
|
-
addDependencies(pkg) {
|
|
43901
|
-
|
|
43903
|
+
async addDependencies(pkg) {
|
|
43904
|
+
for (const dependencyName of Object.keys(pkg.dependencies)) {
|
|
43902
43905
|
if (utils.isLibrary(dependencyName) || utils.isType(dependencyName)) {
|
|
43903
43906
|
console.log('[*] Adding dependency: ' + dependencyName);
|
|
43904
43907
|
// await this.e.loadPackage(dependencyName, dependencyVersion); // Is this better ?
|
|
@@ -43907,10 +43910,10 @@ class GraphModel {
|
|
|
43907
43910
|
this.data.root.libs[pkg.name] = pkg.version;
|
|
43908
43911
|
await this.addDependencies(pkg);
|
|
43909
43912
|
}
|
|
43910
|
-
}
|
|
43913
|
+
}
|
|
43911
43914
|
}
|
|
43912
43915
|
|
|
43913
|
-
addNode(id, pkg) {
|
|
43916
|
+
async addNode(id, pkg) {
|
|
43914
43917
|
console.log('adding node: ' + id);
|
|
43915
43918
|
|
|
43916
43919
|
var desc = {
|
|
@@ -43925,7 +43928,7 @@ class GraphModel {
|
|
|
43925
43928
|
return false;
|
|
43926
43929
|
}
|
|
43927
43930
|
var node = this.getCurrentMetanode().modules[id] = desc;
|
|
43928
|
-
this.addDependencies(pkg); // async but no pb
|
|
43931
|
+
await this.addDependencies(pkg); // async but no pb
|
|
43929
43932
|
} else if (utils.isUI(pkg.name)) {
|
|
43930
43933
|
this.ensure('ui');
|
|
43931
43934
|
if (this.getCurrentMetanode().ui[id]) {
|
|
@@ -43933,7 +43936,7 @@ class GraphModel {
|
|
|
43933
43936
|
return false;
|
|
43934
43937
|
}
|
|
43935
43938
|
var node = this.getCurrentMetanode().ui[id] = desc;
|
|
43936
|
-
this.addDependencies(pkg); // async but no pb
|
|
43939
|
+
await this.addDependencies(pkg); // async but no pb
|
|
43937
43940
|
} else {
|
|
43938
43941
|
// may be a metanode
|
|
43939
43942
|
var nodeDef = idx_1(this.getCurrentMetanode(), o => o.metanodes[pkg.name]);
|
|
@@ -90654,7 +90657,7 @@ class GraphController {
|
|
|
90654
90657
|
}
|
|
90655
90658
|
|
|
90656
90659
|
// Add a node from the search results
|
|
90657
|
-
addNewBox(packageName, pos = null) {
|
|
90660
|
+
async addNewBox(packageName, pos = null) {
|
|
90658
90661
|
// first, make sure the package is loaded
|
|
90659
90662
|
this.e.loadPackage(packageName).then(async () => {
|
|
90660
90663
|
var id = this.createId(packageName);
|
|
@@ -90670,7 +90673,7 @@ class GraphController {
|
|
|
90670
90673
|
// first, add node in the model
|
|
90671
90674
|
// batch it so add node + set position + register to UI is 1 history change only
|
|
90672
90675
|
await this.m.batch(async () => {
|
|
90673
|
-
var nodeInfo = this.m.addNode(id, pkg);
|
|
90676
|
+
var nodeInfo = await this.m.addNode(id, pkg);
|
|
90674
90677
|
if (nodeInfo) {
|
|
90675
90678
|
if (pos) {
|
|
90676
90679
|
var node = this.m.getNode(nodeInfo.id);
|
|
@@ -90694,7 +90697,7 @@ class GraphController {
|
|
|
90694
90697
|
}
|
|
90695
90698
|
|
|
90696
90699
|
// create a new metabox
|
|
90697
|
-
addNewMetabox(name, json = {}, pos) {
|
|
90700
|
+
async addNewMetabox(name, json = {}, pos) {
|
|
90698
90701
|
if (this.m.hasMetanode(name)) {
|
|
90699
90702
|
sweetalert2_all("Can't add metabox", "metabox with name '" + name + "' already exists.", "error");
|
|
90700
90703
|
} else {
|
|
@@ -90704,7 +90707,7 @@ class GraphController {
|
|
|
90704
90707
|
// add 1 node of this metabox on the graph
|
|
90705
90708
|
var id = this.createId(name);
|
|
90706
90709
|
|
|
90707
|
-
this.m.addNode(id, {
|
|
90710
|
+
await this.m.addNode(id, {
|
|
90708
90711
|
"name": name,
|
|
90709
90712
|
"version": "*"
|
|
90710
90713
|
});
|
|
@@ -78,7 +78,7 @@ class GraphController {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// Add a node from the search results
|
|
81
|
-
addNewBox(packageName, pos = null) {
|
|
81
|
+
async addNewBox(packageName, pos = null) {
|
|
82
82
|
// first, make sure the package is loaded
|
|
83
83
|
this.e.loadPackage(packageName).then(async () => {
|
|
84
84
|
var id = this.createId(packageName);
|
|
@@ -94,7 +94,7 @@ class GraphController {
|
|
|
94
94
|
// first, add node in the model
|
|
95
95
|
// batch it so add node + set position + register to UI is 1 history change only
|
|
96
96
|
await this.m.batch(async () => {
|
|
97
|
-
var nodeInfo = this.m.addNode(id, pkg);
|
|
97
|
+
var nodeInfo = await this.m.addNode(id, pkg);
|
|
98
98
|
if (nodeInfo) {
|
|
99
99
|
if (pos) {
|
|
100
100
|
var node = this.m.getNode(nodeInfo.id);
|
|
@@ -118,7 +118,7 @@ class GraphController {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
// create a new metabox
|
|
121
|
-
addNewMetabox(name, json = {}, pos) {
|
|
121
|
+
async addNewMetabox(name, json = {}, pos) {
|
|
122
122
|
if (this.m.hasMetanode(name)) {
|
|
123
123
|
swal("Can't add metabox", "metabox with name '" + name + "' already exists.", "error");
|
|
124
124
|
} else {
|
|
@@ -128,7 +128,7 @@ class GraphController {
|
|
|
128
128
|
// add 1 node of this metabox on the graph
|
|
129
129
|
var id = this.createId(name);
|
|
130
130
|
|
|
131
|
-
this.m.addNode(id, {
|
|
131
|
+
await this.m.addNode(id, {
|
|
132
132
|
"name": name,
|
|
133
133
|
"version": "*"
|
|
134
134
|
});
|
package/js/src/m/GraphModel.js
CHANGED
|
@@ -218,9 +218,12 @@ class GraphModel {
|
|
|
218
218
|
// batch all changes in a function into one (for history save)
|
|
219
219
|
// if cb returns a Promise, return a Promise that will be resolved once it's all done
|
|
220
220
|
async batch(cb) {
|
|
221
|
-
|
|
222
|
-
if (
|
|
223
|
-
|
|
221
|
+
let diffChange = await this.history.batch(cb);
|
|
222
|
+
if (diffChange && diffChange.diff && diffChange.hash) {
|
|
223
|
+
let { diff, hash } = diffChange;
|
|
224
|
+
if (this.onChangeCb) {
|
|
225
|
+
this.onChangeCb(diff, hash);
|
|
226
|
+
}
|
|
224
227
|
}
|
|
225
228
|
}
|
|
226
229
|
|
|
@@ -405,8 +408,8 @@ class GraphModel {
|
|
|
405
408
|
}
|
|
406
409
|
|
|
407
410
|
// add pkg dependencies (lib, types, etc) to app graph
|
|
408
|
-
addDependencies(pkg) {
|
|
409
|
-
|
|
411
|
+
async addDependencies(pkg) {
|
|
412
|
+
for (const dependencyName of Object.keys(pkg.dependencies)) {
|
|
410
413
|
if (utils.isLibrary(dependencyName) || utils.isType(dependencyName)) {
|
|
411
414
|
console.log('[*] Adding dependency: ' + dependencyName);
|
|
412
415
|
// await this.e.loadPackage(dependencyName, dependencyVersion); // Is this better ?
|
|
@@ -415,10 +418,10 @@ class GraphModel {
|
|
|
415
418
|
this.data.root.libs[pkg.name] = pkg.version;
|
|
416
419
|
await this.addDependencies(pkg);
|
|
417
420
|
}
|
|
418
|
-
}
|
|
421
|
+
}
|
|
419
422
|
}
|
|
420
423
|
|
|
421
|
-
addNode(id, pkg) {
|
|
424
|
+
async addNode(id, pkg) {
|
|
422
425
|
console.log('adding node: ' + id);
|
|
423
426
|
|
|
424
427
|
var desc = {
|
|
@@ -433,7 +436,7 @@ class GraphModel {
|
|
|
433
436
|
return false;
|
|
434
437
|
}
|
|
435
438
|
var node = this.getCurrentMetanode().modules[id] = desc;
|
|
436
|
-
this.addDependencies(pkg); // async but no pb
|
|
439
|
+
await this.addDependencies(pkg); // async but no pb
|
|
437
440
|
} else if (utils.isUI(pkg.name)) {
|
|
438
441
|
this.ensure('ui');
|
|
439
442
|
if (this.getCurrentMetanode().ui[id]) {
|
|
@@ -441,7 +444,7 @@ class GraphModel {
|
|
|
441
444
|
return false;
|
|
442
445
|
}
|
|
443
446
|
var node = this.getCurrentMetanode().ui[id] = desc;
|
|
444
|
-
this.addDependencies(pkg); // async but no pb
|
|
447
|
+
await this.addDependencies(pkg); // async but no pb
|
|
445
448
|
} else {
|
|
446
449
|
// may be a metanode
|
|
447
450
|
var nodeDef = idx(this.getCurrentMetanode(), o => o.metanodes[pkg.name]);
|