@knotx/core 0.2.14 → 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 +57 -29
- package/dist/index.d.cts +6 -163
- package/dist/index.d.mts +6 -163
- package/dist/index.d.ts +6 -163
- package/dist/index.js +57 -29
- 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.B-u2ysAC.d.cts +0 -148
- package/dist/shared/core.B-u2ysAC.d.mts +0 -148
- package/dist/shared/core.B-u2ysAC.d.ts +0 -148
package/dist/definition.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'jsonschema';
|
|
2
2
|
import 'rxjs';
|
|
3
|
-
export { C as Container,
|
|
3
|
+
export { C as Container, d as Edge, t as EdgeOperation, r as EdgeOperationPipe, v as EdgeOperatorFunction, e as EdgeProps, g as EdgeRenderType, n as EngineTools, H as HorizontalAlignment, w as IEngineRuntime, i as IPlugin, o as IPluginInfo, I as IRecord, p as IToolInfo, L as Layer, h as LayerComponent, b as Node, a as NodeMeasured, s as NodeOperation, q as NodeOperationPipe, u as NodeOperatorFunction, N as NodePosition, c as NodeProps, f as NodeRenderType, j as Plugin, k as PluginConfigs, l as PluginData, m as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CpyG0nWq.cjs';
|
|
4
4
|
import '@knotx/data';
|
package/dist/definition.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'jsonschema';
|
|
2
2
|
import 'rxjs';
|
|
3
|
-
export { C as Container,
|
|
3
|
+
export { C as Container, d as Edge, t as EdgeOperation, r as EdgeOperationPipe, v as EdgeOperatorFunction, e as EdgeProps, g as EdgeRenderType, n as EngineTools, H as HorizontalAlignment, w as IEngineRuntime, i as IPlugin, o as IPluginInfo, I as IRecord, p as IToolInfo, L as Layer, h as LayerComponent, b as Node, a as NodeMeasured, s as NodeOperation, q as NodeOperationPipe, u as NodeOperatorFunction, N as NodePosition, c as NodeProps, f as NodeRenderType, j as Plugin, k as PluginConfigs, l as PluginData, m as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CpyG0nWq.mjs';
|
|
4
4
|
import '@knotx/data';
|
package/dist/definition.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'jsonschema';
|
|
2
2
|
import 'rxjs';
|
|
3
|
-
export { C as Container,
|
|
3
|
+
export { C as Container, d as Edge, t as EdgeOperation, r as EdgeOperationPipe, v as EdgeOperatorFunction, e as EdgeProps, g as EdgeRenderType, n as EngineTools, H as HorizontalAlignment, w as IEngineRuntime, i as IPlugin, o as IPluginInfo, I as IRecord, p as IToolInfo, L as Layer, h as LayerComponent, b as Node, a as NodeMeasured, s as NodeOperation, q as NodeOperationPipe, u as NodeOperatorFunction, N as NodePosition, c as NodeProps, f as NodeRenderType, j as Plugin, k as PluginConfigs, l as PluginData, m as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CpyG0nWq.js';
|
|
4
4
|
import '@knotx/data';
|
package/dist/index.cjs
CHANGED
|
@@ -193,17 +193,62 @@ class Engine {
|
|
|
193
193
|
{
|
|
194
194
|
type: "function",
|
|
195
195
|
name: "getNodes",
|
|
196
|
-
description: "Get all nodes",
|
|
196
|
+
description: "Get all nodes data",
|
|
197
197
|
parameters: {}
|
|
198
198
|
},
|
|
199
199
|
{
|
|
200
200
|
type: "function",
|
|
201
201
|
name: "getEdges",
|
|
202
|
-
description: "Get all edges",
|
|
202
|
+
description: "Get all edges data",
|
|
203
203
|
parameters: {}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
type: "function",
|
|
207
|
+
name: "getNode",
|
|
208
|
+
description: "Get node data",
|
|
209
|
+
parameters: {
|
|
210
|
+
type: "object",
|
|
211
|
+
properties: {
|
|
212
|
+
id: { type: "string" }
|
|
213
|
+
},
|
|
214
|
+
required: ["id"]
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
type: "function",
|
|
219
|
+
name: "getEdge",
|
|
220
|
+
description: "Get edge data",
|
|
221
|
+
parameters: {
|
|
222
|
+
type: "object",
|
|
223
|
+
properties: {
|
|
224
|
+
id: { type: "string" }
|
|
225
|
+
},
|
|
226
|
+
required: ["id"]
|
|
227
|
+
}
|
|
204
228
|
}
|
|
205
229
|
].map((tool) => [tool.name, tool])));
|
|
206
230
|
__publicField$2(this, "toolParametersValidator", new jsonschema.Validator());
|
|
231
|
+
__publicField$2(this, "callTool", (pluginNameOrEngineToolName, ...args) => {
|
|
232
|
+
let toolDefinition;
|
|
233
|
+
let toolDisplayName;
|
|
234
|
+
if (this.engineTools.has(pluginNameOrEngineToolName)) {
|
|
235
|
+
toolDefinition = __spreadProps$1(__spreadValues$1({}, this.engineTools.get(pluginNameOrEngineToolName)), { func: this[pluginNameOrEngineToolName].bind(this) });
|
|
236
|
+
toolDisplayName = toolDefinition.name;
|
|
237
|
+
} else {
|
|
238
|
+
toolDefinition = lodashEs.get(this, ["_pluginToolsContainer", pluginNameOrEngineToolName, args == null ? void 0 : args[0]]);
|
|
239
|
+
toolDisplayName = `${pluginNameOrEngineToolName}.${args == null ? void 0 : args[0]}`;
|
|
240
|
+
}
|
|
241
|
+
const tool = toolDefinition == null ? void 0 : toolDefinition.func;
|
|
242
|
+
if (!tool || typeof tool !== "function") {
|
|
243
|
+
throw new Error(`Tool ${String(toolDisplayName)} not found`);
|
|
244
|
+
}
|
|
245
|
+
const parameters = args[args.length - 1];
|
|
246
|
+
const validator = this.toolParametersValidator.validate(parameters, toolDefinition.parameters);
|
|
247
|
+
if (validator.errors.length > 0) {
|
|
248
|
+
throw new Error(`Invalid tool parameters: ${validator.errors.map((e) => e.stack).join(", ")}`);
|
|
249
|
+
}
|
|
250
|
+
return tool(parameters);
|
|
251
|
+
});
|
|
207
252
|
var _a;
|
|
208
253
|
this.runtime = (_a = options.runtime) != null ? _a : {};
|
|
209
254
|
this.container$.next(options.container);
|
|
@@ -274,7 +319,7 @@ class Engine {
|
|
|
274
319
|
addEdgePipe(pipe) {
|
|
275
320
|
return this.edgesManager.addDataOperationPipe(pipe);
|
|
276
321
|
}
|
|
277
|
-
changePluginConfig(pluginName, config) {
|
|
322
|
+
changePluginConfig({ pluginName, config }) {
|
|
278
323
|
var _a, _b;
|
|
279
324
|
(_b = (_a = this.plugins$.value.get(pluginName)) == null ? void 0 : _a.onConfigChange) == null ? void 0 : _b.call(_a, config);
|
|
280
325
|
}
|
|
@@ -284,13 +329,13 @@ class Engine {
|
|
|
284
329
|
dispatchEdgeOperation(operation) {
|
|
285
330
|
this.edgesManager.dispatch(operation);
|
|
286
331
|
}
|
|
287
|
-
getPlugin(pluginName) {
|
|
332
|
+
getPlugin({ pluginName }) {
|
|
288
333
|
return this.plugins$.value.get(pluginName);
|
|
289
334
|
}
|
|
290
|
-
getNode(id) {
|
|
335
|
+
getNode({ id }) {
|
|
291
336
|
return this.nodesManager.getData(id);
|
|
292
337
|
}
|
|
293
|
-
getNodeDraft(id) {
|
|
338
|
+
getNodeDraft({ id }) {
|
|
294
339
|
return this.nodesManager.getCurrentDraftData(id);
|
|
295
340
|
}
|
|
296
341
|
getNodes() {
|
|
@@ -299,10 +344,10 @@ class Engine {
|
|
|
299
344
|
getNodeRenderer(type) {
|
|
300
345
|
return this.nodeRenderers$.value.get(type);
|
|
301
346
|
}
|
|
302
|
-
getEdge(id) {
|
|
347
|
+
getEdge({ id }) {
|
|
303
348
|
return this.edgesManager.getData(id);
|
|
304
349
|
}
|
|
305
|
-
getEdgeDraft(id) {
|
|
350
|
+
getEdgeDraft({ id }) {
|
|
306
351
|
return this.edgesManager.getCurrentDraftData(id);
|
|
307
352
|
}
|
|
308
353
|
getEdges() {
|
|
@@ -352,27 +397,6 @@ class Engine {
|
|
|
352
397
|
endInteraction(pluginId, type) {
|
|
353
398
|
this.interactionManager.endInteraction(pluginId, type);
|
|
354
399
|
}
|
|
355
|
-
callTool(pluginNameOrEngineToolName, ...args) {
|
|
356
|
-
let toolDefinition;
|
|
357
|
-
let toolDisplayName;
|
|
358
|
-
if (this.engineTools.has(pluginNameOrEngineToolName)) {
|
|
359
|
-
toolDefinition = __spreadProps$1(__spreadValues$1({}, this.engineTools.get(pluginNameOrEngineToolName)), { func: this[pluginNameOrEngineToolName].bind(this) });
|
|
360
|
-
toolDisplayName = toolDefinition.name;
|
|
361
|
-
} else {
|
|
362
|
-
toolDefinition = lodashEs.get(this, ["_pluginToolsContainer", pluginNameOrEngineToolName, args == null ? void 0 : args[0]]);
|
|
363
|
-
toolDisplayName = `${pluginNameOrEngineToolName}.${args == null ? void 0 : args[0]}`;
|
|
364
|
-
}
|
|
365
|
-
const tool = toolDefinition == null ? void 0 : toolDefinition.func;
|
|
366
|
-
if (!tool || typeof tool !== "function") {
|
|
367
|
-
throw new Error(`Tool ${String(toolDisplayName)} not found`);
|
|
368
|
-
}
|
|
369
|
-
const parameters = args[args.length - 1];
|
|
370
|
-
const validator = this.toolParametersValidator.validate(parameters, toolDefinition.parameters);
|
|
371
|
-
if (validator.errors.length > 0) {
|
|
372
|
-
throw new Error(`Invalid tool parameters: ${validator.errors.map((e) => e.stack).join(", ")}`);
|
|
373
|
-
}
|
|
374
|
-
return tool(parameters);
|
|
375
|
-
}
|
|
376
400
|
listPlugins() {
|
|
377
401
|
return Array.from(this.plugins$.value.values()).map((plugin) => ({
|
|
378
402
|
name: plugin.name,
|
|
@@ -418,6 +442,10 @@ const _BasePlugin = class _BasePlugin {
|
|
|
418
442
|
* 可随时存入,销毁时会自动执行
|
|
419
443
|
*/
|
|
420
444
|
__publicField$1(this, "subscriptions", []);
|
|
445
|
+
__publicField$1(this, "callTool", (...args) => {
|
|
446
|
+
var _a;
|
|
447
|
+
return (_a = Reflect.get(this, utils.getSymbol("engine")).value) == null ? void 0 : _a.callTool(...args);
|
|
448
|
+
});
|
|
421
449
|
Reflect.set(this, utils.getSymbol("engine"), new rxjs.BehaviorSubject(null));
|
|
422
450
|
}
|
|
423
451
|
get pluginId() {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,169 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
1
|
+
import { E as Engine } from './shared/core.CpyG0nWq.cjs';
|
|
2
|
+
export { D as BasePlugin, y as CallToolMethod, C as Container, d as Edge, t as EdgeOperation, r as EdgeOperationPipe, v as EdgeOperatorFunction, e as EdgeProps, g as EdgeRenderType, x as EngineOptions, n as EngineTools, H as HorizontalAlignment, w as IEngineRuntime, i as IPlugin, o as IPluginInfo, I as IRecord, p as IToolInfo, A as Interaction, B as InteractionManager, z as InteractionPriority, L as Layer, h as LayerComponent, b as Node, a as NodeMeasured, s as NodeOperation, q as NodeOperationPipe, u as NodeOperatorFunction, N as NodePosition, c as NodeProps, f as NodeRenderType, j as Plugin, k as PluginConfigs, l as PluginData, m as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CpyG0nWq.cjs';
|
|
3
|
+
import { RenderType, IPlugin, LayerComponent } from '@knotx/core';
|
|
4
4
|
import { BehaviorSubject } from 'rxjs';
|
|
5
|
-
import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
|
|
6
5
|
export * from '@knotx/data';
|
|
7
|
-
import { RenderType as RenderType$1, IPlugin as IPlugin$1, LayerComponent as LayerComponent$1 } from '@knotx/core';
|
|
8
6
|
export * from '@knotx/utils';
|
|
7
|
+
import 'jsonschema';
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
* 用户交互优先级定义
|
|
12
|
-
* 数值越大优先级越高
|
|
13
|
-
*/
|
|
14
|
-
declare enum InteractionPriority {
|
|
15
|
-
/** 文本输入框激活状态(输入中需独占) */
|
|
16
|
-
InputActive = 2000,
|
|
17
|
-
/** 实体连接拖拽 */
|
|
18
|
-
EntityConnectDrag = 1930,
|
|
19
|
-
/** 实体测量拖拽 */
|
|
20
|
-
EntityMeasureDrag = 1920,
|
|
21
|
-
/** 实体位置拖拽 */
|
|
22
|
-
EntityPositionDrag = 1910,
|
|
23
|
-
/** 连续操作:画布拖拽、缩放等进行中的动作 */
|
|
24
|
-
ContinuousDrag = 1900,
|
|
25
|
-
/** 右键菜单/上下文操作 */
|
|
26
|
-
ContextMenu = 1800,
|
|
27
|
-
/** 键盘快捷键(如 Delete/Ctrl+C) */
|
|
28
|
-
KeyboardShortcut = 1700,
|
|
29
|
-
/** 单击选中元素 */
|
|
30
|
-
ClickSelection = 1600,
|
|
31
|
-
/** 双击编辑元素 */
|
|
32
|
-
DoubleClickEdit = 1500,
|
|
33
|
-
/** 框选(多选)操作 */
|
|
34
|
-
MarqueeSelection = 1300,
|
|
35
|
-
/** 套索选择(Lasso Select) */
|
|
36
|
-
LassoSelection = 1250,
|
|
37
|
-
/** 长按操作(长按菜单/工具) */
|
|
38
|
-
LongPress = 1100,
|
|
39
|
-
/** 悬停提示(Hover Tooltip) */
|
|
40
|
-
HoverTooltip = 1000,
|
|
41
|
-
/** 画布平移(空格拖拽或手势) */
|
|
42
|
-
CanvasPan = 900,
|
|
43
|
-
/** 画布缩放(滚轮或双指) */
|
|
44
|
-
CanvasZoom = 800,
|
|
45
|
-
/** 多指手势(如三指滑动) */
|
|
46
|
-
MultiTouchGesture = 700
|
|
47
|
-
}
|
|
48
|
-
interface Interaction {
|
|
49
|
-
pluginId: string;
|
|
50
|
-
type: string;
|
|
51
|
-
priority: InteractionPriority;
|
|
52
|
-
active?: boolean;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* 交互管理器
|
|
56
|
-
*/
|
|
57
|
-
declare class InteractionManager {
|
|
58
|
-
private interactions;
|
|
59
|
-
/**
|
|
60
|
-
* 获取当前活动的交互
|
|
61
|
-
*/
|
|
62
|
-
get activeInteraction(): Interaction | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* 检查是否可以交互
|
|
65
|
-
* @param pluginId 插件ID
|
|
66
|
-
* @param type 交互类型
|
|
67
|
-
* @param autoStartPriority 自动启动优先级
|
|
68
|
-
* @returns 是否可以交互
|
|
69
|
-
*/
|
|
70
|
-
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* 启动交互
|
|
73
|
-
* @param pluginId 插件ID
|
|
74
|
-
* @param type 交互类型
|
|
75
|
-
* @param priority 优先级
|
|
76
|
-
* @returns 取消交互的函数
|
|
77
|
-
*/
|
|
78
|
-
startInteraction(pluginId: string, type: string, priority: InteractionPriority): () => void;
|
|
79
|
-
/**
|
|
80
|
-
* 结束交互
|
|
81
|
-
* @param pluginId 插件ID
|
|
82
|
-
* @param type 交互类型
|
|
83
|
-
*/
|
|
84
|
-
endInteraction(pluginId: string, type: string): void;
|
|
85
|
-
private updateActive;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
interface EngineOptions<TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
|
|
89
|
-
container: Container;
|
|
90
|
-
plugins?: Plugin[];
|
|
91
|
-
pluginConfig?: IRecord;
|
|
92
|
-
nodes?: Node<TNode>[];
|
|
93
|
-
edges?: Edge<TEdge>[];
|
|
94
|
-
runtime?: IEngineRuntime;
|
|
95
|
-
}
|
|
96
|
-
declare module '@knotx/core' {
|
|
97
|
-
interface EngineTools {
|
|
98
|
-
listPlugins: Engine['listPlugins'];
|
|
99
|
-
listPluginTools: Engine['listPluginTools'];
|
|
100
|
-
getNodes: Engine['getNodes'];
|
|
101
|
-
getEdges: Engine['getEdges'];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
declare class Engine<TRenderType extends RenderType = RenderType, TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
|
|
105
|
-
readonly runtime: IEngineRuntime;
|
|
106
|
-
readonly interactionManager: InteractionManager;
|
|
107
|
-
readonly nodesManager: DataManager<Node<TNode>>;
|
|
108
|
-
readonly edgesManager: DataManager<Edge<TEdge>>;
|
|
109
|
-
private container$;
|
|
110
|
-
private nodes$;
|
|
111
|
-
private edges$;
|
|
112
|
-
private layers$;
|
|
113
|
-
private plugins$;
|
|
114
|
-
private nodeRenderers$;
|
|
115
|
-
private edgeRenderers$;
|
|
116
|
-
private _pluginDataContainer;
|
|
117
|
-
private _pluginToolsContainer;
|
|
118
|
-
private engineTools;
|
|
119
|
-
private toolParametersValidator;
|
|
120
|
-
get container(): Container;
|
|
121
|
-
set container(value: Container);
|
|
122
|
-
get nodes(): Node<TNode>[];
|
|
123
|
-
get edges(): Edge<TEdge>[];
|
|
124
|
-
get layers(): Map<number, LayerComponent<TRenderType>[]>;
|
|
125
|
-
get plugins(): IPlugin<string, any, RenderType>[];
|
|
126
|
-
constructor(options: EngineOptions<TNode, TEdge>);
|
|
127
|
-
private init;
|
|
128
|
-
getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
|
|
129
|
-
addNodePipe(pipe: DataOperationPipe<Node<TNode>>): () => void;
|
|
130
|
-
addEdgePipe(pipe: DataOperationPipe<Edge<TEdge>>): () => void;
|
|
131
|
-
changePluginConfig(pluginName: string, config: IRecord): void;
|
|
132
|
-
dispatchNodeOperation(operation: DataOperation<Node<TNode>>): void;
|
|
133
|
-
dispatchEdgeOperation(operation: DataOperation<Edge<TEdge>>): void;
|
|
134
|
-
getPlugin<TPlugin extends IPlugin>(pluginName: TPlugin['name']): TPlugin | undefined;
|
|
135
|
-
getNode(id: string): Node<TNode> | undefined;
|
|
136
|
-
getNodeDraft(id: string): Node<TNode> | undefined;
|
|
137
|
-
getNodes(): Node<TNode>[];
|
|
138
|
-
getNodeRenderer(type: string): NodeRenderType | undefined;
|
|
139
|
-
getEdge(id: string): Edge<TEdge> | undefined;
|
|
140
|
-
getEdgeDraft(id: string): Edge<TEdge> | undefined;
|
|
141
|
-
getEdges(): Edge<TEdge>[];
|
|
142
|
-
getEdgeRenderer(type: string): EdgeRenderType | undefined;
|
|
143
|
-
registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
|
|
144
|
-
resetPluginData<T extends keyof PluginData>(pluginName: T): void;
|
|
145
|
-
registerPluginTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, property: TP, data: {
|
|
146
|
-
description: string;
|
|
147
|
-
parameters: Schema;
|
|
148
|
-
func: PluginTools[T][TP];
|
|
149
|
-
}): void;
|
|
150
|
-
resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
|
|
151
|
-
registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
|
|
152
|
-
registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
|
|
153
|
-
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
|
|
154
|
-
startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
|
|
155
|
-
endInteraction(pluginId: string, type: string): void;
|
|
156
|
-
callTool<T extends keyof EngineTools>(engineToolName: T, ...args: Parameters<EngineTools[T]>): ReturnType<EngineTools[T]>;
|
|
157
|
-
callTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, toolName: TP, ...args: Parameters<PluginTools[T][TP]>): ReturnType<PluginTools[T][TP]>;
|
|
158
|
-
listPlugins(): IPluginInfo[];
|
|
159
|
-
listPluginTools({ pluginName }: {
|
|
160
|
-
pluginName: string;
|
|
161
|
-
}): IPluginToolInfo[];
|
|
162
|
-
listEngineTools(): IPluginToolInfo[];
|
|
163
|
-
destroy(): void;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
declare function getLayerRenders<TRenderType extends RenderType$1 = RenderType$1>(plugin: IPlugin$1): LayerComponent$1<TRenderType>[];
|
|
9
|
+
declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
|
|
167
10
|
|
|
168
11
|
/**
|
|
169
12
|
* Runtime 类
|
|
@@ -226,4 +69,4 @@ declare function use<T, TContext>(hook: () => {
|
|
|
226
69
|
__contextValue__: TContext;
|
|
227
70
|
}, context: TContext): T;
|
|
228
71
|
|
|
229
|
-
export {
|
|
72
|
+
export { Engine, Runtime, getLayerRenders, use };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,169 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
1
|
+
import { E as Engine } from './shared/core.CpyG0nWq.mjs';
|
|
2
|
+
export { D as BasePlugin, y as CallToolMethod, C as Container, d as Edge, t as EdgeOperation, r as EdgeOperationPipe, v as EdgeOperatorFunction, e as EdgeProps, g as EdgeRenderType, x as EngineOptions, n as EngineTools, H as HorizontalAlignment, w as IEngineRuntime, i as IPlugin, o as IPluginInfo, I as IRecord, p as IToolInfo, A as Interaction, B as InteractionManager, z as InteractionPriority, L as Layer, h as LayerComponent, b as Node, a as NodeMeasured, s as NodeOperation, q as NodeOperationPipe, u as NodeOperatorFunction, N as NodePosition, c as NodeProps, f as NodeRenderType, j as Plugin, k as PluginConfigs, l as PluginData, m as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CpyG0nWq.mjs';
|
|
3
|
+
import { RenderType, IPlugin, LayerComponent } from '@knotx/core';
|
|
4
4
|
import { BehaviorSubject } from 'rxjs';
|
|
5
|
-
import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
|
|
6
5
|
export * from '@knotx/data';
|
|
7
|
-
import { RenderType as RenderType$1, IPlugin as IPlugin$1, LayerComponent as LayerComponent$1 } from '@knotx/core';
|
|
8
6
|
export * from '@knotx/utils';
|
|
7
|
+
import 'jsonschema';
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
* 用户交互优先级定义
|
|
12
|
-
* 数值越大优先级越高
|
|
13
|
-
*/
|
|
14
|
-
declare enum InteractionPriority {
|
|
15
|
-
/** 文本输入框激活状态(输入中需独占) */
|
|
16
|
-
InputActive = 2000,
|
|
17
|
-
/** 实体连接拖拽 */
|
|
18
|
-
EntityConnectDrag = 1930,
|
|
19
|
-
/** 实体测量拖拽 */
|
|
20
|
-
EntityMeasureDrag = 1920,
|
|
21
|
-
/** 实体位置拖拽 */
|
|
22
|
-
EntityPositionDrag = 1910,
|
|
23
|
-
/** 连续操作:画布拖拽、缩放等进行中的动作 */
|
|
24
|
-
ContinuousDrag = 1900,
|
|
25
|
-
/** 右键菜单/上下文操作 */
|
|
26
|
-
ContextMenu = 1800,
|
|
27
|
-
/** 键盘快捷键(如 Delete/Ctrl+C) */
|
|
28
|
-
KeyboardShortcut = 1700,
|
|
29
|
-
/** 单击选中元素 */
|
|
30
|
-
ClickSelection = 1600,
|
|
31
|
-
/** 双击编辑元素 */
|
|
32
|
-
DoubleClickEdit = 1500,
|
|
33
|
-
/** 框选(多选)操作 */
|
|
34
|
-
MarqueeSelection = 1300,
|
|
35
|
-
/** 套索选择(Lasso Select) */
|
|
36
|
-
LassoSelection = 1250,
|
|
37
|
-
/** 长按操作(长按菜单/工具) */
|
|
38
|
-
LongPress = 1100,
|
|
39
|
-
/** 悬停提示(Hover Tooltip) */
|
|
40
|
-
HoverTooltip = 1000,
|
|
41
|
-
/** 画布平移(空格拖拽或手势) */
|
|
42
|
-
CanvasPan = 900,
|
|
43
|
-
/** 画布缩放(滚轮或双指) */
|
|
44
|
-
CanvasZoom = 800,
|
|
45
|
-
/** 多指手势(如三指滑动) */
|
|
46
|
-
MultiTouchGesture = 700
|
|
47
|
-
}
|
|
48
|
-
interface Interaction {
|
|
49
|
-
pluginId: string;
|
|
50
|
-
type: string;
|
|
51
|
-
priority: InteractionPriority;
|
|
52
|
-
active?: boolean;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* 交互管理器
|
|
56
|
-
*/
|
|
57
|
-
declare class InteractionManager {
|
|
58
|
-
private interactions;
|
|
59
|
-
/**
|
|
60
|
-
* 获取当前活动的交互
|
|
61
|
-
*/
|
|
62
|
-
get activeInteraction(): Interaction | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* 检查是否可以交互
|
|
65
|
-
* @param pluginId 插件ID
|
|
66
|
-
* @param type 交互类型
|
|
67
|
-
* @param autoStartPriority 自动启动优先级
|
|
68
|
-
* @returns 是否可以交互
|
|
69
|
-
*/
|
|
70
|
-
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* 启动交互
|
|
73
|
-
* @param pluginId 插件ID
|
|
74
|
-
* @param type 交互类型
|
|
75
|
-
* @param priority 优先级
|
|
76
|
-
* @returns 取消交互的函数
|
|
77
|
-
*/
|
|
78
|
-
startInteraction(pluginId: string, type: string, priority: InteractionPriority): () => void;
|
|
79
|
-
/**
|
|
80
|
-
* 结束交互
|
|
81
|
-
* @param pluginId 插件ID
|
|
82
|
-
* @param type 交互类型
|
|
83
|
-
*/
|
|
84
|
-
endInteraction(pluginId: string, type: string): void;
|
|
85
|
-
private updateActive;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
interface EngineOptions<TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
|
|
89
|
-
container: Container;
|
|
90
|
-
plugins?: Plugin[];
|
|
91
|
-
pluginConfig?: IRecord;
|
|
92
|
-
nodes?: Node<TNode>[];
|
|
93
|
-
edges?: Edge<TEdge>[];
|
|
94
|
-
runtime?: IEngineRuntime;
|
|
95
|
-
}
|
|
96
|
-
declare module '@knotx/core' {
|
|
97
|
-
interface EngineTools {
|
|
98
|
-
listPlugins: Engine['listPlugins'];
|
|
99
|
-
listPluginTools: Engine['listPluginTools'];
|
|
100
|
-
getNodes: Engine['getNodes'];
|
|
101
|
-
getEdges: Engine['getEdges'];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
declare class Engine<TRenderType extends RenderType = RenderType, TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
|
|
105
|
-
readonly runtime: IEngineRuntime;
|
|
106
|
-
readonly interactionManager: InteractionManager;
|
|
107
|
-
readonly nodesManager: DataManager<Node<TNode>>;
|
|
108
|
-
readonly edgesManager: DataManager<Edge<TEdge>>;
|
|
109
|
-
private container$;
|
|
110
|
-
private nodes$;
|
|
111
|
-
private edges$;
|
|
112
|
-
private layers$;
|
|
113
|
-
private plugins$;
|
|
114
|
-
private nodeRenderers$;
|
|
115
|
-
private edgeRenderers$;
|
|
116
|
-
private _pluginDataContainer;
|
|
117
|
-
private _pluginToolsContainer;
|
|
118
|
-
private engineTools;
|
|
119
|
-
private toolParametersValidator;
|
|
120
|
-
get container(): Container;
|
|
121
|
-
set container(value: Container);
|
|
122
|
-
get nodes(): Node<TNode>[];
|
|
123
|
-
get edges(): Edge<TEdge>[];
|
|
124
|
-
get layers(): Map<number, LayerComponent<TRenderType>[]>;
|
|
125
|
-
get plugins(): IPlugin<string, any, RenderType>[];
|
|
126
|
-
constructor(options: EngineOptions<TNode, TEdge>);
|
|
127
|
-
private init;
|
|
128
|
-
getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
|
|
129
|
-
addNodePipe(pipe: DataOperationPipe<Node<TNode>>): () => void;
|
|
130
|
-
addEdgePipe(pipe: DataOperationPipe<Edge<TEdge>>): () => void;
|
|
131
|
-
changePluginConfig(pluginName: string, config: IRecord): void;
|
|
132
|
-
dispatchNodeOperation(operation: DataOperation<Node<TNode>>): void;
|
|
133
|
-
dispatchEdgeOperation(operation: DataOperation<Edge<TEdge>>): void;
|
|
134
|
-
getPlugin<TPlugin extends IPlugin>(pluginName: TPlugin['name']): TPlugin | undefined;
|
|
135
|
-
getNode(id: string): Node<TNode> | undefined;
|
|
136
|
-
getNodeDraft(id: string): Node<TNode> | undefined;
|
|
137
|
-
getNodes(): Node<TNode>[];
|
|
138
|
-
getNodeRenderer(type: string): NodeRenderType | undefined;
|
|
139
|
-
getEdge(id: string): Edge<TEdge> | undefined;
|
|
140
|
-
getEdgeDraft(id: string): Edge<TEdge> | undefined;
|
|
141
|
-
getEdges(): Edge<TEdge>[];
|
|
142
|
-
getEdgeRenderer(type: string): EdgeRenderType | undefined;
|
|
143
|
-
registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
|
|
144
|
-
resetPluginData<T extends keyof PluginData>(pluginName: T): void;
|
|
145
|
-
registerPluginTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, property: TP, data: {
|
|
146
|
-
description: string;
|
|
147
|
-
parameters: Schema;
|
|
148
|
-
func: PluginTools[T][TP];
|
|
149
|
-
}): void;
|
|
150
|
-
resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
|
|
151
|
-
registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
|
|
152
|
-
registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
|
|
153
|
-
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
|
|
154
|
-
startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
|
|
155
|
-
endInteraction(pluginId: string, type: string): void;
|
|
156
|
-
callTool<T extends keyof EngineTools>(engineToolName: T, ...args: Parameters<EngineTools[T]>): ReturnType<EngineTools[T]>;
|
|
157
|
-
callTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, toolName: TP, ...args: Parameters<PluginTools[T][TP]>): ReturnType<PluginTools[T][TP]>;
|
|
158
|
-
listPlugins(): IPluginInfo[];
|
|
159
|
-
listPluginTools({ pluginName }: {
|
|
160
|
-
pluginName: string;
|
|
161
|
-
}): IPluginToolInfo[];
|
|
162
|
-
listEngineTools(): IPluginToolInfo[];
|
|
163
|
-
destroy(): void;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
declare function getLayerRenders<TRenderType extends RenderType$1 = RenderType$1>(plugin: IPlugin$1): LayerComponent$1<TRenderType>[];
|
|
9
|
+
declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
|
|
167
10
|
|
|
168
11
|
/**
|
|
169
12
|
* Runtime 类
|
|
@@ -226,4 +69,4 @@ declare function use<T, TContext>(hook: () => {
|
|
|
226
69
|
__contextValue__: TContext;
|
|
227
70
|
}, context: TContext): T;
|
|
228
71
|
|
|
229
|
-
export {
|
|
72
|
+
export { Engine, Runtime, getLayerRenders, use };
|