@knotx/core 0.2.1 → 0.2.3
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 +26 -0
- package/dist/definition.d.cts +113 -0
- package/dist/definition.d.mts +113 -0
- package/dist/definition.d.ts +113 -0
- package/dist/definition.js +23 -0
- package/dist/index.cjs +3 -24
- package/dist/index.d.cts +36 -144
- package/dist/index.d.mts +36 -144
- package/dist/index.d.ts +36 -144
- package/dist/{index.mjs → index.js} +4 -25
- package/package.json +16 -11
- /package/dist/{data.mjs → data.js} +0 -0
- /package/dist/{utils.mjs → utils.js} +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
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
|
+
var Layer = /* @__PURE__ */ ((Layer2) => {
|
|
7
|
+
Layer2[Layer2["Canvas"] = 0] = "Canvas";
|
|
8
|
+
Layer2[Layer2["Background"] = 4] = "Background";
|
|
9
|
+
Layer2[Layer2["Edges"] = 16] = "Edges";
|
|
10
|
+
Layer2[Layer2["Nodes"] = 64] = "Nodes";
|
|
11
|
+
Layer2[Layer2["Foreground"] = 256] = "Foreground";
|
|
12
|
+
return Layer2;
|
|
13
|
+
})(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
|
+
|
|
25
|
+
exports.BasePlugin = BasePlugin;
|
|
26
|
+
exports.Layer = Layer;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
import { DataOperationPipe, DataOperation } from '@knotx/data';
|
|
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 };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
import { DataOperationPipe, DataOperation } from '@knotx/data';
|
|
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 };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
import { DataOperationPipe, DataOperation } from '@knotx/data';
|
|
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 };
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
var Layer = /* @__PURE__ */ ((Layer2) => {
|
|
5
|
+
Layer2[Layer2["Canvas"] = 0] = "Canvas";
|
|
6
|
+
Layer2[Layer2["Background"] = 4] = "Background";
|
|
7
|
+
Layer2[Layer2["Edges"] = 16] = "Edges";
|
|
8
|
+
Layer2[Layer2["Nodes"] = 64] = "Nodes";
|
|
9
|
+
Layer2[Layer2["Foreground"] = 256] = "Foreground";
|
|
10
|
+
return Layer2;
|
|
11
|
+
})(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
|
+
|
|
23
|
+
export { BasePlugin, Layer };
|
package/dist/index.cjs
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const definition = require('./definition.cjs');
|
|
3
4
|
const lodashEs = require('lodash-es');
|
|
4
5
|
const rxjs = require('rxjs');
|
|
5
6
|
const core = require('@knotx/core');
|
|
6
7
|
const utils = require('@knotx/utils');
|
|
7
8
|
const data = require('@knotx/data');
|
|
8
9
|
|
|
9
|
-
var __defProp$4 = Object.defineProperty;
|
|
10
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __publicField$3 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
|
12
|
-
var Layer = /* @__PURE__ */ ((Layer2) => {
|
|
13
|
-
Layer2[Layer2["Canvas"] = 0] = "Canvas";
|
|
14
|
-
Layer2[Layer2["Background"] = 4] = "Background";
|
|
15
|
-
Layer2[Layer2["Edges"] = 16] = "Edges";
|
|
16
|
-
Layer2[Layer2["Nodes"] = 64] = "Nodes";
|
|
17
|
-
Layer2[Layer2["Foreground"] = 256] = "Foreground";
|
|
18
|
-
return Layer2;
|
|
19
|
-
})(Layer || {});
|
|
20
|
-
const _BasePlugin = class _BasePlugin {
|
|
21
|
-
constructor(__) {
|
|
22
|
-
__publicField$3(this, "_instanceId", _BasePlugin._instanceId++);
|
|
23
|
-
}
|
|
24
|
-
get pluginId() {
|
|
25
|
-
return `${this.name}:${this._instanceId}`;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
__publicField$3(_BasePlugin, "_instanceId", 0);
|
|
29
|
-
let BasePlugin = _BasePlugin;
|
|
30
|
-
|
|
31
10
|
var __defProp$3 = Object.defineProperty;
|
|
32
11
|
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
33
12
|
var __publicField$2 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
|
|
@@ -391,11 +370,11 @@ function use(hook, context) {
|
|
|
391
370
|
return Runtime.getInstance().runInContext("render", hook, context);
|
|
392
371
|
}
|
|
393
372
|
|
|
394
|
-
exports.BasePlugin = BasePlugin;
|
|
373
|
+
exports.BasePlugin = definition.BasePlugin;
|
|
374
|
+
exports.Layer = definition.Layer;
|
|
395
375
|
exports.Engine = Engine;
|
|
396
376
|
exports.InteractionManager = InteractionManager;
|
|
397
377
|
exports.InteractionPriority = InteractionPriority;
|
|
398
|
-
exports.Layer = Layer;
|
|
399
378
|
exports.Runtime = Runtime;
|
|
400
379
|
exports.getLayerRenders = getLayerRenders;
|
|
401
380
|
exports.use = use;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,118 +1,10 @@
|
|
|
1
|
+
export { BasePlugin, Container, EdgeData, EdgeOperation, EdgeOperationPipe, EdgeOperatorFunction, EdgeProps, EdgeRenderType, HorizontalAlignment, IEngineRuntime, IPlugin, Layer, LayerComponent, NodeData, NodeMeasured, NodeOperation, NodeOperationPipe, NodeOperatorFunction, NodePosition, NodeProps, NodeRenderType, Plugin, PluginConfigs, PluginData, Position, RenderType, VerticalAlignment } from './definition.cjs';
|
|
2
|
+
import { Container, Plugin, NodeData, EdgeData, IEngineRuntime, RenderType, LayerComponent, IPlugin, Layer, NodeRenderType, EdgeRenderType, PluginData, InteractionPriority as InteractionPriority$1 } from '@knotx/core';
|
|
1
3
|
import { BehaviorSubject } from 'rxjs';
|
|
2
|
-
import { DataOperationPipe, DataOperation
|
|
4
|
+
import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
|
|
3
5
|
export * from '@knotx/data';
|
|
4
|
-
import { Container as Container$1, Plugin as Plugin$1, NodeData as NodeData$1, EdgeData as EdgeData$1, IEngineRuntime as IEngineRuntime$1, RenderType as RenderType$1, LayerComponent as LayerComponent$1, IPlugin as IPlugin$1, Layer as Layer$1, NodeRenderType as NodeRenderType$1, EdgeRenderType as EdgeRenderType$1, PluginData as PluginData$1, InteractionPriority as InteractionPriority$1 } from '@knotx/core';
|
|
5
6
|
export * from '@knotx/utils';
|
|
6
7
|
|
|
7
|
-
type HorizontalAlignment = 'left' | 'right';
|
|
8
|
-
type VerticalAlignment = 'top' | 'bottom';
|
|
9
|
-
interface NodePosition {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
}
|
|
13
|
-
interface NodeMeasured {
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
}
|
|
17
|
-
interface NodeData<TData = any> {
|
|
18
|
-
id: string;
|
|
19
|
-
type?: string;
|
|
20
|
-
position: NodePosition;
|
|
21
|
-
measured?: NodeMeasured;
|
|
22
|
-
data: TData;
|
|
23
|
-
}
|
|
24
|
-
interface NodeProps<T = any> {
|
|
25
|
-
node: NodeData<T>;
|
|
26
|
-
}
|
|
27
|
-
interface EdgeData<TData = any> {
|
|
28
|
-
id: string;
|
|
29
|
-
source: string;
|
|
30
|
-
target: string;
|
|
31
|
-
type?: string;
|
|
32
|
-
data?: TData;
|
|
33
|
-
}
|
|
34
|
-
interface EdgeProps<T = any> {
|
|
35
|
-
edge: EdgeData<T>;
|
|
36
|
-
sourceX: number;
|
|
37
|
-
sourceY: number;
|
|
38
|
-
targetX: number;
|
|
39
|
-
targetY: number;
|
|
40
|
-
}
|
|
41
|
-
interface Container {
|
|
42
|
-
width: number;
|
|
43
|
-
height: number;
|
|
44
|
-
}
|
|
45
|
-
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
46
|
-
type RenderType = (...args: any[]) => any;
|
|
47
|
-
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
48
|
-
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
49
|
-
declare enum Layer {
|
|
50
|
-
Canvas = 0,
|
|
51
|
-
Background = 4,
|
|
52
|
-
Edges = 16,
|
|
53
|
-
Nodes = 64,
|
|
54
|
-
Foreground = 256
|
|
55
|
-
}
|
|
56
|
-
interface LayerComponent<TRenderType> {
|
|
57
|
-
plugin: string;
|
|
58
|
-
name: string;
|
|
59
|
-
layer: Layer;
|
|
60
|
-
render: TRenderType;
|
|
61
|
-
/**
|
|
62
|
-
* 层级偏移量
|
|
63
|
-
* @default 0
|
|
64
|
-
* (layer >> 1, layer << 1]
|
|
65
|
-
*/
|
|
66
|
-
offset?: number;
|
|
67
|
-
}
|
|
68
|
-
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
69
|
-
name: TPluginName;
|
|
70
|
-
pluginId: string;
|
|
71
|
-
onInit?: (config: TPluginConfig) => void;
|
|
72
|
-
onConfigChange?: (config: TPluginConfig) => void;
|
|
73
|
-
onDestroy?: () => void;
|
|
74
|
-
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
75
|
-
}
|
|
76
|
-
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
77
|
-
abstract name: TPluginName;
|
|
78
|
-
constructor(__: TPluginConfig);
|
|
79
|
-
private static _instanceId;
|
|
80
|
-
private _instanceId;
|
|
81
|
-
get pluginId(): string;
|
|
82
|
-
}
|
|
83
|
-
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
84
|
-
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
85
|
-
[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;
|
|
86
|
-
} : {}));
|
|
87
|
-
/**
|
|
88
|
-
* plugin data host
|
|
89
|
-
* @example
|
|
90
|
-
* `declare module '@knotx/core' {
|
|
91
|
-
* interface PluginData {
|
|
92
|
-
* pluginName: {
|
|
93
|
-
* property: any
|
|
94
|
-
* }
|
|
95
|
-
* }
|
|
96
|
-
* }`
|
|
97
|
-
*/
|
|
98
|
-
interface PluginData {
|
|
99
|
-
}
|
|
100
|
-
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
101
|
-
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
102
|
-
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
103
|
-
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
104
|
-
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
105
|
-
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
106
|
-
interface IEngineRuntime {
|
|
107
|
-
render?: {
|
|
108
|
-
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
109
|
-
paths: string[];
|
|
110
|
-
selector?: (value: T, context?: any) => R;
|
|
111
|
-
context?: any;
|
|
112
|
-
}) => T | R;
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
8
|
/**
|
|
117
9
|
* 用户交互优先级定义
|
|
118
10
|
* 数值越大优先级越高
|
|
@@ -192,18 +84,18 @@ declare class InteractionManager {
|
|
|
192
84
|
}
|
|
193
85
|
|
|
194
86
|
interface EngineOptions {
|
|
195
|
-
container: Container
|
|
196
|
-
plugins?: Plugin
|
|
87
|
+
container: Container;
|
|
88
|
+
plugins?: Plugin[];
|
|
197
89
|
pluginConfig?: Record<string, any>;
|
|
198
|
-
nodes?: NodeData
|
|
199
|
-
edges?: EdgeData
|
|
200
|
-
runtime?: IEngineRuntime
|
|
90
|
+
nodes?: NodeData[];
|
|
91
|
+
edges?: EdgeData[];
|
|
92
|
+
runtime?: IEngineRuntime;
|
|
201
93
|
}
|
|
202
|
-
declare class Engine<TRenderType extends RenderType
|
|
203
|
-
readonly runtime: IEngineRuntime
|
|
94
|
+
declare class Engine<TRenderType extends RenderType = RenderType> {
|
|
95
|
+
readonly runtime: IEngineRuntime;
|
|
204
96
|
readonly interactionManager: InteractionManager;
|
|
205
|
-
readonly nodesManager: DataManager<NodeData
|
|
206
|
-
readonly edgesManager: DataManager<EdgeData
|
|
97
|
+
readonly nodesManager: DataManager<NodeData>;
|
|
98
|
+
readonly edgesManager: DataManager<EdgeData>;
|
|
207
99
|
private container$;
|
|
208
100
|
private nodes$;
|
|
209
101
|
private edges$;
|
|
@@ -212,39 +104,39 @@ declare class Engine<TRenderType extends RenderType$1 = RenderType$1> {
|
|
|
212
104
|
private nodeRenderers$;
|
|
213
105
|
private edgeRenderers$;
|
|
214
106
|
private _pluginDataContainer;
|
|
215
|
-
get container(): Container
|
|
216
|
-
set container(value: Container
|
|
217
|
-
get nodes(): NodeData
|
|
218
|
-
get edges(): EdgeData
|
|
219
|
-
get layers(): Map<number, LayerComponent
|
|
220
|
-
get plugins(): IPlugin
|
|
107
|
+
get container(): Container;
|
|
108
|
+
set container(value: Container);
|
|
109
|
+
get nodes(): NodeData<any>[];
|
|
110
|
+
get edges(): EdgeData<any>[];
|
|
111
|
+
get layers(): Map<number, LayerComponent<TRenderType>[]>;
|
|
112
|
+
get plugins(): IPlugin<string, any, RenderType>[];
|
|
221
113
|
constructor(options: EngineOptions);
|
|
222
114
|
private init;
|
|
223
115
|
private calculateEffectiveLayer;
|
|
224
|
-
getLayerComponents(layer: Layer
|
|
225
|
-
addNodePipe(pipe: DataOperationPipe<NodeData
|
|
226
|
-
addEdgePipe(pipe: DataOperationPipe<EdgeData
|
|
116
|
+
getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
|
|
117
|
+
addNodePipe(pipe: DataOperationPipe<NodeData>): void;
|
|
118
|
+
addEdgePipe(pipe: DataOperationPipe<EdgeData>): void;
|
|
227
119
|
changePluginConfig(pluginName: string, config: Record<string, any>): void;
|
|
228
|
-
dispatchNodeOperation(operation: DataOperation<NodeData
|
|
229
|
-
dispatchEdgeOperation(operation: DataOperation<EdgeData
|
|
230
|
-
getNode(id: string): NodeData
|
|
231
|
-
getNodeDraft(id: string): NodeData
|
|
232
|
-
getNodes(): NodeData
|
|
233
|
-
getNodeRenderer(type: string): NodeRenderType
|
|
234
|
-
getEdge(id: string): EdgeData
|
|
235
|
-
getEdgeDraft(id: string): EdgeData
|
|
236
|
-
getEdges(): EdgeData
|
|
237
|
-
getEdgeRenderer(type: string): EdgeRenderType
|
|
238
|
-
registerPluginData<T extends keyof PluginData
|
|
239
|
-
registerNodeRenderer(type: string, renderer: NodeRenderType
|
|
240
|
-
registerEdgeRenderer(type: string, renderer: EdgeRenderType
|
|
120
|
+
dispatchNodeOperation(operation: DataOperation<NodeData>): void;
|
|
121
|
+
dispatchEdgeOperation(operation: DataOperation<EdgeData>): void;
|
|
122
|
+
getNode(id: string): NodeData | undefined;
|
|
123
|
+
getNodeDraft(id: string): NodeData | undefined;
|
|
124
|
+
getNodes(): NodeData[];
|
|
125
|
+
getNodeRenderer(type: string): NodeRenderType | undefined;
|
|
126
|
+
getEdge(id: string): EdgeData | undefined;
|
|
127
|
+
getEdgeDraft(id: string): EdgeData | undefined;
|
|
128
|
+
getEdges(): EdgeData[];
|
|
129
|
+
getEdgeRenderer(type: string): EdgeRenderType | undefined;
|
|
130
|
+
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;
|
|
241
133
|
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority$1): boolean;
|
|
242
134
|
startInteraction(pluginId: string, type: string, priority: InteractionPriority$1): void;
|
|
243
135
|
endInteraction(pluginId: string, type: string): void;
|
|
244
136
|
destroy(): void;
|
|
245
137
|
}
|
|
246
138
|
|
|
247
|
-
declare function getLayerRenders<TRenderType extends RenderType
|
|
139
|
+
declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
|
|
248
140
|
|
|
249
141
|
/**
|
|
250
142
|
* Runtime 类
|
|
@@ -307,4 +199,4 @@ declare function use<T, TContext>(hook: () => {
|
|
|
307
199
|
__contextValue__: TContext;
|
|
308
200
|
}, context: TContext): T;
|
|
309
201
|
|
|
310
|
-
export {
|
|
202
|
+
export { Engine, type EngineOptions, type Interaction, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,118 +1,10 @@
|
|
|
1
|
+
export { BasePlugin, Container, EdgeData, EdgeOperation, EdgeOperationPipe, EdgeOperatorFunction, EdgeProps, EdgeRenderType, HorizontalAlignment, IEngineRuntime, IPlugin, Layer, LayerComponent, NodeData, NodeMeasured, NodeOperation, NodeOperationPipe, NodeOperatorFunction, NodePosition, NodeProps, NodeRenderType, Plugin, PluginConfigs, PluginData, Position, RenderType, VerticalAlignment } from './definition.mjs';
|
|
2
|
+
import { Container, Plugin, NodeData, EdgeData, IEngineRuntime, RenderType, LayerComponent, IPlugin, Layer, NodeRenderType, EdgeRenderType, PluginData, InteractionPriority as InteractionPriority$1 } from '@knotx/core';
|
|
1
3
|
import { BehaviorSubject } from 'rxjs';
|
|
2
|
-
import { DataOperationPipe, DataOperation
|
|
4
|
+
import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
|
|
3
5
|
export * from '@knotx/data';
|
|
4
|
-
import { Container as Container$1, Plugin as Plugin$1, NodeData as NodeData$1, EdgeData as EdgeData$1, IEngineRuntime as IEngineRuntime$1, RenderType as RenderType$1, LayerComponent as LayerComponent$1, IPlugin as IPlugin$1, Layer as Layer$1, NodeRenderType as NodeRenderType$1, EdgeRenderType as EdgeRenderType$1, PluginData as PluginData$1, InteractionPriority as InteractionPriority$1 } from '@knotx/core';
|
|
5
6
|
export * from '@knotx/utils';
|
|
6
7
|
|
|
7
|
-
type HorizontalAlignment = 'left' | 'right';
|
|
8
|
-
type VerticalAlignment = 'top' | 'bottom';
|
|
9
|
-
interface NodePosition {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
}
|
|
13
|
-
interface NodeMeasured {
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
}
|
|
17
|
-
interface NodeData<TData = any> {
|
|
18
|
-
id: string;
|
|
19
|
-
type?: string;
|
|
20
|
-
position: NodePosition;
|
|
21
|
-
measured?: NodeMeasured;
|
|
22
|
-
data: TData;
|
|
23
|
-
}
|
|
24
|
-
interface NodeProps<T = any> {
|
|
25
|
-
node: NodeData<T>;
|
|
26
|
-
}
|
|
27
|
-
interface EdgeData<TData = any> {
|
|
28
|
-
id: string;
|
|
29
|
-
source: string;
|
|
30
|
-
target: string;
|
|
31
|
-
type?: string;
|
|
32
|
-
data?: TData;
|
|
33
|
-
}
|
|
34
|
-
interface EdgeProps<T = any> {
|
|
35
|
-
edge: EdgeData<T>;
|
|
36
|
-
sourceX: number;
|
|
37
|
-
sourceY: number;
|
|
38
|
-
targetX: number;
|
|
39
|
-
targetY: number;
|
|
40
|
-
}
|
|
41
|
-
interface Container {
|
|
42
|
-
width: number;
|
|
43
|
-
height: number;
|
|
44
|
-
}
|
|
45
|
-
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
46
|
-
type RenderType = (...args: any[]) => any;
|
|
47
|
-
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
48
|
-
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
49
|
-
declare enum Layer {
|
|
50
|
-
Canvas = 0,
|
|
51
|
-
Background = 4,
|
|
52
|
-
Edges = 16,
|
|
53
|
-
Nodes = 64,
|
|
54
|
-
Foreground = 256
|
|
55
|
-
}
|
|
56
|
-
interface LayerComponent<TRenderType> {
|
|
57
|
-
plugin: string;
|
|
58
|
-
name: string;
|
|
59
|
-
layer: Layer;
|
|
60
|
-
render: TRenderType;
|
|
61
|
-
/**
|
|
62
|
-
* 层级偏移量
|
|
63
|
-
* @default 0
|
|
64
|
-
* (layer >> 1, layer << 1]
|
|
65
|
-
*/
|
|
66
|
-
offset?: number;
|
|
67
|
-
}
|
|
68
|
-
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
69
|
-
name: TPluginName;
|
|
70
|
-
pluginId: string;
|
|
71
|
-
onInit?: (config: TPluginConfig) => void;
|
|
72
|
-
onConfigChange?: (config: TPluginConfig) => void;
|
|
73
|
-
onDestroy?: () => void;
|
|
74
|
-
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
75
|
-
}
|
|
76
|
-
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
77
|
-
abstract name: TPluginName;
|
|
78
|
-
constructor(__: TPluginConfig);
|
|
79
|
-
private static _instanceId;
|
|
80
|
-
private _instanceId;
|
|
81
|
-
get pluginId(): string;
|
|
82
|
-
}
|
|
83
|
-
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
84
|
-
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
85
|
-
[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;
|
|
86
|
-
} : {}));
|
|
87
|
-
/**
|
|
88
|
-
* plugin data host
|
|
89
|
-
* @example
|
|
90
|
-
* `declare module '@knotx/core' {
|
|
91
|
-
* interface PluginData {
|
|
92
|
-
* pluginName: {
|
|
93
|
-
* property: any
|
|
94
|
-
* }
|
|
95
|
-
* }
|
|
96
|
-
* }`
|
|
97
|
-
*/
|
|
98
|
-
interface PluginData {
|
|
99
|
-
}
|
|
100
|
-
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
101
|
-
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
102
|
-
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
103
|
-
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
104
|
-
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
105
|
-
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
106
|
-
interface IEngineRuntime {
|
|
107
|
-
render?: {
|
|
108
|
-
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
109
|
-
paths: string[];
|
|
110
|
-
selector?: (value: T, context?: any) => R;
|
|
111
|
-
context?: any;
|
|
112
|
-
}) => T | R;
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
8
|
/**
|
|
117
9
|
* 用户交互优先级定义
|
|
118
10
|
* 数值越大优先级越高
|
|
@@ -192,18 +84,18 @@ declare class InteractionManager {
|
|
|
192
84
|
}
|
|
193
85
|
|
|
194
86
|
interface EngineOptions {
|
|
195
|
-
container: Container
|
|
196
|
-
plugins?: Plugin
|
|
87
|
+
container: Container;
|
|
88
|
+
plugins?: Plugin[];
|
|
197
89
|
pluginConfig?: Record<string, any>;
|
|
198
|
-
nodes?: NodeData
|
|
199
|
-
edges?: EdgeData
|
|
200
|
-
runtime?: IEngineRuntime
|
|
90
|
+
nodes?: NodeData[];
|
|
91
|
+
edges?: EdgeData[];
|
|
92
|
+
runtime?: IEngineRuntime;
|
|
201
93
|
}
|
|
202
|
-
declare class Engine<TRenderType extends RenderType
|
|
203
|
-
readonly runtime: IEngineRuntime
|
|
94
|
+
declare class Engine<TRenderType extends RenderType = RenderType> {
|
|
95
|
+
readonly runtime: IEngineRuntime;
|
|
204
96
|
readonly interactionManager: InteractionManager;
|
|
205
|
-
readonly nodesManager: DataManager<NodeData
|
|
206
|
-
readonly edgesManager: DataManager<EdgeData
|
|
97
|
+
readonly nodesManager: DataManager<NodeData>;
|
|
98
|
+
readonly edgesManager: DataManager<EdgeData>;
|
|
207
99
|
private container$;
|
|
208
100
|
private nodes$;
|
|
209
101
|
private edges$;
|
|
@@ -212,39 +104,39 @@ declare class Engine<TRenderType extends RenderType$1 = RenderType$1> {
|
|
|
212
104
|
private nodeRenderers$;
|
|
213
105
|
private edgeRenderers$;
|
|
214
106
|
private _pluginDataContainer;
|
|
215
|
-
get container(): Container
|
|
216
|
-
set container(value: Container
|
|
217
|
-
get nodes(): NodeData
|
|
218
|
-
get edges(): EdgeData
|
|
219
|
-
get layers(): Map<number, LayerComponent
|
|
220
|
-
get plugins(): IPlugin
|
|
107
|
+
get container(): Container;
|
|
108
|
+
set container(value: Container);
|
|
109
|
+
get nodes(): NodeData<any>[];
|
|
110
|
+
get edges(): EdgeData<any>[];
|
|
111
|
+
get layers(): Map<number, LayerComponent<TRenderType>[]>;
|
|
112
|
+
get plugins(): IPlugin<string, any, RenderType>[];
|
|
221
113
|
constructor(options: EngineOptions);
|
|
222
114
|
private init;
|
|
223
115
|
private calculateEffectiveLayer;
|
|
224
|
-
getLayerComponents(layer: Layer
|
|
225
|
-
addNodePipe(pipe: DataOperationPipe<NodeData
|
|
226
|
-
addEdgePipe(pipe: DataOperationPipe<EdgeData
|
|
116
|
+
getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
|
|
117
|
+
addNodePipe(pipe: DataOperationPipe<NodeData>): void;
|
|
118
|
+
addEdgePipe(pipe: DataOperationPipe<EdgeData>): void;
|
|
227
119
|
changePluginConfig(pluginName: string, config: Record<string, any>): void;
|
|
228
|
-
dispatchNodeOperation(operation: DataOperation<NodeData
|
|
229
|
-
dispatchEdgeOperation(operation: DataOperation<EdgeData
|
|
230
|
-
getNode(id: string): NodeData
|
|
231
|
-
getNodeDraft(id: string): NodeData
|
|
232
|
-
getNodes(): NodeData
|
|
233
|
-
getNodeRenderer(type: string): NodeRenderType
|
|
234
|
-
getEdge(id: string): EdgeData
|
|
235
|
-
getEdgeDraft(id: string): EdgeData
|
|
236
|
-
getEdges(): EdgeData
|
|
237
|
-
getEdgeRenderer(type: string): EdgeRenderType
|
|
238
|
-
registerPluginData<T extends keyof PluginData
|
|
239
|
-
registerNodeRenderer(type: string, renderer: NodeRenderType
|
|
240
|
-
registerEdgeRenderer(type: string, renderer: EdgeRenderType
|
|
120
|
+
dispatchNodeOperation(operation: DataOperation<NodeData>): void;
|
|
121
|
+
dispatchEdgeOperation(operation: DataOperation<EdgeData>): void;
|
|
122
|
+
getNode(id: string): NodeData | undefined;
|
|
123
|
+
getNodeDraft(id: string): NodeData | undefined;
|
|
124
|
+
getNodes(): NodeData[];
|
|
125
|
+
getNodeRenderer(type: string): NodeRenderType | undefined;
|
|
126
|
+
getEdge(id: string): EdgeData | undefined;
|
|
127
|
+
getEdgeDraft(id: string): EdgeData | undefined;
|
|
128
|
+
getEdges(): EdgeData[];
|
|
129
|
+
getEdgeRenderer(type: string): EdgeRenderType | undefined;
|
|
130
|
+
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;
|
|
241
133
|
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority$1): boolean;
|
|
242
134
|
startInteraction(pluginId: string, type: string, priority: InteractionPriority$1): void;
|
|
243
135
|
endInteraction(pluginId: string, type: string): void;
|
|
244
136
|
destroy(): void;
|
|
245
137
|
}
|
|
246
138
|
|
|
247
|
-
declare function getLayerRenders<TRenderType extends RenderType
|
|
139
|
+
declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
|
|
248
140
|
|
|
249
141
|
/**
|
|
250
142
|
* Runtime 类
|
|
@@ -307,4 +199,4 @@ declare function use<T, TContext>(hook: () => {
|
|
|
307
199
|
__contextValue__: TContext;
|
|
308
200
|
}, context: TContext): T;
|
|
309
201
|
|
|
310
|
-
export {
|
|
202
|
+
export { Engine, type EngineOptions, type Interaction, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,118 +1,10 @@
|
|
|
1
|
+
export { BasePlugin, Container, EdgeData, EdgeOperation, EdgeOperationPipe, EdgeOperatorFunction, EdgeProps, EdgeRenderType, HorizontalAlignment, IEngineRuntime, IPlugin, Layer, LayerComponent, NodeData, NodeMeasured, NodeOperation, NodeOperationPipe, NodeOperatorFunction, NodePosition, NodeProps, NodeRenderType, Plugin, PluginConfigs, PluginData, Position, RenderType, VerticalAlignment } from './definition.js';
|
|
2
|
+
import { Container, Plugin, NodeData, EdgeData, IEngineRuntime, RenderType, LayerComponent, IPlugin, Layer, NodeRenderType, EdgeRenderType, PluginData, InteractionPriority as InteractionPriority$1 } from '@knotx/core';
|
|
1
3
|
import { BehaviorSubject } from 'rxjs';
|
|
2
|
-
import { DataOperationPipe, DataOperation
|
|
4
|
+
import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
|
|
3
5
|
export * from '@knotx/data';
|
|
4
|
-
import { Container as Container$1, Plugin as Plugin$1, NodeData as NodeData$1, EdgeData as EdgeData$1, IEngineRuntime as IEngineRuntime$1, RenderType as RenderType$1, LayerComponent as LayerComponent$1, IPlugin as IPlugin$1, Layer as Layer$1, NodeRenderType as NodeRenderType$1, EdgeRenderType as EdgeRenderType$1, PluginData as PluginData$1, InteractionPriority as InteractionPriority$1 } from '@knotx/core';
|
|
5
6
|
export * from '@knotx/utils';
|
|
6
7
|
|
|
7
|
-
type HorizontalAlignment = 'left' | 'right';
|
|
8
|
-
type VerticalAlignment = 'top' | 'bottom';
|
|
9
|
-
interface NodePosition {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
}
|
|
13
|
-
interface NodeMeasured {
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
}
|
|
17
|
-
interface NodeData<TData = any> {
|
|
18
|
-
id: string;
|
|
19
|
-
type?: string;
|
|
20
|
-
position: NodePosition;
|
|
21
|
-
measured?: NodeMeasured;
|
|
22
|
-
data: TData;
|
|
23
|
-
}
|
|
24
|
-
interface NodeProps<T = any> {
|
|
25
|
-
node: NodeData<T>;
|
|
26
|
-
}
|
|
27
|
-
interface EdgeData<TData = any> {
|
|
28
|
-
id: string;
|
|
29
|
-
source: string;
|
|
30
|
-
target: string;
|
|
31
|
-
type?: string;
|
|
32
|
-
data?: TData;
|
|
33
|
-
}
|
|
34
|
-
interface EdgeProps<T = any> {
|
|
35
|
-
edge: EdgeData<T>;
|
|
36
|
-
sourceX: number;
|
|
37
|
-
sourceY: number;
|
|
38
|
-
targetX: number;
|
|
39
|
-
targetY: number;
|
|
40
|
-
}
|
|
41
|
-
interface Container {
|
|
42
|
-
width: number;
|
|
43
|
-
height: number;
|
|
44
|
-
}
|
|
45
|
-
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
46
|
-
type RenderType = (...args: any[]) => any;
|
|
47
|
-
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
48
|
-
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
49
|
-
declare enum Layer {
|
|
50
|
-
Canvas = 0,
|
|
51
|
-
Background = 4,
|
|
52
|
-
Edges = 16,
|
|
53
|
-
Nodes = 64,
|
|
54
|
-
Foreground = 256
|
|
55
|
-
}
|
|
56
|
-
interface LayerComponent<TRenderType> {
|
|
57
|
-
plugin: string;
|
|
58
|
-
name: string;
|
|
59
|
-
layer: Layer;
|
|
60
|
-
render: TRenderType;
|
|
61
|
-
/**
|
|
62
|
-
* 层级偏移量
|
|
63
|
-
* @default 0
|
|
64
|
-
* (layer >> 1, layer << 1]
|
|
65
|
-
*/
|
|
66
|
-
offset?: number;
|
|
67
|
-
}
|
|
68
|
-
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
69
|
-
name: TPluginName;
|
|
70
|
-
pluginId: string;
|
|
71
|
-
onInit?: (config: TPluginConfig) => void;
|
|
72
|
-
onConfigChange?: (config: TPluginConfig) => void;
|
|
73
|
-
onDestroy?: () => void;
|
|
74
|
-
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
75
|
-
}
|
|
76
|
-
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
77
|
-
abstract name: TPluginName;
|
|
78
|
-
constructor(__: TPluginConfig);
|
|
79
|
-
private static _instanceId;
|
|
80
|
-
private _instanceId;
|
|
81
|
-
get pluginId(): string;
|
|
82
|
-
}
|
|
83
|
-
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
84
|
-
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
85
|
-
[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;
|
|
86
|
-
} : {}));
|
|
87
|
-
/**
|
|
88
|
-
* plugin data host
|
|
89
|
-
* @example
|
|
90
|
-
* `declare module '@knotx/core' {
|
|
91
|
-
* interface PluginData {
|
|
92
|
-
* pluginName: {
|
|
93
|
-
* property: any
|
|
94
|
-
* }
|
|
95
|
-
* }
|
|
96
|
-
* }`
|
|
97
|
-
*/
|
|
98
|
-
interface PluginData {
|
|
99
|
-
}
|
|
100
|
-
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
101
|
-
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
102
|
-
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
103
|
-
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
104
|
-
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
105
|
-
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
106
|
-
interface IEngineRuntime {
|
|
107
|
-
render?: {
|
|
108
|
-
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
109
|
-
paths: string[];
|
|
110
|
-
selector?: (value: T, context?: any) => R;
|
|
111
|
-
context?: any;
|
|
112
|
-
}) => T | R;
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
8
|
/**
|
|
117
9
|
* 用户交互优先级定义
|
|
118
10
|
* 数值越大优先级越高
|
|
@@ -192,18 +84,18 @@ declare class InteractionManager {
|
|
|
192
84
|
}
|
|
193
85
|
|
|
194
86
|
interface EngineOptions {
|
|
195
|
-
container: Container
|
|
196
|
-
plugins?: Plugin
|
|
87
|
+
container: Container;
|
|
88
|
+
plugins?: Plugin[];
|
|
197
89
|
pluginConfig?: Record<string, any>;
|
|
198
|
-
nodes?: NodeData
|
|
199
|
-
edges?: EdgeData
|
|
200
|
-
runtime?: IEngineRuntime
|
|
90
|
+
nodes?: NodeData[];
|
|
91
|
+
edges?: EdgeData[];
|
|
92
|
+
runtime?: IEngineRuntime;
|
|
201
93
|
}
|
|
202
|
-
declare class Engine<TRenderType extends RenderType
|
|
203
|
-
readonly runtime: IEngineRuntime
|
|
94
|
+
declare class Engine<TRenderType extends RenderType = RenderType> {
|
|
95
|
+
readonly runtime: IEngineRuntime;
|
|
204
96
|
readonly interactionManager: InteractionManager;
|
|
205
|
-
readonly nodesManager: DataManager<NodeData
|
|
206
|
-
readonly edgesManager: DataManager<EdgeData
|
|
97
|
+
readonly nodesManager: DataManager<NodeData>;
|
|
98
|
+
readonly edgesManager: DataManager<EdgeData>;
|
|
207
99
|
private container$;
|
|
208
100
|
private nodes$;
|
|
209
101
|
private edges$;
|
|
@@ -212,39 +104,39 @@ declare class Engine<TRenderType extends RenderType$1 = RenderType$1> {
|
|
|
212
104
|
private nodeRenderers$;
|
|
213
105
|
private edgeRenderers$;
|
|
214
106
|
private _pluginDataContainer;
|
|
215
|
-
get container(): Container
|
|
216
|
-
set container(value: Container
|
|
217
|
-
get nodes(): NodeData
|
|
218
|
-
get edges(): EdgeData
|
|
219
|
-
get layers(): Map<number, LayerComponent
|
|
220
|
-
get plugins(): IPlugin
|
|
107
|
+
get container(): Container;
|
|
108
|
+
set container(value: Container);
|
|
109
|
+
get nodes(): NodeData<any>[];
|
|
110
|
+
get edges(): EdgeData<any>[];
|
|
111
|
+
get layers(): Map<number, LayerComponent<TRenderType>[]>;
|
|
112
|
+
get plugins(): IPlugin<string, any, RenderType>[];
|
|
221
113
|
constructor(options: EngineOptions);
|
|
222
114
|
private init;
|
|
223
115
|
private calculateEffectiveLayer;
|
|
224
|
-
getLayerComponents(layer: Layer
|
|
225
|
-
addNodePipe(pipe: DataOperationPipe<NodeData
|
|
226
|
-
addEdgePipe(pipe: DataOperationPipe<EdgeData
|
|
116
|
+
getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
|
|
117
|
+
addNodePipe(pipe: DataOperationPipe<NodeData>): void;
|
|
118
|
+
addEdgePipe(pipe: DataOperationPipe<EdgeData>): void;
|
|
227
119
|
changePluginConfig(pluginName: string, config: Record<string, any>): void;
|
|
228
|
-
dispatchNodeOperation(operation: DataOperation<NodeData
|
|
229
|
-
dispatchEdgeOperation(operation: DataOperation<EdgeData
|
|
230
|
-
getNode(id: string): NodeData
|
|
231
|
-
getNodeDraft(id: string): NodeData
|
|
232
|
-
getNodes(): NodeData
|
|
233
|
-
getNodeRenderer(type: string): NodeRenderType
|
|
234
|
-
getEdge(id: string): EdgeData
|
|
235
|
-
getEdgeDraft(id: string): EdgeData
|
|
236
|
-
getEdges(): EdgeData
|
|
237
|
-
getEdgeRenderer(type: string): EdgeRenderType
|
|
238
|
-
registerPluginData<T extends keyof PluginData
|
|
239
|
-
registerNodeRenderer(type: string, renderer: NodeRenderType
|
|
240
|
-
registerEdgeRenderer(type: string, renderer: EdgeRenderType
|
|
120
|
+
dispatchNodeOperation(operation: DataOperation<NodeData>): void;
|
|
121
|
+
dispatchEdgeOperation(operation: DataOperation<EdgeData>): void;
|
|
122
|
+
getNode(id: string): NodeData | undefined;
|
|
123
|
+
getNodeDraft(id: string): NodeData | undefined;
|
|
124
|
+
getNodes(): NodeData[];
|
|
125
|
+
getNodeRenderer(type: string): NodeRenderType | undefined;
|
|
126
|
+
getEdge(id: string): EdgeData | undefined;
|
|
127
|
+
getEdgeDraft(id: string): EdgeData | undefined;
|
|
128
|
+
getEdges(): EdgeData[];
|
|
129
|
+
getEdgeRenderer(type: string): EdgeRenderType | undefined;
|
|
130
|
+
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;
|
|
241
133
|
canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority$1): boolean;
|
|
242
134
|
startInteraction(pluginId: string, type: string, priority: InteractionPriority$1): void;
|
|
243
135
|
endInteraction(pluginId: string, type: string): void;
|
|
244
136
|
destroy(): void;
|
|
245
137
|
}
|
|
246
138
|
|
|
247
|
-
declare function getLayerRenders<TRenderType extends RenderType
|
|
139
|
+
declare function getLayerRenders<TRenderType extends RenderType = RenderType>(plugin: IPlugin): LayerComponent<TRenderType>[];
|
|
248
140
|
|
|
249
141
|
/**
|
|
250
142
|
* Runtime 类
|
|
@@ -307,4 +199,4 @@ declare function use<T, TContext>(hook: () => {
|
|
|
307
199
|
__contextValue__: TContext;
|
|
308
200
|
}, context: TContext): T;
|
|
309
201
|
|
|
310
|
-
export {
|
|
202
|
+
export { Engine, type EngineOptions, type Interaction, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
|
|
@@ -1,33 +1,12 @@
|
|
|
1
|
+
export { BasePlugin, Layer } from './definition.js';
|
|
1
2
|
import { set, get } from 'lodash-es';
|
|
2
3
|
import { BehaviorSubject, identity } from 'rxjs';
|
|
3
|
-
import { Layer
|
|
4
|
+
import { Layer } from '@knotx/core';
|
|
4
5
|
import { getSymbol } from '@knotx/utils';
|
|
5
6
|
export * from '@knotx/utils';
|
|
6
7
|
import { DataManager } from '@knotx/data';
|
|
7
8
|
export * from '@knotx/data';
|
|
8
9
|
|
|
9
|
-
var __defProp$4 = Object.defineProperty;
|
|
10
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __publicField$3 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
|
12
|
-
var Layer = /* @__PURE__ */ ((Layer2) => {
|
|
13
|
-
Layer2[Layer2["Canvas"] = 0] = "Canvas";
|
|
14
|
-
Layer2[Layer2["Background"] = 4] = "Background";
|
|
15
|
-
Layer2[Layer2["Edges"] = 16] = "Edges";
|
|
16
|
-
Layer2[Layer2["Nodes"] = 64] = "Nodes";
|
|
17
|
-
Layer2[Layer2["Foreground"] = 256] = "Foreground";
|
|
18
|
-
return Layer2;
|
|
19
|
-
})(Layer || {});
|
|
20
|
-
const _BasePlugin = class _BasePlugin {
|
|
21
|
-
constructor(__) {
|
|
22
|
-
__publicField$3(this, "_instanceId", _BasePlugin._instanceId++);
|
|
23
|
-
}
|
|
24
|
-
get pluginId() {
|
|
25
|
-
return `${this.name}:${this._instanceId}`;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
__publicField$3(_BasePlugin, "_instanceId", 0);
|
|
29
|
-
let BasePlugin = _BasePlugin;
|
|
30
|
-
|
|
31
10
|
var __defProp$3 = Object.defineProperty;
|
|
32
11
|
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
33
12
|
var __publicField$2 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
|
|
@@ -145,7 +124,7 @@ function getLayerRenders(plugin) {
|
|
|
145
124
|
components.push({
|
|
146
125
|
plugin: plugin.name,
|
|
147
126
|
name: `${plugin.name}:render`,
|
|
148
|
-
layer: Layer
|
|
127
|
+
layer: Layer.Foreground,
|
|
149
128
|
render: plugin.render.bind(plugin)
|
|
150
129
|
});
|
|
151
130
|
}
|
|
@@ -391,4 +370,4 @@ function use(hook, context) {
|
|
|
391
370
|
return Runtime.getInstance().runInContext("render", hook, context);
|
|
392
371
|
}
|
|
393
372
|
|
|
394
|
-
export {
|
|
373
|
+
export { Engine, InteractionManager, InteractionPriority, Runtime, getLayerRenders, use };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Core for Knotx",
|
|
5
5
|
"author": "boenfu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,22 +17,27 @@
|
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
|
-
"import": "./dist/index.
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
21
|
"require": "./dist/index.cjs"
|
|
22
22
|
},
|
|
23
23
|
"./utils": {
|
|
24
24
|
"types": "./dist/utils.d.ts",
|
|
25
|
-
"import": "./dist/utils.
|
|
25
|
+
"import": "./dist/utils.js",
|
|
26
26
|
"require": "./dist/utils.cjs"
|
|
27
27
|
},
|
|
28
28
|
"./data": {
|
|
29
29
|
"types": "./dist/data.d.ts",
|
|
30
|
-
"import": "./dist/data.
|
|
30
|
+
"import": "./dist/data.js",
|
|
31
31
|
"require": "./dist/data.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./definition": {
|
|
34
|
+
"types": "./dist/definition.d.ts",
|
|
35
|
+
"import": "./dist/definition.js",
|
|
36
|
+
"require": "./dist/definition.cjs"
|
|
32
37
|
}
|
|
33
38
|
},
|
|
34
39
|
"main": "./dist/index.cjs",
|
|
35
|
-
"module": "./dist/index.
|
|
40
|
+
"module": "./dist/index.js",
|
|
36
41
|
"types": "./dist/index.d.ts",
|
|
37
42
|
"files": [
|
|
38
43
|
"dist"
|
|
@@ -40,17 +45,17 @@
|
|
|
40
45
|
"dependencies": {
|
|
41
46
|
"lodash-es": "^4.17.21",
|
|
42
47
|
"rxjs": "^7.8.1",
|
|
43
|
-
"@knotx/
|
|
44
|
-
"@knotx/
|
|
48
|
+
"@knotx/utils": "0.2.3",
|
|
49
|
+
"@knotx/data": "0.2.3"
|
|
45
50
|
},
|
|
46
51
|
"devDependencies": {
|
|
47
52
|
"@types/lodash-es": "^4.17.12",
|
|
48
|
-
"@knotx/build-config": "0.2.
|
|
49
|
-
"@knotx/
|
|
50
|
-
"@knotx/
|
|
53
|
+
"@knotx/build-config": "0.2.3",
|
|
54
|
+
"@knotx/typescript-config": "0.2.3",
|
|
55
|
+
"@knotx/eslint-config": "0.2.3"
|
|
51
56
|
},
|
|
52
57
|
"scripts": {
|
|
53
|
-
"build": "unbuild
|
|
58
|
+
"build": "unbuild",
|
|
54
59
|
"dev": "unbuild --stub",
|
|
55
60
|
"lint": "eslint .",
|
|
56
61
|
"typecheck": "tsc --noEmit"
|
|
File without changes
|
|
File without changes
|