@knotx/decorators 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/index.cjs +170 -203
- package/dist/index.d.cts +60 -58
- package/dist/index.d.mts +60 -58
- package/dist/index.d.ts +60 -58
- package/dist/index.js +170 -204
- package/package.json +7 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { RenderType, IPlugin, EdgeOperatorFunction, EdgeOperationPipe, EdgeRenderType, Engine, PluginData, Layer, VerticalAlignment, HorizontalAlignment, Container, NodeOperatorFunction, NodeOperationPipe, NodeRenderType } from '@knotx/core';
|
|
1
|
+
import { BasePlugin, RenderType, IPlugin, EdgeOperatorFunction, EdgeOperationPipe, EdgeRenderType, Engine, PluginData, Layer, VerticalAlignment, HorizontalAlignment, Container, NodeOperatorFunction, NodeOperationPipe, NodeRenderType } from '@knotx/core';
|
|
2
2
|
|
|
3
3
|
interface IInternalPlugin<TPluginName extends string = string, TRenderType extends RenderType = RenderType> extends IPlugin<TPluginName, any, TRenderType> {
|
|
4
4
|
}
|
|
5
|
+
type CMDC<TK extends string, TM extends (...args: any[]) => any, TN extends string = string, TC extends Record<string, any> | undefined = any> = ClassMethodDecoratorContext<{
|
|
6
|
+
[key in TK]: TM;
|
|
7
|
+
} & BasePlugin<TN, TC, RenderType> & IPlugin<TN, TC, RenderType>, TM> & {
|
|
8
|
+
name: TK;
|
|
9
|
+
};
|
|
10
|
+
type CFDC<TK extends string, TV, TN extends string = string, TC extends Record<string, any> | undefined = any> = ClassFieldDecoratorContext<{
|
|
11
|
+
[key in TK]: TV;
|
|
12
|
+
} & BasePlugin<TN, TC, RenderType> & IPlugin<TN, TC, RenderType>, TV> & {
|
|
13
|
+
name: TK;
|
|
14
|
+
};
|
|
5
15
|
|
|
6
|
-
declare const edgeOperatorSymbol: unique symbol;
|
|
7
|
-
declare module '../internal' {
|
|
8
|
-
interface IInternalPlugin {
|
|
9
|
-
[edgeOperatorSymbol]?: Record<string | symbol, EdgeOperatorFunction>;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
16
|
/**
|
|
13
17
|
* 边操作装饰器
|
|
14
18
|
* 用于声明一个方法作为边操作函数
|
|
@@ -30,14 +34,8 @@ declare module '../internal' {
|
|
|
30
34
|
* }
|
|
31
35
|
* ```
|
|
32
36
|
*/
|
|
33
|
-
declare function edgeOperator
|
|
37
|
+
declare function edgeOperator<K extends string, V extends EdgeOperatorFunction>(): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
34
38
|
|
|
35
|
-
declare const edgePipeSymbol: unique symbol;
|
|
36
|
-
declare module '../internal' {
|
|
37
|
-
interface IInternalPlugin {
|
|
38
|
-
[edgePipeSymbol]?: Record<string | symbol, EdgeOperationPipe<any>>;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
39
|
/**
|
|
42
40
|
* 边操作管道装饰器
|
|
43
41
|
* 用于声明一个方法作为边操作管道,在边操作执行前后进行处理
|
|
@@ -62,15 +60,23 @@ declare module '../internal' {
|
|
|
62
60
|
* }
|
|
63
61
|
* ```
|
|
64
62
|
*/
|
|
65
|
-
declare function edgePipe(): <
|
|
63
|
+
declare function edgePipe<K extends string>(): <T, V extends (...args: any[]) => EdgeOperationPipe<T>>(_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
/**
|
|
66
|
+
* 连线渲染器装饰器
|
|
67
|
+
* 用于声明一个方法作为连线渲染器
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* class MyPlugin extends BasePlugin {
|
|
72
|
+
* @edgeType('my-edge')
|
|
73
|
+
* renderEdge() {
|
|
74
|
+
* return <div>My Edge</div>
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare function edgeType<K extends string, T extends string, V extends EdgeRenderType>(type: T): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
74
80
|
|
|
75
81
|
type InjectableDataKey = keyof {
|
|
76
82
|
[K in keyof Engine as Engine[K] extends (...args: any[]) => any ? never : K]: Engine[K];
|
|
@@ -235,20 +241,14 @@ declare const inject: InjectDecorator;
|
|
|
235
241
|
* @returns 类字段或 getter 装饰器函数
|
|
236
242
|
* @example
|
|
237
243
|
* ```
|
|
238
|
-
* //
|
|
244
|
+
* // 注册字段
|
|
239
245
|
* @register('canUndo')
|
|
240
246
|
* canUndo = false
|
|
241
|
-
*
|
|
242
|
-
* // 注册计算属性
|
|
243
|
-
* @register('ref')
|
|
244
|
-
* get ref() {
|
|
245
|
-
* return this
|
|
246
|
-
* }
|
|
247
247
|
* ```
|
|
248
248
|
*/
|
|
249
|
-
declare function register<
|
|
249
|
+
declare function register<K extends string, TN extends keyof PluginData, TP extends keyof PluginData[TN]>(property: TP): (_: any, context: CFDC<K, PluginData[TN][TP], TN>) => void;
|
|
250
250
|
|
|
251
|
-
declare function layer<
|
|
251
|
+
declare function layer<K extends string>(layer: Layer, offset?: number): (_: any, context: CMDC<K, () => void>) => void;
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
254
|
* 面板位置
|
|
@@ -283,14 +283,8 @@ declare function createPanelWrapper(position: PanelPosition, offset?: PanelOffse
|
|
|
283
283
|
* @param position 面板位置
|
|
284
284
|
* @param offset 面板偏移
|
|
285
285
|
*/
|
|
286
|
-
declare function panel<
|
|
286
|
+
declare function panel<K extends string>(position: PanelPosition, offset?: PanelOffset): (_: any, context: CMDC<K, () => any>) => void;
|
|
287
287
|
|
|
288
|
-
declare const nodeOperatorSymbol: unique symbol;
|
|
289
|
-
declare module '../internal' {
|
|
290
|
-
interface IInternalPlugin {
|
|
291
|
-
[nodeOperatorSymbol]?: Record<string | symbol, NodeOperatorFunction>;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
288
|
/**
|
|
295
289
|
* 节点操作装饰器
|
|
296
290
|
* 用于声明一个方法作为节点操作函数
|
|
@@ -312,14 +306,8 @@ declare module '../internal' {
|
|
|
312
306
|
* }
|
|
313
307
|
* ```
|
|
314
308
|
*/
|
|
315
|
-
declare function nodeOperator
|
|
309
|
+
declare function nodeOperator<K extends string, V extends NodeOperatorFunction>(): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
316
310
|
|
|
317
|
-
declare const nodePipeSymbol: unique symbol;
|
|
318
|
-
declare module '../internal' {
|
|
319
|
-
interface IInternalPlugin {
|
|
320
|
-
[nodePipeSymbol]?: Record<string | symbol, NodeOperationPipe<any>>;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
311
|
/**
|
|
324
312
|
* 节点操作管道装饰器
|
|
325
313
|
* 用于声明一个方法作为节点操作管道,在节点操作执行前后进行处理
|
|
@@ -344,32 +332,46 @@ declare module '../internal' {
|
|
|
344
332
|
* }
|
|
345
333
|
* ```
|
|
346
334
|
*/
|
|
347
|
-
declare function nodePipe(): <
|
|
335
|
+
declare function nodePipe<K extends string>(): <T, V extends (...args: any[]) => NodeOperationPipe<T>>(_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
348
336
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
337
|
+
/**
|
|
338
|
+
* 节点类型装饰器
|
|
339
|
+
* 用于声明一个方法作为节点类型
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* class MyPlugin extends BasePlugin {
|
|
344
|
+
* @nodeType('my-node')
|
|
345
|
+
* renderNode() {
|
|
346
|
+
* return <div>My Node</div>
|
|
347
|
+
* }
|
|
348
|
+
* }
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
declare function nodeType<K extends string, T extends string, V extends NodeRenderType>(type: T): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* 配置装饰器
|
|
355
|
+
* 自动绑定 OnInit 和 OnConfigChange 生命周期函数 和 observable 装饰器
|
|
356
|
+
*/
|
|
357
|
+
declare function config<K extends string, V extends Record<string, any>>(): (_: any, context: CFDC<K, V, string, V>) => void;
|
|
356
358
|
|
|
357
359
|
/**
|
|
358
360
|
* 生命周期装饰器
|
|
359
361
|
* 在插件初始化时调用
|
|
360
362
|
*/
|
|
361
|
-
declare function OnInit<TPluginConfig extends Record<string, any> | undefined,
|
|
363
|
+
declare function OnInit<K extends string, TPluginConfig extends Record<string, any> | undefined>(_: any, context: CMDC<K, (config: TPluginConfig) => void, string, TPluginConfig> | CFDC<K, (config: TPluginConfig) => void, string, TPluginConfig>): void;
|
|
362
364
|
/**
|
|
363
365
|
* 销毁装饰器
|
|
364
366
|
* 在插件销毁时调用
|
|
365
367
|
*/
|
|
366
|
-
declare function OnDestroy<
|
|
368
|
+
declare function OnDestroy<K extends string>(_: any, context: CMDC<K, () => void> | CFDC<K, () => void>): void;
|
|
367
369
|
/**
|
|
368
370
|
* 配置变更装饰器
|
|
369
371
|
* 在插件配置变更时调用
|
|
370
372
|
*/
|
|
371
|
-
declare function OnConfigChange<TPluginConfig extends Record<string, any> | undefined,
|
|
373
|
+
declare function OnConfigChange<K extends string, TPluginConfig extends Record<string, any> | undefined>(_: any, context: CMDC<K, (config: TPluginConfig) => void, string, TPluginConfig> | CFDC<K, (config: TPluginConfig) => void, string, TPluginConfig>): void;
|
|
372
374
|
|
|
373
|
-
declare function observable<T>(): (_: any, context:
|
|
375
|
+
declare function observable<K extends string, T>(): (_: any, context: CFDC<K, T>) => void;
|
|
374
376
|
|
|
375
|
-
export { type InjectDecorator, type InjectDecoratorCallableDataType, type InjectDecoratorCallableMethodType, type InjectDecoratorCallablePluginDataType, type InjectDecoratorInjectableDataType, type InjectDecoratorInjectableMethodType, type InjectDecoratorInjectablePluginDataType, type InjectDecoratorInjectableType, type InjectWithContext, type Injectable, type InjectableDataKey, type InjectableMethodKey, OnConfigChange, OnDestroy, OnInit, type PanelOffset, type PanelPosition, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|
|
377
|
+
export { type InjectDecorator, type InjectDecoratorCallableDataType, type InjectDecoratorCallableMethodType, type InjectDecoratorCallablePluginDataType, type InjectDecoratorInjectableDataType, type InjectDecoratorInjectableMethodType, type InjectDecoratorInjectablePluginDataType, type InjectDecoratorInjectableType, type InjectWithContext, type Injectable, type InjectableDataKey, type InjectableMethodKey, OnConfigChange, OnDestroy, OnInit, type PanelOffset, type PanelPosition, config, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { RenderType, IPlugin, EdgeOperatorFunction, EdgeOperationPipe, EdgeRenderType, Engine, PluginData, Layer, VerticalAlignment, HorizontalAlignment, Container, NodeOperatorFunction, NodeOperationPipe, NodeRenderType } from '@knotx/core';
|
|
1
|
+
import { BasePlugin, RenderType, IPlugin, EdgeOperatorFunction, EdgeOperationPipe, EdgeRenderType, Engine, PluginData, Layer, VerticalAlignment, HorizontalAlignment, Container, NodeOperatorFunction, NodeOperationPipe, NodeRenderType } from '@knotx/core';
|
|
2
2
|
|
|
3
3
|
interface IInternalPlugin<TPluginName extends string = string, TRenderType extends RenderType = RenderType> extends IPlugin<TPluginName, any, TRenderType> {
|
|
4
4
|
}
|
|
5
|
+
type CMDC<TK extends string, TM extends (...args: any[]) => any, TN extends string = string, TC extends Record<string, any> | undefined = any> = ClassMethodDecoratorContext<{
|
|
6
|
+
[key in TK]: TM;
|
|
7
|
+
} & BasePlugin<TN, TC, RenderType> & IPlugin<TN, TC, RenderType>, TM> & {
|
|
8
|
+
name: TK;
|
|
9
|
+
};
|
|
10
|
+
type CFDC<TK extends string, TV, TN extends string = string, TC extends Record<string, any> | undefined = any> = ClassFieldDecoratorContext<{
|
|
11
|
+
[key in TK]: TV;
|
|
12
|
+
} & BasePlugin<TN, TC, RenderType> & IPlugin<TN, TC, RenderType>, TV> & {
|
|
13
|
+
name: TK;
|
|
14
|
+
};
|
|
5
15
|
|
|
6
|
-
declare const edgeOperatorSymbol: unique symbol;
|
|
7
|
-
declare module '../internal' {
|
|
8
|
-
interface IInternalPlugin {
|
|
9
|
-
[edgeOperatorSymbol]?: Record<string | symbol, EdgeOperatorFunction>;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
16
|
/**
|
|
13
17
|
* 边操作装饰器
|
|
14
18
|
* 用于声明一个方法作为边操作函数
|
|
@@ -30,14 +34,8 @@ declare module '../internal' {
|
|
|
30
34
|
* }
|
|
31
35
|
* ```
|
|
32
36
|
*/
|
|
33
|
-
declare function edgeOperator
|
|
37
|
+
declare function edgeOperator<K extends string, V extends EdgeOperatorFunction>(): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
34
38
|
|
|
35
|
-
declare const edgePipeSymbol: unique symbol;
|
|
36
|
-
declare module '../internal' {
|
|
37
|
-
interface IInternalPlugin {
|
|
38
|
-
[edgePipeSymbol]?: Record<string | symbol, EdgeOperationPipe<any>>;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
39
|
/**
|
|
42
40
|
* 边操作管道装饰器
|
|
43
41
|
* 用于声明一个方法作为边操作管道,在边操作执行前后进行处理
|
|
@@ -62,15 +60,23 @@ declare module '../internal' {
|
|
|
62
60
|
* }
|
|
63
61
|
* ```
|
|
64
62
|
*/
|
|
65
|
-
declare function edgePipe(): <
|
|
63
|
+
declare function edgePipe<K extends string>(): <T, V extends (...args: any[]) => EdgeOperationPipe<T>>(_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
/**
|
|
66
|
+
* 连线渲染器装饰器
|
|
67
|
+
* 用于声明一个方法作为连线渲染器
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* class MyPlugin extends BasePlugin {
|
|
72
|
+
* @edgeType('my-edge')
|
|
73
|
+
* renderEdge() {
|
|
74
|
+
* return <div>My Edge</div>
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare function edgeType<K extends string, T extends string, V extends EdgeRenderType>(type: T): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
74
80
|
|
|
75
81
|
type InjectableDataKey = keyof {
|
|
76
82
|
[K in keyof Engine as Engine[K] extends (...args: any[]) => any ? never : K]: Engine[K];
|
|
@@ -235,20 +241,14 @@ declare const inject: InjectDecorator;
|
|
|
235
241
|
* @returns 类字段或 getter 装饰器函数
|
|
236
242
|
* @example
|
|
237
243
|
* ```
|
|
238
|
-
* //
|
|
244
|
+
* // 注册字段
|
|
239
245
|
* @register('canUndo')
|
|
240
246
|
* canUndo = false
|
|
241
|
-
*
|
|
242
|
-
* // 注册计算属性
|
|
243
|
-
* @register('ref')
|
|
244
|
-
* get ref() {
|
|
245
|
-
* return this
|
|
246
|
-
* }
|
|
247
247
|
* ```
|
|
248
248
|
*/
|
|
249
|
-
declare function register<
|
|
249
|
+
declare function register<K extends string, TN extends keyof PluginData, TP extends keyof PluginData[TN]>(property: TP): (_: any, context: CFDC<K, PluginData[TN][TP], TN>) => void;
|
|
250
250
|
|
|
251
|
-
declare function layer<
|
|
251
|
+
declare function layer<K extends string>(layer: Layer, offset?: number): (_: any, context: CMDC<K, () => void>) => void;
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
254
|
* 面板位置
|
|
@@ -283,14 +283,8 @@ declare function createPanelWrapper(position: PanelPosition, offset?: PanelOffse
|
|
|
283
283
|
* @param position 面板位置
|
|
284
284
|
* @param offset 面板偏移
|
|
285
285
|
*/
|
|
286
|
-
declare function panel<
|
|
286
|
+
declare function panel<K extends string>(position: PanelPosition, offset?: PanelOffset): (_: any, context: CMDC<K, () => any>) => void;
|
|
287
287
|
|
|
288
|
-
declare const nodeOperatorSymbol: unique symbol;
|
|
289
|
-
declare module '../internal' {
|
|
290
|
-
interface IInternalPlugin {
|
|
291
|
-
[nodeOperatorSymbol]?: Record<string | symbol, NodeOperatorFunction>;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
288
|
/**
|
|
295
289
|
* 节点操作装饰器
|
|
296
290
|
* 用于声明一个方法作为节点操作函数
|
|
@@ -312,14 +306,8 @@ declare module '../internal' {
|
|
|
312
306
|
* }
|
|
313
307
|
* ```
|
|
314
308
|
*/
|
|
315
|
-
declare function nodeOperator
|
|
309
|
+
declare function nodeOperator<K extends string, V extends NodeOperatorFunction>(): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
316
310
|
|
|
317
|
-
declare const nodePipeSymbol: unique symbol;
|
|
318
|
-
declare module '../internal' {
|
|
319
|
-
interface IInternalPlugin {
|
|
320
|
-
[nodePipeSymbol]?: Record<string | symbol, NodeOperationPipe<any>>;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
311
|
/**
|
|
324
312
|
* 节点操作管道装饰器
|
|
325
313
|
* 用于声明一个方法作为节点操作管道,在节点操作执行前后进行处理
|
|
@@ -344,32 +332,46 @@ declare module '../internal' {
|
|
|
344
332
|
* }
|
|
345
333
|
* ```
|
|
346
334
|
*/
|
|
347
|
-
declare function nodePipe(): <
|
|
335
|
+
declare function nodePipe<K extends string>(): <T, V extends (...args: any[]) => NodeOperationPipe<T>>(_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
348
336
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
337
|
+
/**
|
|
338
|
+
* 节点类型装饰器
|
|
339
|
+
* 用于声明一个方法作为节点类型
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* class MyPlugin extends BasePlugin {
|
|
344
|
+
* @nodeType('my-node')
|
|
345
|
+
* renderNode() {
|
|
346
|
+
* return <div>My Node</div>
|
|
347
|
+
* }
|
|
348
|
+
* }
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
declare function nodeType<K extends string, T extends string, V extends NodeRenderType>(type: T): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* 配置装饰器
|
|
355
|
+
* 自动绑定 OnInit 和 OnConfigChange 生命周期函数 和 observable 装饰器
|
|
356
|
+
*/
|
|
357
|
+
declare function config<K extends string, V extends Record<string, any>>(): (_: any, context: CFDC<K, V, string, V>) => void;
|
|
356
358
|
|
|
357
359
|
/**
|
|
358
360
|
* 生命周期装饰器
|
|
359
361
|
* 在插件初始化时调用
|
|
360
362
|
*/
|
|
361
|
-
declare function OnInit<TPluginConfig extends Record<string, any> | undefined,
|
|
363
|
+
declare function OnInit<K extends string, TPluginConfig extends Record<string, any> | undefined>(_: any, context: CMDC<K, (config: TPluginConfig) => void, string, TPluginConfig> | CFDC<K, (config: TPluginConfig) => void, string, TPluginConfig>): void;
|
|
362
364
|
/**
|
|
363
365
|
* 销毁装饰器
|
|
364
366
|
* 在插件销毁时调用
|
|
365
367
|
*/
|
|
366
|
-
declare function OnDestroy<
|
|
368
|
+
declare function OnDestroy<K extends string>(_: any, context: CMDC<K, () => void> | CFDC<K, () => void>): void;
|
|
367
369
|
/**
|
|
368
370
|
* 配置变更装饰器
|
|
369
371
|
* 在插件配置变更时调用
|
|
370
372
|
*/
|
|
371
|
-
declare function OnConfigChange<TPluginConfig extends Record<string, any> | undefined,
|
|
373
|
+
declare function OnConfigChange<K extends string, TPluginConfig extends Record<string, any> | undefined>(_: any, context: CMDC<K, (config: TPluginConfig) => void, string, TPluginConfig> | CFDC<K, (config: TPluginConfig) => void, string, TPluginConfig>): void;
|
|
372
374
|
|
|
373
|
-
declare function observable<T>(): (_: any, context:
|
|
375
|
+
declare function observable<K extends string, T>(): (_: any, context: CFDC<K, T>) => void;
|
|
374
376
|
|
|
375
|
-
export { type InjectDecorator, type InjectDecoratorCallableDataType, type InjectDecoratorCallableMethodType, type InjectDecoratorCallablePluginDataType, type InjectDecoratorInjectableDataType, type InjectDecoratorInjectableMethodType, type InjectDecoratorInjectablePluginDataType, type InjectDecoratorInjectableType, type InjectWithContext, type Injectable, type InjectableDataKey, type InjectableMethodKey, OnConfigChange, OnDestroy, OnInit, type PanelOffset, type PanelPosition, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|
|
377
|
+
export { type InjectDecorator, type InjectDecoratorCallableDataType, type InjectDecoratorCallableMethodType, type InjectDecoratorCallablePluginDataType, type InjectDecoratorInjectableDataType, type InjectDecoratorInjectableMethodType, type InjectDecoratorInjectablePluginDataType, type InjectDecoratorInjectableType, type InjectWithContext, type Injectable, type InjectableDataKey, type InjectableMethodKey, OnConfigChange, OnDestroy, OnInit, type PanelOffset, type PanelPosition, config, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { RenderType, IPlugin, EdgeOperatorFunction, EdgeOperationPipe, EdgeRenderType, Engine, PluginData, Layer, VerticalAlignment, HorizontalAlignment, Container, NodeOperatorFunction, NodeOperationPipe, NodeRenderType } from '@knotx/core';
|
|
1
|
+
import { BasePlugin, RenderType, IPlugin, EdgeOperatorFunction, EdgeOperationPipe, EdgeRenderType, Engine, PluginData, Layer, VerticalAlignment, HorizontalAlignment, Container, NodeOperatorFunction, NodeOperationPipe, NodeRenderType } from '@knotx/core';
|
|
2
2
|
|
|
3
3
|
interface IInternalPlugin<TPluginName extends string = string, TRenderType extends RenderType = RenderType> extends IPlugin<TPluginName, any, TRenderType> {
|
|
4
4
|
}
|
|
5
|
+
type CMDC<TK extends string, TM extends (...args: any[]) => any, TN extends string = string, TC extends Record<string, any> | undefined = any> = ClassMethodDecoratorContext<{
|
|
6
|
+
[key in TK]: TM;
|
|
7
|
+
} & BasePlugin<TN, TC, RenderType> & IPlugin<TN, TC, RenderType>, TM> & {
|
|
8
|
+
name: TK;
|
|
9
|
+
};
|
|
10
|
+
type CFDC<TK extends string, TV, TN extends string = string, TC extends Record<string, any> | undefined = any> = ClassFieldDecoratorContext<{
|
|
11
|
+
[key in TK]: TV;
|
|
12
|
+
} & BasePlugin<TN, TC, RenderType> & IPlugin<TN, TC, RenderType>, TV> & {
|
|
13
|
+
name: TK;
|
|
14
|
+
};
|
|
5
15
|
|
|
6
|
-
declare const edgeOperatorSymbol: unique symbol;
|
|
7
|
-
declare module '../internal' {
|
|
8
|
-
interface IInternalPlugin {
|
|
9
|
-
[edgeOperatorSymbol]?: Record<string | symbol, EdgeOperatorFunction>;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
16
|
/**
|
|
13
17
|
* 边操作装饰器
|
|
14
18
|
* 用于声明一个方法作为边操作函数
|
|
@@ -30,14 +34,8 @@ declare module '../internal' {
|
|
|
30
34
|
* }
|
|
31
35
|
* ```
|
|
32
36
|
*/
|
|
33
|
-
declare function edgeOperator
|
|
37
|
+
declare function edgeOperator<K extends string, V extends EdgeOperatorFunction>(): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
34
38
|
|
|
35
|
-
declare const edgePipeSymbol: unique symbol;
|
|
36
|
-
declare module '../internal' {
|
|
37
|
-
interface IInternalPlugin {
|
|
38
|
-
[edgePipeSymbol]?: Record<string | symbol, EdgeOperationPipe<any>>;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
39
|
/**
|
|
42
40
|
* 边操作管道装饰器
|
|
43
41
|
* 用于声明一个方法作为边操作管道,在边操作执行前后进行处理
|
|
@@ -62,15 +60,23 @@ declare module '../internal' {
|
|
|
62
60
|
* }
|
|
63
61
|
* ```
|
|
64
62
|
*/
|
|
65
|
-
declare function edgePipe(): <
|
|
63
|
+
declare function edgePipe<K extends string>(): <T, V extends (...args: any[]) => EdgeOperationPipe<T>>(_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
/**
|
|
66
|
+
* 连线渲染器装饰器
|
|
67
|
+
* 用于声明一个方法作为连线渲染器
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* class MyPlugin extends BasePlugin {
|
|
72
|
+
* @edgeType('my-edge')
|
|
73
|
+
* renderEdge() {
|
|
74
|
+
* return <div>My Edge</div>
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare function edgeType<K extends string, T extends string, V extends EdgeRenderType>(type: T): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
74
80
|
|
|
75
81
|
type InjectableDataKey = keyof {
|
|
76
82
|
[K in keyof Engine as Engine[K] extends (...args: any[]) => any ? never : K]: Engine[K];
|
|
@@ -235,20 +241,14 @@ declare const inject: InjectDecorator;
|
|
|
235
241
|
* @returns 类字段或 getter 装饰器函数
|
|
236
242
|
* @example
|
|
237
243
|
* ```
|
|
238
|
-
* //
|
|
244
|
+
* // 注册字段
|
|
239
245
|
* @register('canUndo')
|
|
240
246
|
* canUndo = false
|
|
241
|
-
*
|
|
242
|
-
* // 注册计算属性
|
|
243
|
-
* @register('ref')
|
|
244
|
-
* get ref() {
|
|
245
|
-
* return this
|
|
246
|
-
* }
|
|
247
247
|
* ```
|
|
248
248
|
*/
|
|
249
|
-
declare function register<
|
|
249
|
+
declare function register<K extends string, TN extends keyof PluginData, TP extends keyof PluginData[TN]>(property: TP): (_: any, context: CFDC<K, PluginData[TN][TP], TN>) => void;
|
|
250
250
|
|
|
251
|
-
declare function layer<
|
|
251
|
+
declare function layer<K extends string>(layer: Layer, offset?: number): (_: any, context: CMDC<K, () => void>) => void;
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
254
|
* 面板位置
|
|
@@ -283,14 +283,8 @@ declare function createPanelWrapper(position: PanelPosition, offset?: PanelOffse
|
|
|
283
283
|
* @param position 面板位置
|
|
284
284
|
* @param offset 面板偏移
|
|
285
285
|
*/
|
|
286
|
-
declare function panel<
|
|
286
|
+
declare function panel<K extends string>(position: PanelPosition, offset?: PanelOffset): (_: any, context: CMDC<K, () => any>) => void;
|
|
287
287
|
|
|
288
|
-
declare const nodeOperatorSymbol: unique symbol;
|
|
289
|
-
declare module '../internal' {
|
|
290
|
-
interface IInternalPlugin {
|
|
291
|
-
[nodeOperatorSymbol]?: Record<string | symbol, NodeOperatorFunction>;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
288
|
/**
|
|
295
289
|
* 节点操作装饰器
|
|
296
290
|
* 用于声明一个方法作为节点操作函数
|
|
@@ -312,14 +306,8 @@ declare module '../internal' {
|
|
|
312
306
|
* }
|
|
313
307
|
* ```
|
|
314
308
|
*/
|
|
315
|
-
declare function nodeOperator
|
|
309
|
+
declare function nodeOperator<K extends string, V extends NodeOperatorFunction>(): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
316
310
|
|
|
317
|
-
declare const nodePipeSymbol: unique symbol;
|
|
318
|
-
declare module '../internal' {
|
|
319
|
-
interface IInternalPlugin {
|
|
320
|
-
[nodePipeSymbol]?: Record<string | symbol, NodeOperationPipe<any>>;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
311
|
/**
|
|
324
312
|
* 节点操作管道装饰器
|
|
325
313
|
* 用于声明一个方法作为节点操作管道,在节点操作执行前后进行处理
|
|
@@ -344,32 +332,46 @@ declare module '../internal' {
|
|
|
344
332
|
* }
|
|
345
333
|
* ```
|
|
346
334
|
*/
|
|
347
|
-
declare function nodePipe(): <
|
|
335
|
+
declare function nodePipe<K extends string>(): <T, V extends (...args: any[]) => NodeOperationPipe<T>>(_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
348
336
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
337
|
+
/**
|
|
338
|
+
* 节点类型装饰器
|
|
339
|
+
* 用于声明一个方法作为节点类型
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* class MyPlugin extends BasePlugin {
|
|
344
|
+
* @nodeType('my-node')
|
|
345
|
+
* renderNode() {
|
|
346
|
+
* return <div>My Node</div>
|
|
347
|
+
* }
|
|
348
|
+
* }
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
declare function nodeType<K extends string, T extends string, V extends NodeRenderType>(type: T): (_: any, context: CMDC<K, V> | CFDC<K, V>) => void;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* 配置装饰器
|
|
355
|
+
* 自动绑定 OnInit 和 OnConfigChange 生命周期函数 和 observable 装饰器
|
|
356
|
+
*/
|
|
357
|
+
declare function config<K extends string, V extends Record<string, any>>(): (_: any, context: CFDC<K, V, string, V>) => void;
|
|
356
358
|
|
|
357
359
|
/**
|
|
358
360
|
* 生命周期装饰器
|
|
359
361
|
* 在插件初始化时调用
|
|
360
362
|
*/
|
|
361
|
-
declare function OnInit<TPluginConfig extends Record<string, any> | undefined,
|
|
363
|
+
declare function OnInit<K extends string, TPluginConfig extends Record<string, any> | undefined>(_: any, context: CMDC<K, (config: TPluginConfig) => void, string, TPluginConfig> | CFDC<K, (config: TPluginConfig) => void, string, TPluginConfig>): void;
|
|
362
364
|
/**
|
|
363
365
|
* 销毁装饰器
|
|
364
366
|
* 在插件销毁时调用
|
|
365
367
|
*/
|
|
366
|
-
declare function OnDestroy<
|
|
368
|
+
declare function OnDestroy<K extends string>(_: any, context: CMDC<K, () => void> | CFDC<K, () => void>): void;
|
|
367
369
|
/**
|
|
368
370
|
* 配置变更装饰器
|
|
369
371
|
* 在插件配置变更时调用
|
|
370
372
|
*/
|
|
371
|
-
declare function OnConfigChange<TPluginConfig extends Record<string, any> | undefined,
|
|
373
|
+
declare function OnConfigChange<K extends string, TPluginConfig extends Record<string, any> | undefined>(_: any, context: CMDC<K, (config: TPluginConfig) => void, string, TPluginConfig> | CFDC<K, (config: TPluginConfig) => void, string, TPluginConfig>): void;
|
|
372
374
|
|
|
373
|
-
declare function observable<T>(): (_: any, context:
|
|
375
|
+
declare function observable<K extends string, T>(): (_: any, context: CFDC<K, T>) => void;
|
|
374
376
|
|
|
375
|
-
export { type InjectDecorator, type InjectDecoratorCallableDataType, type InjectDecoratorCallableMethodType, type InjectDecoratorCallablePluginDataType, type InjectDecoratorInjectableDataType, type InjectDecoratorInjectableMethodType, type InjectDecoratorInjectablePluginDataType, type InjectDecoratorInjectableType, type InjectWithContext, type Injectable, type InjectableDataKey, type InjectableMethodKey, OnConfigChange, OnDestroy, OnInit, type PanelOffset, type PanelPosition, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|
|
377
|
+
export { type InjectDecorator, type InjectDecoratorCallableDataType, type InjectDecoratorCallableMethodType, type InjectDecoratorCallablePluginDataType, type InjectDecoratorInjectableDataType, type InjectDecoratorInjectableMethodType, type InjectDecoratorInjectablePluginDataType, type InjectDecoratorInjectableType, type InjectWithContext, type Injectable, type InjectableDataKey, type InjectableMethodKey, OnConfigChange, OnDestroy, OnInit, type PanelOffset, type PanelPosition, config, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|