@flowgram.ai/fixed-layout-core 0.1.0-alpha.10

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.
@@ -0,0 +1,1894 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
12
+ // src/fixed-layout-container-module.ts
13
+ import { ContainerModule } from "inversify";
14
+ import { FlowRendererContribution } from "@flowgram.ai/renderer";
15
+ import { FlowDocumentContribution } from "@flowgram.ai/document";
16
+ import { PlaygroundContribution } from "@flowgram.ai/core";
17
+ import { bindContributions } from "@flowgram.ai/utils";
18
+
19
+ // src/flow-registers.ts
20
+ import { injectable } from "inversify";
21
+ import {
22
+ FlowLabelsLayer,
23
+ FlowLinesLayer,
24
+ FlowNodesContentLayer,
25
+ FlowNodesTransformLayer
26
+ } from "@flowgram.ai/renderer";
27
+ import {
28
+ FlowNodeRenderData as FlowNodeRenderData4,
29
+ FlowNodeTransformData as FlowNodeTransformData3,
30
+ FlowNodeTransitionData
31
+ } from "@flowgram.ai/document";
32
+ import { PlaygroundLayer } from "@flowgram.ai/core";
33
+
34
+ // src/activities/end.ts
35
+ import { FlowNodeBaseType } from "@flowgram.ai/document";
36
+ var EndRegistry = {
37
+ type: FlowNodeBaseType.END,
38
+ meta: {
39
+ draggable: false,
40
+ isNodeEnd: true,
41
+ selectable: false,
42
+ copyDisable: true
43
+ },
44
+ // 结束节点没有出边和 label
45
+ getLines() {
46
+ return [];
47
+ },
48
+ getLabels() {
49
+ return [];
50
+ }
51
+ };
52
+
53
+ // src/activities/dynamic-split.ts
54
+ import {
55
+ FlowLayoutDefault,
56
+ FlowNodeSplitType,
57
+ FlowTransitionLabelEnum,
58
+ ConstantKeys,
59
+ getDefaultSpacing
60
+ } from "@flowgram.ai/document";
61
+ var DynamicSplitRegistry = {
62
+ type: FlowNodeSplitType.DYNAMIC_SPLIT,
63
+ meta: {
64
+ hidden: true,
65
+ inlineSpacingAfter: (node) => node.collapsed && node.entity.collapsedChildren.length > 1 ? 21 : 0,
66
+ // 判断是否有分支节点
67
+ spacing: (node) => {
68
+ const spacing = getDefaultSpacing(node.entity, ConstantKeys.NODE_SPACING);
69
+ return node.children.length === 1 ? spacing : spacing / 2;
70
+ }
71
+ },
72
+ getLabels(transition) {
73
+ if (transition.isNodeEnd) {
74
+ return [];
75
+ }
76
+ return [
77
+ {
78
+ type: FlowTransitionLabelEnum.ADDER_LABEL,
79
+ offset: transition.transform.outputPoint
80
+ }
81
+ ];
82
+ },
83
+ onCreate(node, json) {
84
+ return node.document.addInlineBlocks(node, json.blocks || []);
85
+ },
86
+ getInputPoint(transform) {
87
+ return transform.firstChild?.inputPoint || transform.defaultInputPoint;
88
+ },
89
+ getOutputPoint(transform, layout) {
90
+ const isVertical = FlowLayoutDefault.isVertical(layout);
91
+ const noInlineBlocks = transform.children.length === 1;
92
+ const lastChildOutput = transform.lastChild?.outputPoint;
93
+ const spacing = getDefaultSpacing(transform.entity, ConstantKeys.NODE_SPACING);
94
+ if (isVertical) {
95
+ return {
96
+ x: lastChildOutput ? lastChildOutput.x : transform.bounds.center.x,
97
+ y: transform.bounds.bottom + (noInlineBlocks ? spacing / 2 : 0)
98
+ };
99
+ }
100
+ return {
101
+ x: transform.bounds.right + (noInlineBlocks ? spacing / 2 : 0),
102
+ y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
103
+ };
104
+ },
105
+ /**
106
+ * @depreacted
107
+ */
108
+ addChild(node, json, options = {}) {
109
+ const { index } = options;
110
+ const document = node.document;
111
+ const parentId = `$inlineBlocks$${node.id}`;
112
+ let parent = document.getNode(parentId);
113
+ if (!parent) {
114
+ parent = document.addNode({
115
+ id: parentId,
116
+ type: "inlineBlocks",
117
+ originParent: node,
118
+ parent: node
119
+ });
120
+ }
121
+ return document.addBlock(node, json, void 0, void 0, index);
122
+ }
123
+ };
124
+
125
+ // src/activities/static-split.ts
126
+ import { FlowNodeBaseType as FlowNodeBaseType2, FlowNodeSplitType as FlowNodeSplitType2 } from "@flowgram.ai/document";
127
+ var StaticSplitRegistry = {
128
+ extend: FlowNodeSplitType2.DYNAMIC_SPLIT,
129
+ type: FlowNodeSplitType2.STATIC_SPLIT,
130
+ extendChildRegistries: [
131
+ {
132
+ type: FlowNodeBaseType2.INLINE_BLOCKS,
133
+ getLabels() {
134
+ return [];
135
+ }
136
+ }
137
+ ]
138
+ };
139
+
140
+ // src/activities/block.ts
141
+ import {
142
+ DEFAULT_SPACING,
143
+ FlowLayoutDefault as FlowLayoutDefault2,
144
+ FlowNodeBaseType as FlowNodeBaseType3,
145
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum2,
146
+ FlowTransitionLineEnum,
147
+ LABEL_SIDE_TYPE
148
+ } from "@flowgram.ai/document";
149
+ var BlockRegistry = {
150
+ type: FlowNodeBaseType3.BLOCK,
151
+ meta: {
152
+ spacing: DEFAULT_SPACING.NULL,
153
+ inlineSpacingAfter: DEFAULT_SPACING.INLINE_BLOCK_PADDING_BOTTOM,
154
+ hidden: true
155
+ },
156
+ getLines(transition) {
157
+ const currentTransform = transition.transform;
158
+ const { isVertical } = transition.entity;
159
+ const lines = [
160
+ {
161
+ type: FlowTransitionLineEnum.DIVERGE_LINE,
162
+ from: currentTransform.parent.inputPoint,
163
+ to: currentTransform.inputPoint,
164
+ side: LABEL_SIDE_TYPE.NORMAL_BRANCH
165
+ }
166
+ ];
167
+ const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
168
+ if (hasBranchDraggingAdder) {
169
+ if (isVertical) {
170
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
171
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
172
+ const currentInputPointY = currentTransform.inputPoint.y;
173
+ if (currentTransform?.next) {
174
+ lines.push({
175
+ type: FlowTransitionLineEnum.DRAGGING_LINE,
176
+ from: currentTransform.parent.inputPoint,
177
+ to: {
178
+ x: (currentOffsetRightX + nextOffsetLeftX) / 2,
179
+ y: currentInputPointY
180
+ },
181
+ side: LABEL_SIDE_TYPE.NORMAL_BRANCH
182
+ });
183
+ }
184
+ } else {
185
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
186
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
187
+ const currentInputPointX = currentTransform.inputPoint.x;
188
+ if (currentTransform?.next) {
189
+ lines.push({
190
+ type: FlowTransitionLineEnum.DRAGGING_LINE,
191
+ from: currentTransform.parent.inputPoint,
192
+ to: {
193
+ x: currentInputPointX,
194
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
195
+ },
196
+ side: LABEL_SIDE_TYPE.NORMAL_BRANCH
197
+ });
198
+ }
199
+ }
200
+ }
201
+ if (!transition.isNodeEnd) {
202
+ lines.push({
203
+ type: FlowTransitionLineEnum.MERGE_LINE,
204
+ from: currentTransform.outputPoint,
205
+ to: currentTransform.parent.outputPoint,
206
+ side: LABEL_SIDE_TYPE.NORMAL_BRANCH
207
+ });
208
+ }
209
+ return lines;
210
+ },
211
+ getInputPoint(trans) {
212
+ const child = trans.firstChild;
213
+ return child ? child.inputPoint : trans.defaultInputPoint;
214
+ },
215
+ getOutputPoint(trans, layout) {
216
+ const isVertical = FlowLayoutDefault2.isVertical(layout);
217
+ const child = trans.lastChild;
218
+ if (isVertical) {
219
+ return {
220
+ x: child ? child.outputPoint.x : trans.bounds.bottomCenter.x,
221
+ y: trans.bounds.bottom
222
+ };
223
+ }
224
+ return {
225
+ x: trans.bounds.right,
226
+ y: child ? child.outputPoint.y : trans.bounds.rightCenter.y
227
+ };
228
+ },
229
+ getLabels(transition) {
230
+ const currentTransform = transition.transform;
231
+ const { isVertical } = transition.entity;
232
+ const draggingLabel = [];
233
+ const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
234
+ if (hasBranchDraggingAdder) {
235
+ if (isVertical) {
236
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
237
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
238
+ const currentInputPointY = currentTransform.inputPoint.y;
239
+ if (currentTransform?.next) {
240
+ draggingLabel.push({
241
+ offset: {
242
+ x: (currentOffsetRightX + nextOffsetLeftX) / 2,
243
+ y: currentInputPointY
244
+ },
245
+ type: FlowTransitionLabelEnum2.BRANCH_DRAGGING_LABEL,
246
+ width: nextOffsetLeftX - currentOffsetRightX,
247
+ props: {
248
+ side: LABEL_SIDE_TYPE.NORMAL_BRANCH
249
+ }
250
+ });
251
+ }
252
+ } else {
253
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
254
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
255
+ const currentInputPointX = currentTransform.inputPoint.x;
256
+ if (currentTransform?.next) {
257
+ draggingLabel.push({
258
+ offset: {
259
+ x: currentInputPointX,
260
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
261
+ },
262
+ type: FlowTransitionLabelEnum2.BRANCH_DRAGGING_LABEL,
263
+ width: nextOffsetTopX - currentOffsetBottomX,
264
+ props: {
265
+ side: LABEL_SIDE_TYPE.NORMAL_BRANCH
266
+ }
267
+ });
268
+ }
269
+ }
270
+ }
271
+ return [...draggingLabel];
272
+ },
273
+ /**
274
+ * @depreacted
275
+ */
276
+ addChild(node, json, options = {}) {
277
+ const { index } = options;
278
+ const document = node.document;
279
+ return document.addNode({
280
+ ...json,
281
+ ...options,
282
+ parent: node,
283
+ index: typeof index === "number" ? index + 1 : void 0
284
+ });
285
+ }
286
+ };
287
+
288
+ // src/activities/inline-blocks.ts
289
+ import { Point } from "@flowgram.ai/utils";
290
+ import { FlowRendererKey } from "@flowgram.ai/renderer";
291
+ import {
292
+ DEFAULT_SPACING as DEFAULT_SPACING2,
293
+ FlowNodeBaseType as FlowNodeBaseType4,
294
+ FlowNodeRenderData,
295
+ FlowNodeTransformData,
296
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum3,
297
+ FlowLayoutDefault as FlowLayoutDefault3,
298
+ ConstantKeys as ConstantKeys2,
299
+ getDefaultSpacing as getDefaultSpacing2
300
+ } from "@flowgram.ai/document";
301
+ var InlineBlocksRegistry = {
302
+ type: FlowNodeBaseType4.INLINE_BLOCKS,
303
+ meta: {
304
+ hidden: true,
305
+ spacing: (node) => getDefaultSpacing2(node.entity, ConstantKeys2.NODE_SPACING),
306
+ isInlineBlocks: true,
307
+ inlineSpacingPre: (node) => getDefaultSpacing2(node.entity, ConstantKeys2.INLINE_BLOCKS_PADDING_TOP) || DEFAULT_SPACING2.INLINE_BLOCKS_PADDING_TOP,
308
+ inlineSpacingAfter: (node) => getDefaultSpacing2(node.entity, ConstantKeys2.INLINE_BLOCKS_PADDING_BOTTOM)
309
+ },
310
+ /**
311
+ * 控制子分支的间距
312
+ * @param child
313
+ */
314
+ getChildDelta(child, layout) {
315
+ const isVertical = FlowLayoutDefault3.isVertical(layout);
316
+ const preTransform = child.entity.pre?.getData(FlowNodeTransformData);
317
+ if (preTransform) {
318
+ const { localBounds: preBounds } = preTransform;
319
+ if (isVertical) {
320
+ const leftSpacing = preTransform.size.width + preTransform.originDeltaX;
321
+ const delta = Math.max(
322
+ child.parent.minInlineBlockSpacing - leftSpacing,
323
+ getDefaultSpacing2(child.entity, ConstantKeys2.BRANCH_SPACING) - child.originDeltaX
324
+ );
325
+ return {
326
+ // 这里需要加上原点的偏移量,并加上水平间距
327
+ x: preBounds.right + delta,
328
+ y: 0
329
+ };
330
+ } else {
331
+ const bottomSpacing = preTransform.size.height + preTransform.originDeltaY;
332
+ const delta = Math.max(
333
+ child.parent.minInlineBlockSpacing - bottomSpacing,
334
+ getDefaultSpacing2(child.entity, ConstantKeys2.BRANCH_SPACING) - child.originDeltaY
335
+ );
336
+ return {
337
+ x: 0,
338
+ // 这里需要加上原点的偏移量,并加上垂直间距
339
+ y: preBounds.bottom + delta
340
+ };
341
+ }
342
+ }
343
+ return {
344
+ x: 0,
345
+ y: 0
346
+ };
347
+ },
348
+ /**
349
+ * 控制条件分支居中布局
350
+ * @param trans
351
+ */
352
+ getDelta(trans, layout) {
353
+ const isVertical = FlowLayoutDefault3.isVertical(layout);
354
+ const { pre, collapsed } = trans;
355
+ if (collapsed) {
356
+ return { x: 0, y: 0 };
357
+ }
358
+ if (isVertical) {
359
+ const preCenter2 = pre.localBounds.center.x;
360
+ const firstBlockX = trans.firstChild?.transform.position.x || 0;
361
+ const lastBlockX = trans.lastChild?.transform.position.x || 0;
362
+ const currentCenter2 = (lastBlockX - firstBlockX) / 2;
363
+ return {
364
+ x: preCenter2 - currentCenter2,
365
+ y: 0
366
+ };
367
+ }
368
+ const preCenter = pre.localBounds.center.y;
369
+ const firstBlockY = trans.firstChild?.transform.position.y || 0;
370
+ const lastBlockY = trans.lastChild?.transform.position.y || 0;
371
+ const currentCenter = (lastBlockY - firstBlockY) / 2;
372
+ return {
373
+ x: 0,
374
+ y: preCenter - currentCenter
375
+ };
376
+ },
377
+ getLabels(transition) {
378
+ return getBranchAdderLabel(transition);
379
+ },
380
+ getLines() {
381
+ return [];
382
+ },
383
+ // 和前序节点对齐
384
+ getInputPoint(transform, layout) {
385
+ const isVertical = FlowLayoutDefault3.isVertical(layout);
386
+ if (isVertical) {
387
+ return {
388
+ x: transform.pre?.outputPoint.x || 0,
389
+ y: transform.bounds.top
390
+ };
391
+ }
392
+ return {
393
+ x: transform.bounds.left,
394
+ y: transform.pre?.outputPoint.y || 0
395
+ };
396
+ },
397
+ getOutputPoint(transform, layout) {
398
+ const isVertical = FlowLayoutDefault3.isVertical(layout);
399
+ if (transform.collapsed) {
400
+ return transform.inputPoint;
401
+ }
402
+ if (isVertical) {
403
+ return {
404
+ x: transform.pre?.outputPoint.x || 0,
405
+ y: transform.bounds.bottom
406
+ };
407
+ }
408
+ return {
409
+ x: transform.bounds.right,
410
+ y: transform.pre?.outputPoint.y || 0
411
+ };
412
+ }
413
+ };
414
+ function getBranchAdderLabel(transition) {
415
+ const { isVertical } = transition.entity;
416
+ const currentTransform = transition.transform;
417
+ if (currentTransform.collapsed) {
418
+ return [
419
+ {
420
+ type: FlowTransitionLabelEnum3.COLLAPSE_LABEL,
421
+ offset: Point.move(currentTransform.inputPoint, isVertical ? { y: 10 } : { x: 10 }),
422
+ props: {
423
+ activateNode: transition.entity.pre
424
+ }
425
+ }
426
+ ];
427
+ }
428
+ return [
429
+ {
430
+ type: FlowTransitionLabelEnum3.CUSTOM_LABEL,
431
+ renderKey: FlowRendererKey.BRANCH_ADDER,
432
+ offset: Point.move(currentTransform.inputPoint, isVertical ? { y: 10 } : { x: 10 }),
433
+ props: {
434
+ // 激活状态
435
+ activated: transition.entity.getData(FlowNodeRenderData).activated,
436
+ transform: currentTransform,
437
+ // 传给外部使用的 node 信息
438
+ node: currentTransform.originParent?.entity
439
+ }
440
+ }
441
+ ];
442
+ }
443
+
444
+ // src/activities/block-icon.ts
445
+ import { Point as Point2 } from "@flowgram.ai/utils";
446
+ import { DefaultSpacingKey, getDefaultSpacing as getDefaultSpacing3 } from "@flowgram.ai/document";
447
+ import {
448
+ FlowNodeBaseType as FlowNodeBaseType5,
449
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum4
450
+ } from "@flowgram.ai/document";
451
+ var BlockIconRegistry = {
452
+ type: FlowNodeBaseType5.BLOCK_ICON,
453
+ meta: {
454
+ spacing: 20,
455
+ // 占位节点下边偏小
456
+ // 条件分支 icon 默认的高度比较高,在流程里下边有文字
457
+ size: { width: 250, height: 84 }
458
+ },
459
+ /**
460
+ * 是一个占位节点,后续要加上 label 展开收起的图标
461
+ */
462
+ getLabels(transition) {
463
+ const currentTransform = transition.transform;
464
+ const { isVertical } = transition.entity;
465
+ if (transition.entity.parent.collapsedChildren.length <= 1) {
466
+ return [];
467
+ }
468
+ const collapsedSpacing = getDefaultSpacing3(
469
+ transition.entity,
470
+ DefaultSpacingKey.COLLAPSED_SPACING
471
+ );
472
+ return [
473
+ {
474
+ type: FlowTransitionLabelEnum4.COLLAPSE_LABEL,
475
+ offset: Point2.move(
476
+ currentTransform.outputPoint,
477
+ isVertical ? { y: collapsedSpacing } : { x: collapsedSpacing }
478
+ ),
479
+ props: {
480
+ collapseNode: transition.entity.parent,
481
+ activateNode: transition.entity
482
+ }
483
+ }
484
+ ];
485
+ }
486
+ };
487
+
488
+ // src/activities/block-order-icon.ts
489
+ import { Point as Point3 } from "@flowgram.ai/utils";
490
+ import { DefaultSpacingKey as DefaultSpacingKey2, getDefaultSpacing as getDefaultSpacing4 } from "@flowgram.ai/document";
491
+ import {
492
+ FlowNodeBaseType as FlowNodeBaseType6,
493
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum5
494
+ } from "@flowgram.ai/document";
495
+ var BlockOrderIconRegistry = {
496
+ type: FlowNodeBaseType6.BLOCK_ORDER_ICON,
497
+ meta: {
498
+ spacing: 40
499
+ },
500
+ getLabels(transition) {
501
+ const currentTransform = transition.transform;
502
+ const { isVertical } = transition.entity;
503
+ const currentOutput = currentTransform.outputPoint;
504
+ const nextTransform = currentTransform.next;
505
+ const parentTransform = currentTransform.parent;
506
+ if (transition.entity.parent.collapsedChildren.length <= 1) {
507
+ const parentOutput = parentTransform?.outputPoint;
508
+ return [
509
+ {
510
+ offset: parentOutput,
511
+ type: FlowTransitionLabelEnum5.ADDER_LABEL
512
+ }
513
+ ];
514
+ }
515
+ const collapsedSpacing = getDefaultSpacing4(
516
+ transition.entity,
517
+ DefaultSpacingKey2.COLLAPSED_SPACING
518
+ );
519
+ return [
520
+ {
521
+ offset: nextTransform ? Point3.getMiddlePoint(currentOutput, nextTransform.inputPoint) : Point3.move(
522
+ currentOutput,
523
+ isVertical ? { y: collapsedSpacing } : { x: collapsedSpacing }
524
+ ),
525
+ // 收起展开复合按钮
526
+ type: FlowTransitionLabelEnum5.COLLAPSE_ADDER_LABEL,
527
+ props: {
528
+ activateNode: transition.entity,
529
+ collapseNode: transition.entity.parent
530
+ }
531
+ }
532
+ ];
533
+ }
534
+ };
535
+
536
+ // src/activities/start.ts
537
+ import { FlowNodeBaseType as FlowNodeBaseType7 } from "@flowgram.ai/document";
538
+ var StartRegistry = {
539
+ type: FlowNodeBaseType7.START,
540
+ meta: {
541
+ isStart: true,
542
+ draggable: false,
543
+ selectable: false,
544
+ // 触发器等开始节点不能被框选
545
+ deleteDisable: true,
546
+ // 禁止删除
547
+ copyDisable: true,
548
+ // 禁止copy
549
+ addDisable: true
550
+ // 禁止添加
551
+ }
552
+ };
553
+
554
+ // src/activities/try-catch.ts
555
+ import {
556
+ FlowLayoutDefault as FlowLayoutDefault6,
557
+ FlowNodeBaseType as FlowNodeBaseType12
558
+ } from "@flowgram.ai/document";
559
+
560
+ // src/activities/try-catch-extends/catch-block.ts
561
+ import {
562
+ DEFAULT_SPACING as DEFAULT_SPACING3,
563
+ FlowNodeBaseType as FlowNodeBaseType8,
564
+ FlowTransitionLineEnum as FlowTransitionLineEnum2
565
+ } from "@flowgram.ai/document";
566
+ var CatchBlockRegistry = {
567
+ extend: FlowNodeBaseType8.BLOCK,
568
+ type: "catchBlock" /* CATCH_BLOCK */,
569
+ meta: {
570
+ hidden: true,
571
+ spacing: DEFAULT_SPACING3.NULL
572
+ },
573
+ getLines(transition) {
574
+ const { transform } = transition;
575
+ const { isVertical } = transition.entity;
576
+ const parentPoint = transform.parent;
577
+ const { inputPoint, outputPoint } = transform;
578
+ let parentInputPoint;
579
+ if (isVertical) {
580
+ parentInputPoint = {
581
+ x: parentPoint.inputPoint.x,
582
+ y: parentPoint.inputPoint.y - 20 /* CATCH_INLINE_SPACING */
583
+ };
584
+ } else {
585
+ parentInputPoint = {
586
+ x: parentPoint.inputPoint.x - 20 /* CATCH_INLINE_SPACING */,
587
+ y: parentPoint.inputPoint.y
588
+ };
589
+ }
590
+ const lines = [
591
+ {
592
+ type: FlowTransitionLineEnum2.DIVERGE_LINE,
593
+ from: parentInputPoint,
594
+ to: inputPoint
595
+ }
596
+ ];
597
+ if (!transition.isNodeEnd) {
598
+ let mergePoint;
599
+ if (isVertical) {
600
+ mergePoint = {
601
+ x: parentPoint.outputPoint.x,
602
+ y: parentPoint.bounds.bottom
603
+ };
604
+ } else {
605
+ mergePoint = {
606
+ x: parentPoint.bounds.right,
607
+ y: parentPoint.outputPoint.y
608
+ };
609
+ }
610
+ lines.push({
611
+ type: FlowTransitionLineEnum2.MERGE_LINE,
612
+ from: outputPoint,
613
+ to: mergePoint
614
+ });
615
+ }
616
+ return lines;
617
+ },
618
+ getLabels() {
619
+ return [];
620
+ }
621
+ };
622
+
623
+ // src/activities/try-catch-extends/catch-inline-blocks.ts
624
+ import { FlowRendererKey as FlowRendererKey2 } from "@flowgram.ai/renderer";
625
+ import {
626
+ DEFAULT_SPACING as DEFAULT_SPACING4,
627
+ FlowNodeBaseType as FlowNodeBaseType9,
628
+ FlowNodeRenderData as FlowNodeRenderData2,
629
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum6,
630
+ FlowTransitionLineEnum as FlowTransitionLineEnum3,
631
+ FlowLayoutDefault as FlowLayoutDefault4
632
+ } from "@flowgram.ai/document";
633
+ var CatchInlineBlocksRegistry = {
634
+ extend: FlowNodeBaseType9.INLINE_BLOCKS,
635
+ type: "catchInlineBlocks" /* CATCH_INLINE_BLOCKS */,
636
+ meta: {
637
+ spacing: DEFAULT_SPACING4.NULL,
638
+ inlineSpacingPre: DEFAULT_SPACING4.NULL
639
+ // inlineSpacingAfter: DEFAULT_SPACING.NULL,
640
+ },
641
+ getDelta() {
642
+ return void 0;
643
+ },
644
+ getLines(transition) {
645
+ const { transform } = transition;
646
+ const mainInlineBlocks = transform.parent;
647
+ const lines = [
648
+ {
649
+ type: FlowTransitionLineEnum3.DIVERGE_LINE,
650
+ from: mainInlineBlocks.pre.outputPoint,
651
+ to: transform.inputPoint
652
+ }
653
+ ];
654
+ if (!transform.entity.isNodeEnd) {
655
+ lines.push({
656
+ type: FlowTransitionLineEnum3.MERGE_LINE,
657
+ from: transform.outputPoint,
658
+ to: mainInlineBlocks.outputPoint
659
+ });
660
+ }
661
+ return lines;
662
+ },
663
+ getOriginDeltaX(transform) {
664
+ const { firstChild } = transform;
665
+ if (!firstChild) return 0;
666
+ return firstChild.originDeltaX;
667
+ },
668
+ getLabels(transition) {
669
+ const { inputPoint } = transition.transform;
670
+ const { isVertical } = transition.entity;
671
+ const currentTransform = transition.transform;
672
+ const actualInputPoint = {
673
+ x: isVertical ? inputPoint.x : inputPoint.x - 20 /* CATCH_INLINE_SPACING */,
674
+ y: isVertical ? inputPoint.y - 20 /* CATCH_INLINE_SPACING */ : inputPoint.y
675
+ };
676
+ if (currentTransform.collapsed) {
677
+ return [];
678
+ }
679
+ return [
680
+ {
681
+ type: FlowTransitionLabelEnum6.CUSTOM_LABEL,
682
+ renderKey: FlowRendererKey2.BRANCH_ADDER,
683
+ offset: actualInputPoint,
684
+ props: {
685
+ // 激活状态
686
+ activated: transition.entity.getData(FlowNodeRenderData2).activated,
687
+ transform: currentTransform,
688
+ // 传给外部使用的 node 信息
689
+ node: currentTransform.originParent?.entity
690
+ }
691
+ }
692
+ ];
693
+ },
694
+ getInputPoint(transform, layout) {
695
+ const isVertical = FlowLayoutDefault4.isVertical(layout);
696
+ const firstCatchBlock = transform.firstChild;
697
+ if (firstCatchBlock) {
698
+ return firstCatchBlock.inputPoint;
699
+ }
700
+ return isVertical ? transform.bounds.topCenter : transform.bounds.rightCenter;
701
+ },
702
+ getOutputPoint(transform, layout) {
703
+ const isVertical = FlowLayoutDefault4.isVertical(layout);
704
+ if (transform.collapsed) {
705
+ return transform.inputPoint;
706
+ }
707
+ const firstCatchBlock = transform.firstChild;
708
+ if (firstCatchBlock) {
709
+ return isVertical ? {
710
+ x: firstCatchBlock.outputPoint?.x,
711
+ y: transform.bounds.bottom
712
+ } : {
713
+ x: transform.bounds.right,
714
+ y: firstCatchBlock.outputPoint?.y
715
+ };
716
+ }
717
+ return isVertical ? transform.bounds.bottomCenter : transform.bounds.rightCenter;
718
+ }
719
+ };
720
+
721
+ // src/activities/try-catch-extends/main-inline-blocks.ts
722
+ import { FlowRendererKey as FlowRendererKey3, FlowTextKey } from "@flowgram.ai/renderer";
723
+ import {
724
+ FlowNodeBaseType as FlowNodeBaseType10,
725
+ FlowNodeTransformData as FlowNodeTransformData2,
726
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum7,
727
+ FlowTransitionLineEnum as FlowTransitionLineEnum4,
728
+ FlowLayoutDefault as FlowLayoutDefault5,
729
+ getDefaultSpacing as getDefaultSpacing5,
730
+ ConstantKeys as ConstantKeys3
731
+ } from "@flowgram.ai/document";
732
+ var MainInlineBlocksRegistry = {
733
+ extend: FlowNodeBaseType10.INLINE_BLOCKS,
734
+ type: "mainInlineBlocks" /* MAIN_INLINE_BLOCKS */,
735
+ meta: {
736
+ inlineSpacingPre: 20 /* MAIN_INLINE_SPACING_TOP */,
737
+ inlineSpacingAfter: 40 /* MAIN_INLINE_SPACING_BOTTOM */
738
+ },
739
+ getLines(transition) {
740
+ const { transform } = transition;
741
+ const tryBranch = transform.firstChild;
742
+ const lines = [
743
+ {
744
+ type: FlowTransitionLineEnum4.STRAIGHT_LINE,
745
+ from: tryBranch.outputPoint,
746
+ to: transform.originParent.outputPoint
747
+ }
748
+ ];
749
+ return lines;
750
+ },
751
+ getLabels(transition) {
752
+ const { transform } = transition;
753
+ const { isVertical } = transition.entity;
754
+ const catchInlineBlocks = transform.children[1];
755
+ const errLabelX = isVertical ? (transform.parent.outputPoint.x + catchInlineBlocks.inputPoint.x) / 2 : transform.inputPoint.x - 54 /* INLINE_SPACING_TOP */;
756
+ const errLabelY = isVertical ? transform.inputPoint.y - 54 /* INLINE_SPACING_TOP */ : (transform.parent.outputPoint.y + catchInlineBlocks.inputPoint.y) / 2;
757
+ const errorLabelX = errLabelX;
758
+ const errorLabelY = errLabelY;
759
+ return [
760
+ {
761
+ type: FlowTransitionLabelEnum7.TEXT_LABEL,
762
+ renderKey: FlowTextKey.TRY_START_TEXT,
763
+ offset: {
764
+ x: isVertical ? transform.inputPoint.x : transform.inputPoint.x + -20 /* TRY_START_LABEL_DELTA */,
765
+ y: isVertical ? transform.inputPoint.y + -20 /* TRY_START_LABEL_DELTA */ : transform.inputPoint.y
766
+ }
767
+ },
768
+ {
769
+ type: FlowTransitionLabelEnum7.TEXT_LABEL,
770
+ renderKey: FlowTextKey.TRY_END_TEXT,
771
+ offset: {
772
+ x: isVertical ? transform.inputPoint.x : transform.originParent.outputPoint.x + -20 /* TRY_END_LABEL_DELTA */,
773
+ y: isVertical ? transform.originParent.outputPoint.y + -20 /* TRY_END_LABEL_DELTA */ : transform.inputPoint.y
774
+ }
775
+ },
776
+ // 错误分支收起
777
+ {
778
+ type: FlowTransitionLabelEnum7.CUSTOM_LABEL,
779
+ renderKey: FlowRendererKey3.TRY_CATCH_COLLAPSE,
780
+ offset: {
781
+ x: errorLabelX,
782
+ y: errorLabelY
783
+ },
784
+ props: {
785
+ node: transform.lastChild?.entity
786
+ }
787
+ }
788
+ ];
789
+ },
790
+ getInputPoint(transform) {
791
+ const tryBlock = transform.firstChild;
792
+ return tryBlock.inputPoint;
793
+ },
794
+ getOutputPoint(transform, layout) {
795
+ const tryBlock = transform.firstChild;
796
+ const isVertical = FlowLayoutDefault5.isVertical(layout);
797
+ if (isVertical) {
798
+ return {
799
+ x: tryBlock.outputPoint.x,
800
+ y: transform.bounds.bottom + 20 /* CATCH_INLINE_SPACING */
801
+ };
802
+ }
803
+ return {
804
+ x: transform.bounds.right + 20 /* CATCH_INLINE_SPACING */,
805
+ y: tryBlock.outputPoint.y
806
+ };
807
+ },
808
+ getDelta() {
809
+ return void 0;
810
+ },
811
+ getChildDelta(child, layout) {
812
+ const preTransform = child.entity.pre?.getData(FlowNodeTransformData2);
813
+ const isVertical = FlowLayoutDefault5.isVertical(layout);
814
+ if (preTransform) {
815
+ const { localBounds: preBounds } = preTransform;
816
+ let delta = 0;
817
+ if (isVertical) {
818
+ delta = Math.max(
819
+ child.parent.minInlineBlockSpacing,
820
+ -child.originDeltaX + getDefaultSpacing5(child.entity, ConstantKeys3.BRANCH_SPACING)
821
+ );
822
+ } else {
823
+ delta = Math.max(
824
+ child.parent.minInlineBlockSpacing,
825
+ -child.originDeltaY + getDefaultSpacing5(child.entity, ConstantKeys3.BRANCH_SPACING)
826
+ );
827
+ }
828
+ return {
829
+ // 分支只有两个所以这里可以写死间隔宽度
830
+ x: isVertical ? preBounds.right + delta : 0,
831
+ y: isVertical ? 0 : preBounds.bottom + delta
832
+ };
833
+ }
834
+ return {
835
+ x: 0,
836
+ y: 0
837
+ };
838
+ }
839
+ };
840
+
841
+ // src/activities/try-catch-extends/try-block.ts
842
+ import { DEFAULT_SPACING as DEFAULT_SPACING5, FlowNodeBaseType as FlowNodeBaseType11 } from "@flowgram.ai/document";
843
+ var TryBlockRegistry = {
844
+ extend: FlowNodeBaseType11.BLOCK,
845
+ type: "tryBlock" /* TRY_BLOCK */,
846
+ meta: {
847
+ hidden: true,
848
+ spacing: DEFAULT_SPACING5.NULL
849
+ },
850
+ getLines() {
851
+ return [];
852
+ },
853
+ getLabels() {
854
+ return [];
855
+ }
856
+ };
857
+
858
+ // src/activities/try-catch-extends/try-slot.ts
859
+ import { FlowTransitionLabelEnum as FlowTransitionLabelEnum8 } from "@flowgram.ai/document";
860
+ var TrySlotRegistry = {
861
+ type: "trySlot" /* TRY_SLOT */,
862
+ meta: {
863
+ inlineSpacingAfter: 16,
864
+ spacing: 0,
865
+ size: {
866
+ width: 16,
867
+ height: 0
868
+ }
869
+ },
870
+ onAfterUpdateLocalTransform(transform) {
871
+ if (transform.entity.isVertical) {
872
+ transform.data.size = {
873
+ width: 16,
874
+ height: 0
875
+ };
876
+ } else {
877
+ transform.data.size = {
878
+ width: 0,
879
+ height: 16
880
+ };
881
+ }
882
+ transform.transform.update({
883
+ size: transform.data.size
884
+ });
885
+ },
886
+ getLabels(transition) {
887
+ return [
888
+ {
889
+ offset: transition.transform.bounds.center,
890
+ type: FlowTransitionLabelEnum8.ADDER_LABEL
891
+ }
892
+ ];
893
+ }
894
+ };
895
+
896
+ // src/activities/try-catch.ts
897
+ var TryCatchRegistry = {
898
+ type: "tryCatch",
899
+ meta: {
900
+ hidden: true,
901
+ inlineSpacingAfter: 0 /* INLINE_SPACING_BOTTOM */
902
+ },
903
+ /**
904
+ * 结构
905
+ * tryCatch
906
+ * - tryCatchIcon
907
+ * - mainInlineBlocks
908
+ * - tryBlock // try 分支
909
+ * - trySlot // 空节点用来占位,try 分支一开始没有节点
910
+ * - catchInlineBlocks
911
+ * - catchBlock // catch 分支 1
912
+ * - blockOrderIcon
913
+ * - node1
914
+ * - catchBlock // catch 分支 2
915
+ * - blockOrderIcon
916
+ * - node 2
917
+ * @param node
918
+ * @param json
919
+ */
920
+ onCreate(node, json) {
921
+ const { document } = node;
922
+ const [tryBlock, ...catchBlocks] = json.blocks || [];
923
+ const addedNodes = [];
924
+ const tryCatchIconNode = document.addNode({
925
+ id: `$tryCatchIcon$${node.id}`,
926
+ type: FlowNodeBaseType12.BLOCK_ICON,
927
+ originParent: node,
928
+ parent: node
929
+ });
930
+ const mainBlockNode = document.addNode({
931
+ id: `$mainInlineBlocks$${node.id}`,
932
+ type: "mainInlineBlocks" /* MAIN_INLINE_BLOCKS */,
933
+ originParent: node,
934
+ parent: node
935
+ });
936
+ const tryBlockNode = document.addNode({
937
+ id: tryBlock.id,
938
+ type: tryBlock.type || "tryBlock" /* TRY_BLOCK */,
939
+ originParent: node,
940
+ parent: mainBlockNode,
941
+ data: tryBlock.data
942
+ });
943
+ const trySlotNode = document.addNode({
944
+ id: `$trySlot$${tryBlock.id}`,
945
+ hidden: true,
946
+ type: "trySlot" /* TRY_SLOT */,
947
+ // 占位节点
948
+ originParent: node,
949
+ parent: tryBlockNode
950
+ });
951
+ const catchInlineBlocksNode = document.addNode({
952
+ id: `$catchInlineBlocks$${node.id}`,
953
+ type: "catchInlineBlocks" /* CATCH_INLINE_BLOCKS */,
954
+ originParent: node,
955
+ parent: mainBlockNode
956
+ });
957
+ addedNodes.push(
958
+ tryCatchIconNode,
959
+ mainBlockNode,
960
+ tryBlockNode,
961
+ trySlotNode,
962
+ catchInlineBlocksNode
963
+ );
964
+ (tryBlock.blocks || []).forEach((blockData) => {
965
+ document.addNode(
966
+ {
967
+ ...blockData,
968
+ parent: tryBlockNode
969
+ },
970
+ addedNodes
971
+ );
972
+ });
973
+ catchBlocks.forEach((blockData) => {
974
+ document.addBlock(node, blockData, addedNodes);
975
+ });
976
+ return addedNodes;
977
+ },
978
+ /**
979
+ * 添加 catch 分支
980
+ * @param node
981
+ * @param blockData
982
+ * @param addedNodes
983
+ */
984
+ onBlockChildCreate(node, blockData, addedNodes) {
985
+ const parent = node.document.getNode(`$catchInlineBlocks$${node.id}`);
986
+ const block = node.document.addNode({
987
+ id: blockData.id,
988
+ type: blockData.type || "catchBlock" /* CATCH_BLOCK */,
989
+ originParent: node,
990
+ parent,
991
+ data: blockData.data
992
+ });
993
+ const blockOrderIcon = node.document.addNode({
994
+ id: `$blockOrderIcon$${blockData.id}`,
995
+ type: FlowNodeBaseType12.BLOCK_ORDER_ICON,
996
+ originParent: node,
997
+ parent: block
998
+ });
999
+ if (blockData.blocks) {
1000
+ node.document.addBlocksAsChildren(block, blockData.blocks || [], addedNodes);
1001
+ }
1002
+ addedNodes?.push(block, blockOrderIcon);
1003
+ return block;
1004
+ },
1005
+ getInputPoint(transform) {
1006
+ const tryCatchIcon = transform.firstChild;
1007
+ return tryCatchIcon.inputPoint;
1008
+ },
1009
+ getOutputPoint(transform, layout) {
1010
+ const isVertical = FlowLayoutDefault6.isVertical(layout);
1011
+ const tryCatchIcon = transform.firstChild;
1012
+ if (isVertical) {
1013
+ return {
1014
+ x: tryCatchIcon.inputPoint.x,
1015
+ y: transform.bounds.bottom
1016
+ };
1017
+ }
1018
+ return {
1019
+ x: transform.bounds.right,
1020
+ y: tryCatchIcon.inputPoint.y
1021
+ };
1022
+ },
1023
+ /**
1024
+ * tryCatch 子节点配置
1025
+ */
1026
+ extendChildRegistries: [
1027
+ /**
1028
+ * icon 节点
1029
+ */
1030
+ {
1031
+ type: FlowNodeBaseType12.BLOCK_ICON,
1032
+ meta: {
1033
+ spacing: 54 /* INLINE_SPACING_TOP */
1034
+ },
1035
+ getLabels() {
1036
+ return [];
1037
+ }
1038
+ },
1039
+ MainInlineBlocksRegistry,
1040
+ CatchInlineBlocksRegistry,
1041
+ TryBlockRegistry,
1042
+ CatchBlockRegistry,
1043
+ TrySlotRegistry
1044
+ ]
1045
+ };
1046
+
1047
+ // src/activities/loop.ts
1048
+ import { Point as Point5 } from "@flowgram.ai/utils";
1049
+ import { FlowTextKey as FlowTextKey3 } from "@flowgram.ai/renderer";
1050
+ import {
1051
+ FlowNodeBaseType as FlowNodeBaseType14,
1052
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum11,
1053
+ getDefaultSpacing as getDefaultSpacing7,
1054
+ ConstantKeys as ConstantKeys6
1055
+ } from "@flowgram.ai/document";
1056
+
1057
+ // src/activities/loop-extends/constants.ts
1058
+ import { ConstantKeys as ConstantKeys4 } from "@flowgram.ai/document";
1059
+ var LoopSpacings = {
1060
+ SPACING: 16,
1061
+ // 距离下面节点距离
1062
+ COLLAPSE_INLINE_SPACING_BOTTOM: 60,
1063
+ // 距离下面节点距离
1064
+ [ConstantKeys4.INLINE_SPACING_BOTTOM]: 48,
1065
+ // 下边空白
1066
+ MIN_INLINE_BLOCK_SPACING: 280,
1067
+ // 最小循环圈宽度
1068
+ HORIZONTAL_MIN_INLINE_BLOCK_SPACING: 180,
1069
+ // 水平布局下的最小循环圈高度
1070
+ LEFT_EMPTY_BLOCK_WIDTH: 80,
1071
+ // 左边空分支宽度
1072
+ EMPTY_BRANCH_SPACING: 20,
1073
+ // 左边空分支宽度
1074
+ LOOP_BLOCK_ICON_SPACING: 13,
1075
+ // inlineBlocks 的 inlineBottom
1076
+ [ConstantKeys4.INLINE_BLOCKS_INLINE_SPACING_BOTTOM]: 23,
1077
+ // inlineBlocks 的 inlineBottom
1078
+ INLINE_BLOCKS_INLINE_SPACING_TOP: 30
1079
+ // inlineBlocks 的 inlineTop
1080
+ };
1081
+
1082
+ // src/activities/loop-extends/loop-left-empty-block.ts
1083
+ var LoopLeftEmptyBlockRegistry = {
1084
+ type: "loopLeftEmptyBlock" /* LOOP_LEFT_EMPTY_BLOCK */,
1085
+ meta: {
1086
+ inlineSpacingAfter: 0,
1087
+ spacing: 0,
1088
+ size: {
1089
+ width: LoopSpacings.LEFT_EMPTY_BLOCK_WIDTH,
1090
+ height: 0
1091
+ }
1092
+ },
1093
+ onAfterUpdateLocalTransform(transform) {
1094
+ if (transform.entity.isVertical) {
1095
+ transform.data.size = {
1096
+ width: LoopSpacings.LEFT_EMPTY_BLOCK_WIDTH,
1097
+ height: 0
1098
+ };
1099
+ } else {
1100
+ transform.data.size = {
1101
+ width: 0,
1102
+ height: LoopSpacings.LEFT_EMPTY_BLOCK_WIDTH
1103
+ };
1104
+ }
1105
+ transform.transform.update({
1106
+ size: transform.data.size
1107
+ });
1108
+ },
1109
+ getLines() {
1110
+ return [];
1111
+ },
1112
+ getLabels() {
1113
+ return [];
1114
+ }
1115
+ };
1116
+
1117
+ // src/activities/loop-extends/loop-right-empty-block.ts
1118
+ var LoopRightEmptyBlockRegistry = {
1119
+ ...BlockRegistry,
1120
+ type: "loopRightEmptyBlock" /* LOOP_RIGHT_EMPTY_BLOCK */,
1121
+ meta: {
1122
+ ...BlockRegistry.meta,
1123
+ inlineSpacingAfter: 0
1124
+ }
1125
+ };
1126
+
1127
+ // src/activities/loop-extends/loop-empty-branch.ts
1128
+ import { FlowTransitionLabelEnum as FlowTransitionLabelEnum9 } from "@flowgram.ai/document";
1129
+ var LoopEmptyBranchRegistry = {
1130
+ type: "loopEmptyBranch" /* LOOP_EMPTY_BRANCH */,
1131
+ meta: {
1132
+ inlineSpacingAfter: 0,
1133
+ spacing: LoopSpacings.EMPTY_BRANCH_SPACING,
1134
+ size: {
1135
+ width: 100,
1136
+ height: 0
1137
+ }
1138
+ },
1139
+ getLabels(transition) {
1140
+ const { isVertical } = transition.entity;
1141
+ const currentTransform = transition.transform;
1142
+ if (isVertical) {
1143
+ return [
1144
+ {
1145
+ type: FlowTransitionLabelEnum9.ADDER_LABEL,
1146
+ offset: {
1147
+ x: currentTransform.inputPoint.x,
1148
+ y: currentTransform.bounds.center.y + 8
1149
+ // 右边空节点
1150
+ }
1151
+ }
1152
+ ];
1153
+ }
1154
+ return [
1155
+ {
1156
+ type: FlowTransitionLabelEnum9.ADDER_LABEL,
1157
+ offset: {
1158
+ x: currentTransform.bounds.center.x + 8,
1159
+ y: currentTransform.inputPoint.y
1160
+ }
1161
+ }
1162
+ ];
1163
+ },
1164
+ onAfterUpdateLocalTransform(transform) {
1165
+ if (transform.entity.isVertical) {
1166
+ transform.data.size = {
1167
+ width: 100,
1168
+ height: 0
1169
+ };
1170
+ } else {
1171
+ transform.data.size = {
1172
+ width: 0,
1173
+ height: 100
1174
+ };
1175
+ }
1176
+ transform.transform.update({
1177
+ size: transform.data.size
1178
+ });
1179
+ }
1180
+ };
1181
+
1182
+ // src/activities/loop-extends/loop-inline-blocks.ts
1183
+ import { Point as Point4 } from "@flowgram.ai/utils";
1184
+ import { FlowTextKey as FlowTextKey2 } from "@flowgram.ai/renderer";
1185
+ import {
1186
+ FlowNodeBaseType as FlowNodeBaseType13,
1187
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum10,
1188
+ FlowTransitionLineEnum as FlowTransitionLineEnum5,
1189
+ getDefaultSpacing as getDefaultSpacing6,
1190
+ ConstantKeys as ConstantKeys5
1191
+ } from "@flowgram.ai/document";
1192
+ var LoopInlineBlocksNodeRegistry = {
1193
+ type: FlowNodeBaseType13.INLINE_BLOCKS,
1194
+ meta: {
1195
+ inlineSpacingPre: (node) => {
1196
+ const inlineBlocksInlineSpacingTop = getDefaultSpacing6(
1197
+ node.entity,
1198
+ ConstantKeys5.INLINE_BLOCKS_INLINE_SPACING_TOP,
1199
+ LoopSpacings.INLINE_BLOCKS_INLINE_SPACING_TOP
1200
+ );
1201
+ return inlineBlocksInlineSpacingTop;
1202
+ },
1203
+ inlineSpacingAfter: (node) => {
1204
+ const inlineBlocksInlineSpacingBottom = getDefaultSpacing6(
1205
+ node.entity,
1206
+ ConstantKeys5.INLINE_BLOCKS_INLINE_SPACING_BOTTOM,
1207
+ LoopSpacings.INLINE_BLOCKS_INLINE_SPACING_BOTTOM
1208
+ );
1209
+ return inlineBlocksInlineSpacingBottom;
1210
+ },
1211
+ minInlineBlockSpacing: (node) => node.entity.isVertical ? LoopSpacings.MIN_INLINE_BLOCK_SPACING : LoopSpacings.HORIZONTAL_MIN_INLINE_BLOCK_SPACING
1212
+ },
1213
+ getLines(transition) {
1214
+ const currentTransform = transition.transform;
1215
+ const parentTransform = currentTransform.parent;
1216
+ const { isVertical } = transition.entity;
1217
+ const lines = [
1218
+ // 循环结束线
1219
+ {
1220
+ type: FlowTransitionLineEnum5.STRAIGHT_LINE,
1221
+ from: currentTransform.outputPoint,
1222
+ to: parentTransform.outputPoint
1223
+ }
1224
+ ];
1225
+ if (currentTransform.collapsed) {
1226
+ return lines;
1227
+ }
1228
+ const [leftBlockTransform] = currentTransform.children;
1229
+ return [
1230
+ ...lines,
1231
+ // 循环回撤线 - 1 分成两段可以被 viewport 识别出矩阵区域
1232
+ {
1233
+ type: FlowTransitionLineEnum5.ROUNDED_LINE,
1234
+ from: currentTransform.outputPoint,
1235
+ to: leftBlockTransform.outputPoint,
1236
+ vertices: [
1237
+ isVertical ? { x: leftBlockTransform.inputPoint.x, y: currentTransform.bounds.bottom } : { x: currentTransform.bounds.right, y: leftBlockTransform.inputPoint.y }
1238
+ ]
1239
+ },
1240
+ // 循环回撤线 - 2
1241
+ {
1242
+ type: FlowTransitionLineEnum5.ROUNDED_LINE,
1243
+ from: leftBlockTransform.outputPoint,
1244
+ to: Point4.move(
1245
+ currentTransform.inputPoint,
1246
+ isVertical ? { x: -12, y: 10 } : { x: 10, y: -12 }
1247
+ ),
1248
+ vertices: [
1249
+ isVertical ? { x: leftBlockTransform.inputPoint.x, y: currentTransform.bounds.top + 10 } : { x: currentTransform.bounds.left + 10, y: leftBlockTransform.inputPoint.y }
1250
+ ],
1251
+ arrow: true
1252
+ }
1253
+ ];
1254
+ },
1255
+ getLabels(transition) {
1256
+ const currentTransform = transition.transform;
1257
+ const { isVertical } = transition.entity;
1258
+ const labels = [];
1259
+ if (currentTransform.collapsed) {
1260
+ return labels;
1261
+ }
1262
+ const leftBlockTransform = currentTransform.children[0];
1263
+ const rightBlockTransform = currentTransform.children[1];
1264
+ if (transition.entity.originParent?.id.startsWith("while_")) {
1265
+ labels.push({
1266
+ type: FlowTransitionLabelEnum10.TEXT_LABEL,
1267
+ renderKey: FlowTextKey2.LOOP_WHILE_TEXT,
1268
+ rotate: isVertical ? "" : "-90deg",
1269
+ offset: isVertical ? {
1270
+ x: (currentTransform.inputPoint.x + rightBlockTransform.inputPoint.x) / 2,
1271
+ y: currentTransform.inputPoint.y + 10
1272
+ } : {
1273
+ x: currentTransform.inputPoint.x + 10,
1274
+ y: (currentTransform.inputPoint.y + rightBlockTransform.inputPoint.y) / 2
1275
+ }
1276
+ });
1277
+ } else {
1278
+ labels.push({
1279
+ type: FlowTransitionLabelEnum10.TEXT_LABEL,
1280
+ renderKey: FlowTextKey2.LOOP_TRAVERSE_TEXT,
1281
+ // rotate: isVertical ? '' : '-90deg',
1282
+ offset: isVertical ? { x: leftBlockTransform.inputPoint.x, y: currentTransform.bounds.center.y + 5 } : { x: currentTransform.bounds.center.x + 5, y: leftBlockTransform.inputPoint.y }
1283
+ });
1284
+ }
1285
+ return labels;
1286
+ }
1287
+ };
1288
+
1289
+ // src/activities/loop.ts
1290
+ var LoopRegistry = {
1291
+ type: "loop",
1292
+ meta: {
1293
+ hidden: true,
1294
+ inlineSpacingAfter: (node) => {
1295
+ if (node.collapsed) {
1296
+ return LoopSpacings.COLLAPSE_INLINE_SPACING_BOTTOM;
1297
+ }
1298
+ const inlineSpacingBottom = getDefaultSpacing7(
1299
+ node.entity,
1300
+ ConstantKeys6.INLINE_SPACING_BOTTOM,
1301
+ LoopSpacings.INLINE_SPACING_BOTTOM
1302
+ );
1303
+ return inlineSpacingBottom;
1304
+ },
1305
+ spacing: LoopSpacings.SPACING
1306
+ },
1307
+ /**
1308
+ * - loopNode
1309
+ * - loopBlockIcon
1310
+ * - loopInlineBlocks
1311
+ * - loopEmptyBlock 左侧占位区域
1312
+ * - loopBlock
1313
+ * - xxx
1314
+ * - xxx
1315
+ * @param node
1316
+ * @param json
1317
+ */
1318
+ onCreate(node, json) {
1319
+ const { document } = node;
1320
+ const loopBlocks = json.blocks || [];
1321
+ const loopIconNode = document.addNode({
1322
+ id: `$blockIcon$${node.id}`,
1323
+ type: FlowNodeBaseType14.BLOCK_ICON,
1324
+ originParent: node,
1325
+ parent: node
1326
+ });
1327
+ const loopInlineBlocks = document.addNode({
1328
+ id: `$inlineBlocks$${node.id}`,
1329
+ hidden: true,
1330
+ type: FlowNodeBaseType14.INLINE_BLOCKS,
1331
+ originParent: node,
1332
+ parent: node
1333
+ });
1334
+ const loopEmptyBlockNode = document.addNode({
1335
+ id: `$loopLeftEmpty$${node.id}`,
1336
+ hidden: true,
1337
+ type: "loopLeftEmptyBlock" /* LOOP_LEFT_EMPTY_BLOCK */,
1338
+ originParent: node,
1339
+ parent: loopInlineBlocks
1340
+ });
1341
+ const loopBlockNode = document.addNode({
1342
+ id: `$block$${node.id}`,
1343
+ hidden: true,
1344
+ type: FlowNodeBaseType14.BLOCK,
1345
+ // : LoopTypeEnum.LOOP_RIGHT_EMPTY_BLOCK,
1346
+ originParent: node,
1347
+ parent: loopInlineBlocks
1348
+ });
1349
+ const loopBranch = document.addNode({
1350
+ id: `$loopRightEmpty$${node.id}`,
1351
+ hidden: true,
1352
+ type: "loopEmptyBranch" /* LOOP_EMPTY_BRANCH */,
1353
+ originParent: node,
1354
+ parent: loopBlockNode
1355
+ });
1356
+ const otherNodes = [];
1357
+ loopBlocks.forEach(
1358
+ (b) => document.addNode(
1359
+ {
1360
+ ...b,
1361
+ type: b.type,
1362
+ parent: loopBlockNode
1363
+ },
1364
+ otherNodes
1365
+ )
1366
+ );
1367
+ return [
1368
+ loopIconNode,
1369
+ loopEmptyBlockNode,
1370
+ loopInlineBlocks,
1371
+ loopBlockNode,
1372
+ loopBranch,
1373
+ ...otherNodes
1374
+ ];
1375
+ },
1376
+ getLabels(transition) {
1377
+ const currentTransform = transition.transform;
1378
+ const { isVertical } = transition.entity;
1379
+ return [
1380
+ // 循环结束
1381
+ {
1382
+ type: FlowTransitionLabelEnum11.TEXT_LABEL,
1383
+ renderKey: FlowTextKey3.LOOP_END_TEXT,
1384
+ // 循环 label 垂直样式展示,而非 rotate 旋转文案
1385
+ props: isVertical ? void 0 : {
1386
+ style: {
1387
+ maxWidth: "20px",
1388
+ lineHeight: "12px",
1389
+ whiteSpace: "pre-wrap"
1390
+ }
1391
+ },
1392
+ offset: Point5.move(currentTransform.outputPoint, isVertical ? { y: -26 } : { x: -26 })
1393
+ },
1394
+ {
1395
+ type: FlowTransitionLabelEnum11.ADDER_LABEL,
1396
+ offset: currentTransform.outputPoint
1397
+ }
1398
+ ];
1399
+ },
1400
+ // 和前序节点对齐
1401
+ getInputPoint(transform) {
1402
+ const { isVertical } = transform.entity;
1403
+ if (isVertical) {
1404
+ return {
1405
+ x: transform.pre?.outputPoint.x || transform.firstChild?.outputPoint.x || 0,
1406
+ y: transform.bounds.top
1407
+ };
1408
+ }
1409
+ return {
1410
+ x: transform.bounds.left,
1411
+ y: transform.pre?.outputPoint.y || transform.firstChild?.outputPoint.y || 0
1412
+ };
1413
+ },
1414
+ getOutputPoint(transform) {
1415
+ const { isVertical } = transform.entity;
1416
+ if (isVertical) {
1417
+ return {
1418
+ x: transform.pre?.outputPoint.x || transform.firstChild?.outputPoint.x || 0,
1419
+ y: transform.bounds.bottom
1420
+ };
1421
+ }
1422
+ return {
1423
+ x: transform.bounds.right,
1424
+ y: transform.pre?.outputPoint.y || transform.firstChild?.outputPoint.y || 0
1425
+ };
1426
+ },
1427
+ extendChildRegistries: [
1428
+ {
1429
+ type: FlowNodeBaseType14.BLOCK_ICON,
1430
+ meta: {
1431
+ spacing: LoopSpacings.LOOP_BLOCK_ICON_SPACING
1432
+ }
1433
+ },
1434
+ LoopLeftEmptyBlockRegistry,
1435
+ LoopEmptyBranchRegistry,
1436
+ LoopRightEmptyBlockRegistry,
1437
+ LoopInlineBlocksNodeRegistry
1438
+ ],
1439
+ /**
1440
+ * @depreacted
1441
+ */
1442
+ addChild(node, json, options = {}) {
1443
+ const { index } = options;
1444
+ const document = node.document;
1445
+ return document.addNode({
1446
+ ...json,
1447
+ ...options,
1448
+ parent: document.getNode(`$block$${node.id}`),
1449
+ index: typeof index === "number" ? index + 1 : void 0
1450
+ });
1451
+ }
1452
+ };
1453
+
1454
+ // src/activities/root.ts
1455
+ import { DEFAULT_SPACING as DEFAULT_SPACING6, FlowNodeBaseType as FlowNodeBaseType15 } from "@flowgram.ai/document";
1456
+ var RootRegistry = {
1457
+ type: FlowNodeBaseType15.ROOT,
1458
+ meta: {
1459
+ spacing: DEFAULT_SPACING6.NULL,
1460
+ hidden: true
1461
+ },
1462
+ getInputPoint(transform) {
1463
+ return transform.firstChild?.inputPoint || transform.bounds.topCenter;
1464
+ },
1465
+ getOutputPoint(transform) {
1466
+ return transform.firstChild?.outputPoint || transform.bounds.bottomCenter;
1467
+ }
1468
+ };
1469
+
1470
+ // src/activities/empty.ts
1471
+ import {
1472
+ FlowNodeBaseType as FlowNodeBaseType16,
1473
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum12,
1474
+ ConstantKeys as ConstantKeys7,
1475
+ getDefaultSpacing as getDefaultSpacing8
1476
+ } from "@flowgram.ai/document";
1477
+ var EmptyRegistry = {
1478
+ type: FlowNodeBaseType16.EMPTY,
1479
+ meta: {
1480
+ spacing: (node) => {
1481
+ const spacing = getDefaultSpacing8(node.entity, ConstantKeys7.NODE_SPACING);
1482
+ return spacing / 2;
1483
+ },
1484
+ size: { width: 0, height: 0 },
1485
+ hidden: true
1486
+ },
1487
+ getLabels(transition) {
1488
+ return [
1489
+ {
1490
+ offset: transition.transform.bounds,
1491
+ type: FlowTransitionLabelEnum12.ADDER_LABEL
1492
+ }
1493
+ ];
1494
+ }
1495
+ };
1496
+
1497
+ // src/activities/simple-split.ts
1498
+ import {
1499
+ FlowNodeSplitType as FlowNodeSplitType3,
1500
+ FlowNodeBaseType as FlowNodeBaseType17
1501
+ } from "@flowgram.ai/document";
1502
+ var SimpleSplitRegistry = {
1503
+ type: FlowNodeSplitType3.SIMPLE_SPLIT,
1504
+ extend: FlowNodeSplitType3.DYNAMIC_SPLIT,
1505
+ onBlockChildCreate(originParent, blockData, addedNodes = []) {
1506
+ const { document } = originParent;
1507
+ const parent = document.getNode(`$inlineBlocks$${originParent.id}`);
1508
+ const realBlock = document.addNode(
1509
+ {
1510
+ ...blockData,
1511
+ type: blockData.type || FlowNodeBaseType17.BLOCK,
1512
+ parent
1513
+ },
1514
+ addedNodes
1515
+ );
1516
+ addedNodes.push(realBlock);
1517
+ return realBlock;
1518
+ }
1519
+ // addChild(node, json, options = {}) {
1520
+ // const { index } = options;
1521
+ // const document = node.document;
1522
+ // return document.addBlock(node, json, undefined, undefined, index);
1523
+ // }
1524
+ };
1525
+
1526
+ // src/activities/break.ts
1527
+ import { FlowNodeBaseType as FlowNodeBaseType18 } from "@flowgram.ai/document";
1528
+ var BreakRegistry = {
1529
+ type: FlowNodeBaseType18.BREAK,
1530
+ extend: FlowNodeBaseType18.END
1531
+ };
1532
+
1533
+ // src/activities/input.ts
1534
+ import {
1535
+ FlowNodeBaseType as FlowNodeBaseType19,
1536
+ FlowTransitionLineEnum as FlowTransitionLineEnum6,
1537
+ LABEL_SIDE_TYPE as LABEL_SIDE_TYPE2,
1538
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum13
1539
+ } from "@flowgram.ai/document";
1540
+ var InputRegistry = {
1541
+ type: FlowNodeBaseType19.INPUT,
1542
+ extend: FlowNodeBaseType19.BLOCK,
1543
+ meta: {
1544
+ hidden: false
1545
+ },
1546
+ getLines(transition, layout) {
1547
+ const currentTransform = transition.transform;
1548
+ const { isVertical } = transition.entity;
1549
+ const lines = [];
1550
+ const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
1551
+ if (hasBranchDraggingAdder) {
1552
+ if (isVertical) {
1553
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
1554
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
1555
+ const currentInputPointY = currentTransform.outputPoint.y;
1556
+ if (currentTransform?.next) {
1557
+ lines.push({
1558
+ type: FlowTransitionLineEnum6.MERGE_LINE,
1559
+ isDraggingLine: true,
1560
+ from: {
1561
+ x: (currentOffsetRightX + nextOffsetLeftX) / 2,
1562
+ y: currentInputPointY
1563
+ },
1564
+ to: currentTransform.parent.outputPoint,
1565
+ side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
1566
+ });
1567
+ }
1568
+ } else {
1569
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
1570
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
1571
+ const currentInputPointX = currentTransform.outputPoint.x;
1572
+ if (currentTransform?.next) {
1573
+ lines.push({
1574
+ type: FlowTransitionLineEnum6.MERGE_LINE,
1575
+ isDraggingLine: true,
1576
+ from: {
1577
+ x: currentInputPointX,
1578
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
1579
+ },
1580
+ to: currentTransform.parent.outputPoint,
1581
+ side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
1582
+ });
1583
+ }
1584
+ }
1585
+ }
1586
+ if (!transition.isNodeEnd) {
1587
+ lines.push({
1588
+ type: FlowTransitionLineEnum6.MERGE_LINE,
1589
+ from: currentTransform.outputPoint,
1590
+ to: currentTransform.parent.outputPoint,
1591
+ side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
1592
+ });
1593
+ }
1594
+ return lines;
1595
+ },
1596
+ getLabels(transition) {
1597
+ const currentTransform = transition.transform;
1598
+ const { isVertical } = transition.entity;
1599
+ const draggingLabel = [];
1600
+ const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
1601
+ if (hasBranchDraggingAdder) {
1602
+ if (isVertical) {
1603
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
1604
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
1605
+ const currentInputPointY = currentTransform.outputPoint.y;
1606
+ if (currentTransform?.next) {
1607
+ draggingLabel.push({
1608
+ offset: {
1609
+ x: (currentOffsetRightX + nextOffsetLeftX) / 2,
1610
+ y: currentInputPointY
1611
+ },
1612
+ type: FlowTransitionLabelEnum13.BRANCH_DRAGGING_LABEL,
1613
+ width: nextOffsetLeftX - currentOffsetRightX,
1614
+ props: {
1615
+ side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
1616
+ }
1617
+ });
1618
+ }
1619
+ } else {
1620
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
1621
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
1622
+ const currentInputPointX = currentTransform.outputPoint.x;
1623
+ if (currentTransform?.next) {
1624
+ draggingLabel.push({
1625
+ offset: {
1626
+ x: currentInputPointX,
1627
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
1628
+ },
1629
+ type: FlowTransitionLabelEnum13.BRANCH_DRAGGING_LABEL,
1630
+ width: nextOffsetTopX - currentOffsetBottomX,
1631
+ props: {
1632
+ side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
1633
+ }
1634
+ });
1635
+ }
1636
+ }
1637
+ }
1638
+ return [...draggingLabel];
1639
+ }
1640
+ };
1641
+
1642
+ // src/activities/output.ts
1643
+ import { FlowNodeBaseType as FlowNodeBaseType20 } from "@flowgram.ai/document";
1644
+ var OuputRegistry = {
1645
+ type: FlowNodeBaseType20.OUTPUT,
1646
+ extend: FlowNodeBaseType20.BLOCK,
1647
+ meta: {
1648
+ hidden: false,
1649
+ isNodeEnd: true
1650
+ }
1651
+ };
1652
+
1653
+ // src/activities/multi-outputs.ts
1654
+ import {
1655
+ FlowLayoutDefault as FlowLayoutDefault7,
1656
+ FlowNodeSplitType as FlowNodeSplitType4,
1657
+ FlowNodeBaseType as FlowNodeBaseType21
1658
+ } from "@flowgram.ai/document";
1659
+ var MultiOuputsRegistry = {
1660
+ type: FlowNodeBaseType21.MULTI_OUTPUTS,
1661
+ extend: FlowNodeSplitType4.SIMPLE_SPLIT,
1662
+ meta: {
1663
+ isNodeEnd: true
1664
+ },
1665
+ getLines: (transition, layout) => {
1666
+ if (transition.entity.parent?.flowNodeType === FlowNodeBaseType21.INLINE_BLOCKS) {
1667
+ return BlockRegistry.getLines(transition, layout);
1668
+ }
1669
+ return [];
1670
+ },
1671
+ getLabels: (transition, layout) => [
1672
+ ...DynamicSplitRegistry.getLabels(transition, layout),
1673
+ ...BlockRegistry.getLabels(transition, layout)
1674
+ ],
1675
+ getOutputPoint(transform, layout) {
1676
+ const isVertical = FlowLayoutDefault7.isVertical(layout);
1677
+ const lastChildOutput = transform.lastChild?.outputPoint;
1678
+ if (isVertical) {
1679
+ return {
1680
+ x: lastChildOutput ? lastChildOutput.x : transform.bounds.center.x,
1681
+ y: transform.bounds.bottom
1682
+ };
1683
+ }
1684
+ return {
1685
+ x: transform.bounds.right,
1686
+ y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
1687
+ };
1688
+ },
1689
+ extendChildRegistries: [
1690
+ {
1691
+ type: FlowNodeBaseType21.BLOCK_ICON,
1692
+ meta: {
1693
+ // isNodeEnd: true
1694
+ }
1695
+ }
1696
+ ]
1697
+ };
1698
+
1699
+ // src/activities/multi-inputs.ts
1700
+ import { Point as Point6 } from "@flowgram.ai/utils";
1701
+ import { FlowRendererKey as FlowRendererKey4 } from "@flowgram.ai/renderer";
1702
+ import {
1703
+ FlowNodeBaseType as FlowNodeBaseType22,
1704
+ FlowNodeRenderData as FlowNodeRenderData3,
1705
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum14,
1706
+ FlowNodeSplitType as FlowNodeSplitType5,
1707
+ getDefaultSpacing as getDefaultSpacing9,
1708
+ ConstantKeys as ConstantKeys8
1709
+ } from "@flowgram.ai/document";
1710
+ var MultiInputsRegistry = {
1711
+ type: FlowNodeBaseType22.MULTI_INPUTS,
1712
+ extend: FlowNodeSplitType5.SIMPLE_SPLIT,
1713
+ extendChildRegistries: [
1714
+ {
1715
+ type: FlowNodeBaseType22.BLOCK_ICON,
1716
+ meta: {
1717
+ hidden: true,
1718
+ spacing: 0
1719
+ },
1720
+ getLines() {
1721
+ return [];
1722
+ },
1723
+ getLabels() {
1724
+ return [];
1725
+ }
1726
+ },
1727
+ {
1728
+ type: FlowNodeBaseType22.INLINE_BLOCKS,
1729
+ meta: {
1730
+ inlineSpacingPre: 0
1731
+ },
1732
+ getLabels(transition) {
1733
+ const isVertical = transition.entity.isVertical;
1734
+ const currentTransform = transition.transform;
1735
+ const spacing = getDefaultSpacing9(
1736
+ transition.entity,
1737
+ ConstantKeys8.INLINE_BLOCKS_PADDING_BOTTOM
1738
+ );
1739
+ if (currentTransform.collapsed || transition.entity.childrenLength === 0) {
1740
+ return [
1741
+ {
1742
+ type: FlowTransitionLabelEnum14.CUSTOM_LABEL,
1743
+ renderKey: FlowRendererKey4.BRANCH_ADDER,
1744
+ offset: Point6.move(
1745
+ currentTransform.outputPoint,
1746
+ isVertical ? { y: spacing } : { x: spacing }
1747
+ ),
1748
+ props: {
1749
+ // 激活状态
1750
+ activated: transition.entity.getData(FlowNodeRenderData3).activated,
1751
+ transform: currentTransform,
1752
+ // 传给外部使用的 node 信息
1753
+ node: currentTransform.originParent?.entity
1754
+ }
1755
+ }
1756
+ ];
1757
+ }
1758
+ return [
1759
+ {
1760
+ type: FlowTransitionLabelEnum14.CUSTOM_LABEL,
1761
+ renderKey: FlowRendererKey4.BRANCH_ADDER,
1762
+ offset: Point6.move(
1763
+ currentTransform.outputPoint,
1764
+ isVertical ? { y: -spacing / 2 } : { x: -spacing / 2 }
1765
+ ),
1766
+ props: {
1767
+ // 激活状态
1768
+ activated: transition.entity.getData(FlowNodeRenderData3).activated,
1769
+ transform: currentTransform,
1770
+ // 传给外部使用的 node 信息
1771
+ node: currentTransform.originParent?.entity
1772
+ }
1773
+ }
1774
+ ];
1775
+ }
1776
+ }
1777
+ ],
1778
+ getLabels() {
1779
+ return [];
1780
+ }
1781
+ };
1782
+
1783
+ // src/flow-registers.ts
1784
+ var FlowRegisters = class {
1785
+ /**
1786
+ * 注册数据层
1787
+ * @param document
1788
+ */
1789
+ registerDocument(document) {
1790
+ document.registerFlowNodes(
1791
+ RootRegistry,
1792
+ // 根节点
1793
+ StartRegistry,
1794
+ // 开始节点
1795
+ DynamicSplitRegistry,
1796
+ // 动态分支(并行、排他)
1797
+ StaticSplitRegistry,
1798
+ // 静态分支(审批)
1799
+ SimpleSplitRegistry,
1800
+ // 简单分支 (不带 orderIcon 节点)
1801
+ BlockRegistry,
1802
+ // 单条 block 注册
1803
+ InlineBlocksRegistry,
1804
+ // 多个 block 组成的 block 列表
1805
+ BlockIconRegistry,
1806
+ // icon 节点,如条件分支的菱形图标
1807
+ BlockOrderIconRegistry,
1808
+ // 带顺序的图标节点,一般为 block 第一个分支节点
1809
+ TryCatchRegistry,
1810
+ // TryCatch
1811
+ EndRegistry,
1812
+ // 结束节点
1813
+ LoopRegistry,
1814
+ // 循环节点
1815
+ EmptyRegistry,
1816
+ // 占位节点
1817
+ BreakRegistry,
1818
+ // 分支断开
1819
+ MultiOuputsRegistry,
1820
+ MultiInputsRegistry,
1821
+ InputRegistry,
1822
+ OuputRegistry
1823
+ );
1824
+ document.registerNodeDatas(
1825
+ FlowNodeRenderData4,
1826
+ // 渲染节点相关数据
1827
+ FlowNodeTransitionData,
1828
+ // 线条绘制数据
1829
+ FlowNodeTransformData3
1830
+ // 坐标计算数据
1831
+ );
1832
+ }
1833
+ /**
1834
+ * 注册渲染层
1835
+ * @param renderer
1836
+ */
1837
+ registerRenderer(renderer) {
1838
+ renderer.registerLayers(
1839
+ FlowNodesTransformLayer,
1840
+ // 节点位置渲染
1841
+ FlowNodesContentLayer,
1842
+ // 节点内容渲染
1843
+ FlowLinesLayer,
1844
+ // 线条渲染
1845
+ FlowLabelsLayer,
1846
+ // Label 渲染
1847
+ PlaygroundLayer
1848
+ // 画布基础层,提供缩放、手势等能力
1849
+ );
1850
+ }
1851
+ /**
1852
+ * 画布开始渲染 (hook)
1853
+ */
1854
+ onReady() {
1855
+ }
1856
+ /**
1857
+ * 画布销毁 (hook)
1858
+ */
1859
+ onDispose() {
1860
+ }
1861
+ };
1862
+ FlowRegisters = __decorateClass([
1863
+ injectable()
1864
+ ], FlowRegisters);
1865
+
1866
+ // src/fixed-layout-container-module.ts
1867
+ var FixedLayoutContainerModule = new ContainerModule((bind) => {
1868
+ bindContributions(bind, FlowRegisters, [
1869
+ FlowDocumentContribution,
1870
+ FlowRendererContribution,
1871
+ PlaygroundContribution
1872
+ ]);
1873
+ });
1874
+
1875
+ // src/index.ts
1876
+ var FixedLayoutRegistries = {
1877
+ BlockIconRegistry,
1878
+ BlockOrderIconRegistry,
1879
+ BlockRegistry,
1880
+ DynamicSplitRegistry,
1881
+ EmptyRegistry,
1882
+ LoopRegistry,
1883
+ StaticSplitRegistry,
1884
+ TryCatchRegistry,
1885
+ StartRegistry,
1886
+ RootRegistry,
1887
+ InlineBlocksRegistry,
1888
+ EndRegistry
1889
+ };
1890
+ export {
1891
+ FixedLayoutContainerModule,
1892
+ FixedLayoutRegistries
1893
+ };
1894
+ //# sourceMappingURL=index.js.map