@lcap/nasl 2.20.0-beta.3 → 2.20.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/out/automate/engine/index.d.ts +1 -1
  2. package/out/automate/engine/index.js +2 -3
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/uniqueName.d.ts +1 -1
  5. package/out/automate/engine/uniqueName.js +2 -2
  6. package/out/automate/engine/uniqueName.js.map +1 -1
  7. package/out/automate/engine/utils.js +4 -1
  8. package/out/automate/engine/utils.js.map +1 -1
  9. package/out/automate/template/myProcess.d.ts +1 -1
  10. package/out/automate/template/myProcess.js +2 -2
  11. package/out/automate/template/myProcess.js.map +1 -1
  12. package/out/bak/translator.js +14 -22
  13. package/out/bak/translator.js.map +1 -1
  14. package/out/common/BaseNode.js +4 -1
  15. package/out/common/BaseNode.js.map +1 -1
  16. package/out/common/Command.d.ts +1 -0
  17. package/out/common/Command.js +5 -1
  18. package/out/common/Command.js.map +1 -1
  19. package/out/concepts/App__.d.ts +4 -0
  20. package/out/concepts/App__.js +30 -6
  21. package/out/concepts/App__.js.map +1 -1
  22. package/out/concepts/Assignee__.js +4 -3
  23. package/out/concepts/Assignee__.js.map +1 -1
  24. package/out/concepts/BatchAssignment__.js +3 -3
  25. package/out/concepts/BatchAssignment__.js.map +1 -1
  26. package/out/concepts/BindAttribute__.d.ts +7 -0
  27. package/out/concepts/BindAttribute__.js +270 -39
  28. package/out/concepts/BindAttribute__.js.map +1 -1
  29. package/out/concepts/BindDirective__.d.ts +7 -0
  30. package/out/concepts/BindDirective__.js +215 -17
  31. package/out/concepts/BindDirective__.js.map +1 -1
  32. package/out/concepts/BindStyle__.d.ts +7 -0
  33. package/out/concepts/BindStyle__.js +194 -4
  34. package/out/concepts/BindStyle__.js.map +1 -1
  35. package/out/concepts/CallFunction__.js +22 -8
  36. package/out/concepts/CallFunction__.js.map +1 -1
  37. package/out/concepts/CallInterface__.js +3 -2
  38. package/out/concepts/CallInterface__.js.map +1 -1
  39. package/out/concepts/CallLogic__.d.ts +3 -0
  40. package/out/concepts/CallLogic__.js +78 -89
  41. package/out/concepts/CallLogic__.js.map +1 -1
  42. package/out/concepts/CallQueryComponent__.js +20 -3
  43. package/out/concepts/CallQueryComponent__.js.map +1 -1
  44. package/out/concepts/ConfigGroup__.d.ts +1 -0
  45. package/out/concepts/ConfigGroup__.js +13 -0
  46. package/out/concepts/ConfigGroup__.js.map +1 -1
  47. package/out/concepts/ConfigProperty__.d.ts +19 -0
  48. package/out/concepts/ConfigProperty__.js +61 -0
  49. package/out/concepts/ConfigProperty__.js.map +1 -1
  50. package/out/concepts/Configuration__.d.ts +1 -0
  51. package/out/concepts/Configuration__.js +13 -0
  52. package/out/concepts/Configuration__.js.map +1 -1
  53. package/out/concepts/DataSource__.js.map +1 -1
  54. package/out/concepts/Destination__.d.ts +1 -0
  55. package/out/concepts/Destination__.js +61 -7
  56. package/out/concepts/Destination__.js.map +1 -1
  57. package/out/concepts/EntityProperty__.js +9 -1
  58. package/out/concepts/EntityProperty__.js.map +1 -1
  59. package/out/concepts/EnumItem__.d.ts +5 -5
  60. package/out/concepts/EnumItem__.js +6 -6
  61. package/out/concepts/Enum__.d.ts +20 -19
  62. package/out/concepts/Enum__.js +28 -1
  63. package/out/concepts/Enum__.js.map +1 -1
  64. package/out/concepts/ExternalDestination__.d.ts +1 -0
  65. package/out/concepts/ExternalDestination__.js +21 -3
  66. package/out/concepts/ExternalDestination__.js.map +1 -1
  67. package/out/concepts/ForEachStatement__.js +2 -0
  68. package/out/concepts/ForEachStatement__.js.map +1 -1
  69. package/out/concepts/Frontend__.d.ts +2 -1
  70. package/out/concepts/Frontend__.js.map +1 -1
  71. package/out/concepts/Identifier__.js +16 -5
  72. package/out/concepts/Identifier__.js.map +1 -1
  73. package/out/concepts/InterfaceParam__.js +9 -1
  74. package/out/concepts/InterfaceParam__.js.map +1 -1
  75. package/out/concepts/JSBlock__.js +5 -1
  76. package/out/concepts/JSBlock__.js.map +1 -1
  77. package/out/concepts/Logic__.d.ts +79 -79
  78. package/out/concepts/Logic__.js +16 -3
  79. package/out/concepts/Logic__.js.map +1 -1
  80. package/out/concepts/Match__.d.ts +0 -3
  81. package/out/concepts/Match__.js +11 -66
  82. package/out/concepts/Match__.js.map +1 -1
  83. package/out/concepts/MemberExpression__.js +9 -0
  84. package/out/concepts/MemberExpression__.js.map +1 -1
  85. package/out/concepts/Module__.d.ts +16 -0
  86. package/out/concepts/Module__.js +43 -0
  87. package/out/concepts/Module__.js.map +1 -1
  88. package/out/concepts/NewComposite__.d.ts +2 -4
  89. package/out/concepts/NewComposite__.js +91 -126
  90. package/out/concepts/NewComposite__.js.map +1 -1
  91. package/out/concepts/NewList__.d.ts +1 -0
  92. package/out/concepts/NewList__.js +22 -2
  93. package/out/concepts/NewList__.js.map +1 -1
  94. package/out/concepts/NewMap__.d.ts +1 -0
  95. package/out/concepts/NewMap__.js +43 -11
  96. package/out/concepts/NewMap__.js.map +1 -1
  97. package/out/concepts/OqlQueryComponent__.js +40 -12
  98. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  99. package/out/concepts/Param__.js +10 -2
  100. package/out/concepts/Param__.js.map +1 -1
  101. package/out/concepts/ProcessElement__.js +2 -1
  102. package/out/concepts/ProcessElement__.js.map +1 -1
  103. package/out/concepts/ProcessOutcome__.js +1 -1
  104. package/out/concepts/ProcessOutcome__.js.map +1 -1
  105. package/out/concepts/ProcessOutcomes__.js +1 -1
  106. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  107. package/out/concepts/Process__.js +1 -0
  108. package/out/concepts/Process__.js.map +1 -1
  109. package/out/concepts/Return__.js +10 -2
  110. package/out/concepts/Return__.js.map +1 -1
  111. package/out/concepts/StringInterpolation__.js +14 -2
  112. package/out/concepts/StringInterpolation__.js.map +1 -1
  113. package/out/concepts/StringLiteral__.js +6 -6
  114. package/out/concepts/StringLiteral__.js.map +1 -1
  115. package/out/concepts/StructureProperty__.js +9 -1
  116. package/out/concepts/StructureProperty__.js.map +1 -1
  117. package/out/concepts/TypeAnnotation__.d.ts +6 -3
  118. package/out/concepts/TypeAnnotation__.js +67 -13
  119. package/out/concepts/TypeAnnotation__.js.map +1 -1
  120. package/out/concepts/ValidationRule__.d.ts +1 -0
  121. package/out/concepts/ValidationRule__.js +53 -0
  122. package/out/concepts/ValidationRule__.js.map +1 -1
  123. package/out/concepts/Variable__.js +9 -1
  124. package/out/concepts/Variable__.js.map +1 -1
  125. package/out/concepts/ViewElement__.js +17 -1
  126. package/out/concepts/ViewElement__.js.map +1 -1
  127. package/out/concepts/View__.d.ts +1 -3
  128. package/out/concepts/View__.js +22 -11
  129. package/out/concepts/View__.js.map +1 -1
  130. package/out/concepts/basics/stdlib/nasl.collection.js +6 -1
  131. package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -1
  132. package/out/concepts/basics/stdlib/nasl.configuration.js +3 -0
  133. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
  134. package/out/concepts/basics/stdlib/nasl.core.d.ts +2 -0
  135. package/out/concepts/basics/stdlib/nasl.core.js +34 -0
  136. package/out/concepts/basics/stdlib/nasl.core.js.map +1 -1
  137. package/out/concepts/basics/stdlib/nasl.util.js +4 -2
  138. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  139. package/out/concepts/basics/types/index.d.ts +1 -0
  140. package/out/concepts/basics/types/index.js +3 -1
  141. package/out/concepts/basics/types/index.js.map +1 -1
  142. package/out/concepts/index__.d.ts +0 -1
  143. package/out/concepts/index__.js +0 -1
  144. package/out/concepts/index__.js.map +1 -1
  145. package/out/enums/KEYWORDS.js +8 -0
  146. package/out/enums/KEYWORDS.js.map +1 -1
  147. package/out/generator/genBundleFiles.js +24 -5
  148. package/out/generator/genBundleFiles.js.map +1 -1
  149. package/out/generator/genReleaseBody.d.ts +2 -3
  150. package/out/generator/genReleaseBody.js +97 -23
  151. package/out/generator/genReleaseBody.js.map +1 -1
  152. package/out/generator/permission.d.ts +2 -10
  153. package/out/generator/permission.js +26 -13
  154. package/out/generator/permission.js.map +1 -1
  155. package/out/server/entity2LogicNamespace.js +2 -20
  156. package/out/server/entity2LogicNamespace.js.map +1 -1
  157. package/out/server/extendBaseNode.js +16 -5
  158. package/out/server/extendBaseNode.js.map +1 -1
  159. package/out/server/formatTsUtils.d.ts +2 -1
  160. package/out/server/formatTsUtils.js +40 -10
  161. package/out/server/formatTsUtils.js.map +1 -1
  162. package/out/server/getLogics.d.ts +2 -2
  163. package/out/server/getLogics.js +3 -3
  164. package/out/server/getLogics.js.map +1 -1
  165. package/out/server/getMemberIdentifier.d.ts +1 -0
  166. package/out/server/getMemberIdentifier.js +27 -1
  167. package/out/server/getMemberIdentifier.js.map +1 -1
  168. package/out/server/index.js +1 -0
  169. package/out/server/index.js.map +1 -1
  170. package/out/server/naslServer.d.ts +7 -1
  171. package/out/server/naslServer.js +519 -46
  172. package/out/server/naslServer.js.map +1 -1
  173. package/out/server/translator.js +109 -33
  174. package/out/server/translator.js.map +1 -1
  175. package/out/service/storage/init.js +21 -1
  176. package/out/service/storage/init.js.map +1 -1
  177. package/out/templator/genCreateBlock.js +1 -3
  178. package/out/templator/genCreateBlock.js.map +1 -1
  179. package/out/templator/genCurdEditMultipleKeyBlock.js +1 -3
  180. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  181. package/out/templator/genCurdMultipleKeyBlock.js +2 -4
  182. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  183. package/out/templator/genGetBlock.js +1 -1
  184. package/out/templator/genGetBlock.js.map +1 -1
  185. package/out/templator/genGridViewBlock.js +2 -2
  186. package/out/templator/genGridViewBlock.js.map +1 -1
  187. package/out/templator/genListViewBlock.js +7 -1
  188. package/out/templator/genListViewBlock.js.map +1 -1
  189. package/out/templator/genSelectBlock.js +1 -1
  190. package/out/templator/genSelectBlock.js.map +1 -1
  191. package/out/templator/genTableBlock.js +2 -2
  192. package/out/templator/genTableBlock.js.map +1 -1
  193. package/out/templator/genUpdateBlock.js +2 -3
  194. package/out/templator/genUpdateBlock.js.map +1 -1
  195. package/out/utils/traverse.js +8 -2
  196. package/out/utils/traverse.js.map +1 -1
  197. package/package.json +2 -2
  198. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  199. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  200. package/sandbox/stdlib/nasl.collection.ts +1 -0
  201. package/sandbox/stdlib/nasl.core.ts +34 -0
  202. package/sandbox/stdlib/nasl.oql.ts +71 -15
  203. package/sandbox/stdlib/nasl.util.ts +9 -3
  204. package/src/automate/engine/dist/index.dev.js +517 -0
  205. package/src/automate/engine/index.js +2 -3
  206. package/src/automate/engine/uniqueName.js +2 -2
  207. package/src/automate/engine/utils.js +4 -2
  208. package/src/automate/template/myProcess.js +2 -2
  209. package/src/bak/translator.js +16 -25
  210. package/src/common/BaseNode.ts +3 -1
  211. package/src/common/Command.ts +4 -0
  212. package/src/common/dist/BaseNode.js +1101 -0
  213. package/src/concepts/App__.ts +36 -7
  214. package/src/concepts/Assignee__.ts +4 -3
  215. package/src/concepts/BatchAssignment__.ts +3 -3
  216. package/src/concepts/BindAttribute__.ts +299 -38
  217. package/src/concepts/BindDirective__.ts +204 -31
  218. package/src/concepts/BindStyle__.ts +187 -24
  219. package/src/concepts/CallFunction__.ts +55 -10
  220. package/src/concepts/CallInterface__.ts +3 -2
  221. package/src/concepts/CallLogic__.ts +110 -90
  222. package/src/concepts/CallQueryComponent__.ts +18 -3
  223. package/src/concepts/ConfigGroup__.ts +17 -4
  224. package/src/concepts/ConfigProperty__.ts +70 -4
  225. package/src/concepts/Configuration__.ts +14 -5
  226. package/src/concepts/DataSource__.ts +4 -1
  227. package/src/concepts/Destination__.ts +61 -7
  228. package/src/concepts/EntityProperty__.ts +7 -1
  229. package/src/concepts/EnumItem__.ts +6 -6
  230. package/src/concepts/Enum__.ts +22 -19
  231. package/src/concepts/ExternalDestination__.ts +28 -8
  232. package/src/concepts/ForEachStatement__.ts +2 -0
  233. package/src/concepts/Frontend__.ts +2 -1
  234. package/src/concepts/Identifier__.ts +16 -5
  235. package/src/concepts/InterfaceParam__.ts +7 -1
  236. package/src/concepts/JSBlock__.ts +3 -2
  237. package/src/concepts/Logic__.ts +95 -83
  238. package/src/concepts/Match__.ts +31 -67
  239. package/src/concepts/MemberExpression__.ts +6 -0
  240. package/src/concepts/Module__.ts +57 -0
  241. package/src/concepts/NewComposite__.ts +95 -140
  242. package/src/concepts/NewList__.ts +23 -2
  243. package/src/concepts/NewMap__.ts +48 -24
  244. package/src/concepts/OqlQueryComponent__.ts +40 -20
  245. package/src/concepts/Param__.ts +178 -176
  246. package/src/concepts/ProcessElement__.ts +2 -1
  247. package/src/concepts/ProcessOutcome__.ts +1 -1
  248. package/src/concepts/ProcessOutcomes__.ts +1 -1
  249. package/src/concepts/Process__.ts +1 -0
  250. package/src/concepts/Return__.ts +8 -2
  251. package/src/concepts/StringInterpolation__.ts +19 -7
  252. package/src/concepts/StringLiteral__.ts +7 -6
  253. package/src/concepts/StructureProperty__.ts +7 -1
  254. package/src/concepts/TypeAnnotation__.ts +101 -14
  255. package/src/concepts/ValidationRule__.ts +58 -9
  256. package/src/concepts/Variable__.ts +11 -1
  257. package/src/concepts/ViewElement__.ts +39 -2
  258. package/src/concepts/View__.ts +26 -14
  259. package/src/concepts/basics/stdlib/dist/nasl.util.js +1602 -0
  260. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
  261. package/src/concepts/basics/stdlib/nasl.collection.ts +6 -1
  262. package/src/concepts/basics/stdlib/nasl.configuration.ts +3 -0
  263. package/src/concepts/basics/stdlib/nasl.core.ts +33 -2
  264. package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
  265. package/src/concepts/basics/types/index.ts +1 -0
  266. package/src/concepts/dist/BindAttribute__.js +795 -0
  267. package/src/concepts/dist/BindEvent__.js +732 -0
  268. package/src/concepts/dist/CallFunction__.js +527 -0
  269. package/src/concepts/dist/CallLogic__.js +932 -0
  270. package/src/concepts/dist/Destination__.js +708 -0
  271. package/src/concepts/dist/ExternalDestination__.js +298 -0
  272. package/src/concepts/dist/Identifier__.js +311 -0
  273. package/src/concepts/dist/StringInterpolation__.js +231 -0
  274. package/src/concepts/dist/TypeAnnotation__.js +834 -0
  275. package/src/concepts/dist/ViewElement__.js +1692 -0
  276. package/src/concepts/dist/View__.js +1601 -0
  277. package/src/concepts/index__.ts +0 -1
  278. package/src/enums/KEYWORDS.ts +8 -0
  279. package/src/generator/dist/genBundleFiles.js +261 -0
  280. package/src/generator/dist/genMetaData.js +245 -0
  281. package/src/generator/dist/permission.js +405 -0
  282. package/src/generator/genBundleFiles.ts +24 -5
  283. package/src/generator/genReleaseBody.ts +75 -30
  284. package/src/generator/permission.ts +30 -14
  285. package/src/server/entity2LogicNamespace.ts +2 -20
  286. package/src/server/extendBaseNode.ts +15 -5
  287. package/src/server/formatTsUtils.ts +41 -10
  288. package/src/server/getLogics.ts +4 -4
  289. package/src/server/getMemberIdentifier.ts +27 -1
  290. package/src/server/index.ts +2 -0
  291. package/src/server/naslServer.ts +520 -48
  292. package/src/server/translator.ts +96 -34
  293. package/src/service/storage/dist/init.js +579 -0
  294. package/src/service/storage/init.ts +22 -2
  295. package/src/templator/dist/genEditTableBlock.js +204 -0
  296. package/src/templator/dist/genGridViewBlock.js +265 -0
  297. package/src/templator/dist/genListViewBlock.js +84 -0
  298. package/src/templator/dist/genTableBlock.js +209 -0
  299. package/src/templator/dist/utils.js +527 -0
  300. package/src/templator/genCreateBlock.ts +1 -3
  301. package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -3
  302. package/src/templator/genCurdMultipleKeyBlock.ts +2 -4
  303. package/src/templator/genGetBlock.ts +1 -1
  304. package/src/templator/genGridViewBlock.ts +3 -4
  305. package/src/templator/genListViewBlock.ts +9 -3
  306. package/src/templator/genSelectBlock.ts +1 -1
  307. package/src/templator/genTableBlock.ts +3 -3
  308. package/src/templator/genUpdateBlock.ts +2 -3
  309. package/src/utils/traverse.ts +10 -2
  310. package/ts-worker/lib/tsserver.js +10 -2
  311. package/ts-worker/package.json +1 -0
  312. package/ts-worker/webpack.config.js +11 -2
  313. package/out/concepts/ConstructArgument__.d.ts +0 -40
  314. package/out/concepts/ConstructArgument__.js +0 -108
  315. package/out/concepts/ConstructArgument__.js.map +0 -1
  316. package/out/concepts/Construct__.d.ts +0 -189
  317. package/out/concepts/Construct__.js +0 -340
  318. package/out/concepts/Construct__.js.map +0 -1
  319. package/out/templator/sql-parser/index.d.ts +0 -1
  320. package/out/templator/sql-parser/index.js +0 -228
  321. package/out/templator/sql-parser/index.js.map +0 -1
  322. package/out/templator/sql-parser/parser.js +0 -26664
  323. package/out/templator/sql-parser/parser.js.map +0 -1
