@knotx/core 0.2.13 → 0.3.0
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/definition.d.cts +1 -1
- package/dist/definition.d.mts +1 -1
- package/dist/definition.d.ts +1 -1
- package/dist/index.cjs +117 -51
- package/dist/index.d.cts +6 -151
- package/dist/index.d.mts +6 -151
- package/dist/index.d.ts +6 -151
- package/dist/index.js +117 -51
- package/dist/shared/core.CpyG0nWq.d.cts +323 -0
- package/dist/shared/core.CpyG0nWq.d.mts +323 -0
- package/dist/shared/core.CpyG0nWq.d.ts +323 -0
- package/package.json +6 -6
- package/dist/shared/core.Cwp_TTTs.d.cts +0 -146
- package/dist/shared/core.Cwp_TTTs.d.mts +0 -146
- package/dist/shared/core.Cwp_TTTs.d.ts +0 -146
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { Schema } from 'jsonschema';
|
|
2
|
+
import { BehaviorSubject, SubscriptionLike } from 'rxjs';
|
|
3
|
+
import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 用户交互优先级定义
|
|
7
|
+
* 数值越大优先级越高
|
|
8
|
+
*/
|
|
9
|
+
declare enum InteractionPriority {
|
|
10
|
+
/** 文本输入框激活状态(输入中需独占) */
|
|
11
|
+
InputActive = 2000,
|
|
12
|
+
/** 实体连接拖拽 */
|
|
13
|
+
EntityConnectDrag = 1930,
|
|
14
|
+
/** 实体测量拖拽 */
|
|
15
|
+
EntityMeasureDrag = 1920,
|
|
16
|
+
/** 实体位置拖拽 */
|
|
17
|
+
EntityPositionDrag = 1910,
|
|
18
|
+
/** 连续操作:画布拖拽、缩放等进行中的动作 */
|
|
19
|
+
ContinuousDrag = 1900,
|
|
20
|
+
/** 右键菜单/上下文操作 */
|
|
21
|
+
ContextMenu = 1800,
|
|
22
|
+
/** 键盘快捷键(如 Delete/Ctrl+C) */
|
|
23
|
+
KeyboardShortcut = 1700,
|
|
24
|
+
/** 单击选中元素 */
|
|
25
|
+
ClickSelection = 1600,
|
|
26
|
+
/** 双击编辑元素 */
|
|
27
|
+
DoubleClickEdit = 1500,
|
|
28
|
+
/** 框选(多选)操作 */
|
|
29
|
+
MarqueeSelection = 1300,
|
|
30
|
+
/** 套索选择(Lasso Select) */
|
|
31
|
+
LassoSelection = 1250,
|
|
32
|
+
/** 长按操作(长按菜单/工具) */
|
|
33
|
+
LongPress = 1100,
|
|
34
|
+
/** 悬停提示(Hover Tooltip) */
|
|
35
|
+
HoverTooltip = 1000,
|
|
36
|
+
/** 画布平移(空格拖拽或手势) */
|
|
37
|
+
CanvasPan = 900,
|
|
38
|
+
/** 画布缩放(滚轮或双指) */
|
|
39
|
+
CanvasZoom = 800,
|
|
40
|
+
/** 多指手势(如三指滑动) */
|
|
41
|
+
MultiTouchGesture = 700
|
|
42
|
+
}
|
|
43
|
+
interface Interaction {
|
|
44
|
+
pluginId: string;
|
|
45
|
+
type: string;
|
|
46
|
+
priority: InteractionPriority;
|
|
47
|
+
active?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 交互管理器
|
|
51
|
+
*/
|
|
52
|
+
declare class InteractionManager {
|
|
53
|
+
private interactions;
|
|
54
|
+
/**
|
|
55
|
+
* 获取当前活动的交互
|
|
56
|
+
*/
|
|
57
|
+
get activeInteraction(): Interaction | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* 检查是否可以交互
|
|
60
|
+
* @param pluginId 插件ID
|
|
61
|
+
* @param type 交互类型
|
|
62
|
+
* @param autoStartPriority 自动启动优先级
|
|
63
|
+
* @returns 是否可以交互
|
|
64
|
+
*/
|
|
65
|
+
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* 启动交互
|
|
68
|
+
* @param pluginId 插件ID
|
|
69
|
+
* @param type 交互类型
|
|
70
|
+
* @param priority 优先级
|
|
71
|
+
* @returns 取消交互的函数
|
|
72
|
+
*/
|
|
73
|
+
startInteraction(pluginId: string, type: string, priority: InteractionPriority): () => void;
|
|
74
|
+
/**
|
|
75
|
+
* 结束交互
|
|
76
|
+
* @param pluginId 插件ID
|
|
77
|
+
* @param type 交互类型
|
|
78
|
+
*/
|
|
79
|
+
endInteraction(pluginId: string, type: string): void;
|
|
80
|
+
private updateActive;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface EngineOptions<TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
|
|
84
|
+
container: Container;
|
|
85
|
+
plugins?: Plugin[];
|
|
86
|
+
pluginConfig?: IRecord;
|
|
87
|
+
nodes?: Node<TNode>[];
|
|
88
|
+
edges?: Edge<TEdge>[];
|
|
89
|
+
runtime?: IEngineRuntime;
|
|
90
|
+
}
|
|
91
|
+
declare module '@knotx/core' {
|
|
92
|
+
interface EngineTools {
|
|
93
|
+
listPlugins: Engine['listPlugins'];
|
|
94
|
+
listPluginTools: Engine['listPluginTools'];
|
|
95
|
+
getNodes: Engine['getNodes'];
|
|
96
|
+
getEdges: Engine['getEdges'];
|
|
97
|
+
getNode: Engine['getNode'];
|
|
98
|
+
getEdge: Engine['getEdge'];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
interface CallToolMethod {
|
|
102
|
+
<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: Extract<T, keyof PluginTools>, toolName: Extract<TP, keyof PluginTools[T]>, ...args: Parameters<PluginTools[T][TP]>): ReturnType<PluginTools[T][TP]>;
|
|
103
|
+
<T extends keyof EngineTools>(engineToolName: Extract<T, keyof EngineTools>, ...args: Parameters<EngineTools[T]>): ReturnType<EngineTools[T]>;
|
|
104
|
+
}
|
|
105
|
+
declare class Engine<TRenderType extends RenderType = RenderType, TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
|
|
106
|
+
readonly runtime: IEngineRuntime;
|
|
107
|
+
readonly interactionManager: InteractionManager;
|
|
108
|
+
readonly nodesManager: DataManager<Node<TNode>>;
|
|
109
|
+
readonly edgesManager: DataManager<Edge<TEdge>>;
|
|
110
|
+
private container$;
|
|
111
|
+
private nodes$;
|
|
112
|
+
private edges$;
|
|
113
|
+
private layers$;
|
|
114
|
+
private plugins$;
|
|
115
|
+
private nodeRenderers$;
|
|
116
|
+
private edgeRenderers$;
|
|
117
|
+
private _pluginDataContainer;
|
|
118
|
+
private _pluginToolsContainer;
|
|
119
|
+
private engineTools;
|
|
120
|
+
private toolParametersValidator;
|
|
121
|
+
get container(): Container;
|
|
122
|
+
set container(value: Container);
|
|
123
|
+
get nodes(): Node<TNode>[];
|
|
124
|
+
get edges(): Edge<TEdge>[];
|
|
125
|
+
get layers(): Map<number, LayerComponent<TRenderType>[]>;
|
|
126
|
+
get plugins(): IPlugin<string, any, RenderType>[];
|
|
127
|
+
constructor(options: EngineOptions<TNode, TEdge>);
|
|
128
|
+
private init;
|
|
129
|
+
callTool: CallToolMethod;
|
|
130
|
+
getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
|
|
131
|
+
addNodePipe(pipe: DataOperationPipe<Node<TNode>>): () => void;
|
|
132
|
+
addEdgePipe(pipe: DataOperationPipe<Edge<TEdge>>): () => void;
|
|
133
|
+
changePluginConfig({ pluginName, config }: {
|
|
134
|
+
pluginName: string;
|
|
135
|
+
config: IRecord;
|
|
136
|
+
}): void;
|
|
137
|
+
dispatchNodeOperation(operation: DataOperation<Node<TNode>>): void;
|
|
138
|
+
dispatchEdgeOperation(operation: DataOperation<Edge<TEdge>>): void;
|
|
139
|
+
getPlugin<TPlugin extends IPlugin>({ pluginName }: {
|
|
140
|
+
pluginName: TPlugin['name'];
|
|
141
|
+
}): TPlugin | undefined;
|
|
142
|
+
getNode({ id }: {
|
|
143
|
+
id: string;
|
|
144
|
+
}): Node<TNode> | undefined;
|
|
145
|
+
getNodeDraft({ id }: {
|
|
146
|
+
id: string;
|
|
147
|
+
}): Node<TNode> | undefined;
|
|
148
|
+
getNodes(): Node<TNode>[];
|
|
149
|
+
getNodeRenderer(type: string): NodeRenderType | undefined;
|
|
150
|
+
getEdge({ id }: {
|
|
151
|
+
id: string;
|
|
152
|
+
}): Edge<TEdge> | undefined;
|
|
153
|
+
getEdgeDraft({ id }: {
|
|
154
|
+
id: string;
|
|
155
|
+
}): Edge<TEdge> | undefined;
|
|
156
|
+
getEdges(): Edge<TEdge>[];
|
|
157
|
+
getEdgeRenderer(type: string): EdgeRenderType | undefined;
|
|
158
|
+
registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
|
|
159
|
+
resetPluginData<T extends keyof PluginData>(pluginName: T): void;
|
|
160
|
+
registerPluginTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, property: TP, data: {
|
|
161
|
+
description: string;
|
|
162
|
+
parameters: Schema;
|
|
163
|
+
func: PluginTools[T][TP];
|
|
164
|
+
}): void;
|
|
165
|
+
resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
|
|
166
|
+
registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
|
|
167
|
+
registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
|
|
168
|
+
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
|
|
169
|
+
startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
|
|
170
|
+
endInteraction(pluginId: string, type: string): void;
|
|
171
|
+
listPlugins(): IPluginInfo[];
|
|
172
|
+
listPluginTools({ pluginName }: {
|
|
173
|
+
pluginName: string;
|
|
174
|
+
}): IToolInfo[];
|
|
175
|
+
listEngineTools(): IToolInfo[];
|
|
176
|
+
destroy(): void;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
180
|
+
abstract name: TPluginName;
|
|
181
|
+
constructor(__: TPluginConfig);
|
|
182
|
+
private static _instanceId;
|
|
183
|
+
private _instanceId;
|
|
184
|
+
get pluginId(): string;
|
|
185
|
+
/**
|
|
186
|
+
* 插件生命周期中的订阅回调
|
|
187
|
+
* 可随时存入,销毁时会自动执行
|
|
188
|
+
*/
|
|
189
|
+
protected subscriptions: (SubscriptionLike | (() => void))[];
|
|
190
|
+
protected callTool: Engine['callTool'];
|
|
191
|
+
onDestroy(): void;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
type HorizontalAlignment = 'left' | 'right';
|
|
195
|
+
type VerticalAlignment = 'top' | 'bottom';
|
|
196
|
+
type IRecord = Record<string, any>;
|
|
197
|
+
interface NodePosition {
|
|
198
|
+
x: number;
|
|
199
|
+
y: number;
|
|
200
|
+
}
|
|
201
|
+
interface NodeMeasured {
|
|
202
|
+
width: number;
|
|
203
|
+
height: number;
|
|
204
|
+
}
|
|
205
|
+
interface Node<TData extends IRecord = IRecord> {
|
|
206
|
+
id: string;
|
|
207
|
+
type?: string;
|
|
208
|
+
position: NodePosition;
|
|
209
|
+
measured?: NodeMeasured;
|
|
210
|
+
data: TData;
|
|
211
|
+
}
|
|
212
|
+
interface NodeProps<TData extends IRecord = IRecord> {
|
|
213
|
+
node: Node<TData>;
|
|
214
|
+
}
|
|
215
|
+
interface Edge<TData extends IRecord = IRecord> {
|
|
216
|
+
id: string;
|
|
217
|
+
source: string;
|
|
218
|
+
target: string;
|
|
219
|
+
type?: string;
|
|
220
|
+
data?: TData;
|
|
221
|
+
}
|
|
222
|
+
interface EdgeProps<TData extends IRecord = IRecord> {
|
|
223
|
+
edge: Edge<TData>;
|
|
224
|
+
sourceX: number;
|
|
225
|
+
sourceY: number;
|
|
226
|
+
targetX: number;
|
|
227
|
+
targetY: number;
|
|
228
|
+
}
|
|
229
|
+
interface Container {
|
|
230
|
+
width: number;
|
|
231
|
+
height: number;
|
|
232
|
+
}
|
|
233
|
+
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
234
|
+
type RenderType = (...args: any[]) => any;
|
|
235
|
+
type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
236
|
+
type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
237
|
+
declare enum Layer {
|
|
238
|
+
Canvas = 0,
|
|
239
|
+
Background = 4,
|
|
240
|
+
Edges = 16,
|
|
241
|
+
Nodes = 64,
|
|
242
|
+
Foreground = 256
|
|
243
|
+
}
|
|
244
|
+
interface LayerComponent<TRenderType> {
|
|
245
|
+
plugin: string;
|
|
246
|
+
name: string;
|
|
247
|
+
layer: Layer;
|
|
248
|
+
render: TRenderType;
|
|
249
|
+
/**
|
|
250
|
+
* 层级偏移量
|
|
251
|
+
* @default 0
|
|
252
|
+
* (layer >> 1, layer << 1]
|
|
253
|
+
*/
|
|
254
|
+
offset?: number;
|
|
255
|
+
}
|
|
256
|
+
interface IPlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
257
|
+
name: TPluginName;
|
|
258
|
+
pluginId: string;
|
|
259
|
+
description?: string;
|
|
260
|
+
onInit?: (config: TPluginConfig) => void;
|
|
261
|
+
onConfigChange?: (config: TPluginConfig) => void;
|
|
262
|
+
onDestroy?: () => void;
|
|
263
|
+
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
264
|
+
}
|
|
265
|
+
type Plugin<TName extends string = string, TConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
266
|
+
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
267
|
+
[TName in T as Extract<TPlugins[number], Plugin<TName>> extends Plugin<TName, undefined> ? never : TName]: Extract<TPlugins[number], Plugin<TName>> extends infer T ? T extends Plugin<TName, infer TConfig> ? TConfig : never : never;
|
|
268
|
+
} : {}));
|
|
269
|
+
/**
|
|
270
|
+
* plugin data host
|
|
271
|
+
* @example
|
|
272
|
+
* `declare module '@knotx/core' {
|
|
273
|
+
* interface PluginData {
|
|
274
|
+
* pluginName: {
|
|
275
|
+
* property: any
|
|
276
|
+
* }
|
|
277
|
+
* }
|
|
278
|
+
* }`
|
|
279
|
+
*/
|
|
280
|
+
interface PluginData {
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* plugin tools host
|
|
284
|
+
* @example
|
|
285
|
+
* `declare module '@knotx/core' {
|
|
286
|
+
* interface PluginTools {
|
|
287
|
+
* pluginName: {
|
|
288
|
+
* toolName: (params: any) => any
|
|
289
|
+
* }
|
|
290
|
+
* }
|
|
291
|
+
* }`
|
|
292
|
+
*/
|
|
293
|
+
interface PluginTools {
|
|
294
|
+
}
|
|
295
|
+
interface EngineTools {
|
|
296
|
+
}
|
|
297
|
+
interface IPluginInfo {
|
|
298
|
+
name: string;
|
|
299
|
+
description?: string;
|
|
300
|
+
}
|
|
301
|
+
interface IToolInfo {
|
|
302
|
+
type: 'function';
|
|
303
|
+
name: string;
|
|
304
|
+
description: string;
|
|
305
|
+
parameters: Schema;
|
|
306
|
+
}
|
|
307
|
+
type NodeOperationPipe<T extends IRecord = any> = DataOperationPipe<Node<T>>;
|
|
308
|
+
type EdgeOperationPipe<T extends IRecord = any> = DataOperationPipe<Edge<T>>;
|
|
309
|
+
type NodeOperation<T extends IRecord = any> = DataOperation<Node<T>>;
|
|
310
|
+
type EdgeOperation<T extends IRecord = any> = DataOperation<Edge<T>>;
|
|
311
|
+
type NodeOperatorFunction<T extends IRecord = any, TArgs extends any[] = any[]> = (...args: TArgs) => NodeOperation<T>[];
|
|
312
|
+
type EdgeOperatorFunction<T extends IRecord = any, TArgs extends any[] = any[]> = (...args: TArgs) => EdgeOperation<T>[];
|
|
313
|
+
interface IEngineRuntime {
|
|
314
|
+
render?: {
|
|
315
|
+
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
316
|
+
paths: string[];
|
|
317
|
+
selector?: (value: T, context?: any) => R;
|
|
318
|
+
context?: any;
|
|
319
|
+
}) => T | R;
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export { type Interaction as A, InteractionManager as B, type Container as C, BasePlugin as D, Engine as E, type HorizontalAlignment as H, type IRecord as I, Layer as L, type NodePosition as N, type Position as P, type RenderType as R, type VerticalAlignment as V, type NodeMeasured as a, type Node as b, type NodeProps as c, type Edge as d, type EdgeProps as e, type NodeRenderType as f, type EdgeRenderType as g, type LayerComponent as h, type IPlugin as i, type Plugin as j, type PluginConfigs as k, type PluginData as l, type PluginTools as m, type EngineTools as n, type IPluginInfo as o, type IToolInfo as p, type NodeOperationPipe as q, type EdgeOperationPipe as r, type NodeOperation as s, type EdgeOperation as t, type NodeOperatorFunction as u, type EdgeOperatorFunction as v, type IEngineRuntime as w, type EngineOptions as x, type CallToolMethod as y, InteractionPriority as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Core for Knotx",
|
|
5
5
|
"author": "boenfu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"jsonschema": "^1.5.0",
|
|
47
47
|
"lodash-es": "^4.17.21",
|
|
48
48
|
"rxjs": "^7.8.1",
|
|
49
|
-
"@knotx/data": "0.
|
|
50
|
-
"@knotx/utils": "0.
|
|
49
|
+
"@knotx/data": "0.3.0",
|
|
50
|
+
"@knotx/utils": "0.3.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/lodash-es": "^4.17.12",
|
|
54
|
-
"@knotx/build-config": "0.
|
|
55
|
-
"@knotx/eslint-config": "0.
|
|
56
|
-
"@knotx/typescript-config": "0.
|
|
54
|
+
"@knotx/build-config": "0.3.0",
|
|
55
|
+
"@knotx/eslint-config": "0.3.0",
|
|
56
|
+
"@knotx/typescript-config": "0.3.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "unbuild",
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'jsonschema';
|
|
2
|
-
import { SubscriptionLike, BehaviorSubject } from 'rxjs';
|
|
3
|
-
import { DataOperationPipe, DataOperation } from '@knotx/data';
|
|
4
|
-
|
|
5
|
-
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
6
|
-
abstract name: TPluginName;
|
|
7
|
-
constructor(__: TPluginConfig);
|
|
8
|
-
private static _instanceId;
|
|
9
|
-
private _instanceId;
|
|
10
|
-
get pluginId(): string;
|
|
11
|
-
/**
|
|
12
|
-
* 插件生命周期中的订阅回调
|
|
13
|
-
* 可随时存入,销毁时会自动执行
|
|
14
|
-
*/
|
|
15
|
-
protected subscriptions: (SubscriptionLike | (() => void))[];
|
|
16
|
-
onDestroy(): void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type HorizontalAlignment = 'left' | 'right';
|
|
20
|
-
type VerticalAlignment = 'top' | 'bottom';
|
|
21
|
-
type IRecord = Record<string, any>;
|
|
22
|
-
interface NodePosition {
|
|
23
|
-
x: number;
|
|
24
|
-
y: number;
|
|
25
|
-
}
|
|
26
|
-
interface NodeMeasured {
|
|
27
|
-
width: number;
|
|
28
|
-
height: number;
|
|
29
|
-
}
|
|
30
|
-
interface Node<TData extends IRecord = IRecord> {
|
|
31
|
-
id: string;
|
|
32
|
-
type?: string;
|
|
33
|
-
position: NodePosition;
|
|
34
|
-
measured?: NodeMeasured;
|
|
35
|
-
data: TData;
|
|
36
|
-
}
|
|
37
|
-
interface NodeProps<TData extends IRecord = IRecord> {
|
|
38
|
-
node: Node<TData>;
|
|
39
|
-
}
|
|
40
|
-
interface Edge<TData extends IRecord = IRecord> {
|
|
41
|
-
id: string;
|
|
42
|
-
source: string;
|
|
43
|
-
target: string;
|
|
44
|
-
type?: string;
|
|
45
|
-
data?: TData;
|
|
46
|
-
}
|
|
47
|
-
interface EdgeProps<TData extends IRecord = IRecord> {
|
|
48
|
-
edge: Edge<TData>;
|
|
49
|
-
sourceX: number;
|
|
50
|
-
sourceY: number;
|
|
51
|
-
targetX: number;
|
|
52
|
-
targetY: number;
|
|
53
|
-
}
|
|
54
|
-
interface Container {
|
|
55
|
-
width: number;
|
|
56
|
-
height: number;
|
|
57
|
-
}
|
|
58
|
-
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
59
|
-
type RenderType = (...args: any[]) => any;
|
|
60
|
-
type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
61
|
-
type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
62
|
-
declare enum Layer {
|
|
63
|
-
Canvas = 0,
|
|
64
|
-
Background = 4,
|
|
65
|
-
Edges = 16,
|
|
66
|
-
Nodes = 64,
|
|
67
|
-
Foreground = 256
|
|
68
|
-
}
|
|
69
|
-
interface LayerComponent<TRenderType> {
|
|
70
|
-
plugin: string;
|
|
71
|
-
name: string;
|
|
72
|
-
layer: Layer;
|
|
73
|
-
render: TRenderType;
|
|
74
|
-
/**
|
|
75
|
-
* 层级偏移量
|
|
76
|
-
* @default 0
|
|
77
|
-
* (layer >> 1, layer << 1]
|
|
78
|
-
*/
|
|
79
|
-
offset?: number;
|
|
80
|
-
}
|
|
81
|
-
interface IPlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
82
|
-
name: TPluginName;
|
|
83
|
-
pluginId: string;
|
|
84
|
-
description?: string;
|
|
85
|
-
onInit?: (config: TPluginConfig) => void;
|
|
86
|
-
onConfigChange?: (config: TPluginConfig) => void;
|
|
87
|
-
onDestroy?: () => void;
|
|
88
|
-
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
89
|
-
}
|
|
90
|
-
type Plugin<TName extends string = string, TConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
91
|
-
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
92
|
-
[TName in T as Extract<TPlugins[number], Plugin<TName>> extends Plugin<TName, undefined> ? never : TName]: Extract<TPlugins[number], Plugin<TName>> extends infer T ? T extends Plugin<TName, infer TConfig> ? TConfig : never : never;
|
|
93
|
-
} : {}));
|
|
94
|
-
/**
|
|
95
|
-
* plugin data host
|
|
96
|
-
* @example
|
|
97
|
-
* `declare module '@knotx/core' {
|
|
98
|
-
* interface PluginData {
|
|
99
|
-
* pluginName: {
|
|
100
|
-
* property: any
|
|
101
|
-
* }
|
|
102
|
-
* }
|
|
103
|
-
* }`
|
|
104
|
-
*/
|
|
105
|
-
interface PluginData {
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* plugin tools host
|
|
109
|
-
* @example
|
|
110
|
-
* `declare module '@knotx/core' {
|
|
111
|
-
* interface PluginTools {
|
|
112
|
-
* pluginName: {
|
|
113
|
-
* toolName: (params: any) => any
|
|
114
|
-
* }
|
|
115
|
-
* }
|
|
116
|
-
* }`
|
|
117
|
-
*/
|
|
118
|
-
interface PluginTools {
|
|
119
|
-
}
|
|
120
|
-
interface IPluginInfo {
|
|
121
|
-
name: string;
|
|
122
|
-
description?: string;
|
|
123
|
-
}
|
|
124
|
-
interface IPluginToolInfo {
|
|
125
|
-
type: 'function';
|
|
126
|
-
name: string;
|
|
127
|
-
description: string;
|
|
128
|
-
parameters: Schema;
|
|
129
|
-
}
|
|
130
|
-
type NodeOperationPipe<T extends IRecord = any> = DataOperationPipe<Node<T>>;
|
|
131
|
-
type EdgeOperationPipe<T extends IRecord = any> = DataOperationPipe<Edge<T>>;
|
|
132
|
-
type NodeOperation<T extends IRecord = any> = DataOperation<Node<T>>;
|
|
133
|
-
type EdgeOperation<T extends IRecord = any> = DataOperation<Edge<T>>;
|
|
134
|
-
type NodeOperatorFunction<T extends IRecord = any, TArgs extends any[] = any[]> = (...args: TArgs) => NodeOperation<T>[];
|
|
135
|
-
type EdgeOperatorFunction<T extends IRecord = any, TArgs extends any[] = any[]> = (...args: TArgs) => EdgeOperation<T>[];
|
|
136
|
-
interface IEngineRuntime {
|
|
137
|
-
render?: {
|
|
138
|
-
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
139
|
-
paths: string[];
|
|
140
|
-
selector?: (value: T, context?: any) => R;
|
|
141
|
-
context?: any;
|
|
142
|
-
}) => T | R;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export { BasePlugin as B, type Container as C, type Edge as E, type HorizontalAlignment as H, type IRecord as I, type LayerComponent as L, type Node as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IEngineRuntime as a, type IPlugin as b, Layer as c, type NodeRenderType as d, type EdgeRenderType as e, type PluginData as f, type PluginTools as g, type IPluginInfo as h, type IPluginToolInfo as i, type NodePosition as j, type NodeMeasured as k, type NodeProps as l, type EdgeProps as m, type Position as n, type PluginConfigs as o, type NodeOperationPipe as p, type EdgeOperationPipe as q, type NodeOperation as r, type EdgeOperation as s, type NodeOperatorFunction as t, type EdgeOperatorFunction as u };
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'jsonschema';
|
|
2
|
-
import { SubscriptionLike, BehaviorSubject } from 'rxjs';
|
|
3
|
-
import { DataOperationPipe, DataOperation } from '@knotx/data';
|
|
4
|
-
|
|
5
|
-
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
6
|
-
abstract name: TPluginName;
|
|
7
|
-
constructor(__: TPluginConfig);
|
|
8
|
-
private static _instanceId;
|
|
9
|
-
private _instanceId;
|
|
10
|
-
get pluginId(): string;
|
|
11
|
-
/**
|
|
12
|
-
* 插件生命周期中的订阅回调
|
|
13
|
-
* 可随时存入,销毁时会自动执行
|
|
14
|
-
*/
|
|
15
|
-
protected subscriptions: (SubscriptionLike | (() => void))[];
|
|
16
|
-
onDestroy(): void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type HorizontalAlignment = 'left' | 'right';
|
|
20
|
-
type VerticalAlignment = 'top' | 'bottom';
|
|
21
|
-
type IRecord = Record<string, any>;
|
|
22
|
-
interface NodePosition {
|
|
23
|
-
x: number;
|
|
24
|
-
y: number;
|
|
25
|
-
}
|
|
26
|
-
interface NodeMeasured {
|
|
27
|
-
width: number;
|
|
28
|
-
height: number;
|
|
29
|
-
}
|
|
30
|
-
interface Node<TData extends IRecord = IRecord> {
|
|
31
|
-
id: string;
|
|
32
|
-
type?: string;
|
|
33
|
-
position: NodePosition;
|
|
34
|
-
measured?: NodeMeasured;
|
|
35
|
-
data: TData;
|
|
36
|
-
}
|
|
37
|
-
interface NodeProps<TData extends IRecord = IRecord> {
|
|
38
|
-
node: Node<TData>;
|
|
39
|
-
}
|
|
40
|
-
interface Edge<TData extends IRecord = IRecord> {
|
|
41
|
-
id: string;
|
|
42
|
-
source: string;
|
|
43
|
-
target: string;
|
|
44
|
-
type?: string;
|
|
45
|
-
data?: TData;
|
|
46
|
-
}
|
|
47
|
-
interface EdgeProps<TData extends IRecord = IRecord> {
|
|
48
|
-
edge: Edge<TData>;
|
|
49
|
-
sourceX: number;
|
|
50
|
-
sourceY: number;
|
|
51
|
-
targetX: number;
|
|
52
|
-
targetY: number;
|
|
53
|
-
}
|
|
54
|
-
interface Container {
|
|
55
|
-
width: number;
|
|
56
|
-
height: number;
|
|
57
|
-
}
|
|
58
|
-
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
59
|
-
type RenderType = (...args: any[]) => any;
|
|
60
|
-
type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
61
|
-
type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
62
|
-
declare enum Layer {
|
|
63
|
-
Canvas = 0,
|
|
64
|
-
Background = 4,
|
|
65
|
-
Edges = 16,
|
|
66
|
-
Nodes = 64,
|
|
67
|
-
Foreground = 256
|
|
68
|
-
}
|
|
69
|
-
interface LayerComponent<TRenderType> {
|
|
70
|
-
plugin: string;
|
|
71
|
-
name: string;
|
|
72
|
-
layer: Layer;
|
|
73
|
-
render: TRenderType;
|
|
74
|
-
/**
|
|
75
|
-
* 层级偏移量
|
|
76
|
-
* @default 0
|
|
77
|
-
* (layer >> 1, layer << 1]
|
|
78
|
-
*/
|
|
79
|
-
offset?: number;
|
|
80
|
-
}
|
|
81
|
-
interface IPlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
82
|
-
name: TPluginName;
|
|
83
|
-
pluginId: string;
|
|
84
|
-
description?: string;
|
|
85
|
-
onInit?: (config: TPluginConfig) => void;
|
|
86
|
-
onConfigChange?: (config: TPluginConfig) => void;
|
|
87
|
-
onDestroy?: () => void;
|
|
88
|
-
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
89
|
-
}
|
|
90
|
-
type Plugin<TName extends string = string, TConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
91
|
-
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
92
|
-
[TName in T as Extract<TPlugins[number], Plugin<TName>> extends Plugin<TName, undefined> ? never : TName]: Extract<TPlugins[number], Plugin<TName>> extends infer T ? T extends Plugin<TName, infer TConfig> ? TConfig : never : never;
|
|
93
|
-
} : {}));
|
|
94
|
-
/**
|
|
95
|
-
* plugin data host
|
|
96
|
-
* @example
|
|
97
|
-
* `declare module '@knotx/core' {
|
|
98
|
-
* interface PluginData {
|
|
99
|
-
* pluginName: {
|
|
100
|
-
* property: any
|
|
101
|
-
* }
|
|
102
|
-
* }
|
|
103
|
-
* }`
|
|
104
|
-
*/
|
|
105
|
-
interface PluginData {
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* plugin tools host
|
|
109
|
-
* @example
|
|
110
|
-
* `declare module '@knotx/core' {
|
|
111
|
-
* interface PluginTools {
|
|
112
|
-
* pluginName: {
|
|
113
|
-
* toolName: (params: any) => any
|
|
114
|
-
* }
|
|
115
|
-
* }
|
|
116
|
-
* }`
|
|
117
|
-
*/
|
|
118
|
-
interface PluginTools {
|
|
119
|
-
}
|
|
120
|
-
interface IPluginInfo {
|
|
121
|
-
name: string;
|
|
122
|
-
description?: string;
|
|
123
|
-
}
|
|
124
|
-
interface IPluginToolInfo {
|
|
125
|
-
type: 'function';
|
|
126
|
-
name: string;
|
|
127
|
-
description: string;
|
|
128
|
-
parameters: Schema;
|
|
129
|
-
}
|
|
130
|
-
type NodeOperationPipe<T extends IRecord = any> = DataOperationPipe<Node<T>>;
|
|
131
|
-
type EdgeOperationPipe<T extends IRecord = any> = DataOperationPipe<Edge<T>>;
|
|
132
|
-
type NodeOperation<T extends IRecord = any> = DataOperation<Node<T>>;
|
|
133
|
-
type EdgeOperation<T extends IRecord = any> = DataOperation<Edge<T>>;
|
|
134
|
-
type NodeOperatorFunction<T extends IRecord = any, TArgs extends any[] = any[]> = (...args: TArgs) => NodeOperation<T>[];
|
|
135
|
-
type EdgeOperatorFunction<T extends IRecord = any, TArgs extends any[] = any[]> = (...args: TArgs) => EdgeOperation<T>[];
|
|
136
|
-
interface IEngineRuntime {
|
|
137
|
-
render?: {
|
|
138
|
-
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
139
|
-
paths: string[];
|
|
140
|
-
selector?: (value: T, context?: any) => R;
|
|
141
|
-
context?: any;
|
|
142
|
-
}) => T | R;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export { BasePlugin as B, type Container as C, type Edge as E, type HorizontalAlignment as H, type IRecord as I, type LayerComponent as L, type Node as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IEngineRuntime as a, type IPlugin as b, Layer as c, type NodeRenderType as d, type EdgeRenderType as e, type PluginData as f, type PluginTools as g, type IPluginInfo as h, type IPluginToolInfo as i, type NodePosition as j, type NodeMeasured as k, type NodeProps as l, type EdgeProps as m, type Position as n, type PluginConfigs as o, type NodeOperationPipe as p, type EdgeOperationPipe as q, type NodeOperation as r, type EdgeOperation as s, type NodeOperatorFunction as t, type EdgeOperatorFunction as u };
|