@flowgram.ai/fixed-layout-core 0.2.23 → 0.2.25
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 +524 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +530 -17
- package/dist/index.js.map +1 -1
- package/package.json +9 -7
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ declare const FixedLayoutRegistries: {
|
|
|
21
21
|
RootRegistry: _flowgram_ai_document.FlowNodeRegistry<_flowgram_ai_document.FlowNodeMeta>;
|
|
22
22
|
InlineBlocksRegistry: _flowgram_ai_document.FlowNodeRegistry<_flowgram_ai_document.FlowNodeMeta>;
|
|
23
23
|
EndRegistry: _flowgram_ai_document.FlowNodeRegistry<_flowgram_ai_document.FlowNodeMeta>;
|
|
24
|
+
SlotRegistry: _flowgram_ai_document.FlowNodeRegistry<_flowgram_ai_document.FlowNodeMeta>;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export { FixedLayoutContainerModule, FixedLayoutRegistries };
|
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
|
|
39
|
-
var
|
|
38
|
+
var import_renderer9 = require("@flowgram.ai/renderer");
|
|
39
|
+
var import_document39 = require("@flowgram.ai/document");
|
|
40
40
|
var import_core2 = require("@flowgram.ai/core");
|
|
41
|
-
var
|
|
41
|
+
var import_utils8 = require("@flowgram.ai/utils");
|
|
42
42
|
|
|
43
43
|
// src/flow-registers.ts
|
|
44
44
|
var import_inversify = require("inversify");
|
|
45
|
-
var
|
|
46
|
-
var
|
|
45
|
+
var import_renderer8 = require("@flowgram.ai/renderer");
|
|
46
|
+
var import_document38 = require("@flowgram.ai/document");
|
|
47
47
|
var import_core = require("@flowgram.ai/core");
|
|
48
48
|
|
|
49
49
|
// src/activities/end.ts
|
|
@@ -1710,6 +1710,516 @@ var MultiInputsRegistry = {
|
|
|
1710
1710
|
}
|
|
1711
1711
|
};
|
|
1712
1712
|
|
|
1713
|
+
// src/activities/slot/slot.ts
|
|
1714
|
+
var import_document37 = require("@flowgram.ai/document");
|
|
1715
|
+
|
|
1716
|
+
// src/activities/slot/utils/transition.ts
|
|
1717
|
+
var import_utils7 = require("@flowgram.ai/utils");
|
|
1718
|
+
var import_document30 = require("@flowgram.ai/document");
|
|
1719
|
+
|
|
1720
|
+
// src/activities/slot/constants.ts
|
|
1721
|
+
var import_renderer7 = require("@flowgram.ai/renderer");
|
|
1722
|
+
var RENDER_SLOT_ADDER_KEY = import_renderer7.FlowRendererKey.SLOT_ADDER;
|
|
1723
|
+
var RENDER_SLOT_COLLAPSE_KEY = import_renderer7.FlowRendererKey.SLOT_COLLPASE;
|
|
1724
|
+
var SLOT_BLOCK_DISTANCE = 60;
|
|
1725
|
+
var SLOT_COLLAPSE_MARGIN = 20;
|
|
1726
|
+
var SLOT_SPACING = 32;
|
|
1727
|
+
var SLOT_NODE_LAST_SPACING = 10;
|
|
1728
|
+
var SLOT_INLINE_BLOCKS_DELTA = SLOT_COLLAPSE_MARGIN + SLOT_BLOCK_DISTANCE * 2;
|
|
1729
|
+
|
|
1730
|
+
// src/activities/slot/typings.ts
|
|
1731
|
+
var import_document29 = require("@flowgram.ai/document");
|
|
1732
|
+
var SlotNodeType = ((SlotNodeType2) => {
|
|
1733
|
+
SlotNodeType2[SlotNodeType2["Slot"] = import_document29.FlowNodeBaseType.SLOT] = "Slot";
|
|
1734
|
+
SlotNodeType2[SlotNodeType2["SlotBlock"] = import_document29.FlowNodeBaseType.SLOT_BLOCK] = "SlotBlock";
|
|
1735
|
+
SlotNodeType2["SlotInlineBlocks"] = "slotInlineBlocks";
|
|
1736
|
+
SlotNodeType2["SlotBlockInlineBlocks"] = "slotBlockInlineBlocks";
|
|
1737
|
+
return SlotNodeType2;
|
|
1738
|
+
})(SlotNodeType || {});
|
|
1739
|
+
|
|
1740
|
+
// src/activities/slot/utils/node.ts
|
|
1741
|
+
var canSlotDrilldown = (Slot) => !!Slot?.lastCollapsedChild?.blocks.length;
|
|
1742
|
+
var insideSlot = (entity) => !!entity?.parent?.isTypeOrExtendType(SlotNodeType.SlotBlock);
|
|
1743
|
+
var getDisplayFirstChildTransform = (transform) => {
|
|
1744
|
+
if (transform.firstChild) {
|
|
1745
|
+
return getDisplayFirstChildTransform(transform.firstChild);
|
|
1746
|
+
}
|
|
1747
|
+
return transform;
|
|
1748
|
+
};
|
|
1749
|
+
|
|
1750
|
+
// src/activities/slot/utils/transition.ts
|
|
1751
|
+
var getSlotChildLineStartPoint = (iconTransform) => {
|
|
1752
|
+
if (!iconTransform) {
|
|
1753
|
+
return { x: 0, y: 0 };
|
|
1754
|
+
}
|
|
1755
|
+
if (!iconTransform.entity.isVertical) {
|
|
1756
|
+
return {
|
|
1757
|
+
x: iconTransform?.bounds.center.x,
|
|
1758
|
+
y: iconTransform?.bounds.bottom + SLOT_COLLAPSE_MARGIN
|
|
1759
|
+
};
|
|
1760
|
+
}
|
|
1761
|
+
return {
|
|
1762
|
+
x: iconTransform?.bounds.right + SLOT_COLLAPSE_MARGIN,
|
|
1763
|
+
y: iconTransform?.bounds.center.y
|
|
1764
|
+
};
|
|
1765
|
+
};
|
|
1766
|
+
var getOutputPoint = (transform) => {
|
|
1767
|
+
const icon = transform.firstChild;
|
|
1768
|
+
if (!icon) {
|
|
1769
|
+
return { x: 0, y: 0 };
|
|
1770
|
+
}
|
|
1771
|
+
if (!transform.entity.isVertical) {
|
|
1772
|
+
return {
|
|
1773
|
+
x: transform.bounds.right,
|
|
1774
|
+
y: icon.outputPoint.y
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
return {
|
|
1778
|
+
x: icon.outputPoint.x,
|
|
1779
|
+
y: transform.bounds.bottom
|
|
1780
|
+
};
|
|
1781
|
+
};
|
|
1782
|
+
var getInputPoint = (transform) => {
|
|
1783
|
+
const icon = transform.firstChild;
|
|
1784
|
+
if (!icon) {
|
|
1785
|
+
return { x: 0, y: 0 };
|
|
1786
|
+
}
|
|
1787
|
+
if (!transform.entity.isVertical) {
|
|
1788
|
+
return {
|
|
1789
|
+
x: transform.bounds.left,
|
|
1790
|
+
y: icon.outputPoint.y
|
|
1791
|
+
};
|
|
1792
|
+
}
|
|
1793
|
+
return icon.inputPoint;
|
|
1794
|
+
};
|
|
1795
|
+
var getTransitionToPoint = (transition) => {
|
|
1796
|
+
let toPoint = transition.transform.next?.inputPoint;
|
|
1797
|
+
const icon = transition.transform.firstChild;
|
|
1798
|
+
const parent = transition.transform.parent;
|
|
1799
|
+
if (!icon || !parent) {
|
|
1800
|
+
return { x: 0, y: 0 };
|
|
1801
|
+
}
|
|
1802
|
+
if (!transition.transform.next) {
|
|
1803
|
+
if (!transition.entity.isVertical) {
|
|
1804
|
+
toPoint = {
|
|
1805
|
+
x: parent.outputPoint.x,
|
|
1806
|
+
y: icon.outputPoint.y
|
|
1807
|
+
};
|
|
1808
|
+
} else {
|
|
1809
|
+
toPoint = {
|
|
1810
|
+
x: icon.outputPoint.x,
|
|
1811
|
+
y: parent.outputPoint.y
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
return toPoint || { x: 0, y: 0 };
|
|
1816
|
+
};
|
|
1817
|
+
var drawStraightLine = (transition) => {
|
|
1818
|
+
const icon = transition.transform.firstChild;
|
|
1819
|
+
const toPoint = getTransitionToPoint(transition);
|
|
1820
|
+
if (!icon) {
|
|
1821
|
+
return [];
|
|
1822
|
+
}
|
|
1823
|
+
return [
|
|
1824
|
+
{
|
|
1825
|
+
type: import_document30.FlowTransitionLineEnum.STRAIGHT_LINE,
|
|
1826
|
+
from: icon.outputPoint,
|
|
1827
|
+
to: toPoint
|
|
1828
|
+
},
|
|
1829
|
+
{
|
|
1830
|
+
type: import_document30.FlowTransitionLineEnum.STRAIGHT_LINE,
|
|
1831
|
+
from: icon.inputPoint,
|
|
1832
|
+
to: transition.transform.inputPoint
|
|
1833
|
+
}
|
|
1834
|
+
];
|
|
1835
|
+
};
|
|
1836
|
+
var drawCollapseLabel = (transition) => {
|
|
1837
|
+
const icon = transition.transform;
|
|
1838
|
+
return [
|
|
1839
|
+
{
|
|
1840
|
+
type: import_document30.FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
1841
|
+
renderKey: RENDER_SLOT_COLLAPSE_KEY,
|
|
1842
|
+
offset: getSlotChildLineStartPoint(icon),
|
|
1843
|
+
props: {
|
|
1844
|
+
node: transition.entity.parent
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
];
|
|
1848
|
+
};
|
|
1849
|
+
var drawCollapseLine = (transition) => [
|
|
1850
|
+
{
|
|
1851
|
+
type: import_document30.FlowTransitionLineEnum.STRAIGHT_LINE,
|
|
1852
|
+
from: getSlotChildLineStartPoint(transition.transform),
|
|
1853
|
+
to: import_utils7.Point.move(
|
|
1854
|
+
getSlotChildLineStartPoint(transition.transform),
|
|
1855
|
+
transition.entity.isVertical ? { x: -SLOT_COLLAPSE_MARGIN, y: 0 } : { x: 0, y: -SLOT_COLLAPSE_MARGIN }
|
|
1856
|
+
),
|
|
1857
|
+
style: {
|
|
1858
|
+
strokeDasharray: "5 5"
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
];
|
|
1862
|
+
var drawStraightAdder = (transition) => {
|
|
1863
|
+
const toPoint = getTransitionToPoint(transition);
|
|
1864
|
+
const fromPoint = transition.transform.firstChild.outputPoint;
|
|
1865
|
+
const hoverProps = transition.entity.isVertical ? {
|
|
1866
|
+
hoverHeight: toPoint.y - fromPoint.y,
|
|
1867
|
+
hoverWidth: transition.transform.firstChild?.bounds.width
|
|
1868
|
+
} : {
|
|
1869
|
+
hoverHeight: transition.transform.firstChild?.bounds.height,
|
|
1870
|
+
hoverWidth: toPoint.x - fromPoint.x
|
|
1871
|
+
};
|
|
1872
|
+
return [
|
|
1873
|
+
{
|
|
1874
|
+
offset: import_utils7.Point.getMiddlePoint(fromPoint, toPoint),
|
|
1875
|
+
type: import_document30.FlowTransitionLabelEnum.ADDER_LABEL,
|
|
1876
|
+
props: hoverProps
|
|
1877
|
+
}
|
|
1878
|
+
];
|
|
1879
|
+
};
|
|
1880
|
+
var getPortChildInput = (_child) => {
|
|
1881
|
+
if (!_child) {
|
|
1882
|
+
return { x: 0, y: 0 };
|
|
1883
|
+
}
|
|
1884
|
+
const firstChild = getDisplayFirstChildTransform(_child);
|
|
1885
|
+
return { x: _child.bounds.left, y: firstChild.bounds.center.y };
|
|
1886
|
+
};
|
|
1887
|
+
|
|
1888
|
+
// src/activities/slot/utils/layout.ts
|
|
1889
|
+
var import_lodash = require("lodash");
|
|
1890
|
+
var getDisplayFirstChildTop = (transform) => {
|
|
1891
|
+
if (transform.firstChild) {
|
|
1892
|
+
return transform.localBounds.top + getDisplayFirstChildTop(transform.firstChild);
|
|
1893
|
+
}
|
|
1894
|
+
return transform.localBounds.center.y;
|
|
1895
|
+
};
|
|
1896
|
+
var getPortMiddle = (_port) => {
|
|
1897
|
+
if (!_port.children.length) {
|
|
1898
|
+
return _port.localBounds.top;
|
|
1899
|
+
}
|
|
1900
|
+
const portChildInputs = [_port.firstChild, _port.lastChild].map(
|
|
1901
|
+
(_portChild) => getDisplayFirstChildTop(_portChild)
|
|
1902
|
+
);
|
|
1903
|
+
return _port.localBounds.top + (0, import_lodash.mean)(portChildInputs);
|
|
1904
|
+
};
|
|
1905
|
+
var getAllPortsMiddle = (inlineBlocks) => {
|
|
1906
|
+
if (!inlineBlocks.children.length) {
|
|
1907
|
+
return inlineBlocks.localBounds.height / 2;
|
|
1908
|
+
}
|
|
1909
|
+
const portInputs = [inlineBlocks.firstChild, inlineBlocks.lastChild].map(
|
|
1910
|
+
(_port) => getPortMiddle(_port)
|
|
1911
|
+
);
|
|
1912
|
+
return (0, import_lodash.mean)(portInputs);
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1915
|
+
// src/activities/slot/utils/create.ts
|
|
1916
|
+
var import_document31 = require("@flowgram.ai/document");
|
|
1917
|
+
var createSlotFromJSON = (node, json) => {
|
|
1918
|
+
const { document } = node;
|
|
1919
|
+
const addedNodes = [];
|
|
1920
|
+
const blockIconNode = document.addNode({
|
|
1921
|
+
id: `$slotIcon$${node.id}`,
|
|
1922
|
+
type: import_document31.FlowNodeBaseType.BLOCK_ICON,
|
|
1923
|
+
originParent: node,
|
|
1924
|
+
parent: node
|
|
1925
|
+
});
|
|
1926
|
+
const inlineBlocksNode = document.addNode({
|
|
1927
|
+
id: `$slotInlineBlocks$${node.id}`,
|
|
1928
|
+
type: "slotInlineBlocks" /* SlotInlineBlocks */,
|
|
1929
|
+
originParent: node,
|
|
1930
|
+
parent: node
|
|
1931
|
+
});
|
|
1932
|
+
addedNodes.push(blockIconNode);
|
|
1933
|
+
addedNodes.push(inlineBlocksNode);
|
|
1934
|
+
const portJSONList = json.blocks || [];
|
|
1935
|
+
portJSONList.forEach((_portJSON) => {
|
|
1936
|
+
const port = document.addNode({
|
|
1937
|
+
type: SlotNodeType.SlotBlock,
|
|
1938
|
+
..._portJSON,
|
|
1939
|
+
originParent: node,
|
|
1940
|
+
parent: inlineBlocksNode
|
|
1941
|
+
});
|
|
1942
|
+
addedNodes.push(port);
|
|
1943
|
+
(_portJSON.blocks || []).forEach((_portChild) => {
|
|
1944
|
+
document.addNode(
|
|
1945
|
+
{
|
|
1946
|
+
type: SlotNodeType.Slot,
|
|
1947
|
+
..._portChild,
|
|
1948
|
+
parent: port
|
|
1949
|
+
},
|
|
1950
|
+
addedNodes
|
|
1951
|
+
);
|
|
1952
|
+
});
|
|
1953
|
+
});
|
|
1954
|
+
return addedNodes;
|
|
1955
|
+
};
|
|
1956
|
+
|
|
1957
|
+
// src/activities/slot/extends/slot-icon.ts
|
|
1958
|
+
var import_document32 = require("@flowgram.ai/document");
|
|
1959
|
+
var SlotIconRegistry = {
|
|
1960
|
+
type: import_document32.FlowNodeBaseType.BLOCK_ICON,
|
|
1961
|
+
meta: {
|
|
1962
|
+
defaultExpanded: false,
|
|
1963
|
+
spacing: 0
|
|
1964
|
+
},
|
|
1965
|
+
getLines: (transition) => [
|
|
1966
|
+
...canSlotDrilldown(transition.entity.parent) ? drawCollapseLine(transition) : []
|
|
1967
|
+
],
|
|
1968
|
+
getLabels: (transition) => [
|
|
1969
|
+
...canSlotDrilldown(transition.entity.parent) ? drawCollapseLabel(transition) : []
|
|
1970
|
+
],
|
|
1971
|
+
getDelta: (transform) => {
|
|
1972
|
+
if (insideSlot(transform.entity.parent)) {
|
|
1973
|
+
return transform.entity.isVertical ? { x: -transform.originDeltaX, y: 0 } : { x: 0, y: -transform.originDeltaY };
|
|
1974
|
+
}
|
|
1975
|
+
return { x: 0, y: 0 };
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
|
|
1979
|
+
// src/activities/slot/extends/slot-inline-blocks.ts
|
|
1980
|
+
var import_document33 = require("@flowgram.ai/document");
|
|
1981
|
+
var import_document34 = require("@flowgram.ai/document");
|
|
1982
|
+
var SlotInlineBlocksRegistry = {
|
|
1983
|
+
type: "slotInlineBlocks" /* SlotInlineBlocks */,
|
|
1984
|
+
extend: import_document33.FlowNodeBaseType.BLOCK,
|
|
1985
|
+
meta: {
|
|
1986
|
+
spacing: 0,
|
|
1987
|
+
inlineSpacingPre: 0,
|
|
1988
|
+
inlineSpacingAfter: 0,
|
|
1989
|
+
isInlineBlocks: (node) => !node.isVertical
|
|
1990
|
+
},
|
|
1991
|
+
getLines() {
|
|
1992
|
+
return [];
|
|
1993
|
+
},
|
|
1994
|
+
getLabels() {
|
|
1995
|
+
return [];
|
|
1996
|
+
},
|
|
1997
|
+
getChildDelta(child, layout) {
|
|
1998
|
+
if (child.entity.isVertical) {
|
|
1999
|
+
return { x: 0, y: 0 };
|
|
2000
|
+
}
|
|
2001
|
+
const preTransform = child.entity.pre?.getData(import_document34.FlowNodeTransformData);
|
|
2002
|
+
if (preTransform) {
|
|
2003
|
+
const { localBounds: preBounds } = preTransform;
|
|
2004
|
+
return {
|
|
2005
|
+
x: 0,
|
|
2006
|
+
y: preBounds.bottom + 30
|
|
2007
|
+
};
|
|
2008
|
+
}
|
|
2009
|
+
return { x: 0, y: 0 };
|
|
2010
|
+
},
|
|
2011
|
+
/**
|
|
2012
|
+
* 控制条件分支居右布局
|
|
2013
|
+
*/
|
|
2014
|
+
getDelta(transform) {
|
|
2015
|
+
if (!transform.children.length) {
|
|
2016
|
+
return { x: 0, y: 0 };
|
|
2017
|
+
}
|
|
2018
|
+
const icon = transform.pre;
|
|
2019
|
+
if (!icon) {
|
|
2020
|
+
return { x: 0, y: 0 };
|
|
2021
|
+
}
|
|
2022
|
+
if (!transform.entity.isVertical) {
|
|
2023
|
+
const noChildren = transform?.children?.every?.((_port) => !_port.children.length);
|
|
2024
|
+
if (noChildren) {
|
|
2025
|
+
return {
|
|
2026
|
+
x: SLOT_BLOCK_DISTANCE - icon.localBounds.width / 2,
|
|
2027
|
+
y: icon.localBounds.bottom + SLOT_COLLAPSE_MARGIN
|
|
2028
|
+
};
|
|
2029
|
+
}
|
|
2030
|
+
return {
|
|
2031
|
+
x: 2 * SLOT_BLOCK_DISTANCE - icon.localBounds.width / 2,
|
|
2032
|
+
y: icon.localBounds.bottom + SLOT_COLLAPSE_MARGIN
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
return {
|
|
2036
|
+
x: icon.localBounds.right + SLOT_INLINE_BLOCKS_DELTA,
|
|
2037
|
+
y: -icon.localBounds.height
|
|
2038
|
+
};
|
|
2039
|
+
}
|
|
2040
|
+
};
|
|
2041
|
+
|
|
2042
|
+
// src/activities/slot/extends/slot-block.ts
|
|
2043
|
+
var import_lodash2 = require("lodash");
|
|
2044
|
+
var import_document35 = require("@flowgram.ai/document");
|
|
2045
|
+
var import_document36 = require("@flowgram.ai/document");
|
|
2046
|
+
var SlotBlockRegistry = {
|
|
2047
|
+
type: SlotNodeType.SlotBlock,
|
|
2048
|
+
extend: import_document35.FlowNodeBaseType.BLOCK,
|
|
2049
|
+
meta: {
|
|
2050
|
+
inlineSpacingAfter: 0,
|
|
2051
|
+
inlineSpacingPre: 0,
|
|
2052
|
+
spacing: (transform) => {
|
|
2053
|
+
if (!transform.entity.isVertical && transform.size.width === 0) {
|
|
2054
|
+
return 90;
|
|
2055
|
+
}
|
|
2056
|
+
return 30;
|
|
2057
|
+
},
|
|
2058
|
+
isInlineBlocks: (node) => !node.isVertical
|
|
2059
|
+
},
|
|
2060
|
+
getLines(transition) {
|
|
2061
|
+
const icon = transition.transform.parent?.pre;
|
|
2062
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
2063
|
+
const portPoint = transition.transform.inputPoint;
|
|
2064
|
+
return [
|
|
2065
|
+
{
|
|
2066
|
+
type: import_document35.FlowTransitionLineEnum.ROUNDED_LINE,
|
|
2067
|
+
from: start,
|
|
2068
|
+
to: portPoint,
|
|
2069
|
+
vertices: [{ x: start.x, y: portPoint.y }],
|
|
2070
|
+
style: {
|
|
2071
|
+
strokeDasharray: "5 5"
|
|
2072
|
+
},
|
|
2073
|
+
radius: 5
|
|
2074
|
+
},
|
|
2075
|
+
...transition.transform.children.map((_child) => {
|
|
2076
|
+
const childInput = getPortChildInput(_child);
|
|
2077
|
+
return {
|
|
2078
|
+
type: import_document35.FlowTransitionLineEnum.ROUNDED_LINE,
|
|
2079
|
+
radius: 5,
|
|
2080
|
+
from: portPoint,
|
|
2081
|
+
to: childInput,
|
|
2082
|
+
vertices: [{ x: portPoint.x, y: childInput.y }],
|
|
2083
|
+
style: {
|
|
2084
|
+
strokeDasharray: "5 5"
|
|
2085
|
+
}
|
|
2086
|
+
};
|
|
2087
|
+
})
|
|
2088
|
+
];
|
|
2089
|
+
},
|
|
2090
|
+
getLabels(transition) {
|
|
2091
|
+
const portPoint = transition.transform.inputPoint;
|
|
2092
|
+
return [
|
|
2093
|
+
{
|
|
2094
|
+
type: import_document35.FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
2095
|
+
renderKey: RENDER_SLOT_ADDER_KEY,
|
|
2096
|
+
props: {
|
|
2097
|
+
node: transition.entity
|
|
2098
|
+
},
|
|
2099
|
+
offset: portPoint
|
|
2100
|
+
}
|
|
2101
|
+
];
|
|
2102
|
+
},
|
|
2103
|
+
getInputPoint(transform) {
|
|
2104
|
+
const icon = transform.parent?.pre;
|
|
2105
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
2106
|
+
let inputY = transform.bounds.center.y;
|
|
2107
|
+
if (transform.children.length) {
|
|
2108
|
+
inputY = (0, import_lodash2.mean)([
|
|
2109
|
+
getPortChildInput(transform.firstChild).y,
|
|
2110
|
+
getPortChildInput(transform.lastChild).y
|
|
2111
|
+
]);
|
|
2112
|
+
}
|
|
2113
|
+
return {
|
|
2114
|
+
x: start.x + SLOT_BLOCK_DISTANCE,
|
|
2115
|
+
y: inputY
|
|
2116
|
+
};
|
|
2117
|
+
},
|
|
2118
|
+
getChildDelta(child, layout) {
|
|
2119
|
+
const hasChild = !!child.firstChild;
|
|
2120
|
+
if (child.entity.isVertical) {
|
|
2121
|
+
let deltaX = hasChild ? 0 : -child.originDeltaX;
|
|
2122
|
+
return { x: deltaX, y: 0 };
|
|
2123
|
+
}
|
|
2124
|
+
let deltaY = hasChild ? 0 : -child.originDeltaY;
|
|
2125
|
+
const preTransform = child.entity.pre?.getData(import_document36.FlowNodeTransformData);
|
|
2126
|
+
if (preTransform) {
|
|
2127
|
+
const { localBounds: preBounds } = preTransform;
|
|
2128
|
+
return {
|
|
2129
|
+
x: 0,
|
|
2130
|
+
y: preBounds.bottom + 30 + deltaY
|
|
2131
|
+
};
|
|
2132
|
+
}
|
|
2133
|
+
return { x: 0, y: deltaY };
|
|
2134
|
+
},
|
|
2135
|
+
getChildLabels() {
|
|
2136
|
+
return [];
|
|
2137
|
+
},
|
|
2138
|
+
getChildLines() {
|
|
2139
|
+
return [];
|
|
2140
|
+
},
|
|
2141
|
+
getDelta(transform) {
|
|
2142
|
+
return {
|
|
2143
|
+
x: 0,
|
|
2144
|
+
y: 0
|
|
2145
|
+
};
|
|
2146
|
+
}
|
|
2147
|
+
};
|
|
2148
|
+
|
|
2149
|
+
// src/activities/slot/slot.ts
|
|
2150
|
+
var SlotRegistry = {
|
|
2151
|
+
type: import_document37.FlowNodeBaseType.SLOT,
|
|
2152
|
+
extend: "block",
|
|
2153
|
+
meta: {
|
|
2154
|
+
// Slot 节点内部暂时不允许拖拽
|
|
2155
|
+
draggable: (node) => !insideSlot(node),
|
|
2156
|
+
hidden: true,
|
|
2157
|
+
spacing: SLOT_SPACING,
|
|
2158
|
+
padding: (node) => ({
|
|
2159
|
+
left: 0,
|
|
2160
|
+
right: node.collapsed ? SLOT_COLLAPSE_MARGIN : 0,
|
|
2161
|
+
bottom: !insideSlot(node.entity) && node.isLast ? SLOT_NODE_LAST_SPACING : 0,
|
|
2162
|
+
top: 0
|
|
2163
|
+
}),
|
|
2164
|
+
copyDisable: false,
|
|
2165
|
+
defaultExpanded: false
|
|
2166
|
+
},
|
|
2167
|
+
/**
|
|
2168
|
+
* 业务通常需要重载方法
|
|
2169
|
+
*/
|
|
2170
|
+
onCreate: createSlotFromJSON,
|
|
2171
|
+
getLines: (transition) => [
|
|
2172
|
+
...!insideSlot(transition.entity) ? drawStraightLine(transition) : []
|
|
2173
|
+
],
|
|
2174
|
+
getLabels: (transition) => [
|
|
2175
|
+
...!insideSlot(transition.entity) ? drawStraightAdder(transition) : []
|
|
2176
|
+
],
|
|
2177
|
+
getInputPoint,
|
|
2178
|
+
getOutputPoint,
|
|
2179
|
+
onAfterUpdateLocalTransform(transform) {
|
|
2180
|
+
const { isVertical } = transform.entity;
|
|
2181
|
+
if (!isVertical) {
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
const icon = transform.firstChild;
|
|
2185
|
+
const inlineBlocks = transform.lastChild;
|
|
2186
|
+
if (!icon || !inlineBlocks) {
|
|
2187
|
+
return;
|
|
2188
|
+
}
|
|
2189
|
+
const iconSize = icon.localBounds.height;
|
|
2190
|
+
const inlineBlocksSize = inlineBlocks.localBounds.height;
|
|
2191
|
+
if (transform.collapsed || !inlineBlocks) {
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
const portsMiddle = getAllPortsMiddle(inlineBlocks);
|
|
2195
|
+
icon.entity.clearMemoLocal();
|
|
2196
|
+
inlineBlocks.entity.clearMemoLocal();
|
|
2197
|
+
if (iconSize / 2 + portsMiddle > inlineBlocksSize || !inlineBlocks.children.length) {
|
|
2198
|
+
icon.transform.update({
|
|
2199
|
+
position: { x: icon.transform.position.x, y: 0 }
|
|
2200
|
+
});
|
|
2201
|
+
inlineBlocks.transform.update({
|
|
2202
|
+
position: {
|
|
2203
|
+
x: inlineBlocks.transform.position.x,
|
|
2204
|
+
y: Math.max(iconSize / 2 - inlineBlocksSize / 2, 0)
|
|
2205
|
+
}
|
|
2206
|
+
});
|
|
2207
|
+
return;
|
|
2208
|
+
}
|
|
2209
|
+
inlineBlocks.transform.update({
|
|
2210
|
+
position: { x: inlineBlocks.transform.position.x, y: 0 }
|
|
2211
|
+
});
|
|
2212
|
+
icon?.transform.update({
|
|
2213
|
+
position: {
|
|
2214
|
+
x: icon.transform.position.x,
|
|
2215
|
+
y: Math.max(portsMiddle - iconSize / 2, 0)
|
|
2216
|
+
// 所有 port 的中间点
|
|
2217
|
+
}
|
|
2218
|
+
});
|
|
2219
|
+
},
|
|
2220
|
+
extendChildRegistries: [SlotIconRegistry, SlotInlineBlocksRegistry]
|
|
2221
|
+
};
|
|
2222
|
+
|
|
1713
2223
|
// src/flow-registers.ts
|
|
1714
2224
|
var FlowRegisters = class {
|
|
1715
2225
|
/**
|
|
@@ -1749,14 +2259,16 @@ var FlowRegisters = class {
|
|
|
1749
2259
|
MultiOuputsRegistry,
|
|
1750
2260
|
MultiInputsRegistry,
|
|
1751
2261
|
InputRegistry,
|
|
1752
|
-
OuputRegistry
|
|
2262
|
+
OuputRegistry,
|
|
2263
|
+
SlotRegistry,
|
|
2264
|
+
SlotBlockRegistry
|
|
1753
2265
|
);
|
|
1754
2266
|
document.registerNodeDatas(
|
|
1755
|
-
|
|
2267
|
+
import_document38.FlowNodeRenderData,
|
|
1756
2268
|
// 渲染节点相关数据
|
|
1757
|
-
|
|
2269
|
+
import_document38.FlowNodeTransitionData,
|
|
1758
2270
|
// 线条绘制数据
|
|
1759
|
-
|
|
2271
|
+
import_document38.FlowNodeTransformData
|
|
1760
2272
|
// 坐标计算数据
|
|
1761
2273
|
);
|
|
1762
2274
|
}
|
|
@@ -1766,13 +2278,13 @@ var FlowRegisters = class {
|
|
|
1766
2278
|
*/
|
|
1767
2279
|
registerRenderer(renderer) {
|
|
1768
2280
|
renderer.registerLayers(
|
|
1769
|
-
|
|
2281
|
+
import_renderer8.FlowNodesTransformLayer,
|
|
1770
2282
|
// 节点位置渲染
|
|
1771
|
-
|
|
2283
|
+
import_renderer8.FlowNodesContentLayer,
|
|
1772
2284
|
// 节点内容渲染
|
|
1773
|
-
|
|
2285
|
+
import_renderer8.FlowLinesLayer,
|
|
1774
2286
|
// 线条渲染
|
|
1775
|
-
|
|
2287
|
+
import_renderer8.FlowLabelsLayer,
|
|
1776
2288
|
// Label 渲染
|
|
1777
2289
|
import_core.PlaygroundLayer
|
|
1778
2290
|
// 画布基础层,提供缩放、手势等能力
|
|
@@ -1795,9 +2307,9 @@ FlowRegisters = __decorateClass([
|
|
|
1795
2307
|
|
|
1796
2308
|
// src/fixed-layout-container-module.ts
|
|
1797
2309
|
var FixedLayoutContainerModule = new import_inversify2.ContainerModule((bind) => {
|
|
1798
|
-
(0,
|
|
1799
|
-
|
|
1800
|
-
|
|
2310
|
+
(0, import_utils8.bindContributions)(bind, FlowRegisters, [
|
|
2311
|
+
import_document39.FlowDocumentContribution,
|
|
2312
|
+
import_renderer9.FlowRendererContribution,
|
|
1801
2313
|
import_core2.PlaygroundContribution
|
|
1802
2314
|
]);
|
|
1803
2315
|
});
|
|
@@ -1815,7 +2327,8 @@ var FixedLayoutRegistries = {
|
|
|
1815
2327
|
StartRegistry,
|
|
1816
2328
|
RootRegistry,
|
|
1817
2329
|
InlineBlocksRegistry,
|
|
1818
|
-
EndRegistry
|
|
2330
|
+
EndRegistry,
|
|
2331
|
+
SlotRegistry
|
|
1819
2332
|
};
|
|
1820
2333
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1821
2334
|
0 && (module.exports = {
|