topo-engine 0.1.0 → 0.1.3
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 +395 -163
- package/dist/index.d.ts +115 -0
- package/dist/style.css +366 -248
- package/dist/topo-engine.cjs +228 -91
- package/dist/topo-engine.cjs.map +1 -1
- package/dist/topo-engine.js +228 -91
- package/dist/topo-engine.js.map +1 -1
- package/dist/topo-engine.umd.cjs +228 -91
- package/dist/topo-engine.umd.cjs.map +1 -1
- package/package.json +4 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 拓扑引擎类型声明文件
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// 核心 API
|
|
6
|
+
export class TopoApi {
|
|
7
|
+
constructor(graph: any, model: any, layout: any, nodeByIdMap: Map<string, any>);
|
|
8
|
+
|
|
9
|
+
// 查询 API
|
|
10
|
+
getNode(nodeId: string): any;
|
|
11
|
+
getAllNodes(): any[];
|
|
12
|
+
findNodes(filter: object): any[];
|
|
13
|
+
getSelectedId(): string | null;
|
|
14
|
+
getNeighbors(nodeId: string): { upstream: any[], downstream: any[] };
|
|
15
|
+
getStreamNodes(nodeId: string, direction: 'upstream' | 'downstream'): any[];
|
|
16
|
+
getTrunkNodes(): any[];
|
|
17
|
+
getSubtreeNodes(nodeId: string): any[];
|
|
18
|
+
getPath(fromId: string, toId: string): any[] | null;
|
|
19
|
+
getEdge(srcId: string, tgtId: string): any;
|
|
20
|
+
getEdges(): any[];
|
|
21
|
+
getStreamEdges(nodeId: string, direction: 'upstream' | 'downstream'): any[];
|
|
22
|
+
getMainEdge(): any[];
|
|
23
|
+
getNodePosition(nodeId: string): { x: number, y: number } | null;
|
|
24
|
+
getEdgePath(srcId: string, tgtId: string): number[][] | null;
|
|
25
|
+
getGraphBounds(): { minX: number, minY: number, maxX: number, maxY: number };
|
|
26
|
+
getStats(): any;
|
|
27
|
+
|
|
28
|
+
// 视图控制
|
|
29
|
+
fitView(padding?: number): void;
|
|
30
|
+
zoomTo(ratio: number, center?: { x: number, y: number }): void;
|
|
31
|
+
zoomIn(step?: number): void;
|
|
32
|
+
zoomOut(step?: number): void;
|
|
33
|
+
locateNode(nodeId: string, zoom?: number): void;
|
|
34
|
+
getViewport(): { zoom: number, center: { x: number, y: number } };
|
|
35
|
+
|
|
36
|
+
// 节点样式
|
|
37
|
+
setNodeStyle(nodeId: string, style: object): void;
|
|
38
|
+
batchSetNodeStyle(nodeIds: string[], style: object): void;
|
|
39
|
+
resetNodeStyle(nodeId: string): void;
|
|
40
|
+
resetAllNodeStyles(): void;
|
|
41
|
+
|
|
42
|
+
// 边样式
|
|
43
|
+
setEdgeStyle(srcId: string, tgtId: string, style: object): void;
|
|
44
|
+
batchSetEdgeStyle(edgeIds: [string, string][], style: object): void;
|
|
45
|
+
resetEdgeStyle(srcId: string, tgtId: string): void;
|
|
46
|
+
|
|
47
|
+
// 高亮与标注
|
|
48
|
+
highlightNode(nodeId: string, opts?: object): void;
|
|
49
|
+
unhighlightNode(nodeId: string): void;
|
|
50
|
+
highlightPath(nodeIds: string[], opts?: object): void;
|
|
51
|
+
unhighlightAll(): void;
|
|
52
|
+
dimOthers(keepIds: string[], opacity?: number): void;
|
|
53
|
+
|
|
54
|
+
// 动画
|
|
55
|
+
setNodePulse(nodeId: string, opts?: object): void;
|
|
56
|
+
setEdgeFlow(srcId: string, tgtId: string, opts?: object): void;
|
|
57
|
+
removeAnimation(targetId: string): void;
|
|
58
|
+
removeAllAnimations(): void;
|
|
59
|
+
|
|
60
|
+
// 文字标注
|
|
61
|
+
setText(nodeId: string, text: string, opts?: object): void;
|
|
62
|
+
removeText(nodeId: string): void;
|
|
63
|
+
removeAllTexts(): void;
|
|
64
|
+
setDeviceText(cat: string, fontSize: number): void;
|
|
65
|
+
changeUserName(mode: 'full' | 'short' | 'hidden'): void;
|
|
66
|
+
|
|
67
|
+
// 卡片盒
|
|
68
|
+
showCard(nodeId: string, content: object): void;
|
|
69
|
+
hideCard(nodeId: string): void;
|
|
70
|
+
hideAllCards(): void;
|
|
71
|
+
|
|
72
|
+
// 连接线与拓扑线
|
|
73
|
+
addConnection(fromId: string, toId: string, opts?: object): void;
|
|
74
|
+
removeConnection(fromId: string, toId: string): void;
|
|
75
|
+
removeAllConnections(): void;
|
|
76
|
+
addTopoLine(nodeIds: string[], opts?: object): string;
|
|
77
|
+
removeTopoLine(lineId: string): void;
|
|
78
|
+
removeAllTopoLines(): void;
|
|
79
|
+
|
|
80
|
+
// 事件系统
|
|
81
|
+
on(event: string, handler: Function): void;
|
|
82
|
+
off(event: string, handler?: Function): void;
|
|
83
|
+
|
|
84
|
+
// 导出
|
|
85
|
+
exportPng(filename?: string): Promise<void>;
|
|
86
|
+
toDataURL(opts?: object): Promise<string>;
|
|
87
|
+
getGraphData(): object;
|
|
88
|
+
|
|
89
|
+
// 底层访问
|
|
90
|
+
getGraphInstance(): any;
|
|
91
|
+
getModel(): any;
|
|
92
|
+
getLayoutData(): any;
|
|
93
|
+
getNodeByIdMap(): Map<string, any>;
|
|
94
|
+
|
|
95
|
+
// 数据刷新
|
|
96
|
+
update(graph: any, model: any, layout: any, nodeByIdMap: Map<string, any>): void;
|
|
97
|
+
|
|
98
|
+
// 销毁
|
|
99
|
+
destroy(): void;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 工具函数
|
|
103
|
+
export function parseTopo(raw: object): any;
|
|
104
|
+
export function computeOrthogonalLayout(model: any, options?: object): any;
|
|
105
|
+
export function assertOrthogonal(model: any, edgeCP: Map<string, number[][]>): string[];
|
|
106
|
+
export function buildGraphData(model: any, layout: any): any;
|
|
107
|
+
export function edgeStyle(datum: any): any;
|
|
108
|
+
export function calculateTopDistances(edges: any[], nodes: any[], edgeCP: Map<string, number[][]>, fishboneRibs: Set<string>, topN?: number): any[];
|
|
109
|
+
export function getSymbolSpec(cat: string): { w: number, h: number };
|
|
110
|
+
|
|
111
|
+
// 常量
|
|
112
|
+
export const SYMBOL_SPEC: Record<string, { w: number, h: number }>;
|
|
113
|
+
export const FONT: string;
|
|
114
|
+
export const VERSION: string;
|
|
115
|
+
export const DESCRIPTION: string;
|