@flowgram.ai/free-layout-core 0.2.28 → 0.2.29

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/dist/esm/index.js CHANGED
@@ -201,15 +201,16 @@ var WorkflowPortEntity = class extends Entity {
201
201
  }
202
202
  // 设置连线的错误态,外部应使用 validate 进行更新
203
203
  set hasError(hasError) {
204
- this._hasError = hasError;
205
- this._onErrorChangedEmitter.fire();
204
+ if (hasError !== this._hasError) {
205
+ this._hasError = hasError;
206
+ this._onErrorChangedEmitter.fire();
207
+ }
206
208
  }
207
209
  validate() {
208
210
  const anyLineHasError = this.allLines.some((line) => {
209
211
  if (line.disposed || line.isHidden) {
210
212
  return false;
211
213
  }
212
- line.validateSelf();
213
214
  return line.hasError;
214
215
  });
215
216
  const isPortHasError = this.node.document.isErrorPort(this);
@@ -403,7 +404,6 @@ var WorkflowNodePortsData = class extends EntityData {
403
404
  port.allLines.forEach((line) => {
404
405
  line.validate();
405
406
  });
406
- port.validate();
407
407
  });
408
408
  }
409
409
  /**
@@ -534,6 +534,9 @@ var _WorkflowNodeLinesData = class _WorkflowNodeLinesData extends EntityData2 {
534
534
  get outputLines() {
535
535
  return this.data.outputLines;
536
536
  }
537
+ get allLines() {
538
+ return this.data.inputLines.concat(this.data.outputLines);
539
+ }
537
540
  /**
538
541
  * 输入节点
539
542
  */
@@ -749,6 +752,14 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
749
752
  if (opts.drawingTo) {
750
753
  this.isDrawing = true;
751
754
  }
755
+ this.onEntityChange(() => {
756
+ this.fromPort?.validate();
757
+ this.toPort?.validate();
758
+ });
759
+ this.onDispose(() => {
760
+ this.fromPort?.validate();
761
+ this.toPort?.validate();
762
+ });
752
763
  }
753
764
  /**
754
765
  * 转成线条 id
@@ -854,6 +865,7 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
854
865
  if (this.toPort === toPort) {
855
866
  return;
856
867
  }
868
+ const prePort = this.toPort;
857
869
  if (toPort && toPort.portType === "input" && this.linesManager.canAddLine(this.fromPort, toPort, true)) {
858
870
  const { node, portID } = toPort;
859
871
  this._to = node;
@@ -866,6 +878,9 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
866
878
  this.info.to = void 0;
867
879
  this.info.toPort = "";
868
880
  }
881
+ if (prePort) {
882
+ prePort.validate();
883
+ }
869
884
  this.fireChange();
870
885
  }
871
886
  /**
@@ -979,11 +994,12 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
979
994
  }
980
995
  // 校验连线是否为错误态
981
996
  validate() {
982
- const { fromPort, toPort } = this;
983
997
  this.validateSelf();
984
- fromPort?.validate();
985
- toPort?.validate();
986
998
  }
999
+ /**
1000
+ * use `validate` instead
1001
+ * @deprecated
1002
+ */
987
1003
  validateSelf() {
988
1004
  const { fromPort, toPort } = this;
989
1005
  if (fromPort) {
@@ -1423,7 +1439,6 @@ var WorkflowLinesManager = class {
1423
1439
  }
1424
1440
  fromNode.removeLine(line);
1425
1441
  toNode?.removeLine(line);
1426
- line.validate();
1427
1442
  });
1428
1443
  line.onDispose(() => {
1429
1444
  if (available) {