@lcap/nasl 1.0.0-alpha.13 → 1.0.0-alpha.16

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 (324) hide show
  1. package/out/automate/engine/index.d.ts +1 -1
  2. package/out/automate/engine/index.js +73 -25
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/utils.js +7 -6
  5. package/out/automate/engine/utils.js.map +1 -1
  6. package/out/common/BaseNode.d.ts +5 -4
  7. package/out/common/BaseNode.js +48 -41
  8. package/out/common/BaseNode.js.map +1 -1
  9. package/out/concepts/App__.d.ts +18 -1
  10. package/out/concepts/App__.js +64 -24
  11. package/out/concepts/App__.js.map +1 -1
  12. package/out/concepts/Argument__.js +2 -2
  13. package/out/concepts/Argument__.js.map +1 -1
  14. package/out/concepts/Assignee__.d.ts +190 -0
  15. package/out/concepts/Assignee__.js +264 -0
  16. package/out/concepts/Assignee__.js.map +1 -0
  17. package/out/concepts/BinaryExpression__.js +6 -6
  18. package/out/concepts/BinaryExpression__.js.map +1 -1
  19. package/out/concepts/BindAttribute__.d.ts +19 -0
  20. package/out/concepts/BindAttribute__.js +36 -2
  21. package/out/concepts/BindAttribute__.js.map +1 -1
  22. package/out/concepts/BindDirective__.js +21 -1
  23. package/out/concepts/BindDirective__.js.map +1 -1
  24. package/out/concepts/BindEvent__.d.ts +1 -0
  25. package/out/concepts/BindEvent__.js +38 -14
  26. package/out/concepts/BindEvent__.js.map +1 -1
  27. package/out/concepts/CallFunction__.js +20 -7
  28. package/out/concepts/CallFunction__.js.map +1 -1
  29. package/out/concepts/CallInterface__.d.ts +11 -8
  30. package/out/concepts/CallInterface__.js +160 -23
  31. package/out/concepts/CallInterface__.js.map +1 -1
  32. package/out/concepts/CallLogic__.d.ts +1 -0
  33. package/out/concepts/CallLogic__.js +17 -7
  34. package/out/concepts/CallLogic__.js.map +1 -1
  35. package/out/concepts/CallQueryComponent__.d.ts +5 -1
  36. package/out/concepts/CallQueryComponent__.js +15 -11
  37. package/out/concepts/CallQueryComponent__.js.map +1 -1
  38. package/out/concepts/Comment__.js +6 -2
  39. package/out/concepts/Comment__.js.map +1 -1
  40. package/out/concepts/ConfigGroup__.js +1 -1
  41. package/out/concepts/ConfigGroup__.js.map +1 -1
  42. package/out/concepts/ConfigProperty__.js +1 -1
  43. package/out/concepts/ConfigProperty__.js.map +1 -1
  44. package/out/concepts/Configuration__.js +1 -1
  45. package/out/concepts/Configuration__.js.map +1 -1
  46. package/out/concepts/Destination__.d.ts +11 -0
  47. package/out/concepts/Destination__.js +59 -19
  48. package/out/concepts/Destination__.js.map +1 -1
  49. package/out/concepts/End__.js +10 -2
  50. package/out/concepts/End__.js.map +1 -1
  51. package/out/concepts/EntityProperty__.d.ts +7 -0
  52. package/out/concepts/EntityProperty__.js +60 -3
  53. package/out/concepts/EntityProperty__.js.map +1 -1
  54. package/out/concepts/Entity__.d.ts +4 -1
  55. package/out/concepts/Entity__.js +29 -12
  56. package/out/concepts/Entity__.js.map +1 -1
  57. package/out/concepts/Enum__.d.ts +4 -0
  58. package/out/concepts/Enum__.js +9 -6
  59. package/out/concepts/Enum__.js.map +1 -1
  60. package/out/concepts/Event__.js +1 -1
  61. package/out/concepts/Event__.js.map +1 -1
  62. package/out/concepts/ForEachStatement__.js +8 -12
  63. package/out/concepts/ForEachStatement__.js.map +1 -1
  64. package/out/concepts/Function__.js +5 -5
  65. package/out/concepts/Function__.js.map +1 -1
  66. package/out/concepts/Identifier__.js +26 -24
  67. package/out/concepts/Identifier__.js.map +1 -1
  68. package/out/concepts/IfStatement__.js +2 -2
  69. package/out/concepts/IfStatement__.js.map +1 -1
  70. package/out/concepts/InterfaceParam__.d.ts +2 -0
  71. package/out/concepts/InterfaceParam__.js +41 -21
  72. package/out/concepts/InterfaceParam__.js.map +1 -1
  73. package/out/concepts/Interface__.d.ts +3 -0
  74. package/out/concepts/Interface__.js +105 -9
  75. package/out/concepts/Interface__.js.map +1 -1
  76. package/out/concepts/LogicItem__.d.ts +2 -1
  77. package/out/concepts/LogicItem__.js +14 -0
  78. package/out/concepts/LogicItem__.js.map +1 -1
  79. package/out/concepts/Logic__.d.ts +3 -0
  80. package/out/concepts/Logic__.js +57 -16
  81. package/out/concepts/Logic__.js.map +1 -1
  82. package/out/concepts/MemberExpression__.js +13 -6
  83. package/out/concepts/MemberExpression__.js.map +1 -1
  84. package/out/concepts/Module__.d.ts +6 -0
  85. package/out/concepts/Module__.js +18 -8
  86. package/out/concepts/Module__.js.map +1 -1
  87. package/out/concepts/Namespace__.d.ts +4 -0
  88. package/out/concepts/Namespace__.js +23 -12
  89. package/out/concepts/Namespace__.js.map +1 -1
  90. package/out/concepts/Param__.d.ts +2 -1
  91. package/out/concepts/Param__.js +35 -22
  92. package/out/concepts/Param__.js.map +1 -1
  93. package/out/concepts/ProcessComponent__.js +2 -2
  94. package/out/concepts/ProcessComponent__.js.map +1 -1
  95. package/out/concepts/ProcessElement__.js +20 -18
  96. package/out/concepts/ProcessElement__.js.map +1 -1
  97. package/out/concepts/ProcessOutcome__.js +1 -1
  98. package/out/concepts/ProcessOutcome__.js.map +1 -1
  99. package/out/concepts/Process__.d.ts +6 -1
  100. package/out/concepts/Process__.js +18 -14
  101. package/out/concepts/Process__.js.map +1 -1
  102. package/out/concepts/QueryAggregateExpression__.js +1 -1
  103. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  104. package/out/concepts/QueryFromExpression__.js +1 -1
  105. package/out/concepts/QueryFromExpression__.js.map +1 -1
  106. package/out/concepts/QueryJoinExpression__.js +2 -2
  107. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  108. package/out/concepts/QuerySelectExpression__.js +1 -1
  109. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  110. package/out/concepts/Return__.d.ts +1 -0
  111. package/out/concepts/Return__.js +38 -25
  112. package/out/concepts/Return__.js.map +1 -1
  113. package/out/concepts/SqlQueryComponent__.js +1 -1
  114. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  115. package/out/concepts/StringLiteral__.d.ts +1 -1
  116. package/out/concepts/StringLiteral__.js +2 -2
  117. package/out/concepts/StringLiteral__.js.map +1 -1
  118. package/out/concepts/StructureProperty__.d.ts +5 -4
  119. package/out/concepts/StructureProperty__.js +54 -31
  120. package/out/concepts/StructureProperty__.js.map +1 -1
  121. package/out/concepts/Structure__.d.ts +1 -0
  122. package/out/concepts/Structure__.js +18 -5
  123. package/out/concepts/Structure__.js.map +1 -1
  124. package/out/concepts/SwitchCase__.js +3 -3
  125. package/out/concepts/SwitchCase__.js.map +1 -1
  126. package/out/concepts/SwitchStatement__.js +1 -1
  127. package/out/concepts/SwitchStatement__.js.map +1 -1
  128. package/out/concepts/TypeAnnotation__.d.ts +3 -5
  129. package/out/concepts/TypeAnnotation__.js +36 -14
  130. package/out/concepts/TypeAnnotation__.js.map +1 -1
  131. package/out/concepts/UnaryExpression__.js +4 -2
  132. package/out/concepts/UnaryExpression__.js.map +1 -1
  133. package/out/concepts/ValidationRule__.d.ts +1 -0
  134. package/out/concepts/ValidationRule__.js +27 -1
  135. package/out/concepts/ValidationRule__.js.map +1 -1
  136. package/out/concepts/Variable__.d.ts +1 -0
  137. package/out/concepts/Variable__.js +38 -25
  138. package/out/concepts/Variable__.js.map +1 -1
  139. package/out/concepts/ViewComponent__.js +5 -5
  140. package/out/concepts/ViewComponent__.js.map +1 -1
  141. package/out/concepts/ViewElement__.d.ts +7 -1
  142. package/out/concepts/ViewElement__.js +154 -117
  143. package/out/concepts/ViewElement__.js.map +1 -1
  144. package/out/concepts/View__.d.ts +4 -0
  145. package/out/concepts/View__.js +38 -25
  146. package/out/concepts/View__.js.map +1 -1
  147. package/out/concepts/WhileStatement__.js +1 -1
  148. package/out/concepts/WhileStatement__.js.map +1 -1
  149. package/out/concepts/basics/stdlib/index.js +3 -1
  150. package/out/concepts/basics/stdlib/index.js.map +1 -1
  151. package/out/concepts/basics/stdlib/nasl.auth.d.ts +3 -0
  152. package/out/concepts/basics/stdlib/nasl.auth.js +30 -0
  153. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -0
  154. package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +3 -0
  155. package/out/concepts/basics/stdlib/nasl.browser copy.js +70 -0
  156. package/out/concepts/basics/stdlib/nasl.browser copy.js.map +1 -0
  157. package/out/concepts/basics/stdlib/nasl.browser.js +6 -35
  158. package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
  159. package/out/concepts/basics/stdlib/nasl.configuration.d.ts +3 -0
  160. package/out/concepts/basics/stdlib/nasl.configuration.js +25 -0
  161. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -0
  162. package/out/concepts/basics/stdlib/nasl.util.js +49 -41
  163. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  164. package/out/concepts/basics/stdlib/nasl.validation.js +26 -20
  165. package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
  166. package/out/concepts/basics/types/coreTypeList.js +11 -11
  167. package/out/concepts/basics/types/coreTypeList.js.map +1 -1
  168. package/out/concepts/index__.d.ts +1 -0
  169. package/out/concepts/index__.js +1 -0
  170. package/out/concepts/index__.js.map +1 -1
  171. package/out/enums/KEYWORDS.js +1 -1
  172. package/out/enums/KEYWORDS.js.map +1 -1
  173. package/out/generator/genBundleFiles.d.ts +1 -0
  174. package/out/generator/genBundleFiles.js +122 -93
  175. package/out/generator/genBundleFiles.js.map +1 -1
  176. package/out/manager/diagnostic.d.ts +1 -1
  177. package/out/server/createUiTs.d.ts +1 -0
  178. package/out/server/createUiTs.js +19 -2
  179. package/out/server/createUiTs.js.map +1 -1
  180. package/out/server/entity2LogicNamespace.js +24 -9
  181. package/out/server/entity2LogicNamespace.js.map +1 -1
  182. package/out/server/getExtensionModules.js +2 -0
  183. package/out/server/getExtensionModules.js.map +1 -1
  184. package/out/server/getLogics.js +40 -56
  185. package/out/server/getLogics.js.map +1 -1
  186. package/out/server/getMemberIdentifier.d.ts +4 -0
  187. package/out/server/getMemberIdentifier.js +90 -48
  188. package/out/server/getMemberIdentifier.js.map +1 -1
  189. package/out/server/getProcesses.d.ts +2 -2
  190. package/out/server/getProcesses.js +34 -11
  191. package/out/server/getProcesses.js.map +1 -1
  192. package/out/server/index.js +4 -0
  193. package/out/server/index.js.map +1 -1
  194. package/out/server/naslServer.d.ts +11 -30
  195. package/out/server/naslServer.js +410 -199
  196. package/out/server/naslServer.js.map +1 -1
  197. package/out/server/process2LogicNamespace.d.ts +10 -0
  198. package/out/server/process2LogicNamespace.js +16 -0
  199. package/out/server/process2LogicNamespace.js.map +1 -1
  200. package/out/server/translator.d.ts +22 -3
  201. package/out/server/translator.js +336 -130
  202. package/out/server/translator.js.map +1 -1
  203. package/out/service/storage/init.js +29 -15
  204. package/out/service/storage/init.js.map +1 -1
  205. package/out/templator/genCreateBlock.js +5 -5
  206. package/out/templator/genCreateBlock.js.map +1 -1
  207. package/out/templator/genCurdEditMultipleKeyBlock.js +9 -13
  208. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  209. package/out/templator/genCurdMultipleKeyBlock.js +7 -7
  210. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  211. package/out/templator/genEditTableBlock.js +2 -2
  212. package/out/templator/genEditTableBlock.js.map +1 -1
  213. package/out/templator/genGetBlock.js +4 -2
  214. package/out/templator/genGetBlock.js.map +1 -1
  215. package/out/templator/genGridViewBlock.d.ts +1 -1
  216. package/out/templator/genGridViewBlock.js +3 -3
  217. package/out/templator/genGridViewBlock.js.map +1 -1
  218. package/out/templator/genQueryComponent.d.ts +2 -0
  219. package/out/templator/genQueryComponent.js +1 -0
  220. package/out/templator/genQueryComponent.js.map +1 -1
  221. package/out/templator/genTableBlock.d.ts +1 -1
  222. package/out/templator/genTableBlock.js +3 -3
  223. package/out/templator/genTableBlock.js.map +1 -1
  224. package/out/templator/genUpdateBlock.js +7 -7
  225. package/out/templator/genUpdateBlock.js.map +1 -1
  226. package/out/templator/utils.d.ts +3 -1
  227. package/out/templator/utils.js +2 -1
  228. package/out/templator/utils.js.map +1 -1
  229. package/out/utils/index.d.ts +6 -0
  230. package/out/utils/index.js +20 -1
  231. package/out/utils/index.js.map +1 -1
  232. package/package.json +2 -1
  233. package/src/automate/engine/index.js +73 -25
  234. package/src/automate/engine/utils.js +7 -6
  235. package/src/common/BaseNode.ts +51 -42
  236. package/src/concepts/App__.ts +104 -26
  237. package/src/concepts/Argument__.ts +3 -2
  238. package/src/concepts/Assignee__.ts +437 -0
  239. package/src/concepts/BinaryExpression__.ts +7 -6
  240. package/src/concepts/BindAttribute__.ts +51 -2
  241. package/src/concepts/BindDirective__.ts +20 -1
  242. package/src/concepts/BindEvent__.ts +39 -16
  243. package/src/concepts/CallFunction__.ts +21 -8
  244. package/src/concepts/CallInterface__.ts +161 -42
  245. package/src/concepts/CallLogic__.ts +21 -9
  246. package/src/concepts/CallQueryComponent__.ts +15 -13
  247. package/src/concepts/Comment__.ts +6 -2
  248. package/src/concepts/ConfigGroup__.ts +1 -1
  249. package/src/concepts/ConfigProperty__.ts +1 -1
  250. package/src/concepts/Configuration__.ts +1 -1
  251. package/src/concepts/Destination__.ts +57 -19
  252. package/src/concepts/End__.ts +9 -11
  253. package/src/concepts/EntityProperty__.ts +56 -3
  254. package/src/concepts/Entity__.ts +33 -20
  255. package/src/concepts/Enum__.ts +8 -7
  256. package/src/concepts/Event__.ts +1 -1
  257. package/src/concepts/ForEachStatement__.ts +8 -13
  258. package/src/concepts/Function__.ts +5 -5
  259. package/src/concepts/Identifier__.ts +31 -26
  260. package/src/concepts/IfStatement__.ts +2 -2
  261. package/src/concepts/InterfaceParam__.ts +39 -20
  262. package/src/concepts/Interface__.ts +103 -9
  263. package/src/concepts/LogicItem__.ts +16 -1
  264. package/src/concepts/Logic__.ts +60 -18
  265. package/src/concepts/MemberExpression__.ts +18 -6
  266. package/src/concepts/Module__.ts +19 -8
  267. package/src/concepts/Namespace__.ts +24 -12
  268. package/src/concepts/Param__.ts +34 -23
  269. package/src/concepts/ProcessComponent__.ts +2 -2
  270. package/src/concepts/ProcessElement__.ts +51 -50
  271. package/src/concepts/ProcessOutcome__.ts +1 -1
  272. package/src/concepts/Process__.ts +32 -28
  273. package/src/concepts/QueryAggregateExpression__.ts +1 -1
  274. package/src/concepts/QueryFromExpression__.ts +1 -1
  275. package/src/concepts/QueryJoinExpression__.ts +2 -2
  276. package/src/concepts/QuerySelectExpression__.ts +1 -1
  277. package/src/concepts/Return__.ts +35 -25
  278. package/src/concepts/SqlQueryComponent__.ts +1 -1
  279. package/src/concepts/StringLiteral__.ts +2 -2
  280. package/src/concepts/StructureProperty__.ts +49 -29
  281. package/src/concepts/Structure__.ts +17 -5
  282. package/src/concepts/SwitchCase__.ts +3 -3
  283. package/src/concepts/SwitchStatement__.ts +1 -1
  284. package/src/concepts/TypeAnnotation__.ts +34 -12
  285. package/src/concepts/UnaryExpression__.ts +4 -2
  286. package/src/concepts/ValidationRule__.ts +24 -1
  287. package/src/concepts/Variable__.ts +35 -24
  288. package/src/concepts/ViewComponent__.ts +5 -5
  289. package/src/concepts/ViewElement__.ts +168 -113
  290. package/src/concepts/View__.ts +44 -25
  291. package/src/concepts/WhileStatement__.ts +1 -1
  292. package/src/concepts/basics/stdlib/index.ts +3 -1
  293. package/src/concepts/basics/stdlib/nasl.auth.ts +26 -0
  294. package/src/concepts/basics/stdlib/nasl.browser.ts +7 -41
  295. package/src/concepts/basics/stdlib/nasl.configuration.ts +21 -0
  296. package/src/concepts/basics/stdlib/nasl.util.ts +49 -41
  297. package/src/concepts/basics/stdlib/nasl.validation.ts +17 -11
  298. package/src/concepts/basics/types/coreTypeList.ts +11 -11
  299. package/src/concepts/index__.ts +1 -0
  300. package/src/enums/KEYWORDS.ts +1 -1
  301. package/src/generator/genBundleFiles.ts +131 -112
  302. package/src/manager/diagnostic.ts +1 -1
  303. package/src/server/createUiTs.ts +22 -4
  304. package/src/server/entity2LogicNamespace.ts +25 -9
  305. package/src/server/getExtensionModules.ts +2 -0
  306. package/src/server/getLogics.ts +42 -58
  307. package/src/server/getMemberIdentifier.ts +88 -46
  308. package/src/server/getProcesses.ts +32 -9
  309. package/src/server/index.ts +12 -1
  310. package/src/server/naslServer.ts +422 -215
  311. package/src/server/process2LogicNamespace.ts +17 -1
  312. package/src/server/translator.ts +392 -134
  313. package/src/service/storage/init.ts +27 -16
  314. package/src/templator/genCreateBlock.ts +5 -5
  315. package/src/templator/genCurdEditMultipleKeyBlock.ts +25 -26
  316. package/src/templator/genCurdMultipleKeyBlock.ts +7 -7
  317. package/src/templator/genEditTableBlock.ts +2 -2
  318. package/src/templator/genGetBlock.ts +5 -7
  319. package/src/templator/genGridViewBlock.ts +4 -7
  320. package/src/templator/genQueryComponent.ts +1 -0
  321. package/src/templator/genTableBlock.ts +4 -7
  322. package/src/templator/genUpdateBlock.ts +7 -8
  323. package/src/templator/utils.ts +2 -1
  324. package/src/utils/index.ts +19 -0
