@knotx/decorators 0.2.14 → 0.3.0
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 +2 -2
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -619,7 +619,7 @@ function register(property) {
|
|
|
619
619
|
};
|
|
620
620
|
}
|
|
621
621
|
|
|
622
|
-
function tool(description,
|
|
622
|
+
function tool(description, parameters) {
|
|
623
623
|
return function(_, context) {
|
|
624
624
|
if (context.static) {
|
|
625
625
|
return;
|
|
@@ -628,7 +628,7 @@ function tool(description, params) {
|
|
|
628
628
|
subscribeEngine.call(this, (engine) => {
|
|
629
629
|
engine.registerPluginTool(this.name, context.name, {
|
|
630
630
|
description,
|
|
631
|
-
|
|
631
|
+
parameters,
|
|
632
632
|
func: this[context.name].bind(this)
|
|
633
633
|
});
|
|
634
634
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -191,7 +191,7 @@ interface InjectDecoratorCallableMethodType {
|
|
|
191
191
|
* @example
|
|
192
192
|
* ```
|
|
193
193
|
* @inject('getNode')
|
|
194
|
-
* getNode!: (id: string) => Node | undefined
|
|
194
|
+
* getNode!: (params: { id: string }) => Node | undefined
|
|
195
195
|
*
|
|
196
196
|
* @inject('dispatchNodeOperation')
|
|
197
197
|
* dispatchNodeOperation!: (operation: NodeOperation) => void
|
|
@@ -470,20 +470,20 @@ type InferSchemaType<T> = T extends Schema ? InferParamsFromSchema<T> : any;
|
|
|
470
470
|
* 用于装饰插件中的工具函数,使其能被 engine 和其他 plugin 调用
|
|
471
471
|
*
|
|
472
472
|
* @param description 工具函数描述
|
|
473
|
-
* @param
|
|
473
|
+
* @param parameters 工具函数参数
|
|
474
474
|
* @returns 方法装饰器函数
|
|
475
475
|
* @example
|
|
476
476
|
* ```
|
|
477
477
|
* class MyPlugin extends BasePlugin {
|
|
478
478
|
* @tool('calculateDistance')
|
|
479
|
-
* calculateDistance(
|
|
480
|
-
* const dx =
|
|
481
|
-
* const dy =
|
|
479
|
+
* calculateDistance(parameters: { x1: number, y1: number, x2: number, y2: number }): number {
|
|
480
|
+
* const dx = parameters.x2 - parameters.x1;
|
|
481
|
+
* const dy = parameters.y2 - parameters.y1;
|
|
482
482
|
* return Math.sqrt(dx * dx + dy * dy);
|
|
483
483
|
* }
|
|
484
484
|
* }
|
|
485
485
|
* ```
|
|
486
486
|
*/
|
|
487
|
-
declare function tool<TN extends keyof PluginTools, TP extends keyof PluginTools[TN], TS extends Schema>(description: string,
|
|
487
|
+
declare function tool<TN extends keyof PluginTools, TP extends keyof PluginTools[TN], TS extends Schema>(description: string, parameters: TS): (_: any, context: CMDC<Extract<TP, string>, PluginTools[TN][TP], TN>) => void;
|
|
488
488
|
|
|
489
489
|
export { type InferParamsFromSchema, type InferSchemaType, 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, type SubscribeDataKey, type SubscribeDecorator, type SubscribeDecoratorCallableDataType, type SubscribeDecoratorCallablePluginDataType, type SubscribeDecoratorSelectableDataType, type SubscribeDecoratorSelectablePluginDataType, type ToolParams, config, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register, subscribe, tool };
|
package/dist/index.d.mts
CHANGED
|
@@ -191,7 +191,7 @@ interface InjectDecoratorCallableMethodType {
|
|
|
191
191
|
* @example
|
|
192
192
|
* ```
|
|
193
193
|
* @inject('getNode')
|
|
194
|
-
* getNode!: (id: string) => Node | undefined
|
|
194
|
+
* getNode!: (params: { id: string }) => Node | undefined
|
|
195
195
|
*
|
|
196
196
|
* @inject('dispatchNodeOperation')
|
|
197
197
|
* dispatchNodeOperation!: (operation: NodeOperation) => void
|
|
@@ -470,20 +470,20 @@ type InferSchemaType<T> = T extends Schema ? InferParamsFromSchema<T> : any;
|
|
|
470
470
|
* 用于装饰插件中的工具函数,使其能被 engine 和其他 plugin 调用
|
|
471
471
|
*
|
|
472
472
|
* @param description 工具函数描述
|
|
473
|
-
* @param
|
|
473
|
+
* @param parameters 工具函数参数
|
|
474
474
|
* @returns 方法装饰器函数
|
|
475
475
|
* @example
|
|
476
476
|
* ```
|
|
477
477
|
* class MyPlugin extends BasePlugin {
|
|
478
478
|
* @tool('calculateDistance')
|
|
479
|
-
* calculateDistance(
|
|
480
|
-
* const dx =
|
|
481
|
-
* const dy =
|
|
479
|
+
* calculateDistance(parameters: { x1: number, y1: number, x2: number, y2: number }): number {
|
|
480
|
+
* const dx = parameters.x2 - parameters.x1;
|
|
481
|
+
* const dy = parameters.y2 - parameters.y1;
|
|
482
482
|
* return Math.sqrt(dx * dx + dy * dy);
|
|
483
483
|
* }
|
|
484
484
|
* }
|
|
485
485
|
* ```
|
|
486
486
|
*/
|
|
487
|
-
declare function tool<TN extends keyof PluginTools, TP extends keyof PluginTools[TN], TS extends Schema>(description: string,
|
|
487
|
+
declare function tool<TN extends keyof PluginTools, TP extends keyof PluginTools[TN], TS extends Schema>(description: string, parameters: TS): (_: any, context: CMDC<Extract<TP, string>, PluginTools[TN][TP], TN>) => void;
|
|
488
488
|
|
|
489
489
|
export { type InferParamsFromSchema, type InferSchemaType, 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, type SubscribeDataKey, type SubscribeDecorator, type SubscribeDecoratorCallableDataType, type SubscribeDecoratorCallablePluginDataType, type SubscribeDecoratorSelectableDataType, type SubscribeDecoratorSelectablePluginDataType, type ToolParams, config, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register, subscribe, tool };
|
package/dist/index.d.ts
CHANGED
|
@@ -191,7 +191,7 @@ interface InjectDecoratorCallableMethodType {
|
|
|
191
191
|
* @example
|
|
192
192
|
* ```
|
|
193
193
|
* @inject('getNode')
|
|
194
|
-
* getNode!: (id: string) => Node | undefined
|
|
194
|
+
* getNode!: (params: { id: string }) => Node | undefined
|
|
195
195
|
*
|
|
196
196
|
* @inject('dispatchNodeOperation')
|
|
197
197
|
* dispatchNodeOperation!: (operation: NodeOperation) => void
|
|
@@ -470,20 +470,20 @@ type InferSchemaType<T> = T extends Schema ? InferParamsFromSchema<T> : any;
|
|
|
470
470
|
* 用于装饰插件中的工具函数,使其能被 engine 和其他 plugin 调用
|
|
471
471
|
*
|
|
472
472
|
* @param description 工具函数描述
|
|
473
|
-
* @param
|
|
473
|
+
* @param parameters 工具函数参数
|
|
474
474
|
* @returns 方法装饰器函数
|
|
475
475
|
* @example
|
|
476
476
|
* ```
|
|
477
477
|
* class MyPlugin extends BasePlugin {
|
|
478
478
|
* @tool('calculateDistance')
|
|
479
|
-
* calculateDistance(
|
|
480
|
-
* const dx =
|
|
481
|
-
* const dy =
|
|
479
|
+
* calculateDistance(parameters: { x1: number, y1: number, x2: number, y2: number }): number {
|
|
480
|
+
* const dx = parameters.x2 - parameters.x1;
|
|
481
|
+
* const dy = parameters.y2 - parameters.y1;
|
|
482
482
|
* return Math.sqrt(dx * dx + dy * dy);
|
|
483
483
|
* }
|
|
484
484
|
* }
|
|
485
485
|
* ```
|
|
486
486
|
*/
|
|
487
|
-
declare function tool<TN extends keyof PluginTools, TP extends keyof PluginTools[TN], TS extends Schema>(description: string,
|
|
487
|
+
declare function tool<TN extends keyof PluginTools, TP extends keyof PluginTools[TN], TS extends Schema>(description: string, parameters: TS): (_: any, context: CMDC<Extract<TP, string>, PluginTools[TN][TP], TN>) => void;
|
|
488
488
|
|
|
489
489
|
export { type InferParamsFromSchema, type InferSchemaType, 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, type SubscribeDataKey, type SubscribeDecorator, type SubscribeDecoratorCallableDataType, type SubscribeDecoratorCallablePluginDataType, type SubscribeDecoratorSelectableDataType, type SubscribeDecoratorSelectablePluginDataType, type ToolParams, config, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register, subscribe, tool };
|
package/dist/index.js
CHANGED
|
@@ -617,7 +617,7 @@ function register(property) {
|
|
|
617
617
|
};
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
-
function tool(description,
|
|
620
|
+
function tool(description, parameters) {
|
|
621
621
|
return function(_, context) {
|
|
622
622
|
if (context.static) {
|
|
623
623
|
return;
|
|
@@ -626,7 +626,7 @@ function tool(description, params) {
|
|
|
626
626
|
subscribeEngine.call(this, (engine) => {
|
|
627
627
|
engine.registerPluginTool(this.name, context.name, {
|
|
628
628
|
description,
|
|
629
|
-
|
|
629
|
+
parameters,
|
|
630
630
|
func: this[context.name].bind(this)
|
|
631
631
|
});
|
|
632
632
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/decorators",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Decorators for Knotx",
|
|
5
5
|
"author": "boenfu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@knotx/jsx": "0.
|
|
31
|
+
"@knotx/jsx": "0.3.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"jsonschema": "^1.5.0",
|
|
35
35
|
"lodash-es": "^4.17.21",
|
|
36
36
|
"rxjs": "^7.8.1",
|
|
37
|
-
"@knotx/core": "0.
|
|
37
|
+
"@knotx/core": "0.3.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/lodash-es": "^4.14.12",
|
|
41
|
-
"@knotx/build-config": "0.
|
|
42
|
-
"@knotx/eslint-config": "0.
|
|
43
|
-
"@knotx/jsx": "0.
|
|
44
|
-
"@knotx/typescript-config": "0.
|
|
41
|
+
"@knotx/build-config": "0.3.0",
|
|
42
|
+
"@knotx/eslint-config": "0.3.0",
|
|
43
|
+
"@knotx/jsx": "0.3.0",
|
|
44
|
+
"@knotx/typescript-config": "0.3.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "unbuild",
|