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

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 (254) hide show
  1. package/out/automate/engine/index.js +1 -1
  2. package/out/automate/engine/index.js.map +1 -1
  3. package/out/common/BaseNode.d.ts +4 -4
  4. package/out/common/BaseNode.js +45 -41
  5. package/out/common/BaseNode.js.map +1 -1
  6. package/out/concepts/App__.d.ts +17 -0
  7. package/out/concepts/App__.js +54 -12
  8. package/out/concepts/App__.js.map +1 -1
  9. package/out/concepts/Argument__.js +2 -2
  10. package/out/concepts/Argument__.js.map +1 -1
  11. package/out/concepts/BinaryExpression__.js +8 -6
  12. package/out/concepts/BinaryExpression__.js.map +1 -1
  13. package/out/concepts/BindAttribute__.d.ts +21 -21
  14. package/out/concepts/BindAttribute__.js +4 -3
  15. package/out/concepts/BindAttribute__.js.map +1 -1
  16. package/out/concepts/BindDirective__.d.ts +3 -3
  17. package/out/concepts/BindDirective__.js +22 -2
  18. package/out/concepts/BindDirective__.js.map +1 -1
  19. package/out/concepts/BindEvent__.d.ts +9 -8
  20. package/out/concepts/BindEvent__.js +17 -7
  21. package/out/concepts/BindEvent__.js.map +1 -1
  22. package/out/concepts/CallFunction__.js +10 -5
  23. package/out/concepts/CallFunction__.js.map +1 -1
  24. package/out/concepts/CallInterface__.js +11 -1
  25. package/out/concepts/CallInterface__.js.map +1 -1
  26. package/out/concepts/CallLogic__.d.ts +1 -0
  27. package/out/concepts/CallLogic__.js +17 -7
  28. package/out/concepts/CallLogic__.js.map +1 -1
  29. package/out/concepts/CallQueryComponent__.d.ts +0 -1
  30. package/out/concepts/CallQueryComponent__.js +5 -8
  31. package/out/concepts/CallQueryComponent__.js.map +1 -1
  32. package/out/concepts/Comment__.js +6 -2
  33. package/out/concepts/Comment__.js.map +1 -1
  34. package/out/concepts/ConfigGroup__.js +1 -1
  35. package/out/concepts/ConfigGroup__.js.map +1 -1
  36. package/out/concepts/ConfigProperty__.js +1 -1
  37. package/out/concepts/ConfigProperty__.js.map +1 -1
  38. package/out/concepts/Configuration__.js +1 -1
  39. package/out/concepts/Configuration__.js.map +1 -1
  40. package/out/concepts/Destination__.js +10 -7
  41. package/out/concepts/Destination__.js.map +1 -1
  42. package/out/concepts/EntityProperty__.d.ts +3 -0
  43. package/out/concepts/EntityProperty__.js +38 -0
  44. package/out/concepts/EntityProperty__.js.map +1 -1
  45. package/out/concepts/Entity__.d.ts +34 -31
  46. package/out/concepts/Entity__.js +29 -12
  47. package/out/concepts/Entity__.js.map +1 -1
  48. package/out/concepts/Enum__.js +1 -1
  49. package/out/concepts/Enum__.js.map +1 -1
  50. package/out/concepts/Event__.js +1 -1
  51. package/out/concepts/Event__.js.map +1 -1
  52. package/out/concepts/ForEachStatement__.js +8 -12
  53. package/out/concepts/ForEachStatement__.js.map +1 -1
  54. package/out/concepts/Function__.js +4 -4
  55. package/out/concepts/Function__.js.map +1 -1
  56. package/out/concepts/Identifier__.js +13 -7
  57. package/out/concepts/Identifier__.js.map +1 -1
  58. package/out/concepts/IfStatement__.js +2 -2
  59. package/out/concepts/IfStatement__.js.map +1 -1
  60. package/out/concepts/InterfaceParam__.d.ts +2 -0
  61. package/out/concepts/InterfaceParam__.js +10 -0
  62. package/out/concepts/InterfaceParam__.js.map +1 -1
  63. package/out/concepts/Interface__.js +3 -3
  64. package/out/concepts/Interface__.js.map +1 -1
  65. package/out/concepts/LogicItem__.d.ts +1 -0
  66. package/out/concepts/LogicItem__.js +14 -0
  67. package/out/concepts/LogicItem__.js.map +1 -1
  68. package/out/concepts/Logic__.d.ts +1 -0
  69. package/out/concepts/Logic__.js +16 -11
  70. package/out/concepts/Logic__.js.map +1 -1
  71. package/out/concepts/Module__.js +8 -8
  72. package/out/concepts/Module__.js.map +1 -1
  73. package/out/concepts/Namespace__.js +12 -12
  74. package/out/concepts/Namespace__.js.map +1 -1
  75. package/out/concepts/Param__.d.ts +1 -0
  76. package/out/concepts/Param__.js +3 -0
  77. package/out/concepts/Param__.js.map +1 -1
  78. package/out/concepts/ProcessComponent__.js +2 -2
  79. package/out/concepts/ProcessComponent__.js.map +1 -1
  80. package/out/concepts/ProcessElement__.js +5 -5
  81. package/out/concepts/ProcessElement__.js.map +1 -1
  82. package/out/concepts/ProcessOutcome__.js +1 -1
  83. package/out/concepts/ProcessOutcome__.js.map +1 -1
  84. package/out/concepts/Process__.js +4 -4
  85. package/out/concepts/Process__.js.map +1 -1
  86. package/out/concepts/QueryFromExpression__.js +1 -1
  87. package/out/concepts/QueryFromExpression__.js.map +1 -1
  88. package/out/concepts/QueryJoinExpression__.js +2 -2
  89. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  90. package/out/concepts/QuerySelectExpression__.js +1 -1
  91. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  92. package/out/concepts/Return__.d.ts +1 -0
  93. package/out/concepts/Return__.js +6 -3
  94. package/out/concepts/Return__.js.map +1 -1
  95. package/out/concepts/StringLiteral__.d.ts +1 -1
  96. package/out/concepts/StringLiteral__.js +2 -2
  97. package/out/concepts/StringLiteral__.js.map +1 -1
  98. package/out/concepts/StructureProperty__.d.ts +3 -6
  99. package/out/concepts/StructureProperty__.js +38 -32
  100. package/out/concepts/StructureProperty__.js.map +1 -1
  101. package/out/concepts/Structure__.js +3 -3
  102. package/out/concepts/Structure__.js.map +1 -1
  103. package/out/concepts/SwitchCase__.js +3 -3
  104. package/out/concepts/SwitchCase__.js.map +1 -1
  105. package/out/concepts/SwitchStatement__.js +1 -1
  106. package/out/concepts/SwitchStatement__.js.map +1 -1
  107. package/out/concepts/TypeAnnotation__.js +10 -2
  108. package/out/concepts/TypeAnnotation__.js.map +1 -1
  109. package/out/concepts/UnaryExpression__.js +1 -1
  110. package/out/concepts/UnaryExpression__.js.map +1 -1
  111. package/out/concepts/ValidationRule__.d.ts +1 -0
  112. package/out/concepts/ValidationRule__.js +27 -1
  113. package/out/concepts/ValidationRule__.js.map +1 -1
  114. package/out/concepts/Variable__.d.ts +1 -0
  115. package/out/concepts/Variable__.js +6 -3
  116. package/out/concepts/Variable__.js.map +1 -1
  117. package/out/concepts/ViewComponent__.js +5 -5
  118. package/out/concepts/ViewComponent__.js.map +1 -1
  119. package/out/concepts/ViewElement__.d.ts +63 -60
  120. package/out/concepts/ViewElement__.js +123 -88
  121. package/out/concepts/ViewElement__.js.map +1 -1
  122. package/out/concepts/View__.d.ts +4 -0
  123. package/out/concepts/View__.js +26 -10
  124. package/out/concepts/View__.js.map +1 -1
  125. package/out/concepts/WhileStatement__.js +1 -1
  126. package/out/concepts/WhileStatement__.js.map +1 -1
  127. package/out/concepts/basics/stdlib/index.js +3 -1
  128. package/out/concepts/basics/stdlib/index.js.map +1 -1
  129. package/out/concepts/basics/stdlib/nasl.auth.d.ts +3 -0
  130. package/out/concepts/basics/stdlib/nasl.auth.js +39 -0
  131. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -0
  132. package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +3 -0
  133. package/out/concepts/basics/stdlib/nasl.browser copy.js +70 -0
  134. package/out/concepts/basics/stdlib/nasl.browser copy.js.map +1 -0
  135. package/out/concepts/basics/stdlib/nasl.browser.js +6 -35
  136. package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
  137. package/out/concepts/basics/stdlib/nasl.configuration.d.ts +3 -0
  138. package/out/concepts/basics/stdlib/nasl.configuration.js +25 -0
  139. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -0
  140. package/out/concepts/basics/stdlib/nasl.util.js +0 -29
  141. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  142. package/out/enums/KEYWORDS.js +1 -0
  143. package/out/enums/KEYWORDS.js.map +1 -1
  144. package/out/generator/genBundleFiles.js +98 -72
  145. package/out/generator/genBundleFiles.js.map +1 -1
  146. package/out/server/createUiTs.d.ts +1 -0
  147. package/out/server/createUiTs.js +15 -1
  148. package/out/server/createUiTs.js.map +1 -1
  149. package/out/server/getLogics.js +27 -45
  150. package/out/server/getLogics.js.map +1 -1
  151. package/out/server/getMemberIdentifier.js +3 -3
  152. package/out/server/getMemberIdentifier.js.map +1 -1
  153. package/out/server/getProcesses.d.ts +1 -1
  154. package/out/server/getProcesses.js +2 -2
  155. package/out/server/getProcesses.js.map +1 -1
  156. package/out/server/naslServer.d.ts +1 -3
  157. package/out/server/naslServer.js +73 -57
  158. package/out/server/naslServer.js.map +1 -1
  159. package/out/server/translator.d.ts +0 -3
  160. package/out/server/translator.js +16 -7
  161. package/out/server/translator.js.map +1 -1
  162. package/out/service/storage/init.js +21 -12
  163. package/out/service/storage/init.js.map +1 -1
  164. package/out/templator/genCreateBlock.js +3 -3
  165. package/out/templator/genCreateBlock.js.map +1 -1
  166. package/out/templator/genCurdEditMultipleKeyBlock.js +6 -10
  167. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  168. package/out/templator/genCurdMultipleKeyBlock.js +2 -2
  169. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  170. package/out/templator/genGetBlock.js +1 -1
  171. package/out/templator/genGetBlock.js.map +1 -1
  172. package/out/templator/genQueryComponent.d.ts +2 -0
  173. package/out/templator/genQueryComponent.js +1 -0
  174. package/out/templator/genQueryComponent.js.map +1 -1
  175. package/out/templator/genUpdateBlock.js +5 -5
  176. package/out/templator/genUpdateBlock.js.map +1 -1
  177. package/out/templator/utils.d.ts +3 -1
  178. package/out/templator/utils.js +2 -1
  179. package/out/templator/utils.js.map +1 -1
  180. package/package.json +1 -1
  181. package/src/automate/engine/index.js +1 -1
  182. package/src/common/BaseNode.ts +46 -42
  183. package/src/concepts/App__.ts +54 -12
  184. package/src/concepts/Argument__.ts +3 -2
  185. package/src/concepts/BinaryExpression__.ts +8 -6
  186. package/src/concepts/BindAttribute__.ts +26 -32
  187. package/src/concepts/BindDirective__.ts +24 -9
  188. package/src/concepts/BindEvent__.ts +25 -29
  189. package/src/concepts/CallFunction__.ts +11 -6
  190. package/src/concepts/CallInterface__.ts +11 -1
  191. package/src/concepts/CallLogic__.ts +21 -40
  192. package/src/concepts/CallQueryComponent__.ts +6 -10
  193. package/src/concepts/Comment__.ts +6 -2
  194. package/src/concepts/ConfigGroup__.ts +1 -1
  195. package/src/concepts/ConfigProperty__.ts +1 -1
  196. package/src/concepts/Configuration__.ts +1 -1
  197. package/src/concepts/Destination__.ts +9 -7
  198. package/src/concepts/EntityProperty__.ts +36 -0
  199. package/src/concepts/Entity__.ts +63 -50
  200. package/src/concepts/Enum__.ts +1 -1
  201. package/src/concepts/Event__.ts +1 -1
  202. package/src/concepts/ForEachStatement__.ts +8 -13
  203. package/src/concepts/Function__.ts +4 -4
  204. package/src/concepts/Identifier__.ts +15 -18
  205. package/src/concepts/IfStatement__.ts +2 -2
  206. package/src/concepts/InterfaceParam__.ts +11 -0
  207. package/src/concepts/Interface__.ts +3 -3
  208. package/src/concepts/LogicItem__.ts +15 -0
  209. package/src/concepts/Logic__.ts +34 -50
  210. package/src/concepts/Module__.ts +8 -8
  211. package/src/concepts/Namespace__.ts +12 -12
  212. package/src/concepts/Param__.ts +3 -0
  213. package/src/concepts/ProcessComponent__.ts +2 -2
  214. package/src/concepts/ProcessElement__.ts +5 -5
  215. package/src/concepts/ProcessOutcome__.ts +1 -1
  216. package/src/concepts/Process__.ts +4 -4
  217. package/src/concepts/QueryFromExpression__.ts +1 -1
  218. package/src/concepts/QueryJoinExpression__.ts +2 -2
  219. package/src/concepts/QuerySelectExpression__.ts +1 -1
  220. package/src/concepts/Return__.ts +6 -3
  221. package/src/concepts/StringLiteral__.ts +2 -2
  222. package/src/concepts/StructureProperty__.ts +36 -29
  223. package/src/concepts/Structure__.ts +3 -3
  224. package/src/concepts/SwitchCase__.ts +3 -3
  225. package/src/concepts/SwitchStatement__.ts +1 -1
  226. package/src/concepts/TypeAnnotation__.ts +8 -2
  227. package/src/concepts/UnaryExpression__.ts +1 -1
  228. package/src/concepts/ValidationRule__.ts +24 -1
  229. package/src/concepts/Variable__.ts +6 -3
  230. package/src/concepts/ViewComponent__.ts +5 -5
  231. package/src/concepts/ViewElement__.ts +183 -147
  232. package/src/concepts/View__.ts +30 -32
  233. package/src/concepts/WhileStatement__.ts +1 -1
  234. package/src/concepts/basics/stdlib/index.ts +3 -1
  235. package/src/concepts/basics/stdlib/nasl.auth.ts +35 -0
  236. package/src/concepts/basics/stdlib/nasl.browser.ts +7 -41
  237. package/src/concepts/basics/stdlib/nasl.configuration.ts +21 -0
  238. package/src/concepts/basics/stdlib/nasl.util.ts +0 -29
  239. package/src/enums/KEYWORDS.ts +1 -0
  240. package/src/generator/genBundleFiles.ts +102 -74
  241. package/src/server/createUiTs.ts +18 -3
  242. package/src/server/getLogics.ts +29 -47
  243. package/src/server/getMemberIdentifier.ts +3 -3
  244. package/src/server/getProcesses.ts +2 -2
  245. package/src/server/naslServer.ts +84 -62
  246. package/src/server/translator.ts +18 -6
  247. package/src/service/storage/init.ts +20 -13
  248. package/src/templator/genCreateBlock.ts +3 -3
  249. package/src/templator/genCurdEditMultipleKeyBlock.ts +22 -23
  250. package/src/templator/genCurdMultipleKeyBlock.ts +2 -2
  251. package/src/templator/genGetBlock.ts +1 -1
  252. package/src/templator/genQueryComponent.ts +1 -0
  253. package/src/templator/genUpdateBlock.ts +5 -6
  254. package/src/templator/utils.ts +2 -1
