@lcap/nasl 2.20.0-beta.4 → 2.20.1-beta.1

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.
Files changed (217) hide show
  1. package/out/automate/engine/2.14-components.d.ts +1115 -0
  2. package/out/automate/engine/2.14-components.js +1087 -0
  3. package/out/automate/engine/2.14-components.js.map +1 -0
  4. package/out/automate/engine/operators.d.ts +0 -9
  5. package/out/automate/engine/viewCache.d.ts +0 -1
  6. package/out/automate/template/myProcess.d.ts +0 -1
  7. package/out/common/BaseNode.js.map +1 -1
  8. package/out/common/Command.d.ts +1 -1
  9. package/out/common/EventEmitter.d.ts +1 -1
  10. package/out/concepts/Anchor__.js.map +1 -1
  11. package/out/concepts/AnonymousFunction__.js.map +1 -1
  12. package/out/concepts/App__.js +13 -0
  13. package/out/concepts/App__.js.map +1 -1
  14. package/out/concepts/Argument__.js.map +1 -1
  15. package/out/concepts/Assignee__.js.map +1 -1
  16. package/out/concepts/AssignmentLine__.js.map +1 -1
  17. package/out/concepts/Assignment__.js.map +1 -1
  18. package/out/concepts/Attribute__.d.ts +9 -14
  19. package/out/concepts/Attribute__.js +12 -39
  20. package/out/concepts/Attribute__.js.map +1 -1
  21. package/out/concepts/BatchAssignment__.js.map +1 -1
  22. package/out/concepts/BinaryExpression__.js.map +1 -1
  23. package/out/concepts/BindAttribute__.js.map +1 -1
  24. package/out/concepts/BindDirective__.js +1 -1
  25. package/out/concepts/BindDirective__.js.map +1 -1
  26. package/out/concepts/BindEvent__.js.map +1 -1
  27. package/out/concepts/BindStyle__.js +1 -1
  28. package/out/concepts/BindStyle__.js.map +1 -1
  29. package/out/concepts/BooleanLiteral__.js.map +1 -1
  30. package/out/concepts/CallFunction__.js.map +1 -1
  31. package/out/concepts/CallInterface__.js.map +1 -1
  32. package/out/concepts/CallLogic__.js +13 -6
  33. package/out/concepts/CallLogic__.js.map +1 -1
  34. package/out/concepts/CallQueryComponent__.js.map +1 -1
  35. package/out/concepts/Comment__.js.map +1 -1
  36. package/out/concepts/CompletionProperty__.js.map +1 -1
  37. package/out/concepts/ConfigGroup__.js.map +1 -1
  38. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  39. package/out/concepts/ConfigProperty__.js +8 -6
  40. package/out/concepts/ConfigProperty__.js.map +1 -1
  41. package/out/concepts/Configuration__.js.map +1 -1
  42. package/out/concepts/Constant__.js.map +1 -1
  43. package/out/concepts/DataElement__.js.map +1 -1
  44. package/out/concepts/DataSource__.js.map +1 -1
  45. package/out/concepts/Destination__.js +1 -1
  46. package/out/concepts/Destination__.js.map +1 -1
  47. package/out/concepts/End__.js.map +1 -1
  48. package/out/concepts/EntityIndex__.d.ts +1 -1
  49. package/out/concepts/EntityIndex__.js.map +1 -1
  50. package/out/concepts/EntityProperty__.d.ts +1 -1
  51. package/out/concepts/EntityProperty__.js.map +1 -1
  52. package/out/concepts/Entity__.js.map +1 -1
  53. package/out/concepts/EnumItem__.js.map +1 -1
  54. package/out/concepts/Enum__.js.map +1 -1
  55. package/out/concepts/Event__.js.map +1 -1
  56. package/out/concepts/ExternalDestination__.js +1 -1
  57. package/out/concepts/ExternalDestination__.js.map +1 -1
  58. package/out/concepts/ForEachStatement__.js.map +1 -1
  59. package/out/concepts/FrontendLibrary__.d.ts +212 -0
  60. package/out/concepts/FrontendLibrary__.js +349 -0
  61. package/out/concepts/FrontendLibrary__.js.map +1 -0
  62. package/out/concepts/Frontend__.js.map +1 -1
  63. package/out/concepts/Function__.js.map +1 -1
  64. package/out/concepts/Identifier__.js.map +1 -1
  65. package/out/concepts/IfStatement__.js.map +1 -1
  66. package/out/concepts/InterfaceParam__.js.map +1 -1
  67. package/out/concepts/Interface__.js.map +1 -1
  68. package/out/concepts/JSBlock__.js.map +1 -1
  69. package/out/concepts/LogicItem__.js.map +1 -1
  70. package/out/concepts/Logic__.js +26 -13
  71. package/out/concepts/Logic__.js.map +1 -1
  72. package/out/concepts/MatchCase__.js.map +1 -1
  73. package/out/concepts/Match__.js.map +1 -1
  74. package/out/concepts/MemberExpression__.js.map +1 -1
  75. package/out/concepts/Module__.d.ts +49 -49
  76. package/out/concepts/Module__.js +50 -50
  77. package/out/concepts/Module__.js.map +1 -1
  78. package/out/concepts/Namespace__.js.map +1 -1
  79. package/out/concepts/NewComposite__.js.map +1 -1
  80. package/out/concepts/NewList__.js.map +1 -1
  81. package/out/concepts/NewMap__.js.map +1 -1
  82. package/out/concepts/New__.js.map +1 -1
  83. package/out/concepts/NullLiteral__.js.map +1 -1
  84. package/out/concepts/NumericLiteral__.js.map +1 -1
  85. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  86. package/out/concepts/Param__.js.map +1 -1
  87. package/out/concepts/Point__.js.map +1 -1
  88. package/out/concepts/ProcessComponent__.js.map +1 -1
  89. package/out/concepts/ProcessElement__.js.map +1 -1
  90. package/out/concepts/ProcessOutcome__.js.map +1 -1
  91. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  92. package/out/concepts/Process__.js.map +1 -1
  93. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  94. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  95. package/out/concepts/QueryFromExpression__.js.map +1 -1
  96. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  97. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  98. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  99. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  100. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  101. package/out/concepts/Rect__.js.map +1 -1
  102. package/out/concepts/Return__.js +3 -0
  103. package/out/concepts/Return__.js.map +1 -1
  104. package/out/concepts/Role__.js.map +1 -1
  105. package/out/concepts/SelectMembers__.js.map +1 -1
  106. package/out/concepts/Slot__.d.ts +16 -0
  107. package/out/concepts/Slot__.js +43 -0
  108. package/out/concepts/Slot__.js.map +1 -1
  109. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  110. package/out/concepts/Start__.js.map +1 -1
  111. package/out/concepts/StringInterpolation__.js +1 -1
  112. package/out/concepts/StringInterpolation__.js.map +1 -1
  113. package/out/concepts/StringLiteral__.js.map +1 -1
  114. package/out/concepts/StructureProperty__.js.map +1 -1
  115. package/out/concepts/Structure__.js.map +1 -1
  116. package/out/concepts/SwitchCase__.js.map +1 -1
  117. package/out/concepts/SwitchStatement__.js.map +1 -1
  118. package/out/concepts/Theme__.js.map +1 -1
  119. package/out/concepts/Transactional__.js.map +1 -1
  120. package/out/concepts/TypeAnnotation__.js +1 -1
  121. package/out/concepts/TypeAnnotation__.js.map +1 -1
  122. package/out/concepts/TypeParam__.js.map +1 -1
  123. package/out/concepts/UnaryExpression__.js.map +1 -1
  124. package/out/concepts/Unparsed__.js.map +1 -1
  125. package/out/concepts/UseComponent__.js.map +1 -1
  126. package/out/concepts/ValidationRule__.js.map +1 -1
  127. package/out/concepts/Variable__.js +3 -0
  128. package/out/concepts/Variable__.js.map +1 -1
  129. package/out/concepts/ViewBlock__.d.ts +34 -0
  130. package/out/concepts/ViewBlock__.js +82 -0
  131. package/out/concepts/ViewBlock__.js.map +1 -0
  132. package/out/concepts/ViewComponent__.d.ts +85 -0
  133. package/out/concepts/ViewComponent__.js +104 -0
  134. package/out/concepts/ViewComponent__.js.map +1 -1
  135. package/out/concepts/ViewElement__.js.map +1 -1
  136. package/out/concepts/View__.d.ts +1 -0
  137. package/out/concepts/View__.js +13 -8
  138. package/out/concepts/View__.js.map +1 -1
  139. package/out/concepts/WhileStatement__.js.map +1 -1
  140. package/out/concepts/index__.d.ts +2 -0
  141. package/out/concepts/index__.js +2 -0
  142. package/out/concepts/index__.js.map +1 -1
  143. package/out/config.d.ts +1 -1
  144. package/out/decorators/index.d.ts +2 -2
  145. package/out/generator/permission.d.ts +1 -1
  146. package/out/server/getLogics.js +12 -0
  147. package/out/server/getLogics.js.map +1 -1
  148. package/out/server/getProcesses.d.ts +3 -3
  149. package/out/server/getScope.d.ts +1 -1
  150. package/out/server/naslServer.d.ts +1 -1
  151. package/out/server/naslServer.js +70 -36
  152. package/out/server/naslServer.js.map +1 -1
  153. package/out/server/translator.js +1 -1
  154. package/out/service/storage/init.js +1 -1
  155. package/out/service/storage/init.js.map +1 -1
  156. package/out/translator/index.d.ts +1 -1
  157. package/out/translator/lsp.d.ts +3 -3
  158. package/out/utils/index.d.ts +4 -4
  159. package/package.json +1 -1
  160. package/src/concepts/App__.ts +13 -0
  161. package/src/concepts/Attribute__.ts +10 -59
  162. package/src/concepts/BindAttribute__.ts +11 -12
  163. package/src/concepts/BindDirective__.ts +16 -1
  164. package/src/concepts/BindStyle__.ts +16 -1
  165. package/src/concepts/CallLogic__.ts +12 -37
  166. package/src/concepts/ConfigProperty__.ts +8 -6
  167. package/src/concepts/Destination__.ts +19 -1
  168. package/src/concepts/ExternalDestination__.ts +6 -6
  169. package/src/concepts/FrontendLibrary__.ts +518 -0
  170. package/src/concepts/Frontend__.ts +12 -1
  171. package/src/concepts/Identifier__.ts +9 -0
  172. package/src/concepts/Logic__.ts +27 -14
  173. package/src/concepts/Module__.ts +92 -121
  174. package/src/concepts/Param__.ts +4 -0
  175. package/src/concepts/ProcessElement__.ts +23 -1
  176. package/src/concepts/Process__.ts +16 -1
  177. package/src/concepts/Return__.ts +2 -0
  178. package/src/concepts/Slot__.ts +55 -0
  179. package/src/concepts/StringInterpolation__.ts +1 -1
  180. package/src/concepts/TypeAnnotation__.ts +1 -1
  181. package/src/concepts/ValidationRule__.ts +9 -9
  182. package/src/concepts/Variable__.ts +2 -0
  183. package/src/concepts/ViewBlock__.ts +91 -0
  184. package/src/concepts/ViewComponent__.ts +199 -0
  185. package/src/concepts/View__.ts +39 -10
  186. package/src/concepts/index__.ts +2 -0
  187. package/src/server/getLogics.ts +13 -0
  188. package/src/server/naslServer.ts +66 -34
  189. package/src/server/translator.ts +1 -1
  190. package/src/service/storage/init.ts +1 -1
  191. package/yarn-error.log +2087 -0
  192. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  193. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  194. package/src/automate/engine/dist/index.dev.js +0 -517
  195. package/src/common/dist/BaseNode.js +0 -1101
  196. package/src/concepts/basics/stdlib/dist/nasl.util.js +0 -1602
  197. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +0 -24
  198. package/src/concepts/dist/BindAttribute__.js +0 -795
  199. package/src/concepts/dist/BindEvent__.js +0 -732
  200. package/src/concepts/dist/CallFunction__.js +0 -527
  201. package/src/concepts/dist/CallLogic__.js +0 -932
  202. package/src/concepts/dist/Destination__.js +0 -708
  203. package/src/concepts/dist/ExternalDestination__.js +0 -298
  204. package/src/concepts/dist/Identifier__.js +0 -311
  205. package/src/concepts/dist/StringInterpolation__.js +0 -231
  206. package/src/concepts/dist/TypeAnnotation__.js +0 -834
  207. package/src/concepts/dist/ViewElement__.js +0 -1692
  208. package/src/concepts/dist/View__.js +0 -1601
  209. package/src/generator/dist/genBundleFiles.js +0 -261
  210. package/src/generator/dist/genMetaData.js +0 -245
  211. package/src/generator/dist/permission.js +0 -405
  212. package/src/service/storage/dist/init.js +0 -579
  213. package/src/templator/dist/genEditTableBlock.js +0 -204
  214. package/src/templator/dist/genGridViewBlock.js +0 -265
  215. package/src/templator/dist/genListViewBlock.js +0 -84
  216. package/src/templator/dist/genTableBlock.js +0 -209
  217. package/src/templator/dist/utils.js +0 -527
