@3plate/graph-core 0.1.0 → 0.1.2
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.cjs +2198 -1322
- package/dist/index.d.cts +133 -0
- package/dist/index.d.ts +127 -45
- package/dist/index.js +2193 -1308
- package/package.json +10 -3
- package/dist/index.d.mts +0 -51
- package/dist/index.mjs +0 -323
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
type Side = 'source' | 'target';
|
|
2
|
+
type MergeOrder = Side[];
|
|
3
|
+
type NodeAlign = 'natural' | 'top' | 'bottom' | 'left' | 'right';
|
|
4
|
+
type Orientation = 'TB' | 'BT' | 'LR' | 'RL';
|
|
5
|
+
|
|
6
|
+
type LayoutStep = 'alignChildren' | 'alignParents' | 'compact';
|
|
7
|
+
|
|
8
|
+
type GraphOptions = {
|
|
9
|
+
mergeOrder?: MergeOrder;
|
|
10
|
+
nodeMargin?: number;
|
|
11
|
+
dummyNodeSize?: number;
|
|
12
|
+
defaultPortOffset?: number;
|
|
13
|
+
nodeAlign?: NodeAlign;
|
|
14
|
+
edgeSpacing?: number;
|
|
15
|
+
turnRadius?: number;
|
|
16
|
+
orientation?: Orientation;
|
|
17
|
+
layerMargin?: number;
|
|
18
|
+
alignIterations?: number;
|
|
19
|
+
alignThreshold?: number;
|
|
20
|
+
separateTrackSets?: boolean;
|
|
21
|
+
layoutSteps?: LayoutStep[] | null;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type EdgeAttributes = {
|
|
25
|
+
width?: number;
|
|
26
|
+
style?: string;
|
|
27
|
+
color?: string;
|
|
28
|
+
turnRadius?: number;
|
|
29
|
+
sourceTerminal?: string | null;
|
|
30
|
+
targetTerminal?: string | null;
|
|
31
|
+
};
|
|
32
|
+
type NodeAttributes = {
|
|
33
|
+
strokeWidth?: number;
|
|
34
|
+
strokeStyle?: string;
|
|
35
|
+
};
|
|
36
|
+
type RenderNode<N> = (node: N) => HTMLElement;
|
|
37
|
+
type EdgeStyle = (type: string) => EdgeAttributes;
|
|
38
|
+
type NodeStyle<N> = (node: N) => NodeAttributes;
|
|
39
|
+
type PortStyle = 'inside' | 'outside' | 'custom';
|
|
40
|
+
type CanvasOptions<N> = {
|
|
41
|
+
renderNode?: RenderNode<N>;
|
|
42
|
+
nodeStyle?: NodeStyle<N>;
|
|
43
|
+
edgeStyle?: EdgeStyle;
|
|
44
|
+
width?: number | string;
|
|
45
|
+
height?: number | string;
|
|
46
|
+
portStyle?: PortStyle;
|
|
47
|
+
classPrefix?: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type StructuredNode<P> = {
|
|
51
|
+
id: string;
|
|
52
|
+
title?: string;
|
|
53
|
+
text?: string;
|
|
54
|
+
ports?: {
|
|
55
|
+
in?: P[];
|
|
56
|
+
out?: P[];
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
type StructuredEdge = {
|
|
60
|
+
source: {
|
|
61
|
+
id: string;
|
|
62
|
+
port?: string;
|
|
63
|
+
};
|
|
64
|
+
target: {
|
|
65
|
+
id: string;
|
|
66
|
+
port?: string;
|
|
67
|
+
};
|
|
68
|
+
type?: string;
|
|
69
|
+
};
|
|
70
|
+
type StructuredPort = {
|
|
71
|
+
id: string;
|
|
72
|
+
label: string;
|
|
73
|
+
};
|
|
74
|
+
type Nav = 'first' | 'last' | 'prev' | 'next';
|
|
75
|
+
type NodeProps<N, P> = (node: N) => StructuredNode<P>;
|
|
76
|
+
type EdgeProps<E> = (edge: E) => StructuredEdge;
|
|
77
|
+
type PortProps<P> = (port: P) => StructuredPort;
|
|
78
|
+
type APIOptions<N, E, P> = GraphOptions & CanvasOptions<N> & {
|
|
79
|
+
nodeProps?: NodeProps<N, P>;
|
|
80
|
+
edgeProps?: EdgeProps<E>;
|
|
81
|
+
portProps?: PortProps<P>;
|
|
82
|
+
};
|
|
83
|
+
type APIArguments<N, E, P> = APIOptions<N, E, P> & {
|
|
84
|
+
nodes?: N[];
|
|
85
|
+
edges?: E[];
|
|
86
|
+
};
|
|
87
|
+
declare class API<N, E, P> {
|
|
88
|
+
private state;
|
|
89
|
+
private seq;
|
|
90
|
+
private index;
|
|
91
|
+
private canvas;
|
|
92
|
+
private _options;
|
|
93
|
+
options: Required<APIOptions<N, E, P>>;
|
|
94
|
+
constructor(options: APIOptions<N, E, P>);
|
|
95
|
+
render(): HTMLElement;
|
|
96
|
+
nav(nav: Nav): void;
|
|
97
|
+
private applyDiff;
|
|
98
|
+
addNode(node: N): Promise<void>;
|
|
99
|
+
deleteNode(node: N): Promise<void>;
|
|
100
|
+
updateNode(node: N): Promise<void>;
|
|
101
|
+
addEdge(edge: E): Promise<void>;
|
|
102
|
+
deleteEdge(edge: E): Promise<void>;
|
|
103
|
+
update(callback: (update: Update<N, E>) => void): Promise<void>;
|
|
104
|
+
private measureNodes;
|
|
105
|
+
private getDims;
|
|
106
|
+
private _updateNode;
|
|
107
|
+
private _updateEdge;
|
|
108
|
+
private _addNode;
|
|
109
|
+
private _removeNode;
|
|
110
|
+
private _addEdge;
|
|
111
|
+
private _removeEdge;
|
|
112
|
+
private _onOptionChange;
|
|
113
|
+
}
|
|
114
|
+
declare class Update<N, E> {
|
|
115
|
+
addedNodes: N[];
|
|
116
|
+
removedNodes: N[];
|
|
117
|
+
updatedNodes: N[];
|
|
118
|
+
addedEdges: E[];
|
|
119
|
+
removedEdges: E[];
|
|
120
|
+
updatedEdges: E[];
|
|
121
|
+
desc?: string;
|
|
122
|
+
constructor();
|
|
123
|
+
describe(desc: string): void;
|
|
124
|
+
addNode(node: N): void;
|
|
125
|
+
deleteNode(node: N): void;
|
|
126
|
+
updateNode(node: N): void;
|
|
127
|
+
addEdge(edge: E): void;
|
|
128
|
+
deleteEdge(edge: E): void;
|
|
129
|
+
updateEdge(edge: E): void;
|
|
130
|
+
}
|
|
131
|
+
declare function graph<N, E, P>(args?: APIArguments<N, E, P>): Promise<API<N, E, P>>;
|
|
132
|
+
|
|
133
|
+
export { graph as default, graph };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,51 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
type Side = 'source' | 'target';
|
|
2
|
+
type MergeOrder = Side[];
|
|
3
|
+
type NodeAlign = 'natural' | 'top' | 'bottom' | 'left' | 'right';
|
|
4
|
+
type Orientation = 'TB' | 'BT' | 'LR' | 'RL';
|
|
5
|
+
|
|
6
|
+
type LayoutStep = 'alignChildren' | 'alignParents' | 'compact';
|
|
7
|
+
|
|
8
|
+
type GraphOptions = {
|
|
9
|
+
mergeOrder?: MergeOrder;
|
|
10
|
+
nodeMargin?: number;
|
|
11
|
+
dummyNodeSize?: number;
|
|
12
|
+
defaultPortOffset?: number;
|
|
13
|
+
nodeAlign?: NodeAlign;
|
|
14
|
+
edgeSpacing?: number;
|
|
15
|
+
turnRadius?: number;
|
|
16
|
+
orientation?: Orientation;
|
|
17
|
+
layerMargin?: number;
|
|
18
|
+
alignIterations?: number;
|
|
19
|
+
alignThreshold?: number;
|
|
20
|
+
separateTrackSets?: boolean;
|
|
21
|
+
layoutSteps?: LayoutStep[] | null;
|
|
22
|
+
};
|
|
17
23
|
|
|
18
|
-
|
|
24
|
+
type EdgeAttributes = {
|
|
25
|
+
width?: number;
|
|
26
|
+
style?: string;
|
|
27
|
+
color?: string;
|
|
28
|
+
turnRadius?: number;
|
|
29
|
+
sourceTerminal?: string | null;
|
|
30
|
+
targetTerminal?: string | null;
|
|
31
|
+
};
|
|
32
|
+
type NodeAttributes = {
|
|
33
|
+
strokeWidth?: number;
|
|
34
|
+
strokeStyle?: string;
|
|
35
|
+
};
|
|
36
|
+
type RenderNode<N> = (node: N) => HTMLElement;
|
|
37
|
+
type EdgeStyle = (type: string) => EdgeAttributes;
|
|
38
|
+
type NodeStyle<N> = (node: N) => NodeAttributes;
|
|
39
|
+
type PortStyle = 'inside' | 'outside' | 'custom';
|
|
40
|
+
type CanvasOptions<N> = {
|
|
41
|
+
renderNode?: RenderNode<N>;
|
|
42
|
+
nodeStyle?: NodeStyle<N>;
|
|
43
|
+
edgeStyle?: EdgeStyle;
|
|
44
|
+
width?: number | string;
|
|
45
|
+
height?: number | string;
|
|
46
|
+
portStyle?: PortStyle;
|
|
47
|
+
classPrefix?: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type StructuredNode<P> = {
|
|
19
51
|
id: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
52
|
+
title?: string;
|
|
53
|
+
text?: string;
|
|
54
|
+
ports?: {
|
|
55
|
+
in?: P[];
|
|
56
|
+
out?: P[];
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
type StructuredEdge = {
|
|
60
|
+
source: {
|
|
61
|
+
id: string;
|
|
62
|
+
port?: string;
|
|
63
|
+
};
|
|
64
|
+
target: {
|
|
65
|
+
id: string;
|
|
66
|
+
port?: string;
|
|
67
|
+
};
|
|
68
|
+
type?: string;
|
|
69
|
+
};
|
|
70
|
+
type StructuredPort = {
|
|
71
|
+
id: string;
|
|
72
|
+
label: string;
|
|
73
|
+
};
|
|
74
|
+
type Nav = 'first' | 'last' | 'prev' | 'next';
|
|
75
|
+
type NodeProps<N, P> = (node: N) => StructuredNode<P>;
|
|
76
|
+
type EdgeProps<E> = (edge: E) => StructuredEdge;
|
|
77
|
+
type PortProps<P> = (port: P) => StructuredPort;
|
|
78
|
+
type APIOptions<N, E, P> = GraphOptions & CanvasOptions<N> & {
|
|
79
|
+
nodeProps?: NodeProps<N, P>;
|
|
80
|
+
edgeProps?: EdgeProps<E>;
|
|
81
|
+
portProps?: PortProps<P>;
|
|
82
|
+
};
|
|
83
|
+
type APIArguments<N, E, P> = APIOptions<N, E, P> & {
|
|
84
|
+
nodes?: N[];
|
|
85
|
+
edges?: E[];
|
|
86
|
+
};
|
|
87
|
+
declare class API<N, E, P> {
|
|
88
|
+
private state;
|
|
89
|
+
private seq;
|
|
90
|
+
private index;
|
|
91
|
+
private canvas;
|
|
92
|
+
private _options;
|
|
93
|
+
options: Required<APIOptions<N, E, P>>;
|
|
94
|
+
constructor(options: APIOptions<N, E, P>);
|
|
95
|
+
render(): HTMLElement;
|
|
96
|
+
nav(nav: Nav): void;
|
|
97
|
+
private applyDiff;
|
|
98
|
+
addNode(node: N): Promise<void>;
|
|
99
|
+
deleteNode(node: N): Promise<void>;
|
|
100
|
+
updateNode(node: N): Promise<void>;
|
|
101
|
+
addEdge(edge: E): Promise<void>;
|
|
102
|
+
deleteEdge(edge: E): Promise<void>;
|
|
103
|
+
update(callback: (update: Update<N, E>) => void): Promise<void>;
|
|
104
|
+
private measureNodes;
|
|
105
|
+
private getDims;
|
|
106
|
+
private _updateNode;
|
|
107
|
+
private _updateEdge;
|
|
108
|
+
private _addNode;
|
|
109
|
+
private _removeNode;
|
|
110
|
+
private _addEdge;
|
|
111
|
+
private _removeEdge;
|
|
112
|
+
private _onOptionChange;
|
|
31
113
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
114
|
+
declare class Update<N, E> {
|
|
115
|
+
addedNodes: N[];
|
|
116
|
+
removedNodes: N[];
|
|
117
|
+
updatedNodes: N[];
|
|
118
|
+
addedEdges: E[];
|
|
119
|
+
removedEdges: E[];
|
|
120
|
+
updatedEdges: E[];
|
|
121
|
+
desc?: string;
|
|
40
122
|
constructor();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
hasEdge(id: string): boolean;
|
|
123
|
+
describe(desc: string): void;
|
|
124
|
+
addNode(node: N): void;
|
|
125
|
+
deleteNode(node: N): void;
|
|
126
|
+
updateNode(node: N): void;
|
|
127
|
+
addEdge(edge: E): void;
|
|
128
|
+
deleteEdge(edge: E): void;
|
|
129
|
+
updateEdge(edge: E): void;
|
|
49
130
|
}
|
|
131
|
+
declare function graph<N, E, P>(args?: APIArguments<N, E, P>): Promise<API<N, E, P>>;
|
|
50
132
|
|
|
51
|
-
export {
|
|
133
|
+
export { graph as default, graph };
|