@knotx/decorators 0.0.5 → 0.0.7
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 +14 -2
- package/dist/index.d.cts +8 -3
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.mjs +14 -3
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -541,8 +541,8 @@ function OnInit(originalMethod, context) {
|
|
|
541
541
|
return;
|
|
542
542
|
}
|
|
543
543
|
context.addInitializer(function() {
|
|
544
|
-
this.onInit = () => {
|
|
545
|
-
originalMethod.call(this);
|
|
544
|
+
this.onInit = (config) => {
|
|
545
|
+
originalMethod.call(this, config);
|
|
546
546
|
};
|
|
547
547
|
});
|
|
548
548
|
}
|
|
@@ -557,6 +557,17 @@ function OnDestroy(originalMethod, context) {
|
|
|
557
557
|
};
|
|
558
558
|
});
|
|
559
559
|
}
|
|
560
|
+
function OnConfigChange(originalMethod, context) {
|
|
561
|
+
if (context.kind !== "method") {
|
|
562
|
+
console.warn("OnConfigChange decorator can only be applied to methods");
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
context.addInitializer(function() {
|
|
566
|
+
this.onConfigChange = (config) => {
|
|
567
|
+
originalMethod.call(this, config);
|
|
568
|
+
};
|
|
569
|
+
});
|
|
570
|
+
}
|
|
560
571
|
|
|
561
572
|
function observable() {
|
|
562
573
|
return function(_, context) {
|
|
@@ -585,6 +596,7 @@ function observable() {
|
|
|
585
596
|
};
|
|
586
597
|
}
|
|
587
598
|
|
|
599
|
+
exports.OnConfigChange = OnConfigChange;
|
|
588
600
|
exports.OnDestroy = OnDestroy;
|
|
589
601
|
exports.OnInit = OnInit;
|
|
590
602
|
exports.createPanelWrapper = createPanelWrapper;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RenderType, IPlugin, EdgeOperatorFunction, EdgeOperationPipe, EdgeRenderType, Engine, PluginData, Layer, VerticalAlignment, HorizontalAlignment, Container, NodeOperatorFunction, NodeOperationPipe, NodeRenderType } from '@knotx/core';
|
|
2
2
|
|
|
3
|
-
interface IInternalPlugin<TPluginName extends string = string, TRenderType extends RenderType = RenderType> extends IPlugin<TPluginName, TRenderType> {
|
|
3
|
+
interface IInternalPlugin<TPluginName extends string = string, TRenderType extends RenderType = RenderType> extends IPlugin<TPluginName, any, TRenderType> {
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
declare const edgeOperatorSymbol: unique symbol;
|
|
@@ -358,13 +358,18 @@ declare function nodeType(type: string): <TRenderType extends RenderType>(_targe
|
|
|
358
358
|
* 生命周期装饰器
|
|
359
359
|
* 在插件初始化时调用
|
|
360
360
|
*/
|
|
361
|
-
declare function OnInit<This extends IPlugin
|
|
361
|
+
declare function OnInit<TPluginConfig extends Record<string, any> | undefined, This extends IPlugin<string, TPluginConfig>>(originalMethod: (this: This, config: TPluginConfig) => void, context: ClassMethodDecoratorContext<This>): void;
|
|
362
362
|
/**
|
|
363
363
|
* 销毁装饰器
|
|
364
364
|
* 在插件销毁时调用
|
|
365
365
|
*/
|
|
366
366
|
declare function OnDestroy<This extends IPlugin>(originalMethod: (this: This) => void, context: ClassMethodDecoratorContext<This>): void;
|
|
367
|
+
/**
|
|
368
|
+
* 配置变更装饰器
|
|
369
|
+
* 在插件配置变更时调用
|
|
370
|
+
*/
|
|
371
|
+
declare function OnConfigChange<TPluginConfig extends Record<string, any> | undefined, This extends IPlugin<string, TPluginConfig>>(originalMethod: (this: This, config: TPluginConfig) => void, context: ClassMethodDecoratorContext<This>): void;
|
|
367
372
|
|
|
368
373
|
declare function observable<T>(): (_: any, context: ClassFieldDecoratorContext<IPlugin, T>) => void;
|
|
369
374
|
|
|
370
|
-
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, OnDestroy, OnInit, type PanelOffset, type PanelPosition, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|
|
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 };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RenderType, IPlugin, EdgeOperatorFunction, EdgeOperationPipe, EdgeRenderType, Engine, PluginData, Layer, VerticalAlignment, HorizontalAlignment, Container, NodeOperatorFunction, NodeOperationPipe, NodeRenderType } from '@knotx/core';
|
|
2
2
|
|
|
3
|
-
interface IInternalPlugin<TPluginName extends string = string, TRenderType extends RenderType = RenderType> extends IPlugin<TPluginName, TRenderType> {
|
|
3
|
+
interface IInternalPlugin<TPluginName extends string = string, TRenderType extends RenderType = RenderType> extends IPlugin<TPluginName, any, TRenderType> {
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
declare const edgeOperatorSymbol: unique symbol;
|
|
@@ -358,13 +358,18 @@ declare function nodeType(type: string): <TRenderType extends RenderType>(_targe
|
|
|
358
358
|
* 生命周期装饰器
|
|
359
359
|
* 在插件初始化时调用
|
|
360
360
|
*/
|
|
361
|
-
declare function OnInit<This extends IPlugin
|
|
361
|
+
declare function OnInit<TPluginConfig extends Record<string, any> | undefined, This extends IPlugin<string, TPluginConfig>>(originalMethod: (this: This, config: TPluginConfig) => void, context: ClassMethodDecoratorContext<This>): void;
|
|
362
362
|
/**
|
|
363
363
|
* 销毁装饰器
|
|
364
364
|
* 在插件销毁时调用
|
|
365
365
|
*/
|
|
366
366
|
declare function OnDestroy<This extends IPlugin>(originalMethod: (this: This) => void, context: ClassMethodDecoratorContext<This>): void;
|
|
367
|
+
/**
|
|
368
|
+
* 配置变更装饰器
|
|
369
|
+
* 在插件配置变更时调用
|
|
370
|
+
*/
|
|
371
|
+
declare function OnConfigChange<TPluginConfig extends Record<string, any> | undefined, This extends IPlugin<string, TPluginConfig>>(originalMethod: (this: This, config: TPluginConfig) => void, context: ClassMethodDecoratorContext<This>): void;
|
|
367
372
|
|
|
368
373
|
declare function observable<T>(): (_: any, context: ClassFieldDecoratorContext<IPlugin, T>) => void;
|
|
369
374
|
|
|
370
|
-
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, OnDestroy, OnInit, type PanelOffset, type PanelPosition, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RenderType, IPlugin, EdgeOperatorFunction, EdgeOperationPipe, EdgeRenderType, Engine, PluginData, Layer, VerticalAlignment, HorizontalAlignment, Container, NodeOperatorFunction, NodeOperationPipe, NodeRenderType } from '@knotx/core';
|
|
2
2
|
|
|
3
|
-
interface IInternalPlugin<TPluginName extends string = string, TRenderType extends RenderType = RenderType> extends IPlugin<TPluginName, TRenderType> {
|
|
3
|
+
interface IInternalPlugin<TPluginName extends string = string, TRenderType extends RenderType = RenderType> extends IPlugin<TPluginName, any, TRenderType> {
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
declare const edgeOperatorSymbol: unique symbol;
|
|
@@ -358,13 +358,18 @@ declare function nodeType(type: string): <TRenderType extends RenderType>(_targe
|
|
|
358
358
|
* 生命周期装饰器
|
|
359
359
|
* 在插件初始化时调用
|
|
360
360
|
*/
|
|
361
|
-
declare function OnInit<This extends IPlugin
|
|
361
|
+
declare function OnInit<TPluginConfig extends Record<string, any> | undefined, This extends IPlugin<string, TPluginConfig>>(originalMethod: (this: This, config: TPluginConfig) => void, context: ClassMethodDecoratorContext<This>): void;
|
|
362
362
|
/**
|
|
363
363
|
* 销毁装饰器
|
|
364
364
|
* 在插件销毁时调用
|
|
365
365
|
*/
|
|
366
366
|
declare function OnDestroy<This extends IPlugin>(originalMethod: (this: This) => void, context: ClassMethodDecoratorContext<This>): void;
|
|
367
|
+
/**
|
|
368
|
+
* 配置变更装饰器
|
|
369
|
+
* 在插件配置变更时调用
|
|
370
|
+
*/
|
|
371
|
+
declare function OnConfigChange<TPluginConfig extends Record<string, any> | undefined, This extends IPlugin<string, TPluginConfig>>(originalMethod: (this: This, config: TPluginConfig) => void, context: ClassMethodDecoratorContext<This>): void;
|
|
367
372
|
|
|
368
373
|
declare function observable<T>(): (_: any, context: ClassFieldDecoratorContext<IPlugin, T>) => void;
|
|
369
374
|
|
|
370
|
-
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, OnDestroy, OnInit, type PanelOffset, type PanelPosition, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|
|
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -539,8 +539,8 @@ function OnInit(originalMethod, context) {
|
|
|
539
539
|
return;
|
|
540
540
|
}
|
|
541
541
|
context.addInitializer(function() {
|
|
542
|
-
this.onInit = () => {
|
|
543
|
-
originalMethod.call(this);
|
|
542
|
+
this.onInit = (config) => {
|
|
543
|
+
originalMethod.call(this, config);
|
|
544
544
|
};
|
|
545
545
|
});
|
|
546
546
|
}
|
|
@@ -555,6 +555,17 @@ function OnDestroy(originalMethod, context) {
|
|
|
555
555
|
};
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
|
+
function OnConfigChange(originalMethod, context) {
|
|
559
|
+
if (context.kind !== "method") {
|
|
560
|
+
console.warn("OnConfigChange decorator can only be applied to methods");
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
context.addInitializer(function() {
|
|
564
|
+
this.onConfigChange = (config) => {
|
|
565
|
+
originalMethod.call(this, config);
|
|
566
|
+
};
|
|
567
|
+
});
|
|
568
|
+
}
|
|
558
569
|
|
|
559
570
|
function observable() {
|
|
560
571
|
return function(_, context) {
|
|
@@ -583,4 +594,4 @@ function observable() {
|
|
|
583
594
|
};
|
|
584
595
|
}
|
|
585
596
|
|
|
586
|
-
export { OnDestroy, OnInit, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|
|
597
|
+
export { OnConfigChange, OnDestroy, OnInit, createPanelWrapper, edgeOperator, edgePipe, edgeType, inject, layer, nodeOperator, nodePipe, nodeType, observable, panel, register };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/decorators",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"description": "Decorators for Knotx",
|
|
6
6
|
"author": "boenfu",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"lodash-es": "^4.17.21",
|
|
33
33
|
"rxjs": "^7.8.1",
|
|
34
|
-
"@knotx/core": "0.0.
|
|
34
|
+
"@knotx/core": "0.0.7"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/lodash-es": "^4.14.12",
|
|
38
|
-
"@knotx/build-config": "0.0.
|
|
39
|
-
"@knotx/eslint-config": "0.0.
|
|
40
|
-
"@knotx/jsx": "0.0.
|
|
41
|
-
"@knotx/typescript-config": "0.0.
|
|
38
|
+
"@knotx/build-config": "0.0.7",
|
|
39
|
+
"@knotx/eslint-config": "0.0.7",
|
|
40
|
+
"@knotx/jsx": "0.0.7",
|
|
41
|
+
"@knotx/typescript-config": "0.0.7"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "unbuild --failOnWarn=false",
|