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