@knotx/core 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/definition.cjs +0 -14
- package/dist/definition.d.cts +4 -113
- package/dist/definition.d.mts +4 -113
- package/dist/definition.d.ts +4 -113
- package/dist/definition.js +1 -14
- package/dist/index.cjs +132 -26
- package/dist/index.d.cts +25 -10
- package/dist/index.d.mts +25 -10
- package/dist/index.d.ts +25 -10
- package/dist/index.js +133 -27
- package/dist/shared/core.BUBec6Va.d.cts +145 -0
- package/dist/shared/core.BUBec6Va.d.mts +145 -0
- package/dist/shared/core.BUBec6Va.d.ts +145 -0
- package/package.json +7 -6
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Schema } from 'jsonschema';
|
|
2
|
+
import { SubscriptionLike, BehaviorSubject } from 'rxjs';
|
|
3
|
+
import { DataOperationPipe, DataOperation } from '@knotx/data';
|
|
4
|
+
|
|
5
|
+
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
6
|
+
abstract name: TPluginName;
|
|
7
|
+
constructor(__: TPluginConfig);
|
|
8
|
+
private static _instanceId;
|
|
9
|
+
private _instanceId;
|
|
10
|
+
get pluginId(): string;
|
|
11
|
+
/**
|
|
12
|
+
* 插件生命周期中的订阅回调
|
|
13
|
+
* 可随时存入,销毁时会自动执行
|
|
14
|
+
*/
|
|
15
|
+
protected subscriptions: (SubscriptionLike | (() => void))[];
|
|
16
|
+
onDestroy(): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type HorizontalAlignment = 'left' | 'right';
|
|
20
|
+
type VerticalAlignment = 'top' | 'bottom';
|
|
21
|
+
interface NodePosition {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}
|
|
25
|
+
interface NodeMeasured {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}
|
|
29
|
+
interface NodeData<TData = any> {
|
|
30
|
+
id: string;
|
|
31
|
+
type?: string;
|
|
32
|
+
position: NodePosition;
|
|
33
|
+
measured?: NodeMeasured;
|
|
34
|
+
data: TData;
|
|
35
|
+
}
|
|
36
|
+
interface NodeProps<T = any> {
|
|
37
|
+
node: NodeData<T>;
|
|
38
|
+
}
|
|
39
|
+
interface EdgeData<TData = any> {
|
|
40
|
+
id: string;
|
|
41
|
+
source: string;
|
|
42
|
+
target: string;
|
|
43
|
+
type?: string;
|
|
44
|
+
data?: TData;
|
|
45
|
+
}
|
|
46
|
+
interface EdgeProps<T = any> {
|
|
47
|
+
edge: EdgeData<T>;
|
|
48
|
+
sourceX: number;
|
|
49
|
+
sourceY: number;
|
|
50
|
+
targetX: number;
|
|
51
|
+
targetY: number;
|
|
52
|
+
}
|
|
53
|
+
interface Container {
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
}
|
|
57
|
+
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
58
|
+
type RenderType = (...args: any[]) => any;
|
|
59
|
+
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
60
|
+
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
61
|
+
declare enum Layer {
|
|
62
|
+
Canvas = 0,
|
|
63
|
+
Background = 4,
|
|
64
|
+
Edges = 16,
|
|
65
|
+
Nodes = 64,
|
|
66
|
+
Foreground = 256
|
|
67
|
+
}
|
|
68
|
+
interface LayerComponent<TRenderType> {
|
|
69
|
+
plugin: string;
|
|
70
|
+
name: string;
|
|
71
|
+
layer: Layer;
|
|
72
|
+
render: TRenderType;
|
|
73
|
+
/**
|
|
74
|
+
* 层级偏移量
|
|
75
|
+
* @default 0
|
|
76
|
+
* (layer >> 1, layer << 1]
|
|
77
|
+
*/
|
|
78
|
+
offset?: number;
|
|
79
|
+
}
|
|
80
|
+
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
81
|
+
name: TPluginName;
|
|
82
|
+
pluginId: string;
|
|
83
|
+
description?: string;
|
|
84
|
+
onInit?: (config: TPluginConfig) => void;
|
|
85
|
+
onConfigChange?: (config: TPluginConfig) => void;
|
|
86
|
+
onDestroy?: () => void;
|
|
87
|
+
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
88
|
+
}
|
|
89
|
+
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
90
|
+
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
91
|
+
[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;
|
|
92
|
+
} : {}));
|
|
93
|
+
/**
|
|
94
|
+
* plugin data host
|
|
95
|
+
* @example
|
|
96
|
+
* `declare module '@knotx/core' {
|
|
97
|
+
* interface PluginData {
|
|
98
|
+
* pluginName: {
|
|
99
|
+
* property: any
|
|
100
|
+
* }
|
|
101
|
+
* }
|
|
102
|
+
* }`
|
|
103
|
+
*/
|
|
104
|
+
interface PluginData {
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* plugin tools host
|
|
108
|
+
* @example
|
|
109
|
+
* `declare module '@knotx/core' {
|
|
110
|
+
* interface PluginTools {
|
|
111
|
+
* pluginName: {
|
|
112
|
+
* toolName: (params: any) => any
|
|
113
|
+
* }
|
|
114
|
+
* }
|
|
115
|
+
* }`
|
|
116
|
+
*/
|
|
117
|
+
interface PluginTools {
|
|
118
|
+
}
|
|
119
|
+
interface IPluginInfo {
|
|
120
|
+
name: string;
|
|
121
|
+
description?: string;
|
|
122
|
+
}
|
|
123
|
+
interface IPluginToolInfo {
|
|
124
|
+
type: 'function';
|
|
125
|
+
name: string;
|
|
126
|
+
description: string;
|
|
127
|
+
parameters: Schema;
|
|
128
|
+
}
|
|
129
|
+
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
130
|
+
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
131
|
+
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
132
|
+
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
133
|
+
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
134
|
+
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
135
|
+
interface IEngineRuntime {
|
|
136
|
+
render?: {
|
|
137
|
+
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
138
|
+
paths: string[];
|
|
139
|
+
selector?: (value: T, context?: any) => R;
|
|
140
|
+
context?: any;
|
|
141
|
+
}) => T | R;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
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 PluginTools as f, type IPluginInfo as g, type IPluginToolInfo as h, type NodePosition as i, type NodeMeasured as j, type NodeProps as k, type EdgeProps as l, type Position as m, type PluginConfigs as n, type NodeOperationPipe as o, type EdgeOperationPipe as p, type NodeOperation as q, type EdgeOperation as r, type NodeOperatorFunction as s, type EdgeOperatorFunction as t };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Schema } from 'jsonschema';
|
|
2
|
+
import { SubscriptionLike, BehaviorSubject } from 'rxjs';
|
|
3
|
+
import { DataOperationPipe, DataOperation } from '@knotx/data';
|
|
4
|
+
|
|
5
|
+
declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
|
|
6
|
+
abstract name: TPluginName;
|
|
7
|
+
constructor(__: TPluginConfig);
|
|
8
|
+
private static _instanceId;
|
|
9
|
+
private _instanceId;
|
|
10
|
+
get pluginId(): string;
|
|
11
|
+
/**
|
|
12
|
+
* 插件生命周期中的订阅回调
|
|
13
|
+
* 可随时存入,销毁时会自动执行
|
|
14
|
+
*/
|
|
15
|
+
protected subscriptions: (SubscriptionLike | (() => void))[];
|
|
16
|
+
onDestroy(): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type HorizontalAlignment = 'left' | 'right';
|
|
20
|
+
type VerticalAlignment = 'top' | 'bottom';
|
|
21
|
+
interface NodePosition {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}
|
|
25
|
+
interface NodeMeasured {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}
|
|
29
|
+
interface NodeData<TData = any> {
|
|
30
|
+
id: string;
|
|
31
|
+
type?: string;
|
|
32
|
+
position: NodePosition;
|
|
33
|
+
measured?: NodeMeasured;
|
|
34
|
+
data: TData;
|
|
35
|
+
}
|
|
36
|
+
interface NodeProps<T = any> {
|
|
37
|
+
node: NodeData<T>;
|
|
38
|
+
}
|
|
39
|
+
interface EdgeData<TData = any> {
|
|
40
|
+
id: string;
|
|
41
|
+
source: string;
|
|
42
|
+
target: string;
|
|
43
|
+
type?: string;
|
|
44
|
+
data?: TData;
|
|
45
|
+
}
|
|
46
|
+
interface EdgeProps<T = any> {
|
|
47
|
+
edge: EdgeData<T>;
|
|
48
|
+
sourceX: number;
|
|
49
|
+
sourceY: number;
|
|
50
|
+
targetX: number;
|
|
51
|
+
targetY: number;
|
|
52
|
+
}
|
|
53
|
+
interface Container {
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
}
|
|
57
|
+
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
58
|
+
type RenderType = (...args: any[]) => any;
|
|
59
|
+
type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
|
|
60
|
+
type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
|
|
61
|
+
declare enum Layer {
|
|
62
|
+
Canvas = 0,
|
|
63
|
+
Background = 4,
|
|
64
|
+
Edges = 16,
|
|
65
|
+
Nodes = 64,
|
|
66
|
+
Foreground = 256
|
|
67
|
+
}
|
|
68
|
+
interface LayerComponent<TRenderType> {
|
|
69
|
+
plugin: string;
|
|
70
|
+
name: string;
|
|
71
|
+
layer: Layer;
|
|
72
|
+
render: TRenderType;
|
|
73
|
+
/**
|
|
74
|
+
* 层级偏移量
|
|
75
|
+
* @default 0
|
|
76
|
+
* (layer >> 1, layer << 1]
|
|
77
|
+
*/
|
|
78
|
+
offset?: number;
|
|
79
|
+
}
|
|
80
|
+
interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
|
|
81
|
+
name: TPluginName;
|
|
82
|
+
pluginId: string;
|
|
83
|
+
description?: string;
|
|
84
|
+
onInit?: (config: TPluginConfig) => void;
|
|
85
|
+
onConfigChange?: (config: TPluginConfig) => void;
|
|
86
|
+
onDestroy?: () => void;
|
|
87
|
+
render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
|
|
88
|
+
}
|
|
89
|
+
type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
|
|
90
|
+
type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
|
|
91
|
+
[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;
|
|
92
|
+
} : {}));
|
|
93
|
+
/**
|
|
94
|
+
* plugin data host
|
|
95
|
+
* @example
|
|
96
|
+
* `declare module '@knotx/core' {
|
|
97
|
+
* interface PluginData {
|
|
98
|
+
* pluginName: {
|
|
99
|
+
* property: any
|
|
100
|
+
* }
|
|
101
|
+
* }
|
|
102
|
+
* }`
|
|
103
|
+
*/
|
|
104
|
+
interface PluginData {
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* plugin tools host
|
|
108
|
+
* @example
|
|
109
|
+
* `declare module '@knotx/core' {
|
|
110
|
+
* interface PluginTools {
|
|
111
|
+
* pluginName: {
|
|
112
|
+
* toolName: (params: any) => any
|
|
113
|
+
* }
|
|
114
|
+
* }
|
|
115
|
+
* }`
|
|
116
|
+
*/
|
|
117
|
+
interface PluginTools {
|
|
118
|
+
}
|
|
119
|
+
interface IPluginInfo {
|
|
120
|
+
name: string;
|
|
121
|
+
description?: string;
|
|
122
|
+
}
|
|
123
|
+
interface IPluginToolInfo {
|
|
124
|
+
type: 'function';
|
|
125
|
+
name: string;
|
|
126
|
+
description: string;
|
|
127
|
+
parameters: Schema;
|
|
128
|
+
}
|
|
129
|
+
type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
|
|
130
|
+
type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
|
|
131
|
+
type NodeOperation<T = any> = DataOperation<NodeData<T>>;
|
|
132
|
+
type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
|
|
133
|
+
type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
|
|
134
|
+
type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
|
|
135
|
+
interface IEngineRuntime {
|
|
136
|
+
render?: {
|
|
137
|
+
getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
|
|
138
|
+
paths: string[];
|
|
139
|
+
selector?: (value: T, context?: any) => R;
|
|
140
|
+
context?: any;
|
|
141
|
+
}) => T | R;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
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 PluginTools as f, type IPluginInfo as g, type IPluginToolInfo as h, type NodePosition as i, type NodeMeasured as j, type NodeProps as k, type EdgeProps as l, type Position as m, type PluginConfigs as n, type NodeOperationPipe as o, type EdgeOperationPipe as p, type NodeOperation as q, type EdgeOperation as r, type NodeOperatorFunction as s, type EdgeOperatorFunction as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Core for Knotx",
|
|
5
5
|
"author": "boenfu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,16 +43,17 @@
|
|
|
43
43
|
"dist"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
+
"jsonschema": "^1.5.0",
|
|
46
47
|
"lodash-es": "^4.17.21",
|
|
47
48
|
"rxjs": "^7.8.1",
|
|
48
|
-
"@knotx/data": "0.2.
|
|
49
|
-
"@knotx/utils": "0.2.
|
|
49
|
+
"@knotx/data": "0.2.6",
|
|
50
|
+
"@knotx/utils": "0.2.6"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@types/lodash-es": "^4.17.12",
|
|
53
|
-
"@knotx/build-config": "0.2.
|
|
54
|
-
"@knotx/eslint-config": "0.2.
|
|
55
|
-
"@knotx/typescript-config": "0.2.
|
|
54
|
+
"@knotx/build-config": "0.2.6",
|
|
55
|
+
"@knotx/eslint-config": "0.2.6",
|
|
56
|
+
"@knotx/typescript-config": "0.2.6"
|
|
56
57
|
},
|
|
57
58
|
"scripts": {
|
|
58
59
|
"build": "unbuild",
|