@flowgram-vue/fixed-layout-core 0.2.0

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.
Files changed (54) hide show
  1. package/LICENSE +22 -0
  2. package/dist/index.cjs +2327 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.ts +61 -0
  5. package/dist/index.js +2323 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +56 -0
  8. package/src/activities/block-icon.ts +55 -0
  9. package/src/activities/block-order-icon.ts +64 -0
  10. package/src/activities/block.ts +192 -0
  11. package/src/activities/break.ts +14 -0
  12. package/src/activities/dynamic-split.ts +94 -0
  13. package/src/activities/empty.ts +35 -0
  14. package/src/activities/end.ts +26 -0
  15. package/src/activities/index.ts +24 -0
  16. package/src/activities/inline-blocks.ts +197 -0
  17. package/src/activities/input.ts +152 -0
  18. package/src/activities/loop-extends/constants.ts +25 -0
  19. package/src/activities/loop-extends/index.ts +10 -0
  20. package/src/activities/loop-extends/loop-empty-branch.ts +60 -0
  21. package/src/activities/loop-extends/loop-inline-blocks.ts +140 -0
  22. package/src/activities/loop-extends/loop-left-empty-block.ts +43 -0
  23. package/src/activities/loop-extends/loop-right-empty-block.ts +18 -0
  24. package/src/activities/loop.ts +198 -0
  25. package/src/activities/multi-inputs.ts +98 -0
  26. package/src/activities/multi-outputs.ts +65 -0
  27. package/src/activities/output.ts +18 -0
  28. package/src/activities/root.ts +23 -0
  29. package/src/activities/simple-split.ts +47 -0
  30. package/src/activities/slot/constants.ts +56 -0
  31. package/src/activities/slot/extends/index.ts +8 -0
  32. package/src/activities/slot/extends/slot-block.ts +229 -0
  33. package/src/activities/slot/extends/slot-icon.ts +32 -0
  34. package/src/activities/slot/extends/slot-inline-blocks.ts +102 -0
  35. package/src/activities/slot/index.ts +8 -0
  36. package/src/activities/slot/slot.ts +108 -0
  37. package/src/activities/slot/typings.ts +13 -0
  38. package/src/activities/slot/utils/create.ts +105 -0
  39. package/src/activities/slot/utils/layout.ts +49 -0
  40. package/src/activities/slot/utils/node.ts +38 -0
  41. package/src/activities/slot/utils/transition.ts +222 -0
  42. package/src/activities/start.ts +21 -0
  43. package/src/activities/static-split.ts +29 -0
  44. package/src/activities/try-catch-extends/catch-block.ts +78 -0
  45. package/src/activities/try-catch-extends/catch-inline-blocks.ts +122 -0
  46. package/src/activities/try-catch-extends/constants.ts +27 -0
  47. package/src/activities/try-catch-extends/index.ts +11 -0
  48. package/src/activities/try-catch-extends/main-inline-blocks.ts +147 -0
  49. package/src/activities/try-catch-extends/try-block.ts +26 -0
  50. package/src/activities/try-catch-extends/try-slot.ts +48 -0
  51. package/src/activities/try-catch.ts +176 -0
  52. package/src/fixed-layout-container-module.ts +20 -0
  53. package/src/flow-registers.ts +117 -0
  54. package/src/index.ts +45 -0
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { FlowRendererKey } from '@flowgram-vue/renderer';
7
+ import {
8
+ DEFAULT_SPACING,
9
+ FlowNodeBaseType,
10
+ type FlowNodeRegistry,
11
+ FlowNodeRenderData,
12
+ FlowTransitionLabelEnum,
13
+ FlowTransitionLineEnum,
14
+ FlowLayoutDefault,
15
+ } from '@flowgram-vue/document';
16
+
17
+ import { TryCatchSpacings, TryCatchTypeEnum } from './constants';
18
+
19
+ /**
20
+ * catch 分支列表
21
+ */
22
+ export const CatchInlineBlocksRegistry: FlowNodeRegistry = {
23
+ extend: FlowNodeBaseType.INLINE_BLOCKS,
24
+ type: TryCatchTypeEnum.CATCH_INLINE_BLOCKS,
25
+ meta: {
26
+ spacing: DEFAULT_SPACING.NULL,
27
+ inlineSpacingPre: DEFAULT_SPACING.NULL,
28
+ // inlineSpacingAfter: DEFAULT_SPACING.NULL,
29
+ },
30
+ getDelta() {
31
+ return undefined;
32
+ },
33
+ getLines(transition) {
34
+ const { transform } = transition;
35
+ const mainInlineBlocks = transform.parent!;
36
+
37
+ const lines = [
38
+ {
39
+ type: FlowTransitionLineEnum.DIVERGE_LINE,
40
+ from: mainInlineBlocks.pre!.outputPoint,
41
+ to: transform.inputPoint,
42
+ },
43
+ ];
44
+
45
+ if (!transform.entity.isNodeEnd) {
46
+ lines.push({
47
+ type: FlowTransitionLineEnum.MERGE_LINE,
48
+ from: transform.outputPoint,
49
+ to: mainInlineBlocks.outputPoint,
50
+ });
51
+ }
52
+
53
+ return lines;
54
+ },
55
+ getOriginDeltaX(transform) {
56
+ const { firstChild } = transform;
57
+ if (!firstChild) return 0;
58
+ return firstChild.originDeltaX;
59
+ },
60
+ getLabels(transition) {
61
+ const { inputPoint } = transition.transform;
62
+ const { isVertical } = transition.entity;
63
+ const currentTransform = transition.transform;
64
+
65
+ // 实际输入点
66
+ const actualInputPoint = {
67
+ x: isVertical ? inputPoint.x : inputPoint.x - TryCatchSpacings.CATCH_INLINE_SPACING,
68
+ y: isVertical ? inputPoint.y - TryCatchSpacings.CATCH_INLINE_SPACING : inputPoint.y,
69
+ };
70
+
71
+ if (currentTransform.collapsed) {
72
+ return [];
73
+ }
74
+
75
+ // branch adder 节点
76
+ return [
77
+ {
78
+ type: FlowTransitionLabelEnum.CUSTOM_LABEL,
79
+ renderKey: FlowRendererKey.BRANCH_ADDER,
80
+ offset: actualInputPoint,
81
+ props: {
82
+ // 激活状态
83
+ activated: transition.entity.getData(FlowNodeRenderData)!.activated,
84
+ transform: currentTransform,
85
+ // 传给外部使用的 node 信息
86
+ node: currentTransform.originParent?.entity,
87
+ },
88
+ },
89
+ ];
90
+ },
91
+ getInputPoint(transform, layout) {
92
+ const isVertical = FlowLayoutDefault.isVertical(layout);
93
+ // 因为是左偏移,所以用第一条 catch 分支
94
+ const firstCatchBlock = transform.firstChild;
95
+ if (firstCatchBlock) {
96
+ return firstCatchBlock.inputPoint;
97
+ }
98
+ return isVertical ? transform.bounds.topCenter : transform.bounds.rightCenter;
99
+ },
100
+ getOutputPoint(transform, layout) {
101
+ const isVertical = FlowLayoutDefault.isVertical(layout);
102
+
103
+ // 收缩时,出点为入点
104
+ if (transform.collapsed) {
105
+ return transform.inputPoint;
106
+ }
107
+
108
+ const firstCatchBlock = transform.firstChild;
109
+ if (firstCatchBlock) {
110
+ return isVertical
111
+ ? {
112
+ x: firstCatchBlock!.outputPoint?.x,
113
+ y: transform.bounds.bottom,
114
+ }
115
+ : {
116
+ x: transform.bounds.right,
117
+ y: firstCatchBlock!.outputPoint?.y,
118
+ };
119
+ }
120
+ return isVertical ? transform.bounds.bottomCenter : transform.bounds.rightCenter;
121
+ },
122
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * tryCatch 自定义类型
8
+ */
9
+ export enum TryCatchTypeEnum {
10
+ MAIN_INLINE_BLOCKS = 'mainInlineBlocks',
11
+ CATCH_INLINE_BLOCKS = 'catchInlineBlocks',
12
+ TRY_BLOCK = 'tryBlock',
13
+ TRY_SLOT = 'trySlot',
14
+ CATCH_BLOCK = 'catchBlock',
15
+ }
16
+
17
+ export enum TryCatchSpacings {
18
+ INLINE_SPACING_TOP = 54, // 上边空白
19
+ INLINE_SPACING_BOTTOM = 0, // 下边空白
20
+ TRY_START_LABEL_DELTA = -20, // try 开始标签偏移
21
+ TRY_END_LABEL_DELTA = -20, // try 结束标签偏移
22
+ CATCH_INLINE_SPACING = 20, // Catch 分支的上边间隙
23
+ // lint-fix: 这里枚举重复了,但是看语义定义两个 key 是合理的。因此 disabled 处理
24
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
25
+ MAIN_INLINE_SPACING_TOP = 20,
26
+ MAIN_INLINE_SPACING_BOTTOM = 40, // main 分支下边留白,不然会遮挡 "监控结束"标签
27
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export * from './constants';
7
+ export * from './catch-block';
8
+ export * from './catch-inline-blocks';
9
+ export * from './main-inline-blocks';
10
+ export * from './try-block';
11
+ export * from './try-slot';
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { FlowRendererKey, FlowTextKey } from '@flowgram-vue/renderer';
7
+ import {
8
+ FlowNodeBaseType,
9
+ type FlowNodeRegistry,
10
+ FlowNodeTransformData,
11
+ FlowTransitionLabelEnum,
12
+ FlowTransitionLineEnum,
13
+ FlowLayoutDefault,
14
+ getDefaultSpacing,
15
+ ConstantKeys,
16
+ } from '@flowgram-vue/document';
17
+
18
+ import { TryCatchSpacings, TryCatchTypeEnum } from './constants';
19
+
20
+ /**
21
+ * 主 BLOCK
22
+ */
23
+ export const MainInlineBlocksRegistry: FlowNodeRegistry = {
24
+ extend: FlowNodeBaseType.INLINE_BLOCKS,
25
+ type: TryCatchTypeEnum.MAIN_INLINE_BLOCKS,
26
+ meta: {
27
+ inlineSpacingPre: TryCatchSpacings.MAIN_INLINE_SPACING_TOP,
28
+ inlineSpacingAfter: TryCatchSpacings.MAIN_INLINE_SPACING_BOTTOM,
29
+ },
30
+ getLines(transition) {
31
+ const { transform } = transition;
32
+ const tryBranch = transform.firstChild!;
33
+
34
+ const lines = [
35
+ {
36
+ type: FlowTransitionLineEnum.STRAIGHT_LINE,
37
+ from: tryBranch.outputPoint,
38
+ to: transform.originParent!.outputPoint,
39
+ },
40
+ ];
41
+
42
+ return lines;
43
+ },
44
+ getLabels(transition) {
45
+ const { transform } = transition;
46
+ const { isVertical } = transition.entity;
47
+ const catchInlineBlocks = transform.children[1]!;
48
+ const errLabelX = isVertical
49
+ ? (transform.parent!.outputPoint.x + catchInlineBlocks.inputPoint.x) / 2
50
+ : transform.inputPoint.x - TryCatchSpacings.INLINE_SPACING_TOP;
51
+ const errLabelY = isVertical
52
+ ? transform.inputPoint.y - TryCatchSpacings.INLINE_SPACING_TOP
53
+ : (transform.parent!.outputPoint.y + catchInlineBlocks.inputPoint.y) / 2;
54
+
55
+ const errorLabelX = errLabelX;
56
+ const errorLabelY = errLabelY;
57
+ return [
58
+ {
59
+ type: FlowTransitionLabelEnum.TEXT_LABEL,
60
+ renderKey: FlowTextKey.TRY_START_TEXT,
61
+ offset: {
62
+ x: isVertical
63
+ ? transform.inputPoint.x
64
+ : transform.inputPoint.x + TryCatchSpacings.TRY_START_LABEL_DELTA,
65
+ y: isVertical
66
+ ? transform.inputPoint.y + TryCatchSpacings.TRY_START_LABEL_DELTA
67
+ : transform.inputPoint.y,
68
+ },
69
+ },
70
+ {
71
+ type: FlowTransitionLabelEnum.TEXT_LABEL,
72
+ renderKey: FlowTextKey.TRY_END_TEXT,
73
+ offset: {
74
+ x: isVertical
75
+ ? transform.inputPoint.x
76
+ : transform.originParent!.outputPoint.x + TryCatchSpacings.TRY_END_LABEL_DELTA,
77
+ y: isVertical
78
+ ? transform.originParent!.outputPoint.y + TryCatchSpacings.TRY_END_LABEL_DELTA
79
+ : transform.inputPoint.y,
80
+ },
81
+ },
82
+ // 错误分支收起
83
+ {
84
+ type: FlowTransitionLabelEnum.CUSTOM_LABEL,
85
+ renderKey: FlowRendererKey.TRY_CATCH_COLLAPSE,
86
+ offset: {
87
+ x: errorLabelX,
88
+ y: errorLabelY,
89
+ },
90
+ props: {
91
+ node: transform.lastChild?.entity,
92
+ },
93
+ },
94
+ ];
95
+ },
96
+ getInputPoint(transform) {
97
+ const tryBlock = transform.firstChild!;
98
+ return tryBlock.inputPoint;
99
+ },
100
+ getOutputPoint(transform, layout) {
101
+ const tryBlock = transform.firstChild!;
102
+ const isVertical = FlowLayoutDefault.isVertical(layout);
103
+ if (isVertical) {
104
+ return {
105
+ x: tryBlock.outputPoint.x,
106
+ y: transform.bounds.bottom + TryCatchSpacings.CATCH_INLINE_SPACING,
107
+ };
108
+ }
109
+ return {
110
+ x: transform.bounds.right + TryCatchSpacings.CATCH_INLINE_SPACING,
111
+ y: tryBlock.outputPoint.y,
112
+ };
113
+ },
114
+ getDelta() {
115
+ return undefined;
116
+ },
117
+ getChildDelta(child, layout) {
118
+ const preTransform = child.entity.pre?.getData(FlowNodeTransformData);
119
+ const isVertical = FlowLayoutDefault.isVertical(layout);
120
+ if (preTransform) {
121
+ const { localBounds: preBounds } = preTransform;
122
+ // try 分支和 catch 分支的最小间距不低于 minInlineBlockSpacing
123
+ let delta = 0;
124
+ if (isVertical) {
125
+ delta = Math.max(
126
+ child.parent!.minInlineBlockSpacing,
127
+ -child.originDeltaX + getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING)
128
+ );
129
+ } else {
130
+ delta = Math.max(
131
+ child.parent!.minInlineBlockSpacing,
132
+ -child.originDeltaY + getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING)
133
+ );
134
+ }
135
+
136
+ return {
137
+ // 分支只有两个所以这里可以写死间隔宽度
138
+ x: isVertical ? preBounds.right + delta : 0,
139
+ y: isVertical ? 0 : preBounds.bottom + delta,
140
+ };
141
+ }
142
+ return {
143
+ x: 0,
144
+ y: 0,
145
+ };
146
+ },
147
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { DEFAULT_SPACING, FlowNodeBaseType, type FlowNodeRegistry } from '@flowgram-vue/document';
7
+
8
+ import { TryCatchTypeEnum } from './constants';
9
+
10
+ /**
11
+ * try 分支
12
+ */
13
+ export const TryBlockRegistry: FlowNodeRegistry = {
14
+ extend: FlowNodeBaseType.BLOCK,
15
+ type: TryCatchTypeEnum.TRY_BLOCK,
16
+ meta: {
17
+ hidden: true,
18
+ spacing: DEFAULT_SPACING.NULL,
19
+ },
20
+ getLines() {
21
+ return [];
22
+ },
23
+ getLabels() {
24
+ return [];
25
+ },
26
+ };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { type FlowNodeRegistry, FlowTransitionLabelEnum } from '@flowgram-vue/document';
7
+
8
+ import { TryCatchTypeEnum } from './constants';
9
+
10
+ /**
11
+ * try 占位节点
12
+ */
13
+ export const TrySlotRegistry: FlowNodeRegistry = {
14
+ type: TryCatchTypeEnum.TRY_SLOT,
15
+ meta: {
16
+ inlineSpacingAfter: 16,
17
+ spacing: 0,
18
+ size: {
19
+ width: 16,
20
+ height: 0,
21
+ },
22
+ },
23
+ onAfterUpdateLocalTransform(transform): void {
24
+ // 根据布局要置换宽高数据
25
+ if (transform.entity.isVertical) {
26
+ transform.data.size = {
27
+ width: 16,
28
+ height: 0,
29
+ };
30
+ } else {
31
+ transform.data.size = {
32
+ width: 0,
33
+ height: 16,
34
+ };
35
+ }
36
+ transform.transform.update({
37
+ size: transform.data.size,
38
+ });
39
+ },
40
+ getLabels(transition) {
41
+ return [
42
+ {
43
+ offset: transition.transform.bounds.center,
44
+ type: FlowTransitionLabelEnum.ADDER_LABEL,
45
+ },
46
+ ];
47
+ },
48
+ };
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import {
7
+ FlowLayoutDefault,
8
+ FlowNodeBaseType,
9
+ type FlowNodeEntity,
10
+ type FlowNodeJSON,
11
+ type FlowNodeRegistry,
12
+ } from '@flowgram-vue/document';
13
+
14
+ import {
15
+ CatchBlockRegistry,
16
+ CatchInlineBlocksRegistry,
17
+ MainInlineBlocksRegistry,
18
+ TryBlockRegistry,
19
+ TryCatchSpacings,
20
+ TryCatchTypeEnum,
21
+ TrySlotRegistry,
22
+ } from './try-catch-extends';
23
+
24
+ /**
25
+ * try catch 节点
26
+ */
27
+ export const TryCatchRegistry: FlowNodeRegistry = {
28
+ type: 'tryCatch',
29
+ meta: {
30
+ hidden: true,
31
+ inlineSpacingAfter: TryCatchSpacings.INLINE_SPACING_BOTTOM,
32
+ },
33
+ /**
34
+ * 结构
35
+ * tryCatch
36
+ * - tryCatchIcon
37
+ * - mainInlineBlocks
38
+ * - tryBlock // try 分支
39
+ * - trySlot // 空节点用来占位,try 分支一开始没有节点
40
+ * - catchInlineBlocks
41
+ * - catchBlock // catch 分支 1
42
+ * - blockOrderIcon
43
+ * - node1
44
+ * - catchBlock // catch 分支 2
45
+ * - blockOrderIcon
46
+ * - node 2
47
+ * @param node
48
+ * @param json
49
+ */
50
+ onCreate(node: FlowNodeEntity, json: FlowNodeJSON) {
51
+ const { document } = node;
52
+ const [tryBlock, ...catchBlocks] = json.blocks || [];
53
+ const addedNodes: FlowNodeEntity[] = [];
54
+ const tryCatchIconNode = document.addNode({
55
+ id: `$tryCatchIcon$${node.id}`,
56
+ type: FlowNodeBaseType.BLOCK_ICON,
57
+ originParent: node,
58
+ parent: node,
59
+ });
60
+ const mainBlockNode = document.addNode({
61
+ id: `$mainInlineBlocks$${node.id}`,
62
+ type: TryCatchTypeEnum.MAIN_INLINE_BLOCKS,
63
+ originParent: node,
64
+ parent: node,
65
+ });
66
+ const tryBlockNode = document.addNode({
67
+ id: tryBlock.id,
68
+ type: tryBlock.type || TryCatchTypeEnum.TRY_BLOCK,
69
+ originParent: node,
70
+ parent: mainBlockNode,
71
+ data: tryBlock.data,
72
+ });
73
+ const trySlotNode = document.addNode({
74
+ id: `$trySlot$${tryBlock.id}`,
75
+ hidden: true,
76
+ type: TryCatchTypeEnum.TRY_SLOT, // 占位节点
77
+ originParent: node,
78
+ parent: tryBlockNode,
79
+ });
80
+ const catchInlineBlocksNode = document.addNode({
81
+ id: `$catchInlineBlocks$${node.id}`,
82
+ type: TryCatchTypeEnum.CATCH_INLINE_BLOCKS,
83
+ originParent: node,
84
+ parent: mainBlockNode,
85
+ });
86
+ addedNodes.push(
87
+ tryCatchIconNode,
88
+ mainBlockNode,
89
+ tryBlockNode,
90
+ trySlotNode,
91
+ catchInlineBlocksNode
92
+ );
93
+ (tryBlock.blocks || []).forEach((blockData) => {
94
+ document.addNode(
95
+ {
96
+ ...blockData,
97
+ parent: tryBlockNode,
98
+ },
99
+ addedNodes
100
+ );
101
+ });
102
+ catchBlocks.forEach((blockData) => {
103
+ document.addBlock(node, blockData, addedNodes);
104
+ });
105
+ return addedNodes;
106
+ },
107
+ /**
108
+ * 添加 catch 分支
109
+ * @param node
110
+ * @param blockData
111
+ * @param addedNodes
112
+ */
113
+ onBlockChildCreate(node, blockData, addedNodes) {
114
+ const parent = node.document.getNode(`$catchInlineBlocks$${node.id}`);
115
+ const block = node.document.addNode({
116
+ id: blockData.id,
117
+ type: blockData.type || TryCatchTypeEnum.CATCH_BLOCK,
118
+ originParent: node,
119
+ parent,
120
+ data: blockData.data,
121
+ });
122
+ // 分支开始节点
123
+ const blockOrderIcon = node.document.addNode({
124
+ id: `$blockOrderIcon$${blockData.id}`,
125
+ type: FlowNodeBaseType.BLOCK_ORDER_ICON,
126
+ originParent: node,
127
+ parent: block,
128
+ });
129
+ if (blockData.blocks) {
130
+ node.document.addBlocksAsChildren(block, blockData.blocks || [], addedNodes);
131
+ }
132
+ addedNodes?.push(block, blockOrderIcon);
133
+ return block;
134
+ },
135
+ getInputPoint(transform) {
136
+ const tryCatchIcon = transform.firstChild!;
137
+ // 使用图标的 inputPoint
138
+ return tryCatchIcon.inputPoint;
139
+ },
140
+ getOutputPoint(transform, layout) {
141
+ const isVertical = FlowLayoutDefault.isVertical(layout);
142
+ const tryCatchIcon = transform.firstChild!;
143
+ if (isVertical) {
144
+ return {
145
+ x: tryCatchIcon.inputPoint.x,
146
+ y: transform.bounds.bottom,
147
+ };
148
+ }
149
+ return {
150
+ x: transform.bounds.right,
151
+ y: tryCatchIcon.inputPoint.y,
152
+ };
153
+ },
154
+ /**
155
+ * tryCatch 子节点配置
156
+ */
157
+ extendChildRegistries: [
158
+ /**
159
+ * icon 节点
160
+ */
161
+ {
162
+ type: FlowNodeBaseType.BLOCK_ICON,
163
+ meta: {
164
+ spacing: TryCatchSpacings.INLINE_SPACING_TOP,
165
+ },
166
+ getLabels() {
167
+ return [];
168
+ },
169
+ },
170
+ MainInlineBlocksRegistry,
171
+ CatchInlineBlocksRegistry,
172
+ TryBlockRegistry,
173
+ CatchBlockRegistry,
174
+ TrySlotRegistry,
175
+ ],
176
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { ContainerModule } from 'inversify';
7
+ import { FlowRendererContribution } from '@flowgram-vue/renderer';
8
+ import { FlowDocumentContribution } from '@flowgram-vue/document';
9
+ import { PlaygroundContribution } from '@flowgram-vue/core';
10
+ import { bindContributions } from '@flowgram-vue/utils';
11
+
12
+ import { FlowRegisters } from './flow-registers';
13
+
14
+ export const FixedLayoutContainerModule = new ContainerModule(bind => {
15
+ bindContributions(bind, FlowRegisters, [
16
+ FlowDocumentContribution,
17
+ FlowRendererContribution,
18
+ PlaygroundContribution,
19
+ ]);
20
+ });
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { injectable } from 'inversify';
7
+ import {
8
+ FlowLabelsLayer,
9
+ FlowLinesLayer,
10
+ FlowNodesContentLayer,
11
+ FlowNodesTransformLayer,
12
+ type FlowRendererContribution,
13
+ type FlowRendererRegistry,
14
+ } from '@flowgram-vue/renderer';
15
+ import {
16
+ type FlowDocument,
17
+ type FlowDocumentContribution,
18
+ FlowNodeRenderData,
19
+ FlowNodeTransformData,
20
+ FlowNodeTransitionData,
21
+ } from '@flowgram-vue/document';
22
+ import { type PlaygroundContribution, PlaygroundLayer } from '@flowgram-vue/core';
23
+
24
+ import { EndRegistry } from './activities/end';
25
+ import {
26
+ BlockIconRegistry,
27
+ BlockOrderIconRegistry,
28
+ BlockRegistry,
29
+ DynamicSplitRegistry,
30
+ EmptyRegistry,
31
+ InlineBlocksRegistry,
32
+ LoopRegistry,
33
+ RootRegistry,
34
+ StartRegistry,
35
+ StaticSplitRegistry,
36
+ TryCatchRegistry,
37
+ SimpleSplitRegistry,
38
+ BreakRegistry,
39
+ MultiOuputsRegistry,
40
+ MultiInputsRegistry,
41
+ InputRegistry,
42
+ OuputRegistry,
43
+ SlotRegistry,
44
+ SlotBlockRegistry,
45
+ } from './activities';
46
+
47
+ @injectable()
48
+ export class FlowRegisters
49
+ implements FlowDocumentContribution, FlowRendererContribution, PlaygroundContribution
50
+ {
51
+ /**
52
+ * 注册数据层
53
+ * @param document
54
+ */
55
+ registerDocument(document: FlowDocument) {
56
+ /**
57
+ * 注册节点 (ECS - Entity)
58
+ */
59
+ document.registerFlowNodes(
60
+ RootRegistry, // 根节点
61
+ StartRegistry, // 开始节点
62
+ DynamicSplitRegistry, // 动态分支(并行、排他)
63
+ StaticSplitRegistry, // 静态分支(审批)
64
+ SimpleSplitRegistry, // 简单分支 (不带 orderIcon 节点)
65
+ BlockRegistry, // 单条 block 注册
66
+ InlineBlocksRegistry, // 多个 block 组成的 block 列表
67
+ BlockIconRegistry, // icon 节点,如条件分支的菱形图标
68
+ BlockOrderIconRegistry, // 带顺序的图标节点,一般为 block 第一个分支节点
69
+ TryCatchRegistry, // TryCatch
70
+ EndRegistry, // 结束节点
71
+ LoopRegistry, // 循环节点
72
+ EmptyRegistry, // 占位节点
73
+ BreakRegistry, // 分支断开
74
+ MultiOuputsRegistry,
75
+ MultiInputsRegistry,
76
+ InputRegistry,
77
+ OuputRegistry,
78
+ SlotRegistry,
79
+ SlotBlockRegistry
80
+ );
81
+ /**
82
+ * 注册节点数据 (ECS - Component)
83
+ */
84
+ document.registerNodeDatas(
85
+ FlowNodeRenderData, // 渲染节点相关数据
86
+ FlowNodeTransitionData, // 线条绘制数据
87
+ FlowNodeTransformData // 坐标计算数据
88
+ );
89
+ }
90
+
91
+ /**
92
+ * 注册渲染层
93
+ * @param renderer
94
+ */
95
+ registerRenderer(renderer: FlowRendererRegistry) {
96
+ /**
97
+ * 注册 layer (ECS - System)
98
+ */
99
+ renderer.registerLayers(
100
+ FlowNodesTransformLayer, // 节点位置渲染
101
+ FlowNodesContentLayer, // 节点内容渲染
102
+ FlowLinesLayer, // 线条渲染
103
+ FlowLabelsLayer, // Label 渲染
104
+ PlaygroundLayer // 画布基础层,提供缩放、手势等能力
105
+ );
106
+ }
107
+
108
+ /**
109
+ * 画布开始渲染 (hook)
110
+ */
111
+ onReady(): void {}
112
+
113
+ /**
114
+ * 画布销毁 (hook)
115
+ */
116
+ onDispose(): void {}
117
+ }