@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.
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
3
- export { C as Container, E as Edge, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, e as EdgeRenderType, H as HorizontalAlignment, a as IEngineRuntime, b as IPlugin, h as IPluginInfo, i as IPluginToolInfo, I as IRecord, c as Layer, L as LayerComponent, N as Node, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, d as NodeRenderType, P as Plugin, o as PluginConfigs, f as PluginData, g as PluginTools, n as Position, R as RenderType, V as VerticalAlignment } from './shared/core.Cwp_TTTs.cjs';
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';
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
3
- export { C as Container, E as Edge, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, e as EdgeRenderType, H as HorizontalAlignment, a as IEngineRuntime, b as IPlugin, h as IPluginInfo, i as IPluginToolInfo, I as IRecord, c as Layer, L as LayerComponent, N as Node, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, d as NodeRenderType, P as Plugin, o as PluginConfigs, f as PluginData, g as PluginTools, n as Position, R as RenderType, V as VerticalAlignment } from './shared/core.Cwp_TTTs.mjs';
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';
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
3
- export { C as Container, E as Edge, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, e as EdgeRenderType, H as HorizontalAlignment, a as IEngineRuntime, b as IPlugin, h as IPluginInfo, i as IPluginToolInfo, I as IRecord, c as Layer, L as LayerComponent, N as Node, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, d as NodeRenderType, P as Plugin, o as PluginConfigs, f as PluginData, g as PluginTools, n as Position, R as RenderType, V as VerticalAlignment } from './shared/core.Cwp_TTTs.js';
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
@@ -92,17 +92,17 @@ class InteractionManager {
92
92
  }
93
93
 
94
94
  var __defProp$3 = Object.defineProperty;
95
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
96
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
97
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
95
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
96
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
97
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
98
98
  var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
