@knotx/core 0.2.4 → 0.2.5
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 +3 -113
- package/dist/definition.d.mts +3 -113
- package/dist/definition.d.ts +3 -113
- package/dist/definition.js +1 -14
- package/dist/index.cjs +67 -26
- package/dist/index.d.cts +11 -10
- package/dist/index.d.mts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.js +68 -27
- package/dist/shared/core.BKaZlwmj.d.cts +120 -0
- package/dist/shared/core.BKaZlwmj.d.mts +120 -0
- package/dist/shared/core.BKaZlwmj.d.ts +120 -0
- package/package.json +6 -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,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type HorizontalAlignment = 'left' | 'right';
|
|
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 'rxjs';
|
|
2
|
+
export { C as Container, E as EdgeData, o as EdgeOperation, m as EdgeOperationPipe, q as EdgeOperatorFunction, i as EdgeProps, d as EdgeRenderType, H as HorizontalAlignment, I as IEngineRuntime, a as IPlugin, b as Layer, L as LayerComponent, N as NodeData, g as NodeMeasured, n as NodeOperation, l as NodeOperationPipe, p as NodeOperatorFunction, f as NodePosition, h as NodeProps, c as NodeRenderType, P as Plugin, k as PluginConfigs, e as PluginData, j as Position, R as RenderType, V as VerticalAlignment } from './shared/core.BKaZlwmj.cjs';
|
|
3
|
+
import '@knotx/data';
|
package/dist/definition.d.mts
CHANGED
|
@@ -1,113 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type HorizontalAlignment = 'left' | 'right';
|
|
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 'rxjs';
|
|
2
|
+
export { C as Container, E as EdgeData, o as EdgeOperation, m as EdgeOperationPipe, q as EdgeOperatorFunction, i as EdgeProps, d as EdgeRenderType, H as HorizontalAlignment, I as IEngineRuntime, a as IPlugin, b as Layer, L as LayerComponent, N as NodeData, g as NodeMeasured, n as NodeOperation, l as NodeOperationPipe, p as NodeOperatorFunction, f as NodePosition, h as NodeProps, c as NodeRenderType, P as Plugin, k as PluginConfigs, e as PluginData, j as Position, R as RenderType, V as VerticalAlignment } from './shared/core.BKaZlwmj.mjs';
|
|
3
|
+
import '@knotx/data';
|
package/dist/definition.d.ts
CHANGED
|
@@ -1,113 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type HorizontalAlignment = 'left' | 'right';
|
|
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 'rxjs';
|
|
2
|
+
export { C as Container, E as EdgeData, o as EdgeOperation, m as EdgeOperationPipe, q as EdgeOperatorFunction, i as EdgeProps, d as EdgeRenderType, H as HorizontalAlignment, I as IEngineRuntime, a as IPlugin, b as Layer, L as LayerComponent, N as NodeData, g as NodeMeasured, n as NodeOperation, l as NodeOperationPipe, p as NodeOperatorFunction, f as NodePosition, h as NodeProps, c as NodeRenderType, P as Plugin, k as PluginConfigs, e as PluginData, j as Position, R as RenderType, V as VerticalAlignment } from './shared/core.BKaZlwmj.js';
|
|
3
|
+
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
|
@@ -7,9 +7,9 @@ const core = require('@knotx/core');
|
|
|
7
7
|
const utils = require('@knotx/utils');
|
|
8
8
|
const data = require('@knotx/data');
|
|
9
9
|
|
|
10
|
-
var __defProp$
|
|
11
|
-
var __defNormalProp$
|
|
12
|
-
var __publicField$
|
|
10
|
+
var __defProp$4 = Object.defineProperty;
|
|
11
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
|
13
13
|
var InteractionPriority = /* @__PURE__ */ ((InteractionPriority2) => {
|
|
14
14
|
InteractionPriority2[InteractionPriority2["InputActive"] = 2e3] = "InputActive";
|
|
15
15
|
InteractionPriority2[InteractionPriority2["EntityConnectDrag"] = 1930] = "EntityConnectDrag";
|
|
@@ -31,7 +31,7 @@ var InteractionPriority = /* @__PURE__ */ ((InteractionPriority2) => {
|
|
|
31
31
|
})(InteractionPriority || {});
|
|
32
32
|
class InteractionManager {
|
|
33
33
|
constructor() {
|
|
34
|
-
__publicField$
|
|
34
|
+
__publicField$3(this, "interactions", /* @__PURE__ */ new Map());
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* 获取当前活动的交互
|
|
@@ -90,19 +90,19 @@ class InteractionManager {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
var __defProp$
|
|
93
|
+
var __defProp$3 = Object.defineProperty;
|
|
94
94
|
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
95
95
|
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
96
96
|
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
97
|
-
var __defNormalProp$
|
|
97
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
98
98
|
var __spreadValues$1 = (a, b) => {
|
|
99
99
|
for (var prop in b || (b = {}))
|
|
100
100
|
if (__hasOwnProp$1.call(b, prop))
|
|
101
|
-
__defNormalProp$
|
|
101
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
102
102
|
if (__getOwnPropSymbols$1)
|
|
103
103
|
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
104
104
|
if (__propIsEnum$1.call(b, prop))
|
|
105
|
-
__defNormalProp$
|
|
105
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
106
106
|
}
|
|
107
107
|
return a;
|
|
108
108
|
};
|
|
@@ -131,23 +131,23 @@ function getLayerRenders(plugin) {
|
|
|
131
131
|
return components;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
var __defProp$
|
|
135
|
-
var __defNormalProp$
|
|
136
|
-
var __publicField$
|
|
134
|
+
var __defProp$2 = Object.defineProperty;
|
|
135
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
136
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
137
137
|
class Engine {
|
|
138
138
|
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$
|
|
139
|
+
__publicField$2(this, "runtime");
|
|
140
|
+
__publicField$2(this, "interactionManager", new InteractionManager());
|
|
141
|
+
__publicField$2(this, "nodesManager");
|
|
142
|
+
__publicField$2(this, "edgesManager");
|
|
143
|
+
__publicField$2(this, "container$", new rxjs.BehaviorSubject(null));
|
|
144
|
+
__publicField$2(this, "nodes$", new rxjs.BehaviorSubject([]));
|
|
145
|
+
__publicField$2(this, "edges$", new rxjs.BehaviorSubject([]));
|
|
146
|
+
__publicField$2(this, "layers$", new rxjs.BehaviorSubject(/* @__PURE__ */ new Map()));
|
|
147
|
+
__publicField$2(this, "plugins$", new rxjs.BehaviorSubject([]));
|
|
148
|
+
__publicField$2(this, "nodeRenderers$", new rxjs.BehaviorSubject(/* @__PURE__ */ new Map()));
|
|
149
|
+
__publicField$2(this, "edgeRenderers$", new rxjs.BehaviorSubject(/* @__PURE__ */ new Map()));
|
|
150
|
+
__publicField$2(this, "_pluginDataContainer", {});
|
|
151
151
|
var _a;
|
|
152
152
|
this.runtime = (_a = options.runtime) != null ? _a : {};
|
|
153
153
|
this.container$.next(options.container);
|
|
@@ -216,10 +216,10 @@ class Engine {
|
|
|
216
216
|
return this.layers$.value.get(layer) || [];
|
|
217
217
|
}
|
|
218
218
|
addNodePipe(pipe) {
|
|
219
|
-
this.nodesManager.addDataOperationPipe(pipe);
|
|
219
|
+
return this.nodesManager.addDataOperationPipe(pipe);
|
|
220
220
|
}
|
|
221
221
|
addEdgePipe(pipe) {
|
|
222
|
-
this.edgesManager.addDataOperationPipe(pipe);
|
|
222
|
+
return this.edgesManager.addDataOperationPipe(pipe);
|
|
223
223
|
}
|
|
224
224
|
changePluginConfig(pluginName, config) {
|
|
225
225
|
var _a, _b;
|
|
@@ -262,11 +262,21 @@ class Engine {
|
|
|
262
262
|
const nodeRenderers = this.nodeRenderers$.value;
|
|
263
263
|
nodeRenderers.set(type, renderer);
|
|
264
264
|
this.nodeRenderers$.next(nodeRenderers);
|
|
265
|
+
return () => {
|
|
266
|
+
const nodeRenderers2 = this.nodeRenderers$.value;
|
|
267
|
+
nodeRenderers2.delete(type);
|
|
268
|
+
this.nodeRenderers$.next(nodeRenderers2);
|
|
269
|
+
};
|
|
265
270
|
}
|
|
266
271
|
registerEdgeRenderer(type, renderer) {
|
|
267
272
|
const edgeRenderers = this.edgeRenderers$.value;
|
|
268
273
|
edgeRenderers.set(type, renderer);
|
|
269
274
|
this.edgeRenderers$.next(edgeRenderers);
|
|
275
|
+
return () => {
|
|
276
|
+
const edgeRenderers2 = this.edgeRenderers$.value;
|
|
277
|
+
edgeRenderers2.delete(type);
|
|
278
|
+
this.edgeRenderers$.next(edgeRenderers2);
|
|
279
|
+
};
|
|
270
280
|
}
|
|
271
281
|
canInteract(pluginId, type, autoStartPriority) {
|
|
272
282
|
return this.interactionManager.canInteract(pluginId, type, autoStartPriority);
|
|
@@ -292,6 +302,37 @@ class Engine {
|
|
|
292
302
|
}
|
|
293
303
|
}
|
|
294
304
|
|
|
305
|
+
var __defProp$1 = Object.defineProperty;
|
|
306
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
307
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
308
|
+
const _BasePlugin = class _BasePlugin {
|
|
309
|
+
constructor(__) {
|
|
310
|
+
__publicField$1(this, "_instanceId", _BasePlugin._instanceId++);
|
|
311
|
+
/**
|
|
312
|
+
* 插件生命周期中的订阅回调
|
|
313
|
+
* 可随时存入,销毁时会自动执行
|
|
314
|
+
*/
|
|
315
|
+
__publicField$1(this, "subscriptions", []);
|
|
316
|
+
Reflect.set(this, utils.getSymbol("engine"), new rxjs.BehaviorSubject(null));
|
|
317
|
+
}
|
|
318
|
+
get pluginId() {
|
|
319
|
+
return `${this.name}:${this._instanceId}`;
|
|
320
|
+
}
|
|
321
|
+
onDestroy() {
|
|
322
|
+
var _a;
|
|
323
|
+
this.subscriptions.forEach((subscription) => {
|
|
324
|
+
if (typeof subscription === "function") {
|
|
325
|
+
subscription();
|
|
326
|
+
} else {
|
|
327
|
+
subscription.unsubscribe();
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
(_a = Reflect.get(this, utils.getSymbol("engine"))) == null ? void 0 : _a.complete();
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
__publicField$1(_BasePlugin, "_instanceId", 0);
|
|
334
|
+
let BasePlugin = _BasePlugin;
|
|
335
|
+
|
|
295
336
|
var __defProp = Object.defineProperty;
|
|
296
337
|
var __defProps = Object.defineProperties;
|
|
297
338
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -370,8 +411,8 @@ function use(hook, context) {
|
|
|
370
411
|
return Runtime.getInstance().runInContext("render", hook, context);
|
|
371
412
|
}
|
|
372
413
|
|
|
373
|
-
exports.BasePlugin = definition.BasePlugin;
|
|
374
414
|
exports.Layer = definition.Layer;
|
|
415
|
+
exports.BasePlugin = BasePlugin;
|
|
375
416
|
exports.Engine = Engine;
|
|
376
417
|
exports.InteractionManager = InteractionManager;
|
|
377
418
|
exports.InteractionPriority = InteractionPriority;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { C as Container, P as Plugin, N as NodeData, E as EdgeData, I as IEngineRuntime, R as RenderType, L as LayerComponent, a as IPlugin, b as Layer, c as NodeRenderType, d as EdgeRenderType, e as PluginData } from './shared/core.BKaZlwmj.cjs';
|
|
2
|
+
export { B as BasePlugin, o as EdgeOperation, m as EdgeOperationPipe, q as EdgeOperatorFunction, i as EdgeProps, H as HorizontalAlignment, g as NodeMeasured, n as NodeOperation, l as NodeOperationPipe, p as NodeOperatorFunction, f as NodePosition, h as NodeProps, k as PluginConfigs, j as Position, V as VerticalAlignment } from './shared/core.BKaZlwmj.cjs';
|
|
3
3
|
import { BehaviorSubject } from 'rxjs';
|
|
4
4
|
import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
|
|
5
5
|
export * from '@knotx/data';
|
|
6
|
+
import { RenderType as RenderType$1, IPlugin as IPlugin$1, LayerComponent as LayerComponent$1 } from '@knotx/core';
|
|
6
7
|
export * from '@knotx/utils';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -114,8 +115,8 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
|
|
|
114
115
|
private init;
|
|
115
116
|
private calculateEffectiveLayer;
|
|
116
117
|
getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
|
|
117
|
-
addNodePipe(pipe: DataOperationPipe<NodeData>): void;
|
|
118
|
-
addEdgePipe(pipe: DataOperationPipe<EdgeData>): void;
|
|
118
|
+
addNodePipe(pipe: DataOperationPipe<NodeData>): () => void;
|
|
119
|
+
addEdgePipe(pipe: DataOperationPipe<EdgeData>): () => void;
|
|
119
120
|
changePluginConfig(pluginName: string, config: Record<string, any>): void;
|
|
120
121
|
dispatchNodeOperation(operation: DataOperation<NodeData>): void;
|
|
121
122
|
dispatchEdgeOperation(operation: DataOperation<EdgeData>): void;
|
|
@@ -128,15 +129,15 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
|
|
|
128
129
|
getEdges(): EdgeData[];
|
|
129
130
|
getEdgeRenderer(type: string): EdgeRenderType | undefined;
|
|
130
131
|
registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
|
|
131
|
-
registerNodeRenderer(type: string, renderer: NodeRenderType): void;
|
|
132
|
-
registerEdgeRenderer(type: string, renderer: EdgeRenderType): void;
|
|
133
|
-
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority
|
|
134
|
-
startInteraction(pluginId: string, type: string, priority: InteractionPriority
|
|
132
|
+
registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
|
|
133
|
+
registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
|
|
134
|
+
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
|
|
135
|
+
startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
|
|
135
136
|
endInteraction(pluginId: string, type: string): void;
|
|
136
137
|
destroy(): void;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
|
|
140
|
+
declare function getLayerRenders<TRenderType extends RenderType$1 = RenderType$1>(plugin: IPlugin$1): LayerComponent$1<TRenderType>[];
|
|
140
141
|
|
|
141
142
|
/**
|
|
142
143
|
* Runtime 类
|
|
@@ -199,4 +200,4 @@ declare function use<T, TContext>(hook: () => {
|
|
|
199
200
|
__contextValue__: TContext;
|
|
200
201
|
}, context: TContext): T;
|
|
201
202
|
|
|
202
|
-
export { Engine, type EngineOptions, type Interaction, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
|
|
203
|
+
export { Container, EdgeData, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, NodeData, NodeRenderType, Plugin, PluginData, RenderType, Runtime, getLayerRenders, use };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { C as Container, P as Plugin, N as NodeData, E as EdgeData, I as IEngineRuntime, R as RenderType, L as LayerComponent, a as IPlugin, b as Layer, c as NodeRenderType, d as EdgeRenderType, e as PluginData } from './shared/core.BKaZlwmj.mjs';
|
|
2
|
+
export { B as BasePlugin, o as EdgeOperation, m as EdgeOperationPipe, q as EdgeOperatorFunction, i as EdgeProps, H as HorizontalAlignment, g as NodeMeasured, n as NodeOperation, l as NodeOperationPipe, p as NodeOperatorFunction, f as NodePosition, h as NodeProps, k as PluginConfigs, j as Position, V as VerticalAlignment } from './shared/core.BKaZlwmj.mjs';
|
|
3
3
|
import { BehaviorSubject } from 'rxjs';
|
|
4
4
|
import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
|
|
5
5
|
export * from '@knotx/data';
|
|
6
|
+
import { RenderType as RenderType$1, IPlugin as IPlugin$1, LayerComponent as LayerComponent$1 } from '@knotx/core';
|
|
6
7
|
export * from '@knotx/utils';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -114,8 +115,8 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
|
|
|
114
115
|
private init;
|
|
115
116
|
private calculateEffectiveLayer;
|
|
116
117
|
getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
|
|
117
|
-
addNodePipe(pipe: DataOperationPipe<NodeData>): void;
|
|
118
|
-
addEdgePipe(pipe: DataOperationPipe<EdgeData>): void;
|
|
118
|
+
addNodePipe(pipe: DataOperationPipe<NodeData>): () => void;
|
|
119
|
+
addEdgePipe(pipe: DataOperationPipe<EdgeData>): () => void;
|
|
119
120
|
changePluginConfig(pluginName: string, config: Record<string, any>): void;
|
|
120
121
|
dispatchNodeOperation(operation: DataOperation<NodeData>): void;
|
|
121
122
|
dispatchEdgeOperation(operation: DataOperation<EdgeData>): void;
|
|
@@ -128,15 +129,15 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
|
|
|
128
129
|
getEdges(): EdgeData[];
|
|
129
130
|
getEdgeRenderer(type: string): EdgeRenderType | undefined;
|
|
130
131
|
registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
|
|
131
|
-
registerNodeRenderer(type: string, renderer: NodeRenderType): void;
|
|
132
|
-
registerEdgeRenderer(type: string, renderer: EdgeRenderType): void;
|
|
133
|
-
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority
|
|
134
|
-
startInteraction(pluginId: string, type: string, priority: InteractionPriority
|
|
132
|
+
registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
|
|
133
|
+
registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
|
|
134
|
+
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
|
|
135
|
+
startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
|
|
135
136
|
endInteraction(pluginId: string, type: string): void;
|
|
136
137
|
destroy(): void;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
|
|
140
|
+
declare function getLayerRenders<TRenderType extends RenderType$1 = RenderType$1>(plugin: IPlugin$1): LayerComponent$1<TRenderType>[];
|
|
140
141
|
|
|
141
142
|
/**
|
|
142
143
|
* Runtime 类
|
|
@@ -199,4 +200,4 @@ declare function use<T, TContext>(hook: () => {
|
|
|
199
200
|
__contextValue__: TContext;
|
|
200
201
|
}, context: TContext): T;
|
|
201
202
|
|
|
202
|
-
export { Engine, type EngineOptions, type Interaction, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
|
|
203
|
+
export { Container, EdgeData, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, NodeData, NodeRenderType, Plugin, PluginData, RenderType, Runtime, getLayerRenders, use };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { C as Container, P as Plugin, N as NodeData, E as EdgeData, I as IEngineRuntime, R as RenderType, L as LayerComponent, a as IPlugin, b as Layer, c as NodeRenderType, d as EdgeRenderType, e as PluginData } from './shared/core.BKaZlwmj.js';
|
|
2
|
+
export { B as BasePlugin, o as EdgeOperation, m as EdgeOperationPipe, q as EdgeOperatorFunction, i as EdgeProps, H as HorizontalAlignment, g as NodeMeasured, n as NodeOperation, l as NodeOperationPipe, p as NodeOperatorFunction, f as NodePosition, h as NodeProps, k as PluginConfigs, j as Position, V as VerticalAlignment } from './shared/core.BKaZlwmj.js';
|
|
3
3
|
import { BehaviorSubject } from 'rxjs';
|
|
4
4
|
import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
|
|
5
5
|
export * from '@knotx/data';
|
|
6
|
+
import { RenderType as RenderType$1, IPlugin as IPlugin$1, LayerComponent as LayerComponent$1 } from '@knotx/core';
|
|
6
7
|
export * from '@knotx/utils';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -114,8 +115,8 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
|
|
|
114
115
|
private init;
|
|
115
116
|
private calculateEffectiveLayer;
|
|
116
117
|
getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
|
|
117
|
-
addNodePipe(pipe: DataOperationPipe<NodeData>): void;
|
|
118
|
-
addEdgePipe(pipe: DataOperationPipe<EdgeData>): void;
|
|
118
|
+
addNodePipe(pipe: DataOperationPipe<NodeData>): () => void;
|
|
119
|
+
addEdgePipe(pipe: DataOperationPipe<EdgeData>): () => void;
|
|
119
120
|
changePluginConfig(pluginName: string, config: Record<string, any>): void;
|
|
120
121
|
dispatchNodeOperation(operation: DataOperation<NodeData>): void;
|
|
121
122
|
dispatchEdgeOperation(operation: DataOperation<EdgeData>): void;
|
|
@@ -128,15 +129,15 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
|
|
|
128
129
|
getEdges(): EdgeData[];
|
|
129
130
|
getEdgeRenderer(type: string): EdgeRenderType | undefined;
|
|
130
131
|
registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
|
|
131
|
-
registerNodeRenderer(type: string, renderer: NodeRenderType): void;
|
|
132
|
-
registerEdgeRenderer(type: string, renderer: EdgeRenderType): void;
|
|
133
|
-
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority
|
|
134
|
-
startInteraction(pluginId: string, type: string, priority: InteractionPriority
|
|
132
|
+
registerNodeRenderer(type: string, renderer: NodeRenderType): () => void;
|
|
133
|
+
registerEdgeRenderer(type: string, renderer: EdgeRenderType): (() => void);
|
|
134
|
+
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
|
|
135
|
+
startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
|
|
135
136
|
endInteraction(pluginId: string, type: string): void;
|
|
136
137
|
destroy(): void;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
|
|
140
|
+
declare function getLayerRenders<TRenderType extends RenderType$1 = RenderType$1>(plugin: IPlugin$1): LayerComponent$1<TRenderType>[];
|
|
140
141
|
|
|
141
142
|
/**
|
|
142
143
|
* Runtime 类
|
|
@@ -199,4 +200,4 @@ declare function use<T, TContext>(hook: () => {
|
|
|
199
200
|
__contextValue__: TContext;
|
|
200
201
|
}, context: TContext): T;
|
|
201
202
|
|
|
202
|
-
export { Engine, type EngineOptions, type Interaction, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
|
|
203
|
+
export { Container, EdgeData, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, NodeData, NodeRenderType, Plugin, PluginData, RenderType, Runtime, getLayerRenders, use };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Layer } from './definition.js';
|
|
2
2
|
import { set, get } from 'lodash-es';
|
|
3
3
|
import { BehaviorSubject, identity } from 'rxjs';
|
|
4
4
|
import { Layer } from '@knotx/core';
|
|
@@ -7,9 +7,9 @@ export * from '@knotx/utils';
|
|
|
7
7
|
import { DataManager } from '@knotx/data';
|
|
8
8
|
export * from '@knotx/data';
|
|
9
9
|
|
|
10
|
-
var __defProp$
|
|
11
|
-
var __defNormalProp$
|
|
12
|
-
var __publicField$
|
|
10
|
+
var __defProp$4 = Object.defineProperty;
|
|
11
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
|
13
13
|
var InteractionPriority = /* @__PURE__ */ ((InteractionPriority2) => {
|
|
14
14
|
InteractionPriority2[InteractionPriority2["InputActive"] = 2e3] = "InputActive";
|
|
15
15
|
InteractionPriority2[InteractionPriority2["EntityConnectDrag"] = 1930] = "EntityConnectDrag";
|
|
@@ -31,7 +31,7 @@ var InteractionPriority = /* @__PURE__ */ ((InteractionPriority2) => {
|
|
|
31
31
|
})(InteractionPriority || {});
|
|
32
32
|
class InteractionManager {
|
|
33
33
|
constructor() {
|
|
34
|
-
__publicField$
|
|
34
|
+
__publicField$3(this, "interactions", /* @__PURE__ */ new Map());
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* 获取当前活动的交互
|
|
@@ -90,19 +90,19 @@ class InteractionManager {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
var __defProp$
|
|
93
|
+
var __defProp$3 = Object.defineProperty;
|
|
94
94
|
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
95
95
|
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
96
96
|
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
97
|
-
var __defNormalProp$
|
|
97
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
98
98
|
var __spreadValues$1 = (a, b) => {
|
|
99
99
|
for (var prop in b || (b = {}))
|
|
100
100
|
if (__hasOwnProp$1.call(b, prop))
|
|
101
|
-
__defNormalProp$
|
|
101
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
102
102
|
if (__getOwnPropSymbols$1)
|
|
103
103
|
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
104
104
|
if (__propIsEnum$1.call(b, prop))
|
|
105
|
-
__defNormalProp$
|
|
105
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
106
106
|
}
|
|
107
107
|
return a;
|
|
108
108
|
};
|
|
@@ -131,23 +131,23 @@ function getLayerRenders(plugin) {
|
|
|
131
131
|
return components;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
var __defProp$
|
|
135
|
-
var __defNormalProp$
|
|
136
|
-
var __publicField$
|
|
134
|
+
var __defProp$2 = Object.defineProperty;
|
|
135
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
136
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
137
137
|
class Engine {
|
|
138
138
|
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$
|
|
139
|
+
__publicField$2(this, "runtime");
|
|
140
|
+
__publicField$2(this, "interactionManager", new InteractionManager());
|
|
141
|
+
__publicField$2(this, "nodesManager");
|
|
142
|
+
__publicField$2(this, "edgesManager");
|
|
143
|
+
__publicField$2(this, "container$", new BehaviorSubject(null));
|
|
144
|
+
__publicField$2(this, "nodes$", new BehaviorSubject([]));
|
|
145
|
+
__publicField$2(this, "edges$", new BehaviorSubject([]));
|
|
146
|
+
__publicField$2(this, "layers$", new BehaviorSubject(/* @__PURE__ */ new Map()));
|
|
147
|
+
__publicField$2(this, "plugins$", new BehaviorSubject([]));
|
|
148
|
+
__publicField$2(this, "nodeRenderers$", new BehaviorSubject(/* @__PURE__ */ new Map()));
|
|
149
|
+
__publicField$2(this, "edgeRenderers$", new BehaviorSubject(/* @__PURE__ */ new Map()));
|
|
150
|
+
__publicField$2(this, "_pluginDataContainer", {});
|
|
151
151
|
var _a;
|
|
152
152
|
this.runtime = (_a = options.runtime) != null ? _a : {};
|
|
153
153
|
this.container$.next(options.container);
|
|
@@ -216,10 +216,10 @@ class Engine {
|
|
|
216
216
|
return this.layers$.value.get(layer) || [];
|
|
217
217
|
}
|
|
218
218
|
addNodePipe(pipe) {
|
|
219
|
-
this.nodesManager.addDataOperationPipe(pipe);
|
|
219
|
+
return this.nodesManager.addDataOperationPipe(pipe);
|
|
220
220
|
}
|
|
221
221
|
addEdgePipe(pipe) {
|
|
222
|
-
this.edgesManager.addDataOperationPipe(pipe);
|
|
222
|
+
return this.edgesManager.addDataOperationPipe(pipe);
|
|
223
223
|
}
|
|
224
224
|
changePluginConfig(pluginName, config) {
|
|
225
225
|
var _a, _b;
|
|
@@ -262,11 +262,21 @@ class Engine {
|
|
|
262
262
|
const nodeRenderers = this.nodeRenderers$.value;
|
|
263
263
|
nodeRenderers.set(type, renderer);
|
|
264
264
|
this.nodeRenderers$.next(nodeRenderers);
|
|
265
|
+
return () => {
|
|
266
|
+
const nodeRenderers2 = this.nodeRenderers$.value;
|
|
267
|
+
nodeRenderers2.delete(type);
|
|
268
|
+
this.nodeRenderers$.next(nodeRenderers2);
|
|
269
|
+
};
|
|
265
270
|
}
|
|
266
271
|
registerEdgeRenderer(type, renderer) {
|
|
267
272
|
const edgeRenderers = this.edgeRenderers$.value;
|
|
268
273
|
edgeRenderers.set(type, renderer);
|
|
269
274
|
this.edgeRenderers$.next(edgeRenderers);
|
|
275
|
+
return () => {
|
|
276
|
+
const edgeRenderers2 = this.edgeRenderers$.value;
|
|
277
|
+
edgeRenderers2.delete(type);
|
|
278
|
+
this.edgeRenderers$.next(edgeRenderers2);
|
|
279
|
+
};
|
|
270
280
|
}
|
|
271
281
|
canInteract(pluginId, type, autoStartPriority) {
|
|
272
282
|
return this.interactionManager.canInteract(pluginId, type, autoStartPriority);
|
|
@@ -292,6 +302,37 @@ class Engine {
|
|
|
292
302
|
}
|
|
293
303
|
}
|
|
294
304
|
|
|
305
|
+
var __defProp$1 = Object.defineProperty;
|
|
306
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
307
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
308
|
+
const _BasePlugin = class _BasePlugin {
|
|
309
|
+
constructor(__) {
|
|
310
|
+
__publicField$1(this, "_instanceId", _BasePlugin._instanceId++);
|
|
311
|
+
/**
|
|
312
|
+
* 插件生命周期中的订阅回调
|
|
313
|
+
* 可随时存入,销毁时会自动执行
|
|
314
|
+
*/
|
|
315
|
+
__publicField$1(this, "subscriptions", []);
|
|
316
|
+
Reflect.set(this, getSymbol("engine"), new BehaviorSubject(null));
|
|
317
|
+
}
|
|
318
|
+
get pluginId() {
|
|
319
|
+
return `${this.name}:${this._instanceId}`;
|
|
320
|
+
}
|
|
321
|
+
onDestroy() {
|
|
322
|
+
var _a;
|
|
323
|
+
this.subscriptions.forEach((subscription) => {
|
|
324
|
+
if (typeof subscription === "function") {
|
|
325
|
+
subscription();
|
|
326
|
+
} else {
|
|
327
|
+
subscription.unsubscribe();
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
(_a = Reflect.get(this, getSymbol("engine"))) == null ? void 0 : _a.complete();
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
__publicField$1(_BasePlugin, "_instanceId", 0);
|
|
334
|
+
let BasePlugin = _BasePlugin;
|
|
335
|
+
|
|
295
336
|
var __defProp = Object.defineProperty;
|
|
296
337
|
var __defProps = Object.defineProperties;
|
|
297
338
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -370,4 +411,4 @@ function use(hook, context) {
|
|
|
370
411
|
return Runtime.getInstance().runInContext("render", hook, context);
|
|
371
412
|
}
|
|
372
413
|
|
|
373
|
-
export { Engine, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
|
|
414
|
+
export { BasePlugin, Engine, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { SubscriptionLike, BehaviorSubject } from 'rxjs';
|
|
2
|
+
import { DataOperationPipe, DataOperation } from '@knotx/data';
|
|
3
|
+
|
|
4
|
+
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
5
|
+
abstract name: TPluginName;
|
|
6
|
+
constructor(__: TPluginConfig);
|
|
7
|
+
private static _instanceId;
|
|
8
|
+
private _instanceId;
|
|
9
|
+
get pluginId(): string;
|
|
10
|
+
/**
|
|
11
|
+
* 插件生命周期中的订阅回调
|
|
12
|
+
* 可随时存入,销毁时会自动执行
|
|
13
|
+
*/
|
|
14
|
+
protected subscriptions: (SubscriptionLike | (() => void))[];
|
|
15
|
+
onDestroy(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type HorizontalAlignment = 'left' | 'right';
|
|
19
|
+
type VerticalAlignment = 'top' | 'bottom';
|
|
20
|
+
interface NodePosition {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
}
|
|
24
|
+
interface NodeMeasured {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}
|
|
28
|
+
interface NodeData<TData = any> {
|
|
29
|
+
id: string;
|
|
30
|
+
type?: string;
|
|
31
|
+
position: NodePosition;
|
|
32
|
+
measured?: NodeMeasured;
|
|
33
|
+
data: TData;
|
|
34
|
+
}
|
|
35
|
+
interface NodeProps<T = any> {
|
|
36
|
+
node: NodeData<T>;
|
|
37
|
+
}
|
|
38
|
+
interface EdgeData<TData = any> {
|
|
39
|
+
id: string;
|
|
40
|
+
source: string;
|
|
41
|
+
target: string;
|
|
42
|
+
type?: string;
|
|
43
|
+
data?: TData;
|
|
44
|
+
}
|
|
45
|
+
interface EdgeProps<T = any> {
|
|
46
|
+
edge: EdgeData<T>;
|
|
47
|
+
sourceX: number;
|
|
48
|
+
sourceY: number;
|
|
49
|
+
targetX: number;
|
|
50
|
+
targetY: number;
|
|
51
|
+
}
|
|
52
|
+
interface Container {
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
}
|
|
56
|
+
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
57
|
+
type RenderType = (...args: any[]) => any;
|
|
58
|
+
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
59
|
+
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
60
|
+
declare enum Layer {
|
|
61
|
+
Canvas = 0,
|
|
62
|
+
Background = 4,
|
|
63
|
+
Edges = 16,
|
|
64
|
+
Nodes = 64,
|
|
65
|
+
Foreground = 256
|
|
66
|
+
}
|
|
67
|
+
interface LayerComponent<TRenderType> {
|
|
68
|
+
plugin: string;
|
|
69
|
+
name: string;
|
|
70
|
+
layer: Layer;
|
|
71
|
+
render: TRenderType;
|
|
72
|
+
/**
|
|
73
|
+
* 层级偏移量
|
|
74
|
+
* @default 0
|
|
75
|
+
* (layer >> 1, layer << 1]
|
|
76
|
+
*/
|
|
77
|
+
offset?: number;
|
|
78
|
+
}
|
|
79
|
+
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
80
|
+
name: TPluginName;
|
|
81
|
+
pluginId: string;
|
|
82
|
+
onInit?: (config: TPluginConfig) => void;
|
|
83
|
+
onConfigChange?: (config: TPluginConfig) => void;
|
|
84
|
+
onDestroy?: () => void;
|
|
85
|
+
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
86
|
+
}
|
|
87
|
+
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
88
|
+
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
89
|
+
[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;
|
|
90
|
+
} : {}));
|
|
91
|
+
/**
|
|
92
|
+
* plugin data host
|
|
93
|
+
* @example
|
|
94
|
+
* `declare module '@knotx/core' {
|
|
95
|
+
* interface PluginData {
|
|
96
|
+
* pluginName: {
|
|
97
|
+
* property: any
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
* }`
|
|
101
|
+
*/
|
|
102
|
+
interface PluginData {
|
|
103
|
+
}
|
|
104
|
+
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
105
|
+
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
106
|
+
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
107
|
+
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
108
|
+
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
109
|
+
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
110
|
+
interface IEngineRuntime {
|
|
111
|
+
render?: {
|
|
112
|
+
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
113
|
+
paths: string[];
|
|
114
|
+
selector?: (value: T, context?: any) => R;
|
|
115
|
+
context?: any;
|
|
116
|
+
}) => T | R;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { BasePlugin as B, type Container as C, type EdgeData as E, type HorizontalAlignment as H, type IEngineRuntime as I, type LayerComponent as L, type NodeData as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IPlugin as a, Layer as b, type NodeRenderType as c, type EdgeRenderType as d, type PluginData as e, type NodePosition as f, type NodeMeasured as g, type NodeProps as h, type EdgeProps as i, type Position as j, type PluginConfigs as k, type NodeOperationPipe as l, type EdgeOperationPipe as m, type NodeOperation as n, type EdgeOperation as o, type NodeOperatorFunction as p, type EdgeOperatorFunction as q };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { SubscriptionLike, BehaviorSubject } from 'rxjs';
|
|
2
|
+
import { DataOperationPipe, DataOperation } from '@knotx/data';
|
|
3
|
+
|
|
4
|
+
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
5
|
+
abstract name: TPluginName;
|
|
6
|
+
constructor(__: TPluginConfig);
|
|
7
|
+
private static _instanceId;
|
|
8
|
+
private _instanceId;
|
|
9
|
+
get pluginId(): string;
|
|
10
|
+
/**
|
|
11
|
+
* 插件生命周期中的订阅回调
|
|
12
|
+
* 可随时存入,销毁时会自动执行
|
|
13
|
+
*/
|
|
14
|
+
protected subscriptions: (SubscriptionLike | (() => void))[];
|
|
15
|
+
onDestroy(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type HorizontalAlignment = 'left' | 'right';
|
|
19
|
+
type VerticalAlignment = 'top' | 'bottom';
|
|
20
|
+
interface NodePosition {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
}
|
|
24
|
+
interface NodeMeasured {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}
|
|
28
|
+
interface NodeData<TData = any> {
|
|
29
|
+
id: string;
|
|
30
|
+
type?: string;
|
|
31
|
+
position: NodePosition;
|
|
32
|
+
measured?: NodeMeasured;
|
|
33
|
+
data: TData;
|
|
34
|
+
}
|
|
35
|
+
interface NodeProps<T = any> {
|
|
36
|
+
node: NodeData<T>;
|
|
37
|
+
}
|
|
38
|
+
interface EdgeData<TData = any> {
|
|
39
|
+
id: string;
|
|
40
|
+
source: string;
|
|
41
|
+
target: string;
|
|
42
|
+
type?: string;
|
|
43
|
+
data?: TData;
|
|
44
|
+
}
|
|
45
|
+
interface EdgeProps<T = any> {
|
|
46
|
+
edge: EdgeData<T>;
|
|
47
|
+
sourceX: number;
|
|
48
|
+
sourceY: number;
|
|
49
|
+
targetX: number;
|
|
50
|
+
targetY: number;
|
|
51
|
+
}
|
|
52
|
+
interface Container {
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
}
|
|
56
|
+
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
57
|
+
type RenderType = (...args: any[]) => any;
|
|
58
|
+
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
59
|
+
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
60
|
+
declare enum Layer {
|
|
61
|
+
Canvas = 0,
|
|
62
|
+
Background = 4,
|
|
63
|
+
Edges = 16,
|
|
64
|
+
Nodes = 64,
|
|
65
|
+
Foreground = 256
|
|
66
|
+
}
|
|
67
|
+
interface LayerComponent<TRenderType> {
|
|
68
|
+
plugin: string;
|
|
69
|
+
name: string;
|
|
70
|
+
layer: Layer;
|
|
71
|
+
render: TRenderType;
|
|
72
|
+
/**
|
|
73
|
+
* 层级偏移量
|
|
74
|
+
* @default 0
|
|
75
|
+
* (layer >> 1, layer << 1]
|
|
76
|
+
*/
|
|
77
|
+
offset?: number;
|
|
78
|
+
}
|
|
79
|
+
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
80
|
+
name: TPluginName;
|
|
81
|
+
pluginId: string;
|
|
82
|
+
onInit?: (config: TPluginConfig) => void;
|
|
83
|
+
onConfigChange?: (config: TPluginConfig) => void;
|
|
84
|
+
onDestroy?: () => void;
|
|
85
|
+
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
86
|
+
}
|
|
87
|
+
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
88
|
+
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
89
|
+
[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;
|
|
90
|
+
} : {}));
|
|
91
|
+
/**
|
|
92
|
+
* plugin data host
|
|
93
|
+
* @example
|
|
94
|
+
* `declare module '@knotx/core' {
|
|
95
|
+
* interface PluginData {
|
|
96
|
+
* pluginName: {
|
|
97
|
+
* property: any
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
* }`
|
|
101
|
+
*/
|
|
102
|
+
interface PluginData {
|
|
103
|
+
}
|
|
104
|
+
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
105
|
+
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
106
|
+
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
107
|
+
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
108
|
+
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
109
|
+
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
110
|
+
interface IEngineRuntime {
|
|
111
|
+
render?: {
|
|
112
|
+
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
113
|
+
paths: string[];
|
|
114
|
+
selector?: (value: T, context?: any) => R;
|
|
115
|
+
context?: any;
|
|
116
|
+
}) => T | R;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { BasePlugin as B, type Container as C, type EdgeData as E, type HorizontalAlignment as H, type IEngineRuntime as I, type LayerComponent as L, type NodeData as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IPlugin as a, Layer as b, type NodeRenderType as c, type EdgeRenderType as d, type PluginData as e, type NodePosition as f, type NodeMeasured as g, type NodeProps as h, type EdgeProps as i, type Position as j, type PluginConfigs as k, type NodeOperationPipe as l, type EdgeOperationPipe as m, type NodeOperation as n, type EdgeOperation as o, type NodeOperatorFunction as p, type EdgeOperatorFunction as q };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { SubscriptionLike, BehaviorSubject } from 'rxjs';
|
|
2
|
+
import { DataOperationPipe, DataOperation } from '@knotx/data';
|
|
3
|
+
|
|
4
|
+
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
5
|
+
abstract name: TPluginName;
|
|
6
|
+
constructor(__: TPluginConfig);
|
|
7
|
+
private static _instanceId;
|
|
8
|
+
private _instanceId;
|
|
9
|
+
get pluginId(): string;
|
|
10
|
+
/**
|
|
11
|
+
* 插件生命周期中的订阅回调
|
|
12
|
+
* 可随时存入,销毁时会自动执行
|
|
13
|
+
*/
|
|
14
|
+
protected subscriptions: (SubscriptionLike | (() => void))[];
|
|
15
|
+
onDestroy(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type HorizontalAlignment = 'left' | 'right';
|
|
19
|
+
type VerticalAlignment = 'top' | 'bottom';
|
|
20
|
+
interface NodePosition {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
}
|
|
24
|
+
interface NodeMeasured {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}
|
|
28
|
+
interface NodeData<TData = any> {
|
|
29
|
+
id: string;
|
|
30
|
+
type?: string;
|
|
31
|
+
position: NodePosition;
|
|
32
|
+
measured?: NodeMeasured;
|
|
33
|
+
data: TData;
|
|
34
|
+
}
|
|
35
|
+
interface NodeProps<T = any> {
|
|
36
|
+
node: NodeData<T>;
|
|
37
|
+
}
|
|
38
|
+
interface EdgeData<TData = any> {
|
|
39
|
+
id: string;
|
|
40
|
+
source: string;
|
|
41
|
+
target: string;
|
|
42
|
+
type?: string;
|
|
43
|
+
data?: TData;
|
|
44
|
+
}
|
|
45
|
+
interface EdgeProps<T = any> {
|
|
46
|
+
edge: EdgeData<T>;
|
|
47
|
+
sourceX: number;
|
|
48
|
+
sourceY: number;
|
|
49
|
+
targetX: number;
|
|
50
|
+
targetY: number;
|
|
51
|
+
}
|
|
52
|
+
interface Container {
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
}
|
|
56
|
+
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
57
|
+
type RenderType = (...args: any[]) => any;
|
|
58
|
+
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
59
|
+
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
60
|
+
declare enum Layer {
|
|
61
|
+
Canvas = 0,
|
|
62
|
+
Background = 4,
|
|
63
|
+
Edges = 16,
|
|
64
|
+
Nodes = 64,
|
|
65
|
+
Foreground = 256
|
|
66
|
+
}
|
|
67
|
+
interface LayerComponent<TRenderType> {
|
|
68
|
+
plugin: string;
|
|
69
|
+
name: string;
|
|
70
|
+
layer: Layer;
|
|
71
|
+
render: TRenderType;
|
|
72
|
+
/**
|
|
73
|
+
* 层级偏移量
|
|
74
|
+
* @default 0
|
|
75
|
+
* (layer >> 1, layer << 1]
|
|
76
|
+
*/
|
|
77
|
+
offset?: number;
|
|
78
|
+
}
|
|
79
|
+
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
80
|
+
name: TPluginName;
|
|
81
|
+
pluginId: string;
|
|
82
|
+
onInit?: (config: TPluginConfig) => void;
|
|
83
|
+
onConfigChange?: (config: TPluginConfig) => void;
|
|
84
|
+
onDestroy?: () => void;
|
|
85
|
+
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
86
|
+
}
|
|
87
|
+
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
88
|
+
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
89
|
+
[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;
|
|
90
|
+
} : {}));
|
|
91
|
+
/**
|
|
92
|
+
* plugin data host
|
|
93
|
+
* @example
|
|
94
|
+
* `declare module '@knotx/core' {
|
|
95
|
+
* interface PluginData {
|
|
96
|
+
* pluginName: {
|
|
97
|
+
* property: any
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
* }`
|
|
101
|
+
*/
|
|
102
|
+
interface PluginData {
|
|
103
|
+
}
|
|
104
|
+
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
105
|
+
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
106
|
+
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
107
|
+
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
108
|
+
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
109
|
+
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
110
|
+
interface IEngineRuntime {
|
|
111
|
+
render?: {
|
|
112
|
+
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
113
|
+
paths: string[];
|
|
114
|
+
selector?: (value: T, context?: any) => R;
|
|
115
|
+
context?: any;
|
|
116
|
+
}) => T | R;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { BasePlugin as B, type Container as C, type EdgeData as E, type HorizontalAlignment as H, type IEngineRuntime as I, type LayerComponent as L, type NodeData as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IPlugin as a, Layer as b, type NodeRenderType as c, type EdgeRenderType as d, type PluginData as e, type NodePosition as f, type NodeMeasured as g, type NodeProps as h, type EdgeProps as i, type Position as j, type PluginConfigs as k, type NodeOperationPipe as l, type EdgeOperationPipe as m, type NodeOperation as n, type EdgeOperation as o, type NodeOperatorFunction as p, type EdgeOperatorFunction as q };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Core for Knotx",
|
|
5
5
|
"author": "boenfu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"lodash-es": "^4.17.21",
|
|
47
47
|
"rxjs": "^7.8.1",
|
|
48
|
-
"@knotx/data": "0.2.
|
|
49
|
-
"@knotx/utils": "0.2.
|
|
48
|
+
"@knotx/data": "0.2.5",
|
|
49
|
+
"@knotx/utils": "0.2.5"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/lodash-es": "^4.17.12",
|
|
53
|
-
"@knotx/build-config": "0.2.
|
|
54
|
-
"@knotx/eslint-config": "0.2.
|
|
55
|
-
"@knotx/typescript-config": "0.2.
|
|
53
|
+
"@knotx/build-config": "0.2.5",
|
|
54
|
+
"@knotx/eslint-config": "0.2.5",
|
|
55
|
+
"@knotx/typescript-config": "0.2.5"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "unbuild",
|