@@ -46,6 +46,7 @@ export interface ElementToVueOptions {
46
46
  getExtraParts?: (element?: ViewElement) => Array<string>;
47
47
  attrFormat?: (attr: BindAttribute | BindEvent | BindDirective, element?: ViewElement, defaultResult?: string) => string | false;
48
48
  finalCode?: boolean;
49
+ scopeList?: string[];
49
50
  }
50
51
 
51
52
  function transAstNodeToNaslNode(astNode: any, namespace?: string): any {
@@ -86,7 +87,8 @@ function transAstNodeToNaslNode(astNode: any, namespace?: string): any {
86
87
  }
87
88
  } else if (astNode.type === 'MemberExpression') {
88
89
  if (astNode.object?.name === '$global') {
89
- node = transAstNodeToNaslNode(astNode.property, 'nasl.browser');
90
+ // 目前只有权限相关的
91
+ node = transAstNodeToNaslNode(astNode.property, 'nasl.auth');
90
92
  } else {
91
93
  node = {
92
94
  concept: 'MemberExpression',
@@ -260,17 +262,19 @@ export class ViewElement extends BaseNode {
260
262
  super.subConstructor(source);
261
263
  }
262
264
 
265
+
266
+
263
267
  /**
264
268
  * 从父级删除该节点
265
269
  * @internal
266
270
  */
267
- // _delete() {
268
- // let params: Params = null;
269
- // if (this.parentNode) {
270
- // params = (this.parentNode as any)?.__removeViewElement?.(this);
271
- // }
272
- // return params;
273
- // }
271
+ _delete() {
272
+ let params: Params = null;
273
+ if (this.parentNode) {
274
+ params = (this.parentNode as any)?.__removeViewElement?.(this);
275
+ }
276
+ return params;
277
+ }
274
278
  /**
275
279
  * 设置页面元素名称
276
280
  */
@@ -296,7 +300,7 @@ export class ViewElement extends BaseNode {
296
300
  });
297
301
  }
298
302
 
299
- getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
303
+ getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
300
304
  const excludedSet = new Set(excludedList);
301
305
  return (this.bindAttrs || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
302
306
  }
@@ -340,7 +344,7 @@ export class ViewElement extends BaseNode {
340
344
  name: options,
341
345
  }, this, 'bindAttrs');
