@knotx/core 0.3.8 → 0.4.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, 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.CEEdZ7QA.cjs';
3
+ export { C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.cjs';
4
4
  import '@knotx/data';
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
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.CEEdZ7QA.mjs';
3
+ export { C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.mjs';
4
4
  import '@knotx/data';
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
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.CEEdZ7QA.js';
3
+ export { C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.js';
4
4
  import '@knotx/data';
package/dist/index.cjs CHANGED
@@ -242,7 +242,7 @@ class Engine {
242
242
  throw new Error(`Tool ${String(toolDisplayName)} not found`);
243
243
  }
244
244
  const parameters = args[args.length - 1];
245
- const validator = this.toolParametersValidator.validate(parameters, toolDefinition.parameters);
245
+ const validator = this.toolParametersValidator.validate(parameters, toolDefinition.parameters, { base: "https://knotx.org" });
246
246
  if (validator.errors.length > 0) {
247
247
  throw new Error(`Invalid tool parameters: ${validator.errors.map((e) => e.stack).join(", ")}`);
248
248
  }
@@ -377,9 +377,12 @@ class Engine {
377
377
  this.nodeRenderers$.next(nodeRenderers2);
378
378
  };
379
379
  }
380
- registerEdgeRenderer(type, renderer) {
380
+ registerEdgeRenderer(type, renderer, config) {
381
381
  const edgeRenderers = this.edgeRenderers$.value;
382
- edgeRenderers.set(type, renderer);
382
+ edgeRenderers.set(type, {
383
+ renderer,
384
+ config
385
+ });
383
386
  this.edgeRenderers$.next(edgeRenderers);
384
387
  return () => {
385
388
  const edgeRenderers2 = this.edgeRenderers$.value;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Engine } from './shared/core.CEEdZ7QA.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.CEEdZ7QA.cjs';
1
+ import { E as Engine } from './shared/core.CJuzxwMC.cjs';
2
+ export { G as BasePlugin, A as CallToolMethod, C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, z as EngineOptions, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, D as Interaction, F as InteractionManager, B as InteractionPriority, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.cjs';
3
3
  import { RenderType, IPlugin, LayerComponent } from '@knotx/core';
4
4
  import { BehaviorSubject } from 'rxjs';
5
5
  export * from '@knotx/data';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Engine } from './shared/core.CEEdZ7QA.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.CEEdZ7QA.mjs';
1
+ import { E as Engine } from './shared/core.CJuzxwMC.mjs';
2
+ export { G as BasePlugin, A as CallToolMethod, C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, z as EngineOptions, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, D as Interaction, F as InteractionManager, B as InteractionPriority, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.mjs';
3
3
  import { RenderType, IPlugin, LayerComponent } from '@knotx/core';
4
4
  import { BehaviorSubject } from 'rxjs';
5
5
  export * from '@knotx/data';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Engine } from './shared/core.CEEdZ7QA.js';
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.CEEdZ7QA.js';
1
+ import { E as Engine } from './shared/core.CJuzxwMC.js';
2
+ export { G as BasePlugin, A as CallToolMethod, C as Container, d as Edge, e as EdgeConfig, v as EdgeOperation, t as EdgeOperationPipe, x as EdgeOperatorFunction, f as EdgeProps, i as EdgeRender, h as EdgeRenderType, z as EngineOptions, p as EngineTools, H as HorizontalAlignment, y as IEngineRuntime, k as IPlugin, q as IPluginInfo, I as IRecord, r as IToolInfo, D as Interaction, F as InteractionManager, B as InteractionPriority, L as Layer, j as LayerComponent, b as Node, a as NodeMeasured, u as NodeOperation, s as NodeOperationPipe, w as NodeOperatorFunction, N as NodePosition, c as NodeProps, g as NodeRenderType, l as Plugin, m as PluginConfigs, n as PluginData, o as PluginTools, P as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CJuzxwMC.js';
3
3
  import { RenderType, IPlugin, LayerComponent } from '@knotx/core';
4
4
  import { BehaviorSubject } from 'rxjs';
5
5
  export * from '@knotx/data';
package/dist/index.js CHANGED
@@ -242,7 +242,7 @@ class Engine {
242
242
  throw new Error(`Tool ${String(toolDisplayName)} not found`);
243
243
  }
244
244
  const parameters = args[args.length - 1];
245
- const validator = this.toolParametersValidator.validate(parameters, toolDefinition.parameters);
245
+ const validator = this.toolParametersValidator.validate(parameters, toolDefinition.parameters, { base: "https://knotx.org" });
246
246
  if (validator.errors.length > 0) {
247
247
  throw new Error(`Invalid tool parameters: ${validator.errors.map((e) => e.stack).join(", ")}`);
248
248
  }
@@ -377,9 +377,12 @@ class Engine {
377
377
  this.nodeRenderers$.next(nodeRenderers2);
378
378
  };
379
379
  }
380
- registerEdgeRenderer(type, renderer) {
380
+ registerEdgeRenderer(type, renderer, config) {
381
381
  const edgeRenderers = this.edgeRenderers$.value;
382
- edgeRenderers.set(type, renderer);
382
+ edgeRenderers.set(type, {
383
+ renderer,
384
+ config
385
+ });
383
386
  this.edgeRenderers$.next(edgeRenderers);
384
387
  return () => {
385
388
  const edgeRenderers2 = this.edgeRenderers$.value;
@@ -154,7 +154,7 @@ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends
154
154
  id: string;
155
155
  }): Edge<TEdge> | undefined;
156
156
  getEdges(): Edge<TEdge>[];
157
- getEdgeRenderer(type: string): EdgeRenderType | undefined;
157
+ getEdgeRenderer(type: string): EdgeRender | undefined;
158
158
  registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
159
159
  resetPluginData<T extends keyof PluginData>(pluginName: T): void;
160
160
  registerPluginTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, property: TP, data: {
@@ -164,7 +164,7 @@ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends
164
164
  }): void;
165
165
  resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
166
166
  registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
167
- registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
167
+ registerEdgeRenderer(type: string, renderer: EdgeRenderType, config: EdgeConfig): (() => void);
168
168
  listPlugins(): IPluginInfo[];
169
169
  listPluginTools({ pluginName }: {
170
170
  pluginName: string;
@@ -209,13 +209,21 @@ interface Node<TData extends IRecord = IRecord> {
209
209
  interface NodeProps<TData extends IRecord = IRecord> {
210
210
  node: Node<TData>;
211
211
  }
212
- interface Edge<TData extends IRecord = IRecord> {
212
+ interface Edge<TData extends IRecord = IRecord> extends Partial<EdgeConfig> {
213
213
  id: string;
214
214
  source: string;
215
215
  target: string;
216
216
  type?: string;
217
217
  data?: TData;
218
218
  }
219
+ interface EdgeConfig {
220
+ sourcePosition: Position;
221
+ targetPosition: Position;
222
+ sourceYOffset: string | number;
223
+ sourceXOffset: string | number;
224
+ targetYOffset: string | number;
225
+ targetXOffset: string | number;
226
+ }
219
227
  interface EdgeProps<TData extends IRecord = IRecord> {
220
228
  edge: Edge<TData>;
221
229
  sourceX: number;
@@ -227,10 +235,14 @@ interface Container {
227
235
  width: number;
228
236
  height: number;
229
237
  }
230
- type Position = 'top' | 'right' | 'bottom' | 'left';
238
+ type Position = VerticalAlignment | HorizontalAlignment | `${HorizontalAlignment}-${VerticalAlignment}` | 'center';
231
239
  type RenderType = (...args: any[]) => any;
232
240
  type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>) => TR;
233
241
  type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
242
+ interface EdgeRender<TD extends IRecord = any, TR = any> {
243
+ renderer: EdgeRenderType<TD, TR>;
244
+ config: EdgeConfig;
245
+ }
234
246
  declare enum Layer {
235
247
  Canvas = 0,
236
248
  Background = 4,
@@ -317,4 +329,4 @@ interface IEngineRuntime {
317
329
  };
318
330
  }
319
331
 
320
- 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 };
332
+ export { type CallToolMethod as A, InteractionPriority as B, type Container as C, type Interaction as D, Engine as E, InteractionManager as F, BasePlugin as G, 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 EdgeConfig as e, type EdgeProps as f, type NodeRenderType as g, type EdgeRenderType as h, type EdgeRender as i, type LayerComponent as j, type IPlugin as k, type Plugin as l, type PluginConfigs as m, type PluginData as n, type PluginTools as o, type EngineTools as p, type IPluginInfo as q, type IToolInfo as r, type NodeOperationPipe as s, type EdgeOperationPipe as t, type NodeOperation as u, type EdgeOperation as v, type NodeOperatorFunction as w, type EdgeOperatorFunction as x, type IEngineRuntime as y, type EngineOptions as z };
@@ -154,7 +154,7 @@ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends
154
154
  id: string;
155
155
  }): Edge<TEdge> | undefined;
156
156
  getEdges(): Edge<TEdge>[];
157
- getEdgeRenderer(type: string): EdgeRenderType | undefined;
157
+ getEdgeRenderer(type: string): EdgeRender | undefined;
158
158
  registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
159
159
  resetPluginData<T extends keyof PluginData>(pluginName: T): void;
160
160
  registerPluginTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, property: TP, data: {
@@ -164,7 +164,7 @@ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends
164
164
  }): void;
165
165
  resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
166
166
  registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
167
- registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
167
+ registerEdgeRenderer(type: string, renderer: EdgeRenderType, config: EdgeConfig): (() => void);
168
168
  listPlugins(): IPluginInfo[];
169
169
  listPluginTools({ pluginName }: {
170
170
  pluginName: string;
@@ -209,13 +209,21 @@ interface Node<TData extends IRecord = IRecord> {
209
209
  interface NodeProps<TData extends IRecord = IRecord> {
210
210
  node: Node<TData>;
211
211
  }
212
- interface Edge<TData extends IRecord = IRecord> {
212
+ interface Edge<TData extends IRecord = IRecord> extends Partial<EdgeConfig> {
213
213
  id: string;
214
214
  source: string;
215
215
  target: string;
216
216
  type?: string;
217
217
  data?: TData;
218
218
  }
219
+ interface EdgeConfig {
220
+ sourcePosition: Position;
221
+ targetPosition: Position;
222
+ sourceYOffset: string | number;
223
+ sourceXOffset: string | number;
224
+ targetYOffset: string | number;
225
+ targetXOffset: string | number;
226
+ }
219
227
  interface EdgeProps<TData extends IRecord = IRecord> {
220
228
  edge: Edge<TData>;
221
229
  sourceX: number;
@@ -227,10 +235,14 @@ interface Container {
227
235
  width: number;
228
236
  height: number;
229
237
  }
230
- type Position = 'top' | 'right' | 'bottom' | 'left';
238
+ type Position = VerticalAlignment | HorizontalAlignment | `${HorizontalAlignment}-${VerticalAlignment}` | 'center';
231
239
  type RenderType = (...args: any[]) => any;
232
240
  type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>) => TR;
233
241
  type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
242
+ interface EdgeRender<TD extends IRecord = any, TR = any> {
243
+ renderer: EdgeRenderType<TD, TR>;
244
+ config: EdgeConfig;
245
+ }
234
246
  declare enum Layer {
235
247
  Canvas = 0,
236
248
  Background = 4,
@@ -317,4 +329,4 @@ interface IEngineRuntime {
317
329
  };
318
330
  }
319
331
 
320
- 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 };
332
+ export { type CallToolMethod as A, InteractionPriority as B, type Container as C, type Interaction as D, Engine as E, InteractionManager as F, BasePlugin as G, 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 EdgeConfig as e, type EdgeProps as f, type NodeRenderType as g, type EdgeRenderType as h, type EdgeRender as i, type LayerComponent as j, type IPlugin as k, type Plugin as l, type PluginConfigs as m, type PluginData as n, type PluginTools as o, type EngineTools as p, type IPluginInfo as q, type IToolInfo as r, type NodeOperationPipe as s, type EdgeOperationPipe as t, type NodeOperation as u, type EdgeOperation as v, type NodeOperatorFunction as w, type EdgeOperatorFunction as x, type IEngineRuntime as y, type EngineOptions as z };
@@ -154,7 +154,7 @@ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends
154
154
  id: string;
155
155
  }): Edge<TEdge> | undefined;
156
156
  getEdges(): Edge<TEdge>[];
157
- getEdgeRenderer(type: string): EdgeRenderType | undefined;
157
+ getEdgeRenderer(type: string): EdgeRender | undefined;
158
158
  registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
159
159
  resetPluginData<T extends keyof PluginData>(pluginName: T): void;
160
160
  registerPluginTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, property: TP, data: {
@@ -164,7 +164,7 @@ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends
164
164
  }): void;
165
165
  resetPluginTool<T extends keyof PluginTools>(pluginName: T): void;
166
166
  registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
167
- registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
167
+ registerEdgeRenderer(type: string, renderer: EdgeRenderType, config: EdgeConfig): (() => void);
168
168
  listPlugins(): IPluginInfo[];
169
169
  listPluginTools({ pluginName }: {
170
170
  pluginName: string;
@@ -209,13 +209,21 @@ interface Node<TData extends IRecord = IRecord> {
209
209
  interface NodeProps<TData extends IRecord = IRecord> {
210
210
  node: Node<TData>;
211
211
  }
212
- interface Edge<TData extends IRecord = IRecord> {
212
+ interface Edge<TData extends IRecord = IRecord> extends Partial<EdgeConfig> {
213
213
  id: string;
214
214
  source: string;
215
215
  target: string;
216
216
  type?: string;
217
217
  data?: TData;
218
218
  }
219
+ interface EdgeConfig {
220
+ sourcePosition: Position;
221
+ targetPosition: Position;
222
+ sourceYOffset: string | number;
223
+ sourceXOffset: string | number;
224
+ targetYOffset: string | number;
225
+ targetXOffset: string | number;
226
+ }
219
227
  interface EdgeProps<TData extends IRecord = IRecord> {
220
228
  edge: Edge<TData>;
221
229
  sourceX: number;
@@ -227,10 +235,14 @@ interface Container {
227
235
  width: number;
228
236
  height: number;
229
237
  }
230
- type Position = 'top' | 'right' | 'bottom' | 'left';
238
+ type Position = VerticalAlignment | HorizontalAlignment | `${HorizontalAlignment}-${VerticalAlignment}` | 'center';
231
239
  type RenderType = (...args: any[]) => any;
232
240
  type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>) => TR;
233
241
  type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
242
+ interface EdgeRender<TD extends IRecord = any, TR = any> {
243
+ renderer: EdgeRenderType<TD, TR>;
244
+ config: EdgeConfig;
245
+ }
234
246
  declare enum Layer {
235
247
  Canvas = 0,
236
248
  Background = 4,
@@ -317,4 +329,4 @@ interface IEngineRuntime {
317
329
  };
318
330
  }
319
331
 
320
- 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 };
332
+ export { type CallToolMethod as A, InteractionPriority as B, type Container as C, type Interaction as D, Engine as E, InteractionManager as F, BasePlugin as G, 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 EdgeConfig as e, type EdgeProps as f, type NodeRenderType as g, type EdgeRenderType as h, type EdgeRender as i, type LayerComponent as j, type IPlugin as k, type Plugin as l, type PluginConfigs as m, type PluginData as n, type PluginTools as o, type EngineTools as p, type IPluginInfo as q, type IToolInfo as r, type NodeOperationPipe as s, type EdgeOperationPipe as t, type NodeOperation as u, type EdgeOperation as v, type NodeOperatorFunction as w, type EdgeOperatorFunction as x, type IEngineRuntime as y, type EngineOptions as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knotx/core",
3
- "version": "0.3.8",
3
+ "version": "0.4.0",
4
4
  "description": "Core for Knotx",
5
5
  "author": "boenfu",
6
6
  "license": "MIT",
@@ -43,17 +43,17 @@
43
43
  "dist"
44
44
  ],
45
45
  "dependencies": {
46
- "jsonschema": "~1.4.1",
46
+ "jsonschema": "^1.5.0",
47
47
  "lodash-es": "^4.17.21",
48
48
  "rxjs": "^7.8.1",
49
- "@knotx/data": "0.3.8",
50
- "@knotx/utils": "0.3.8"
49
+ "@knotx/data": "0.4.0",
50
+ "@knotx/utils": "0.4.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/lodash-es": "^4.17.12",
54
- "@knotx/build-config": "0.3.8",
55
- "@knotx/eslint-config": "0.3.8",
56
- "@knotx/typescript-config": "0.3.8"
54
+ "@knotx/build-config": "0.4.0",
55
+ "@knotx/eslint-config": "0.4.0",
56
+ "@knotx/typescript-config": "0.4.0"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "unbuild",