@@ -86,7 +86,8 @@ function transAstNodeToNaslNode(astNode: any, namespace?: string): any {
86
86
  }
87
87
  } else if (astNode.type === 'MemberExpression') {
88
88
  if (astNode.object?.name === '$global') {
89
- node = transAstNodeToNaslNode(astNode.property, 'nasl.browser');
89
+ // 目前只有权限相关的
90
+ node = transAstNodeToNaslNode(astNode.property, 'nasl.auth');
90
91
  } else {
91
92
  node = {
92
93
  concept: 'MemberExpression',
@@ -305,24 +306,24 @@ export class ViewElement extends BaseNode {
305
306
  }
306
307
 
307
308
  /**
308
- * 插入元素绑定属性
309
- * @internal
310
- * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
311
- */
309
+ * 插入元素绑定属性
310
+ * @internal
311
+ * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
312
+ */
312
313
  _insertBindAttributeAt(name: string, index: number): BindAttribute;
313
314
 
314
315
  /**
315
- * 插入元素绑定属性
316
- * @internal
317
- * @param bindAttributeOptions 元素绑定属性参数
318
- */
316
+ * 插入元素绑定属性
317
+ * @internal
318
+ * @param bindAttributeOptions 元素绑定属性参数
319
+ */
319
320
  _insertBindAttributeAt(bindAttributeOptions: Partial<BindAttribute>, index: number): BindAttribute;
320
321
 
321
322
  /**
322
- * 插入元素绑定属性
323
- * @internal
324
- * @param bindAttribute 已有的元素绑定属性实例
325
- */
323
+ * 插入元素绑定属性
324
+ * @internal
325
+ * @param bindAttribute 已有的元素绑定属性实例
326
+ */
326
327
  _insertBindAttributeAt(bindAttribute: BindAttribute, index: number): BindAttribute;
327
328
 
328
329
  _insertBindAttributeAt(options: string | Partial<BindAttribute> | BindAttribute, index: number) {
@@ -340,7 +341,7 @@ export class ViewElement extends BaseNode {
340
341
  name: options,
341
342
  }, this, 'bindAttrs');
342
343
  } else if (options instanceof BindAttribute) {
343
- options.delete(); // 同一实例不支持多处存在
344
+ options.ensureDelete(); // 同一实例不支持多处存在
344
345
  bindAttribute = options;
345
346
  Object.assign(bindAttribute, relationOptions);
346
347
  } else {
@@ -446,24 +447,24 @@ export class ViewElement extends BaseNode {
446
447
  }
447
448
 
448
449
  /**
449
- * 插入元素绑定事件
450
- * @internal
451
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
452
- */
450
+ * 插入元素绑定事件
451
+ * @internal
452
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
453
+ */
453
454
  _insertBindEventAt(name: string, index: number): BindEvent;
454
455
 
455
456
  /**
456
- * 插入元素绑定事件
457
- * @internal
458
- * @param bindEventOptions 元素绑定事件参数
459
- */
457
+ * 插入元素绑定事件
458
+ * @internal
459
+ * @param bindEventOptions 元素绑定事件参数
460
+ */
460
461
  _insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
461
462
 
462
463
  /**
463
- * 插入元素绑定事件
464
- * @internal
465
- * @param bindEvent 已有的元素绑定事件实例
466
- */
464
+ * 插入元素绑定事件
465
+ * @internal
466
+ * @param bindEvent 已有的元素绑定事件实例
467
+ */
467
468
  _insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
468
469
 
469
470
  _insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
@@ -481,7 +482,7 @@ export class ViewElement extends BaseNode {
481
482
  name: options,
482
483
  }, this, 'bindEvents');
483
484
  } else if (options instanceof BindEvent) {
484
- options.delete(); // 同一实例不支持多处存在
485
+ options.ensureDelete(); // 同一实例不支持多处存在
485
486
  bindEvent = options;
486
487
  Object.assign(bindEvent, relationOptions);
487
488
  } else {
@@ -587,24 +588,24 @@ export class ViewElement extends BaseNode {
587
588
  }
588
589
 
589
590
  /**
590
- * 插入元素指令
591
- * @internal
592
- * @param name 元素指令名称,如果不填会自动生成一个唯一名称
593
- */
591
+ * 插入元素指令
592
+ * @internal
593
+ * @param name 元素指令名称,如果不填会自动生成一个唯一名称
594
+ */
594
595
  _insertBindDirectiveAt(name: string, index: number): BindDirective;
595
596
 
596
597
  /**
597
- * 插入元素指令
598
- * @internal
599
- * @param bindDirectiveOptions 元素指令参数
600
- */
598
+ * 插入元素指令
599
+ * @internal
600
+ * @param bindDirectiveOptions 元素指令参数
601
+ */
601
602
  _insertBindDirectiveAt(bindDirectiveOptions: Partial<BindDirective>, index: number): BindDirective;
602
603
 
603
604
  /**
604
- * 插入元素指令
605
- * @internal
606
- * @param bindDirective 已有的元素指令实例
607
- */
605
+ * 插入元素指令
606
+ * @internal
607
+ * @param bindDirective 已有的元素指令实例
608
+ */
608
609
  _insertBindDirectiveAt(bindDirective: BindDirective, index: number): BindDirective;
609
610
 
610
611
  _insertBindDirectiveAt(options: string | Partial<BindDirective> | BindDirective, index: number) {
@@ -622,7 +623,7 @@ export class ViewElement extends BaseNode {
622
623
  name: options,
623
624
  }, this, 'bindDirectives');
624
625
  } else if (options instanceof BindDirective) {
625
- options.delete(); // 同一实例不支持多处存在
626
+ options.ensureDelete(); // 同一实例不支持多处存在
626
627
  bindDirective = options;
627
628
  Object.assign(bindDirective, relationOptions);
628
629
  } else {
@@ -720,24 +721,24 @@ export class ViewElement extends BaseNode {
720
721
  }
721
722
 
722
723
  /**
723
- * 插入页面元素
724
- * @internal
725
- * @param name 页面元素名称,如果不填会自动生成一个唯一名称
726
- */
724
+ * 插入页面元素
725
+ * @internal
726
+ * @param name 页面元素名称,如果不填会自动生成一个唯一名称
727
+ */
727
728
  _insertViewElementAt(name: string, index: number): ViewElement;
728
729
 
729
730
  /**
730
- * 插入页面元素
731
- * @internal
732
- * @param viewElementOptions 页面元素参数
733
- */
731
+ * 插入页面元素
732
+ * @internal
733
+ * @param viewElementOptions 页面元素参数
734
+ */
734
735
  _insertViewElementAt(viewElementOptions: Partial<ViewElement>, index: number): ViewElement;
735
736
 
736
737
  /**
737
- * 插入页面元素
738
- * @internal
739
- * @param viewElement 已有的页面元素实例
740
- */
738
+ * 插入页面元素
739
+ * @internal
740
+ * @param viewElement 已有的页面元素实例
741
+ */
741
742
  _insertViewElementAt(viewElement: ViewElement, index: number): ViewElement;
742
743
 
743
744
  _insertViewElementAt(options: string | Partial<ViewElement> | ViewElement, index: number) {
@@ -755,7 +756,7 @@ export class ViewElement extends BaseNode {
755
756
  name: options,
756
757
  }, this, 'children');
757
758
  } else if (options instanceof ViewElement) {
758
- options.delete(); // 同一实例不支持多处存在
759
+ options.ensureDelete(); // 同一实例不支持多处存在
759
760
  viewElement = options;
760
761
  Object.assign(viewElement, relationOptions);
761
762
  } else {
@@ -853,9 +854,9 @@ export class ViewElement extends BaseNode {
853
854
  }
854
855
 
855
856
  /**
856
- * 删除元素绑定属性
857
- * @param name 元素绑定属性名称
858
- */
857
+ * 删除元素绑定属性
858
+ * @param name 元素绑定属性名称
859
+ */
859
860
  removeBindAttribute(name: string): void;
860
861
 
861
862
  /**
@@ -901,9 +902,9 @@ export class ViewElement extends BaseNode {
901
902
  }
902
903
 
903
904
  /**
904
- * 删除元素绑定事件
905
- * @param name 元素绑定事件名称
906
- */
905
+ * 删除元素绑定事件
906
+ * @param name 元素绑定事件名称
907
+ */
907
908
  removeBindEvent(name: string): void;
908
909
 
909
910
  /**
@@ -949,9 +950,9 @@ export class ViewElement extends BaseNode {
949
950
  }
950
951
 
951
952
  /**
952
- * 删除元素指令
953
- * @param name 元素指令名称
954
- */
953
+ * 删除元素指令
954
+ * @param name 元素指令名称
955
+ */
955
956
  removeBindDirective(name: string): void;
956
957
 
957
958
  /**
@@ -997,9 +998,9 @@ export class ViewElement extends BaseNode {
997
998
  }
998
999
 
999
1000
  /**
1000
- * 删除页面元素
1001
- * @param name 页面元素名称
1002
- */
1001
+ * 删除页面元素
1002
+ * @param name 页面元素名称
1003
+ */
1003
1004
  removeViewElement(name: string): void;
1004
1005
 
1005
1006
  /**
@@ -1053,7 +1054,7 @@ export class ViewElement extends BaseNode {
1053
1054
  get parentAuth() {
1054
1055
  const _nameSpace = this.view.getNamespace();
1055
1056
  const mainViewName = _nameSpace.split('.')[2];
1056
- return this.app.views.find((item) => item.name === mainViewName)?.auth;
1057
+ return this.view.parentNode.concept === 'App' ? this.view.auth : this.app.views.find((item) => item.name === mainViewName)?.auth;
1057
1058
  }
1058
1059
 
1059
1060
  getViewElementUniqueName(name = 'viewElement1') {
@@ -1092,8 +1093,9 @@ export class ViewElement extends BaseNode {
1092
1093
  }
1093
1094
 
1094
1095
  haveScope(node: ViewElement): boolean {
1095
- const dataSourcePcList = ['uGallery', 'uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect'];
1096
- const dataSourceH5List = ['vanListView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
1096
+ // uGallery 没有子集不需要scope
1097
+ const dataSourcePcList = ['uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect'];
1098
+ const dataSourceH5List = ['vanListView', 'vanGridView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
1097
1099
  const dataSourceList = [...dataSourcePcList, ...dataSourceH5List];
1098
1100
  return dataSourceList.includes(node.toHump(node.tag));
1099
1101
  }
@@ -1231,6 +1233,11 @@ export class ViewElement extends BaseNode {
1231
1233
  tabSize: state.tabSize + 2,
1232
1234
  })) + ',\n';
1233
1235
  }
1236
+ if (Array.isArray(attr.rules) && attr.rules.length) {
1237
+ attr.rules.forEach((item) => {
1238
+ code += item.toEmbeddedTS(shiftState(state, code)) + ',\n';
1239
+ });
1240
+ }
1234
1241
  });
1235
1242
  this.bindDirectives.forEach((directive) => {
1236
1243
  if (directive.expression) {
@@ -1336,6 +1343,11 @@ export class ViewElement extends BaseNode {
1336
1343
  */
1337
1344
  private static _fromASTNode(astNode: compiler.ASTElement, context?: ParseContext): ViewElement {
1338
1345
  const view: View = context?.view;
1346
+ // 从祖先节点收集的slot列表
1347
+ let slotScopeList: string[] = [];
1348
+ if (Array.isArray(context?.slotScopeList)) {
1349
+ slotScopeList = [...context?.slotScopeList];
1350
+ }
1339
1351
  // 临时处理组件的 text
1340
1352
  //h5-mock
1341
1353
  if (
@@ -1350,13 +1362,13 @@ export class ViewElement extends BaseNode {
1350
1362
  });
1351
1363
  astNode.children = [];
1352
1364
  }
1353
-
1354
1365
  // 将 scopedSlots 合并到 children 中
1355
1366
  if (astNode.scopedSlots) {
1356
1367
  astNode.children = astNode.children || [];
1357
1368
  Object.keys(astNode.scopedSlots).forEach((key) => {
1358
- if (!astNode.children.find((child) => key === (child as compiler.ASTElement).slotTarget))
1369
+ if (!astNode.children.find((child) => key === (child as compiler.ASTElement).slotTarget)) {
1359
1370
  astNode.children.unshift(astNode.scopedSlots[key]);
1371
+ }
1360
1372
  });
1361
1373
  delete astNode.scopedSlots;
1362
1374
  }
@@ -1375,8 +1387,17 @@ export class ViewElement extends BaseNode {
1375
1387
  } else {
1376
1388
  astNode.tag = 'u-router-view';
1377
1389
  }
1390
+ } else if (astNode.tag === 'template') {
1391
+ slotScopeList.unshift(astNode.slotScope);
1378
1392
  }
1379
1393
  const tagName = astNode.tag.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1394
+ let newContext: any = {};
1395
+ if (context) {
1396
+ newContext = {
1397
+ ...context,
1398
+ };
1399
+ }
1400
+ newContext.slotScopeList = slotScopeList;
1380
1401
  element = new ViewElement({
1381
1402
  tag: astNode.tag,
1382
1403
  name: astNode.attrsMap.ref || view.getViewElementUniqueName(`${tagName}1`),
@@ -1384,45 +1405,43 @@ export class ViewElement extends BaseNode {
1384
1405
  staticStyle: astNode.attrsMap.style,
1385
1406
  slotTarget: astNode.slotTarget && json5.parse(astNode.slotTarget),
1386
1407
  slotScope: astNode.slotScope === '_empty_' ? '' : astNode.slotScope,
1387
- children: astNode.children.map((item) => this._fromASTNode(item as compiler.ASTElement, context)) as unknown as Array<ViewElement>,
1408
+ children: astNode.children.map((item) => this._fromASTNode(item as compiler.ASTElement, newContext)) as unknown as Array<ViewElement>,
1388
1409
  });
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) {
1410
+ astNode?.attrs?.forEach((oldAttr) => {
1411
+ let attr: BindAttribute;
1412
+ if (oldAttr.value === '""' && (oldAttr as any).end - (oldAttr as any).start === oldAttr.name.length) {
1413
+ attr = new BindAttribute({
1414
+ type: 'static',
1415
+ name: oldAttr.name,
1416
+ value: 'true',
1417
+ });
1418
+ } else {
1419
+ try {
1420
+ const tmp = json5.parse(oldAttr.value);
1421
+ const source: any = {
1422
+ type: typeof tmp === 'string' ? 'string' : 'static',
1423
+ name: oldAttr.name,
1424
+ value: typeof tmp === 'string' ? tmp : oldAttr.value,
1425
+ };
1426
+ if (oldAttr.name === 'rules') {
1427
+ source.rules = tmp?.split('|').map((ruleStr: string) => this._parseValidationRule(ruleStr.trim()));
1428
+ }
1429
+ attr = new BindAttribute(source);
1430
+ } catch (e) {
1431
+ const expression = <any> this._parseExpression(oldAttr.value);
1394
1432
  attr = new BindAttribute({
1395
- type: 'static',
1433
+ type: 'dynamic',
1396
1434
  name: oldAttr.name,
1397
- value: 'true',
1435
+ value: expression ? '' : oldAttr.value,
1436
+ expression,
1398
1437
  });
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
- }
1438
+ if (astNode.attrsMap[`:${attr.name}.sync`]) {
1439
+ attr.sync = true;
1422
1440
  }
1423
1441
  }
1424
- element.addBindAttribute(attr);
1425
- });
1442
+ }
1443
+ element.addBindAttribute(attr);
1444
+ });
1426
1445
 
