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

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
@@ -317,7 +317,6 @@ var _FlowNodeRenderData = class _FlowNodeRenderData extends EntityData {
317
317
  this.expanded = !this.expanded;
318
318
  }
319
319
  toggleMouseEnter(silent = false) {
320
- var _a;
321
320
  this.entity.document.renderState.setNodeHovered(this.entity);
322
321
  if (silent) return;
323
322
  const transform = this.entity.getData(FlowNodeTransformData);
@@ -329,7 +328,7 @@ var _FlowNodeRenderData = class _FlowNodeRenderData extends EntityData {
329
328
  this.mouseLeaveTimeout = void 0;
330
329
  }
331
330
  transform.renderState.hovered = true;
332
- if (this.entity.isFirst && ((_a = this.entity.parent) == null ? void 0 : _a.id) !== "root") {
331
+ if (this.entity.isFirst && this.entity.parent?.id !== "root") {
333
332
  transform.parent.renderState.activated = true;
334
333
  } else {
335
334
  transform.renderState.activated = true;
@@ -340,9 +339,8 @@ var _FlowNodeRenderData = class _FlowNodeRenderData extends EntityData {
340
339
  if (silent) return;
341
340
  const transform = this.entity.getData(FlowNodeTransformData);
342
341
  this.mouseLeaveTimeout = setTimeout(() => {
343
- var _a;
344
342
  transform.renderState.hovered = false;
345
- if (this.entity.isFirst && ((_a = this.entity.parent) == null ? void 0 : _a.id) !== "root") {
343
+ if (this.entity.isFirst && this.entity.parent?.id !== "root") {
346
344
  transform.parent.renderState.activated = false;
347
345
  }
348
346
  transform.renderState.activated = false;
@@ -391,11 +389,10 @@ var _FlowNodeRenderData = class _FlowNodeRenderData extends EntityData {
391
389
  this.data.stackIndex = index;
392
390
  }
393
391
  get lineActivated() {
394
- var _a, _b, _c;
395
392
  const { activated } = this;
396
393
  if (!activated) return false;
397
394
  return Boolean(
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)
395
+ this.entity.parent?.getData(_FlowNodeRenderData)?.activated || this.entity.isInlineBlock || this.entity.next?.getData(_FlowNodeRenderData).activated
399
396
  );
400
397
  }
401
398
  get node() {
@@ -599,10 +596,10 @@ var _FlowNodeTransformData = class _FlowNodeTransformData extends EntityData2 {
599
596
  return this.entity.document.layout.getPadding(this.entity);
600
597
  }
601
598
  setParentTransform(transform) {
602
- if (this.transform.parent !== (transform == null ? void 0 : transform.transform)) {
599
+ if (this.transform.parent !== transform?.transform) {
603
600
  this.localDirty = true;
604
601
  }
605
- this.transform.setParent(transform == null ? void 0 : transform.transform);
602
+ this.transform.setParent(transform?.transform);
606
603
  }
607
604
  get spacing() {
608
605
  const { spacing } = this.entity.getNodeMeta();
@@ -629,12 +626,10 @@ var _FlowNodeTransformData = class _FlowNodeTransformData extends EntityData2 {
629
626
  * 上一个节点的 transform 数据
630
627
  */
631
628
  get pre() {
632
- var _a;
633
- return (_a = this.entity.pre) == null ? void 0 : _a.getData(_FlowNodeTransformData);
629
+ return this.entity.pre?.getData(_FlowNodeTransformData);
634
630
  }
635
631
  get originParent() {
636
- var _a;
637
- return (_a = this.entity.originParent) == null ? void 0 : _a.getData(_FlowNodeTransformData);
632
+ return this.entity.originParent?.getData(_FlowNodeTransformData);
638
633
  }
639
634
  get isFirst() {
640
635
  return this.entity.isFirst;
@@ -643,26 +638,22 @@ var _FlowNodeTransformData = class _FlowNodeTransformData extends EntityData2 {
643
638
  return this.entity.isLast;
644
639
  }
645
640
  get lastChild() {
646
- var _a;
647
- return (_a = this.entity.lastChild) == null ? void 0 : _a.getData(_FlowNodeTransformData);
641
+ return this.entity.lastChild?.getData(_FlowNodeTransformData);
648
642
  }
649
643
  get firstChild() {
650
- var _a;
651
- return (_a = this.entity.firstChild) == null ? void 0 : _a.getData(_FlowNodeTransformData);
644
+ return this.entity.firstChild?.getData(_FlowNodeTransformData);
652
645
  }
653
646
  /**
654
647
  * 下一个节点的 transform 数据
655
648
  */
656
649
  get next() {
657
- var _a;
658
- return (_a = this.entity.next) == null ? void 0 : _a.getData(_FlowNodeTransformData);
650
+ return this.entity.next?.getData(_FlowNodeTransformData);
659
651
  }
660
652
  /**
661
653
  * parent 节点的 transform 数据
662
654
  */
663
655
  get parent() {
664
- var _a;
665
- return (_a = this.entity.parent) == null ? void 0 : _a.getData(_FlowNodeTransformData);
656
+ return this.entity.parent?.getData(_FlowNodeTransformData);
666
657
  }
667
658
  };
668
659
  _FlowNodeTransformData.type = "FlowNodeTransformData";
@@ -686,10 +677,9 @@ var drawLineToNext = (transition) => {
686
677
  return [];
687
678
  };
688
679
  var drawLineToBottom = (transition) => {
689
- var _a;
690
680
  const { transform } = transition;
691
681
  const currentOutput = transform.outputPoint;
692
- const parentOutput = (_a = transform.parent) == null ? void 0 : _a.outputPoint;
682
+ const parentOutput = transform.parent?.outputPoint;
693
683
  if (!transform.next && parentOutput && !new Point().copyFrom(currentOutput).equals(parentOutput) && !transition.isNodeEnd) {
694
684
  return [
695
685
  {
@@ -706,23 +696,20 @@ var FlowNodeTransitionData = class extends EntityData3 {
706
696
  return {};
707
697
  }
708
698
  formatLines(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);
699
+ if (this.entity.document.options?.formatNodeLines) {
700
+ return this.entity.document.options?.formatNodeLines?.(this.entity, lines);
712
701
  }
713
702
  return lines;
714
703
  }
715
704
  formatLabels(labels) {
716
- var _a, _b;
717
705
  if (this.entity.document.options.formatNodeLabels) {
718
- return (_b = (_a = this.entity.document.options) == null ? void 0 : _a.formatNodeLabels) == null ? void 0 : _b.call(_a, this.entity, labels);
706
+ return this.entity.document.options?.formatNodeLabels?.(this.entity, labels);
719
707
  }
720
708
  return labels;
721
709
  }
722
710
  get lines() {
723
711
  return this.entity.memoGlobal("lines", () => {
724
- var _a;
725
- const { getChildLines } = ((_a = this.entity.parent) == null ? void 0 : _a.getNodeRegistry()) || {};
712
+ const { getChildLines } = this.entity.parent?.getNodeRegistry() || {};
726
713
  if (getChildLines) {
727
714
  return this.formatLines(getChildLines(this, this.entity.document.layout));
728
715
  }
@@ -738,8 +725,7 @@ var FlowNodeTransitionData = class extends EntityData3 {
738
725
  }
739
726
  get labels() {
740
727
  return this.entity.memoGlobal("labels", () => {
741
- var _a, _b;
742
- const { getChildLabels } = ((_a = this.entity.parent) == null ? void 0 : _a.getNodeRegistry()) || {};
728
+ const { getChildLabels } = this.entity.parent?.getNodeRegistry() || {};
743
729
  if (getChildLabels) {
744
730
  return this.formatLabels(getChildLabels(this, this.entity.document.layout));
745
731
  }
@@ -759,7 +745,7 @@ var FlowNodeTransitionData = class extends EntityData3 {
759
745
  }
760
746
  ]);
761
747
  }
762
- const parentOutput = (_b = this.transform.parent) == null ? void 0 : _b.outputPoint;
748
+ const parentOutput = this.transform.parent?.outputPoint;
763
749
  if (parentOutput && !new Point().copyFrom(currentOutput).equals(parentOutput) && !this.isNodeEnd) {
764
750
  return this.formatLabels([
765
751
  {
@@ -1006,9 +992,8 @@ var FlowNodeEntity = class extends Entity {
1006
992
  return this.children.length;
1007
993
  }
1008
994
  get collapsed() {
1009
- var _a;
1010
995
  if (this.document.renderTree.isCollapsed(this)) return true;
1011
- return !!((_a = this.parent) == null ? void 0 : _a.collapsed);
996
+ return !!this.parent?.collapsed;
1012
997
  }
1013
998
  set collapsed(collapsed) {
1014
999
  this.document.renderTree.setCollapsed(this, collapsed);
@@ -1209,7 +1194,7 @@ var FlowRendererStateEntity = class extends ConfigEntity2 {
1209
1194
  }
1210
1195
  setNodeHovered(node) {
1211
1196
  this.updateConfig({
1212
- nodeHoveredId: node == null ? void 0 : node.id
1197
+ nodeHoveredId: node?.id
1213
1198
  });
1214
1199
  }
1215
1200
  getDragLabelSide() {
@@ -1234,7 +1219,7 @@ var FlowRendererStateEntity = class extends ConfigEntity2 {
1234
1219
  }
1235
1220
  setDragStartEntity(node) {
1236
1221
  this.updateConfig({
1237
- nodeDragStartId: node == null ? void 0 : node.id
1222
+ nodeDragStartId: node?.id
1238
1223
  });
1239
1224
  }
1240
1225
  // 拖拽多个节点时
@@ -1336,7 +1321,7 @@ var FlowVirtualTree = class _FlowVirtualTree {
1336
1321
  moveChilds(parent, childs, index) {
1337
1322
  const parentInfo = this.getInfo(parent);
1338
1323
  const len = parentInfo.children.length;
1339
- let childIndex = index != null ? index : len;
1324
+ let childIndex = index ?? len;
1340
1325
  childs.forEach((child) => {
1341
1326
  const childInfo = this.getInfo(child);
1342
1327
  if (childInfo.parent) {
@@ -1486,8 +1471,7 @@ var FlowRenderTree = class extends FlowVirtualTree {
1486
1471
  *
1487
1472
  */
1488
1473
  openNodeInsideCollapsed(node) {
1489
- var _a;
1490
- let curr = (_a = this.originTree.getInfo(node)) == null ? void 0 : _a.parent;
1474
+ let curr = this.originTree.getInfo(node)?.parent;
1491
1475
  while (curr) {
1492
1476
  if (this.nodesCollapsed.has(curr)) {
1493
1477
  this.nodesCollapsed.delete(curr);
@@ -1559,7 +1543,7 @@ var FlowRenderTree = class extends FlowVirtualTree {
1559
1543
  if (shouldDragAllNextNodes && next) {
1560
1544
  this.dragNextNodesToBlock(passBlocks[0], next);
1561
1545
  }
1562
- children == null ? void 0 : children.forEach((child) => {
1546
+ children?.forEach((child) => {
1563
1547
  this.refineBranch(child);
1564
1548
  });
1565
1549
  if (shouldDragAllNextNodes) {
@@ -1718,13 +1702,9 @@ var FlowDocument = class {
1718
1702
  return this._disposed;
1719
1703
  }
1720
1704
  init() {
1721
- var _a, _b;
1722
1705
  if (!this.options) this.options = FlowDocumentOptionsDefault;
1723
1706
  this.currentLayoutKey = this.options.defaultLayout || "vertical-fixed-layout" /* VERTICAL_FIXED_LAYOUT */;
1724
- this.contributions.forEach((contrib) => {
1725
- var _a2;
1726
- return (_a2 = contrib.registerDocument) == null ? void 0 : _a2.call(contrib, this);
1727
- });
1707
+ this.contributions.forEach((contrib) => contrib.registerDocument?.(this));
1728
1708
  this.root = this.addNode({ id: "root", type: "root" /* ROOT */ });
1729
1709
  this.originTree = new FlowVirtualTree(this.root);
1730
1710
  this.transformer = this.entityManager.createEntity(
@@ -1733,7 +1713,7 @@ var FlowDocument = class {
1733
1713
  );
1734
1714
  this.renderState = this.entityManager.createEntity(FlowRendererStateEntity);
1735
1715
  this.renderTree = new FlowRenderTree(this.root, this.originTree, this);
1736
- (_b = (_a = this.layout).reload) == null ? void 0 : _b.call(_a);
1716
+ this.layout.reload?.();
1737
1717
  }
1738
1718
  /**
1739
1719
  * 从数据初始化 O(n)
@@ -1769,10 +1749,7 @@ var FlowDocument = class {
1769
1749
  return layout;
1770
1750
  }
1771
1751
  async load() {
1772
- await Promise.all(this.contributions.map((c) => {
1773
- var _a;
1774
- return (_a = c.loadDocument) == null ? void 0 : _a.call(c, this);
1775
- }));
1752
+ await Promise.all(this.contributions.map((c) => c.loadDocument?.(this)));
1776
1753
  }
1777
1754
  get loading() {
1778
1755
  return this.transformer.loading;
@@ -1806,9 +1783,8 @@ var FlowDocument = class {
1806
1783
  return result;
1807
1784
  }
1808
1785
  removeNode(node) {
1809
- var _a;
1810
1786
  if (typeof node === "string") {
1811
- (_a = this.getNode(node)) == null ? void 0 : _a.dispose();
1787
+ this.getNode(node)?.dispose();
1812
1788
  } else {
1813
1789
  node.dispose();
1814
1790
  }
@@ -1818,8 +1794,7 @@ var FlowDocument = class {
1818
1794
  * @param data
1819
1795
  * @param addedNodes
1820
1796
  */
1821
- addNode(data, addedNodes, ignoreCreateAndUpdateEvent, ignoreBlocks) {
1822
- var _a, _b, _c, _d;
1797
+ addNode(data, addedNodes) {
1823
1798
  const { id, type = "block", originParent, parent, meta, hidden, index } = data;
1824
1799
  let node = this.getNode(id);
1825
1800
  let isNew = false;
@@ -1840,10 +1815,10 @@ var FlowDocument = class {
1840
1815
  const datas = dataRegistries ? this.nodeDataRegistries.concat(...dataRegistries) : this.nodeDataRegistries;
1841
1816
  node.addInitializeData(datas);
1842
1817
  node.onDispose(() => this.onNodeDisposeEmitter.fire({ node }));
1843
- (_b = (_a = this.options).fromNodeJSON) == null ? void 0 : _b.call(_a, node, data, true);
1818
+ this.options.fromNodeJSON?.(node, data, true);
1844
1819
  isNew = true;
1845
1820
  } else {
1846
- (_d = (_c = this.options).fromNodeJSON) == null ? void 0 : _d.call(_c, node, data, false);
1821
+ this.options.fromNodeJSON?.(node, data, false);
1847
1822
  }
1848
1823
  node.initData({
1849
1824
  originParent,
@@ -1855,29 +1830,27 @@ var FlowDocument = class {
1855
1830
  if (node.isStart) {
1856
1831
  this.root.addChild(node);
1857
1832
  }
1858
- addedNodes == null ? void 0 : addedNodes.push(node);
1833
+ addedNodes?.push(node);
1859
1834
  if (register.onCreate) {
1860
1835
  const extendNodes = register.onCreate(node, data);
1861
1836
  if (extendNodes && addedNodes) {
1862
1837
  addedNodes.push(...extendNodes);
1863
1838
  }
1864
- } else if (data.blocks && data.blocks.length > 0 && !ignoreBlocks) {
1839
+ } else if (data.blocks && data.blocks.length > 0) {
1865
1840
  if (!data.blocks[0].type) {
1866
1841
  this.addInlineBlocks(node, data.blocks, addedNodes);
1867
1842
  } else {
1868
1843
  this.addBlocksAsChildren(node, data.blocks, addedNodes);
1869
1844
  }
1870
1845
  }
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
- }
1846
+ if (isNew) {
1847
+ this.onNodeCreateEmitter.fire({
1848
+ node,
1849
+ data,
1850
+ json: data
1851
+ });
1852
+ } else {
1853
+ this.onNodeUpdateEmitter.fire({ node, data, json: data });
1881
1854
  }
1882
1855
  return node;
1883
1856
  }
@@ -1933,7 +1906,6 @@ var FlowDocument = class {
1933
1906
  * @param parent 默认去找 $inlineBlocks$
1934
1907
  */
1935
1908
  addBlock(target, blockData, addedNodes, parent, index) {
1936
- var _a;
1937
1909
  const node = typeof target === "string" ? this.getNode(target) : target;
1938
1910
  const { onBlockChildCreate } = node.getNodeRegistry();
1939
1911
  if (onBlockChildCreate) {
@@ -1947,7 +1919,7 @@ var FlowDocument = class {
1947
1919
  parent,
1948
1920
  index
1949
1921
  });
1950
- if ((_a = blockData.meta) == null ? void 0 : _a.defaultCollapsed) {
1922
+ if (blockData.meta?.defaultCollapsed) {
1951
1923
  block.collapsed = true;
1952
1924
  }
1953
1925
  const blockOrderIcon = this.addNode({
@@ -1958,7 +1930,7 @@ var FlowDocument = class {
1958
1930
  data: blockData.data,
1959
1931
  parent: block
1960
1932
  });
1961
- addedNodes == null ? void 0 : addedNodes.push(block, blockOrderIcon);
1933
+ addedNodes?.push(block, blockOrderIcon);
1962
1934
  if (blockData.blocks) {
1963
1935
  this.addBlocksAsChildren(block, blockData.blocks, addedNodes);
1964
1936
  }
@@ -1986,12 +1958,12 @@ var FlowDocument = class {
1986
1958
  ...preRegistry,
1987
1959
  ...newRegistry,
1988
1960
  meta: {
1989
- ...preRegistry == null ? void 0 : preRegistry.meta,
1990
- ...newRegistry == null ? void 0 : newRegistry.meta
1961
+ ...preRegistry?.meta,
1962
+ ...newRegistry?.meta
1991
1963
  },
1992
1964
  extendChildRegistries: FlowNodeRegistry.mergeChildRegistries(
1993
- preRegistry == null ? void 0 : preRegistry.extendChildRegistries,
1994
- newRegistry == null ? void 0 : newRegistry.extendChildRegistries
1965
+ preRegistry?.extendChildRegistries,
1966
+ newRegistry?.extendChildRegistries
1995
1967
  )
1996
1968
  });
1997
1969
  });
@@ -2020,12 +1992,11 @@ var FlowDocument = class {
2020
1992
  return this.getNodeRegistry(type, originParent);
2021
1993
  }
2022
1994
  getNodeRegistry(type, originParent) {
2023
- var _a, _b, _c, _d, _e;
2024
- const typeKey = `${type}_${(originParent == null ? void 0 : originParent.flowNodeType) || ""}`;
1995
+ const typeKey = `${type}_${originParent?.flowNodeType || ""}`;
2025
1996
  if (this.nodeRegistryCache.has(typeKey)) {
2026
1997
  return this.nodeRegistryCache.get(typeKey);
2027
1998
  }
2028
- const customDefaultRegistry = (_b = (_a = this.options).getNodeDefaultRegistry) == null ? void 0 : _b.call(_a, type);
1999
+ const customDefaultRegistry = this.options.getNodeDefaultRegistry?.(type);
2029
2000
  let register = this.registers.get(type) || { type };
2030
2001
  const extendRegisters = [];
2031
2002
  const extendKey = register.extend;
@@ -2037,9 +2008,9 @@ var FlowDocument = class {
2037
2008
  );
2038
2009
  }
2039
2010
  if (originParent) {
2040
- const extendRegister = (_c = this.getNodeRegistry(
2011
+ const extendRegister = this.getNodeRegistry(
2041
2012
  originParent.flowNodeType
2042
- ).extendChildRegistries) == null ? void 0 : _c.find((r) => r.type === type);
2013
+ ).extendChildRegistries?.find((r) => r.type === type);
2043
2014
  if (extendRegister) {
2044
2015
  if (extendRegister.extend && this.registers.has(extendRegister.extend)) {
2045
2016
  extendRegisters.push(this.registers.get(extendRegister.extend));
@@ -2049,13 +2020,13 @@ var FlowDocument = class {
2049
2020
  }
2050
2021
  register = FlowNodeRegistry.extend(register, extendRegisters);
2051
2022
  const defaultNodeMeta = DEFAULT_FLOW_NODE_META(type, this);
2052
- defaultNodeMeta.spacing = ((_e = (_d = this.options) == null ? void 0 : _d.constants) == null ? void 0 : _e[ConstantKeys.NODE_SPACING]) || defaultNodeMeta.spacing;
2023
+ defaultNodeMeta.spacing = this.options?.constants?.[ConstantKeys.NODE_SPACING] || defaultNodeMeta.spacing;
2053
2024
  const res = {
2054
2025
  ...customDefaultRegistry,
2055
2026
  ...register,
2056
2027
  meta: {
2057
2028
  ...defaultNodeMeta,
2058
- ...customDefaultRegistry == null ? void 0 : customDefaultRegistry.meta,
2029
+ ...customDefaultRegistry?.meta,
2059
2030
  ...register.meta
2060
2031
  }
2061
2032
  };
@@ -2190,13 +2161,12 @@ var FlowDocument = class {
2190
2161
  * @param layoutKey
2191
2162
  */
2192
2163
  setLayout(layoutKey) {
2193
- var _a;
2194
2164
  if (this.currentLayoutKey === layoutKey) return;
2195
2165
  const layout = this.layouts.find((layout2) => layout2.name === layoutKey);
2196
2166
  if (!layout) return;
2197
2167
  this.currentLayoutKey = layoutKey;
2198
2168
  this.transformer.clear();
2199
- (_a = layout.reload) == null ? void 0 : _a.call(layout);
2169
+ layout.reload?.();
2200
2170
  this.fireRender();
2201
2171
  this.onLayoutChangeEmitter.fire(this.layout);
2202
2172
  }
@@ -2311,12 +2281,11 @@ var FlowGroupController = class _FlowGroupController {
2311
2281
  return this.groupNode.getNodeMeta().positionConfig;
2312
2282
  }
2313
2283
  set collapsed(collapsed) {
2314
- var _a;
2315
2284
  const groupTransformData = this.groupNode.getData(FlowNodeTransformData);
2316
2285
  groupTransformData.collapsed = collapsed;
2317
2286
  groupTransformData.localDirty = true;
2318
2287
  if (groupTransformData.parent) groupTransformData.parent.localDirty = true;
2319
- if ((_a = groupTransformData.parent) == null ? void 0 : _a.firstChild)
2288
+ if (groupTransformData.parent?.firstChild)
2320
2289
  groupTransformData.parent.firstChild.localDirty = true;
2321
2290
  }
2322
2291
  set hovered(hovered) {
@@ -2359,8 +2328,7 @@ var FlowGroupUtils;
2359
2328
  return parents;
2360
2329
  };
2361
2330
  const isNodeInGroup = (node) => {
2362
- var _a;
2363
- if (((_a = node == null ? void 0 : node.parent) == null ? void 0 : _a.flowNodeType) === "group" /* GROUP */) {
2331
+ if (node?.parent?.flowNodeType === "group" /* GROUP */) {
2364
2332
  return true;
2365
2333
  }
2366
2334
  return false;
@@ -2396,7 +2364,7 @@ var FlowGroupUtils;
2396
2364
  if (!isNodeInGroup(node)) {
2397
2365
  return;
2398
2366
  }
2399
- const groupNode = node == null ? void 0 : node.parent;
2367
+ const groupNode = node?.parent;
2400
2368
  return FlowGroupController.create(groupNode);
2401
2369
  };
2402
2370
  FlowGroupUtils2.getNodeRecursionGroupController = (node) => {
@@ -2438,17 +2406,15 @@ var FlowDragService = class {
2438
2406
  }
2439
2407
  // 是否在拖拽分支
2440
2408
  get isDragBranch() {
2441
- var _a;
2442
- return (_a = this.dragStartNode) == null ? void 0 : _a.isInlineBlock;
2409
+ return this.dragStartNode?.isInlineBlock;
2443
2410
  }
2444
2411
  // 拖拽的所有节点及其自节点
2445
2412
  get nodeDragIdsWithChildren() {
2446
2413
  return this.renderState.config.nodeDragIdsWithChildren || [];
2447
2414
  }
2448
2415
  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);
2416
+ const renderData = this.dragStartNode?.getData(FlowNodeRenderData);
2417
+ return !!renderData?.dragging;
2452
2418
  }
2453
2419
  get labelSide() {
2454
2420
  return this.renderState.config.dragLabelSide;
@@ -2582,7 +2548,7 @@ var FlowOperationBaseServiceImpl = class {
2582
2548
  hidden
2583
2549
  };
2584
2550
  let added;
2585
- if (parentEntity && (register == null ? void 0 : register.addChild)) {
2551
+ if (parentEntity && register?.addChild) {
2586
2552
  added = register.addChild(parentEntity, addJSON, {
2587
2553
  index,
2588
2554
  hidden
@@ -2614,7 +2580,7 @@ var FlowOperationBaseServiceImpl = class {
2614
2580
  moveNode(node, config = {}) {
2615
2581
  const { parent: newParent, index } = config;
2616
2582
  const entity = this.toNodeEntity(node);
2617
- const parent = entity == null ? void 0 : entity.parent;
2583
+ const parent = entity?.parent;
2618
2584
  if (!parent) {
2619
2585
  return;
2620
2586
  }
@@ -2665,13 +2631,12 @@ var FlowOperationBaseServiceImpl = class {
2665
2631
  * @returns 操作返回
2666
2632
  */
2667
2633
  apply(operation) {
2668
- var _a, _b, _c, _d, _e, _f;
2669
2634
  const document = this.document;
2670
2635
  switch (operation.type) {
2671
2636
  case "addFromNode" /* addFromNode */:
2672
2637
  return document.addFromNode(operation.value.fromId, operation.value.data);
2673
2638
  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();
2639
+ return document.getNode(operation.value?.data?.id)?.dispose();
2675
2640
  case "addBlock" /* addBlock */: {
2676
2641
  let parent;
2677
2642
  if (operation.value.parentId) {
@@ -2686,8 +2651,8 @@ var FlowOperationBaseServiceImpl = class {
2686
2651
  );
2687
2652
  }
2688
2653
  case "deleteBlock" /* deleteBlock */: {
2689
- const entity = document.getNode((_d = operation.value) == null ? void 0 : _d.blockData.id);
2690
- return entity == null ? void 0 : entity.dispose();
2654
+ const entity = document.getNode(operation.value?.blockData.id);
2655
+ return entity?.dispose();
2691
2656
  }
2692
2657
  case "createGroup" /* createGroup */: {
2693
2658
  const groupNode = document.addFromNode(operation.value.targetId, {
@@ -2706,7 +2671,7 @@ var FlowOperationBaseServiceImpl = class {
2706
2671
  dropNodeId: operation.value.groupId,
2707
2672
  sortNodeIds: operation.value.nodeIds
2708
2673
  });
2709
- return (_e = document.getNode(operation.value.groupId)) == null ? void 0 : _e.dispose();
2674
+ return document.getNode(operation.value.groupId)?.dispose();
2710
2675
  }
2711
2676
  case "moveNodes" /* moveNodes */: {
2712
2677
  return document.moveNodes({
@@ -2731,7 +2696,7 @@ var FlowOperationBaseServiceImpl = class {
2731
2696
  case "deleteNodes" /* deleteNodes */: {
2732
2697
  (operation.value.nodes || []).forEach((node) => {
2733
2698
  const entity = document.getNode(node.id);
2734
- entity == null ? void 0 : entity.dispose();
2699
+ entity?.dispose();
2735
2700
  });
2736
2701
  break;
2737
2702
  }
@@ -2745,7 +2710,7 @@ var FlowOperationBaseServiceImpl = class {
2745
2710
  });
2746
2711
  }
2747
2712
  case "deleteChildNode" /* deleteChildNode */:
2748
- return (_f = document.getNode(operation.value.data.id)) == null ? void 0 : _f.dispose();
2713
+ return document.getNode(operation.value.data.id)?.dispose();
2749
2714
  case "moveChildNodes" /* moveChildNodes */:
2750
2715
  return document.moveChildNodes(operation.value);
2751
2716
  default:
@@ -2770,7 +2735,7 @@ var FlowOperationBaseServiceImpl = class {
2770
2735
  }
2771
2736
  getNodeIndex(node) {
2772
2737
  const entity = this.toNodeEntity(node);
2773
- const parent = entity == null ? void 0 : entity.parent;
2738
+ const parent = entity?.parent;
2774
2739
  if (!parent) {
2775
2740
  return -1;
2776
2741
  }
@@ -2930,7 +2895,6 @@ var VerticalFixedLayout = class {
2930
2895
  * @param forceChange
2931
2896
  */
2932
2897
  updateLocalTransform(node, forceChange = false) {
2933
- var _a, _b, _c, _d;
2934
2898
  const { children, parent, isInlineBlock } = node;
2935
2899
  const transform = node.getData(FlowNodeTransformData);
2936
2900
  const { getDelta, getOrigin } = node.getNodeRegistry();
@@ -2964,9 +2928,9 @@ var VerticalFixedLayout = class {
2964
2928
  origin: getOrigin ? getOrigin(transform, this) : this.getDefaultNodeOrigin()
2965
2929
  });
2966
2930
  const preTransform = transform.pre;
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)) || {
2931
+ const delta = getDelta?.(transform, this) || { x: 0, y: 0 };
2932
+ const inlineSpacingPre = isInlineBlock && transform.parent?.inlineSpacingPre ? transform.parent?.inlineSpacingPre : 0;
2933
+ const fromParentDelta = parent?.getNodeRegistry().getChildDelta?.(transform, this) || {
2970
2934
  x: 0,
2971
2935
  y: 0
2972
2936
  };
@@ -2976,8 +2940,8 @@ var VerticalFixedLayout = class {
2976
2940
  if (isInlineBlock) {
2977
2941
  position.y += inlineSpacingPre;
2978
2942
  } else {
2979
- position.y += (preTransform == null ? void 0 : preTransform.localBounds.bottom) || 0;
2980
- position.y += (preTransform == null ? void 0 : preTransform.spacing) || 0;
2943
+ position.y += preTransform?.localBounds.bottom || 0;
2944
+ position.y += preTransform?.spacing || 0;
2981
2945
  }
2982
2946
  transform.transform.update({
2983
2947
  size: transform.data.size,
@@ -2988,12 +2952,10 @@ var VerticalFixedLayout = class {
2988
2952
  return true;
2989
2953
  }
2990
2954
  onAfterUpdateLocalTransform(transform) {
2991
- var _a;
2992
2955
  const { onAfterUpdateLocalTransform } = transform.entity.getNodeRegistry();
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);
2956
+ onAfterUpdateLocalTransform?.(transform, this);
2957
+ this.contribs?.forEach((_contrib) => {
2958
+ _contrib?.onAfterUpdateLocalTransform?.(transform, this);
2997
2959
  });
2998
2960
  }
2999
2961
  getNodeTransform(node) {
@@ -3070,7 +3032,6 @@ var HorizontalFixedLayout = class {
3070
3032
  * @param forceChange
3071
3033
  */
3072
3034
  updateLocalTransform(node, forceChange = false) {
3073
- var _a, _b, _c, _d;
3074
3035
  const { children, parent, isInlineBlock } = node;
3075
3036
  const transform = node.getData(FlowNodeTransformData);
3076
3037
  const { getDelta, getOrigin } = node.getNodeRegistry();
@@ -3104,9 +3065,9 @@ var HorizontalFixedLayout = class {
3104
3065
  origin: getOrigin ? getOrigin(transform, this) : this.getDefaultNodeOrigin()
3105
3066
  });
3106
3067
  const preTransform = transform.pre;
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)) || {
3068
+ const delta = getDelta?.(transform, this) || { x: 0, y: 0 };
3069
+ const inlineSpacingPre = isInlineBlock && transform.parent?.inlineSpacingPre ? transform.parent?.inlineSpacingPre : 0;
3070
+ const fromParentDelta = parent?.getNodeRegistry().getChildDelta?.(transform, this) || {
3110
3071
  x: 0,
3111
3072
  y: 0
3112
3073
  };
@@ -3116,8 +3077,8 @@ var HorizontalFixedLayout = class {
3116
3077
  if (isInlineBlock) {
3117
3078
  position.x += inlineSpacingPre;
3118
3079
  } else {
3119
- position.x += (preTransform == null ? void 0 : preTransform.localBounds.right) || 0;
3120
- position.x += (preTransform == null ? void 0 : preTransform.spacing) || 0;
3080
+ position.x += preTransform?.localBounds.right || 0;
3081
+ position.x += preTransform?.spacing || 0;
3121
3082
  }
3122
3083
  transform.transform.update({
3123
3084
  size: transform.data.size,
@@ -3128,12 +3089,10 @@ var HorizontalFixedLayout = class {
3128
3089
  return true;
3129
3090
  }
3130
3091
  onAfterUpdateLocalTransform(transform) {
3131
- var _a;
3132
3092
  const { onAfterUpdateLocalTransform } = transform.entity.getNodeRegistry();
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);
3093
+ onAfterUpdateLocalTransform?.(transform, this);
3094
+ this.contribs?.forEach((_contrib) => {
3095
+ _contrib?.onAfterUpdateLocalTransform?.(transform, this);
3137
3096
  });
3138
3097
  }
3139
3098
  getNodeTransform(node) {
@@ -3201,9 +3160,8 @@ var FlowDocumentContainerModule = new ContainerModule((bind) => {
3201
3160
 
3202
3161
  // src/utils/get-default-spacing.ts
3203
3162
  var getDefaultSpacing = (node, key, defaultSpacing) => {
3204
- var _a;
3205
3163
  const flowDocumentOptions = node.getService(FlowDocumentOptions);
3206
- const spacing = ((_a = flowDocumentOptions == null ? void 0 : flowDocumentOptions.constants) == null ? void 0 : _a[key]) || defaultSpacing || DEFAULT_SPACING[key];
3164
+ const spacing = flowDocumentOptions?.constants?.[key] || defaultSpacing || DEFAULT_SPACING[key];
3207
3165
  return spacing;
3208
3166
  };
3209
3167
  export {