@knotx/core 0.2.4 → 0.2.6
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.cjs +0 -14
- package/dist/definition.d.cts +4 -113
- package/dist/definition.d.mts +4 -113
- package/dist/definition.d.ts +4 -113
- package/dist/definition.js +1 -14
- package/dist/index.cjs +132 -26
- package/dist/index.d.cts +25 -10
- package/dist/index.d.mts +25 -10
- package/dist/index.d.ts +25 -10
- package/dist/index.js +133 -27
- package/dist/shared/core.BUBec6Va.d.cts +145 -0
- package/dist/shared/core.BUBec6Va.d.mts +145 -0
- package/dist/shared/core.BUBec6Va.d.ts +145 -0
- package/package.json +7 -6
package/dist/definition.cjs
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
|
|
6
3
|
var Layer = /* @__PURE__ */ ((Layer2) => {
|
|
7
4
|
Layer2[Layer2["Canvas"] = 0] = "Canvas";
|
|
8
5
|
Layer2[Layer2["Background"] = 4] = "Background";
|
|
@@ -11,16 +8,5 @@ var Layer = /* @__PURE__ */ ((Layer2) => {
|
|
|
11
8
|
Layer2[Layer2["Foreground"] = 256] = "Foreground";
|
|
12
9
|
return Layer2;
|
|
13
10
|
})(Layer || {});
|
|
14
|
-
const _BasePlugin = class _BasePlugin {
|
|
15
|
-
constructor(__) {
|
|
16
|
-
__publicField(this, "_instanceId", _BasePlugin._instanceId++);
|
|
17
|
-
}
|
|
18
|
-
get pluginId() {
|
|
19
|
-
return `${this.name}:${this._instanceId}`;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
__publicField(_BasePlugin, "_instanceId", 0);
|
|
23
|
-
let BasePlugin = _BasePlugin;
|
|
24
11
|
|
|
25
|
-
exports.BasePlugin = BasePlugin;
|
|
26
12
|
exports.Layer = Layer;
|
package/dist/definition.d.cts
CHANGED
|
@@ -1,113 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type VerticalAlignment = 'top' | 'bottom';
|
|
6
|
-
interface NodePosition {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
}
|
|
10
|
-
interface NodeMeasured {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
}
|
|
14
|
-
interface NodeData<TData = any> {
|
|
15
|
-
id: string;
|
|
16
|
-
type?: string;
|
|
17
|
-
position: NodePosition;
|
|
18
|
-
measured?: NodeMeasured;
|
|
19
|
-
data: TData;
|
|
20
|
-
}
|
|
21
|
-
interface NodeProps<T = any> {
|
|
22
|
-
node: NodeData<T>;
|
|
23
|
-
}
|
|
24
|
-
interface EdgeData<TData = any> {
|
|
25
|
-
id: string;
|
|
26
|
-
source: string;
|
|
27
|
-
target: string;
|
|
28
|
-
type?: string;
|
|
29
|
-
data?: TData;
|
|
30
|
-
}
|
|
31
|
-
interface EdgeProps<T = any> {
|
|
32
|
-
edge: EdgeData<T>;
|
|
33
|
-
sourceX: number;
|
|
34
|
-
sourceY: number;
|
|
35
|
-
targetX: number;
|
|
36
|
-
targetY: number;
|
|
37
|
-
}
|
|
38
|
-
interface Container {
|
|
39
|
-
width: number;
|
|
40
|
-
height: number;
|
|
41
|
-
}
|
|
42
|
-
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
43
|
-
type RenderType = (...args: any[]) => any;
|
|
44
|
-
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
45
|
-
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
46
|
-
declare enum Layer {
|
|
47
|
-
Canvas = 0,
|
|
48
|
-
Background = 4,
|
|
49
|
-
Edges = 16,
|
|
50
|
-
Nodes = 64,
|
|
51
|
-
Foreground = 256
|
|
52
|
-
}
|
|
53
|
-
interface LayerComponent<TRenderType> {
|
|
54
|
-
plugin: string;
|
|
55
|
-
name: string;
|
|
56
|
-
layer: Layer;
|
|
57
|
-
render: TRenderType;
|
|
58
|
-
/**
|
|
59
|
-
* 层级偏移量
|
|
60
|
-
* @default 0
|
|
61
|
-
* (layer >> 1, layer << 1]
|
|
62
|
-
*/
|
|
63
|
-
offset?: number;
|
|
64
|
-
}
|
|
65
|
-
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
66
|
-
name: TPluginName;
|
|
67
|
-
pluginId: string;
|
|
68
|
-
onInit?: (config: TPluginConfig) => void;
|
|
69
|
-
onConfigChange?: (config: TPluginConfig) => void;
|
|
70
|
-
onDestroy?: () => void;
|
|
71
|
-
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
72
|
-
}
|
|
73
|
-
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
74
|
-
abstract name: TPluginName;
|
|
75
|
-
constructor(__: TPluginConfig);
|
|
76
|
-
private static _instanceId;
|
|
77
|
-
private _instanceId;
|
|
78
|
-
get pluginId(): string;
|
|
79
|
-
}
|
|
80
|
-
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
81
|
-
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
82
|
-
[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;
|
|
83
|
-
} : {}));
|
|
84
|
-
/**
|
|
85
|
-
* plugin data host
|
|
86
|
-
* @example
|
|
87
|
-
* `declare module '@knotx/core' {
|
|
88
|
-
* interface PluginData {
|
|
89
|
-
* pluginName: {
|
|
90
|
-
* property: any
|
|
91
|
-
* }
|
|
92
|
-
* }
|
|
93
|
-
* }`
|
|
94
|
-
*/
|
|
95
|
-
interface PluginData {
|
|
96
|
-
}
|
|
97
|
-
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
98
|
-
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
99
|
-
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
100
|
-
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
101
|
-
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
102
|
-
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
103
|
-
interface IEngineRuntime {
|
|
104
|
-
render?: {
|
|
105
|
-
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
106
|
-
paths: string[];
|
|
107
|
-
selector?: (value: T, context?: any) => R;
|
|
108
|
-
context?: any;
|
|
109
|
-
}) => T | R;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export { BasePlugin, type Container, type EdgeData, type EdgeOperation, type EdgeOperationPipe, type EdgeOperatorFunction, type EdgeProps, type EdgeRenderType, type HorizontalAlignment, type IEngineRuntime, type IPlugin, Layer, type LayerComponent, type NodeData, type NodeMeasured, type NodeOperation, type NodeOperationPipe, type NodeOperatorFunction, type NodePosition, type NodeProps, type NodeRenderType, type Plugin, type PluginConfigs, type PluginData, type Position, type RenderType, type VerticalAlignment };
|
|
1
|
+
import 'jsonschema';
|
|
2
|
+
import 'rxjs';
|
|
3
|
+
export { C as Container, E as EdgeData, r as EdgeOperation, p as EdgeOperationPipe, t as EdgeOperatorFunction, l as EdgeProps, d as EdgeRenderType, H as HorizontalAlignment, I as IEngineRuntime, a as IPlugin, g as IPluginInfo, h as IPluginToolInfo, b as Layer, L as LayerComponent, N as NodeData, j as NodeMeasured, q as NodeOperation, o as NodeOperationPipe, s as NodeOperatorFunction, i as NodePosition, k as NodeProps, c as NodeRenderType, P as Plugin, n as PluginConfigs, e as PluginData, f as PluginTools, m as Position, R as RenderType, V as VerticalAlignment } from './shared/core.BUBec6Va.cjs';
|
|
4
|
+
import '@knotx/data';
|
package/dist/definition.d.mts
CHANGED
|
@@ -1,113 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type VerticalAlignment = 'top' | 'bottom';
|
|
6
|
-
interface NodePosition {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
}
|
|
10
|
-
interface NodeMeasured {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
}
|
|
14
|
-
interface NodeData<TData = any> {
|
|
15
|
-
id: string;
|
|
16
|
-
type?: string;
|
|
17
|
-
position: NodePosition;
|
|
18
|
-
measured?: NodeMeasured;
|
|
19
|
-
data: TData;
|
|
20
|
-
}
|
|
21
|
-
interface NodeProps<T = any> {
|
|
22
|
-
node: NodeData<T>;
|
|
23
|
-
}
|
|
24
|
-
interface EdgeData<TData = any> {
|
|
25
|
-
id: string;
|
|
26
|
-
source: string;
|
|
27
|
-
target: string;
|
|
28
|
-
type?: string;
|
|
29
|
-
data?: TData;
|
|
30
|
-
}
|
|
31
|
-
interface EdgeProps<T = any> {
|
|
32
|
-
edge: EdgeData<T>;
|
|
33
|
-
sourceX: number;
|
|
34
|
-
sourceY: number;
|
|
35
|
-
targetX: number;
|
|
36
|
-
targetY: number;
|
|
37
|
-
}
|
|
38
|
-
interface Container {
|
|
39
|
-
width: number;
|
|
40
|
-
height: number;
|
|
41
|
-
}
|
|
42
|
-
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
43
|
-
type RenderType = (...args: any[]) => any;
|
|
44
|
-
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
45
|
-
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
46
|
-
declare enum Layer {
|
|
47
|
-
Canvas = 0,
|
|
48
|
-
Background = 4,
|
|
49
|
-
Edges = 16,
|
|
50
|
-
Nodes = 64,
|
|
51
|
-
Foreground = 256
|
|
52
|
-
}
|
|
53
|
-
interface LayerComponent<TRenderType> {
|
|
54
|
-
plugin: string;
|
|
55
|
-
name: string;
|
|
56
|
-
layer: Layer;
|
|
57
|
-
render: TRenderType;
|
|
58
|
-
/**
|
|
59
|
-
* 层级偏移量
|
|
60
|
-
* @default 0
|
|
61
|
-
* (layer >> 1, layer << 1]
|
|
62
|
-
*/
|
|
63
|
-
offset?: number;
|
|
64
|
-
}
|
|
65
|
-
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
66
|
-
name: TPluginName;
|
|
67
|
-
pluginId: string;
|
|
68
|
-
onInit?: (config: TPluginConfig) => void;
|
|
69
|
-
onConfigChange?: (config: TPluginConfig) => void;
|
|
70
|
-
onDestroy?: () => void;
|
|
71
|
-
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
72
|
-
}
|
|
73
|
-
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
74
|
-
abstract name: TPluginName;
|
|
75
|
-
constructor(__: TPluginConfig);
|
|
76
|
-
private static _instanceId;
|
|
77
|
-
private _instanceId;
|
|
78
|
-
get pluginId(): string;
|
|
79
|
-
}
|
|
80
|
-
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
81
|
-
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
82
|
-
[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;
|
|
83
|
-
} : {}));
|
|
84
|
-
/**
|
|
85
|
-
* plugin data host
|
|
86
|
-
* @example
|
|
87
|
-
* `declare module '@knotx/core' {
|
|
88
|
-
* interface PluginData {
|
|
89
|
-
* pluginName: {
|
|
90
|
-
* property: any
|
|
91
|
-
* }
|
|
92
|
-
* }
|
|
93
|
-
* }`
|
|
94
|
-
*/
|
|
95
|
-
interface PluginData {
|
|
96
|
-
}
|
|
97
|
-
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
98
|
-
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
99
|
-
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
100
|
-
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
101
|
-
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
102
|
-
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
103
|
-
interface IEngineRuntime {
|
|
104
|
-
render?: {
|
|
105
|
-
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
106
|
-
paths: string[];
|
|
107
|
-
selector?: (value: T, context?: any) => R;
|
|
108
|
-
context?: any;
|
|
109
|
-
}) => T | R;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export { BasePlugin, type Container, type EdgeData, type EdgeOperation, type EdgeOperationPipe, type EdgeOperatorFunction, type EdgeProps, type EdgeRenderType, type HorizontalAlignment, type IEngineRuntime, type IPlugin, Layer, type LayerComponent, type NodeData, type NodeMeasured, type NodeOperation, type NodeOperationPipe, type NodeOperatorFunction, type NodePosition, type NodeProps, type NodeRenderType, type Plugin, type PluginConfigs, type PluginData, type Position, type RenderType, type VerticalAlignment };
|
|
1
|
+
import 'jsonschema';
|
|
2
|
+
import 'rxjs';
|
|
3
|
+
export { C as Container, E as EdgeData, r as EdgeOperation, p as EdgeOperationPipe, t as EdgeOperatorFunction, l as EdgeProps, d as EdgeRenderType, H as HorizontalAlignment, I as IEngineRuntime, a as IPlugin, g as IPluginInfo, h as IPluginToolInfo, b as Layer, L as LayerComponent, N as NodeData, j as NodeMeasured, q as NodeOperation, o as NodeOperationPipe, s as NodeOperatorFunction, i as NodePosition, k as NodeProps, c as NodeRenderType, P as Plugin, n as PluginConfigs, e as PluginData, f as PluginTools, m as Position, R as RenderType, V as VerticalAlignment } from './shared/core.BUBec6Va.mjs';
|
|
4
|
+
import '@knotx/data';
|
package/dist/definition.d.ts
CHANGED
|
@@ -1,113 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type VerticalAlignment = 'top' | 'bottom';
|
|
6
|
-
interface NodePosition {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
}
|
|
10
|
-
interface NodeMeasured {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
}
|
|
14
|
-
interface NodeData<TData = any> {
|
|
15
|
-
id: string;
|
|
16
|
-
type?: string;
|
|
17
|
-
position: NodePosition;
|
|
18
|
-
measured?: NodeMeasured;
|
|
19
|
-
data: TData;
|
|
20
|
-
}
|
|
21
|
-
interface NodeProps<T = any> {
|
|
22
|
-
node: NodeData<T>;
|
|
23
|
-
}
|
|
24
|
-
interface EdgeData<TData = any> {
|
|
25
|
-
id: string;
|
|
26
|
-
source: string;
|
|
27
|
-
target: string;
|
|
28
|
-
type?: string;
|
|
29
|
-
data?: TData;
|
|
30
|
-
}
|
|
31
|
-
interface EdgeProps<T = any> {
|
|
32
|
-
edge: EdgeData<T>;
|
|
33
|
-
sourceX: number;
|
|
34
|
-
sourceY: number;
|
|
35
|
-
targetX: number;
|
|
36
|
-
targetY: number;
|
|
37
|
-
}
|
|
38
|
-
interface Container {
|
|
39
|
-
width: number;
|
|
40
|
-
height: number;
|
|
41
|
-
}
|
|
42
|
-
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
43
|
-
type RenderType = (...args: any[]) => any;
|
|
44
|
-
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
45
|
-
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
46
|
-
declare enum Layer {
|
|
47
|
-
Canvas = 0,
|
|
48
|
-
Background = 4,
|
|
49
|
-
Edges = 16,
|
|
50
|
-
Nodes = 64,
|
|
51
|
-
Foreground = 256
|
|
52
|
-
}
|
|
53
|
-
interface LayerComponent<TRenderType> {
|
|
54
|
-
plugin: string;
|
|
55
|
-
name: string;
|
|
56
|
-
layer: Layer;
|
|
57
|
-
render: TRenderType;
|
|
58
|
-
/**
|
|
59
|
-
* 层级偏移量
|
|
60
|
-
* @default 0
|
|
61
|
-
* (layer >> 1, layer << 1]
|
|
62
|
-
*/
|
|
63
|
-
offset?: number;
|
|
64
|
-
}
|
|
65
|
-
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
66
|
-
name: TPluginName;
|
|
67
|
-
pluginId: string;
|
|
68
|
-
onInit?: (config: TPluginConfig) => void;
|
|
69
|
-
onConfigChange?: (config: TPluginConfig) => void;
|
|
70
|
-
onDestroy?: () => void;
|
|
71
|
-
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
72
|
-
}
|
|
73
|
-
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
74
|
-
abstract name: TPluginName;
|
|
75
|
-
constructor(__: TPluginConfig);
|
|
76
|
-
private static _instanceId;
|
|
77
|
-
private _instanceId;
|
|
78
|
-
get pluginId(): string;
|
|
79
|
-
}
|
|
80
|
-
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
81
|
-
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
82
|
-
[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;
|
|
83
|
-
} : {}));
|
|
84
|
-
/**
|
|
85
|
-
* plugin data host
|
|
86
|
-
* @example
|
|
87
|
-
* `declare module '@knotx/core' {
|
|
88
|
-
* interface PluginData {
|
|
89
|
-
* pluginName: {
|
|
90
|
-
* property: any
|
|
91
|
-
* }
|
|
92
|
-
* }
|
|
93
|
-
* }`
|
|
94
|
-
*/
|
|
95
|
-
interface PluginData {
|
|
96
|
-
}
|
|
97
|
-
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
98
|
-
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
99
|
-
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
100
|
-
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
101
|
-
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
102
|
-
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
103
|
-
interface IEngineRuntime {
|
|
104
|
-
render?: {
|
|
105
|
-
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
106
|
-
paths: string[];
|
|
107
|
-
selector?: (value: T, context?: any) => R;
|
|
108
|
-
context?: any;
|
|
109
|
-
}) => T | R;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export { BasePlugin, type Container, type EdgeData, type EdgeOperation, type EdgeOperationPipe, type EdgeOperatorFunction, type EdgeProps, type EdgeRenderType, type HorizontalAlignment, type IEngineRuntime, type IPlugin, Layer, type LayerComponent, type NodeData, type NodeMeasured, type NodeOperation, type NodeOperationPipe, type NodeOperatorFunction, type NodePosition, type NodeProps, type NodeRenderType, type Plugin, type PluginConfigs, type PluginData, type Position, type RenderType, type VerticalAlignment };
|
|
1
|
+
import 'jsonschema';
|
|
2
|
+
import 'rxjs';
|
|
3
|
+
export { C as Container, E as EdgeData, r as EdgeOperation, p as EdgeOperationPipe, t as EdgeOperatorFunction, l as EdgeProps, d as EdgeRenderType, H as HorizontalAlignment, I as IEngineRuntime, a as IPlugin, g as IPluginInfo, h as IPluginToolInfo, b as Layer, L as LayerComponent, N as NodeData, j as NodeMeasured, q as NodeOperation, o as NodeOperationPipe, s as NodeOperatorFunction, i as NodePosition, k as NodeProps, c as NodeRenderType, P as Plugin, n as PluginConfigs, e as PluginData, f as PluginTools, m as Position, R as RenderType, V as VerticalAlignment } from './shared/core.BUBec6Va.js';
|
|
4
|
+
import '@knotx/data';
|
package/dist/definition.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
|
|
4
1
|
var Layer = /* @__PURE__ */ ((Layer2) => {
|
|
5
2
|
Layer2[Layer2["Canvas"] = 0] = "Canvas";
|
|
6
3
|
Layer2[Layer2["Background"] = 4] = "Background";
|
|
@@ -9,15 +6,5 @@ var Layer = /* @__PURE__ */ ((Layer2) => {
|
|
|
9
6
|
Layer2[Layer2["Foreground"] = 256] = "Foreground";
|
|
10
7
|
return Layer2;
|
|
11
8
|
})(Layer || {});
|
|
12
|
-
const _BasePlugin = class _BasePlugin {
|
|
13
|
-
constructor(__) {
|
|
14
|
-
__publicField(this, "_instanceId", _BasePlugin._instanceId++);
|
|
15
|
-
}
|
|
16
|
-
get pluginId() {
|
|
17
|
-
return `${this.name}:${this._instanceId}`;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
__publicField(_BasePlugin, "_instanceId", 0);
|
|
21
|
-
let BasePlugin = _BasePlugin;
|
|
22
9
|
|
|
23
|
-
export {
|
|
10
|
+
export { Layer };
|
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const definition = require('./definition.cjs');
|
|
4
|
+
const jsonschema = require('jsonschema');
|
|
4
5
|
const lodashEs = require('lodash-es');
|
|
5
6
|
const rxjs = require('rxjs');
|
|
6
7
|
const core = require('@knotx/core');
|
|
7
8
|
const utils = require('@knotx/utils');
|
|
8
9
|
const data = require('@knotx/data');
|
|
9
10
|
|
|
10
|
-
var __defProp$
|
|
11
|
-
var __defNormalProp$
|
|
12
|
-
var __publicField$
|
|
11
|
+
var __defProp$4 = Object.defineProperty;
|
|
12
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
|
13
14
|
var InteractionPriority = /* @__PURE__ */ ((InteractionPriority2) => {
|
|
14
15
|
InteractionPriority2[InteractionPriority2["InputActive"] = 2e3] = "InputActive";
|
|
15
16
|
InteractionPriority2[InteractionPriority2["EntityConnectDrag"] = 1930] = "EntityConnectDrag";
|
|
@@ -31,7 +32,7 @@ var InteractionPriority = /* @__PURE__ */ ((InteractionPriority2) => {
|
|
|
31
32
|
})(InteractionPriority || {});
|
|
32
33
|
class InteractionManager {
|
|
33
34
|
constructor() {
|
|
34
|
-
__publicField$
|
|
35
|
+
__publicField$3(this, "interactions", /* @__PURE__ */ new Map());
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* 获取当前活动的交互
|
|
@@ -90,19 +91,19 @@ class InteractionManager {
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
var __defProp$
|
|
94
|
+
var __defProp$3 = Object.defineProperty;
|
|
94
95
|
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
95
96
|
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
96
97
|
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
97
|
-
var __defNormalProp$
|
|
98
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
98
99
|
var __spreadValues$1 = (a, b) => {
|
|
99
100
|
for (var prop in b || (b = {}))
|
|
100
101
|
if (__hasOwnProp$1.call(b, prop))
|
|
101
|
-
__defNormalProp$
|
|
102
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
102
103
|
if (__getOwnPropSymbols$1)
|
|
103
104
|
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
104
105
|
if (__propIsEnum$1.call(b, prop))
|
|
105
|
-
__defNormalProp$
|
|
106
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
106
107
|
}
|
|
107
108
|
return a;
|
|
108
109
|
};
|
|
@@ -131,23 +132,25 @@ function getLayerRenders(plugin) {
|
|
|
131
132
|
return components;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
var __defProp$
|
|
135
|
-
var __defNormalProp$
|
|
136
|
-
var __publicField$
|
|
135
|
+
var __defProp$2 = Object.defineProperty;
|
|
136
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
137
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
137
138
|
class Engine {
|
|
138
139
|
constructor(options) {
|
|
139
|
-
__publicField$
|
|
140
|
-
__publicField$
|
|
141
|
-
__publicField$
|
|
142
|
-
__publicField$
|
|
143
|
-
__publicField$
|
|
144
|
-
__publicField$
|
|
145
|
-
__publicField$
|
|
146
|
-
__publicField$
|
|
147
|
-
__publicField$
|
|
148
|
-
__publicField$
|
|
149
|
-
__publicField$
|
|
150
|
-
__publicField$
|
|
140
|
+
__publicField$2(this, "runtime");
|
|
141
|
+
__publicField$2(this, "interactionManager", new InteractionManager());
|
|
142
|
+
__publicField$2(this, "nodesManager");
|
|
143
|
+
__publicField$2(this, "edgesManager");
|
|
144
|
+
__publicField$2(this, "container$", new rxjs.BehaviorSubject(null));
|
|
145
|
+
__publicField$2(this, "nodes$", new rxjs.BehaviorSubject([]));
|
|
146
|
+
__publicField$2(this, "edges$", new rxjs.BehaviorSubject([]));
|
|
147
|
+
__publicField$2(this, "layers$", new rxjs.BehaviorSubject(/* @__PURE__ */ new Map()));
|
|
148
|
+
__publicField$2(this, "plugins$", new rxjs.BehaviorSubject([]));
|
|
149
|
+
__publicField$2(this, "nodeRenderers$", new rxjs.BehaviorSubject(/* @__PURE__ */ new Map()));
|
|
150
|
+
__publicField$2(this, "edgeRenderers$", new rxjs.BehaviorSubject(/* @__PURE__ */ new Map()));
|
|
151
|
+
__publicField$2(this, "_pluginDataContainer", {});
|
|
152
|
+
__publicField$2(this, "toolParamsValidator", new jsonschema.Validator());
|
|
153
|
+
__publicField$2(this, "_pluginToolsContainer", {});
|
|
151
154
|
var _a;
|
|
152
155
|
this.runtime = (_a = options.runtime) != null ? _a : {};
|
|
153
156
|
this.container$.next(options.container);
|
|
@@ -184,6 +187,7 @@ class Engine {
|
|
|
184
187
|
continue;
|
|
185
188
|
}
|
|
186
189
|
this._pluginDataContainer[plugin.name] = {};
|
|
190
|
+
this._pluginToolsContainer[plugin.name] = {};
|
|
187
191
|
const engineSymbol = utils.getSymbol("engine");
|
|
188
192
|
if (!Reflect.has(plugin, engineSymbol)) {
|
|
189
193
|
Reflect.set(plugin, engineSymbol, new rxjs.BehaviorSubject(null));
|
|
@@ -216,10 +220,10 @@ class Engine {
|
|
|
216
220
|
return this.layers$.value.get(layer) || [];
|
|
217
221
|
}
|
|
218
222
|
addNodePipe(pipe) {
|
|
219
|
-
this.nodesManager.addDataOperationPipe(pipe);
|
|
223
|
+
return this.nodesManager.addDataOperationPipe(pipe);
|
|
220
224
|
}
|
|
221
225
|
addEdgePipe(pipe) {
|
|
222
|
-
this.edgesManager.addDataOperationPipe(pipe);
|
|
226
|
+
return this.edgesManager.addDataOperationPipe(pipe);
|
|
223
227
|
}
|
|
224
228
|
changePluginConfig(pluginName, config) {
|
|
225
229
|
var _a, _b;
|
|
@@ -258,15 +262,34 @@ class Engine {
|
|
|
258
262
|
registerPluginData(pluginName, property, data) {
|
|
259
263
|
lodashEs.set(this, ["_pluginDataContainer", pluginName, property], data);
|
|
260
264
|
}
|
|
265
|
+
resetPluginData(pluginName) {
|
|
266
|
+
lodashEs.set(this, ["_pluginDataContainer", pluginName], void 0);
|
|
267
|
+
}
|
|
268
|
+
registerPluginTool(pluginName, property, data) {
|
|
269
|
+
lodashEs.set(this, ["_pluginToolsContainer", pluginName, property], data);
|
|
270
|
+
}
|
|
271
|
+
resetPluginTool(pluginName) {
|
|
272
|
+
lodashEs.set(this, ["_pluginToolsContainer", pluginName], void 0);
|
|
273
|
+
}
|
|
261
274
|
registerNodeRenderer(type, renderer) {
|
|
262
275
|
const nodeRenderers = this.nodeRenderers$.value;
|
|
263
276
|
nodeRenderers.set(type, renderer);
|
|
264
277
|
this.nodeRenderers$.next(nodeRenderers);
|
|
278
|
+
return () => {
|
|
279
|
+
const nodeRenderers2 = this.nodeRenderers$.value;
|
|
280
|
+
nodeRenderers2.delete(type);
|
|
281
|
+
this.nodeRenderers$.next(nodeRenderers2);
|
|
282
|
+
};
|
|
265
283
|
}
|
|
266
284
|
registerEdgeRenderer(type, renderer) {
|
|
267
285
|
const edgeRenderers = this.edgeRenderers$.value;
|
|
268
286
|
edgeRenderers.set(type, renderer);
|
|
269
287
|
this.edgeRenderers$.next(edgeRenderers);
|
|
288
|
+
return () => {
|
|
289
|
+
const edgeRenderers2 = this.edgeRenderers$.value;
|
|
290
|
+
edgeRenderers2.delete(type);
|
|
291
|
+
this.edgeRenderers$.next(edgeRenderers2);
|
|
292
|
+
};
|
|
270
293
|
}
|
|
271
294
|
canInteract(pluginId, type, autoStartPriority) {
|
|
272
295
|
return this.interactionManager.canInteract(pluginId, type, autoStartPriority);
|
|
@@ -277,6 +300,54 @@ class Engine {
|
|
|
277
300
|
endInteraction(pluginId, type) {
|
|
278
301
|
this.interactionManager.endInteraction(pluginId, type);
|
|
279
302
|
}
|
|
303
|
+
callTool(pluginName, toolName, params) {
|
|
304
|
+
const toolDefinition = lodashEs.get(this, ["_pluginToolsContainer", pluginName, toolName]);
|
|
305
|
+
const tool = toolDefinition == null ? void 0 : toolDefinition.func;
|
|
306
|
+
if (!tool || typeof tool !== "function") {
|
|
307
|
+
throw new Error(`Tool ${String(toolName)} not found in plugin ${pluginName}`);
|
|
308
|
+
}
|
|
309
|
+
const validator = this.toolParamsValidator.validate(params, toolDefinition.params);
|
|
310
|
+
if (validator.errors.length > 0) {
|
|
311
|
+
throw new Error(`Invalid tool params: ${validator.errors.map((e) => e.stack).join(", ")}`);
|
|
312
|
+
}
|
|
313
|
+
return tool(params);
|
|
314
|
+
}
|
|
315
|
+
listPlugins() {
|
|
316
|
+
return this.plugins$.value.map((plugin) => ({
|
|
317
|
+
name: plugin.name,
|
|
318
|
+
description: plugin.description
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
listPluginTools(pluginName) {
|
|
322
|
+
return Object.entries(lodashEs.get(this, ["_pluginToolsContainer", pluginName]) || {}).map(([toolName, toolDefinition]) => ({
|
|
323
|
+
type: "function",
|
|
324
|
+
name: toolName,
|
|
325
|
+
description: toolDefinition.description,
|
|
326
|
+
parameters: toolDefinition.params
|
|
327
|
+
}));
|
|
328
|
+
}
|
|
329
|
+
listEngineTools() {
|
|
330
|
+
return [
|
|
331
|
+
{
|
|
332
|
+
type: "function",
|
|
333
|
+
name: "listPlugins",
|
|
334
|
+
description: "List all plugins",
|
|
335
|
+
parameters: {}
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
type: "function",
|
|
339
|
+
name: "listPluginTools",
|
|
340
|
+
description: "List all tools of a plugin",
|
|
341
|
+
parameters: {
|
|
342
|
+
type: "object",
|
|
343
|
+
properties: {
|
|
344
|
+
pluginName: { type: "string" }
|
|
345
|
+
},
|
|
346
|
+
required: ["pluginName"]
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
];
|
|
350
|
+
}
|
|
280
351
|
destroy() {
|
|
281
352
|
this.plugins$.value.forEach((plugin) => {
|
|
282
353
|
var _a;
|
|
@@ -289,9 +360,44 @@ class Engine {
|
|
|
289
360
|
this.edges$.complete();
|
|
290
361
|
this.nodeRenderers$.complete();
|
|
291
362
|
this.edgeRenderers$.complete();
|
|
363
|
+
this._pluginToolsContainer = {};
|
|
364
|
+
this._pluginDataContainer = {};
|
|
292
365
|
}
|
|
293
366
|
}
|
|
294
367
|
|
|
368
|
+
var __defProp$1 = Object.defineProperty;
|
|
369
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
370
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
371
|
+
const _BasePlugin = class _BasePlugin {
|
|
372
|
+
constructor(__) {
|
|
373
|
+
__publicField$1(this, "_instanceId", _BasePlugin._instanceId++);
|
|
374
|
+
/**
|
|
375
|
+
* 插件生命周期中的订阅回调
|
|
376
|
+
* 可随时存入,销毁时会自动执行
|
|
377
|
+
*/
|
|
378
|
+
__publicField$1(this, "subscriptions", []);
|
|
379
|
+
Reflect.set(this, utils.getSymbol("engine"), new rxjs.BehaviorSubject(null));
|
|
380
|
+
}
|
|
381
|
+
get pluginId() {
|
|
382
|
+
return `${this.name}:${this._instanceId}`;
|
|
383
|
+
}
|
|
384
|
+
onDestroy() {
|
|
385
|
+
this.subscriptions.forEach((subscription) => {
|
|
386
|
+
if (typeof subscription === "function") {
|
|
387
|
+
subscription();
|
|
388
|
+
} else {
|
|
389
|
+
subscription.unsubscribe();
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
const engin$ = Reflect.get(this, utils.getSymbol("engine"));
|
|
393
|
+
engin$.value.resetPluginData(this.name);
|
|
394
|
+
engin$.value.resetPluginTool(this.name);
|
|
395
|
+
engin$.complete();
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
__publicField$1(_BasePlugin, "_instanceId", 0);
|
|
399
|
+
let BasePlugin = _BasePlugin;
|
|
400
|
+
|
|
295
401
|
var __defProp = Object.defineProperty;
|
|
296
402
|
var __defProps = Object.defineProperties;
|
|
297
403
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -370,8 +476,8 @@ function use(hook, context) {
|
|
|
370
476
|
return Runtime.getInstance().runInContext("render", hook, context);
|
|
371
477
|
}
|
|
372
478
|
|
|
373
|
-
exports.BasePlugin = definition.BasePlugin;
|
|
374
479
|
exports.Layer = definition.Layer;
|
|
480
|
+
exports.BasePlugin = BasePlugin;
|
|
375
481
|
exports.Engine = Engine;
|
|
376
482
|
exports.InteractionManager = InteractionManager;
|
|
377
483
|
exports.InteractionPriority = InteractionPriority;
|