342
346
  } else if (options instanceof BindAttribute) {
343
- options.delete(); // 同一实例不支持多处存在
347
+ options.ensureDelete(); // 同一实例不支持多处存在
344
348
  bindAttribute = options;
345
349
  Object.assign(bindAttribute, relationOptions);
346
350
  } else {
@@ -437,6 +441,7 @@ export class ViewElement extends BaseNode {
437
441
  return node;
438
442
  }
439
443
 
444
+
440
445
  getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
441
446
  const excludedSet = new Set(excludedList);
442
447
  return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -481,7 +486,7 @@ export class ViewElement extends BaseNode {
481
486
  name: options,
482
487
  }, this, 'bindEvents');
483
488
  } else if (options instanceof BindEvent) {
484
- options.delete(); // 同一实例不支持多处存在
489
+ options.ensureDelete(); // 同一实例不支持多处存在
485
490
  bindEvent = options;
486
491
  Object.assign(bindEvent, relationOptions);
487
492
  } else {
@@ -578,6 +583,7 @@ export class ViewElement extends BaseNode {
578
583
  return node;
579
584
  }
580
585
 
586
+
581
587
  getBindDirectiveExistingNames(excludedList: Array<BindDirective> = []) {
582
588
  const excludedSet = new Set(excludedList);
583
589
  return (this.bindDirectives || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -622,7 +628,7 @@ export class ViewElement extends BaseNode {
622
628
  name: options,
623
629
  }, this, 'bindDirectives');
624
630
  } else if (options instanceof BindDirective) {
625
- options.delete(); // 同一实例不支持多处存在
631
+ options.ensureDelete(); // 同一实例不支持多处存在
626
632
  bindDirective = options;
627
633
  Object.assign(bindDirective, relationOptions);
628
634
  } else {
@@ -719,6 +725,11 @@ export class ViewElement extends BaseNode {
719
725
  return node;
720
726
  }
721
727
 
728
+
729
+
730
+
731
+
732
+
722
733
  /**
723
734
  * 插入页面元素
724
735
  * @internal
@@ -755,7 +766,7 @@ export class ViewElement extends BaseNode {
755
766
  name: options,
756
767
  }, this, 'children');
757
768
  } else if (options instanceof ViewElement) {
758
- options.delete(); // 同一实例不支持多处存在
769
+ options.ensureDelete(); // 同一实例不支持多处存在
759
770
  viewElement = options;
760
771
  Object.assign(viewElement, relationOptions);
761
772
  } else {
@@ -852,6 +863,9 @@ export class ViewElement extends BaseNode {
852
863
  return node;
853
864
  }
854
865
 
866
+
867
+
868
+
855
869
  /**
856
870
  * 删除元素绑定属性
857
871
  * @param name 元素绑定属性名称
@@ -900,6 +914,8 @@ export class ViewElement extends BaseNode {
900
914
  return params;
901
915
  }
902
916
 
917
+
918
+
903
919
  /**
904
920
  * 删除元素绑定事件
905
921
  * @param name 元素绑定事件名称
@@ -948,6 +964,8 @@ export class ViewElement extends BaseNode {
948
964
  return params;
949
965
  }
950
966
 
967
+
968
+
951
969
  /**
952
970
  * 删除元素指令
953
971
  * @param name 元素指令名称
@@ -996,6 +1014,8 @@ export class ViewElement extends BaseNode {
996
1014
  return params;
997
1015
  }
998
1016
 
1017
+
1018
+
999
1019
  /**
1000
1020
  * 删除页面元素
1001
1021
  * @param name 页面元素名称
@@ -1053,7 +1073,7 @@ export class ViewElement extends BaseNode {
1053
1073
  get parentAuth() {
1054
1074
  const _nameSpace = this.view.getNamespace();
1055
1075
  const mainViewName = _nameSpace.split('.')[2];
1056
- return this.app.views.find((item) => item.name === mainViewName)?.auth;
1076
+ return this.view.parentNode.concept === 'App' ? this.view.auth : this.app.views.find((item) => item.name === mainViewName)?.auth;
1057
1077
  }
1058
1078
 
1059
1079
  getViewElementUniqueName(name = 'viewElement1') {
@@ -1092,8 +1112,9 @@ export class ViewElement extends BaseNode {
1092
1112
  }
1093
1113
 
1094
1114
  haveScope(node: ViewElement): boolean {
1095
- const dataSourcePcList = ['uGallery', 'uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect'];
1096
- const dataSourceH5List = ['vanListView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
1115
+ // uGallery 没有子集不需要scope
1116
+ const dataSourcePcList = ['uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect'];
1117
+ const dataSourceH5List = ['vanRadioGroup', 'vanCheckboxGroup', 'vanListView', 'vanGridView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
1097
1118
  const dataSourceList = [...dataSourcePcList, ...dataSourceH5List];
1098
1119
  return dataSourceList.includes(node.toHump(node.tag));
1099
1120
  }
@@ -1135,7 +1156,11 @@ export class ViewElement extends BaseNode {
1135
1156
  while (!haveScopeFlag && parentNode.concept !== 'View') {
1136
1157
  if (this.haveScope(parentNode as ViewElement)) {
1137
1158
  // type d = nasl.ui.GetItemTypeFromDataSource<typeof listStructure>['tableRelation']
1138
- const tsArr = expressionTs.split('.');
1159
+ const tsArr = expressionTs.replace('scope.item.', '').split('.');
1160
+ let itemStr = '';
1161
+ tsArr.forEach((item) => {
1162
+ itemStr += `['${item}']`;
1163
+ });
1139
1164
  const parentbindAttrs = (parentNode as ViewElement).bindAttrs;
1140
1165
  if (parentbindAttrs && parentbindAttrs.length) {
1141
1166
  const parentAttr = parentbindAttrs.find((item) => item.name === 'data-source');
@@ -1143,7 +1168,7 @@ export class ViewElement extends BaseNode {
1143
1168
  let parentExpressionTs = parentAttr.expression.toEmbeddedTS(shiftState(state, code));
1144
1169
  parentExpressionTs = parentExpressionTs.replaceAll(' ', '');
1145
1170
  // 如果是逻辑就推导出逻辑类型
1146
- genericType = `nasl.ui.GetItemTypeFromDataSource<nasl.ui.GetItemTypeFromDataSource<typeof ${parentExpressionTs}>['${tsArr[tsArr.length - 1]}']>`;
1171
+ genericType = `nasl.ui.GetItemTypeFromDataSource<nasl.ui.GetItemTypeFromDataSource<typeof ${parentExpressionTs}>${itemStr}>`;
1147
1172
  }
1148
1173
  }
1149
1174
  haveScopeFlag = true;
@@ -1184,7 +1209,7 @@ export class ViewElement extends BaseNode {
1184
1209
  hasAuth = !!this.bindDirectives.filter((directive) => directive.name === 'auth').length;
1185
1210
  }
1186
1211
  // 角色
1187
- if (hasAuth && Array.isArray(this.bindRoles)) {
1212
+ if (Array.isArray(this.bindRoles) && this.bindRoles.length) {
1188
1213
  code += indent(state.tabSize + 2);
1189
1214
  code += 'roles = [\n';
1190
1215
  this.bindRoles.forEach((role) => {
@@ -1231,6 +1256,11 @@ export class ViewElement extends BaseNode {
1231
1256
  tabSize: state.tabSize + 2,
1232
1257
  })) + ',\n';
1233
1258
  }
1259
+ if (Array.isArray(attr.rules) && attr.rules.length) {
1260
+ attr.rules.forEach((item) => {
1261
+ code += item.toEmbeddedTS(shiftState(state, code)) + ',\n';
1262
+ });
1263
+ }
1234
1264
  });
1235
1265
  this.bindDirectives.forEach((directive) => {
1236
1266
  if (directive.expression) {
@@ -1350,13 +1380,13 @@ export class ViewElement extends BaseNode {
1350
1380
  });
1351
1381
  astNode.children = [];
1352
1382
  }
1353
-
1354
1383
  // 将 scopedSlots 合并到 children 中
1355
1384
  if (astNode.scopedSlots) {
1356
1385
  astNode.children = astNode.children || [];
1357
1386
  Object.keys(astNode.scopedSlots).forEach((key) => {
1358
- if (!astNode.children.find((child) => key === (child as compiler.ASTElement).slotTarget))
1387
+ if (!astNode.children.find((child) => key === (child as compiler.ASTElement).slotTarget)) {
1359
1388
  astNode.children.unshift(astNode.scopedSlots[key]);
1389
+ }
1360
1390
  });
1361
1391
  delete astNode.scopedSlots;
1362
1392
  }
@@ -1377,6 +1407,12 @@ export class ViewElement extends BaseNode {
1377
1407
  }
1378
1408
  }
1379
1409
  const tagName = astNode.tag.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1410
+ let newContext: any = {};
1411
+ if (context) {
1412
+ newContext = {
1413
+ ...context,
1414
+ };
1415
+ }
1380
1416
  element = new ViewElement({
1381
1417
  tag: astNode.tag,
1382
1418
  name: astNode.attrsMap.ref || view.getViewElementUniqueName(`${tagName}1`),
@@ -1384,45 +1420,43 @@ export class ViewElement extends BaseNode {
1384
1420
  staticStyle: astNode.attrsMap.style,
1385
1421
  slotTarget: astNode.slotTarget && json5.parse(astNode.slotTarget),
1386
1422
  slotScope: astNode.slotScope === '_empty_' ? '' : astNode.slotScope,
1387
- children: astNode.children.map((item) => this._fromASTNode(item as compiler.ASTElement, context)) as unknown as Array<ViewElement>,
1423
+ children: astNode.children.map((item) => this._fromASTNode(item as compiler.ASTElement, newContext)) as unknown as Array<ViewElement>,
1388
1424
  });
1389
-
1390
- astNode.attrs
1391
- && astNode.attrs.forEach((oldAttr) => {
1392
- let attr: BindAttribute;
1393
- if (oldAttr.value === '""' && (oldAttr as any).end - (oldAttr as any).start === oldAttr.name.length) {
1425
+ astNode?.attrs?.forEach((oldAttr) => {
1426
+ let attr: BindAttribute;
1427
+ if (oldAttr.value === '""' && (oldAttr as any).end - (oldAttr as any).start === oldAttr.name.length) {
1428
+ attr = new BindAttribute({
1429
+ type: 'static',
1430
+ name: oldAttr.name,
1431
+ value: 'true',
1432
+ });
1433
+ } else {
1434
+ try {
1435
+ const tmp = json5.parse(oldAttr.value);
1436
+ const source: any = {
1437
+ type: typeof tmp === 'string' ? 'string' : 'static',
1438
+ name: oldAttr.name,
1439
+ value: typeof tmp === 'string' ? tmp : oldAttr.value,
1440
+ };
1441
+ if (oldAttr.name === 'rules') {
1442
+ source.rules = tmp?.split('|').map((ruleStr: string) => this._parseValidationRule(ruleStr.trim()));
1443
+ }
1444
+ attr = new BindAttribute(source);
1445
+ } catch (e) {
1446
+ const expression = <any> this._parseExpression(oldAttr.value);
1394
1447
  attr = new BindAttribute({
1395
- type: 'static',
1448
+ type: 'dynamic',
1396
1449
  name: oldAttr.name,
1397
- value: 'true',
1450
+ value: expression ? '' : oldAttr.value,
1451
+ expression,
1398
1452
  });
1399
- } else {
1400
- try {
1401
- const tmp = json5.parse(oldAttr.value);
1402
- const source: any = {
1403
- type: typeof tmp === 'string' ? 'string' : 'static',
1404
- name: oldAttr.name,
1405
- value: typeof tmp === 'string' ? tmp : oldAttr.value,
1406
- };
1407
- if (oldAttr.name === 'rules') {
1408
- source.rules = tmp?.split('|').map((ruleStr: string) => this._parseValidationRule(ruleStr.trim()));
1409
- }
1410
- attr = new BindAttribute(source);
1411
- } catch (e) {
1412
- const expression = <any> this._parseExpression(oldAttr.value);
1413
- attr = new BindAttribute({
1414
- type: 'dynamic',
1415
- name: oldAttr.name,
1416
- value: expression ? '' : oldAttr.value,
1417
- expression,
1418
- });
1419
- if (astNode.attrsMap[`:${attr.name}.sync`]) {
1420
- attr.sync = true;
1421
- }
1453
+ if (astNode.attrsMap[`:${attr.name}.sync`]) {
1454
+ attr.sync = true;
1422
1455
  }
1423
1456
  }
1424
- element.addBindAttribute(attr);
1425
- });
1457
+ }
1458
+ element.addBindAttribute(attr);
1459
+ });
1426
1460
 
1427
1461
  // compiler 处理:value.sync 时会加上update:value事件,需要过滤
1428
1462
  astNode.events
@@ -1438,18 +1472,17 @@ export class ViewElement extends BaseNode {
1438
1472
  argsStr = matchArr[1];
1439
1473
  }
1440
1474
  let args: any[] = [];
1441
- if (argsStr) {
1442
- args = argsStr.split(',').map((argStr) => {
1475
+ const argStrs: string[] = argsStr.split(',');
1476
+ args = argStrs
1477
+ .filter((argStr) => !!argStr && argStr !== '_empty_')
1478
+ .map((argStr) => {
1443
1479
  const keyword = argStr.trim().split('.');
1444
1480
  return {
1445
1481
  concept: 'Argument',
1446
1482
  expression: genArgumentMemberExpression(keyword),
1447
1483
  };
1448
1484
  });
1449
- }
1450
- const viewNamespace = view?.getNamespace();
1451
- const viewName = `${view?.name}`;
1452
- let calleeNamespace = `${viewNamespace}.${viewName}.logics`;
1485
+ let calleeNamespace = '';
1453
1486
  if (calleeName) {
1454
1487
  const namespaceArr = calleeName.split('.');
1455
1488
  const start = namespaceArr.shift();
@@ -1504,15 +1537,12 @@ export class ViewElement extends BaseNode {
1504
1537
  }));
1505
1538
  }
1506
1539
  } else if (astNode.type === 2) {
1507
- if (config.scope === 'h5') {
1508
- element = new ViewElement({
1509
- tag: 'van-text',
1510
- });
1511
- } else {
1512
- element = new ViewElement({
1513
- tag: 'u-text',
1514
- });
1515
- }
1540
+ const tagName = config.scope === 'h5' ? 'van-text' : 'u-text';
1541
+ const baseName = tagName.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1542
+ element = new ViewElement({
1543
+ tag: tagName,
1544
+ name: view.getViewElementUniqueName(`${baseName}1`),
1545
+ });
1516
1546
  const value = astNode.text.match(/{{(.*?)}}/)[1].trim();
1517
1547
  const expression = <any> this._parseExpression(value);
1518
1548
  element.addBindAttribute(new BindAttribute({
@@ -1522,15 +1552,12 @@ export class ViewElement extends BaseNode {
1522
1552
  expression,
1523
1553
  }));
1524
1554
  } else if (astNode.type === 3) {
1525
- if (config.scope === 'h5') {
1526
- element = new ViewElement({
1527
- tag: 'van-text',
1528
- });
1529
- } else {
1530
- element = new ViewElement({
1531
- tag: 'u-text',
1532
- });
1533
- }
1555
+ const tagName = config.scope === 'h5' ? 'van-text' : 'u-text';
1556
+ const baseName = tagName.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1557
+ element = new ViewElement({
1558
+ tag: tagName,
1559
+ name: view.getViewElementUniqueName(`${baseName}1`),
1560
+ });
1534
1561
  element.addBindAttribute(new BindAttribute({
1535
1562
  name: 'text',
1536
1563
  type: 'string',
@@ -1557,24 +1584,14 @@ export class ViewElement extends BaseNode {
1557
1584
  let ast = compiler.compile(html, compilerOptions).ast;
1558
1585
  if (ast.tag === 'template' && !ast.slotTarget)
1559
1586
  ast = ast.children[0] as compiler.ASTElement;
1560
-
1561
- let root: ViewElement;
1562
- utils.traverse((current) => {
1563
- // 处理 scopedSlots;
1564
- if (!current.parent)
1565
- root = this._fromASTNode(current.node, context);
1566
- else
1567
- (current.parent.children as any)[current.index] = this._fromASTNode(current.node, context);
1568
- }, { node: ast });
1569
- return root;
1587
+ return this._fromASTNode(ast, context);
1570
1588
  }
1571
1589
 
1572
1590
  /**
1573
1591
  * 从模板生成规范的 ViewElement 对象
1574
1592
  */
1575
1593
  public static fromHTML(html: string, context?: ParseContext) {
1576
- const element = this.parse(html, context);
1577
- return element;
1594
+ return this.parse(html, context);
1578
1595
  }
1579
1596
 
1580
1597
  /**
@@ -1602,7 +1619,7 @@ export class ViewElement extends BaseNode {
1602
1619
  }
1603
1620
  }
1604
1621
  if ((attr as BindAttribute).type === 'dynamic' && !(element.tag === 'u-cascade-select' && attr.name === 'categories'))
1605
- return defaultResult.replace(/:?(\w+)(?:.*?)="(.*)"/, (m, name, value) => {
1622
+ return defaultResult.replace(/:?([\w-]+)(?:.*?)="(.*)"/, (m, name, value) => {
1606
1623
  try {
1607
1624
  const tempValue = json5.parse(value);
1608
1625
  if (typeof tempValue === 'boolean' || typeof tempValue === 'number') {
@@ -1613,7 +1630,12 @@ export class ViewElement extends BaseNode {
1613
1630
  if (apiOfAttr && !apiOfAttr.type.includes('string'))
1614
1631
  return '';
1615
1632
  }
1616
- return `${name}="{{ ${value.replace(/"/g, "'").replace(/\$utils\['(.+?)'\]/g, '$1')} }}"`;
1633
+ value = value
1634
+ .replace(/"/g, "'")
1635
+ .replace(/\$utils\['(.+?)'\]/g, '$1')
1636
+ .replace(/\$refs./g, 'elements.')
1637
+ .replace(/\$global./g, 'nasl.auth.');
1638
+ return `${name}="{{ ${value} }}"`;
1617
1639
  });
1618
1640
  else
1619
1641
  return defaultResult;
@@ -1661,7 +1683,14 @@ export class ViewElement extends BaseNode {
1661
1683
  * 转换成 Vue 的模板格式
1662
1684
  */
1663
1685
  toVue(options?: ElementToVueOptions) {
1664
- options = Object.assign({
1686
+ let scopeList: string[] = [];
1687
+ if (Array.isArray(options?.scopeList)) {
1688
+ scopeList = [...options?.scopeList];
1689
+ }
1690
+ if (this.slotScope) {
1691
+ scopeList.unshift(this.slotScope);
1692
+ }
1693
+ const newOptions: ElementToVueOptions = Object.assign({
1665
1694
  indentStyle: 'space',
1666
1695
  tabSize: 4,
1667
1696
  indentLevel: 0,
@@ -1669,27 +1698,30 @@ export class ViewElement extends BaseNode {
1669
1698
  nodePathAttr: false,
1670
1699
  getExtraParts: () => [],
1671
1700
  attrFormat: (attr: BindAttribute | BindEvent | BindDirective, element?: ViewElement, defaultResult?: string) => defaultResult,
1672
- }, options);
1673
- const tabString = ' '.repeat(options.tabSize * options.indentLevel);
1674
- const insideTabString = ' '.repeat(options.tabSize * (options.indentLevel + 1));
1701
+ }, options, {
1702
+ scopeList,
1703
+ });
1704
+ const tabString = ' '.repeat(newOptions.tabSize * newOptions.indentLevel);
1705
+ const insideTabString = ' '.repeat(newOptions.tabSize * (newOptions.indentLevel + 1));
1675
1706
  let shouldIndent = true;
1676
1707
  const content: string = !this.children ? '' : this.children
1677
1708
  .map((element) => {
1678
- const childOptions = Object.assign({}, options);
1709
+ const childOptions = Object.assign({}, newOptions);
1679
1710
  childOptions.indentLevel++;
1680
1711
  return (shouldIndent ? '\n' + insideTabString : '') + element.toVue(childOptions);
1681
1712
  })
1682
1713
  .join('');
1683
- if (!content.length)
1714
+ if (!content.length) {
1684
1715
  shouldIndent = false;
1685
-
1716
+ }
1686
1717
  const parts = [];
1687
- if (options.aslIdAttr) {
1688
- if (options.aslIdAttr === true)
1689
- options.aslIdAttr = 'asl-id';
1690
- parts.push(`${options.aslIdAttr}="${this.id}"`);
1718
+ if (newOptions.aslIdAttr) {
1719
+ if (newOptions.aslIdAttr === true) {
1720
+ newOptions.aslIdAttr = 'asl-id';
1721
+ }
1722
+ parts.push(`${newOptions.aslIdAttr}="${this.id}"`);
1691
1723
  }
1692
- if (options.nodePathAttr) {
1724
+ if (newOptions.nodePathAttr) {
1693
1725
  // 注入 asl 的 node-path
1694
1726
  parts.push(`vusion-node-path="${this.nodePath}"`);
1695
1727
  }
@@ -1700,11 +1732,10 @@ export class ViewElement extends BaseNode {
1700
1732
  this.staticStyle && parts.push(`style="${this.staticStyle}"`);
1701
1733
 
1702
1734
  [].concat(this.bindAttrs, this.bindDirectives, this.bindEvents).forEach((attr: BindAttribute | BindDirective | BindEvent) => {
1703
- const result = options.attrFormat(attr, this, attr.toVue(options));
1735
+ const result = newOptions.attrFormat(attr, this, attr.toVue(newOptions));
1704
1736
  result && parts.push(result);
1705
1737
  });
1706
-
1707
- options.getExtraParts(this).forEach((part) => parts.push(part));
1738
+ newOptions.getExtraParts(this).forEach((part) => parts.push(part));
1708
1739
 
1709
1740
  let partsLength = 0;
1710
1741
  let partsString = '';
@@ -1724,22 +1755,46 @@ export class ViewElement extends BaseNode {
1724
1755
  * 从父级删除该节点
1725
1756
  * @internal
1726
1757
  */
1727
- _delete() {
1728
- let params: Params = null;
1758
+ delete() {
1759
+ super.delete();
1729
1760
  if (this.parentNode) {
1730
- params = (this.parentNode as any)?.__removeViewElement?.(this);
1731
- (this.view as any)?.removeExistingViewElement(this);
1761
+ this.traverseChildren((ele: ViewElement) => {
1762
+ (this.view as any)?.removeExistingViewElement(ele);
1763
+ });
1732
1764
  }
1733
- return params;
1734
1765
  }
1735
1766
 
1767
+ findElementByName(name: string): ViewElement {
1768
+ return utils.traverse((current) => {
1769
+ if (current.node.name === name)
1770
+ return current.node;
1771
+ }, { node: this });
1772
+ }
1773
+
1774
+ findElementByTag(tag: string): ViewElement {
1775
+ return utils.traverse((current) => {
1776
+ if (current.node.tag === tag)
1777
+ return current.node;
1778
+ }, { node: this });
1779
+ }
1780
+
1781
+ findElementByAttr(name: string, value: string): ViewElement {
1782
+ return utils.traverse((current) => {
1783
+ if (current.node.bindAttrs.some((attr) => attr.name === name && attr.value === value))
1784
+ return current.node;
1785
+ }, { node: this });
1786
+ }
1787
+
1788
+ @excludedInJSON()
1789
+ computedStyle: object = {};
1790
+
1736
1791
  //================================================================================
1737
1792
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1738
1793
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
1739
1794
  //================================================================================
1740
1795
  }
1741
1796
 
1742
- classMap.ViewElement = ViewElement;
1797
+ classMap['ViewElement'] = ViewElement;
1743
1798
  export default ViewElement;
1744
1799
  //================================================================================
1745
1800
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