1427
1446
  // compiler 处理:value.sync 时会加上update:value事件,需要过滤
1428
1447
  astNode.events
@@ -1437,19 +1456,24 @@ export class ViewElement extends BaseNode {
1437
1456
  if (matchArr?.length >= 2) {
1438
1457
  argsStr = matchArr[1];
1439
1458
  }
1459
+ const newArgList = ['$event', ...slotScopeList];
1440
1460
  let args: any[] = [];
1441
- if (argsStr) {
1442
- args = argsStr.split(',').map((argStr) => {
1443
- const keyword = argStr.trim().split('.');
1444
- return {
1445
- concept: 'Argument',
1446
- expression: genArgumentMemberExpression(keyword),
1447
- };
1448
- });
1449
- }
1450
- const viewNamespace = view?.getNamespace();
1451
- const viewName = `${view?.name}`;
1452
- let calleeNamespace = `${viewNamespace}.${viewName}.logics`;
1461
+ const argStrs: string[] = argsStr.split(',');
1462
+ argStrs.forEach((argStr) => {
1463
+ const index = newArgList.indexOf(argStr.trim());
1464
+ if (index !== -1) {
1465
+ newArgList.splice(index, 1);
1466
+ }
1467
+ });
1468
+ argStrs.push(...newArgList);
1469
+ args = argStrs.filter((argStr) => !!argStr && argStr !== '_empty_').map((argStr) => {
1470
+ const keyword = argStr.trim().split('.');
1471
+ return {
1472
+ concept: 'Argument',
1473
+ expression: genArgumentMemberExpression(keyword),
1474
+ };
1475
+ });
1476
+ let calleeNamespace = '';
1453
1477
  if (calleeName) {
1454
1478
  const namespaceArr = calleeName.split('.');
1455
1479
  const start = namespaceArr.shift();
@@ -1504,15 +1528,12 @@ export class ViewElement extends BaseNode {
1504
1528
  }));
