@flowgram.ai/document 0.1.0-alpha.7 → 0.1.0-alpha.8

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
@@ -22,11 +22,17 @@ var FlowNodeBaseType = /* @__PURE__ */ ((FlowNodeBaseType2) => {
22
22
  FlowNodeBaseType2["BLOCK_ORDER_ICON"] = "blockOrderIcon";
23
23
  FlowNodeBaseType2["GROUP"] = "group";
24
24
  FlowNodeBaseType2["END"] = "end";
25
+ FlowNodeBaseType2["BREAK"] = "break";
25
26
  FlowNodeBaseType2["CONDITION"] = "condition";
26
27
  FlowNodeBaseType2["SUB_CANVAS"] = "subCanvas";
28
+ FlowNodeBaseType2["MULTI_INPUTS"] = "multiInputs";
29
+ FlowNodeBaseType2["MULTI_OUTPUTS"] = "multiOutputs";
30
+ FlowNodeBaseType2["INPUT"] = "input";
31
+ FlowNodeBaseType2["OUTPUT"] = "output";
27
32
  return FlowNodeBaseType2;
28
33
  })(FlowNodeBaseType || {});
29
34
  var FlowNodeSplitType = /* @__PURE__ */ ((FlowNodeSplitType2) => {
35
+ FlowNodeSplitType2["SIMPLE_SPLIT"] = "simpleSplit";
30
36
  FlowNodeSplitType2["DYNAMIC_SPLIT"] = "dynamicSplit";
31
37
  FlowNodeSplitType2["STATIC_SPLIT"] = "staticSplit";
32
38
  return FlowNodeSplitType2;
@@ -170,13 +176,37 @@ var DEFAULT_FLOW_NODE_META = (nodeType, document) => {
170
176
  };
171
177
  var FlowNodeRegistry;
172
178
  ((FlowNodeRegistry4) => {
179
+ function mergeChildRegistries(r1 = [], r2 = []) {
180
+ if (r1.length === 0 || r2.length === 0) {
181
+ return [...r1, ...r2];
182
+ }
183
+ const r1Filter = r1.map((r1Current) => {
184
+ const r2Current = r2.find((n) => n.type === r1Current.type);
185
+ if (r2Current) {
186
+ return merge(r1Current, r2Current, r1Current.type);
187
+ }
188
+ return r1Current;
189
+ });
190
+ const r2Filter = r2.filter((n) => !r1.some((r) => r.type === n.type));
191
+ return [...r1Filter, ...r2Filter];
192
+ }
193
+ FlowNodeRegistry4.mergeChildRegistries = mergeChildRegistries;
173
194
  function merge(registry1, registry2, finalType) {
195
+ const extendKeys = registry1.__extends__ ? registry1.__extends__.slice() : [];
196
+ if (registry1.type !== registry2.type) {
197
+ extendKeys.unshift(registry1.type);
198
+ }
174
199
  return {
175
200
  ...registry1,
176
201
  ...registry2,
202
+ extendChildRegistries: mergeChildRegistries(
203
+ registry1.extendChildRegistries,
204
+ registry2.extendChildRegistries
205
+ ),
177
206
  meta: { ...registry1.meta, ...registry2.meta },
178
207
  extend: void 0,
179
- type: finalType
208
+ type: finalType,
209
+ __extends__: extendKeys
180
210
  };
181
211
  }
182
212
  FlowNodeRegistry4.merge = merge;
@@ -287,6 +317,7 @@ var _FlowNodeRenderData = class _FlowNodeRenderData extends EntityData {
287
317
  this.expanded = !this.expanded;
288
318
  }
289
319
  toggleMouseEnter(silent = false) {
320
+ var _a;
290
321
  this.entity.document.renderState.setNodeHovered(this.entity);
291
322
  if (silent) return;
292
323
  const transform = this.entity.getData(FlowNodeTransformData);
@@ -298,7 +329,7 @@ var _FlowNodeRenderData = class _FlowNodeRenderData extends EntityData {
298
329
  this.mouseLeaveTimeout = void 0;
299
330
  }
300
331
  transform.renderState.hovered = true;
301
- if (this.entity.isFirst && this.entity.parent?.id !== "root") {
332
+ if (this.entity.isFirst && ((_a = this.entity.parent) == null ? void 0 : _a.id) !== "root") {
302
333
  transform.parent.renderState.activated = true;
303
334
  } else {
304
335
  transform.renderState.activated = true;
@@ -309,8 +340,9 @@ var _FlowNodeRenderData = class _FlowNodeRenderData extends EntityData {
309
340
  if (silent) return;
310
341
  const transform = this.entity.getData(FlowNodeTransformData);
311
342
  this.mouseLeaveTimeout = setTimeout(() => {
343
+ var _a;
312
344
  transform.renderState.hovered = false;
313
- if (this.entity.isFirst && this.entity.parent?.id !== "root") {
345
+ if (this.entity.isFirst && ((_a = this.entity.parent) == null ? void 0 : _a.id) !== "root") {
314
346
  transform.parent.renderState.activated = false;
315
347
  }
316
348
  transform.renderState.activated = false;
@@ -359,10 +391,11 @@ var _FlowNodeRenderData = class _FlowNodeRenderData extends EntityData {
359
391
  this.data.stackIndex = index;
360
392
  }
361
393
  get lineActivated() {
394
+ var _a, _b, _c;
362
395
  const { activated } = this;
363
396
  if (!activated) return false;
364
397
  return Boolean(
365
- this.entity.parent?.getData(_FlowNodeRenderData)?.activated || this.entity.isInlineBlock || this.entity.next?.getData(_FlowNodeRenderData).activated
398
+ ((_b = (_a = this.entity.parent) == null ? void 0 : _a.getData(_FlowNodeRenderData)) == null ? void 0 : _b.activated) || this.entity.isInlineBlock || ((_c = this.entity.next) == null ? void 0 : _c.getData(_FlowNodeRenderData).activated)
366
399
  );
367
400
  }
368
401
  get node() {
@@ -566,10 +599,10 @@ var _FlowNodeTransformData = class _FlowNodeTransformData extends EntityData2 {
566
599
  return this.entity.document.layout.getPadding(this.entity);
567
600
  }
568
601
  setParentTransform(transform) {
569
- if (this.transform.parent !== transform?.transform) {
602
+ if (this.transform.parent !== (transform == null ? void 0 : transform.transform)) {
570
603
  this.localDirty = true;
571
604
  }
572
- this.transform.setParent(transform?.transform);
605
+ this.transform.setParent(transform == null ? void 0 : transform.transform);
573
606
  }
574
607
  get spacing() {
575
608
  const { spacing } = this.entity.getNodeMeta();
@@ -596,10 +629,12 @@ var _FlowNodeTransformData = class _FlowNodeTransformData extends EntityData2 {
596
629
  * 上一个节点的 transform 数据
597
630
  */
598
631
  get pre() {
599
- return this.entity.pre?.getData(_FlowNodeTransformData);
632
+ var _a;
633
+ return (_a = this.entity.pre) == null ? void 0 : _a.getData(_FlowNodeTransformData);
600
634
  }
601
635
  get originParent() {
602
- return this.entity.originParent?.getData(_FlowNodeTransformData);
636
+ var _a;
637
+ return (_a = this.entity.originParent) == null ? void 0 : _a.getData(_FlowNodeTransformData);
603
638
  }
604
639
  get isFirst() {
605
640
  return this.entity.isFirst;
@@ -608,22 +643,26 @@ var _FlowNodeTransformData = class _FlowNodeTransformData extends EntityData2 {
608
643
  return this.entity.isLast;
609
644
  }
610
645
  get lastChild() {
611
- return this.entity.lastChild?.getData(_FlowNodeTransformData);
646
+ var _a;
647
+ return (_a = this.entity.lastChild) == null ? void 0 : _a.getData(_FlowNodeTransformData);
612
648
  }
613
649
  get firstChild() {
614
- return this.entity.firstChild?.getData(_FlowNodeTransformData);
650
+ var _a;
651
+ return (_a = this.entity.firstChild) == null ? void 0 : _a.getData(_FlowNodeTransformData);
615
652
  }
616
653
  /**
617
654
  * 下一个节点的 transform 数据
618
655
  */
619
656
  get next() {
620
- return this.entity.next?.getData(_FlowNodeTransformData);
657
+ var _a;
658
+ return (_a = this.entity.next) == null ? void 0 : _a.getData(_FlowNodeTransformData);
621
659
  }
622
660
  /**
623
661
  * parent 节点的 transform 数据
624
662
  */
625
663
  get parent() {
626
- return this.entity.parent?.getData(_FlowNodeTransformData);
664
+ var _a;
665
+ return (_a = this.entity.parent) == null ? void 0 : _a.getData(_FlowNodeTransformData);
627
666
  }
628
667
  };
629
668
  _FlowNodeTransformData.type = "FlowNodeTransformData";
@@ -647,9 +686,10 @@ var drawLineToNext = (transition) => {
647
686
  return [];
648
687
  };
649
688
  var drawLineToBottom = (transition) => {
689
+ var _a;
650
690
  const { transform } = transition;
651
691
  const currentOutput = transform.outputPoint;
652
- const parentOutput = transform.parent?.outputPoint;
692
+ const parentOutput = (_a = transform.parent) == null ? void 0 : _a.outputPoint;
653
693
  if (!transform.next && parentOutput && !new Point().copyFrom(currentOutput).equals(parentOutput) && !transition.isNodeEnd) {
654
694
  return [
655
695
  {
@@ -666,20 +706,23 @@ var FlowNodeTransitionData = class extends EntityData3 {
666
706
  return {};
667
707
  }
668
708
  formatLines(lines) {
669
- if (this.entity.document.options?.formatNodeLines) {
670
- return this.entity.document.options?.formatNodeLines?.(this.entity, lines);
709
+ var _a, _b, _c;
710
+ if ((_a = this.entity.document.options) == null ? void 0 : _a.formatNodeLines) {
711
+ return (_c = (_b = this.entity.document.options) == null ? void 0 : _b.formatNodeLines) == null ? void 0 : _c.call(_b, this.entity, lines);
671
712
  }
672
713
  return lines;
673
714
  }
674
715
  formatLabels(labels) {
716
+ var _a, _b;
675
717
  if (this.entity.document.options.formatNodeLabels) {
676
- return this.entity.document.options?.formatNodeLabels?.(this.entity, labels);
718
+ return (_b = (_a = this.entity.document.options) == null ? void 0 : _a.formatNodeLabels) == null ? void 0 : _b.call(_a, this.entity, labels);
677
719
  }
678
720
  return labels;
679
721
  }
680
722
  get lines() {
681
723
  return this.entity.memoGlobal("lines", () => {
682
- const { getChildLines } = this.entity.parent?.getNodeRegistry() || {};
724
+ var _a;
725
+ const { getChildLines } = ((_a = this.entity.parent) == null ? void 0 : _a.getNodeRegistry()) || {};
683
726
  if (getChildLines) {
684
727
  return this.formatLines(getChildLines(this, this.entity.document.layout));
685
728
  }
@@ -695,7 +738,8 @@ var FlowNodeTransitionData = class extends EntityData3 {
695
738
  }
696
739
  get labels() {
697
740
  return this.entity.memoGlobal("labels", () => {
698
- const { getChildLabels } = this.entity.parent?.getNodeRegistry() || {};
741
+ var _a, _b;
742
+ const { getChildLabels } = ((_a = this.entity.parent) == null ? void 0 : _a.getNodeRegistry()) || {};
699
743
  if (getChildLabels) {
700
744
  return this.formatLabels(getChildLabels(this, this.entity.document.layout));
701
745
  }
@@ -715,7 +759,7 @@ var FlowNodeTransitionData = class extends EntityData3 {
715
759
  }
716
760
  ]);
717
761
  }
718
- const parentOutput = this.transform.parent?.outputPoint;
762
+ const parentOutput = (_b = this.transform.parent) == null ? void 0 : _b.outputPoint;
719
763
  if (parentOutput && !new Point().copyFrom(currentOutput).equals(parentOutput) && !this.isNodeEnd) {
720
764
  return this.formatLabels([
721
765
  {
@@ -962,8 +1006,9 @@ var FlowNodeEntity = class extends Entity {
962
1006
  return this.children.length;
963
1007
  }
964
1008
  get collapsed() {
1009
+ var _a;
965
1010
  if (this.document.renderTree.isCollapsed(this)) return true;
966
- return !!this.parent?.collapsed;
1011
+ return !!((_a = this.parent) == null ? void 0 : _a.collapsed);
967
1012
  }
968
1013
  set collapsed(collapsed) {
969
1014
  this.document.renderTree.setCollapsed(this, collapsed);
@@ -1164,7 +1209,7 @@ var FlowRendererStateEntity = class extends ConfigEntity2 {
1164
1209
  }
1165
1210
  setNodeHovered(node) {
1166
1211
  this.updateConfig({
1167
- nodeHoveredId: node?.id
1212
+ nodeHoveredId: node == null ? void 0 : node.id
1168
1213
  });
1169
1214
  }
1170
1215
  getDragLabelSide() {
@@ -1189,7 +1234,7 @@ var FlowRendererStateEntity = class extends ConfigEntity2 {
1189
1234
  }
1190
1235
  setDragStartEntity(node) {
1191
1236
  this.updateConfig({
1192
- nodeDragStartId: node?.id
1237
+ nodeDragStartId: node == null ? void 0 : node.id
1193
1238
  });
1194
1239
  }
1195
1240
  // 拖拽多个节点时
@@ -1291,7 +1336,7 @@ var FlowVirtualTree = class _FlowVirtualTree {
1291
1336
  moveChilds(parent, childs, index) {
1292
1337
  const parentInfo = this.getInfo(parent);
1293
1338
  const len = parentInfo.children.length;
1294
- let childIndex = index ?? len;
1339
+ let childIndex = index != null ? index : len;
1295
1340
  childs.forEach((child) => {
1296
1341
  const childInfo = this.getInfo(child);
1297
1342
  if (childInfo.parent) {
@@ -1389,13 +1434,15 @@ var FlowVirtualTree = class _FlowVirtualTree {
1389
1434
  get size() {
1390
1435
  return this.map.size;
1391
1436
  }
1392
- toString() {
1437
+ toString(showType) {
1393
1438
  const ret = [];
1394
1439
  this.traverse((node, depth) => {
1395
1440
  if (depth === 0) {
1396
1441
  ret.push(node.id);
1397
1442
  } else {
1398
- ret.push(`|${new Array(depth).fill("--").join("")} ${node.id}`);
1443
+ ret.push(
1444
+ `|${new Array(depth).fill("--").join("")} ${showType ? `${node.flowNodeType}(${node.id})` : node.id}`
1445
+ );
1399
1446
  }
1400
1447
  });
1401
1448
  return `${ret.join("\n")}`;
@@ -1439,7 +1486,8 @@ var FlowRenderTree = class extends FlowVirtualTree {
1439
1486
  *
1440
1487
  */
1441
1488
  openNodeInsideCollapsed(node) {
1442
- let curr = this.originTree.getInfo(node)?.parent;
1489
+ var _a;
1490
+ let curr = (_a = this.originTree.getInfo(node)) == null ? void 0 : _a.parent;
1443
1491
  while (curr) {
1444
1492
  if (this.nodesCollapsed.has(curr)) {
1445
1493
  this.nodesCollapsed.delete(curr);
@@ -1511,7 +1559,7 @@ var FlowRenderTree = class extends FlowVirtualTree {
1511
1559
  if (shouldDragAllNextNodes && next) {
1512
1560
  this.dragNextNodesToBlock(passBlocks[0], next);
1513
1561
  }
1514
- children?.forEach((child) => {
1562
+ children == null ? void 0 : children.forEach((child) => {
1515
1563
  this.refineBranch(child);
1516
1564
  });
1517
1565
  if (shouldDragAllNextNodes) {
@@ -1661,11 +1709,22 @@ var FlowDocument = class {
1661
1709
  this.onNodeCreate = this.onNodeCreateEmitter.event;
1662
1710
  this.onNodeDispose = this.onNodeDisposeEmitter.event;
1663
1711
  this.onLayoutChange = this.onLayoutChangeEmitter.event;
1712
+ this._disposed = false;
1713
+ }
1714
+ /**
1715
+ *
1716
+ */
1717
+ get disposed() {
1718
+ return this._disposed;
1664
1719
  }
1665
1720
  init() {
1721
+ var _a, _b;
1666
1722
  if (!this.options) this.options = FlowDocumentOptionsDefault;
1667
1723
  this.currentLayoutKey = this.options.defaultLayout || "vertical-fixed-layout" /* VERTICAL_FIXED_LAYOUT */;
1668
- this.contributions.forEach((contrib) => contrib.registerDocument?.(this));
1724
+ this.contributions.forEach((contrib) => {
1725
+ var _a2;
1726
+ return (_a2 = contrib.registerDocument) == null ? void 0 : _a2.call(contrib, this);
1727
+ });
1669
1728
  this.root = this.addNode({ id: "root", type: "root" /* ROOT */ });
1670
1729
  this.originTree = new FlowVirtualTree(this.root);
1671
1730
  this.transformer = this.entityManager.createEntity(
@@ -1674,7 +1733,7 @@ var FlowDocument = class {
1674
1733
  );
1675
1734
  this.renderState = this.entityManager.createEntity(FlowRendererStateEntity);
1676
1735
  this.renderTree = new FlowRenderTree(this.root, this.originTree, this);
1677
- this.layout.reload?.();
1736
+ (_b = (_a = this.layout).reload) == null ? void 0 : _b.call(_a);
1678
1737
  }
1679
1738
  /**
1680
1739
  * 从数据初始化 O(n)
@@ -1686,6 +1745,7 @@ var FlowDocument = class {
1686
1745
  * @param fireRender 是否要触发渲染,默认 true
1687
1746
  */
1688
1747
  fromJSON(json, fireRender = true) {
1748
+ if (this._disposed) return;
1689
1749
  this.originTree.clear();
1690
1750
  this.renderTree.clear();
1691
1751
  this.entityManager.changeEntityLocked = true;
@@ -1709,7 +1769,10 @@ var FlowDocument = class {
1709
1769
  return layout;
1710
1770
  }
1711
1771
  async load() {
1712
- await Promise.all(this.contributions.map((c) => c.loadDocument?.(this)));
1772
+ await Promise.all(this.contributions.map((c) => {
1773
+ var _a;
1774
+ return (_a = c.loadDocument) == null ? void 0 : _a.call(c, this);
1775
+ }));
1713
1776
  }
1714
1777
  get loading() {
1715
1778
  return this.transformer.loading;
@@ -1743,8 +1806,9 @@ var FlowDocument = class {
1743
1806
  return result;
1744
1807
  }
1745
1808
  removeNode(node) {
1809
+ var _a;
1746
1810
  if (typeof node === "string") {
1747
- this.getNode(node)?.dispose();
1811
+ (_a = this.getNode(node)) == null ? void 0 : _a.dispose();
1748
1812
  } else {
1749
1813
  node.dispose();
1750
1814
  }
@@ -1754,7 +1818,8 @@ var FlowDocument = class {
1754
1818
  * @param data
1755
1819
  * @param addedNodes
1756
1820
  */
1757
- addNode(data, addedNodes, ignoreCreateEvent) {
1821
+ addNode(data, addedNodes, ignoreCreateAndUpdateEvent, ignoreBlocks) {
1822
+ var _a, _b, _c, _d;
1758
1823
  const { id, type = "block", originParent, parent, meta, hidden, index } = data;
1759
1824
  let node = this.getNode(id);
1760
1825
  let isNew = false;
@@ -1775,10 +1840,10 @@ var FlowDocument = class {
1775
1840
  const datas = dataRegistries ? this.nodeDataRegistries.concat(...dataRegistries) : this.nodeDataRegistries;
1776
1841
  node.addInitializeData(datas);
1777
1842
  node.onDispose(() => this.onNodeDisposeEmitter.fire({ node }));
1778
- if (this.options.fromNodeJSON) {
1779
- this.options.fromNodeJSON(node, data);
1780
- }
1843
+ (_b = (_a = this.options).fromNodeJSON) == null ? void 0 : _b.call(_a, node, data, true);
1781
1844
  isNew = true;
1845
+ } else {
1846
+ (_d = (_c = this.options).fromNodeJSON) == null ? void 0 : _d.call(_c, node, data, false);
1782
1847
  }
1783
1848
  node.initData({
1784
1849
  originParent,
@@ -1790,25 +1855,29 @@ var FlowDocument = class {
1790
1855
  if (node.isStart) {
1791
1856
  this.root.addChild(node);
1792
1857
  }
1793
- this.onNodeUpdateEmitter.fire({ node, data });
1794
- addedNodes?.push(node);
1858
+ addedNodes == null ? void 0 : addedNodes.push(node);
1795
1859
  if (register.onCreate) {
1796
1860
  const extendNodes = register.onCreate(node, data);
1797
1861
  if (extendNodes && addedNodes) {
1798
1862
  addedNodes.push(...extendNodes);
1799
1863
  }
1800
- } else if (data.blocks && data.blocks.length > 0) {
1864
+ } else if (data.blocks && data.blocks.length > 0 && !ignoreBlocks) {
1801
1865
  if (!data.blocks[0].type) {
1802
1866
  this.addInlineBlocks(node, data.blocks, addedNodes);
1803
1867
  } else {
1804
1868
  this.addBlocksAsChildren(node, data.blocks, addedNodes);
1805
1869
  }
1806
1870
  }
1807
- if (isNew && !ignoreCreateEvent) {
1808
- this.onNodeCreateEmitter.fire({
1809
- node,
1810
- data
1811
- });
1871
+ if (!ignoreCreateAndUpdateEvent) {
1872
+ if (isNew) {
1873
+ this.onNodeCreateEmitter.fire({
1874
+ node,
1875
+ data,
1876
+ json: data
1877
+ });
1878
+ } else {
1879
+ this.onNodeUpdateEmitter.fire({ node, data, json: data });
1880
+ }
1812
1881
  }
1813
1882
  return node;
1814
1883
  }
@@ -1844,18 +1913,16 @@ var FlowDocument = class {
1844
1913
  parent: node
1845
1914
  });
1846
1915
  addedNodes.push(blockIconNode);
1847
- if (blocks.length > 0) {
1848
- const inlineBlocksNode = this.addNode({
1849
- id: `$inlineBlocks$${node.id}`,
1850
- type: "inlineBlocks" /* INLINE_BLOCKS */,
1851
- originParent: node,
1852
- parent: node
1853
- });
1854
- addedNodes.push(inlineBlocksNode);
1855
- blocks.forEach((blockData) => {
1856
- this.addBlock(node, blockData, addedNodes);
1857
- });
1858
- }
1916
+ const inlineBlocksNode = this.addNode({
1917
+ id: `$inlineBlocks$${node.id}`,
1918
+ type: "inlineBlocks" /* INLINE_BLOCKS */,
1919
+ originParent: node,
1920
+ parent: node
1921
+ });
1922
+ addedNodes.push(inlineBlocksNode);
1923
+ blocks.forEach((blockData) => {
1924
+ this.addBlock(node, blockData, addedNodes);
1925
+ });
1859
1926
  return addedNodes;
1860
1927
  }
1861
1928
  /**
@@ -1866,6 +1933,7 @@ var FlowDocument = class {
1866
1933
  * @param parent 默认去找 $inlineBlocks$
1867
1934
  */
1868
1935
  addBlock(target, blockData, addedNodes, parent, index) {
1936
+ var _a;
1869
1937
  const node = typeof target === "string" ? this.getNode(target) : target;
1870
1938
  const { onBlockChildCreate } = node.getNodeRegistry();
1871
1939
  if (onBlockChildCreate) {
@@ -1879,7 +1947,7 @@ var FlowDocument = class {
1879
1947
  parent,
1880
1948
  index
1881
1949
  });
1882
- if (blockData.meta?.defaultCollapsed) {
1950
+ if ((_a = blockData.meta) == null ? void 0 : _a.defaultCollapsed) {
1883
1951
  block.collapsed = true;
1884
1952
  }
1885
1953
  const blockOrderIcon = this.addNode({
@@ -1890,7 +1958,7 @@ var FlowDocument = class {
1890
1958
  data: blockData.data,
1891
1959
  parent: block
1892
1960
  });
1893
- addedNodes?.push(block, blockOrderIcon);
1961
+ addedNodes == null ? void 0 : addedNodes.push(block, blockOrderIcon);
1894
1962
  if (blockData.blocks) {
1895
1963
  this.addBlocksAsChildren(block, blockData.blocks, addedNodes);
1896
1964
  }
@@ -1918,12 +1986,24 @@ var FlowDocument = class {
1918
1986
  ...preRegistry,
1919
1987
  ...newRegistry,
1920
1988
  meta: {
1921
- ...preRegistry?.meta,
1922
- ...newRegistry?.meta
1923
- }
1989
+ ...preRegistry == null ? void 0 : preRegistry.meta,
1990
+ ...newRegistry == null ? void 0 : newRegistry.meta
1991
+ },
1992
+ extendChildRegistries: FlowNodeRegistry.mergeChildRegistries(
1993
+ preRegistry == null ? void 0 : preRegistry.extendChildRegistries,
1994
+ newRegistry == null ? void 0 : newRegistry.extendChildRegistries
1995
+ )
1924
1996
  });
1925
1997
  });
1926
1998
  }
1999
+ /**
2000
+ * Check node extend
2001
+ * @param currentType
2002
+ * @param parentType
2003
+ */
2004
+ isExtend(currentType, parentType) {
2005
+ return (this.getNodeRegistry(currentType).__extends__ || []).includes(parentType);
2006
+ }
1927
2007
  /**
1928
2008
  * 导出数据,可以重载
1929
2009
  */
@@ -1940,13 +2020,15 @@ var FlowDocument = class {
1940
2020
  return this.getNodeRegistry(type, originParent);
1941
2021
  }
1942
2022
  getNodeRegistry(type, originParent) {
1943
- const typeKey = `${type}_${originParent?.flowNodeType || ""}`;
2023
+ var _a, _b, _c, _d, _e;
2024
+ const typeKey = `${type}_${(originParent == null ? void 0 : originParent.flowNodeType) || ""}`;
1944
2025
  if (this.nodeRegistryCache.has(typeKey)) {
1945
2026
  return this.nodeRegistryCache.get(typeKey);
1946
2027
  }
1947
- const customDefaultRegistry = this.options.getNodeDefaultRegistry?.(type);
2028
+ const customDefaultRegistry = (_b = (_a = this.options).getNodeDefaultRegistry) == null ? void 0 : _b.call(_a, type);
1948
2029
  let register = this.registers.get(type) || { type };
1949
2030
  const extendRegisters = [];
2031
+ const extendKey = register.extend;
1950
2032
  if (register.extend && this.registers.has(register.extend)) {
1951
2033
  register = FlowNodeRegistry.merge(
1952
2034
  this.getNodeRegistry(register.extend),
@@ -1955,9 +2037,9 @@ var FlowDocument = class {
1955
2037
  );
1956
2038
  }
1957
2039
  if (originParent) {
1958
- const extendRegister = this.getNodeRegistry(
2040
+ const extendRegister = (_c = this.getNodeRegistry(
1959
2041
  originParent.flowNodeType
1960
- ).extendChildRegistries?.find((r) => r.type === type);
2042
+ ).extendChildRegistries) == null ? void 0 : _c.find((r) => r.type === type);
1961
2043
  if (extendRegister) {
1962
2044
  if (extendRegister.extend && this.registers.has(extendRegister.extend)) {
1963
2045
  extendRegisters.push(this.registers.get(extendRegister.extend));
@@ -1967,16 +2049,19 @@ var FlowDocument = class {
1967
2049
  }
1968
2050
  register = FlowNodeRegistry.extend(register, extendRegisters);
1969
2051
  const defaultNodeMeta = DEFAULT_FLOW_NODE_META(type, this);
1970
- defaultNodeMeta.spacing = this.options?.constants?.[ConstantKeys.NODE_SPACING] || defaultNodeMeta.spacing;
2052
+ defaultNodeMeta.spacing = ((_e = (_d = this.options) == null ? void 0 : _d.constants) == null ? void 0 : _e[ConstantKeys.NODE_SPACING]) || defaultNodeMeta.spacing;
1971
2053
  const res = {
1972
2054
  ...customDefaultRegistry,
1973
2055
  ...register,
1974
2056
  meta: {
1975
2057
  ...defaultNodeMeta,
1976
- ...customDefaultRegistry?.meta,
2058
+ ...customDefaultRegistry == null ? void 0 : customDefaultRegistry.meta,
1977
2059
  ...register.meta
1978
2060
  }
1979
2061
  };
2062
+ if (extendKey) {
2063
+ res.extend = extendKey;
2064
+ }
1980
2065
  this.nodeRegistryCache.set(typeKey, res);
1981
2066
  return res;
1982
2067
  }
@@ -2027,8 +2112,8 @@ var FlowDocument = class {
2027
2112
  getAllNodes() {
2028
2113
  return this.entityManager.getEntities(FlowNodeEntity);
2029
2114
  }
2030
- toString() {
2031
- return this.originTree.toString();
2115
+ toString(showType) {
2116
+ return this.originTree.toString(showType);
2032
2117
  }
2033
2118
  /**
2034
2119
  * 返回需要渲染的数据
@@ -2105,12 +2190,13 @@ var FlowDocument = class {
2105
2190
  * @param layoutKey
2106
2191
  */
2107
2192
  setLayout(layoutKey) {
2193
+ var _a;
2108
2194
  if (this.currentLayoutKey === layoutKey) return;
2109
2195
  const layout = this.layouts.find((layout2) => layout2.name === layoutKey);
2110
2196
  if (!layout) return;
2111
2197
  this.currentLayoutKey = layoutKey;
2112
2198
  this.transformer.clear();
2113
- layout.reload?.();
2199
+ (_a = layout.reload) == null ? void 0 : _a.call(layout);
2114
2200
  this.fireRender();
2115
2201
  this.onLayoutChangeEmitter.fire(this.layout);
2116
2202
  }
@@ -2123,6 +2209,7 @@ var FlowDocument = class {
2123
2209
  );
2124
2210
  }
2125
2211
  dispose() {
2212
+ if (this._disposed) return;
2126
2213
  this.registers.clear();
2127
2214
  this.nodeRegistryCache.clear();
2128
2215
  this.originTree.dispose();
@@ -2131,6 +2218,7 @@ var FlowDocument = class {
2131
2218
  this.onNodeCreateEmitter.dispose();
2132
2219
  this.onNodeDisposeEmitter.dispose();
2133
2220
  this.onLayoutChangeEmitter.dispose();
2221
+ this._disposed = true;
2134
2222
  }
2135
2223
  };
2136
2224
  __decorateClass([
@@ -2158,137 +2246,434 @@ FlowDocument = __decorateClass([
2158
2246
  import { ContainerModule } from "inversify";
2159
2247
 
2160
2248
  // src/services/flow-drag-service.ts
2161
- import { inject as inject5, injectable as injectable5 } from "inversify";
2162
- import { EntityManager as EntityManager4 } from "@flowgram.ai/core";
2163
- import { Emitter as Emitter7 } from "@flowgram.ai/utils";
2164
-
2165
- // src/services/flow-operation-base-service.ts
2166
- import { inject as inject3, injectable as injectable3, postConstruct as postConstruct2 } from "inversify";
2167
- import { DisposableCollection, Emitter as Emitter6 } from "@flowgram.ai/utils";
2249
+ import { inject as inject3, injectable as injectable3 } from "inversify";
2250
+ import { Emitter as Emitter6 } from "@flowgram.ai/utils";
2168
2251
  import { EntityManager as EntityManager2 } from "@flowgram.ai/core";
2169
- var FlowOperationBaseServiceImpl = class {
2170
- constructor() {
2171
- this.onNodeAddEmitter = new Emitter6();
2172
- this.onNodeAdd = this.onNodeAddEmitter.event;
2173
- this.toDispose = new DisposableCollection();
2174
- this.onNodeMoveEmitter = new Emitter6();
2175
- this.onNodeMove = this.onNodeMoveEmitter.event;
2252
+
2253
+ // src/services/flow-group-service/flow-group-controller.ts
2254
+ var FlowGroupController = class _FlowGroupController {
2255
+ constructor(groupNode) {
2256
+ this.groupNode = groupNode;
2176
2257
  }
2177
- init() {
2178
- this.toDispose.pushAll([this.onNodeAddEmitter, this.onNodeMoveEmitter]);
2258
+ get nodes() {
2259
+ return this.groupNode.collapsedChildren || [];
2179
2260
  }
2180
- addNode(nodeJSON, config = {}) {
2181
- const { parent, index, hidden } = config;
2182
- let parentEntity;
2183
- if (parent) {
2184
- parentEntity = this.toNodeEntity(parent);
2261
+ get collapsed() {
2262
+ const groupTransformData = this.groupNode.getData(FlowNodeTransformData);
2263
+ return groupTransformData.collapsed;
2264
+ }
2265
+ collapse() {
2266
+ this.collapsed = true;
2267
+ }
2268
+ expand() {
2269
+ this.collapsed = false;
2270
+ }
2271
+ /** 获取分组外围的最大边框 */
2272
+ get bounds() {
2273
+ const groupNodeBounds = this.groupNode.getData(FlowNodeTransformData).bounds;
2274
+ return groupNodeBounds;
2275
+ }
2276
+ /** 是否是开始节点 */
2277
+ isStartNode(node) {
2278
+ if (!node) {
2279
+ return false;
2185
2280
  }
2186
- let register;
2187
- if (parentEntity) {
2188
- register = parentEntity.getNodeRegistry();
2281
+ const nodes = this.nodes;
2282
+ if (!nodes[0]) {
2283
+ return false;
2189
2284
  }
2190
- const addJSON = {
2191
- ...nodeJSON,
2192
- type: nodeJSON.type || "block" /* BLOCK */
2193
- };
2194
- const addNodeData = {
2195
- ...addJSON,
2196
- parent: parentEntity,
2197
- index,
2198
- hidden
2199
- };
2200
- let added;
2201
- if (parentEntity && register?.addChild) {
2202
- added = register.addChild(parentEntity, addJSON, {
2203
- index,
2204
- hidden
2205
- });
2206
- } else {
2207
- added = this.document.addNode(addNodeData);
2285
+ return node.id === nodes[0].id;
2286
+ }
2287
+ /** 是否是结束节点 */
2288
+ isEndNode(node) {
2289
+ if (!node) {
2290
+ return false;
2208
2291
  }
2209
- this.onNodeAddEmitter.fire({
2210
- node: added,
2211
- data: addNodeData
2212
- });
2213
- return added;
2292
+ const nodes = this.nodes;
2293
+ if (!nodes[nodes.length - 1]) {
2294
+ return false;
2295
+ }
2296
+ return node.id === nodes[nodes.length - 1].id;
2214
2297
  }
2215
- addFromNode(fromNode, nodeJSON) {
2216
- return this.document.addFromNode(fromNode, nodeJSON);
2298
+ set note(note) {
2299
+ this.groupNode.getNodeMeta().note = note;
2217
2300
  }
2218
- deleteNode(node) {
2219
- this.document.removeNode(node);
2301
+ get note() {
2302
+ return this.groupNode.getNodeMeta().note || "";
2220
2303
  }
2221
- deleteNodes(nodes) {
2222
- (nodes || []).forEach((node) => {
2223
- this.deleteNode(node);
2224
- });
2304
+ set noteHeight(height) {
2305
+ this.groupNode.getNodeMeta().noteHeight = height;
2225
2306
  }
2226
- addBlock(target, blockJSON, config = {}) {
2227
- const { parent, index } = config;
2228
- return this.document.addBlock(target, blockJSON, void 0, parent, index);
2307
+ get noteHeight() {
2308
+ return this.groupNode.getNodeMeta().noteHeight || 0;
2229
2309
  }
2230
- moveNode(node, config = {}) {
2231
- const { parent: newParent, index } = config;
2232
- const entity = this.toNodeEntity(node);
2233
- const parent = entity?.parent;
2234
- if (!parent) {
2235
- return;
2310
+ get positionConfig() {
2311
+ return this.groupNode.getNodeMeta().positionConfig;
2312
+ }
2313
+ set collapsed(collapsed) {
2314
+ var _a;
2315
+ const groupTransformData = this.groupNode.getData(FlowNodeTransformData);
2316
+ groupTransformData.collapsed = collapsed;
2317
+ groupTransformData.localDirty = true;
2318
+ if (groupTransformData.parent) groupTransformData.parent.localDirty = true;
2319
+ if ((_a = groupTransformData.parent) == null ? void 0 : _a.firstChild)
2320
+ groupTransformData.parent.firstChild.localDirty = true;
2321
+ }
2322
+ set hovered(hovered) {
2323
+ const groupRenderData = this.groupNode.getData(FlowNodeRenderData);
2324
+ if (hovered) {
2325
+ groupRenderData.toggleMouseEnter();
2326
+ } else {
2327
+ groupRenderData.toggleMouseLeave();
2236
2328
  }
2237
- const newParentEntity = newParent ? this.toNodeEntity(newParent) : parent;
2238
- if (!newParentEntity) {
2239
- console.warn("no new parent found", newParent);
2329
+ if (groupRenderData.hovered === hovered) {
2240
2330
  return;
2241
2331
  }
2242
- let toIndex = typeof index === "undefined" ? newParentEntity.collapsedChildren.length : index;
2243
- return this.doMoveNode(entity, newParentEntity, toIndex);
2332
+ groupRenderData.hovered = hovered;
2244
2333
  }
2245
- /**
2246
- * 拖拽节点
2247
- * @param param0
2248
- * @returns
2249
- */
2250
- dragNodes({ dropNode, nodes }) {
2251
- if (nodes.length === 0) {
2334
+ get hovered() {
2335
+ const groupRenderData = this.groupNode.getData(FlowNodeRenderData);
2336
+ return groupRenderData.hovered;
2337
+ }
2338
+ static create(groupNode) {
2339
+ if (!groupNode) {
2252
2340
  return;
2253
2341
  }
2254
- const startNode = nodes[0];
2255
- const fromParent = startNode.parent;
2256
- const toParent = dropNode.parent;
2257
- if (!fromParent || !toParent) {
2342
+ if (!FlowGroupUtils.isGroupNode(groupNode)) {
2258
2343
  return;
2259
2344
  }
2260
- const fromIndex = fromParent.children.findIndex((child) => child === startNode);
2261
- const dropIndex = toParent.children.findIndex((child) => child === dropNode);
2262
- let toIndex = dropIndex + 1;
2263
- if (fromParent === toParent && fromIndex < dropIndex) {
2264
- toIndex = toIndex - nodes.length;
2345
+ return new _FlowGroupController(groupNode);
2346
+ }
2347
+ };
2348
+
2349
+ // src/services/flow-group-service/flow-group-utils.ts
2350
+ var FlowGroupUtils;
2351
+ ((FlowGroupUtils2) => {
2352
+ const findNodeParents = (node) => {
2353
+ const parents = [];
2354
+ let parent = node.parent;
2355
+ while (parent) {
2356
+ parents.push(parent);
2357
+ parent = parent.parent;
2265
2358
  }
2266
- const value = {
2267
- nodeIds: nodes.map((node) => node.id),
2268
- fromParentId: fromParent.id,
2269
- toParentId: toParent.id,
2270
- fromIndex,
2271
- toIndex
2272
- };
2273
- return this.apply({
2274
- type: "moveChildNodes" /* moveChildNodes */,
2275
- value
2359
+ return parents;
2360
+ };
2361
+ const isNodeInGroup = (node) => {
2362
+ var _a;
2363
+ if (((_a = node == null ? void 0 : node.parent) == null ? void 0 : _a.flowNodeType) === "group" /* GROUP */) {
2364
+ return true;
2365
+ }
2366
+ return false;
2367
+ };
2368
+ FlowGroupUtils2.validate = (nodes) => {
2369
+ if (!nodes || !Array.isArray(nodes) || nodes.length === 0) {
2370
+ return false;
2371
+ }
2372
+ const isGroupRelatedNode = nodes.some((node) => (0, FlowGroupUtils2.isGroupNode)(node));
2373
+ if (isGroupRelatedNode) return false;
2374
+ const hasGroup = nodes.some((node) => node && isNodeInGroup(node));
2375
+ if (hasGroup) return false;
2376
+ const parent = nodes[0].parent;
2377
+ const isSameParent = nodes.every((node) => node.parent === parent);
2378
+ if (!isSameParent) return false;
2379
+ const indexes = nodes.map((node) => node.index).sort((a, b) => a - b);
2380
+ const isIndexContinuous = indexes.every((index, i, arr) => {
2381
+ if (i === 0) {
2382
+ return true;
2383
+ }
2384
+ return index === arr[i - 1] + 1;
2276
2385
  });
2386
+ if (!isIndexContinuous) return false;
2387
+ const parents = findNodeParents(nodes[0]);
2388
+ const parentsInGroup = parents.some((parent2) => isNodeInGroup(parent2));
2389
+ if (parentsInGroup) return false;
2390
+ return true;
2391
+ };
2392
+ FlowGroupUtils2.getNodeGroupController = (node) => {
2393
+ if (!node) {
2394
+ return;
2395
+ }
2396
+ if (!isNodeInGroup(node)) {
2397
+ return;
2398
+ }
2399
+ const groupNode = node == null ? void 0 : node.parent;
2400
+ return FlowGroupController.create(groupNode);
2401
+ };
2402
+ FlowGroupUtils2.getNodeRecursionGroupController = (node) => {
2403
+ if (!node) {
2404
+ return;
2405
+ }
2406
+ const group = (0, FlowGroupUtils2.getNodeGroupController)(node);
2407
+ if (group) {
2408
+ return group;
2409
+ }
2410
+ if (node.parent) {
2411
+ return (0, FlowGroupUtils2.getNodeRecursionGroupController)(node.parent);
2412
+ }
2413
+ return;
2414
+ };
2415
+ FlowGroupUtils2.isGroupNode = (group) => group.flowNodeType === "group" /* GROUP */;
2416
+ })(FlowGroupUtils || (FlowGroupUtils = {}));
2417
+
2418
+ // src/services/flow-drag-service.ts
2419
+ var FlowDragService = class {
2420
+ constructor() {
2421
+ this.onDropEmitter = new Emitter6();
2422
+ this.onDrop = this.onDropEmitter.event;
2277
2423
  }
2278
- /**
2279
- * 执行操作
2280
- * @param operation 可序列化的操作
2281
- * @returns 操作返回
2282
- */
2283
- apply(operation) {
2284
- const document = this.document;
2285
- switch (operation.type) {
2286
- case "addFromNode" /* addFromNode */:
2287
- return document.addFromNode(operation.value.fromId, operation.value.data);
2288
- case "deleteFromNode" /* deleteFromNode */:
2289
- return document.getNode(operation.value?.data?.id)?.dispose();
2290
- case "addBlock" /* addBlock */: {
2291
- let parent;
2424
+ get renderState() {
2425
+ return this.document.renderState;
2426
+ }
2427
+ // 拖拽所有节点中的首个节点
2428
+ get dragStartNode() {
2429
+ return this.renderState.getDragStartEntity();
2430
+ }
2431
+ // 拖拽的所有节点
2432
+ get dragNodes() {
2433
+ return this.renderState.getDragEntities();
2434
+ }
2435
+ // 放置的区域
2436
+ get dropNodeId() {
2437
+ return this.renderState.getNodeDroppingId();
2438
+ }
2439
+ // 是否在拖拽分支
2440
+ get isDragBranch() {
2441
+ var _a;
2442
+ return (_a = this.dragStartNode) == null ? void 0 : _a.isInlineBlock;
2443
+ }
2444
+ // 拖拽的所有节点及其自节点
2445
+ get nodeDragIdsWithChildren() {
2446
+ return this.renderState.config.nodeDragIdsWithChildren || [];
2447
+ }
2448
+ get dragging() {
2449
+ var _a;
2450
+ const renderData = (_a = this.dragStartNode) == null ? void 0 : _a.getData(FlowNodeRenderData);
2451
+ return !!(renderData == null ? void 0 : renderData.dragging);
2452
+ }
2453
+ get labelSide() {
2454
+ return this.renderState.config.dragLabelSide;
2455
+ }
2456
+ /**
2457
+ * 放置到目标分支
2458
+ */
2459
+ dropBranch() {
2460
+ this.dropNode();
2461
+ }
2462
+ /**
2463
+ * 移动到目标节点
2464
+ */
2465
+ dropNode() {
2466
+ const dropEntity = this.document.getNode(this.dropNodeId);
2467
+ if (!dropEntity) {
2468
+ return;
2469
+ }
2470
+ const sortNodes = [];
2471
+ let curr = this.dragStartNode;
2472
+ while (curr && this.dragNodes.includes(curr)) {
2473
+ sortNodes.push(curr);
2474
+ curr = curr.next;
2475
+ }
2476
+ this.operationService.dragNodes({
2477
+ dropNode: dropEntity,
2478
+ nodes: sortNodes
2479
+ });
2480
+ if (sortNodes.length > 0) {
2481
+ this.onDropEmitter.fire({
2482
+ dropNode: dropEntity,
2483
+ dragNodes: sortNodes
2484
+ });
2485
+ }
2486
+ }
2487
+ /**
2488
+ * 拖拽是否可以释放在该节点后面
2489
+ */
2490
+ isDroppableNode(node) {
2491
+ if (!this.dragging || this.isDragBranch) {
2492
+ return false;
2493
+ }
2494
+ if (this.nodeDragIdsWithChildren.includes(node.id) || node.next && this.nodeDragIdsWithChildren.includes(node.next.id)) {
2495
+ return false;
2496
+ }
2497
+ if (node.isInlineBlocks || node.isInlineBlock) {
2498
+ return false;
2499
+ }
2500
+ const hasGroupNode = this.dragNodes.some(
2501
+ (node2) => node2.flowNodeType === "group" /* GROUP */
2502
+ );
2503
+ if (hasGroupNode) {
2504
+ const group = FlowGroupUtils.getNodeRecursionGroupController(node);
2505
+ if (group) {
2506
+ return false;
2507
+ }
2508
+ }
2509
+ return true;
2510
+ }
2511
+ /**
2512
+ * 拖拽分支是否可以释放在该分支
2513
+ * @param node 拖拽的分支节点
2514
+ * @param side 分支的前面还是后面
2515
+ */
2516
+ isDroppableBranch(node, side = "normal_branch" /* NORMAL_BRANCH */) {
2517
+ if (this.isDragBranch) {
2518
+ if (
2519
+ // 拖拽到分支
2520
+ !node.isInlineBlock || // 只能在同一分支条件下
2521
+ node.parent !== this.dragStartNode.parent || // 自己不能拖拽给自己
2522
+ node === this.dragStartNode
2523
+ ) {
2524
+ return false;
2525
+ }
2526
+ if (side === "normal_branch" /* NORMAL_BRANCH */ && node.next !== this.dragStartNode) {
2527
+ return true;
2528
+ }
2529
+ if (side === "pre_branch" /* PRE_BRANCH */ && node.pre !== this.dragStartNode) {
2530
+ return true;
2531
+ }
2532
+ }
2533
+ return false;
2534
+ }
2535
+ };
2536
+ __decorateClass([
2537
+ inject3(FlowDocument)
2538
+ ], FlowDragService.prototype, "document", 2);
2539
+ __decorateClass([
2540
+ inject3(FlowOperationBaseService)
2541
+ ], FlowDragService.prototype, "operationService", 2);
2542
+ __decorateClass([
2543
+ inject3(EntityManager2)
2544
+ ], FlowDragService.prototype, "entityManager", 2);
2545
+ FlowDragService = __decorateClass([
2546
+ injectable3()
2547
+ ], FlowDragService);
2548
+
2549
+ // src/services/flow-operation-base-service.ts
2550
+ import { inject as inject4, injectable as injectable4, postConstruct as postConstruct2 } from "inversify";
2551
+ import { DisposableCollection, Emitter as Emitter7 } from "@flowgram.ai/utils";
2552
+ import { EntityManager as EntityManager3 } from "@flowgram.ai/core";
2553
+ var FlowOperationBaseServiceImpl = class {
2554
+ constructor() {
2555
+ this.onNodeAddEmitter = new Emitter7();
2556
+ this.onNodeAdd = this.onNodeAddEmitter.event;
2557
+ this.toDispose = new DisposableCollection();
2558
+ this.onNodeMoveEmitter = new Emitter7();
2559
+ this.onNodeMove = this.onNodeMoveEmitter.event;
2560
+ }
2561
+ init() {
2562
+ this.toDispose.pushAll([this.onNodeAddEmitter, this.onNodeMoveEmitter]);
2563
+ }
2564
+ addNode(nodeJSON, config = {}) {
2565
+ const { parent, index, hidden } = config;
2566
+ let parentEntity;
2567
+ if (parent) {
2568
+ parentEntity = this.toNodeEntity(parent);
2569
+ }
2570
+ let register;
2571
+ if (parentEntity) {
2572
+ register = parentEntity.getNodeRegistry();
2573
+ }
2574
+ const addJSON = {
2575
+ ...nodeJSON,
2576
+ type: nodeJSON.type || "block" /* BLOCK */
2577
+ };
2578
+ const addNodeData = {
2579
+ ...addJSON,
2580
+ parent: parentEntity,
2581
+ index,
2582
+ hidden
2583
+ };
2584
+ let added;
2585
+ if (parentEntity && (register == null ? void 0 : register.addChild)) {
2586
+ added = register.addChild(parentEntity, addJSON, {
2587
+ index,
2588
+ hidden
2589
+ });
2590
+ } else {
2591
+ added = this.document.addNode(addNodeData);
2592
+ }
2593
+ this.onNodeAddEmitter.fire({
2594
+ node: added,
2595
+ data: addNodeData
2596
+ });
2597
+ return added;
2598
+ }
2599
+ addFromNode(fromNode, nodeJSON) {
2600
+ return this.document.addFromNode(fromNode, nodeJSON);
2601
+ }
2602
+ deleteNode(node) {
2603
+ this.document.removeNode(node);
2604
+ }
2605
+ deleteNodes(nodes) {
2606
+ (nodes || []).forEach((node) => {
2607
+ this.deleteNode(node);
2608
+ });
2609
+ }
2610
+ addBlock(target, blockJSON, config = {}) {
2611
+ const { parent, index } = config;
2612
+ return this.document.addBlock(target, blockJSON, void 0, parent, index);
2613
+ }
2614
+ moveNode(node, config = {}) {
2615
+ const { parent: newParent, index } = config;
2616
+ const entity = this.toNodeEntity(node);
2617
+ const parent = entity == null ? void 0 : entity.parent;
2618
+ if (!parent) {
2619
+ return;
2620
+ }
2621
+ const newParentEntity = newParent ? this.toNodeEntity(newParent) : parent;
2622
+ if (!newParentEntity) {
2623
+ console.warn("no new parent found", newParent);
2624
+ return;
2625
+ }
2626
+ let toIndex = typeof index === "undefined" ? newParentEntity.collapsedChildren.length : index;
2627
+ return this.doMoveNode(entity, newParentEntity, toIndex);
2628
+ }
2629
+ /**
2630
+ * 拖拽节点
2631
+ * @param param0
2632
+ * @returns
2633
+ */
2634
+ dragNodes({ dropNode, nodes }) {
2635
+ if (nodes.length === 0) {
2636
+ return;
2637
+ }
2638
+ const startNode = nodes[0];
2639
+ const fromParent = startNode.parent;
2640
+ const toParent = dropNode.parent;
2641
+ if (!fromParent || !toParent) {
2642
+ return;
2643
+ }
2644
+ const fromIndex = fromParent.children.findIndex((child) => child === startNode);
2645
+ const dropIndex = toParent.children.findIndex((child) => child === dropNode);
2646
+ let toIndex = dropIndex + 1;
2647
+ if (fromParent === toParent && fromIndex < dropIndex) {
2648
+ toIndex = toIndex - nodes.length;
2649
+ }
2650
+ const value = {
2651
+ nodeIds: nodes.map((node) => node.id),
2652
+ fromParentId: fromParent.id,
2653
+ toParentId: toParent.id,
2654
+ fromIndex,
2655
+ toIndex
2656
+ };
2657
+ return this.apply({
2658
+ type: "moveChildNodes" /* moveChildNodes */,
2659
+ value
2660
+ });
2661
+ }
2662
+ /**
2663
+ * 执行操作
2664
+ * @param operation 可序列化的操作
2665
+ * @returns 操作返回
2666
+ */
2667
+ apply(operation) {
2668
+ var _a, _b, _c, _d, _e, _f;
2669
+ const document = this.document;
2670
+ switch (operation.type) {
2671
+ case "addFromNode" /* addFromNode */:
2672
+ return document.addFromNode(operation.value.fromId, operation.value.data);
2673
+ case "deleteFromNode" /* deleteFromNode */:
2674
+ return (_c = document.getNode((_b = (_a = operation.value) == null ? void 0 : _a.data) == null ? void 0 : _b.id)) == null ? void 0 : _c.dispose();
2675
+ case "addBlock" /* addBlock */: {
2676
+ let parent;
2292
2677
  if (operation.value.parentId) {
2293
2678
  parent = document.getNode(operation.value.parentId);
2294
2679
  }
@@ -2301,8 +2686,8 @@ var FlowOperationBaseServiceImpl = class {
2301
2686
  );
2302
2687
  }
2303
2688
  case "deleteBlock" /* deleteBlock */: {
2304
- const entity = document.getNode(operation.value?.blockData.id);
2305
- return entity?.dispose();
2689
+ const entity = document.getNode((_d = operation.value) == null ? void 0 : _d.blockData.id);
2690
+ return entity == null ? void 0 : entity.dispose();
2306
2691
  }
2307
2692
  case "createGroup" /* createGroup */: {
2308
2693
  const groupNode = document.addFromNode(operation.value.targetId, {
@@ -2321,7 +2706,7 @@ var FlowOperationBaseServiceImpl = class {
2321
2706
  dropNodeId: operation.value.groupId,
2322
2707
  sortNodeIds: operation.value.nodeIds
2323
2708
  });
2324
- return document.getNode(operation.value.groupId)?.dispose();
2709
+ return (_e = document.getNode(operation.value.groupId)) == null ? void 0 : _e.dispose();
2325
2710
  }
2326
2711
  case "moveNodes" /* moveNodes */: {
2327
2712
  return document.moveNodes({
@@ -2346,7 +2731,7 @@ var FlowOperationBaseServiceImpl = class {
2346
2731
  case "deleteNodes" /* deleteNodes */: {
2347
2732
  (operation.value.nodes || []).forEach((node) => {
2348
2733
  const entity = document.getNode(node.id);
2349
- entity?.dispose();
2734
+ entity == null ? void 0 : entity.dispose();
2350
2735
  });
2351
2736
  break;
2352
2737
  }
@@ -2360,7 +2745,7 @@ var FlowOperationBaseServiceImpl = class {
2360
2745
  });
2361
2746
  }
2362
2747
  case "deleteChildNode" /* deleteChildNode */:
2363
- return document.getNode(operation.value.data.id)?.dispose();
2748
+ return (_f = document.getNode(operation.value.data.id)) == null ? void 0 : _f.dispose();
2364
2749
  case "moveChildNodes" /* moveChildNodes */:
2365
2750
  return document.moveChildNodes(operation.value);
2366
2751
  default:
@@ -2385,7 +2770,7 @@ var FlowOperationBaseServiceImpl = class {
2385
2770
  }
2386
2771
  getNodeIndex(node) {
2387
2772
  const entity = this.toNodeEntity(node);
2388
- const parent = entity?.parent;
2773
+ const parent = entity == null ? void 0 : entity.parent;
2389
2774
  if (!parent) {
2390
2775
  return -1;
2391
2776
  }
@@ -2411,29 +2796,29 @@ var FlowOperationBaseServiceImpl = class {
2411
2796
  }
2412
2797
  };
2413
2798
  __decorateClass([
2414
- inject3(EntityManager2)
2799
+ inject4(EntityManager3)
2415
2800
  ], FlowOperationBaseServiceImpl.prototype, "entityManager", 2);
2416
2801
  __decorateClass([
2417
- inject3(FlowDocument)
2802
+ inject4(FlowDocument)
2418
2803
  ], FlowOperationBaseServiceImpl.prototype, "document", 2);
2419
2804
  __decorateClass([
2420
2805
  postConstruct2()
2421
2806
  ], FlowOperationBaseServiceImpl.prototype, "init", 1);
2422
2807
  FlowOperationBaseServiceImpl = __decorateClass([
2423
- injectable3()
2808
+ injectable4()
2424
2809
  ], FlowOperationBaseServiceImpl);
2425
2810
 
2426
- // src/services/flow-group-service.ts
2811
+ // src/services/flow-group-service/flow-group-service.ts
2427
2812
  import { nanoid } from "nanoid";
2428
- import { inject as inject4, injectable as injectable4 } from "inversify";
2429
- import { EntityManager as EntityManager3 } from "@flowgram.ai/core";
2813
+ import { inject as inject5, injectable as injectable5 } from "inversify";
2814
+ import { EntityManager as EntityManager4 } from "@flowgram.ai/core";
2430
2815
  var FlowGroupService = class {
2431
2816
  /** 创建分组节点 */
2432
2817
  createGroup(nodes) {
2433
2818
  if (!nodes || !Array.isArray(nodes) || nodes.length === 0) {
2434
2819
  return;
2435
2820
  }
2436
- if (!FlowGroupController.validate(nodes)) {
2821
+ if (!FlowGroupUtils.validate(nodes)) {
2437
2822
  return;
2438
2823
  }
2439
2824
  const sortedNodes = nodes.sort((a, b) => a.index - b.index);
@@ -2503,309 +2888,18 @@ var FlowGroupService = class {
2503
2888
  return FlowGroupController.create(group);
2504
2889
  }
2505
2890
  static validate(nodes) {
2506
- return FlowGroupController.validate(nodes);
2891
+ return FlowGroupUtils.validate(nodes);
2507
2892
  }
2508
2893
  };
2509
2894
  __decorateClass([
2510
- inject4(EntityManager3)
2895
+ inject5(EntityManager4)
2511
2896
  ], FlowGroupService.prototype, "entityManager", 2);
2512
2897
  __decorateClass([
2513
- inject4(FlowOperationBaseService)
2898
+ inject5(FlowOperationBaseService)
2514
2899
  ], FlowGroupService.prototype, "operationService", 2);
2515
2900
  FlowGroupService = __decorateClass([
2516
- injectable4()
2517
- ], FlowGroupService);
2518
- var FlowGroupController = class _FlowGroupController {
2519
- constructor(groupNode) {
2520
- this.groupNode = groupNode;
2521
- }
2522
- get nodes() {
2523
- return this.groupNode.collapsedChildren || [];
2524
- }
2525
- get collapsed() {
2526
- const groupTransformData = this.groupNode.getData(FlowNodeTransformData);
2527
- return groupTransformData.collapsed;
2528
- }
2529
- collapse() {
2530
- this.collapsed = true;
2531
- }
2532
- expand() {
2533
- this.collapsed = false;
2534
- }
2535
- /** 获取分组外围的最大边框 */
2536
- get bounds() {
2537
- const groupNodeBounds = this.groupNode.getData(FlowNodeTransformData).bounds;
2538
- return groupNodeBounds;
2539
- }
2540
- /** 是否是开始节点 */
2541
- isStartNode(node) {
2542
- if (!node) {
2543
- return false;
2544
- }
2545
- const nodes = this.nodes;
2546
- if (!nodes[0]) {
2547
- return false;
2548
- }
2549
- return node.id === nodes[0].id;
2550
- }
2551
- /** 是否是结束节点 */
2552
- isEndNode(node) {
2553
- if (!node) {
2554
- return false;
2555
- }
2556
- const nodes = this.nodes;
2557
- if (!nodes[nodes.length - 1]) {
2558
- return false;
2559
- }
2560
- return node.id === nodes[nodes.length - 1].id;
2561
- }
2562
- set note(note) {
2563
- this.groupNode.getNodeMeta().note = note;
2564
- }
2565
- get note() {
2566
- return this.groupNode.getNodeMeta().note || "";
2567
- }
2568
- set noteHeight(height) {
2569
- this.groupNode.getNodeMeta().noteHeight = height;
2570
- }
2571
- get noteHeight() {
2572
- return this.groupNode.getNodeMeta().noteHeight || 0;
2573
- }
2574
- get positionConfig() {
2575
- return this.groupNode.getNodeMeta().positionConfig;
2576
- }
2577
- set collapsed(collapsed) {
2578
- const groupTransformData = this.groupNode.getData(FlowNodeTransformData);
2579
- groupTransformData.collapsed = collapsed;
2580
- groupTransformData.localDirty = true;
2581
- if (groupTransformData.parent) groupTransformData.parent.localDirty = true;
2582
- if (groupTransformData.parent?.firstChild)
2583
- groupTransformData.parent.firstChild.localDirty = true;
2584
- }
2585
- set hovered(hovered) {
2586
- const groupRenderData = this.groupNode.getData(FlowNodeRenderData);
2587
- if (hovered) {
2588
- groupRenderData.toggleMouseEnter();
2589
- } else {
2590
- groupRenderData.toggleMouseLeave();
2591
- }
2592
- if (groupRenderData.hovered === hovered) {
2593
- return;
2594
- }
2595
- groupRenderData.hovered = hovered;
2596
- }
2597
- get hovered() {
2598
- const groupRenderData = this.groupNode.getData(FlowNodeRenderData);
2599
- return groupRenderData.hovered;
2600
- }
2601
- static create(groupNode) {
2602
- if (!groupNode) {
2603
- return;
2604
- }
2605
- if (!_FlowGroupController.isGroupNode(groupNode)) {
2606
- return;
2607
- }
2608
- return new _FlowGroupController(groupNode);
2609
- }
2610
- /** 判断节点能否组成分组 */
2611
- static validate(nodes) {
2612
- if (!nodes || !Array.isArray(nodes) || nodes.length === 0) {
2613
- return false;
2614
- }
2615
- const isGroupRelatedNode = nodes.some((node) => _FlowGroupController.isGroupNode(node));
2616
- if (isGroupRelatedNode) return false;
2617
- const hasGroup = nodes.some((node) => node && this.isNodeInGroup(node));
2618
- if (hasGroup) return false;
2619
- const parent = nodes[0].parent;
2620
- const isSameParent = nodes.every((node) => node.parent === parent);
2621
- if (!isSameParent) return false;
2622
- const indexes = nodes.map((node) => node.index).sort((a, b) => a - b);
2623
- const isIndexContinuous = indexes.every((index, i, arr) => {
2624
- if (i === 0) {
2625
- return true;
2626
- }
2627
- return index === arr[i - 1] + 1;
2628
- });
2629
- if (!isIndexContinuous) return false;
2630
- const parents = this.findNodeParents(nodes[0]);
2631
- const parentsInGroup = parents.some((parent2) => this.isNodeInGroup(parent2));
2632
- if (parentsInGroup) return false;
2633
- return true;
2634
- }
2635
- /** 获取节点分组控制 */
2636
- static getNodeGroupController(node) {
2637
- if (!node) {
2638
- return;
2639
- }
2640
- if (!this.isNodeInGroup(node)) {
2641
- return;
2642
- }
2643
- const groupNode = node?.parent;
2644
- return _FlowGroupController.create(groupNode);
2645
- }
2646
- /** 向上递归查找分组递归控制 */
2647
- static getNodeRecursionGroupController(node) {
2648
- if (!node) {
2649
- return;
2650
- }
2651
- const group = this.getNodeGroupController(node);
2652
- if (group) {
2653
- return group;
2654
- }
2655
- if (node.parent) {
2656
- return this.getNodeRecursionGroupController(node.parent);
2657
- }
2658
- return;
2659
- }
2660
- /** 是否分组节点 */
2661
- static isGroupNode(group) {
2662
- return group.flowNodeType === "group" /* GROUP */;
2663
- }
2664
- /** 找到节点所有上级 */
2665
- static findNodeParents(node) {
2666
- const parents = [];
2667
- let parent = node.parent;
2668
- while (parent) {
2669
- parents.push(parent);
2670
- parent = parent.parent;
2671
- }
2672
- return parents;
2673
- }
2674
- /** 节点是否处于分组中 */
2675
- static isNodeInGroup(node) {
2676
- if (node?.parent?.flowNodeType === "group" /* GROUP */) {
2677
- return true;
2678
- }
2679
- return false;
2680
- }
2681
- };
2682
-
2683
- // src/services/flow-drag-service.ts
2684
- var FlowDragService = class {
2685
- constructor() {
2686
- this.onDropEmitter = new Emitter7();
2687
- this.onDrop = this.onDropEmitter.event;
2688
- }
2689
- get renderState() {
2690
- return this.document.renderState;
2691
- }
2692
- // 拖拽所有节点中的首个节点
2693
- get dragStartNode() {
2694
- return this.renderState.getDragStartEntity();
2695
- }
2696
- // 拖拽的所有节点
2697
- get dragNodes() {
2698
- return this.renderState.getDragEntities();
2699
- }
2700
- // 放置的区域
2701
- get dropNodeId() {
2702
- return this.renderState.getNodeDroppingId();
2703
- }
2704
- // 是否在拖拽分支
2705
- get isDragBranch() {
2706
- return this.dragStartNode?.isInlineBlock;
2707
- }
2708
- // 拖拽的所有节点及其自节点
2709
- get nodeDragIdsWithChildren() {
2710
- return this.renderState.config.nodeDragIdsWithChildren || [];
2711
- }
2712
- get dragging() {
2713
- const renderData = this.dragStartNode?.getData(FlowNodeRenderData);
2714
- return !!renderData?.dragging;
2715
- }
2716
- get labelSide() {
2717
- return this.renderState.config.dragLabelSide;
2718
- }
2719
- /**
2720
- * 放置到目标分支
2721
- */
2722
- dropBranch() {
2723
- this.dropNode();
2724
- }
2725
- /**
2726
- * 移动到目标节点
2727
- */
2728
- dropNode() {
2729
- const dropEntity = this.document.getNode(this.dropNodeId);
2730
- if (!dropEntity) {
2731
- return;
2732
- }
2733
- const sortNodes = [];
2734
- let curr = this.dragStartNode;
2735
- while (curr && this.dragNodes.includes(curr)) {
2736
- sortNodes.push(curr);
2737
- curr = curr.next;
2738
- }
2739
- this.operationService.dragNodes({
2740
- dropNode: dropEntity,
2741
- nodes: sortNodes
2742
- });
2743
- if (sortNodes.length > 0) {
2744
- this.onDropEmitter.fire({
2745
- dropNode: dropEntity,
2746
- dragNodes: sortNodes
2747
- });
2748
- }
2749
- }
2750
- /**
2751
- * 拖拽是否可以释放在该节点后面
2752
- */
2753
- isDroppableNode(node) {
2754
- if (!this.dragging || this.isDragBranch) {
2755
- return false;
2756
- }
2757
- if (this.nodeDragIdsWithChildren.includes(node.id) || node.next && this.nodeDragIdsWithChildren.includes(node.next.id)) {
2758
- return false;
2759
- }
2760
- if (node.isInlineBlocks || node.isInlineBlock) {
2761
- return false;
2762
- }
2763
- const hasGroupNode = this.dragNodes.some((node2) => node2.flowNodeType === "group" /* GROUP */);
2764
- if (hasGroupNode) {
2765
- const group = FlowGroupController.getNodeRecursionGroupController(node);
2766
- if (group) {
2767
- return false;
2768
- }
2769
- }
2770
- return true;
2771
- }
2772
- /**
2773
- * 拖拽分支是否可以释放在该分支
2774
- * @param node 拖拽的分支节点
2775
- * @param side 分支的前面还是后面
2776
- */
2777
- isDroppableBranch(node, side = "normal_branch" /* NORMAL_BRANCH */) {
2778
- if (this.isDragBranch) {
2779
- if (
2780
- // 拖拽到分支
2781
- !node.isInlineBlock || // 只能在同一分支条件下
2782
- node.parent !== this.dragStartNode.parent || // 自己不能拖拽给自己
2783
- node === this.dragStartNode
2784
- ) {
2785
- return false;
2786
- }
2787
- if (side === "normal_branch" /* NORMAL_BRANCH */ && node.next !== this.dragStartNode) {
2788
- return true;
2789
- }
2790
- if (side === "pre_branch" /* PRE_BRANCH */ && node.pre !== this.dragStartNode) {
2791
- return true;
2792
- }
2793
- }
2794
- return false;
2795
- }
2796
- };
2797
- __decorateClass([
2798
- inject5(FlowDocument)
2799
- ], FlowDragService.prototype, "document", 2);
2800
- __decorateClass([
2801
- inject5(FlowOperationBaseService)
2802
- ], FlowDragService.prototype, "operationService", 2);
2803
- __decorateClass([
2804
- inject5(EntityManager4)
2805
- ], FlowDragService.prototype, "entityManager", 2);
2806
- FlowDragService = __decorateClass([
2807
2901
  injectable5()
2808
- ], FlowDragService);
2902
+ ], FlowGroupService);
2809
2903
 
2810
2904
  // src/layout/vertical-fixed-layout.ts
2811
2905
  import { injectable as injectable6, inject as inject6, multiInject as multiInject2, optional as optional3 } from "inversify";
@@ -2836,6 +2930,7 @@ var VerticalFixedLayout = class {
2836
2930
  * @param forceChange
2837
2931
  */
2838
2932
  updateLocalTransform(node, forceChange = false) {
2933
+ var _a, _b, _c, _d;
2839
2934
  const { children, parent, isInlineBlock } = node;
2840
2935
  const transform = node.getData(FlowNodeTransformData);
2841
2936
  const { getDelta, getOrigin } = node.getNodeRegistry();
@@ -2869,9 +2964,9 @@ var VerticalFixedLayout = class {
2869
2964
  origin: getOrigin ? getOrigin(transform, this) : this.getDefaultNodeOrigin()
2870
2965
  });
2871
2966
  const preTransform = transform.pre;
2872
- const delta = getDelta?.(transform, this) || { x: 0, y: 0 };
2873
- const inlineSpacingPre = isInlineBlock && transform.parent?.inlineSpacingPre ? transform.parent?.inlineSpacingPre : 0;
2874
- const fromParentDelta = parent?.getNodeRegistry().getChildDelta?.(transform, this) || {
2967
+ const delta = (getDelta == null ? void 0 : getDelta(transform, this)) || { x: 0, y: 0 };
2968
+ const inlineSpacingPre = isInlineBlock && ((_a = transform.parent) == null ? void 0 : _a.inlineSpacingPre) ? (_b = transform.parent) == null ? void 0 : _b.inlineSpacingPre : 0;
2969
+ const fromParentDelta = ((_d = parent == null ? void 0 : (_c = parent.getNodeRegistry()).getChildDelta) == null ? void 0 : _d.call(_c, transform, this)) || {
2875
2970
  x: 0,
2876
2971
  y: 0
2877
2972
  };
@@ -2881,8 +2976,8 @@ var VerticalFixedLayout = class {
2881
2976
  if (isInlineBlock) {
2882
2977
  position.y += inlineSpacingPre;
2883
2978
  } else {
2884
- position.y += preTransform?.localBounds.bottom || 0;
2885
- position.y += preTransform?.spacing || 0;
2979
+ position.y += (preTransform == null ? void 0 : preTransform.localBounds.bottom) || 0;
2980
+ position.y += (preTransform == null ? void 0 : preTransform.spacing) || 0;
2886
2981
  }
2887
2982
  transform.transform.update({
2888
2983
  size: transform.data.size,
@@ -2893,10 +2988,12 @@ var VerticalFixedLayout = class {
2893
2988
  return true;
2894
2989
  }
2895
2990
  onAfterUpdateLocalTransform(transform) {
2991
+ var _a;
2896
2992
  const { onAfterUpdateLocalTransform } = transform.entity.getNodeRegistry();
2897
- onAfterUpdateLocalTransform?.(transform, this);
2898
- this.contribs?.forEach((_contrib) => {
2899
- _contrib?.onAfterUpdateLocalTransform?.(transform, this);
2993
+ onAfterUpdateLocalTransform == null ? void 0 : onAfterUpdateLocalTransform(transform, this);
2994
+ (_a = this.contribs) == null ? void 0 : _a.forEach((_contrib) => {
2995
+ var _a2;
2996
+ (_a2 = _contrib == null ? void 0 : _contrib.onAfterUpdateLocalTransform) == null ? void 0 : _a2.call(_contrib, transform, this);
2900
2997
  });
2901
2998
  }
2902
2999
  getNodeTransform(node) {
@@ -2973,6 +3070,7 @@ var HorizontalFixedLayout = class {
2973
3070
  * @param forceChange
2974
3071
  */
2975
3072
  updateLocalTransform(node, forceChange = false) {
3073
+ var _a, _b, _c, _d;
2976
3074
  const { children, parent, isInlineBlock } = node;
2977
3075
  const transform = node.getData(FlowNodeTransformData);
2978
3076
  const { getDelta, getOrigin } = node.getNodeRegistry();
@@ -3006,9 +3104,9 @@ var HorizontalFixedLayout = class {
3006
3104
  origin: getOrigin ? getOrigin(transform, this) : this.getDefaultNodeOrigin()
3007
3105
  });
3008
3106
  const preTransform = transform.pre;
3009
- const delta = getDelta?.(transform, this) || { x: 0, y: 0 };
3010
- const inlineSpacingPre = isInlineBlock && transform.parent?.inlineSpacingPre ? transform.parent?.inlineSpacingPre : 0;
3011
- const fromParentDelta = parent?.getNodeRegistry().getChildDelta?.(transform, this) || {
3107
+ const delta = (getDelta == null ? void 0 : getDelta(transform, this)) || { x: 0, y: 0 };
3108
+ const inlineSpacingPre = isInlineBlock && ((_a = transform.parent) == null ? void 0 : _a.inlineSpacingPre) ? (_b = transform.parent) == null ? void 0 : _b.inlineSpacingPre : 0;
3109
+ const fromParentDelta = ((_d = parent == null ? void 0 : (_c = parent.getNodeRegistry()).getChildDelta) == null ? void 0 : _d.call(_c, transform, this)) || {
3012
3110
  x: 0,
3013
3111
  y: 0
3014
3112
  };
@@ -3018,8 +3116,8 @@ var HorizontalFixedLayout = class {
3018
3116
  if (isInlineBlock) {
3019
3117
  position.x += inlineSpacingPre;
3020
3118
  } else {
3021
- position.x += preTransform?.localBounds.right || 0;
3022
- position.x += preTransform?.spacing || 0;
3119
+ position.x += (preTransform == null ? void 0 : preTransform.localBounds.right) || 0;
3120
+ position.x += (preTransform == null ? void 0 : preTransform.spacing) || 0;
3023
3121
  }
3024
3122
  transform.transform.update({
3025
3123
  size: transform.data.size,
@@ -3030,10 +3128,12 @@ var HorizontalFixedLayout = class {
3030
3128
  return true;
3031
3129
  }
3032
3130
  onAfterUpdateLocalTransform(transform) {
3131
+ var _a;
3033
3132
  const { onAfterUpdateLocalTransform } = transform.entity.getNodeRegistry();
3034
- onAfterUpdateLocalTransform?.(transform, this);
3035
- this.contribs?.forEach((_contrib) => {
3036
- _contrib?.onAfterUpdateLocalTransform?.(transform, this);
3133
+ onAfterUpdateLocalTransform == null ? void 0 : onAfterUpdateLocalTransform(transform, this);
3134
+ (_a = this.contribs) == null ? void 0 : _a.forEach((_contrib) => {
3135
+ var _a2;
3136
+ (_a2 = _contrib == null ? void 0 : _contrib.onAfterUpdateLocalTransform) == null ? void 0 : _a2.call(_contrib, transform, this);
3037
3137
  });
3038
3138
  }
3039
3139
  getNodeTransform(node) {
@@ -3101,8 +3201,9 @@ var FlowDocumentContainerModule = new ContainerModule((bind) => {
3101
3201
 
3102
3202
  // src/utils/get-default-spacing.ts
3103
3203
  var getDefaultSpacing = (node, key, defaultSpacing) => {
3204
+ var _a;
3104
3205
  const flowDocumentOptions = node.getService(FlowDocumentOptions);
3105
- const spacing = flowDocumentOptions?.constants?.[key] || defaultSpacing || DEFAULT_SPACING[key];
3206
+ const spacing = ((_a = flowDocumentOptions == null ? void 0 : flowDocumentOptions.constants) == null ? void 0 : _a[key]) || defaultSpacing || DEFAULT_SPACING[key];
3106
3207
  return spacing;
3107
3208
  };
3108
3209
  export {