@nasl/types 0.1.2 → 0.1.4

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/nasl.ui.ast.d.ts CHANGED
@@ -141,6 +141,7 @@ export interface SlotDeclaration {
141
141
  title: string;
142
142
  description?: string;
143
143
  tsType: string;
144
+ params: Array<Param>;
144
145
  emptyBackground?: string;
145
146
  snippets: Array<ViewBlockWithImage>;
146
147
  }
@@ -180,6 +181,7 @@ export interface BooleanLiteral {
180
181
  export interface StringLiteral {
181
182
  concept: 'StringLiteral';
182
183
  value: string;
184
+ i18nKey: string;
183
185
  }
184
186
 
185
187
  /**
@@ -257,21 +259,13 @@ export interface DefaultValue {
257
259
  */
258
260
  export type LogicItem = NullLiteral | BooleanLiteral | StringLiteral | NumericLiteral | NewList;
259
261
 
260
- /**
261
- * 类型参数
262
- */
263
- export interface TypeParam {
264
- concept: 'TypeParam';
265
- name: string;
266
- }
267
-
268
262
  /**
269
263
  * 输入参数
270
264
  */
271
265
  export interface Param {
272
266
  concept: 'Param';
273
267
  name: string;
274
- description: string;
268
+ description?: string;
275
269
  typeAnnotation: TypeAnnotation;
276
270
  defaultValue?: DefaultValue;
277
271
  }
@@ -304,6 +298,14 @@ export interface StructureProperty {
304
298
  jsonName: string;
305
299
  }
306
300
 
301
+ /**
302
+ * 类型参数
303
+ */
304
+ export interface TypeParam {
305
+ concept: 'TypeParam';
306
+ name: string;
307
+ }
308
+
307
309
  /**
308
310
  * 输出参数
309
311
  */
@@ -490,11 +490,15 @@
490
490
  },
491
491
  "value": {
492
492
  "type": "string"
493
+ },
494
+ "i18nKey": {
495
+ "type": "string"
493
496
  }
494
497
  },
495
498
  "required": [
496
499
  "concept",
497
- "value"
500
+ "value",
501
+ "i18nKey"
498
502
  ],
499
503
  "additionalProperties": false,
500
504
  "description": "字符串字面量"
@@ -702,6 +706,12 @@
702
706
  "tsType": {
703
707
  "type": "string"
704
708
  },
709
+ "params": {
710
+ "type": "array",
711
+ "items": {
712
+ "$ref": "#/definitions/Param"
713
+ }
714
+ },
705
715
  "emptyBackground": {
706
716
  "type": "string"
707
717
  },
@@ -717,11 +727,40 @@
717
727
  "name",
718
728
  "title",
719
729
  "tsType",
730
+ "params",
720
731
  "snippets"
721
732
  ],
722
733
  "additionalProperties": false,
723
734
  "description": "插槽"
724
735
  },