1505
1529
  }
1506
1530
  } 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
- }
1531
+ const tagName = config.scope === 'h5' ? 'van-text' : 'u-text';
1532
+ const baseName = tagName.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1533
+ element = new ViewElement({
1534
+ tag: tagName,
1535
+ name: view.getViewElementUniqueName(`${baseName}1`),
1536
+ });
1516
1537
  const value = astNode.text.match(/{{(.*?)}}/)[1].trim();
1517
1538
  const expression = <any> this._parseExpression(value);
1518
1539
  element.addBindAttribute(new BindAttribute({
@@ -1522,15 +1543,12 @@ export class ViewElement extends BaseNode {
1522
1543
  expression,
1523
1544
  }));
1524
1545
  } 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
- }
1546
+ const tagName = config.scope === 'h5' ? 'van-text' : 'u-text';
1547
+ const baseName = tagName.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1548
+ element = new ViewElement({
1549
+ tag: tagName,
1550
+ name: view.getViewElementUniqueName(`${baseName}1`),
1551
+ });
1534
1552
  element.addBindAttribute(new BindAttribute({
1535
1553
  name: 'text',
1536
1554
  type: 'string',
@@ -1557,24 +1575,14 @@ export class ViewElement extends BaseNode {
1557
1575
  let ast = compiler.compile(html, compilerOptions).ast;
1558
1576
  if (ast.tag === 'template' && !ast.slotTarget)
1559
1577
  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;
1578
+ return this._fromASTNode(ast, context);
1570
1579
  }
1571
1580
 
1572
1581
  /**
1573
1582
  * 从模板生成规范的 ViewElement 对象
1574
1583
  */
1575
1584
  public static fromHTML(html: string, context?: ParseContext) {
1576
- const element = this.parse(html, context);
1577
- return element;
1585
+ return this.parse(html, context);
1578
1586
  }
1579
1587
 
1580
1588
  /**
@@ -1613,7 +1621,12 @@ export class ViewElement extends BaseNode {
1613
1621
  if (apiOfAttr && !apiOfAttr.type.includes('string'))
1614
1622
  return '';
1615
1623
  }
1616
- return `${name}="{{ ${value.replace(/"/g, "'").replace(/\$utils\['(.+?)'\]/g, '$1')} }}"`;
1624
+ value = value
1625
+ .replace(/"/g, "'")
1626
+ .replace(/\$utils\['(.+?)'\]/g, '$1')
1627
+ .replace(/\$refs./g, 'elements.')
1628
+ .replace(/\$global./g, 'nasl.auth.');
1629
+ return `${name}="{{ ${value} }}"`;
1617
1630
  });
1618
1631
  else
1619
1632
  return defaultResult;
@@ -1728,11 +1741,34 @@ export class ViewElement extends BaseNode {
1728
1741
  let params: Params = null;
1729
1742
  if (this.parentNode) {
1730
1743
  params = (this.parentNode as any)?.__removeViewElement?.(this);
1731
- (this.view as any)?.removeExistingViewElement(this);
1744
+ this.traverseChildren((ele: ViewElement) => {
1745
+ (this.view as any)?.removeExistingViewElement(ele);
1746
+ });
1732
1747
  }
1733
1748
  return params;
1734
1749
  }
1735
1750
 
1751
+ findElementByName(name: string): ViewElement {
1752
+ return utils.traverse((current) => {
1753
+ if (current.node.name === name)
1754
+ return current.node;
1755
+ }, { node: this });
1756
+ }
1757
+
1758
+ findElementByTag(tag: string): ViewElement {
1759
+ return utils.traverse((current) => {
1760
+ if (current.node.tag === tag)
1761
+ return current.node;
1762
+ }, { node: this });
1763
+ }
1764
+
1765
+ findElementByAttr(name: string, value: string): ViewElement {
1766
+ return utils.traverse((current) => {
1767
+ if (current.node.bindAttrs.some((attr) => attr.name === name && attr.value === value))
1768
+ return current.node;
1769
+ }, { node: this });
1770
+ }
1771
+
1736
1772
  //================================================================================
1737
1773
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1738
1774
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