@@ -1,7 +1,8 @@
1
- import { TranslatorState, shiftState, withSourceMap} from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
3
  import MemberExpression from './MemberExpression__';
4
4
  import StructureProperty from './StructureProperty__';
5
+ import App from './App__';
5
6
  //================================================================================
6
7
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
7
8
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -18,7 +19,6 @@ import Identifier from './Identifier__';
18
19
  import SelectMembers from './SelectMembers__';
19
20
  import AssignmentLine from './AssignmentLine__';
20
21
  import LogicItem from './LogicItem__';
21
- import App from './App__';
22
22
 
23
23
  /**
24
24
  * 实体/(匿名)数据结构构造器
@@ -73,8 +73,6 @@ export class NewComposite extends LogicItem {
73
73
  @property()
74
74
  autoConnection: boolean = true;
75
75
 
76
-
77
-
78
76
  /**
79
77
  * @param source 需要合并的部分参数
80
78
  */
@@ -88,7 +86,6 @@ export class NewComposite extends LogicItem {
88
86
  return super.from(source, parentNode, parentKey) as NewComposite;
89
87
  }
90
88
 
91
-
92
89
  /**
93
90
  * 设置类型
94
91
  */
@@ -176,7 +173,7 @@ export class NewComposite extends LogicItem {
176
173
  });