@@ -330,12 +330,14 @@ export class ConfigProperty extends BaseNode {
330
330
  @withSourceMap()
331
331
  toEmbeddedTS(state?: TranslatorState): string {
332
332
  let code = `let ${this.name}: nasl.core.String; \n`;
333
- this.values.forEach((value) => {
334
- code += indent((state?.tabSize || 0) + 1);
335
- if (!value.value) {
336
- code += `const __${value.env}ConfigValueEmpty: any = null;\n`;
337
- }
338
- });
333
+ if (this.parentNode.name === 'custom') {
334
+ this.values.forEach((value) => {
335
+ code += indent((state?.tabSize || 0) + 1);
336
+ if (!value.value) {
337
+ code += `const __${value.env}ConfigValueEmpty: any = null;\n`;
338
+ }
339
+ });
340
+ }
339
341
  return code;
340
342
  }
341
343
 
@@ -66,6 +66,8 @@ export class Destination extends LogicItem {
66
66
  @property()
67
67
  target: string = '_self';
68
68
 
69
+
70
+
69
71
  /**
70
72
  * @param source 需要合并的部分参数
71
73
  */
@@ -79,6 +81,7 @@ export class Destination extends LogicItem {
79
81
  return super.from(source, parentNode, parentKey) as Destination;
80
82
  }
81
83
 
84
+
82
85
  /**
83
86
  * 设置viewNamespace
84
87
  */
@@ -130,6 +133,10 @@ export class Destination extends LogicItem {
130
133
  });
131
134
  }
