@dualbox/editor 1.0.61 → 1.0.63

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.
@@ -17125,7 +17125,7 @@ class History {
17125
17125
  this.states = []; // all states, save as json diffs
17126
17126
 
17127
17127
  this._holdSaving = false; // if true, save() will have no effect
17128
- this.maxStates = 5; // to be changed accordingly
17128
+ this.maxStates = 100; // to be changed accordingly
17129
17129
 
17130
17130
  this.current = -1;
17131
17131
  this.lastState = null;
@@ -17160,6 +17160,7 @@ class History {
17160
17160
  this.states = [];
17161
17161
  this.current = -1;
17162
17162
  this.origin = origin;
17163
+ this.lastState = origin;
17163
17164
  }
17164
17165
 
17165
17166
  getState(n) {
@@ -17174,26 +17175,27 @@ class History {
17174
17175
  return this.getState(this.current);
17175
17176
  }
17176
17177
 
17178
+ clone(o) {
17179
+ return JSON.parse(JSON.stringify(o));
17180
+ }
17181
+
17177
17182
  save() {
17178
17183
  if (!this._holdSaving) {
17179
- console.time('state saved');
17180
- var previousState = this.lastState ? this.lastState : this.origin;
17181
- var diff = patcher.diff(this.lastState, this.m.data);
17182
- this.lastState = lodash.cloneDeep(this.m.data);
17183
- this.pushState(diff);
17184
- this.current++;
17185
- console.timeEnd("state saved");
17186
- return lodash.cloneDeep(diff);
17184
+ var currentAppClone = this.clone(this.m.data);
17185
+ var diff = patcher.diff(this.lastState, currentAppClone);
17186
+ if (diff) {
17187
+ this.lastState = currentAppClone;
17188
+ this.pushState(diff);
17189
+ this.current++;
17190
+ return this.clone(diff);
17191
+ }
17187
17192
  }
17188
17193
  }
17189
17194
 
17190
17195
  undo() {
17191
17196
  if (this.current >= 0) {
17192
- console.time('undo');
17193
17197
  patcher.unpatch(this.lastState, this.states[this.current]);
17194
- this.m.data = lodash.cloneDeep(this.lastState);
17195
- //this.setState(this.current);
17196
- console.timeEnd('undo');
17198
+ this.m.data = this.clone(this.lastState);
17197
17199
  }
17198
17200
 
17199
17201
  if (this.current >= 0) {
@@ -17207,10 +17209,8 @@ class History {
17207
17209
  }
17208
17210
 
17209
17211
  if (this.current >= 0) {
17210
- console.time('redo');
17211
17212
  patcher.patch(this.lastState, this.states[this.current]);
17212
- this.m.data = lodash.cloneDeep(this.lastState);
17213
- console.timeEnd('undo');
17213
+ this.m.data = this.clone(this.lastState);
17214
17214
  }
17215
17215
  }
17216
17216
 
@@ -42633,6 +42633,7 @@ class GraphModel {
42633
42633
  // Pointer that changes when we view/edit metanodes
42634
42634
  // All methodes are relative to this pointer, so we just need to change it
42635
42635
  // to enter/exit a metanode
42636
+ // Path to the current metanode. Use this.getCurrentMetanode() to resolve it
42636
42637
  app: null,
42637
42638
 
42638
42639
  // Array of pointers to manage navigation between metanodes
@@ -42642,14 +42643,14 @@ class GraphModel {
42642
42643
  // w[2] = view state (result of zoomer.saveState())
42643
42644
  windows: null
42644
42645
  };
42645
- this.data.app = this.data.root;
42646
+ this.data.app = null;
42646
42647
  this.data.windows = [
42647
- [this.e.rootAppName, this.data.app]
42648
+ [this.e.rootAppName, null]
42648
42649
  ];
42649
42650
 
42650
42651
  // An object to save/restore different states of this.data (ctrl-z/ctrl-y)
42651
42652
  this.history = new History(this);
42652
- this.history.setOrigin(lodash.cloneDeep(this.data));
42653
+ this.history.setOrigin(lodash.cloneDeep(this.data.root));
42653
42654
 
42654
42655
  this.inputPrefix = "in-";
42655
42656
  this.outputPrefix = "out-";
@@ -42666,14 +42667,14 @@ class GraphModel {
42666
42667
  this.check(json);
42667
42668
 
42668
42669
  this.data.root = json;
42669
- this.data.app = this.data.root; // reset ptr
42670
+ this.data.app = null; // reset ptr
42670
42671
  this.data.windows = [
42671
- [this.e.rootAppName, this.data.app]
42672
+ [this.e.rootAppName, null]
42672
42673
  ];
42673
42674
 
42674
42675
  await this.addNativeTypes();
42675
42676
 
42676
- this.history.setOrigin(lodash.cloneDeep(this.data));
42677
+ this.history.setOrigin(lodash.cloneDeep(this.data.root));
42677
42678
  }
42678
42679
 
42679
42680
  addNativeTypes() {
@@ -42717,7 +42718,11 @@ class GraphModel {
42717
42718
  }
42718
42719
 
42719
42720
  getCurrentMetanode() {
42720
- return this.data.app;
42721
+ if (this.data.app === null) {
42722
+ return this.data.root
42723
+ } else {
42724
+ return lodash.get(this.data.root, this.data.app);
42725
+ }
42721
42726
  }
42722
42727
 
42723
42728
  getCurrentMetanodeName() {
@@ -42791,10 +42796,6 @@ class GraphModel {
42791
42796
  return this.data.windows;
42792
42797
  }
42793
42798
 
42794
- getCurrentWindow() {
42795
- return this.data.app;
42796
- }
42797
-
42798
42799
  getPanels() {
42799
42800
  return lodash.keys(this.data.root.interface);
42800
42801
  }
@@ -42865,20 +42866,20 @@ class GraphModel {
42865
42866
  * Json security methods
42866
42867
  */
42867
42868
  ensure(field) {
42868
- this.data.app[field] = this.data.app[field] || {};
42869
+ this.getCurrentMetanode()[field] = this.getCurrentMetanode()[field] || {};
42869
42870
  }
42870
42871
 
42871
42872
  /**
42872
42873
  * Metanodes navigation
42873
42874
  */
42874
42875
  enterMetanode(id, viewState) {
42875
- var node = this.data.app.modules[id];
42876
+ var node = this.getCurrentMetanode().modules[id];
42876
42877
  if (!node) {
42877
42878
  throw "couldn't find node " + id;
42878
42879
  }
42879
42880
 
42880
42881
  var name = node.module;
42881
- var metanode = this.data.app.metanodes[name];
42882
+ var metanode = this.getCurrentMetanode().metanodes[name];
42882
42883
  if (!metanode) {
42883
42884
  throw "couldn't find definition for metanode " + name;
42884
42885
  }
@@ -42887,7 +42888,7 @@ class GraphModel {
42887
42888
  this.data.windows[this.data.windows.length - 1][2] = viewState;
42888
42889
 
42889
42890
  // switch to the next window
42890
- this.data.app = metanode;
42891
+ this.data.app = ["metanodes", name];
42891
42892
  this.data.windows.push([name, metanode]);
42892
42893
  this.save();
42893
42894
  }
@@ -42897,7 +42898,7 @@ class GraphModel {
42897
42898
  */
42898
42899
  addMetanode(name, def) {
42899
42900
  this.ensure('metanodes');
42900
- this.data.app.metanodes[name] = def;
42901
+ this.getCurrentMetanode().metanodes[name] = def;
42901
42902
  }
42902
42903
 
42903
42904
  addInput(name, type, desc) {
@@ -42906,7 +42907,7 @@ class GraphModel {
42906
42907
  "desc": desc
42907
42908
  };
42908
42909
  this.ensure('input');
42909
- this.data.app.input[name] = input;
42910
+ this.getCurrentMetanode().input[name] = input;
42910
42911
  this.save();
42911
42912
  return input;
42912
42913
  }
@@ -42917,13 +42918,13 @@ class GraphModel {
42917
42918
  "desc": desc
42918
42919
  };
42919
42920
  this.ensure('output');
42920
- this.data.app.output[name] = output;
42921
+ this.getCurrentMetanode().output[name] = output;
42921
42922
  this.save();
42922
42923
  return output;
42923
42924
  }
42924
42925
 
42925
42926
  hasMetanode(name) {
42926
- return idx_1(this.data, o => o.app.metanodes[name]) !== undefined;
42927
+ return lodash.get(this.getCurrentMetanode(), ["metanodes", name]) !== undefined;
42927
42928
  }
42928
42929
 
42929
42930
  isRootApp(app) {
@@ -42933,7 +42934,7 @@ class GraphModel {
42933
42934
  getMetanodeInstances(app) {
42934
42935
  // first identify metanode name
42935
42936
  var metanodeName = null;
42936
- lodash.each(this.data.app.metanodes, (metanode, name) => {
42937
+ lodash.each(this.getCurrentMetanode().metanodes, (metanode, name) => {
42937
42938
  if (app == metanode) {
42938
42939
  metanodeName = name;
42939
42940
  return false;
@@ -42941,7 +42942,7 @@ class GraphModel {
42941
42942
  });
42942
42943
 
42943
42944
  var instances = [];
42944
- lodash.each(this.data.app.modules, (json, id) => {
42945
+ lodash.each(this.getCurrentMetanode().modules, (json, id) => {
42945
42946
  if (json.module == metanodeName) {
42946
42947
  instances.push(this.getNode(id));
42947
42948
  }
@@ -42960,24 +42961,24 @@ class GraphModel {
42960
42961
  };
42961
42962
  if (utils.isModule(pkg.name)) {
42962
42963
  this.ensure('modules');
42963
- if (this.data.app.modules[id]) {
42964
+ if (this.getCurrentMetanode().modules[id]) {
42964
42965
  console.error('Could not add module ' + id + ': already exists');
42965
42966
  return false;
42966
42967
  }
42967
- var node = this.data.app.modules[id] = desc;
42968
+ var node = this.getCurrentMetanode().modules[id] = desc;
42968
42969
  } else if (utils.isUI(pkg.name)) {
42969
42970
  this.ensure('ui');
42970
- if (this.data.app.ui[id]) {
42971
+ if (this.getCurrentMetanode().ui[id]) {
42971
42972
  console.error('Could not add ui ' + id + ': already exists');
42972
42973
  return false;
42973
42974
  }
42974
- var node = this.data.app.ui[id] = desc;
42975
+ var node = this.getCurrentMetanode().ui[id] = desc;
42975
42976
  } else {
42976
42977
  // may be a metanode
42977
- var nodeDef = idx_1(this.data.app, o => o.metanodes[pkg.name]);
42978
+ var nodeDef = idx_1(this.getCurrentMetanode(), o => o.metanodes[pkg.name]);
42978
42979
  if (nodeDef) {
42979
42980
  this.ensure('modules');
42980
- var node = this.data.app.modules[id] = desc;
42981
+ var node = this.getCurrentMetanode().modules[id] = desc;
42981
42982
  return node;
42982
42983
  } else {
42983
42984
  throw pkg.name + " is not module or ui, can't add node !";
@@ -43019,11 +43020,11 @@ class GraphModel {
43019
43020
  switch (type) {
43020
43021
  case "module":
43021
43022
  this.ensure('modules');
43022
- this.data.app.modules[id] = def;
43023
+ this.getCurrentMetanode().modules[id] = def;
43023
43024
  break;
43024
43025
  case "ui":
43025
43026
  this.ensure('ui');
43026
- this.data.app.ui[id] = def;
43027
+ this.getCurrentMetanode().ui[id] = def;
43027
43028
  break;
43028
43029
  default:
43029
43030
  throw type + " is not module or ui, error";
@@ -43069,7 +43070,7 @@ class GraphModel {
43069
43070
  // check if metanode def is used by at least 1 module
43070
43071
  isMetanodeUsed(name) {
43071
43072
  var stillUsed = false;
43072
- lodash.each(this.data.app.modules, (n) => {
43073
+ lodash.each(this.getCurrentMetanode().modules, (n) => {
43073
43074
  if (n.module === name) {
43074
43075
  stillUsed = true;
43075
43076
  return false; // eol
@@ -43107,25 +43108,25 @@ class GraphModel {
43107
43108
  var keys = null;
43108
43109
  switch (type) {
43109
43110
  case "input":
43110
- keys = lodash.keys(this.data.app.input);
43111
+ keys = lodash.keys(this.getCurrentMetanode().input);
43111
43112
  keys = lodash.map(keys, k => this.inputPrefix + k);
43112
43113
  break;
43113
43114
  case "output":
43114
- keys = lodash.keys(this.data.app.output);
43115
+ keys = lodash.keys(this.getCurrentMetanode().output);
43115
43116
  keys = lodash.map(keys, k => this.outputPrefix + k);
43116
43117
  break;
43117
43118
  case "modules":
43118
- keys = lodash.keys(this.data.app.modules);
43119
+ keys = lodash.keys(this.getCurrentMetanode().modules);
43119
43120
  break;
43120
43121
  case "ui":
43121
- keys = lodash.keys(this.data.app.ui);
43122
+ keys = lodash.keys(this.getCurrentMetanode().ui);
43122
43123
  break;
43123
43124
  default:
43124
43125
  if (type === undefined) {
43125
- keys = [].concat(lodash.map(lodash.keys(this.data.app.input), k => this.inputPrefix + k))
43126
- .concat(lodash.map(lodash.keys(this.data.app.output), k => this.outputPrefix + k))
43127
- .concat(lodash.keys(this.data.app.modules))
43128
- .concat(lodash.keys(this.data.app.ui));
43126
+ keys = [].concat(lodash.map(lodash.keys(this.getCurrentMetanode().input), k => this.inputPrefix + k))
43127
+ .concat(lodash.map(lodash.keys(this.getCurrentMetanode().output), k => this.outputPrefix + k))
43128
+ .concat(lodash.keys(this.getCurrentMetanode().modules))
43129
+ .concat(lodash.keys(this.getCurrentMetanode().ui));
43129
43130
  } else {
43130
43131
  throw new Error('unknown node type: ' + type);
43131
43132
  }
@@ -43231,7 +43232,7 @@ class GraphModel {
43231
43232
  class GraphNode {
43232
43233
  constructor(m, id, example = false) {
43233
43234
  this.m = m;
43234
- this.app = this.m.data.app;
43235
+ this.app = this.m.getCurrentMetanode();
43235
43236
  this.id = id;
43236
43237
  this.uniqId = this.m.getCurrentMetanodePath() + '->' + this.id;
43237
43238
 
@@ -43489,6 +43490,7 @@ class GraphNode {
43489
43490
  setInputDefaultValue(inputName, val) {
43490
43491
  this.def.defaultInputs = this.def.defaultInputs || {};
43491
43492
  this.def.defaultInputs[inputName] = val;
43493
+ this.m.save();
43492
43494
  }
43493
43495
 
43494
43496
  hasDefaultValue(inputName) {
@@ -43563,6 +43565,7 @@ class GraphNode {
43563
43565
  setAttributeValue(attrName, val) {
43564
43566
  this.def.attr = this.def.attr || {};
43565
43567
  this.def.attr[attrName] = val;
43568
+ this.m.save();
43566
43569
  }
43567
43570
 
43568
43571
  // only if this.isUI() == true
@@ -43595,7 +43598,6 @@ class GraphNode {
43595
43598
  return this.setAttributeValue(name, val);
43596
43599
  }
43597
43600
  }
43598
- this.m.save();
43599
43601
  }
43600
43602
 
43601
43603
  deleteVal(srcType, name) {
@@ -43674,6 +43676,7 @@ class GraphNode {
43674
43676
  this.def.loops[0]["iterators"][input] = 1;
43675
43677
 
43676
43678
  this.addLoopToDefaultValue(input);
43679
+ this.m.save();
43677
43680
  }
43678
43681
 
43679
43682
  unsetIterator(input) {
@@ -43682,6 +43685,7 @@ class GraphNode {
43682
43685
  if (lodash.isEmpty(this.def.loops[0])) delete this.def.loops;
43683
43686
 
43684
43687
  this.removeLoopFromDefaultValue(input);
43688
+ this.m.save();
43685
43689
  }
43686
43690
 
43687
43691
  // "array-ise" the default value of the input to match the iterator on it
@@ -43707,6 +43711,7 @@ class GraphNode {
43707
43711
  this.def.loops[0] = this.def.loops[0] || {};
43708
43712
  this.def.loops[0]["feedback"] = this.def.loops[0]["feedback"] || {};
43709
43713
  this.def.loops[0]["feedback"][output] = input;
43714
+ this.m.save();
43710
43715
  }
43711
43716
 
43712
43717
  unsetFeedback(output) {
@@ -43714,6 +43719,7 @@ class GraphNode {
43714
43719
  if (lodash.isEmpty(this.def.loops[0]["feedback"])) delete this.def.loops[0]["feedback"];
43715
43720
  if (lodash.isEmpty(this.def.loops[0])) delete this.def.loops[0];
43716
43721
  if (lodash.isEmpty(this.def.loops)) delete this.def.loops;
43722
+ this.m.save();
43717
43723
  }
43718
43724
 
43719
43725
  isMetanode() {
@@ -43773,10 +43779,12 @@ class GraphNode {
43773
43779
 
43774
43780
  setCache(b) {
43775
43781
  this.def.cache = b;
43782
+ this.m.save();
43776
43783
  }
43777
43784
 
43778
43785
  setParallel(b) {
43779
43786
  this.def.parallel = b;
43787
+ this.m.save();
43780
43788
  }
43781
43789
 
43782
43790
  getInputsNames() {
@@ -43929,6 +43937,7 @@ class GraphNode {
43929
43937
  this.def.graph.in = this.def.graph.in || {};
43930
43938
  this.def.graph.in.visible = this.def.graph.in.visible || {};
43931
43939
  this.def.graph.in.visible[inputName] = b;
43940
+ this.m.save();
43932
43941
  }
43933
43942
 
43934
43943
  setOutputVisibility(outputName, b) {
@@ -43936,6 +43945,7 @@ class GraphNode {
43936
43945
  this.def.graph.out = this.def.graph.out || {};
43937
43946
  this.def.graph.out.visible = this.def.graph.out.visible || {};
43938
43947
  this.def.graph.out.visible[outputName] = b;
43948
+ this.m.save();
43939
43949
  }
43940
43950
 
43941
43951
  // return true if the node has an input link to the node given in id
@@ -44048,10 +44058,10 @@ class GraphNode {
44048
44058
  var collectInputLinks = (def, id) => collectLinks(def, this.m.inputPrefix + id);
44049
44059
  var collectOutputLinks = (def, id) => collectLinks(def, this.m.outputPrefix + id);
44050
44060
 
44051
- lodash.each(this.m.data.app.modules, collectLinks);
44052
- lodash.each(this.m.data.app.ui, collectLinks);
44053
- lodash.each(this.m.data.app.input, collectInputLinks);
44054
- lodash.each(this.m.data.app.output, collectOutputLinks);
44061
+ lodash.each(this.m.getCurrentMetanode().modules, collectLinks);
44062
+ lodash.each(this.m.getCurrentMetanode().ui, collectLinks);
44063
+ lodash.each(this.m.getCurrentMetanode().input, collectInputLinks);
44064
+ lodash.each(this.m.getCurrentMetanode().output, collectOutputLinks);
44055
44065
  return links;
44056
44066
  }
44057
44067
 
@@ -44066,7 +44076,7 @@ class GraphNode {
44066
44076
  }
44067
44077
  });
44068
44078
  };
44069
- lodash.each(this.m.data.app.ui, collectEvents);
44079
+ lodash.each(this.m.getCurrentMetanode().ui, collectEvents);
44070
44080
  return events;
44071
44081
  }
44072
44082
 
@@ -44181,8 +44191,11 @@ class GraphNode {
44181
44191
  // pos: { top: Integer, left: Integer }
44182
44192
  setPosition(pos) {
44183
44193
  this.def.graph = this.def.graph || {};
44184
- this.def.graph.position = pos;
44185
- this.m.save();
44194
+ var curPos = this.def.graph.position;
44195
+ if (!curPos || curPos.top != pos.top || curPos.left != pos.left) {
44196
+ this.def.graph.position = pos;
44197
+ this.m.save();
44198
+ }
44186
44199
  }
44187
44200
 
44188
44201
  getPosition() {
@@ -44764,6 +44777,7 @@ class DataLink {
44764
44777
  }
44765
44778
 
44766
44779
  this.setDef(connection);
44780
+ this.m.save();
44767
44781
  }
44768
44782
 
44769
44783
  // remove the connection from the app
@@ -44774,6 +44788,7 @@ class DataLink {
44774
44788
  } else {
44775
44789
  delete targetNode.def.links[this.targetInput];
44776
44790
  }
44791
+ this.m.save();
44777
44792
  }
44778
44793
  }
44779
44794
 
@@ -44837,6 +44852,7 @@ class EventLink {
44837
44852
  "node": this.targetId,
44838
44853
  "event": this.eventName
44839
44854
  });
44855
+ this.m.save();
44840
44856
  }
44841
44857
 
44842
44858
  detach() {
@@ -44844,6 +44860,7 @@ class EventLink {
44844
44860
  lodash.remove(n.def.events, (evt) => {
44845
44861
  return evt.node === this.targetId && evt.event === this.eventName;
44846
44862
  });
44863
+ this.m.save();
44847
44864
  }
44848
44865
 
44849
44866
  // splitted link: add a step between pos1 and pos2
@@ -44904,6 +44921,7 @@ class EventLink {
44904
44921
 
44905
44922
  class Application {
44906
44923
  constructor(m, json, name, readOnly = false) {
44924
+ this.m = m;
44907
44925
  this.json = readOnly ? lodash.cloneDeep(json) : json;
44908
44926
  this.name = name;
44909
44927
  }
@@ -44914,6 +44932,7 @@ class Application {
44914
44932
 
44915
44933
  setDescription(desc) {
44916
44934
  this.json.description = desc;
44935
+ this.m.save();
44917
44936
  }
44918
44937
 
44919
44938
  getInputsNames() {
@@ -44961,6 +44980,7 @@ class Application {
44961
44980
  setEventDescription(name, desc) {
44962
44981
  this.ensureEvent(name);
44963
44982
  this.json.events[name].desc = desc;
44983
+ this.m.save();
44964
44984
  }
44965
44985
 
44966
44986
  getEventIn(name) {
@@ -44973,19 +44993,23 @@ class Application {
44973
44993
 
44974
44994
  removeAppEvent(name) {
44975
44995
  delete this.json.events[name];
44996
+ this.m.save();
44976
44997
  }
44977
44998
 
44978
44999
  renameAppEvent(oldName, newName) {
44979
45000
  this.json.events[newName] = this.json.events[oldName];
44980
45001
  delete this.json.events[oldName];
45002
+ this.m.save();
44981
45003
  }
44982
45004
 
44983
45005
  removeAppInEvent(name, index) {
44984
45006
  this.json.events[name].in.splice(index, 1);
45007
+ this.m.save();
44985
45008
  }
44986
45009
 
44987
45010
  removeAppOutEvent(name) {
44988
45011
  delete this.json.events[name].out;
45012
+ this.m.save();
44989
45013
  }
44990
45014
 
44991
45015
  addSubEvent(name, nodeName, evtName) {
@@ -44995,11 +45019,13 @@ class Application {
44995
45019
  "node": nodeName,
44996
45020
  "event": evtName
44997
45021
  });
45022
+ this.m.save();
44998
45023
  }
44999
45024
 
45000
45025
  addCallback(name) {
45001
45026
  // get the first node
45002
45027
  lodash.set(this.json.events, [name, "out"], {});
45028
+ this.m.save();
45003
45029
  }
45004
45030
 
45005
45031
  setCallback(name, nodeId, eventName) {
@@ -45007,12 +45033,14 @@ class Application {
45007
45033
  node: nodeId,
45008
45034
  event: eventName,
45009
45035
  });
45036
+ this.m.save();
45010
45037
  }
45011
45038
 
45012
45039
  addAppEvent(name) {
45013
45040
  this.json.events[name] = {
45014
45041
  "in": []
45015
45042
  };
45043
+ this.m.save();
45016
45044
  }
45017
45045
  }
45018
45046
 
@@ -87834,11 +87862,11 @@ class Merger {
87834
87862
  this._bindOutputs();
87835
87863
 
87836
87864
  // 5. Our metanode definition is ready, add it to the app
87837
- this.m.data.app.metanodes = this.m.data.app.metanodes || {};
87838
- this.m.data.app.metanodes[metaboxName] = this.def;
87865
+ this.m.getCurrentMetanode().metanodes = this.m.getCurrentMetanode().metanodes || {};
87866
+ this.m.getCurrentMetanode().metanodes[metaboxName] = this.def;
87839
87867
 
87840
87868
  // 6. Create a new node from this def
87841
- this.m.data.app.modules[this.id] = {
87869
+ this.m.getCurrentMetanode().modules[this.id] = {
87842
87870
  "module": metaboxName,
87843
87871
  "version": "*",
87844
87872
  "graph": {
@@ -88022,13 +88050,13 @@ class Merger {
88022
88050
  }
88023
88051
 
88024
88052
  // move the node module definition (preserving the links between metabox's node)
88025
- this.def.modules[node.id] = this.m.data.app.modules[node.id];
88026
- delete this.m.data.app.modules[node.id];
88053
+ this.def.modules[node.id] = this.m.getCurrentMetanode().modules[node.id];
88054
+ delete this.m.getCurrentMetanode().modules[node.id];
88027
88055
 
88028
88056
  if (node.isMetanode()) {
88029
88057
  // if the metanode isn't still in use in the main app, remove def from here
88030
88058
  if (!this.m.isMetanodeUsed(node.def.module)) {
88031
- delete this.m.data.app.metanodes[node.def.module];
88059
+ delete this.m.getCurrentMetanode().metanodes[node.def.module];
88032
88060
  }
88033
88061
  }
88034
88062
  });
@@ -88160,8 +88188,7 @@ class GraphController {
88160
88188
  this.v.repaint();
88161
88189
  }
88162
88190
  });
88163
- }
88164
- else {
88191
+ } else {
88165
88192
  var options = {};
88166
88193
  lodash.each(this.m.getPanels(), (name) => options[name] = name);
88167
88194
 
@@ -88194,7 +88221,16 @@ class GraphController {
88194
88221
  var pkg = this.e.packages[packageName];
88195
88222
  if (pkg) {
88196
88223
  // first, add node in the model
88197
- var nodeInfo = this.m.addNode(id, pkg);
88224
+ // batch it so add node + set position is 1 history change only
88225
+ var nodeInfo;
88226
+ this.m.batch(() => {
88227
+ nodeInfo = this.m.addNode(id, pkg);
88228
+ if (nodeInfo && pos) {
88229
+ var node = this.m.getNode(nodeInfo.id);
88230
+ node.setPosition(pos);
88231
+ }
88232
+ });
88233
+
88198
88234
  if (nodeInfo) {
88199
88235
  if (pos) {
88200
88236
  var node = this.m.getNode(nodeInfo.id);
@@ -88211,8 +88247,7 @@ class GraphController {
88211
88247
  this.registerNodeToInterface(id);
88212
88248
  }
88213
88249
  }
88214
- }
88215
- else {
88250
+ } else {
88216
88251
  console.error('Package ' + packageName + ' not found');
88217
88252
  }
88218
88253
  });
@@ -88222,8 +88257,7 @@ class GraphController {
88222
88257
  addNewMetabox(name, json = {}, pos) {
88223
88258
  if (this.m.hasMetanode(name)) {
88224
88259
  sweetalert2_all("Can't add metabox", "metabox with name '" + name + "' already exists.", "error");
88225
- }
88226
- else {
88260
+ } else {
88227
88261
  // add metabox def
88228
88262
  this.m.addMetanode(name, json);
88229
88263
 
@@ -88234,7 +88268,7 @@ class GraphController {
88234
88268
  "name": name,
88235
88269
  "version": "*"
88236
88270
  });
88237
- if( pos ) {
88271
+ if (pos) {
88238
88272
  var n = this.m.getNode(id);
88239
88273
  n.setPosition(pos);
88240
88274
  }
@@ -88270,8 +88304,7 @@ class GraphController {
88270
88304
  // if it's an UI, we need to register it to a panel
88271
88305
  if (type === "ui") {
88272
88306
  this.registerNodeToInterface(newId); // will repaint
88273
- }
88274
- else {
88307
+ } else {
88275
88308
  this.v.repaint();
88276
88309
  }
88277
88310
  }
@@ -88281,8 +88314,7 @@ class GraphController {
88281
88314
  if (node.isInputConnected(input) && !visible) {
88282
88315
  sweetalert2_all('Not yet', 'Please remove all connections to this input before changing its visibility', 'error');
88283
88316
  return false;
88284
- }
88285
- else {
88317
+ } else {
88286
88318
  node.setInputVisibility(input, visible);
88287
88319
  this.v.repaint();
88288
88320
  return true;
@@ -88294,8 +88326,7 @@ class GraphController {
88294
88326
  if (node.isOutputConnected(output) && !visible) {
88295
88327
  sweetalert2_all('Not yet', 'Please remove all connections to this output before changing its visibility', 'error');
88296
88328
  return false;
88297
- }
88298
- else {
88329
+ } else {
88299
88330
  node.setOutputVisibility(output, visible);
88300
88331
  this.v.repaint();
88301
88332
  return true;
@@ -88343,12 +88374,10 @@ class GraphController {
88343
88374
  if (type == "input") {
88344
88375
  oldId = this.m.inputPrefix + oldId;
88345
88376
  newId = this.m.inputPrefix + newId;
88346
- }
88347
- else if (type == "output") {
88377
+ } else if (type == "output") {
88348
88378
  oldId = this.m.outputPrefix + oldId;
88349
88379
  newId = this.m.outputPrefix + newId;
88350
- }
88351
- else {
88380
+ } else {
88352
88381
  if (newId.startsWith(this.m.inputPrefix) ||
88353
88382
  newId.startsWith(this.m.outputPrefix)) {
88354
88383
  sweetalert2_all('Breaking convention', 'Only input boxes and output boxes can have a name that starts with "' + this.m.inputPrefix + '" or "' + this.m.outputPrefix + '".', "error");
@@ -88389,12 +88418,10 @@ class GraphController {
88389
88418
  var eventName = id.split('-')[id.split('-').length - 1];
88390
88419
  var def = this.m.getCurrentApp().getEventIn(eventName)[index];
88391
88420
  def[prop] = val;
88392
- }
88393
- else if (id.startsWith("#application-events-out")) {
88421
+ } else if (id.startsWith("#application-events-out")) {
88394
88422
  var def = this.m.getCurrentApp().getEventOut();
88395
88423
  def[prop] = val;
88396
- }
88397
- else {
88424
+ } else {
88398
88425
  var def = this.m.getNode(id).getEvent(index);
88399
88426
  def[prop] = val;
88400
88427
  this.m.getNode(id).setEvent(index, def);
@@ -88478,35 +88505,32 @@ class GraphController {
88478
88505
  var nodeIndex = -1;
88479
88506
  var eventIndex = -1;
88480
88507
 
88481
- var iterateToNextEvent = function () {
88508
+ var iterateToNextEvent = function() {
88482
88509
  if (eventIndex + 1 < eventNames.length) {
88483
88510
  eventIndex++;
88484
88511
  eventName = eventNames[eventIndex];
88485
88512
  return eventName;
88486
- }
88487
- else {
88513
+ } else {
88488
88514
  return null;
88489
88515
  }
88490
88516
  };
88491
88517
 
88492
- var iterateToNextNode = function () {
88518
+ var iterateToNextNode = function() {
88493
88519
  if (nodeIndex + 1 < nodes.length) {
88494
88520
  nodeIndex++;
88495
88521
  node = nodes[nodeIndex];
88496
88522
  eventNames = node.getEventsNames();
88497
88523
  if (eventNames.length !== 0) {
88498
88524
  return node;
88499
- }
88500
- else {
88525
+ } else {
88501
88526
  return iterateToNextNode();
88502
88527
  }
88503
- }
88504
- else {
88528
+ } else {
88505
88529
  return null;
88506
88530
  }
88507
88531
  };
88508
88532
 
88509
- var iterate = function () {
88533
+ var iterate = function() {
88510
88534
  var n, e;
88511
88535
  e = iterateToNextEvent();
88512
88536
  if (e === null) n = iterateToNextNode();
@@ -88537,8 +88561,7 @@ class GraphController {
88537
88561
  if (node != null) {
88538
88562
  var evtName = node.getEventsNames()[0];
88539
88563
  this.m.getCurrentApp().addSubEvent(name, node.getGraphId(), evtName);
88540
- }
88541
- else {
88564
+ } else {
88542
88565
  this.m.getCurrentApp().addSubEvent(name, null, null);
88543
88566
  }
88544
88567
  this.v.setMainMenu();
@@ -88557,7 +88580,7 @@ class GraphController {
88557
88580
  addInput(name, type, desc, pos) {
88558
88581
  var input = this.m.addInput(name, type, desc);
88559
88582
  if (pos) {
88560
- var node = this.m.getNode("in-"+name);
88583
+ var node = this.m.getNode("in-" + name);
88561
88584
  node.setPosition(pos);
88562
88585
  }
88563
88586
  this.v.repaint();
@@ -88566,7 +88589,7 @@ class GraphController {
88566
88589
  addOutput(name, type, desc, pos) {
88567
88590
  var output = this.m.addOutput(name, type, desc);
88568
88591
  if (pos) {
88569
- var node = this.m.getNode("out-"+name);
88592
+ var node = this.m.getNode("out-" + name);
88570
88593
  node.setPosition(pos);
88571
88594
  }
88572
88595
  this.v.repaint();
@@ -88578,8 +88601,7 @@ class GraphController {
88578
88601
  confirmButtonText: 'Next &rarr;',
88579
88602
  showCancelButton: true,
88580
88603
  progressSteps: ['1', '2']
88581
- }).queue([
88582
- {
88604
+ }).queue([{
88583
88605
  input: 'text',
88584
88606
  title: 'Enter the input name',
88585
88607
  },
@@ -88616,8 +88638,7 @@ class GraphController {
88616
88638
  confirmButtonText: 'Next &rarr;',
88617
88639
  showCancelButton: true,
88618
88640
  progressSteps: ['1', '2']
88619
- }).queue([
88620
- {
88641
+ }).queue([{
88621
88642
  input: 'text',
88622
88643
  title: 'Enter the output name',
88623
88644
  },
@@ -88657,7 +88678,7 @@ class GraphController {
88657
88678
 
88658
88679
  unsetIterator(id, input) {
88659
88680
  var node = this.m.getNode(id);
88660
- node.detachInput(input); // this connection is invalid now
88681
+ node.detachInput(input); // this connection is invalid now
88661
88682
  node.unsetIterator(input);
88662
88683
  this.v.repaint();
88663
88684
  }
@@ -88788,8 +88809,7 @@ class GraphController {
88788
88809
  confirmButtonText: 'Next &rarr;',
88789
88810
  showCancelButton: true,
88790
88811
  progressSteps: ['1', '2']
88791
- }).queue([
88792
- {
88812
+ }).queue([{
88793
88813
  input: 'text',
88794
88814
  title: 'Enter the metabox name',
88795
88815
  },