177
174
  }
178
175
 
179
- getIdentifierExistingNames(excludedList: Array<Identifier> = []) {
176
+ getIdentifierExistingNames(excludedList: Array<Identifier> = []) {
180
177
  const excludedSet = new Set(excludedList);
181
178
  return ((this.properties as Identifier[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
182
179
  }
@@ -317,7 +314,6 @@ export class NewComposite extends LogicItem {
317
314
  return node;
318
315
  }
319
316
 
320
-
321
317
  getSelectMembersExistingNames(excludedList: Array<SelectMembers> = []) {
322
318
  const excludedSet = new Set(excludedList);
323
319
  return ((this.rights as SelectMembers[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -459,7 +455,6 @@ export class NewComposite extends LogicItem {
459
455
  return node;
460
456
  }
461
457
 
462
-
463
458
  getAssignmentLineExistingNames(excludedList: Array<AssignmentLine> = []) {
464
459
  const excludedSet = new Set(excludedList);
465
460
  return ((this.assignmentLines as AssignmentLine[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -601,9 +596,6 @@ export class NewComposite extends LogicItem {
601
596
  return node;
602
597
  }
603
598
 
604
-
605
-
606
-
607
599
  /**
608
600
  * 删除类型标注
609
601
  * @param name 类型标注名称
@@ -652,8 +644,6 @@ export class NewComposite extends LogicItem {
652
644
  return params;
653
645
  }
654
646
 
655
-
656
-
657
647
  /**
658
648
  * 删除标识符
659
649
  * @param name 标识符名称
@@ -702,8 +692,6 @@ export class NewComposite extends LogicItem {
702
692
  return params;
703
693
  }
704
694
 
705
-
706
-
707
695
  /**
708
696
  * 删除选择成员
709
697
  * @param name 选择成员名称
@@ -752,8 +740,6 @@ export class NewComposite extends LogicItem {
752
740
  return params;
753
741
  }
754
742
 
755
-
756
-
757
743
  /**
758
744
  * 删除赋值连线
759
745
  * @param name 赋值连线名称
@@ -813,7 +799,6 @@ export class NewComposite extends LogicItem {
813
799
  async newConnection(addRightIndex?: number) {
814
800
  const leftLineSet = new Set();
815
801
  const lineArr: Array<AssignmentLine> = [];
816
- const connectionArr: any = [];
817
802
  // 系统属性不可自动连线
818
803
  ['id', 'createdTime', 'updatedTime', 'createdBy', 'updatedBy'].forEach((name) => leftLineSet.add(name));
819
804
  // 左边已连线的下标
@@ -823,17 +808,13 @@ export class NewComposite extends LogicItem {
823
808
  });
824
809
 
825
810
  const autoConnection = () => {
826
- let structure: any;
827
811
  const isAnnotation = this.typeAnnotation.typeKind === 'anonymousStructure';
828
- if (!isAnnotation)
829
- structure = this.app.findNodeByCompleteName(this.typeAnnotation.typeNamespace + '.' + this.typeAnnotation.typeName);
830
812
  this.app.emit('collect:start', {
831
813
  actionMsg: '自动连线',
832
814
  });
833
815
  this.properties.forEach((property: Identifier, leftSecondIndex: number) => {
834
816
  const leftName = property.name;
835
- const leftTypeAnnotation = !isAnnotation && structure.properties.find((p: StructureProperty) => p.name === property.name).typeAnnotation;
836
- const typeStruct = isAnnotation && this.typeAnnotation.properties[leftSecondIndex]; // 获取匿名数据结构typeAnnotation的具体property
817
+ const leftTypeAnnotation = !isAnnotation && property.__TypeAnnotation;
837
818
  if (leftLineSet.has(leftSecondIndex) || leftLineSet.has(leftName))
838
819
  return;
839
820
 
@@ -858,10 +839,6 @@ export class NewComposite extends LogicItem {
858
839
  rightIndex: [rightFirstIndex],
859
840
  });
860
841
  lineArr.push(Line);
861
- connectionArr.push({
862
- leftItem: typeStruct,
863
- rightItem: expression,
864
- });
865
842
  leftLineSet.add(leftSecondIndex);
866
843
  return;
867
844
  }
@@ -878,33 +855,21 @@ export class NewComposite extends LogicItem {
878
855
  const rightIndex = [rightFirstIndex, rightSecondIndex];
879
856
  const Line: AssignmentLine = new AssignmentLine({ leftIndex, rightIndex });
880
857
  lineArr.push(Line);
881
- connectionArr.push({
882
- leftItem: typeStruct,
883
- rightItem: rightMember,
884
- });
885
858
  leftLineSet.add(leftSecondIndex);
886
859
  }
887
860
  });
888
861
  });
889
862
  });
890
863
  lineArr.length && this.setAssignmentLines([...this.assignmentLines, ...lineArr]);
891
- if (this.typeAnnotation.typeKind === 'anonymousStructure') {
892
- connectionArr.forEach(({ leftItem, rightItem }: any) => {
893
- if (rightItem.__TypeAnnotation) {
894
- leftItem.update({
895
- typeAnnotation: TypeAnnotation.from({ ...rightItem.__TypeAnnotation.toJSON() }),
896
- });
897
- }
898
- });
899
- }
900
864
  this.app.emit('collect:end');
901
865
  };
902
866
 
903
867
  let count = 0;
904
868
  const typeAnnotationEnd = () => {
905
- const r = this.rights.every((right) => right.members.every((item) => item.__isCorrectTypeAnnotation));
869
+ const l = this.properties.every((item) => item.__isCorrectTypeAnnotation);
870
+ const r = this.rights.every((right) => right.members.every((item) => item.__isCorrectTypeAnnotation) && right.expression.__isCorrectTypeAnnotation);
906
871
  count++;
907
- if (r) {
872
+ if (r && l) {
908
873
  autoConnection();
909
874
  } else if (count <= 10) {
910
875
  setTimeout(() => {
@@ -947,47 +912,17 @@ export class NewComposite extends LogicItem {
947
912
  });
948
913
  newLines.push(Line);
949
914
 
950
- if (this.typeAnnotation.typeKind !== 'anonymousStructure') {
951
- this.update({
952
- assignmentLines: newLines,
953
- properties: newProperties,
954
- });
955
- } else {
956
- this.app.emit('collect:start', {
957
- actionMsg: '匿名数据结构连线',
958
- });
959
- // 匿名数据结构typeAnnotation变化
960
- const structureProperty = this.typeAnnotation.properties.find(({ name }) => name === leftItem.name);
961
- const exp = rightItem.concept === 'SelectMembers' ? rightItem.expression : rightItem;
962
- // 场景:右侧连接是非匿名数据
963
- if (exp.__TypeAnnotation && exp.__TypeAnnotation.typeKey !== 'nasl.core.Null') {
964
- structureProperty.update({
965
- typeAnnotation: TypeAnnotation.from({ ...exp.__TypeAnnotation.toJSON() }),
966
- });
967
- }
968
- this.update({
969
- assignmentLines: newLines,
970
- properties: newProperties,
971
- });
972
- this.app.emit('collect:end');
973
- }
915
+ this.update({
916
+ assignmentLines: newLines,
917
+ properties: newProperties,
918
+ });
974
919
  }
975
920
 
976
921
  deleteAssignmentLine(assignmentLine: AssignmentLine) {
977
922
  const newLine = this.assignmentLines.filter((line) => line !== assignmentLine);
978
- this.app.emit('collect:start', {
979
- actionMsg: '删除连线',
980
- });
981
- if (this.typeAnnotation.typeKind === 'anonymousStructure') {
982
- const typeStructureProperty = this.findMember(assignmentLine.leftIndex, 'left', true);
983
- typeStructureProperty.update({
984
- typeAnnotation: null,
985
- });
986
- }
987
923
  this.update({
988
924
  assignmentLines: newLine,
989
925
  });
990
- this.app.emit('collect:end');
991
926
  }
992
927
 
993
928
  changeLinesLocation(selectMember: any) {
@@ -999,7 +934,6 @@ export class NewComposite extends LogicItem {
999
934
  const newRights = this.rights.filter((member) => selectMember !== member);
1000
935
  const filterLine = this.assignmentLines.filter((line) => line.rightIndex[0] !== index);
1001
936
  const newLines: Array<AssignmentLine> = [];
1002
- const oldLines: AssignmentLine[] = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] === index);
1003
937
  filterLine.forEach((line) => {
1004
938
  if (line.rightIndex[0] > index) {
1005
939
  if (line.rightIndex[1] === undefined) {
@@ -1013,22 +947,10 @@ export class NewComposite extends LogicItem {
1013
947
  newLines.push(line);
1014
948
  }
1015
949
  });
1016
- this.app.emit('collect:start', {
1017
- actionMsg: '匿名数据结构删除右侧变量',
1018
- });
1019
- if (this.typeAnnotation.typeKind === 'anonymousStructure') {
1020
- oldLines.forEach(({ leftIndex }) => {
1021
- const leftItem = this.typeAnnotation.properties[leftIndex[1]];
1022
- leftItem.update({
1023
- typeAnnotation: null,
1024
- });
1025
- });
1026
- }
1027
950
  this.update({
1028
951
  rights: newRights,
1029
952
  assignmentLines: newLines,
1030
953
  });
1031
- this.app.emit('collect:end');
1032
954
  }
1033
955
  }
1034
956
 
@@ -1044,7 +966,7 @@ export class NewComposite extends LogicItem {
1044
966
  let oldLines: AssignmentLine[] = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] === splitIndex);
1045
967
  // 右侧变量改变后,修改连线
1046
968
  members.forEach((item, index) => {
1047
- if (keepMembers.has(item.completeName)) {
969
+ if (keepMembers?.has(item.completeName)) {
1048
970
  const lines = this.findlines(item, selectMember);
1049
971
  lines.forEach((line) => {
1050
972
  const newLine = Object.assign({}, line, { rightIndex: [line.rightIndex[0], index] });
@@ -1054,14 +976,6 @@ export class NewComposite extends LogicItem {
1054
976
  }
1055
977
  });
1056
978
 
1057
- if (this.typeAnnotation.typeKind === 'anonymousStructure') {
1058
- oldLines.forEach(({ leftIndex }) => {
1059
- const leftItem = this.typeAnnotation.properties[leftIndex[1]];
1060
- leftItem.update({
1061
- typeAnnotation: null,
1062
- });
1063
- });
1064
- }
1065
979
  this.update({
1066
980
  assignmentLines: newLines,
1067
981
  rights: [...this.rights.slice(0, splitIndex), newSelectMember, ...this.rights.slice(splitIndex + 1, this.rights.length)],
@@ -1094,11 +1008,8 @@ export class NewComposite extends LogicItem {
1094
1008
  return lines;
1095
1009
  }
1096
1010
 
1097
- findMember(arrIndex: Array<number>, place: string, isAnnotation?: boolean) {
1011
+ findMember(arrIndex: Array<number>, place: string) {
1098
1012
  const [firstIndex, secondIndex] = [arrIndex[0], arrIndex[1]];
1099
- if (isAnnotation) {
1100
- return this.typeAnnotation.properties[secondIndex];
1101
- }
1102
1013
 
1103
1014
  if (place === 'left') {
1104
1015
  if (secondIndex === undefined) {
@@ -1219,34 +1130,35 @@ export class NewComposite extends LogicItem {
1219
1130
  });
1220
1131
  // 方便ts报错检查
1221
1132
  code += 'function __newComposite() {\n';
1222
- code += `let obj = nasl.util.New<${this.typeAnnotation.sortedTypeKey}>();`;
1223
- code += '\n';
1133
+ code += `let __obj = nasl.util.New<${this.typeAnnotation.sortedTypeKey}>();\n`;
1224
1134
  // 是否是左边的顶层连线
1225
1135
  const leftTopIndex = this.assignmentLines.findIndex(({ leftIndex }) => leftIndex[1] === undefined);
1226
1136
  if (leftTopIndex !== -1) {
1227
1137
  const rightIndex = this.assignmentLines[leftTopIndex].rightIndex;
1228
1138
  const rightExpression = rightIndex[1] !== undefined ? this.rights[rightIndex[0]].members[rightIndex[1]] : this.rights[rightIndex[0]].expression;
1229
- code += `obj = ${rightExpression.toEmbeddedTS(shiftState(state, code, { inline: true }))};`;
1139
+ code += `__obj = ${rightExpression.toEmbeddedTS(shiftState(state, code, { inline: true }))};`;
1230
1140
  code += '\n';
1231
1141
  } else {
1142
+ // 左侧properties的identifier的类型标注
1143
+ code += 'const { ';
1144
+ this.properties.forEach((item, index) => {
1145
+ code += item.toEmbeddedTS(shiftState(state, code, { inline: true }));
1146
+ if (index < this.properties.length - 1)
1147
+ code += ', ';
1148
+ });
1149
+ code += ' } = __obj;\n';
1232
1150
  this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1233
1151
  const leftSecondIndex = leftIndex[1];
1234
1152
  const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
1235
1153
  const leftItem = this.properties[leftSecondIndex];
1236
1154
  const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
1237
1155
  const rightTs = rightMap.get(rightItem);
1238
- code += `obj.${leftItem.name} = ${['__IDENTIFIER__', '__IDENTIFIER__()'].includes(rightTs) ? 'null' : rightTs};`;
1239
- code += '\n';
1240
- });
1241
- // 左侧properties的identifier的类型标注
1242
- this.properties.forEach((item) => {
1243
- code += '{ const ';
1244
- const name = item.toEmbeddedTS(shiftState(state, code, { inline: true }));
1245
- code += `${name} = obj.${name};`;
1246
- code += '}\n';
1156
+ code += `nasl.core.compareNew(`;
1157
+ code += `${['__IDENTIFIER__', '__IDENTIFIER__()'].includes(rightTs) ? 'null' : rightMap.get(rightItem)}, `;
1158
+ code += `${leftItem.toEmbeddedTS(shiftState(state, code, { inline: true }))});\n`;
1247
1159
  });
1248
1160
  }
1249
- code += 'return obj;\n';
1161
+ code += 'return __obj;\n';
1250
1162
  code += '};\n';
1251
1163
 
1252
1164
  code += 'return __newComposite();\n';
@@ -1280,24 +1192,35 @@ export class NewComposite extends LogicItem {
1280
1192
  code += right.members.length ? '\n' : '';
1281
1193
  });
1282
1194
  // 方便ts报错检查
1283
- code += 'function __newComposite(): ';
1284
- code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code, { inline: true }));
1285
- code += '{\n';
1286
- this.properties.forEach((property) => {
1195
+ code += 'function __newComposite() {\n';
1196
+ this.properties.forEach((property, index) => {
1197
+ const temp = `temp${index}`;
1287
1198
  const name = property.name;
1288
1199
  const rightItem = nameMap.get(name);
1289
- if (rightMap.get(rightItem) !== undefined) {
1290
- code += `{ const x = ${rightMap.get(rightItem)}; const `;
1200
+ const ts = rightMap.get(rightItem);
1201
+ if (ts !== undefined) {
1202
+ if (['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
1203
+ code += `const ${temp}: any = null; `;
1204
+ } else {
1205
+ code += `const ${temp}${ts === 'null' ? ':void' : ''} = ${ts}; `;
1206
+ }
1207
+ code += 'const ';
1291
1208
  code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
1292
- code += `: nasl.core.Incompatible<typeof x, void> = x`;
1293
- code += '; }\n';
1209
+ code += `: nasl.core.Incompatible<typeof ${temp}, void> = ${temp}`;
1210
+ code += ';\n';
1294
1211
  } else {
1295
- code += '{ const ';
1212
+ code += 'const ';
1296
1213
  code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
1297
- code += '; }\n';
1214
+ code += ';\n';
1298
1215
  }
1299
1216
  });
1300
- code += 'return;\n';
1217
+ code += 'return {\n';
1218
+ code += `__name: "AStructure_${this.typeAnnotation.hash}" as const,\n`;
1219
+ this.properties.forEach((property) => {
1220
+ code += `${property.name},\n`;
1221
+ });
1222
+ code += '}\n';
1223
+
1301
1224
  code += '};\n';
1302
1225
 
1303
1226
  code += 'return __newComposite();\n';
@@ -1306,24 +1229,59 @@ export class NewComposite extends LogicItem {
1306
1229
  return code;
1307
1230
  }
1308
1231
 
1309
- __addIdentifier(App: App) {
1310
- const app = this.app || App;
1311
- app.emit('collect:start', {
1312
- actionMsg: '添加匿名数据结构属性',
1232
+ getInitCode(state?: TranslatorState): string {
1233
+ let code = '';
1234
+ const nameMap = new Map();
1235
+ const rightMap = new Map();
1236
+ this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1237
+ const leftSecondIndex = leftIndex[1];
1238
+ const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
1239
+ const leftItem = this.properties[leftSecondIndex];
1240
+ const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
1241
+ nameMap.set(leftItem.name, rightItem);
1242
+ rightMap.set(rightItem, null);
1243
+ });
1244
+ code += '(() => { ';
1245
+ // 提供sourcemap,获取类型标注和上下文可选变量
1246
+ this.rights.forEach((right) => {
1247
+ let ts = right.expression.toEmbeddedTS(shiftState(state, code, { inline: true }));
1248
+ if (rightMap.has(right.expression))
1249
+ rightMap.set(right.expression, ts);
1250
+ right.members.forEach((member) => {
1251
+ ts = member.toEmbeddedTS(shiftState(state, code, { inline: true }));
1252
+ if (rightMap.has(member))
1253
+ rightMap.set(member, ts);
1254
+ });
1313
1255
  });
1314
- const node = this.addIdentifier({ name: this.getIdentifierUniqueName('property1') });
1315
- const struct = StructureProperty.from({
1316
- name: node.name,
1317
- typeAnnotation: null,
1256
+ // 方便ts报错检查
1257
+ code += 'function __newComposite() { ';
1258
+ this.properties.forEach((property) => {
1259
+ const name = property.name;
1260
+ const rightItem = nameMap.get(name);
1261
+ const ts = rightMap.get(rightItem);
1262
+ if (ts !== undefined) {
1263
+ code += `const ${name} = ${['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts}; `;
1264
+ } else {
1265
+ code += `const ${name}; `;
1266
+ }
1267
+ });
1268
+ code += '\nreturn {\n';
1269
+ code += `__name: "AStructure_${this.typeAnnotation.hash}" as const,\n`;
1270
+ this.properties.forEach((property) => {
1271
+ code += `${property.name},\n`;
1318
1272
  });
1319
- this.typeAnnotation.addStructureProperty(struct);
1320
- app.emit('collect:end');
1273
+ code += '}\n';
1274
+
1275
+ code += '};\n';
1276
+
1277
+ code += 'return __newComposite();\n';
1278
+ code += '})()';
1279
+ return code;
1321
1280
  }
1322
1281
 
1323
1282
  __deleteIdentifier(property: Identifier) {
1324
1283
  const index = this.properties.findIndex((p) => p === property);
1325
1284
  const newLines: AssignmentLine[] = [];
1326
- const newProperties = [...this.typeAnnotation.properties.slice(0, index), ...this.typeAnnotation.properties.slice(index + 1, this.properties.length)];
1327
1285
  this.assignmentLines.forEach((line) => {
1328
1286
  const { leftIndex } = line;
1329
1287
  if (leftIndex[1] < index) {
@@ -1337,9 +1295,6 @@ export class NewComposite extends LogicItem {
1337
1295
  actionMsg: '删除匿名数据结属性',
1338
1296
  });
1339
1297
  this.setAssignmentLines(newLines);
1340
- this.typeAnnotation.update({
1341
- properties: newProperties,
1342
- });
1343
1298
  property.delete();
1344
1299
  this.app.emit('collect:end');
1345
1300
  }
@@ -326,6 +326,22 @@ export class NewList extends LogicItem {
326
326
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
327
327
  // 自动生成的代码已结束。下面可以手动编写。
328
328
  //================================================================================
329
+ toBrief(): string {
330
+ let code = '';
331
+ code += '[ ';
332
+ this.items.forEach((value, index) => {
333
+ if (index >= 10)
334
+ return;
335
+ if (index)
336
+ code += ',';
337
+ code += value.toBrief();
338
+ });
339
+ if (this.items.length > 10)
340
+ code += ', ...';
341
+ code += ' ]';
342
+ return code;
343
+ }
344
+
329
345
  toUI(state?: TranslatorState): string {
330
346
  let code = '';
331
347
  code += '[';
@@ -376,11 +392,16 @@ export class NewList extends LogicItem {
376
392
  code += '(() => { \n';
377
393
  const arr: any = [];
378
394
  this.items.forEach((item, index) => {
395
+ if (item.concept === 'Unparsed')
396
+ return;
397
+ code += 'nasl.core.ensureVoid(';
379
398
  arr.push(item.toEmbeddedTS(shiftState(state, code, { inline: true })));
380
399
  code += arr[index];
381
- code += '; ';
400
+ code += '); ';
382
401
  });
383
402
  code += '\n';
403
+ if (!arr.length || arr.every((item: any) => ['__IDENTIFIER__', '__IDENTIFIER__()', 'null'].includes(item)))
404
+ code += '__IDENTIFIER__;\n';
384
405
  // ts报错检查
385
406
  code += 'function __newComposite() {\n';
386
407
  if (this.items.length === 0) {
@@ -413,7 +434,7 @@ export class NewList extends LogicItem {
413
434
  code += 'let arr = [';
414
435
  this.items.forEach((item, index) => {
415
436
  const ts = item.toEmbeddedTS(shiftState(state, code, { inline: true }));
416
- code += ts === '__IDENTIFIER__' ? null : ts;
437
+ code += ['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts;
417
438
  if (index + 1 < this.items.length)
418
439
  code += ', ';
419
440
  });
@@ -43,8 +43,6 @@ export class NewMap extends LogicItem {
43
43
  @property('LogicItem')
44
44
  values: Array<LogicItem> = [];
45
45
 
46
-
47
-
48
46
  /**
49
47
  * @param source 需要合并的部分参数
50
48
  */
@@ -58,7 +56,6 @@ export class NewMap extends LogicItem {
58
56
  return super.from(source, parentNode, parentKey) as NewMap;
59
57
  }
60
58
 
61
-
62
59
  /**
63
60
  * 设置类型
64
61
  */
@@ -98,7 +95,7 @@ export class NewMap extends LogicItem {
98
95
  });
99
96
  }
100
97
 
101
- getItemExistingNames(excludedList: Array<LogicItem> = []) {
98
+ getItemExistingNames(excludedList: Array<LogicItem> = []) {
102
99
  const excludedSet = new Set(excludedList);
103
100
  return ((this.keys as LogicItem[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
104
101
  }
@@ -372,9 +369,6 @@ export class NewMap extends LogicItem {
372
369
  return node;
373
370
  }
374
371
 
375
-
376
-
377
-
378
372
  /**
379
373
  * 删除类型标注
380
374
  * @param name 类型标注名称
@@ -423,8 +417,6 @@ export class NewMap extends LogicItem {
423
417
  return params;
424
418
  }
425
419
 
426
-
427
-
428
420
  /**
429
421
  * 删除逻辑项
430
422
  * @param name 逻辑项名称
@@ -450,8 +442,6 @@ export class NewMap extends LogicItem {
450
442
  return logicItem.delete();
451
443
  }
452
444
 
453
-
454
-
455
445
  /**
456
446
  * 删除逻辑项
457
447
  * @param name 逻辑项名称
@@ -516,7 +506,7 @@ export class NewMap extends LogicItem {
516
506
  this.update({
517
507
  keys: [...this.keys, undefined],
518
508
  values: [...this.values, undefined],
519
- })
509
+ });
520
510
  }
521
511
 
522
512
  removePair(idx: number) {
@@ -527,7 +517,24 @@ export class NewMap extends LogicItem {
527
517
  this.update({
528
518
  keys: k,
529
519
  values: v,
530
- })
520
+ });
521
+ }
522
+
523
+ toBrief(): string {
524
+ let code = '';
525
+ code += '[<br />';
526
+ this.keys.forEach((key, index) => {
527
+ if (index >= 10)
528
+ return;
529
+ const value = this.values[index];
530
+ code += '&nbsp;&nbsp;&nbsp;&nbsp;';
531
+ code += `${key ? key.toBrief() : 'null'} -> ${value ? value.toBrief() : 'null'}`;
532
+ code += '<br />';
533
+ });
534
+ if (this.keys.length > 10)
535
+ code += '&nbsp;&nbsp;&nbsp;&nbsp...<br />';
536
+ code += ']';
537
+ return code;
531
538
  }
532
539
 
533
540
  toJS(state?: TranslatorState): string {
@@ -576,48 +583,65 @@ export class NewMap extends LogicItem {
576
583
  code += 'return __newComposite();\n';
577
584
  code += '})()';
578
585
  } else {
579
- if (this.keys.length) {
586
+ if (this.keys.some((key) => key) || this.values.some((value) => value)) {
580
587
  code += '(() => { \n';
581
588
  const valueTsArr: any = [];
582
589
  let keyTs = 'null';
583
- let keyBol = false;
584
- this.keys.forEach((key) => {
590
+ let valueTs = false;
591
+ let keyIndex = -1;
592
+ this.keys.forEach((key, index) => {
585
593
  if (key) {
586
594
  const ts = key.toEmbeddedTS(shiftState(state, code, { inline: true }));
587
- if (!keyBol && !['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
588
- keyBol = true;
595
+ if (keyIndex === -1 && !['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
596
+ keyIndex = index;
589
597
  keyTs = ts;
590
598
  }
591
599
  }
592
600
  });
593
601
  this.values.forEach((item, index) => {
602
+ if (item)
603
+ valueTs = true;
604
+ code += 'nasl.core.ensureVoid(';
594
605
  const ts = item ? item.toEmbeddedTS(shiftState(state, code, { inline: true })) : null;
595
606
  valueTsArr.push(ts);
596
607
  code += valueTsArr[index];
597
- code += '; ';
608
+ code += '); ';
598
609
  });
599
610
  code += '\n';
611
+ if (keyTs === 'null' || !valueTs) {
612
+ code += '__IDENTIFIER__;\n';
613
+ }
600
614
  // 方便ts报错检查
601
615
  code += 'function __newComposite() {\n';
602
616
  this.keys.forEach((key: any) => {
603
- code += `nasl.core.compare2(${keyTs}, `;
617
+ if (!key)
618
+ return;
619
+ code += `nasl.core.compareNew(${keyTs}, `;
604
620
  code += key.toEmbeddedTS(shiftState(state, code, { inline: true }));
605
621
  code += ');\n';
606
622
  });
607
- code += `return nasl.util.NewMap(${keyTs}, `;
623
+ code += `return nasl.util.NewMap(`;
624
+ code += `${keyIndex === -1 ? 'null' : this.keys[keyIndex].toEmbeddedTS(shiftState(state, code, { inline: true }))}, ...[`;
608
625
  valueTsArr.forEach((ts: any, index: number) => {
609
626
  code += ['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts;
610
627
  if (index + 1 < this.values.length)
611
628
  code += ', ';
612
629
  });
613
- code += ');\n';
630
+ code += ']);\n';
614
631
 
615
632
  code += '};\n';
616
633
 
617
634
  code += 'return __newComposite();\n';
618
635
  code += '})()';
619
636
  } else {
620
- code += `nasl.util.NewMap(${null}, ${null})`;
637
+ code += '(() => {\n';
638
+ code += '__IDENTIFIER__;\n';
639
+ code += 'function __newComposite() {\n';
640
+ code += `return nasl.util.NewMap(${null}, ${null});\n`;
641
+ code += '};\n';
642
+
643
+ code += 'return __newComposite();\n';
644
+ code += '})()';
621
645
  }
622
646
  }
623
647
  return code;
@@ -625,7 +649,7 @@ export class NewMap extends LogicItem {
625
649
 
626
650
  getInitCode(state?: TranslatorState): string {
627
651
  let code = '';
628
- if (this.keys.length) {
652
+ if (this.keys.some((key) => key) || this.values.some((value) => value)) {
629
653
  let keyBol = false;
630
654
  code += `nasl.util.NewMap(`;
631
655
  this.keys.forEach((key) => {