@antv/g6 5.0.48 → 5.0.50
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/g6.min.js +32 -30
- package/dist/lib/behaviors/brush-select.d.ts +1 -1
- package/dist/lib/behaviors/drag-canvas.d.ts +1 -0
- package/dist/lib/behaviors/drag-element.d.ts +3 -2
- package/dist/lib/exports.d.ts +1 -1
- package/dist/lib/layouts/types.d.ts +30 -3
- package/dist/lib/plugins/hull/index.d.ts +1 -0
- package/dist/lib/plugins/index.d.ts +2 -0
- package/dist/lib/plugins/minimap/index.d.ts +7 -4
- package/dist/lib/plugins/title/index.d.ts +85 -0
- package/dist/lib/plugins/tooltip.d.ts +1 -1
- package/dist/lib/registry/extension/index.d.ts +1 -0
- package/dist/lib/runtime/graph.d.ts +27 -0
- package/dist/lib/types/utility.d.ts +1 -0
- package/dist/lib/utils/element.d.ts +1 -1
- package/dist/lib/utils/vector.d.ts +9 -0
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/brush-select.d.ts +1 -1
- package/esm/behaviors/brush-select.js +12 -3
- package/esm/behaviors/brush-select.js.map +1 -1
- package/esm/behaviors/drag-canvas.d.ts +1 -0
- package/esm/behaviors/drag-canvas.js +6 -1
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element-force.js +1 -1
- package/esm/behaviors/drag-element-force.js.map +1 -1
- package/esm/behaviors/drag-element.d.ts +3 -2
- package/esm/behaviors/drag-element.js +12 -3
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/hover-activate.js +1 -1
- package/esm/behaviors/hover-activate.js.map +1 -1
- package/esm/behaviors/lasso-select.js +3 -3
- package/esm/behaviors/lasso-select.js.map +1 -1
- package/esm/exports.d.ts +1 -1
- package/esm/exports.js +1 -1
- package/esm/exports.js.map +1 -1
- package/esm/layouts/types.d.ts +30 -3
- package/esm/plugins/grid-line.js +1 -1
- package/esm/plugins/grid-line.js.map +1 -1
- package/esm/plugins/hull/index.d.ts +1 -0
- package/esm/plugins/hull/index.js +5 -1
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/plugins/index.d.ts +2 -0
- package/esm/plugins/index.js +1 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/minimap/index.d.ts +7 -4
- package/esm/plugins/minimap/index.js +68 -61
- package/esm/plugins/minimap/index.js.map +1 -1
- package/esm/plugins/title/index.d.ts +85 -0
- package/esm/plugins/title/index.js +172 -0
- package/esm/plugins/title/index.js.map +1 -0
- package/esm/plugins/tooltip.d.ts +1 -1
- package/esm/plugins/tooltip.js +4 -4
- package/esm/plugins/tooltip.js.map +1 -1
- package/esm/registry/build-in.js +2 -1
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/extension/index.d.ts +1 -0
- package/esm/registry/extension/index.js +7 -3
- package/esm/registry/extension/index.js.map +1 -1
- package/esm/runtime/canvas.js +2 -0
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/element.js +6 -26
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +27 -0
- package/esm/runtime/graph.js +49 -2
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.js +4 -3
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/viewport.js +3 -0
- package/esm/runtime/viewport.js.map +1 -1
- package/esm/themes/base.js +1 -0
- package/esm/themes/base.js.map +1 -1
- package/esm/transforms/collapse-expand-node.js +1 -1
- package/esm/transforms/collapse-expand-node.js.map +1 -1
- package/esm/transforms/process-parallel-edges.js +16 -3
- package/esm/transforms/process-parallel-edges.js.map +1 -1
- package/esm/types/utility.d.ts +1 -0
- package/esm/types/utility.js +2 -0
- package/esm/types/utility.js.map +1 -0
- package/esm/utils/element.d.ts +1 -1
- package/esm/utils/element.js.map +1 -1
- package/esm/utils/layout.js +2 -2
- package/esm/utils/layout.js.map +1 -1
- package/esm/utils/vector.d.ts +9 -0
- package/esm/utils/vector.js +17 -0
- package/esm/utils/vector.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/behaviors/brush-select.d.ts +1 -1
- package/lib/behaviors/brush-select.js +12 -3
- package/lib/behaviors/brush-select.js.map +1 -1
- package/lib/behaviors/drag-canvas.d.ts +1 -0
- package/lib/behaviors/drag-canvas.js +5 -0
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element-force.js +1 -1
- package/lib/behaviors/drag-element-force.js.map +1 -1
- package/lib/behaviors/drag-element.d.ts +3 -2
- package/lib/behaviors/drag-element.js +11 -2
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/hover-activate.js +1 -1
- package/lib/behaviors/hover-activate.js.map +1 -1
- package/lib/behaviors/lasso-select.js +3 -3
- package/lib/behaviors/lasso-select.js.map +1 -1
- package/lib/exports.d.ts +1 -1
- package/lib/exports.js +3 -2
- package/lib/exports.js.map +1 -1
- package/lib/layouts/types.d.ts +30 -3
- package/lib/plugins/grid-line.js +1 -1
- package/lib/plugins/grid-line.js.map +1 -1
- package/lib/plugins/hull/index.d.ts +1 -0
- package/lib/plugins/hull/index.js +5 -1
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/index.js +3 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/minimap/index.d.ts +7 -4
- package/lib/plugins/minimap/index.js +68 -61
- package/lib/plugins/minimap/index.js.map +1 -1
- package/lib/plugins/title/index.d.ts +85 -0
- package/lib/plugins/title/index.js +176 -0
- package/lib/plugins/title/index.js.map +1 -0
- package/lib/plugins/tooltip.d.ts +1 -1
- package/lib/plugins/tooltip.js +4 -4
- package/lib/plugins/tooltip.js.map +1 -1
- package/lib/registry/build-in.js +1 -0
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/extension/index.d.ts +1 -0
- package/lib/registry/extension/index.js +7 -3
- package/lib/registry/extension/index.js.map +1 -1
- package/lib/runtime/canvas.js +2 -0
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/element.js +6 -26
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +27 -0
- package/lib/runtime/graph.js +49 -2
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.js +4 -3
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/viewport.js +3 -0
- package/lib/runtime/viewport.js.map +1 -1
- package/lib/themes/base.js +1 -0
- package/lib/themes/base.js.map +1 -1
- package/lib/transforms/collapse-expand-node.js +1 -1
- package/lib/transforms/collapse-expand-node.js.map +1 -1
- package/lib/transforms/process-parallel-edges.js +16 -3
- package/lib/transforms/process-parallel-edges.js.map +1 -1
- package/lib/types/utility.d.ts +1 -0
- package/lib/types/utility.js +3 -0
- package/lib/types/utility.js.map +1 -0
- package/lib/utils/element.d.ts +1 -1
- package/lib/utils/element.js.map +1 -1
- package/lib/utils/layout.js +2 -2
- package/lib/utils/layout.js.map +1 -1
- package/lib/utils/vector.d.ts +9 -0
- package/lib/utils/vector.js +18 -0
- package/lib/utils/vector.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +8 -8
- package/src/behaviors/brush-select.ts +14 -3
- package/src/behaviors/drag-canvas.ts +7 -1
- package/src/behaviors/drag-element-force.ts +2 -1
- package/src/behaviors/drag-element.ts +17 -4
- package/src/behaviors/hover-activate.ts +1 -1
- package/src/behaviors/lasso-select.ts +3 -3
- package/src/exports.ts +1 -0
- package/src/layouts/types.ts +33 -4
- package/src/plugins/grid-line.ts +1 -1
- package/src/plugins/hull/index.ts +6 -1
- package/src/plugins/index.ts +2 -0
- package/src/plugins/minimap/index.ts +75 -68
- package/src/plugins/title/index.ts +300 -0
- package/src/plugins/tooltip.ts +4 -4
- package/src/registry/build-in.ts +2 -0
- package/src/registry/extension/index.ts +9 -3
- package/src/runtime/canvas.ts +2 -0
- package/src/runtime/element.ts +6 -32
- package/src/runtime/graph.ts +58 -2
- package/src/runtime/layout.ts +9 -3
- package/src/runtime/viewport.ts +14 -3
- package/src/themes/base.ts +1 -0
- package/src/transforms/collapse-expand-node.ts +1 -1
- package/src/transforms/process-parallel-edges.ts +17 -3
- package/src/types/utility.ts +1 -0
- package/src/utils/element.ts +5 -5
- package/src/utils/layout.ts +2 -3
- package/src/utils/vector.ts +17 -0
- package/src/version.ts +1 -1
package/src/runtime/element.ts
CHANGED
|
@@ -663,20 +663,8 @@ export class ElementController {
|
|
|
663
663
|
* @param options - <zh/> 选项 | <en/> options
|
|
664
664
|
*/
|
|
665
665
|
public async collapseNode(id: ID, options: CollapseExpandNodeOptions): Promise<void> {
|
|
666
|
-
const { animation
|
|
667
|
-
|
|
668
|
-
const { model, layout } = this.context;
|
|
669
|
-
|
|
670
|
-
const simulateLayoutData = this.computeChangesAndDrawData({ stage: 'collapse', animation });
|
|
671
|
-
if (!simulateLayoutData) return;
|
|
672
|
-
|
|
673
|
-
this.markDestroyElement(simulateLayoutData.drawData);
|
|
674
|
-
|
|
675
|
-
// 进行预布局,计算出所有元素的位置
|
|
676
|
-
// Perform pre-layout to calculate the position of all elements
|
|
677
|
-
const result = await layout!.simulate();
|
|
678
|
-
if (align) this.alignLayoutResultToElement(result, id);
|
|
679
|
-
model.updateData(result);
|
|
666
|
+
const { animation } = options;
|
|
667
|
+
const { model } = this.context;
|
|
680
668
|
|
|
681
669
|
// 重新计算数据 / Recalculate data
|
|
682
670
|
const data = this.computeChangesAndDrawData({ stage: 'collapse', animation });
|
|
@@ -718,31 +706,17 @@ export class ElementController {
|
|
|
718
706
|
public async expandNode(id: ID, options: CollapseExpandNodeOptions): Promise<void> {
|
|
719
707
|
const { model, layout } = this.context;
|
|
720
708
|
const { animation, align } = options;
|
|
721
|
-
|
|
722
709
|
const position = positionOf(model.getNodeData([id])[0]);
|
|
723
710
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
// 首先创建展开的元素,然后进行预布局
|
|
728
|
-
// First create the expanded element, then perform pre-layout
|
|
729
|
-
const {
|
|
730
|
-
drawData: { add },
|
|
731
|
-
} = preLayoutData;
|
|
732
|
-
this.createElements(add, { animation: false, stage: 'expand', target: id });
|
|
711
|
+
// 重新计算数据 / Recalculate data
|
|
712
|
+
const data = this.computeChangesAndDrawData({ stage: 'expand', animation });
|
|
713
|
+
this.createElements(data!.drawData.add, { animation: false, stage: 'expand', target: id });
|
|
733
714
|
// 重置动画 / Reset animation
|
|
734
715
|
this.context.animation!.clear();
|
|
735
|
-
|
|
736
|
-
const result = await layout!.simulate();
|
|
737
|
-
if (align) this.alignLayoutResultToElement(result, id);
|
|
738
|
-
model.updateData(result);
|
|
739
|
-
|
|
740
|
-
// 重新计算数据 / Recalculate data
|
|
741
716
|
this.computeStyle('expand');
|
|
742
|
-
const data = this.computeChangesAndDrawData({ stage: 'collapse', animation });
|
|
743
717
|
if (!data) return;
|
|
744
718
|
const { drawData } = data;
|
|
745
|
-
const { update } = drawData;
|
|
719
|
+
const { update, add } = drawData;
|
|
746
720
|
|
|
747
721
|
const context = { animation, stage: 'expand', data: drawData } as const;
|
|
748
722
|
|
package/src/runtime/graph.ts
CHANGED
|
@@ -504,6 +504,40 @@ export class Graph extends EventEmitter {
|
|
|
504
504
|
public getData(): Required<GraphData> {
|
|
505
505
|
return this.context.model.getData();
|
|
506
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* <zh/> 判断图中是否存在指定节点
|
|
509
|
+
* <en/> Determine whether a specified node exists in the graph
|
|
510
|
+
* @param {ID} id
|
|
511
|
+
* @returns {boolean}
|
|
512
|
+
* @remarks <zh/> 判断图中是否存在指定节点,避免在不存在的节点上进行操作
|
|
513
|
+
* <en/> Determine whether a specified node exists in the graph and avoid operating on non-existent nodes
|
|
514
|
+
*/
|
|
515
|
+
public hasNode(id: ID): boolean {
|
|
516
|
+
return this.context.model.hasNode(id);
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* <zh/> 判断图中是否存在指定边
|
|
520
|
+
* <en/> Determine whether a specified edge exists in the graph
|
|
521
|
+
* @param {ID} id
|
|
522
|
+
* @returns {boolean}
|
|
523
|
+
* @remarks <zh/> 判断图中是否存在指定边,避免在不存在的边上进行操作
|
|
524
|
+
* <en/> Determine whether a specified edge exists in the graph and avoid operating on non-existent edges
|
|
525
|
+
*/
|
|
526
|
+
public hasEdge(id: ID): boolean {
|
|
527
|
+
return this.context.model.hasEdge(id);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* <zh/> 判断图中是否存在指定组合
|
|
532
|
+
* <en/> Determine whether a specified combo exists in the graph
|
|
533
|
+
* @param {ID} id
|
|
534
|
+
* @returns {boolean}
|
|
535
|
+
* @remarks <zh/> 判断图中是否存在指定组合,避免在不存在的组合上进行操作
|
|
536
|
+
* <en/> Determine whether a specified combo exists in the graph and avoid operating on non-existent combos
|
|
537
|
+
*/
|
|
538
|
+
public hasCombo(id: ID): boolean {
|
|
539
|
+
return this.context.model.hasCombo(id);
|
|
540
|
+
}
|
|
507
541
|
|
|
508
542
|
/**
|
|
509
543
|
* <zh/> 获取单个元素数据
|
|
@@ -1845,7 +1879,18 @@ export class Graph extends EventEmitter {
|
|
|
1845
1879
|
|
|
1846
1880
|
await this.frontElement(id);
|
|
1847
1881
|
this.isCollapsingExpanding = true;
|
|
1848
|
-
|
|
1882
|
+
|
|
1883
|
+
// 更新折叠状态 / Update collapse style
|
|
1884
|
+
model.updateData(
|
|
1885
|
+
elementType === 'node'
|
|
1886
|
+
? {
|
|
1887
|
+
nodes: [{ id, style: { collapsed: true } }],
|
|
1888
|
+
}
|
|
1889
|
+
: {
|
|
1890
|
+
combos: [{ id, style: { collapsed: true } }],
|
|
1891
|
+
},
|
|
1892
|
+
);
|
|
1893
|
+
|
|
1849
1894
|
if (elementType === 'node') await element!.collapseNode(id, options);
|
|
1850
1895
|
else if (elementType === 'combo') await element!.collapseCombo(id, !!options.animation);
|
|
1851
1896
|
|
|
@@ -1871,7 +1916,18 @@ export class Graph extends EventEmitter {
|
|
|
1871
1916
|
const elementType = model.getElementType(id);
|
|
1872
1917
|
|
|
1873
1918
|
this.isCollapsingExpanding = true;
|
|
1874
|
-
|
|
1919
|
+
|
|
1920
|
+
// 更新折叠状态 / Update collapse style
|
|
1921
|
+
model.updateData(
|
|
1922
|
+
elementType === 'node'
|
|
1923
|
+
? {
|
|
1924
|
+
nodes: [{ id, style: { collapsed: false } }],
|
|
1925
|
+
}
|
|
1926
|
+
: {
|
|
1927
|
+
combos: [{ id, style: { collapsed: false } }],
|
|
1928
|
+
},
|
|
1929
|
+
);
|
|
1930
|
+
|
|
1875
1931
|
if (elementType === 'node') await element!.expandNode(id, options);
|
|
1876
1932
|
else if (elementType === 'combo') await element!.expandCombo(id, !!options.animation);
|
|
1877
1933
|
|
package/src/runtime/layout.ts
CHANGED
|
@@ -296,7 +296,12 @@ export class LayoutController {
|
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
public getLayoutData(options: STDLayoutOptions): GraphData {
|
|
299
|
-
const {
|
|
299
|
+
const {
|
|
300
|
+
nodeFilter = () => true,
|
|
301
|
+
comboFilter = () => true,
|
|
302
|
+
preLayout = false,
|
|
303
|
+
isLayoutInvisibleNodes = false,
|
|
304
|
+
} = options;
|
|
300
305
|
const { nodes, edges, combos } = this.context.model.getData();
|
|
301
306
|
|
|
302
307
|
const { element, model } = this.context;
|
|
@@ -320,9 +325,10 @@ export class LayoutController {
|
|
|
320
325
|
};
|
|
321
326
|
|
|
322
327
|
const nodesToLayout = nodes.filter(filterFn);
|
|
328
|
+
const combosToLayout = combos.filter(comboFilter);
|
|
323
329
|
|
|
324
330
|
const nodeLikeIdsMap = new Map<ID, NodeData>(nodesToLayout.map((node) => [idOf(node), node]));
|
|
325
|
-
|
|
331
|
+
combosToLayout.forEach((combo) => nodeLikeIdsMap.set(idOf(combo), combo));
|
|
326
332
|
|
|
327
333
|
const edgesToLayout = edges.filter(({ source, target }) => {
|
|
328
334
|
return nodeLikeIdsMap.has(source) && nodeLikeIdsMap.has(target);
|
|
@@ -331,7 +337,7 @@ export class LayoutController {
|
|
|
331
337
|
return {
|
|
332
338
|
nodes: nodesToLayout,
|
|
333
339
|
edges: edgesToLayout,
|
|
334
|
-
combos,
|
|
340
|
+
combos: combosToLayout,
|
|
335
341
|
};
|
|
336
342
|
}
|
|
337
343
|
|
package/src/runtime/viewport.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { AABB, ICamera } from '@antv/g';
|
|
2
2
|
import { clamp, isNumber, pick } from '@antv/util';
|
|
3
3
|
import { AnimationType, GraphEvent } from '../constants';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
FitViewOptions,
|
|
6
|
+
ID,
|
|
7
|
+
Point,
|
|
8
|
+
TransformOptions,
|
|
9
|
+
Vector2,
|
|
10
|
+
Vector3,
|
|
11
|
+
ViewportAnimationEffectTiming,
|
|
12
|
+
} from '../types';
|
|
5
13
|
import type { Element } from '../types/element';
|
|
6
14
|
import { getAnimationOptions } from '../utils/animation';
|
|
7
15
|
import { getBBoxSize, getCombinedBBox, getExpandedBBox, isBBoxInside, isPointInBBox } from '../utils/bbox';
|
|
@@ -131,8 +139,8 @@ export class ViewportController {
|
|
|
131
139
|
|
|
132
140
|
return mode === 'relative'
|
|
133
141
|
? {
|
|
134
|
-
position: add(position, delta),
|
|
135
|
-
focalPoint: add(focalPoint, delta),
|
|
142
|
+
position: add(position as Vector3, delta),
|
|
143
|
+
focalPoint: add(focalPoint as Vector3, delta),
|
|
136
144
|
}
|
|
137
145
|
: {
|
|
138
146
|
position: add([cx, cy, position[2]], delta),
|
|
@@ -225,6 +233,9 @@ export class ViewportController {
|
|
|
225
233
|
const scale = direction === 'x' ? scaleX : direction === 'y' ? scaleY : Math.min(scaleX, scaleY);
|
|
226
234
|
|
|
227
235
|
const _animation = this.getAnimation(animation);
|
|
236
|
+
if (!Number.isFinite(scale)) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
228
239
|
await this.transform(
|
|
229
240
|
{
|
|
230
241
|
mode: 'relative',
|
package/src/themes/base.ts
CHANGED
|
@@ -34,7 +34,7 @@ export class CollapseExpandNode extends BaseTransform {
|
|
|
34
34
|
const id = idOf(node);
|
|
35
35
|
weakAssignTo(input, 'add', 'node', node);
|
|
36
36
|
|
|
37
|
-
const relatedEdges = this.context.model.getRelatedEdgesData(id
|
|
37
|
+
const relatedEdges = this.context.model.getRelatedEdgesData(id);
|
|
38
38
|
relatedEdges.forEach((edge) => {
|
|
39
39
|
reassignTo(input, 'add', 'edge', edge);
|
|
40
40
|
});
|
|
@@ -121,9 +121,23 @@ export class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOpti
|
|
|
121
121
|
combosToUpdate.forEach(addRelatedEdges);
|
|
122
122
|
|
|
123
123
|
const pushParallelEdges = (edge: EdgeData) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
// 获取已被标记删除的边ID集合
|
|
125
|
+
// Get the set of edge IDs that have been marked for removal
|
|
126
|
+
const removedEdgeIds = new Set(input.remove.edges.keys());
|
|
127
|
+
|
|
128
|
+
// 过滤掉已删除的边,避免重定向后重新添加(修复combo收起时内部边变成loop边的问题)
|
|
129
|
+
// Filter out removed edges to prevent them from being re-added after redirection (fixes the issue where internal edges become loop edges when combo collapses)
|
|
130
|
+
const validEdgeData = model
|
|
131
|
+
.getEdgeData()
|
|
132
|
+
.filter((edge) => !removedEdgeIds.has(idOf(edge)))
|
|
133
|
+
.map((edge) => getEdgeEndsContext(model, edge));
|
|
134
|
+
|
|
135
|
+
// 查找平行边并添加到处理列表,确保只处理有效的边
|
|
136
|
+
// Find parallel edges and add them to the processing list, ensuring only valid edges are processed
|
|
137
|
+
getParallelEdges(edge, validEdgeData, true).forEach((e) => {
|
|
138
|
+
const id = idOf(e);
|
|
139
|
+
if (!edges.has(id)) edges.set(id, e);
|
|
140
|
+
});
|
|
127
141
|
};
|
|
128
142
|
|
|
129
143
|
if (edgesToRemove.size) edgesToRemove.forEach(pushParallelEdges);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type UnknownStruct = Record<string, unknown>;
|
package/src/utils/element.ts
CHANGED
|
@@ -148,7 +148,7 @@ export function isSimplePort(portStyle: NodePortStyleProps): boolean {
|
|
|
148
148
|
* @returns <zh/> 连接桩的位置 | <en/> Port Position
|
|
149
149
|
*/
|
|
150
150
|
export function getPortPosition(port: Port): Point {
|
|
151
|
-
return isPoint(port) ? port : port.getPosition();
|
|
151
|
+
return isPoint(port) ? port : (port.getPosition() as Point);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/**
|
|
@@ -246,7 +246,7 @@ export function getPortConnectionPoint(port: Port, opposite: Node | Port): Point
|
|
|
246
246
|
if (isPoint(port)) return port;
|
|
247
247
|
|
|
248
248
|
// 1. linkToCenter 为 true,则返回连接桩的中心 | If linkToCenter is true, return the center of the port
|
|
249
|
-
if (port.attributes.linkToCenter) return port.getPosition();
|
|
249
|
+
if (port.attributes.linkToCenter) return port.getPosition() as Point;
|
|
250
250
|
|
|
251
251
|
// 2. 推导对端的具体点:如果是连接桩或节点,则返回它的中心;如果是具体点,则直接返回
|
|
252
252
|
// 2. Get a specific opposite point: if it is a port or a node, return its center; if it is a specific point, return directly
|
|
@@ -257,7 +257,7 @@ export function getPortConnectionPoint(port: Port, opposite: Node | Port): Point
|
|
|
257
257
|
: opposite.getPosition();
|
|
258
258
|
|
|
259
259
|
// 3. 返回连接桩边界上的交点 | Return the intersection point on the port boundary
|
|
260
|
-
return getEllipseIntersectPoint(oppositePosition, port.getBounds());
|
|
260
|
+
return getEllipseIntersectPoint(oppositePosition as Point, port.getBounds());
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
/**
|
|
@@ -275,7 +275,7 @@ export function getNodeConnectionPoint(nodeLike: Node | Combo, opposite: Node |
|
|
|
275
275
|
? opposite
|
|
276
276
|
: isNode(opposite)
|
|
277
277
|
? opposite.getCenter()
|
|
278
|
-
: opposite.getPosition();
|
|
278
|
+
: (opposite.getPosition() as Point);
|
|
279
279
|
return nodeLike.getIntersectPoint(oppositePosition) || nodeLike.getCenter();
|
|
280
280
|
}
|
|
281
281
|
|
|
@@ -544,6 +544,6 @@ export function markToBeDestroyed(element: DisplayObject) {
|
|
|
544
544
|
* @param element - <zh/> 图形 | <en/> element
|
|
545
545
|
* @returns <zh/> 是否即将销毁 | <en/> whether the element is to be destroyed
|
|
546
546
|
*/
|
|
547
|
-
export function isToBeDestroyed(element: DisplayObject) {
|
|
547
|
+
export function isToBeDestroyed(element: DisplayObject | unknown) {
|
|
548
548
|
return get(element, '__to_be_destroyed__', false);
|
|
549
549
|
}
|
package/src/utils/layout.ts
CHANGED
|
@@ -151,9 +151,8 @@ export function layoutAdapter(
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
private transformOptions(options: STDLayoutOptions) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (!onTick) return options;
|
|
154
|
+
if (!('onTick' in options)) return options;
|
|
155
|
+
const onTick = options.onTick as (data: GraphData) => void;
|
|
157
156
|
options.onTick = (data: LayoutMapping) => onTick(layoutMapping2GraphData(data));
|
|
158
157
|
return options;
|
|
159
158
|
}
|
package/src/utils/vector.ts
CHANGED
|
@@ -219,3 +219,20 @@ export function rad(a: Vector2 | Vector3): number {
|
|
|
219
219
|
if (!x && !y) return 0;
|
|
220
220
|
return Math.atan2(y, x);
|
|
221
221
|
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* <zh/> 旋转向量(角度制)
|
|
225
|
+
*
|
|
226
|
+
* <en/> Rotational vector (Angle system)
|
|
227
|
+
* @param a - <zh/> 向量 | <en/> The vector
|
|
228
|
+
* @param angle - <zh/> 旋转角度 | <en/> The rotation angle
|
|
229
|
+
* @returns <zh/> 向量 | <en/> The vector
|
|
230
|
+
*/
|
|
231
|
+
export function rotate(a: Vector2, angle: number): Vector2 {
|
|
232
|
+
const [dx, dy] = a;
|
|
233
|
+
if (angle % 360 === 0) return [dx, dy];
|
|
234
|
+
const rad = (angle * Math.PI) / 180;
|
|
235
|
+
const cos = Math.cos(rad);
|
|
236
|
+
const sin = Math.sin(rad);
|
|
237
|
+
return [dx * cos - dy * sin, dx * sin + dy * cos];
|
|
238
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.0.
|
|
1
|
+
export const version = '5.0.50';
|