99
- var __spreadValues$1 = (a, b) => {
99
+ var __spreadValues$2 = (a, b) => {
100
100
  for (var prop in b || (b = {}))
101
- if (__hasOwnProp$1.call(b, prop))
101
+ if (__hasOwnProp$2.call(b, prop))
102
102
  __defNormalProp$3(a, prop, b[prop]);
103
- if (__getOwnPropSymbols$1)
104
- for (var prop of __getOwnPropSymbols$1(b)) {
105
- if (__propIsEnum$1.call(b, prop))
103
+ if (__getOwnPropSymbols$2)
104
+ for (var prop of __getOwnPropSymbols$2(b)) {
105
+ if (__propIsEnum$2.call(b, prop))
106
106
  __defNormalProp$3(a, prop, b[prop]);
107
107
  }
108
108
  return a;
@@ -112,7 +112,7 @@ function getLayerRenders(plugin) {
112
112
  const components = [];
113
113
  let isRenderConsumed = false;
114
114
  for (const [name, layer] of Object.entries((_a = Reflect.get(plugin, utils.getSymbol("layer"))) != null ? _a : {})) {
115
- components.push(__spreadValues$1({
115
+ components.push(__spreadValues$2({
116
116
  plugin: plugin.name,
117
117
  name: `${plugin.name}:${name}`,
118
118
  render: wrapRender(Reflect.get(plugin, name), plugin)
@@ -137,7 +137,24 @@ function wrapRender(render, plugin) {
137
137
  }
138
138
 
139
139
  var __defProp$2 = Object.defineProperty;
140
+ var __defProps$1 = Object.defineProperties;
141
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
142
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
143
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
144
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
140
145
  var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
146
+ var __spreadValues$1 = (a, b) => {
147
+ for (var prop in b || (b = {}))
148
+ if (__hasOwnProp$1.call(b, prop))
149
+ __defNormalProp$2(a, prop, b[prop]);
150
+ if (__getOwnPropSymbols$1)
151
+ for (var prop of __getOwnPropSymbols$1(b)) {
152
+ if (__propIsEnum$1.call(b, prop))
153
+ __defNormalProp$2(a, prop, b[prop]);
154
+ }
155
+ return a;
156
+ };
157
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
141
158
  var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
142
159
  class Engine {
143
160
  constructor(options) {
@@ -154,7 +171,84 @@ class Engine {
154
171
  __publicField$2(this, "edgeRenderers$", new rxjs.BehaviorSubject(/* @__PURE__ */ new Map()));
155
172
  __publicField$2(this, "_pluginDataContainer", {});
156
173
  __publicField$2(this, "_pluginToolsContainer", {});
157
- __publicField$2(this, "toolParamsValidator", new jsonschema.Validator());
174
+ __publicField$2(this, "engineTools", new Map([
175
+ {
176
+ type: "function",
177
+ name: "listPlugins",
178
+ description: "List all plugins",
179
+ parameters: {}
180
+ },
181
+ {
182
+ type: "function",
183
+ name: "listPluginTools",
184
+ description: "List all tools of a plugin",
185
+ parameters: {
186
+ type: "object",
187
+ properties: {
188
+ pluginName: { type: "string" }
189
+ },
190
+ required: ["pluginName"]
191
+ }
192
+ },
193
+ {
194
+ type: "function",
195
+ name: "getNodes",
196
+ description: "Get all nodes data",
197
+ parameters: {}
198
+ },
199
+ {
200
+ type: "function",
201
+ name: "getEdges",
202
+ description: "Get all edges data",
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
+ }
228
+ }
229
+ ].map((tool) => [tool.name, tool])));
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
+ });
158
252
  var _a;
159
253
  this.runtime = (_a = options.runtime) != null ? _a : {};
160
254
  this.container$.next(options.container);
@@ -225,7 +319,7 @@ class Engine {
225
319
  addEdgePipe(pipe) {
226
320
  return this.edgesManager.addDataOperationPipe(pipe);
227
321
  }
228
- changePluginConfig(pluginName, config) {
322
+ changePluginConfig({ pluginName, config }) {
229
323
  var _a, _b;
230
324
  (_b = (_a = this.plugins$.value.get(pluginName)) == null ? void 0 : _a.onConfigChange) == null ? void 0 : _b.call(_a, config);
231
325
  }
@@ -235,13 +329,13 @@ class Engine {
235
329
  dispatchEdgeOperation(operation) {
236
330
  this.edgesManager.dispatch(operation);
237
331
  }
238
- getPlugin(pluginName) {
332
+ getPlugin({ pluginName }) {
239
333
  return this.plugins$.value.get(pluginName);
240
334
  }
241
- getNode(id) {
335
+ getNode({ id }) {
242
336
  return this.nodesManager.getData(id);
243
337
  }
244
- getNodeDraft(id) {
338
+ getNodeDraft({ id }) {
245
339
  return this.nodesManager.getCurrentDraftData(id);
246
340
  }
247
341
  getNodes() {
@@ -250,10 +344,10 @@ class Engine {
250
344
  getNodeRenderer(type) {
251
345
  return this.nodeRenderers$.value.get(type);
252
346
  }
253
- getEdge(id) {
347
+ getEdge({ id }) {
254
348
  return this.edgesManager.getData(id);
255
349
  }
256
- getEdgeDraft(id) {
350
+ getEdgeDraft({ id }) {
257
351
  return this.edgesManager.getCurrentDraftData(id);
258
352
  }
259
353
  getEdges() {
@@ -303,54 +397,22 @@ class Engine {
303
397
  endInteraction(pluginId, type) {
304
398
  this.interactionManager.endInteraction(pluginId, type);
305
399
  }
306
- callTool(pluginName, toolName, ...args) {
307
- const toolDefinition = lodashEs.get(this, ["_pluginToolsContainer", pluginName, toolName]);
308
- const tool = toolDefinition == null ? void 0 : toolDefinition.func;
309
- if (!tool || typeof tool !== "function") {
310
- throw new Error(`Tool ${String(toolName)} not found in plugin ${pluginName}`);
311
- }
312
- const params = args[0];
313
- const validator = this.toolParamsValidator.validate(params, toolDefinition.params);
314
- if (validator.errors.length > 0) {
315
- throw new Error(`Invalid tool params: ${validator.errors.map((e) => e.stack).join(", ")}`);
316
- }
317
- return tool(params);
318
- }
319
400
  listPlugins() {
320
401
  return Array.from(this.plugins$.value.values()).map((plugin) => ({
321
402
  name: plugin.name,
322
403
  description: plugin.description
323
404
  }));
324
405
  }
325
- listPluginTools(pluginName) {
406
+ listPluginTools({ pluginName }) {
326
407
  return Object.entries(lodashEs.get(this, ["_pluginToolsContainer", pluginName]) || {}).map(([toolName, toolDefinition]) => ({
327
408
  type: "function",
328
409
  name: toolName,
329
410
  description: toolDefinition.description,
330
- parameters: toolDefinition.params
411
+ parameters: toolDefinition.parameters
331
412
  }));
332
413
  }
333
414
  listEngineTools() {
334
- return [
335
- {
336
- type: "function",
337
- name: "listPlugins",
338
- description: "List all plugins",
339
- parameters: {}
340
- },
341
- {
342
- type: "function",
343
- name: "listPluginTools",
344
- description: "List all tools of a plugin",
345
- parameters: {
346
- type: "object",
347
- properties: {
348
- pluginName: { type: "string" }
349
- },
350
- required: ["pluginName"]
351
- }
352
- }
353
- ];
415
+ return Array.from(this.engineTools.values());
354
416
  }
355
417
  destroy() {
356
418
  this.plugins$.value.forEach((plugin) => {
@@ -380,6 +442,10 @@ const _BasePlugin = class _BasePlugin {
380
442
  * 可随时存入,销毁时会自动执行
381
443
  */
382
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
+ });
383
449
  Reflect.set(this, utils.getSymbol("engine"), new rxjs.BehaviorSubject(null));
384
450
  }
385
451
  get pluginId() {
package/dist/index.d.cts CHANGED
@@ -1,157 +1,12 @@
1
- import { I as IRecord, C as Container, P as Plugin, N as Node, E as Edge, a as IEngineRuntime, R as RenderType, L as LayerComponent, b as IPlugin, c as Layer, d as NodeRenderType, e as EdgeRenderType, f as PluginData, g as PluginTools, h as IPluginInfo, i as IPluginToolInfo } from './shared/core.Cwp_TTTs.cjs';
2
- export { B as BasePlugin, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, H as HorizontalAlignment, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, o as PluginConfigs, n as Position, V as VerticalAlignment } from './shared/core.Cwp_TTTs.cjs';
3
- import { Schema } from 'jsonschema';
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 class Engine<TRenderType extends RenderType = RenderType, TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
97
- readonly runtime: IEngineRuntime;
98
- readonly interactionManager: InteractionManager;
99
- readonly nodesManager: DataManager<Node<TNode>>;
100
- readonly edgesManager: DataManager<Edge<TEdge>>;
101
- private container$;
102
- private nodes$;
103
- private edges$;
104
- private layers$;
105
- private plugins$;
106
- private nodeRenderers$;
107
- private edgeRenderers$;
108
- private _pluginDataContainer;
109
- private _pluginToolsContainer;
110
- private toolParamsValidator;
111
- get container(): Container;
112
- set container(value: Container);
113
- get nodes(): Node<TNode>[];
114
- get edges(): Edge<TEdge>[];
115
- get layers(): Map<number, LayerComponent<TRenderType>[]>;
116
- get plugins(): IPlugin<string, any, RenderType>[];
117
- constructor(options: EngineOptions<TNode, TEdge>);
118
- private init;
119
- getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
120
- addNodePipe(pipe: DataOperationPipe<Node<TNode>>): () => void;
121
- addEdgePipe(pipe: DataOperationPipe<Edge<TEdge>>): () => void;
122
- changePluginConfig(pluginName: string, config: IRecord): void;
123
- dispatchNodeOperation(operation: DataOperation<Node<TNode>>): void;
124
- dispatchEdgeOperation(operation: DataOperation<Edge<TEdge>>): void;
125
- getPlugin<TPlugin extends IPlugin>(pluginName: TPlugin['name']): TPlugin | undefined;
126
- getNode(id: string): Node<TNode> | undefined;
127
- getNodeDraft(id: string): Node<TNode> | undefined;
128
- getNodes(): Node<TNode>[];
129
- getNodeRenderer(type: string): NodeRenderType | undefined;
130
- getEdge(id: string): Edge<TEdge> | undefined;
131
- getEdgeDraft(id: string): Edge<TEdge> | undefined;
132
- getEdges(): Edge<TEdge>[];
133
- getEdgeRenderer(type: string): EdgeRenderType | undefined;
134
- registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
135
- resetPluginData<T extends keyof PluginData>(pluginName: T): void;
136
- registerPluginTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, property: TP, data: {
137
- description: string;
138
- params: Schema;
139
- func: PluginTools[T][TP];
140
- }): void;
141
- resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
142
- registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
143
- registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
144
- canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
145
- startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
146
- endInteraction(pluginId: string, type: string): void;
147
- callTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, toolName: TP, ...args: Parameters<PluginTools[T][TP]>): any;
148
- listPlugins(): IPluginInfo[];
149
- listPluginTools(pluginName: string): IPluginToolInfo[];
150
- listEngineTools(): IPluginToolInfo[];
151
- destroy(): void;
152
- }
153
-
154
- 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>[];
155
10
 
156
11
  /**
157
12
  * Runtime 类
@@ -214,4 +69,4 @@ declare function use<T, TContext>(hook: () => {
214
69
  __contextValue__: TContext;
215
70
  }, context: TContext): T;
216
71
 
217
- export { Container, Edge, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, IPluginInfo, IPluginToolInfo, IRecord, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, Node, NodeRenderType, Plugin, PluginData, PluginTools, RenderType, Runtime, getLayerRenders, use };
72
+ export { Engine, Runtime, getLayerRenders, use };
package/dist/index.d.mts CHANGED
@@ -1,157 +1,12 @@
1
- import { I as IRecord, C as Container, P as Plugin, N as Node, E as Edge, a as IEngineRuntime, R as RenderType, L as LayerComponent, b as IPlugin, c as Layer, d as NodeRenderType, e as EdgeRenderType, f as PluginData, g as PluginTools, h as IPluginInfo, i as IPluginToolInfo } from './shared/core.Cwp_TTTs.mjs';
2
- export { B as BasePlugin, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, H as HorizontalAlignment, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, o as PluginConfigs, n as Position, V as VerticalAlignment } from './shared/core.Cwp_TTTs.mjs';
3
- import { Schema } from 'jsonschema';
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 class Engine<TRenderType extends RenderType = RenderType, TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
97
- readonly runtime: IEngineRuntime;
98
- readonly interactionManager: InteractionManager;
99
- readonly nodesManager: DataManager<Node<TNode>>;
100
- readonly edgesManager: DataManager<Edge<TEdge>>;
101
- private container$;
102
- private nodes$;
103
- private edges$;
104
- private layers$;
105
- private plugins$;
106
- private nodeRenderers$;
107
- private edgeRenderers$;
108
- private _pluginDataContainer;
109
- private _pluginToolsContainer;
110
- private toolParamsValidator;
111
- get container(): Container;
112
- set container(value: Container);
113
- get nodes(): Node<TNode>[];
114
- get edges(): Edge<TEdge>[];
115
- get layers(): Map<number, LayerComponent<TRenderType>[]>;
116
- get plugins(): IPlugin<string, any, RenderType>[];
117
- constructor(options: EngineOptions<TNode, TEdge>);
118
- private init;
119
- getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
120
- addNodePipe(pipe: DataOperationPipe<Node<TNode>>): () => void;
121
- addEdgePipe(pipe: DataOperationPipe<Edge<TEdge>>): () => void;
122
- changePluginConfig(pluginName: string, config: IRecord): void;
123
- dispatchNodeOperation(operation: DataOperation<Node<TNode>>): void;
124
- dispatchEdgeOperation(operation: DataOperation<Edge<TEdge>>): void;
125
- getPlugin<TPlugin extends IPlugin>(pluginName: TPlugin['name']): TPlugin | undefined;
126
- getNode(id: string): Node<TNode> | undefined;
127
- getNodeDraft(id: string): Node<TNode> | undefined;
128
- getNodes(): Node<TNode>[];
129
- getNodeRenderer(type: string): NodeRenderType | undefined;
130
- getEdge(id: string): Edge<TEdge> | undefined;
131
- getEdgeDraft(id: string): Edge<TEdge> | undefined;
132
- getEdges(): Edge<TEdge>[];
133
- getEdgeRenderer(type: string): EdgeRenderType | undefined;
134
- registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
135
- resetPluginData<T extends keyof PluginData>(pluginName: T): void;
136
- registerPluginTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, property: TP, data: {
137
- description: string;
138
- params: Schema;
139
- func: PluginTools[T][TP];
140
- }): void;
141
- resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
142
- registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
143
- registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
144
- canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
145
- startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
146
- endInteraction(pluginId: string, type: string): void;
147
- callTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, toolName: TP, ...args: Parameters<PluginTools[T][TP]>): any;
148
- listPlugins(): IPluginInfo[];
149
- listPluginTools(pluginName: string): IPluginToolInfo[];
150
- listEngineTools(): IPluginToolInfo[];
151
- destroy(): void;
152
- }
153
-
154
- 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>[];
155
10
 
156
11
  /**
157
12
  * Runtime 类
@@ -214,4 +69,4 @@ declare function use<T, TContext>(hook: () => {
214
69
  __contextValue__: TContext;
215
70
  }, context: TContext): T;
216
71
 
217
- export { Container, Edge, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, IPluginInfo, IPluginToolInfo, IRecord, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, Node, NodeRenderType, Plugin, PluginData, PluginTools, RenderType, Runtime, getLayerRenders, use };
72
+ export { Engine, Runtime, getLayerRenders, use };