132
135
 
136
+
137
+
138
+
139
+
133
140
  /**
134
141
  * 插入实际参数
135
142
  * @internal
@@ -162,6 +169,8 @@ export class Destination extends LogicItem {
162
169
  return argument;
163
170
  }
164
171
 
172
+
173
+
165
174
  /**
166
175
  * 插入实际参数
167
176
  * @param argumentOptions 实际参数参数
@@ -184,6 +193,8 @@ export class Destination extends LogicItem {
184
193
  return node;
185
194
  }
186
195
 
196
+
197
+
187
198
  /**
188
199
  * 添加实际参数
189
200
  * @internal
@@ -203,6 +214,8 @@ export class Destination extends LogicItem {
203
214
  return this._insertArgumentAt(options as any, index);
204
215
  }
205
216
 
217
+
218
+
206
219
  /**
207
220
  * 添加实际参数
208
221
  * @param argumentOptions 实际参数参数
@@ -226,6 +239,9 @@ export class Destination extends LogicItem {
226
239
  return node;
227
240
  }
228
241
 
242
+
243
+
244
+
229
245
  /**
230
246
  * 删除实际参数
231
247
  * @param argument 已有的实际参数实例
@@ -233,10 +249,12 @@ export class Destination extends LogicItem {
233
249
  removeArgumentInArguments(argument: Argument): void;
234
250
 
235
251
  removeArgumentInArguments(options: Argument) {
236
- const argument: Argument = options;
252
+ let argument: Argument = options;
237
253
  return argument.delete();
238
254
  }
239
255
 
256
+
257
+
240
258
  /**
241
259
  * 删除锚点参数
242
260
  * @param name 锚点参数名称
@@ -47,7 +47,7 @@ export class ExternalDestination extends LogicItem {
47
47
  @property('Anchor')
48
48
  anchor: Anchor = undefined;
49
49
 
50
-
50
+
51
51
 
52
52
  /**
53
53
  * @param source 需要合并的部分参数
@@ -62,7 +62,7 @@ export class ExternalDestination extends LogicItem {
62
62
  return super.from(source, parentNode, parentKey) as ExternalDestination;
63
63
  }
64
64
 
65
-
65
+
66
66
  /**
67
67
  * 设置外部链接
68
68
  */