736
+ "Param": {
737
+ "type": "object",
738
+ "properties": {
739
+ "concept": {
740
+ "type": "string",
741
+ "const": "Param"
742
+ },
743
+ "name": {
744
+ "type": "string"
745
+ },
746
+ "description": {
747
+ "type": "string"
748
+ },
749
+ "typeAnnotation": {
750
+ "$ref": "#/definitions/TypeAnnotation"
751
+ },
752
+ "defaultValue": {
753
+ "$ref": "#/definitions/DefaultValue"
754
+ }
755
+ },
756
+ "required": [
757
+ "concept",
758
+ "name",
759
+ "typeAnnotation"
760
+ ],
761
+ "additionalProperties": false,
762
+ "description": "输入参数"
763
+ },
725
764
  "ViewBlockWithImage": {
726
765
  "type": "object",
727
766
  "properties": {
@@ -819,35 +858,6 @@
819
858
  "additionalProperties": false,
820
859
  "description": "类型参数"
821
860
  },
822
- "Param": {
823
- "type": "object",
824
- "properties": {
825
- "concept": {
826
- "type": "string",
827
- "const": "Param"
828
- },
829
- "name": {
830
- "type": "string"
831
- },
832
- "description": {
833
- "type": "string"
834
- },
835
- "typeAnnotation": {
836
- "$ref": "#/definitions/TypeAnnotation"
837
- },
838
- "defaultValue": {
839
- "$ref": "#/definitions/DefaultValue"
840
- }
841
- },
842
- "required": [
843
- "concept",
844
- "name",
845
- "description",
846
- "typeAnnotation"
847
- ],
848
- "additionalProperties": false,
849
- "description": "输入参数"
850
- },
851
861
  "Return": {
852
862
  "type": "object",
853
863
  "properties": {
@@ -5,16 +5,40 @@ declare namespace nasl.ui {
5
5
  // name: '__ViewComponent';
6
6
  }
7
7
 
8
+ export class ViewComponentOptions {
9
+ // name: '__ViewComponentOptions';
10
+
11
+ @Prop({
12
+ title: '显示条件',
13
+ description: '是否展示组件',
14
+ setter: {
15
+ concept: 'SwitchSetter',
16
+ },
17
+ })
18
+ if: nasl.core.Boolean;
19
+
20
+ @Prop({
21
+ title: '工具提示',
22
+ description: '在鼠标悬停时显示的文字',
23
+ })
24
+ tooltip: nasl.core.String;
25
+ }
26
+
8
27
  export function Component(options?: ViewComponentOptions): (target: any) => void;
9
28
 
10
- export function Prop(options?: PropOptions<never, never>): (target: any, key: string) => void;
11
- export function Prop<T extends object, K extends keyof T>(options?: PropOptions<T, K>): (target: T, key: K) => void;
29
+ export function Prop(options?: PropOpts<never, never>): (target: any, key: string) => void;
30
+ export function Prop<T extends object, K extends keyof T>(options?: PropOpts<T, K>): (target: T, key: K) => void;
31
+
32
+ export function Event(options?: EventOpts): (target: any, key: string) => void;
12
33
 
13
- export function Event(options?: EventOptions): (target: any, key: string) => void;
34
+ export function Slot(options?: SlotOpts): (target: any, key: string) => void;
14
35
 
15
- export function Slot(options?: SlotOptions): (target: any, key: string) => void;
36
+ /**
37
+ * 与类型推导有关,必须将返回值类型放在第一个参数位置
38
+ */
39
+ export type SlotType<T extends (...args: Array<any>) => Array<any>> = (ret: ReturnType<T>, ...args: Parameters<T>) => ReturnType<T>;
16
40
 
17
- export function Method(options?: LogicOptions): (target: any, key: string) => void;
41
+ export function Method(options?: LogicOpts): (target: any, key: string) => void;
18
42
 
19
- export function Param(options?: ParamOptions): (target: any, key: string, paramIndex: number) => void;
43
+ export function Param(options?: ParamOpts): (target: any, key: string, paramIndex: number) => void;
20
44
  }
@@ -4,7 +4,7 @@ declare namespace nasl.ui {
4
4
  /**
5
5
  * 设置器基类
6
6
  */
7
- export type BaseSetter<T, K> = InputSetter | SwitchSetter | EnumSelectSetter<T, K> | CapsulesSetter<T, K> | NumberInputSetter | IconSetter | ImageSetter | PropertySelectSetter;
7
+ export type BaseSetter<T extends object, K extends keyof T> = InputSetter | SwitchSetter | EnumSelectSetter<T, K> | CapsulesSetter<T, K> | NumberInputSetter | IconSetter | ImageSetter | PropertySelectSetter;
8
8
 
9
9
  /**
10
10
  * 输入框设置器
@@ -25,7 +25,7 @@ declare namespace nasl.ui {
25
25
  /**
26
26
  * 枚举选择设置器
27
27
  */
28
- export interface EnumSelectSetter<T, K> {
28
+ export interface EnumSelectSetter<T extends object, K extends keyof T> {
29
29
  concept: 'EnumSelectSetter';
30
30
  options: Array<SetterOption<T, K>>;
31
31
  }
@@ -33,7 +33,7 @@ declare namespace nasl.ui {
33
33
  /**
34
34
  * 胶囊设置器
35
35
  */
36
- export interface CapsulesSetter<T, K> {
36
+ export interface CapsulesSetter<T extends object, K extends keyof T> {
37
37
  concept: 'CapsulesSetter';
38
38
  options: Array<SetterOption<T, K>>;
39
39
  }
@@ -77,7 +77,7 @@ declare namespace nasl.ui {
77
77
  /**
78
78
  * 页面组件
79
79
  */
80
- export interface ViewComponentOptions {
80
+ export interface ViewComponentOpts {
81
81
  kebabName?: string;
82
82
  title: string;
83
83
  group?: string;
@@ -89,7 +89,7 @@ declare namespace nasl.ui {
89
89
  /**
90
90
  * 组件属性
91
91
  */
92
- export interface PropOptions<T extends object, K extends keyof T> {
92
+ export interface PropOpts<T extends object, K extends keyof T> {
93
93
  title: string;
94
94
  group?: '基础信息' | '数据属性' | '主要属性' | '交互属性' | '状态属性' | '样式属性' | '工具属性';
95
95
  icon?: string;
@@ -110,7 +110,7 @@ declare namespace nasl.ui {
110
110
  /**
111
111
  * 组件事件
112
112
  */
113
- export interface EventOptions {
113
+ export interface EventOpts {
114
114
  title: string;
115
115
  description?: string;
116
116
  }
@@ -118,7 +118,7 @@ declare namespace nasl.ui {
118
118
  /**
119
119
  * 插槽
120
120
  */
121
- export interface SlotOptions {
121
+ export interface SlotOpts {
122
122
  title: string;
123
123
  description?: string;
124
124
  emptyBackground?: string;
@@ -128,11 +128,20 @@ declare namespace nasl.ui {
128
128
  /**
129
129
  * 逻辑声明
130
130
  */
131
- export interface LogicOptions {
131
+ export interface LogicOpts {
132
132
  title: string;
133
133
  description: string;
134
134
  }
135
135
 
136
+ /**
137
+ * 带分组的参数
138
+ */
139
+ export interface ParamOpts {
140
+ description?: string;
141
+ title: string;
142
+ group?: string;
143
+ }
144
+
136
145
  /**
137
146
  * 设置器枚举选项
138
147
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nasl/types",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "NASL types for TypeScript Declaration",
5
5
  "main": "index.d.ts",
6
6
  "scripts": {
package/tsconfig.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "module": "ESNext",
5
5
  "moduleResolution": "Node",
6
6
  "experimentalDecorators": true,
7
- "skipLibCheck": true,
7
+ "skipLibCheck": false,
8
8
  "strict": true,
9
9
  "strictPropertyInitialization": false,
10
10
  "rootDir": ".",