@dra2020/baseclient 1.0.102 → 1.0.104

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.
@@ -1071,6 +1071,7 @@ exports.DataFlowStamp = exports.DataFlowCallback = exports.DataFlow = void 0;
1071
1071
  class DataFlow {
1072
1072
  constructor() {
1073
1073
  this.usesList = [];
1074
+ this.inCompute = false;
1074
1075
  }
1075
1076
  // override in subclass
1076
1077
  dfid() { return null; }
@@ -1097,9 +1098,14 @@ class DataFlow {
1097
1098
  this.usesList.forEach(ui => { ui.id = ui.df.dfid(); });
1098
1099
  }
1099
1100
  ifcompute() {
1101
+ var _a;
1100
1102
  if (this.stale()) {
1103
+ if (this.inCompute)
1104
+ console.log(`DataFlow compute reentrancy: ${(_a = this.constructor) === null || _a === void 0 ? void 0 : _a.name}`);
1105
+ this.inCompute = true;
1101
1106
  this.remember();
1102
1107
  this.compute();
1108
+ this.inCompute = false;
1103
1109
  }
1104
1110
  }
1105
1111
  }
@@ -10094,18 +10100,16 @@ exports.topoMergeFeatures = topoMergeFeatures;
10094
10100
  let UniqueState = FSM.FSM_CUSTOM1;
10095
10101
  let FSM_COMPUTING = UniqueState++;
10096
10102
  class FsmIncrementalUnion extends FSM.Fsm {
10097
- constructor(env, options, key, map) {
10103
+ constructor(env, options, multi, key, map) {
10098
10104
  super(env);
10099
10105
  this.options = options;
10106
+ this.multi = multi;
10100
10107
  this.key = key;
10101
10108
  this.result = null;
10102
10109
  this.map = null;
10103
10110
  if (map)
10104
10111
  this.recompute(map);
10105
10112
  }
10106
- matches(key) {
10107
- return Util.shallowEqual(this.key, key);
10108
- }
10109
10113
  recompute(map) {
10110
10114
  if (this.map != null && map != null && Util.shallowEqual(map, this.map)) {
10111
10115
  this.work = { nUnion: 0, nDifference: 0, ms: 0 };
@@ -10119,7 +10123,7 @@ class FsmIncrementalUnion extends FSM.Fsm {
10119
10123
  let values = Object.values(map);
10120
10124
  this.work = { nUnion: values.length, nDifference: 0, ms: 0 };
10121
10125
  let elapsed = new Util.Elapsed();
10122
- this.result = topoMergeFeatures(this.key.multi.allTopo(), values);
10126
+ this.result = topoMergeFeatures(this.multi.allTopo(), values);
10123
10127
  this.work.ms = elapsed.ms();
10124
10128
  this.map = map;
10125
10129
  }
@@ -10145,41 +10149,36 @@ class FsmTopoUnion extends FSM.Fsm {
10145
10149
  constructor(env, options) {
10146
10150
  super(env);
10147
10151
  this.options = Util.shallowAssignImmutable(P.DefaultTickOptions, options);
10148
- this.unions = [];
10152
+ this.unions = {};
10149
10153
  this.work = { nUnion: 0, nDifference: 0, ms: 0 };
10150
10154
  }
10151
10155
  get result() {
10152
- if (this.unions.length > 0 && this.state === FSM.FSM_DONE)
10153
- return this.unions.map((i) => ({ key: i.key, poly: i.result, work: i.work }));
10156
+ if (Util.countKeys(this.unions) > 0 && this.state === FSM.FSM_DONE)
10157
+ return Object.values(this.unions).map((i) => ({ key: i.key, poly: i.result, work: i.work }));
10154
10158
  else
10155
10159
  return null;
10156
10160
  }
10157
10161
  cancel() {
10158
- this.unions.forEach((i) => {
10162
+ Object.values(this.unions).forEach((i) => {
10159
10163
  i.cancel();
10160
10164
  });
10161
- this.unions = [];
10165
+ this.unions = {};
10162
10166
  this.setState(FSM.FSM_DONE);
10163
10167
  }
10164
10168
  cancelOne(key) {
10165
- for (let i = 0; i < this.unions.length; i++) {
10166
- let u = this.unions[i];
10167
- if (u.matches(key)) {
10168
- u.cancel();
10169
- return;
10170
- }
10171
- }
10169
+ let u = this.unions[key];
10170
+ if (u)
10171
+ u.cancel();
10172
10172
  }
10173
- recompute(key, map) {
10174
- let fsm = this.unions.find((i) => i.matches(key));
10175
- if (fsm == null) {
10176
- fsm = new FsmIncrementalUnion(this.env, this.options, key, map);
10177
- this.unions.push(fsm);
10173
+ recompute(multi, key, map) {
10174
+ let fsm = this.unions[key];
10175
+ if (fsm == null || fsm.multi !== multi) {
10176
+ fsm = new FsmIncrementalUnion(this.env, this.options, multi, key, map);
10177
+ this.unions[key] = fsm;
10178
10178
  }
10179
10179
  else
10180
10180
  fsm.recompute(map);
10181
10181
  this.work = { nUnion: 0, nDifference: 0, ms: 0 };
10182
- this.unions.forEach((u) => { this.work.nUnion += u.work.nUnion; this.work.nDifference += u.work.nDifference; });
10183
10182
  this.waitOn(fsm);
10184
10183
  this.setState(FSM_COMPUTING);
10185
10184
  }
@@ -10188,8 +10187,13 @@ class FsmTopoUnion extends FSM.Fsm {
10188
10187
  switch (this.state) {
10189
10188
  case FSM.FSM_STARTING:
10190
10189
  case FSM_COMPUTING:
10190
+ this.work = { nUnion: 0, nDifference: 0, ms: 0 };
10191
10191
  if (this.unions)
10192
- this.unions.forEach((u) => { this.work.ms += u.work.ms; });
10192
+ Object.values(this.unions).forEach((i) => {
10193
+ this.work.ms += i.work.ms;
10194
+ this.work.nUnion += i.work.nUnion;
10195
+ this.work.nDifference += i.work.nDifference;
10196
+ });
10193
10197
  this.setState(FSM.FSM_DONE);
10194
10198
  break;
10195
10199
  }