@@ -105,9 +105,9 @@ export class ExternalDestination extends LogicItem {
105
105
  });
106
106
  }
107
107
 
108
+
108
109
 
109
-
110
-
110
+
111
111
 
112
112
  /**
113
113
  * 删除逻辑项
@@ -134,7 +134,7 @@ export class ExternalDestination extends LogicItem {
134
134
  return link.delete();
135
135
  }
136
136
 
137
-
137
+
138
138
 
139
139
  /**
140
140
  * 删除锚点参数
@@ -223,7 +223,7 @@ export class ExternalDestination extends LogicItem {
223
223
 
224
224
  toVue(options?: ElementToVueOptions) {
225
225
  let url = '`';
226
- const tempLink = this.link ? this.link.toVue(options) : '';
226
+ const tempLink = this.link ? this.link.toVue(options) : "''";
227
227
  url += '${';
228
228
  url += `${tempLink}`;
229
229
  url += '}';
@@ -0,0 +1,518 @@
1
+ import Namespace from './Namespace__';
2
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
3
+ //================================================================================
4
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
5
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
6
+ //================================================================================
7
+ import { EventPayload, Params } from '../common/EventEmitter';
8
+ import { concept, excludedInJSON, property } from '../decorators';
9
+
10
+ import * as utils from '../utils';
11
+ import { v4 as uuidv4 } from 'uuid';
12
+ import BaseNode from '../common/BaseNode';
13
+ import classMap from '../common/classMap';
14
+ import Logic from './Logic__';
15
+ import ViewComponent from './ViewComponent__';
16
+ import Module from './Module__';
17
+ import App from './App__';
18
+
19
+ /**
20
+ * 端包
21
+ */
22
+ @concept('端包')
23
+ export class FrontendLibrary extends BaseNode {
24
+ /**
25
+ * 产品概念
26
+ */
27
+ @property()
28
+ concept: 'FrontendLibrary' = 'FrontendLibrary';
29
+
30
+ /**
31
+ * 名称与type保持一致
32
+ */
33
+ @property()
34
+ name: 'pc' | 'h5' = undefined;
35
+
36
+ /**
37
+ * PC/H5 端
38
+ */
39
+ @property()
40
+ type: 'pc' | 'h5' = undefined;
41
+
42
+ /**
43
+ * 逻辑列表
44
+ */
45
+ @property('Logic')
46
+ logics: Array<Logic> = [];
47
+
48
+ /**
49
+ * 页面组件列表
50
+ */
51
+ @property('ViewComponent')
52
+ viewComponents: Array<ViewComponent> = [];
53
+
54
+ /**
55
+ * 祖先 Module
56
+ */
57
+ get module() {
58
+ return this.getAncestor('Module') as Module;
59
+ }
60
+ /**
61
+ * 祖先 App
62
+ */
63
+ get app() {
64
+ return this.getAncestor('App') as App;
65
+ }
66
+
67
+ /**
68
+ * @param source 需要合并的部分参数
69
+ */
70
+ constructor(source?: Partial<FrontendLibrary>) {
71
+ source = Object.assign({}, FrontendLibrary.getDefaultOptions(), source);
72
+ super(source);
73
+ super.subConstructor(source);
74
+ }
75
+
76
+ static from(source: any, parentNode?: any, parentKey?: string): FrontendLibrary {
77
+ return super.from(source, parentNode, parentKey) as FrontendLibrary;
78
+ }
79
+
80
+ /**
81
+ * 从父级删除该节点
82
+ * @internal
83
+ */
84
+ _delete() {
85
+ let params: Params = null;
86
+ if (this.parentNode) {
87
+ params = (this.parentNode as any)?.__removeFrontendLibrary?.(this);
88
+ }
89
+ return params;
90
+ }
91
+
92
+
93
+ getLogicExistingNames(excludedList: Array<Logic> = []) {
94
+ const excludedSet = new Set(excludedList);
95
+ return ((this.logics as Logic[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
96
+ }
97
+ getLogicUniqueName(name = 'logic1') {
98
+ return utils.unique(name, this.getLogicExistingNames(), undefined, true);
99
+ }
100
+
101
+ /**
102
+ * 插入逻辑
103
+ * @internal
104
+ * @param name 逻辑名称,如果不填会自动生成一个唯一名称
105
+ */
106
+ _insertLogicAt(name: string, index: number): Logic;
107
+
108
+ /**
109
+ * 插入逻辑
110
+ * @internal
111
+ * @param logicOptions 逻辑参数
112
+ */
113
+ _insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
114
+
115
+ /**
116
+ * 插入逻辑
117
+ * @internal
118
+ * @param logic 已有的逻辑实例
119
+ */
120
+ _insertLogicAt(logic: Logic, index: number): Logic;
121
+
122
+ _insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
123
+ const logicOptions: any = {};
124
+ const relationOptions = { parentNode: this, parentKey: 'logics' };
125
+ let logic: Logic;
126
+ if (!options) {
127
+ logic = Logic.from({
128
+ ...logicOptions,
129
+ name: this.getLogicUniqueName(),
130
+ }, this, 'logics');
131
+ } else if (typeof options === 'string') {
132
+ logic = Logic.from({
133
+ ...logicOptions,
134
+ name: options,
135
+ }, this, 'logics');
136
+ } else if (options instanceof Logic) {
137
+ options.ensureDelete(); // 同一实例不支持多处存在
138
+ logic = options;
139
+ Object.assign(logic, relationOptions);
140
+ } else {
141
+ logic = Logic.from({
142
+ ...logicOptions,
143
+ ...options,
144
+ }, this, 'logics');
145
+ }
146
+ this.logics.splice(index, 0, logic);
147
+ return logic;
148
+ }
149
+
150
+ /**
151
+ * 插入逻辑
152
+ * @param name 逻辑名称,如果不填会自动生成一个唯一名称
153
+ */
154
+ insertLogicAt(name: string, index: number): Logic;
155
+
156
+ /**
157
+ * 插入逻辑
158
+ * @param logicOptions 逻辑参数
159
+ */
160
+ insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
161
+
162
+ /**
163
+ * 插入逻辑
164
+ * @param logic 已有的逻辑实例
165
+ */
166
+ insertLogicAt(logic: Logic, index: number): Logic;
167
+
168
+ insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
169
+ const node = this._insertLogicAt(options as any, index);
170
+ node.create({
171
+ index,
172
+ parentNode: this,
173
+ parentKey: 'logics',
174
+ });
175
+ return node;
176
+ }
177
+
178
+ /**
179
+ * 添加逻辑
180
+ * @internal
181
+ * @param name 逻辑名称,如果不填会自动生成一个唯一名称
182
+ */
183
+ _addLogic(name?: string): Logic;
184
+
185
+ /**
186
+ * 添加逻辑
187
+ * @internal
188
+ * @param logicOptions 逻辑参数
189
+ */
190
+ _addLogic(logicOptions: Partial<Logic>): Logic;
191
+
192
+ /**
193
+ * 添加逻辑
194
+ * @internal
195
+ * @param logic 已有的逻辑实例
196
+ */
197
+ _addLogic(logic: Logic): Logic;
198
+
199
+ _addLogic(options?: string | Partial<Logic> | Logic) {
200
+ const index = this.logics.length;
201
+ return this._insertLogicAt(options as any, index);
202
+ }
203
+
204
+ /**
205
+ * 添加逻辑
206
+ * @internal
207
+ * @param name 逻辑名称,如果不填会自动生成一个唯一名称
208
+ */
209
+ addLogic(name?: string): Logic;
210
+
211
+ /**
212
+ * 添加逻辑
213
+ * @param logicOptions 逻辑参数
214
+ */
215
+ addLogic(logicOptions: Partial<Logic>): Logic;
216
+
217
+ /**
218
+ * 添加逻辑
219
+ * @param logic 已有的逻辑实例
220
+ */
221
+ addLogic(logic: Logic): Logic;
222
+
223
+ addLogic(options?: string | Partial<Logic> | Logic) {
224
+ const node = this._addLogic(options as any);
225
+ const index = this.logics.indexOf(node);
226
+ node.create({
227
+ index,
228
+ parentNode: this,
229
+ parentKey: 'logics',
230
+ });
231
+ return node;
232
+ }
233
+
234
+
235
+ getViewComponentExistingNames(excludedList: Array<ViewComponent> = []) {
236
+ const excludedSet = new Set(excludedList);
237
+ return ((this.viewComponents as ViewComponent[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
238
+ }
239
+ getViewComponentUniqueName(name = 'viewComponent1') {
240
+ return utils.unique(name, this.getViewComponentExistingNames(), undefined, false);
241
+ }
242
+
243
+ /**
244
+ * 插入页面组件
245
+ * @internal
246
+ * @param name 页面组件名称,如果不填会自动生成一个唯一名称
247
+ */
248
+ _insertViewComponentAt(name: string, index: number): ViewComponent;
249
+
250
+ /**
251
+ * 插入页面组件
252
+ * @internal
253
+ * @param viewComponentOptions 页面组件参数
254
+ */
255
+ _insertViewComponentAt(viewComponentOptions: Partial<ViewComponent>, index: number): ViewComponent;
256
+
257
+ /**
258
+ * 插入页面组件
259
+ * @internal
260
+ * @param viewComponent 已有的页面组件实例
261
+ */
262
+ _insertViewComponentAt(viewComponent: ViewComponent, index: number): ViewComponent;
263
+
264
+ _insertViewComponentAt(options: string | Partial<ViewComponent> | ViewComponent, index: number) {
265
+ const viewComponentOptions: any = {};
266
+ const relationOptions = { parentNode: this, parentKey: 'viewComponents' };
267
+ let viewComponent: ViewComponent;
268
+ if (!options) {
269
+ viewComponent = ViewComponent.from({
270
+ ...viewComponentOptions,
271
+ name: this.getViewComponentUniqueName(),
272
+ }, this, 'viewComponents');
273
+ } else if (typeof options === 'string') {
274
+ viewComponent = ViewComponent.from({
275
+ ...viewComponentOptions,
276
+ name: options,
277
+ }, this, 'viewComponents');
278
+ } else if (options instanceof ViewComponent) {
279
+ options.ensureDelete(); // 同一实例不支持多处存在
280
+ viewComponent = options;
281
+ Object.assign(viewComponent, relationOptions);
282
+ } else {
283
+ viewComponent = ViewComponent.from({
284
+ ...viewComponentOptions,
285
+ ...options,
286
+ }, this, 'viewComponents');
287
+ }
288
+ this.viewComponents.splice(index, 0, viewComponent);
289
+ return viewComponent;
290
+ }
291
+
292
+ /**
293
+ * 插入页面组件
294
+ * @param name 页面组件名称,如果不填会自动生成一个唯一名称
295
+ */
296
+ insertViewComponentAt(name: string, index: number): ViewComponent;
297
+
298
+ /**
299
+ * 插入页面组件
300
+ * @param viewComponentOptions 页面组件参数
301
+ */
302
+ insertViewComponentAt(viewComponentOptions: Partial<ViewComponent>, index: number): ViewComponent;
303
+
304
+ /**
305
+ * 插入页面组件
306
+ * @param viewComponent 已有的页面组件实例
307
+ */
308
+ insertViewComponentAt(viewComponent: ViewComponent, index: number): ViewComponent;
309
+
310
+ insertViewComponentAt(options: string | Partial<ViewComponent> | ViewComponent, index: number) {
311
+ const node = this._insertViewComponentAt(options as any, index);
312
+ node.create({
313
+ index,
314
+ parentNode: this,
315
+ parentKey: 'viewComponents',
316
+ });
317
+ return node;
318
+ }
319
+
320
+ /**
321
+ * 添加页面组件
322
+ * @internal
323
+ * @param name 页面组件名称,如果不填会自动生成一个唯一名称
324
+ */
325
+ _addViewComponent(name?: string): ViewComponent;
326
+
327
+ /**
328
+ * 添加页面组件
329
+ * @internal
330
+ * @param viewComponentOptions 页面组件参数
331
+ */
332
+ _addViewComponent(viewComponentOptions: Partial<ViewComponent>): ViewComponent;
333
+
334
+ /**
335
+ * 添加页面组件
336
+ * @internal
337
+ * @param viewComponent 已有的页面组件实例
338
+ */
339
+ _addViewComponent(viewComponent: ViewComponent): ViewComponent;
340
+
341
+ _addViewComponent(options?: string | Partial<ViewComponent> | ViewComponent) {
342
+ const index = this.viewComponents.length;
343
+ return this._insertViewComponentAt(options as any, index);
344
+ }
345
+
346
+ /**
347
+ * 添加页面组件
348
+ * @internal
349
+ * @param name 页面组件名称,如果不填会自动生成一个唯一名称
350
+ */
351
+ addViewComponent(name?: string): ViewComponent;
352
+
353
+ /**
354
+ * 添加页面组件
355
+ * @param viewComponentOptions 页面组件参数
356
+ */
357
+ addViewComponent(viewComponentOptions: Partial<ViewComponent>): ViewComponent;
358
+
359
+ /**
360
+ * 添加页面组件
361
+ * @param viewComponent 已有的页面组件实例
362
+ */
363
+ addViewComponent(viewComponent: ViewComponent): ViewComponent;
364
+
365
+ addViewComponent(options?: string | Partial<ViewComponent> | ViewComponent) {
366
+ const node = this._addViewComponent(options as any);
367
+ const index = this.viewComponents.indexOf(node);
368
+ node.create({
369
+ index,
370
+ parentNode: this,
371
+ parentKey: 'viewComponents',
372
+ });
373
+ return node;
374
+ }
375
+
376
+
377
+
378
+
379
+ /**
380
+ * 删除逻辑
381
+ * @param name 逻辑名称
382
+ */
383
+ removeLogic(name: string): void;
384
+
385
+ /**
386
+ * 删除逻辑
387
+ * @param logic 已有的逻辑实例
388
+ */
389
+ removeLogic(logic: Logic): void;
390
+
391
+ removeLogic(options: string | Logic) {
392
+ let logic: Logic;
393
+ if (typeof options === 'string') {
394
+ logic = (this.logics as Logic[]).find((item) => item.name === options);
395
+ if (!logic) {
396
+ throw new Error('找不到逻辑 ' + options);
397
+ }
398
+ } else {
399
+ logic = options;
400
+ }
401
+ return logic.delete();
402
+ }
403
+
404
+ __removeLogic(logic: Logic) {
405
+ const parentKey = logic.parentKey;
406
+ const params: Params = {
407
+ parentNode: this,
408
+ parentKey,
409
+ index: -1,
410
+ object: null,
411
+ oldObject: logic,
412
+ };
413
+ if (parentKey) {
414
+ params.parentKey = parentKey;
415
+ if (Array.isArray((this as any)[parentKey])) {
416
+ const index = (this as any)[parentKey].indexOf(logic);
417
+ ~index && (this as any)[parentKey].splice(index, 1);
418
+ params.index = index;
419
+ } else if ((this as any)[parentKey] === logic) {
420
+ params.index = 0;
421
+ (this as any)[parentKey] = undefined;
422
+ }
423
+ }
424
+ return params;
425
+ }
426
+
427
+
428
+
429
+ /**
430
+ * 删除页面组件
431
+ * @param name 页面组件名称
432
+ */
433
+ removeViewComponent(name: string): void;
434
+
435
+ /**
436
+ * 删除页面组件
437
+ * @param viewComponent 已有的页面组件实例
438
+ */
439
+ removeViewComponent(viewComponent: ViewComponent): void;
440
+
441
+ removeViewComponent(options: string | ViewComponent) {
442
+ let viewComponent: ViewComponent;
443
+ if (typeof options === 'string') {
444
+ viewComponent = (this.viewComponents as ViewComponent[]).find((item) => item.name === options);
445
+ if (!viewComponent) {
446
+ throw new Error('找不到页面组件 ' + options);
447
+ }
448
+ } else {
449
+ viewComponent = options;
450
+ }
451
+ return viewComponent.delete();
452
+ }
453
+
454
+ __removeViewComponent(viewComponent: ViewComponent) {
455
+ const parentKey = viewComponent.parentKey;
456
+ const params: Params = {
457
+ parentNode: this,
458
+ parentKey,
459
+ index: -1,
460
+ object: null,
461
+ oldObject: viewComponent,
462
+ };
463
+ if (parentKey) {
464
+ params.parentKey = parentKey;
465
+ if (Array.isArray((this as any)[parentKey])) {
466
+ const index = (this as any)[parentKey].indexOf(viewComponent);
467
+ ~index && (this as any)[parentKey].splice(index, 1);
468
+ params.index = index;
469
+ } else if ((this as any)[parentKey] === viewComponent) {
470
+ params.index = 0;
471
+ (this as any)[parentKey] = undefined;
472
+ }
473
+ }
474
+ return params;
475
+ }
476
+
477
+ //================================================================================
478
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
479
+ // 自动生成的代码已结束。下面可以手动编写。
480
+ //================================================================================
481
+ getNamespace() {
482
+ if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
483
+ const parentNamespace = (this.parentNode as Namespace).getNamespace();
484
+ const parentName = this.parentNode.name;
485
+ const arr = [parentNamespace];
486
+ if (this.parentNode.concept !== 'App' && parentName) {
487
+ arr.push(parentName);
488
+ }
489
+ return `${arr.join('.')}.frontends`;
490
+ } else
491
+ throw new Error('无法获取命名空间,请设置 parentNode!');
492
+ }
493
+
494
+ getTsNamespace() {
495
+ if (this.parentNode && (this.parentNode as Namespace).getTsNamespace) {
496
+ const parentNamespace = (this.parentNode as Namespace).getTsNamespace();
497
+ const parentName = this.parentNode.tsName || this.parentNode.name;
498
+ const arr = [parentNamespace];
499
+ if (this.parentNode.concept !== 'App' && parentName) {
500
+ arr.push(parentName);
501
+ }
502
+ return `${arr.join('.')}.frontends`;
503
+ } else
504
+ throw new Error('无法获取命名空间,请设置 parentNode!');
505
+ }
506
+
507
+ //================================================================================
508
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
509
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
510
+ //================================================================================
511
+ }
512
+
513
+ classMap.FrontendLibrary = FrontendLibrary;
514
+ export default FrontendLibrary;
515
+ //================================================================================
516
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
517
+ // 自动生成的代码已结束。下面可以手动编写。
518
+ //================================================================================