@flowgram.ai/fixed-layout-core 0.1.29 → 0.1.31

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/index.js CHANGED
@@ -35,15 +35,15 @@ module.exports = __toCommonJS(src_exports);
35
35
 
36
36
  // src/fixed-layout-container-module.ts
37
37
  var import_inversify2 = require("inversify");
38
- var import_renderer7 = require("@flowgram.ai/renderer");
39
- var import_document25 = require("@flowgram.ai/document");
38
+ var import_renderer8 = require("@flowgram.ai/renderer");
39
+ var import_document30 = require("@flowgram.ai/document");
40
40
  var import_core2 = require("@flowgram.ai/core");
41
- var import_utils6 = require("@flowgram.ai/utils");
41
+ var import_utils7 = require("@flowgram.ai/utils");
42
42
 
43
43
  // src/flow-registers.ts
44
44
  var import_inversify = require("inversify");
45
- var import_renderer6 = require("@flowgram.ai/renderer");
46
- var import_document24 = require("@flowgram.ai/document");
45
+ var import_renderer7 = require("@flowgram.ai/renderer");
46
+ var import_document29 = require("@flowgram.ai/document");
47
47
  var import_core = require("@flowgram.ai/core");
48
48
 
49
49
  // src/activities/end.ts
@@ -166,8 +166,8 @@ var BlockRegistry = {
166
166
  const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
167
167
  if (hasBranchDraggingAdder) {
168
168
  if (isVertical) {
169
- const currentOffsetRightX = currentTransform.firstChild?.bounds?.right || 0;
170
- const nextOffsetLeftX = currentTransform.next?.firstChild?.bounds?.left || 0;
169
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
170
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
171
171
  const currentInputPointY = currentTransform.inputPoint.y;
172
172
  if (currentTransform?.next) {
173
173
  lines.push({
@@ -181,8 +181,8 @@ var BlockRegistry = {
181
181
  });
182
182
  }
183
183
  } else {
184
- const currentOffsetRightY = currentTransform.firstChild?.bounds?.bottom || 0;
185
- const nextOffsetLeftY = currentTransform.next?.firstChild?.bounds?.top || 0;
184
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
185
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
186
186
  const currentInputPointX = currentTransform.inputPoint.x;
187
187
  if (currentTransform?.next) {
188
188
  lines.push({
@@ -190,7 +190,7 @@ var BlockRegistry = {
190
190
  from: currentTransform.parent.inputPoint,
191
191
  to: {
192
192
  x: currentInputPointX,
193
- y: (currentOffsetRightY + nextOffsetLeftY) / 2
193
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
194
194
  },
195
195
  side: import_document4.LABEL_SIDE_TYPE.NORMAL_BRANCH
196
196
  });
@@ -232,8 +232,8 @@ var BlockRegistry = {
232
232
  const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
233
233
  if (hasBranchDraggingAdder) {
234
234
  if (isVertical) {
235
- const currentOffsetRightX = currentTransform.firstChild?.bounds?.right || 0;
236
- const nextOffsetLeftX = currentTransform.next?.firstChild?.bounds?.left || 0;
235
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
236
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
237
237
  const currentInputPointY = currentTransform.inputPoint.y;
238
238
  if (currentTransform?.next) {
239
239
  draggingLabel.push({
@@ -249,17 +249,17 @@ var BlockRegistry = {
249
249
  });
250
250
  }
251
251
  } else {
252
- const currentOffsetRightY = currentTransform.firstChild?.bounds?.bottom || 0;
253
- const nextOffsetLeftY = currentTransform.next?.firstChild?.bounds?.top || 0;
252
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
253
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
254
254
  const currentInputPointX = currentTransform.inputPoint.x;
255
255
  if (currentTransform?.next) {
256
256
  draggingLabel.push({
257
257
  offset: {
258
258
  x: currentInputPointX,
259
- y: (currentOffsetRightY + nextOffsetLeftY) / 2
259
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
260
260
  },
261
261
  type: import_document4.FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL,
262
- width: nextOffsetLeftY - currentOffsetRightY,
262
+ width: nextOffsetTopX - currentOffsetBottomX,
263
263
  props: {
264
264
  side: import_document4.LABEL_SIDE_TYPE.NORMAL_BRANCH
265
265
  }
@@ -1442,22 +1442,16 @@ var SimpleSplitRegistry = {
1442
1442
  onBlockChildCreate(originParent, blockData, addedNodes = []) {
1443
1443
  const { document } = originParent;
1444
1444
  const parent = document.getNode(`$inlineBlocks$${originParent.id}`);
1445
- const proxyBlock = document.addNode({
1446
- id: `$block$${blockData.id}`,
1447
- type: import_document23.FlowNodeBaseType.BLOCK,
1448
- originParent,
1449
- parent
1450
- });
1451
1445
  const realBlock = document.addNode(
1452
1446
  {
1453
1447
  ...blockData,
1454
1448
  type: blockData.type || import_document23.FlowNodeBaseType.BLOCK,
1455
- parent: proxyBlock
1449
+ parent
1456
1450
  },
1457
1451
  addedNodes
1458
1452
  );
1459
- addedNodes.push(proxyBlock, realBlock);
1460
- return proxyBlock;
1453
+ addedNodes.push(realBlock);
1454
+ return realBlock;
1461
1455
  }
1462
1456
  // addChild(node, json, options = {}) {
1463
1457
  // const { index } = options;
@@ -1466,6 +1460,247 @@ var SimpleSplitRegistry = {
1466
1460
  // }
1467
1461
  };
1468
1462
 
1463
+ // src/activities/break.ts
1464
+ var import_document24 = require("@flowgram.ai/document");
1465
+ var BreakRegistry = {
1466
+ type: import_document24.FlowNodeBaseType.BREAK,
1467
+ extend: import_document24.FlowNodeBaseType.END
1468
+ };
1469
+
1470
+ // src/activities/input.ts
1471
+ var import_document25 = require("@flowgram.ai/document");
1472
+ var InputRegistry = {
1473
+ type: import_document25.FlowNodeBaseType.INPUT,
1474
+ extend: import_document25.FlowNodeBaseType.BLOCK,
1475
+ meta: {
1476
+ hidden: false
1477
+ },
1478
+ getLines(transition, layout) {
1479
+ const currentTransform = transition.transform;
1480
+ const { isVertical } = transition.entity;
1481
+ const lines = [];
1482
+ const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
1483
+ if (hasBranchDraggingAdder) {
1484
+ if (isVertical) {
1485
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
1486
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
1487
+ const currentInputPointY = currentTransform.outputPoint.y;
1488
+ if (currentTransform?.next) {
1489
+ lines.push({
1490
+ type: import_document25.FlowTransitionLineEnum.MERGE_LINE,
1491
+ isDraggingLine: true,
1492
+ from: {
1493
+ x: (currentOffsetRightX + nextOffsetLeftX) / 2,
1494
+ y: currentInputPointY
1495
+ },
1496
+ to: currentTransform.parent.outputPoint,
1497
+ side: import_document25.LABEL_SIDE_TYPE.NORMAL_BRANCH
1498
+ });
1499
+ }
1500
+ } else {
1501
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
1502
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
1503
+ const currentInputPointX = currentTransform.outputPoint.x;
1504
+ if (currentTransform?.next) {
1505
+ lines.push({
1506
+ type: import_document25.FlowTransitionLineEnum.MERGE_LINE,
1507
+ isDraggingLine: true,
1508
+ from: {
1509
+ x: currentInputPointX,
1510
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
1511
+ },
1512
+ to: currentTransform.parent.outputPoint,
1513
+ side: import_document25.LABEL_SIDE_TYPE.NORMAL_BRANCH
1514
+ });
1515
+ }
1516
+ }
1517
+ }
1518
+ if (!transition.isNodeEnd) {
1519
+ lines.push({
1520
+ type: import_document25.FlowTransitionLineEnum.MERGE_LINE,
1521
+ from: currentTransform.outputPoint,
1522
+ to: currentTransform.parent.outputPoint,
1523
+ side: import_document25.LABEL_SIDE_TYPE.NORMAL_BRANCH
1524
+ });
1525
+ }
1526
+ return lines;
1527
+ },
1528
+ getLabels(transition) {
1529
+ const currentTransform = transition.transform;
1530
+ const { isVertical } = transition.entity;
1531
+ const draggingLabel = [];
1532
+ const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
1533
+ if (hasBranchDraggingAdder) {
1534
+ if (isVertical) {
1535
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
1536
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
1537
+ const currentInputPointY = currentTransform.outputPoint.y;
1538
+ if (currentTransform?.next) {
1539
+ draggingLabel.push({
1540
+ offset: {
1541
+ x: (currentOffsetRightX + nextOffsetLeftX) / 2,
1542
+ y: currentInputPointY
1543
+ },
1544
+ type: import_document25.FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL,
1545
+ width: nextOffsetLeftX - currentOffsetRightX,
1546
+ props: {
1547
+ side: import_document25.LABEL_SIDE_TYPE.NORMAL_BRANCH
1548
+ }
1549
+ });
1550
+ }
1551
+ } else {
1552
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
1553
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
1554
+ const currentInputPointX = currentTransform.outputPoint.x;
1555
+ if (currentTransform?.next) {
1556
+ draggingLabel.push({
1557
+ offset: {
1558
+ x: currentInputPointX,
1559
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
1560
+ },
1561
+ type: import_document25.FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL,
1562
+ width: nextOffsetTopX - currentOffsetBottomX,
1563
+ props: {
1564
+ side: import_document25.LABEL_SIDE_TYPE.NORMAL_BRANCH
1565
+ }
1566
+ });
1567
+ }
1568
+ }
1569
+ }
1570
+ return [...draggingLabel];
1571
+ }
1572
+ };
1573
+
1574
+ // src/activities/output.ts
1575
+ var import_document26 = require("@flowgram.ai/document");
1576
+ var OuputRegistry = {
1577
+ type: import_document26.FlowNodeBaseType.OUTPUT,
1578
+ extend: import_document26.FlowNodeBaseType.BLOCK,
1579
+ meta: {
1580
+ hidden: false,
1581
+ isNodeEnd: true
1582
+ }
1583
+ };
1584
+
1585
+ // src/activities/multi-outputs.ts
1586
+ var import_document27 = require("@flowgram.ai/document");
1587
+ var MultiOuputsRegistry = {
1588
+ type: import_document27.FlowNodeBaseType.MULTI_OUTPUTS,
1589
+ extend: import_document27.FlowNodeSplitType.SIMPLE_SPLIT,
1590
+ meta: {
1591
+ isNodeEnd: true
1592
+ },
1593
+ getLines: (transition, layout) => {
1594
+ if (transition.entity.parent?.flowNodeType === import_document27.FlowNodeBaseType.INLINE_BLOCKS) {
1595
+ return BlockRegistry.getLines(transition, layout);
1596
+ }
1597
+ return [];
1598
+ },
1599
+ getLabels: (transition, layout) => [
1600
+ ...DynamicSplitRegistry.getLabels(transition, layout),
1601
+ ...BlockRegistry.getLabels(transition, layout)
1602
+ ],
1603
+ getOutputPoint(transform, layout) {
1604
+ const isVertical = import_document27.FlowLayoutDefault.isVertical(layout);
1605
+ const lastChildOutput = transform.lastChild?.outputPoint;
1606
+ if (isVertical) {
1607
+ return {
1608
+ x: lastChildOutput ? lastChildOutput.x : transform.bounds.center.x,
1609
+ y: transform.bounds.bottom
1610
+ };
1611
+ }
1612
+ return {
1613
+ x: transform.bounds.right,
1614
+ y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
1615
+ };
1616
+ },
1617
+ extendChildRegistries: [
1618
+ {
1619
+ type: import_document27.FlowNodeBaseType.BLOCK_ICON,
1620
+ meta: {
1621
+ // isNodeEnd: true
1622
+ }
1623
+ }
1624
+ ]
1625
+ };
1626
+
1627
+ // src/activities/multi-inputs.ts
1628
+ var import_utils6 = require("@flowgram.ai/utils");
1629
+ var import_renderer6 = require("@flowgram.ai/renderer");
1630
+ var import_document28 = require("@flowgram.ai/document");
1631
+ var MultiInputsRegistry = {
1632
+ type: import_document28.FlowNodeBaseType.MULTI_INPUTS,
1633
+ extend: import_document28.FlowNodeSplitType.SIMPLE_SPLIT,
1634
+ extendChildRegistries: [
1635
+ {
1636
+ type: import_document28.FlowNodeBaseType.BLOCK_ICON,
1637
+ meta: {
1638
+ hidden: true,
1639
+ spacing: 0
1640
+ },
1641
+ getLines() {
1642
+ return [];
1643
+ },
1644
+ getLabels() {
1645
+ return [];
1646
+ }
1647
+ },
1648
+ {
1649
+ type: import_document28.FlowNodeBaseType.INLINE_BLOCKS,
1650
+ meta: {
1651
+ inlineSpacingPre: 0
1652
+ },
1653
+ getLabels(transition) {
1654
+ const isVertical = transition.entity.isVertical;
1655
+ const currentTransform = transition.transform;
1656
+ const spacing = (0, import_document28.getDefaultSpacing)(
1657
+ transition.entity,
1658
+ import_document28.ConstantKeys.INLINE_BLOCKS_PADDING_BOTTOM
1659
+ );
1660
+ if (currentTransform.collapsed || transition.entity.childrenLength === 0) {
1661
+ return [
1662
+ {
1663
+ type: import_document28.FlowTransitionLabelEnum.CUSTOM_LABEL,
1664
+ renderKey: import_renderer6.FlowRendererKey.BRANCH_ADDER,
1665
+ offset: import_utils6.Point.move(
1666
+ currentTransform.outputPoint,
1667
+ isVertical ? { y: spacing } : { x: spacing }
1668
+ ),
1669
+ props: {
1670
+ // 激活状态
1671
+ activated: transition.entity.getData(import_document28.FlowNodeRenderData).activated,
1672
+ transform: currentTransform,
1673
+ // 传给外部使用的 node 信息
1674
+ node: currentTransform.originParent?.entity
1675
+ }
1676
+ }
1677
+ ];
1678
+ }
1679
+ return [
1680
+ {
1681
+ type: import_document28.FlowTransitionLabelEnum.CUSTOM_LABEL,
1682
+ renderKey: import_renderer6.FlowRendererKey.BRANCH_ADDER,
1683
+ offset: import_utils6.Point.move(
1684
+ currentTransform.outputPoint,
1685
+ isVertical ? { y: -spacing / 2 } : { x: -spacing / 2 }
1686
+ ),
1687
+ props: {
1688
+ // 激活状态
1689
+ activated: transition.entity.getData(import_document28.FlowNodeRenderData).activated,
1690
+ transform: currentTransform,
1691
+ // 传给外部使用的 node 信息
1692
+ node: currentTransform.originParent?.entity
1693
+ }
1694
+ }
1695
+ ];
1696
+ }
1697
+ }
1698
+ ],
1699
+ getLabels() {
1700
+ return [];
1701
+ }
1702
+ };
1703
+
1469
1704
  // src/flow-registers.ts
1470
1705
  var FlowRegisters = class {
1471
1706
  /**
@@ -1498,15 +1733,21 @@ var FlowRegisters = class {
1498
1733
  // 结束节点
1499
1734
  LoopRegistry,
1500
1735
  // 循环节点
1501
- EmptyRegistry
1736
+ EmptyRegistry,
1502
1737
  // 占位节点
1738
+ BreakRegistry,
1739
+ // 分支断开
1740
+ MultiOuputsRegistry,
1741
+ MultiInputsRegistry,
1742
+ InputRegistry,
1743
+ OuputRegistry
1503
1744
  );
1504
1745
  document.registerNodeDatas(
1505
- import_document24.FlowNodeRenderData,
1746
+ import_document29.FlowNodeRenderData,
1506
1747
  // 渲染节点相关数据
1507
- import_document24.FlowNodeTransitionData,
1748
+ import_document29.FlowNodeTransitionData,
1508
1749
  // 线条绘制数据
1509
- import_document24.FlowNodeTransformData
1750
+ import_document29.FlowNodeTransformData
1510
1751
  // 坐标计算数据
1511
1752
  );
1512
1753
  }
@@ -1516,19 +1757,19 @@ var FlowRegisters = class {
1516
1757
  */
1517
1758
  registerRenderer(renderer) {
1518
1759
  renderer.registerLayers(
1519
- import_renderer6.FlowNodesTransformLayer,
1760
+ import_renderer7.FlowNodesTransformLayer,
1520
1761
  // 节点位置渲染
1521
- import_renderer6.FlowNodesContentLayer,
1762
+ import_renderer7.FlowNodesContentLayer,
1522
1763
  // 节点内容渲染
1523
- import_renderer6.FlowLinesLayer,
1764
+ import_renderer7.FlowLinesLayer,
1524
1765
  // 线条渲染
1525
- import_renderer6.FlowLabelsLayer,
1766
+ import_renderer7.FlowLabelsLayer,
1526
1767
  // Label 渲染
1527
1768
  import_core.PlaygroundLayer,
1528
1769
  // 画布基础层,提供缩放、手势等能力
1529
- import_renderer6.FlowScrollLimitLayer,
1770
+ import_renderer7.FlowScrollLimitLayer,
1530
1771
  // 控制滚动范围
1531
- import_renderer6.FlowScrollBarLayer
1772
+ import_renderer7.FlowScrollBarLayer
1532
1773
  // 滚动条
1533
1774
  );
1534
1775
  }
@@ -1549,9 +1790,9 @@ FlowRegisters = __decorateClass([
1549
1790
 
1550
1791
  // src/fixed-layout-container-module.ts
1551
1792
  var FixedLayoutContainerModule = new import_inversify2.ContainerModule((bind) => {
1552
- (0, import_utils6.bindContributions)(bind, FlowRegisters, [
1553
- import_document25.FlowDocumentContribution,
1554
- import_renderer7.FlowRendererContribution,
1793
+ (0, import_utils7.bindContributions)(bind, FlowRegisters, [
1794
+ import_document30.FlowDocumentContribution,
1795
+ import_renderer8.FlowRendererContribution,
1555
1796
  import_core2.PlaygroundContribution
1556
1797
  ]);
1557
1798
  });