@lcap/nasl 1.0.0-alpha.8 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (460) hide show
  1. package/out/automate/engine/index.d.ts +3 -0
  2. package/out/automate/engine/index.js +414 -0
  3. package/out/automate/engine/index.js.map +1 -0
  4. package/out/automate/engine/operators.d.ts +13 -0
  5. package/out/automate/engine/operators.js +63 -0
  6. package/out/automate/engine/operators.js.map +1 -0
  7. package/out/automate/engine/uniqueName.d.ts +6 -0
  8. package/out/automate/engine/uniqueName.js +39 -0
  9. package/out/automate/engine/uniqueName.js.map +1 -0
  10. package/out/automate/engine/utils.d.ts +24 -0
  11. package/out/automate/engine/utils.js +363 -0
  12. package/out/automate/engine/utils.js.map +1 -0
  13. package/out/common/BaseNode.d.ts +20 -0
  14. package/out/common/BaseNode.js +219 -81
  15. package/out/common/BaseNode.js.map +1 -1
  16. package/out/concepts/App__.d.ts +18 -1
  17. package/out/concepts/App__.js +84 -44
  18. package/out/concepts/App__.js.map +1 -1
  19. package/out/concepts/Argument__.d.ts +5 -1
  20. package/out/concepts/Argument__.js +21 -3
  21. package/out/concepts/Argument__.js.map +1 -1
  22. package/out/concepts/Assignee__.d.ts +190 -0
  23. package/out/concepts/Assignee__.js +264 -0
  24. package/out/concepts/Assignee__.js.map +1 -0
  25. package/out/concepts/Assignment__.js +5 -0
  26. package/out/concepts/Assignment__.js.map +1 -1
  27. package/out/concepts/BinaryExpression__.js +8 -7
  28. package/out/concepts/BinaryExpression__.js.map +1 -1
  29. package/out/concepts/BindAttribute__.d.ts +19 -0
  30. package/out/concepts/BindAttribute__.js +55 -10
  31. package/out/concepts/BindAttribute__.js.map +1 -1
  32. package/out/concepts/BindDirective__.js +23 -3
  33. package/out/concepts/BindDirective__.js.map +1 -1
  34. package/out/concepts/BindEvent__.d.ts +2 -2
  35. package/out/concepts/BindEvent__.js +67 -34
  36. package/out/concepts/BindEvent__.js.map +1 -1
  37. package/out/concepts/BooleanLiteral__.d.ts +2 -0
  38. package/out/concepts/BooleanLiteral__.js +10 -0
  39. package/out/concepts/BooleanLiteral__.js.map +1 -1
  40. package/out/concepts/CallFunction__.js +57 -23
  41. package/out/concepts/CallFunction__.js.map +1 -1
  42. package/out/concepts/CallInterface__.d.ts +5 -0
  43. package/out/concepts/CallInterface__.js +238 -31
  44. package/out/concepts/CallInterface__.js.map +1 -1
  45. package/out/concepts/CallLogic__.d.ts +4 -4
  46. package/out/concepts/CallLogic__.js +107 -50
  47. package/out/concepts/CallLogic__.js.map +1 -1
  48. package/out/concepts/CallQueryComponent__.d.ts +7 -1
  49. package/out/concepts/CallQueryComponent__.js +45 -26
  50. package/out/concepts/CallQueryComponent__.js.map +1 -1
  51. package/out/concepts/Comment__.js +6 -2
  52. package/out/concepts/Comment__.js.map +1 -1
  53. package/out/concepts/CompletionProperty__.d.ts +3 -1
  54. package/out/concepts/CompletionProperty__.js +2 -0
  55. package/out/concepts/CompletionProperty__.js.map +1 -1
  56. package/out/concepts/ConfigGroup__.js +3 -3
  57. package/out/concepts/ConfigGroup__.js.map +1 -1
  58. package/out/concepts/ConfigProperty__.js +3 -3
  59. package/out/concepts/ConfigProperty__.js.map +1 -1
  60. package/out/concepts/Configuration__.js +3 -3
  61. package/out/concepts/Configuration__.js.map +1 -1
  62. package/out/concepts/Constant__.d.ts +1 -0
  63. package/out/concepts/Constant__.js +14 -0
  64. package/out/concepts/Constant__.js.map +1 -1
  65. package/out/concepts/Destination__.d.ts +12 -0
  66. package/out/concepts/Destination__.js +98 -19
  67. package/out/concepts/Destination__.js.map +1 -1
  68. package/out/concepts/End__.js +9 -1
  69. package/out/concepts/End__.js.map +1 -1
  70. package/out/concepts/EntityProperty__.d.ts +11 -0
  71. package/out/concepts/EntityProperty__.js +73 -5
  72. package/out/concepts/EntityProperty__.js.map +1 -1
  73. package/out/concepts/Entity__.d.ts +4 -4
  74. package/out/concepts/Entity__.js +30 -20
  75. package/out/concepts/Entity__.js.map +1 -1
  76. package/out/concepts/Enum__.d.ts +4 -0
  77. package/out/concepts/Enum__.js +18 -10
  78. package/out/concepts/Enum__.js.map +1 -1
  79. package/out/concepts/Event__.js +3 -3
  80. package/out/concepts/Event__.js.map +1 -1
  81. package/out/concepts/ForEachStatement__.d.ts +1 -1
  82. package/out/concepts/ForEachStatement__.js +11 -15
  83. package/out/concepts/ForEachStatement__.js.map +1 -1
  84. package/out/concepts/Function__.js +13 -13
  85. package/out/concepts/Function__.js.map +1 -1
  86. package/out/concepts/Identifier__.d.ts +3 -0
  87. package/out/concepts/Identifier__.js +76 -29
  88. package/out/concepts/Identifier__.js.map +1 -1
  89. package/out/concepts/IfStatement__.js +4 -4
  90. package/out/concepts/IfStatement__.js.map +1 -1
  91. package/out/concepts/InterfaceParam__.d.ts +6 -4
  92. package/out/concepts/InterfaceParam__.js +52 -19
  93. package/out/concepts/InterfaceParam__.js.map +1 -1
  94. package/out/concepts/Interface__.d.ts +42 -30
  95. package/out/concepts/Interface__.js +133 -17
  96. package/out/concepts/Interface__.js.map +1 -1
  97. package/out/concepts/JSBlock__.d.ts +1 -0
  98. package/out/concepts/JSBlock__.js +3 -0
  99. package/out/concepts/JSBlock__.js.map +1 -1
  100. package/out/concepts/LogicItem__.d.ts +2 -1
  101. package/out/concepts/LogicItem__.js +14 -0
  102. package/out/concepts/LogicItem__.js.map +1 -1
  103. package/out/concepts/Logic__.d.ts +20 -1
  104. package/out/concepts/Logic__.js +194 -37
  105. package/out/concepts/Logic__.js.map +1 -1
  106. package/out/concepts/MemberExpression__.d.ts +2 -0
  107. package/out/concepts/MemberExpression__.js +49 -13
  108. package/out/concepts/MemberExpression__.js.map +1 -1
  109. package/out/concepts/Module__.d.ts +126 -120
  110. package/out/concepts/Module__.js +36 -26
  111. package/out/concepts/Module__.js.map +1 -1
  112. package/out/concepts/Namespace__.d.ts +5 -1
  113. package/out/concepts/Namespace__.js +48 -37
  114. package/out/concepts/Namespace__.js.map +1 -1
  115. package/out/concepts/NullLiteral__.d.ts +3 -0
  116. package/out/concepts/NullLiteral__.js +11 -1
  117. package/out/concepts/NullLiteral__.js.map +1 -1
  118. package/out/concepts/NumericLiteral__.d.ts +1 -1
  119. package/out/concepts/NumericLiteral__.js +17 -6
  120. package/out/concepts/NumericLiteral__.js.map +1 -1
  121. package/out/concepts/Param__.d.ts +7 -3
  122. package/out/concepts/Param__.js +57 -28
  123. package/out/concepts/Param__.js.map +1 -1
  124. package/out/concepts/ProcessComponent__.js +6 -6
  125. package/out/concepts/ProcessComponent__.js.map +1 -1
  126. package/out/concepts/ProcessElement__.d.ts +0 -4
  127. package/out/concepts/ProcessElement__.js +117 -54
  128. package/out/concepts/ProcessElement__.js.map +1 -1
  129. package/out/concepts/ProcessOutcome__.js +1 -1
  130. package/out/concepts/ProcessOutcome__.js.map +1 -1
  131. package/out/concepts/Process__.d.ts +7 -1
  132. package/out/concepts/Process__.js +81 -85
  133. package/out/concepts/Process__.js.map +1 -1
  134. package/out/concepts/QueryAggregateExpression__.js +1 -1
  135. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  136. package/out/concepts/QueryFromExpression__.js +2 -2
  137. package/out/concepts/QueryFromExpression__.js.map +1 -1
  138. package/out/concepts/QueryJoinExpression__.js +5 -5
  139. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  140. package/out/concepts/QueryLimitExpression__.js +2 -2
  141. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  142. package/out/concepts/QuerySelectExpression__.js +3 -3
  143. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  144. package/out/concepts/Return__.d.ts +4 -1
  145. package/out/concepts/Return__.js +67 -21
  146. package/out/concepts/Return__.js.map +1 -1
  147. package/out/concepts/Role__.d.ts +4 -0
  148. package/out/concepts/Role__.js +13 -4
  149. package/out/concepts/Role__.js.map +1 -1
  150. package/out/concepts/SqlQueryComponent__.js +2 -2
  151. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  152. package/out/concepts/StringLiteral__.d.ts +1 -1
  153. package/out/concepts/StringLiteral__.js +21 -31
  154. package/out/concepts/StringLiteral__.js.map +1 -1
  155. package/out/concepts/StructureProperty__.d.ts +5 -4
  156. package/out/concepts/StructureProperty__.js +55 -26
  157. package/out/concepts/StructureProperty__.js.map +1 -1
  158. package/out/concepts/Structure__.d.ts +44 -30
  159. package/out/concepts/Structure__.js +44 -12
  160. package/out/concepts/Structure__.js.map +1 -1
  161. package/out/concepts/SwitchCase__.js +4 -4
  162. package/out/concepts/SwitchCase__.js.map +1 -1
  163. package/out/concepts/SwitchStatement__.js +2 -2
  164. package/out/concepts/SwitchStatement__.js.map +1 -1
  165. package/out/concepts/TypeAnnotation__.d.ts +5 -5
  166. package/out/concepts/TypeAnnotation__.js +74 -20
  167. package/out/concepts/TypeAnnotation__.js.map +1 -1
  168. package/out/concepts/UnaryExpression__.js +10 -8
  169. package/out/concepts/UnaryExpression__.js.map +1 -1
  170. package/out/concepts/Unparsed__.js +1 -1
  171. package/out/concepts/Unparsed__.js.map +1 -1
  172. package/out/concepts/ValidationRule__.d.ts +1 -0
  173. package/out/concepts/ValidationRule__.js +48 -13
  174. package/out/concepts/ValidationRule__.js.map +1 -1
  175. package/out/concepts/Variable__.d.ts +10 -1
  176. package/out/concepts/Variable__.js +70 -18
  177. package/out/concepts/Variable__.js.map +1 -1
  178. package/out/concepts/ViewComponent__.js +15 -15
  179. package/out/concepts/ViewComponent__.js.map +1 -1
  180. package/out/concepts/ViewElement__.d.ts +17 -11
  181. package/out/concepts/ViewElement__.js +302 -204
  182. package/out/concepts/ViewElement__.js.map +1 -1
  183. package/out/concepts/View__.d.ts +12 -11
  184. package/out/concepts/View__.js +109 -98
  185. package/out/concepts/View__.js.map +1 -1
  186. package/out/concepts/WhileStatement__.js +3 -3
  187. package/out/concepts/WhileStatement__.js.map +1 -1
  188. package/out/concepts/basics/stdlib/index.js +4 -1
  189. package/out/concepts/basics/stdlib/index.js.map +1 -1
  190. package/out/concepts/basics/stdlib/{nasl.validate.d.ts → nasl.auth.d.ts} +0 -0
  191. package/out/concepts/basics/stdlib/nasl.auth.js +30 -0
  192. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -0
  193. package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +3 -0
  194. package/out/concepts/basics/stdlib/nasl.browser copy.js +70 -0
  195. package/out/concepts/basics/stdlib/nasl.browser copy.js.map +1 -0
  196. package/out/concepts/basics/stdlib/nasl.browser.d.ts +3 -0
  197. package/out/concepts/basics/stdlib/nasl.browser.js +41 -0
  198. package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -0
  199. package/out/concepts/basics/stdlib/nasl.configuration.d.ts +3 -0
  200. package/out/concepts/basics/stdlib/nasl.configuration.js +25 -0
  201. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -0
  202. package/out/concepts/basics/stdlib/nasl.ui.js +20 -0
  203. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  204. package/out/concepts/basics/stdlib/nasl.util.js +149 -13
  205. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  206. package/out/concepts/basics/stdlib/nasl.validation.js +54 -20
  207. package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
  208. package/out/concepts/basics/types/coreTypeList.js +11 -10
  209. package/out/concepts/basics/types/coreTypeList.js.map +1 -1
  210. package/out/concepts/index__.d.ts +1 -0
  211. package/out/concepts/index__.js +1 -0
  212. package/out/concepts/index__.js.map +1 -1
  213. package/out/config.d.ts +1 -2
  214. package/out/config.js +1 -2
  215. package/out/config.js.map +1 -1
  216. package/out/enums/KEYWORDS.d.ts +3 -0
  217. package/out/enums/KEYWORDS.js +1206 -0
  218. package/out/enums/KEYWORDS.js.map +1 -0
  219. package/out/enums/LEVEL_NAME_MAP.d.ts +26 -0
  220. package/out/enums/LEVEL_NAME_MAP.js +30 -0
  221. package/out/enums/LEVEL_NAME_MAP.js.map +1 -0
  222. package/out/eventBus.d.ts +3 -0
  223. package/out/eventBus.js +7 -0
  224. package/out/eventBus.js.map +1 -0
  225. package/out/generator/genBundleFiles.d.ts +7 -2
  226. package/out/generator/genBundleFiles.js +168 -27
  227. package/out/generator/genBundleFiles.js.map +1 -1
  228. package/out/generator/genMetaData.d.ts +20 -20
  229. package/out/generator/genMetaData.js +50 -15
  230. package/out/generator/genMetaData.js.map +1 -1
  231. package/out/index.d.ts +2 -0
  232. package/out/index.js +2 -0
  233. package/out/index.js.map +1 -1
  234. package/out/manager/diagnostic.d.ts +1 -1
  235. package/out/server/createUiTs.d.ts +1 -0
  236. package/out/server/createUiTs.js +49 -5
  237. package/out/server/createUiTs.js.map +1 -1
  238. package/out/server/entity2LogicNamespace.js +38 -23
  239. package/out/server/entity2LogicNamespace.js.map +1 -1
  240. package/out/server/getExtensionModules.js +2 -0
  241. package/out/server/getExtensionModules.js.map +1 -1
  242. package/out/server/getFunctions.d.ts +1 -0
  243. package/out/server/getFunctions.js +7 -1
  244. package/out/server/getFunctions.js.map +1 -1
  245. package/out/server/getLogics.js +63 -18
  246. package/out/server/getLogics.js.map +1 -1
  247. package/out/server/getMemberIdentifier.d.ts +16 -1
  248. package/out/server/getMemberIdentifier.js +279 -36
  249. package/out/server/getMemberIdentifier.js.map +1 -1
  250. package/out/server/getProcesses.d.ts +6 -1
  251. package/out/server/getProcesses.js +243 -1
  252. package/out/server/getProcesses.js.map +1 -1
  253. package/out/server/getScope.d.ts +12 -0
  254. package/out/server/getScope.js +57 -0
  255. package/out/server/getScope.js.map +1 -0
  256. package/out/server/index.js +4 -0
  257. package/out/server/index.js.map +1 -1
  258. package/out/server/naslServer.d.ts +30 -53
  259. package/out/server/naslServer.js +721 -381
  260. package/out/server/naslServer.js.map +1 -1
  261. package/out/server/process2LogicNamespace.d.ts +10 -0
  262. package/out/server/process2LogicNamespace.js +29 -1
  263. package/out/server/process2LogicNamespace.js.map +1 -1
  264. package/out/server/translator.d.ts +22 -3
  265. package/out/server/translator.js +367 -123
  266. package/out/server/translator.js.map +1 -1
  267. package/out/service/creator/add.configs.d.ts +1 -0
  268. package/out/service/creator/add.configs.js +68 -0
  269. package/out/service/creator/add.configs.js.map +1 -0
  270. package/out/service/creator/errHandles.d.ts +18 -0
  271. package/out/service/creator/errHandles.js +60 -0
  272. package/out/service/creator/errHandles.js.map +1 -0
  273. package/out/service/creator/index.d.ts +1 -0
  274. package/out/service/creator/index.js +72 -0
  275. package/out/service/creator/index.js.map +1 -0
  276. package/out/service/storage/api.d.ts +18 -0
  277. package/out/service/storage/api.js +17 -0
  278. package/out/service/storage/api.js.map +1 -0
  279. package/out/service/storage/init.js +213 -37
  280. package/out/service/storage/init.js.map +1 -1
  281. package/out/service/storage/service.d.ts +2 -0
  282. package/out/service/storage/service.js +10 -0
  283. package/out/service/storage/service.js.map +1 -0
  284. package/out/service/storage/storagePoint.d.ts +1 -14
  285. package/out/service/storage/storagePoint.js +16 -16
  286. package/out/service/storage/storagePoint.js.map +1 -1
  287. package/out/templator/genCreateBlock.js +6 -6
  288. package/out/templator/genCreateBlock.js.map +1 -1
  289. package/out/templator/genCurdEditMultipleKeyBlock.js +13 -17
  290. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  291. package/out/templator/genCurdMultipleKeyBlock.js +11 -11
  292. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  293. package/out/templator/genEditTableBlock.js +5 -5
  294. package/out/templator/genEditTableBlock.js.map +1 -1
  295. package/out/templator/genEnumSelectBlock.js +2 -2
  296. package/out/templator/genEnumSelectBlock.js.map +1 -1
  297. package/out/templator/genGetBlock.js +5 -3
  298. package/out/templator/genGetBlock.js.map +1 -1
  299. package/out/templator/genGridViewBlock.d.ts +3 -1
  300. package/out/templator/genGridViewBlock.js +61 -6
  301. package/out/templator/genGridViewBlock.js.map +1 -1
  302. package/out/templator/genQueryComponent.d.ts +2 -0
  303. package/out/templator/genQueryComponent.js +27 -14
  304. package/out/templator/genQueryComponent.js.map +1 -1
  305. package/out/templator/genTableBlock.d.ts +1 -1
  306. package/out/templator/genTableBlock.js +4 -5
  307. package/out/templator/genTableBlock.js.map +1 -1
  308. package/out/templator/genUpdateBlock.js +9 -10
  309. package/out/templator/genUpdateBlock.js.map +1 -1
  310. package/out/templator/utils.d.ts +13 -4
  311. package/out/templator/utils.js +8 -4
  312. package/out/templator/utils.js.map +1 -1
  313. package/out/test/fixtures/env.js +0 -1
  314. package/out/test/fixtures/env.js.map +1 -1
  315. package/out/test/integration/connect-file copy.d.ts +1 -0
  316. package/out/test/integration/connect-file copy.js +50 -0
  317. package/out/test/integration/connect-file copy.js.map +1 -0
  318. package/out/test/integration/node-nasl-server.d.ts +1 -0
  319. package/out/test/integration/node-nasl-server.js +41 -0
  320. package/out/test/integration/node-nasl-server.js.map +1 -0
  321. package/out/test/units/page/Element.spec.js +3 -3
  322. package/out/test/units/page/Element.spec.js.map +1 -1
  323. package/out/test/units/temp/temp.spec.js +1 -1
  324. package/out/test/units/temp/temp.spec.js.map +1 -1
  325. package/out/utils/index.d.ts +6 -0
  326. package/out/utils/index.js +25 -1
  327. package/out/utils/index.js.map +1 -1
  328. package/out/utils/string.d.ts +1 -1
  329. package/out/utils/string.js +38 -9
  330. package/out/utils/string.js.map +1 -1
  331. package/package.json +2 -1
  332. package/src/automate/engine/index.js +97 -118
  333. package/src/automate/engine/operators.js +63 -0
  334. package/src/automate/engine/uniqueName.js +36 -0
  335. package/src/automate/engine/utils.js +49 -19
  336. package/src/common/BaseNode.ts +223 -87
  337. package/src/concepts/App__.ts +86 -46
  338. package/src/concepts/Argument__.ts +23 -3
  339. package/src/concepts/Assignee__.ts +437 -0
  340. package/src/concepts/Assignment__.ts +4 -1
  341. package/src/concepts/BinaryExpression__.ts +9 -7
  342. package/src/concepts/BindAttribute__.ts +69 -9
  343. package/src/concepts/BindDirective__.ts +22 -3
  344. package/src/concepts/BindEvent__.ts +67 -23
  345. package/src/concepts/BooleanLiteral__.ts +8 -0
  346. package/src/concepts/CallFunction__.ts +58 -25
  347. package/src/concepts/CallInterface__.ts +236 -26
  348. package/src/concepts/CallLogic__.ts +111 -52
  349. package/src/concepts/CallQueryComponent__.ts +36 -21
  350. package/src/concepts/Comment__.ts +6 -2
  351. package/src/concepts/CompletionProperty__.ts +5 -1
  352. package/src/concepts/ConfigGroup__.ts +3 -3
  353. package/src/concepts/ConfigProperty__.ts +3 -3
  354. package/src/concepts/Configuration__.ts +3 -3
  355. package/src/concepts/Constant__.ts +12 -0
  356. package/src/concepts/Destination__.ts +106 -18
  357. package/src/concepts/End__.ts +8 -1
  358. package/src/concepts/EntityProperty__.ts +69 -5
  359. package/src/concepts/Entity__.ts +33 -28
  360. package/src/concepts/Enum__.ts +16 -11
  361. package/src/concepts/Event__.ts +3 -3
  362. package/src/concepts/ForEachStatement__.ts +16 -21
  363. package/src/concepts/Function__.ts +13 -13
  364. package/src/concepts/Identifier__.ts +82 -32
  365. package/src/concepts/IfStatement__.ts +4 -4
  366. package/src/concepts/InterfaceParam__.ts +49 -27
  367. package/src/concepts/Interface__.ts +130 -16
  368. package/src/concepts/JSBlock__.ts +4 -0
  369. package/src/concepts/LogicItem__.ts +16 -1
  370. package/src/concepts/Logic__.ts +201 -39
  371. package/src/concepts/MemberExpression__.ts +58 -15
  372. package/src/concepts/Module__.ts +35 -24
  373. package/src/concepts/Namespace__.ts +49 -37
  374. package/src/concepts/NullLiteral__.ts +8 -1
  375. package/src/concepts/NumericLiteral__.ts +17 -6
  376. package/src/concepts/Param__.ts +54 -28
  377. package/src/concepts/ProcessComponent__.ts +6 -6
  378. package/src/concepts/ProcessElement__.ts +143 -44
  379. package/src/concepts/ProcessOutcome__.ts +1 -1
  380. package/src/concepts/Process__.ts +85 -98
  381. package/src/concepts/QueryAggregateExpression__.ts +1 -1
  382. package/src/concepts/QueryFromExpression__.ts +2 -2
  383. package/src/concepts/QueryJoinExpression__.ts +5 -5
  384. package/src/concepts/QueryLimitExpression__.ts +2 -2
  385. package/src/concepts/QuerySelectExpression__.ts +3 -3
  386. package/src/concepts/Return__.ts +60 -29
  387. package/src/concepts/Role__.ts +11 -4
  388. package/src/concepts/SqlQueryComponent__.ts +2 -2
  389. package/src/concepts/StringLiteral__.ts +20 -31
  390. package/src/concepts/StructureProperty__.ts +50 -33
  391. package/src/concepts/Structure__.ts +32 -10
  392. package/src/concepts/SwitchCase__.ts +4 -4
  393. package/src/concepts/SwitchStatement__.ts +2 -2
  394. package/src/concepts/TypeAnnotation__.ts +59 -16
  395. package/src/concepts/UnaryExpression__.ts +10 -8
  396. package/src/concepts/Unparsed__.ts +1 -1
  397. package/src/concepts/ValidationRule__.ts +44 -14
  398. package/src/concepts/Variable__.ts +67 -25
  399. package/src/concepts/ViewComponent__.ts +15 -15
  400. package/src/concepts/ViewElement__.ts +380 -264
  401. package/src/concepts/View__.ts +139 -94
  402. package/src/concepts/WhileStatement__.ts +4 -4
  403. package/src/concepts/basics/stdlib/index.ts +4 -2
  404. package/src/concepts/basics/stdlib/nasl.auth.ts +26 -0
  405. package/src/concepts/basics/stdlib/nasl.browser.ts +37 -0
  406. package/src/concepts/basics/stdlib/nasl.configuration.ts +21 -0
  407. package/src/concepts/basics/stdlib/nasl.ui.ts +20 -1
  408. package/src/concepts/basics/stdlib/nasl.util.ts +151 -13
  409. package/src/concepts/basics/stdlib/nasl.validation.ts +45 -11
  410. package/src/concepts/basics/types/coreTypeList.ts +11 -10
  411. package/src/concepts/index__.ts +1 -0
  412. package/src/config.ts +1 -2
  413. package/src/enums/KEYWORDS.ts +1204 -0
  414. package/src/{terms → enums}/LEVEL_NAME_MAP.ts +0 -0
  415. package/src/eventBus.ts +5 -0
  416. package/src/generator/genBundleFiles.ts +182 -30
  417. package/src/generator/genMetaData.ts +72 -21
  418. package/src/index.ts +2 -0
  419. package/src/manager/diagnostic.ts +1 -1
  420. package/src/server/createUiTs.ts +50 -8
  421. package/src/server/entity2LogicNamespace.ts +41 -25
  422. package/src/server/getExtensionModules.ts +2 -0
  423. package/src/server/getFunctions.ts +6 -0
  424. package/src/server/getLogics.ts +66 -19
  425. package/src/server/getMemberIdentifier.ts +275 -46
  426. package/src/server/getProcesses.ts +248 -4
  427. package/src/server/getScope.ts +62 -0
  428. package/src/server/index.ts +12 -1
  429. package/src/server/naslServer.ts +715 -398
  430. package/src/server/process2LogicNamespace.ts +30 -2
  431. package/src/server/translator.ts +423 -128
  432. package/src/service/config/index.js +1 -1
  433. package/src/service/creator/errHandles.js +5 -2
  434. package/src/service/creator/index.js +0 -6
  435. package/src/service/storage/api.js +14 -0
  436. package/src/service/storage/init.ts +217 -47
  437. package/src/service/storage/service.ts +6 -0
  438. package/src/service/storage/storagePoint.ts +16 -16
  439. package/src/templator/genCreateBlock.ts +6 -6
  440. package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -30
  441. package/src/templator/genCurdMultipleKeyBlock.ts +11 -11
  442. package/src/templator/genEditTableBlock.ts +5 -5
  443. package/src/templator/genEnumSelectBlock.ts +2 -2
  444. package/src/templator/genGetBlock.ts +6 -8
  445. package/src/templator/genGridViewBlock.ts +59 -9
  446. package/src/templator/genQueryComponent.ts +39 -28
  447. package/src/templator/genTableBlock.ts +5 -9
  448. package/src/templator/genUpdateBlock.ts +9 -11
  449. package/src/templator/utils.ts +9 -6
  450. package/src/test/fixtures/env.ts +0 -2
  451. package/src/test/units/page/Element.spec.ts +3 -3
  452. package/src/test/units/temp/temp.spec.ts +1 -1
  453. package/src/utils/index.ts +24 -0
  454. package/src/utils/string.ts +39 -9
  455. package/out/concepts/basics/stdlib/nasl.validate.js +0 -527
  456. package/out/concepts/basics/stdlib/nasl.validate.js.map +0 -1
  457. package/out/data/Module.d.ts +0 -34
  458. package/out/data/Module.js +0 -53
  459. package/out/data/Module.js.map +0 -1
  460. package/src/automate/engine/index.d.ts +0 -3
@@ -46,38 +46,62 @@ 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
- function transAstNodeToNaslNode(astNode: any): any {
52
+ function transAstNodeToNaslNode(astNode: any, namespace?: string): any {
52
53
  let node = null;
53
54
  if (astNode.type === 'CallExpression' && astNode.callee.object.name === '$utils') {
54
55
  const calleeName = astNode.callee.property.name || astNode.callee.property.value;
55
- node = {
56
- concept: 'CallFunction',
57
- name: '',
58
- label: '调用逻辑',
59
- kind: 'Expression',
60
- calleeNamespace: 'nasl.util',
61
- calleeName,
62
- arguments: astNode.arguments.map((argument: any) => ({
63
- concept: 'Argument',
56
+
57
+ if (calleeName === 'EnumList') {
58
+ const args = astNode.arguments;
59
+ let name = '';
60
+ let namespace = 'app.enums';
61
+ if (Array.isArray(args)) {
62
+ name = args[0]?.value;
63
+ namespace = args[1]?.value ? args[1]?.value : 'app.enums';
64
+ }
65
+ node = {
66
+ concept: 'Identifier',
67
+ name,
68
+ namespace,
69
+ kind: 'Expression',
70
+ };
71
+ } else {
72
+ node = {
73
+ concept: 'CallFunction',
64
74
  name: '',
65
- kind: 'Statement',
66
- keyword: '',
67
- expression: transAstNodeToNaslNode(Object.assign({}, argument)),
68
- })),
69
- };
75
+ label: '调用内置函数',
76
+ kind: 'Expression',
77
+ calleeNamespace: 'nasl.util',
78
+ calleeName,
79
+ arguments: astNode.arguments.map((argument: any) => ({
80
+ concept: 'Argument',
81
+ name: '',
82
+ kind: 'Statement',
83
+ keyword: '',
84
+ expression: transAstNodeToNaslNode(Object.assign({}, argument)),
85
+ })),
86
+ };
87
+ }
70
88
  } else if (astNode.type === 'MemberExpression') {
71
- node = {
72
- concept: 'MemberExpression',
73
- name: '',
74
- kind: 'Expression',
75
- object: transAstNodeToNaslNode(astNode.object),
76
- property: transAstNodeToNaslNode(astNode.property),
77
- };
89
+ if (astNode.object?.name === '$global') {
90
+ // 目前只有权限相关的
91
+ node = transAstNodeToNaslNode(astNode.property, 'nasl.auth');
92
+ } else {
93
+ node = {
94
+ concept: 'MemberExpression',
95
+ name: '',
96
+ kind: 'Expression',
97
+ object: transAstNodeToNaslNode(astNode.object),
98
+ property: transAstNodeToNaslNode(astNode.property),
99
+ };
100
+ }
78
101
  } else if (astNode.type === 'Identifier') {
79
102
  node = {
80
103
  concept: 'Identifier',
104
+ namespace: namespace || '',
81
105
  name: astNode.name,
82
106
  kind: 'Expression',
83
107
  };
@@ -94,6 +118,17 @@ function transAstNodeToNaslNode(astNode: any): any {
94
118
  name: '',
95
119
  value: astNode.value,
96
120
  };
121
+ } else if (astNode.type === 'UnaryExpression') {
122
+ node = {
123
+ concept: 'UnaryExpression',
124
+ kind: 'Expression',
125
+ name: '',
126
+ operator: astNode.operator,
127
+ argument: transAstNodeToNaslNode(astNode.argument),
128
+ };
129
+ } else {
130
+ node = astNode;
131
+ node.concept = astNode.type;
97
132
  }
98
133
  return node;
99
134
  }
@@ -227,6 +262,8 @@ export class ViewElement extends BaseNode {
227
262
  super.subConstructor(source);
228
263
  }
229
264
 
265
+
266
+
230
267
  /**
231
268
  * 从父级删除该节点
232
269
  * @internal
@@ -263,33 +300,33 @@ export class ViewElement extends BaseNode {
263
300
  });
264
301
  }
265
302
 
266
- getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
303
+ getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
267
304
  const excludedSet = new Set(excludedList);
268
305
  return (this.bindAttrs || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
269
306
  }
270
307
  getBindAttributeUniqueName(name = 'bindAttribute1') {
271
- return utils.unique(name, this.getBindAttributeExistingNames());
308
+ return utils.unique(name, this.getBindAttributeExistingNames(), undefined, false);
272
309
  }
273
310
 
274
311
  /**
275
- * 插入元素绑定属性
276
- * @internal
277
- * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
278
- */
312
+ * 插入元素绑定属性
313
+ * @internal
314
+ * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
315
+ */
279
316
  _insertBindAttributeAt(name: string, index: number): BindAttribute;
280
317
 
281
318
  /**
282
- * 插入元素绑定属性
283
- * @internal
284
- * @param bindAttributeOptions 元素绑定属性参数
285
- */
319
+ * 插入元素绑定属性
320
+ * @internal
321
+ * @param bindAttributeOptions 元素绑定属性参数
322
+ */
286
323
  _insertBindAttributeAt(bindAttributeOptions: Partial<BindAttribute>, index: number): BindAttribute;
287
324
 
288
325
  /**
289
- * 插入元素绑定属性
290
- * @internal
291
- * @param bindAttribute 已有的元素绑定属性实例
292
- */
326
+ * 插入元素绑定属性
327
+ * @internal
328
+ * @param bindAttribute 已有的元素绑定属性实例
329
+ */
293
330
  _insertBindAttributeAt(bindAttribute: BindAttribute, index: number): BindAttribute;
294
331
 
295
332
  _insertBindAttributeAt(options: string | Partial<BindAttribute> | BindAttribute, index: number) {
@@ -307,7 +344,7 @@ export class ViewElement extends BaseNode {
307
344
  name: options,
308
345
  }, this, 'bindAttrs');
309
346
  } else if (options instanceof BindAttribute) {
310
- options.delete(); // 同一实例不支持多处存在
347
+ options.ensureDelete(); // 同一实例不支持多处存在
311
348
  bindAttribute = options;
312
349
  Object.assign(bindAttribute, relationOptions);
313
350
  } else {
@@ -395,7 +432,7 @@ export class ViewElement extends BaseNode {
395
432
 
396
433
  addBindAttribute(options?: string | Partial<BindAttribute> | BindAttribute) {
397
434
  const node = this._addBindAttribute(options as any);
398
- const index = this.bindAttrs.length;
435
+ const index = this.bindAttrs.indexOf(node);
399
436
  node.create({
400
437
  index,
401
438
  parentNode: this,
@@ -404,33 +441,34 @@ export class ViewElement extends BaseNode {
404
441
  return node;
405
442
  }
406
443
 
444
+
407
445
  getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
408
446
  const excludedSet = new Set(excludedList);
409
447
  return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
410
448
  }
411
449
  getBindEventUniqueName(name = 'bindEvent1') {
412
- return utils.unique(name, this.getBindEventExistingNames());
450
+ return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
413
451
  }
414
452
 
415
453
  /**
416
- * 插入元素绑定事件
417
- * @internal
418
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
419
- */
454
+ * 插入元素绑定事件
455
+ * @internal
456
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
457
+ */
420
458
  _insertBindEventAt(name: string, index: number): BindEvent;
421
459
 
422
460
  /**
423
- * 插入元素绑定事件
424
- * @internal
425
- * @param bindEventOptions 元素绑定事件参数
426
- */
461
+ * 插入元素绑定事件
462
+ * @internal
463
+ * @param bindEventOptions 元素绑定事件参数
464
+ */
427
465
  _insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
428
466
 
429
467
  /**
430
- * 插入元素绑定事件
431
- * @internal
432
- * @param bindEvent 已有的元素绑定事件实例
433
- */
468
+ * 插入元素绑定事件
469
+ * @internal
470
+ * @param bindEvent 已有的元素绑定事件实例
471
+ */
434
472
  _insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
435
473
 
436
474
  _insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
@@ -448,7 +486,7 @@ export class ViewElement extends BaseNode {
448
486
  name: options,
449
487
  }, this, 'bindEvents');
450
488
  } else if (options instanceof BindEvent) {
451
- options.delete(); // 同一实例不支持多处存在
489
+ options.ensureDelete(); // 同一实例不支持多处存在
452
490
  bindEvent = options;
453
491
  Object.assign(bindEvent, relationOptions);
454
492
  } else {
@@ -536,7 +574,7 @@ export class ViewElement extends BaseNode {
536
574
 
537
575
  addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
538
576
  const node = this._addBindEvent(options as any);
539
- const index = this.bindEvents.length;
577
+ const index = this.bindEvents.indexOf(node);
540
578
  node.create({
541
579
  index,
542
580
  parentNode: this,
@@ -545,33 +583,34 @@ export class ViewElement extends BaseNode {
545
583
  return node;
546
584
  }
547
585
 
586
+
548
587
  getBindDirectiveExistingNames(excludedList: Array<BindDirective> = []) {
549
588
  const excludedSet = new Set(excludedList);
550
589
  return (this.bindDirectives || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
551
590
  }
552
591
  getBindDirectiveUniqueName(name = 'bindDirective1') {
553
- return utils.unique(name, this.getBindDirectiveExistingNames());
592
+ return utils.unique(name, this.getBindDirectiveExistingNames(), undefined, false);
554
593
  }
555
594
 
556
595
  /**
557
- * 插入元素指令
558
- * @internal
559
- * @param name 元素指令名称,如果不填会自动生成一个唯一名称
560
- */
596
+ * 插入元素指令
597
+ * @internal
598
+ * @param name 元素指令名称,如果不填会自动生成一个唯一名称
599
+ */
561
600
  _insertBindDirectiveAt(name: string, index: number): BindDirective;
562
601
 
563
602
  /**
564
- * 插入元素指令
565
- * @internal
566
- * @param bindDirectiveOptions 元素指令参数
567
- */
603
+ * 插入元素指令
604
+ * @internal
605
+ * @param bindDirectiveOptions 元素指令参数
606
+ */
568
607
  _insertBindDirectiveAt(bindDirectiveOptions: Partial<BindDirective>, index: number): BindDirective;
569
608
 
570
609
  /**
571
- * 插入元素指令
572
- * @internal
573
- * @param bindDirective 已有的元素指令实例
574
- */
610
+ * 插入元素指令
611
+ * @internal
612
+ * @param bindDirective 已有的元素指令实例
613
+ */
575
614
  _insertBindDirectiveAt(bindDirective: BindDirective, index: number): BindDirective;
576
615
 
577
616
  _insertBindDirectiveAt(options: string | Partial<BindDirective> | BindDirective, index: number) {
@@ -589,7 +628,7 @@ export class ViewElement extends BaseNode {
589
628
  name: options,
590
629
  }, this, 'bindDirectives');
591
630
  } else if (options instanceof BindDirective) {
592
- options.delete(); // 同一实例不支持多处存在
631
+ options.ensureDelete(); // 同一实例不支持多处存在
593
632
  bindDirective = options;
594
633
  Object.assign(bindDirective, relationOptions);
595
634
  } else {
@@ -677,7 +716,7 @@ export class ViewElement extends BaseNode {
677
716
 
678
717
  addBindDirective(options?: string | Partial<BindDirective> | BindDirective) {
679
718
  const node = this._addBindDirective(options as any);
680
- const index = this.bindDirectives.length;
719
+ const index = this.bindDirectives.indexOf(node);
681
720
  node.create({
682
721
  index,
683
722
  parentNode: this,
@@ -686,25 +725,30 @@ export class ViewElement extends BaseNode {
686
725
  return node;
687
726
  }
688
727
 
728
+
729
+
730
+
731
+
732
+
689
733
  /**
690
- * 插入页面元素
691
- * @internal
692
- * @param name 页面元素名称,如果不填会自动生成一个唯一名称
693
- */
734
+ * 插入页面元素
735
+ * @internal
736
+ * @param name 页面元素名称,如果不填会自动生成一个唯一名称
737
+ */
694
738
  _insertViewElementAt(name: string, index: number): ViewElement;
695
739
 
696
740
  /**
697
- * 插入页面元素
698
- * @internal
699
- * @param viewElementOptions 页面元素参数
700
- */
741
+ * 插入页面元素
742
+ * @internal
743
+ * @param viewElementOptions 页面元素参数
744
+ */
701
745
  _insertViewElementAt(viewElementOptions: Partial<ViewElement>, index: number): ViewElement;
702
746
 
703
747
  /**
704
- * 插入页面元素
705
- * @internal
706
- * @param viewElement 已有的页面元素实例
707
- */
748
+ * 插入页面元素
749
+ * @internal
750
+ * @param viewElement 已有的页面元素实例
751
+ */
708
752
  _insertViewElementAt(viewElement: ViewElement, index: number): ViewElement;
709
753
 
710
754
  _insertViewElementAt(options: string | Partial<ViewElement> | ViewElement, index: number) {
@@ -722,7 +766,7 @@ export class ViewElement extends BaseNode {
722
766
  name: options,
723
767
  }, this, 'children');
724
768
  } else if (options instanceof ViewElement) {
725
- options.delete(); // 同一实例不支持多处存在
769
+ options.ensureDelete(); // 同一实例不支持多处存在
726
770
  viewElement = options;
727
771
  Object.assign(viewElement, relationOptions);
728
772
  } else {
@@ -810,7 +854,7 @@ export class ViewElement extends BaseNode {
810
854
 
811
855
  addViewElement(options?: string | Partial<ViewElement> | ViewElement) {
812
856
  const node = this._addViewElement(options as any);
813
- const index = this.children.length;
857
+ const index = this.children.indexOf(node);
814
858
  node.create({
815
859
  index,
816
860
  parentNode: this,
@@ -819,10 +863,13 @@ export class ViewElement extends BaseNode {
819
863
  return node;
820
864
  }
821
865
 
866
+
867
+
868
+
822
869
  /**
823
- * 删除元素绑定属性
824
- * @param name 元素绑定属性名称
825
- */
870
+ * 删除元素绑定属性
871
+ * @param name 元素绑定属性名称
872
+ */
826
873
  removeBindAttribute(name: string): void;
827
874
 
828
875
  /**
@@ -867,10 +914,12 @@ export class ViewElement extends BaseNode {
867
914
  return params;
868
915
  }
869
916
 
917
+
918
+
870
919
  /**
871
- * 删除元素绑定事件
872
- * @param name 元素绑定事件名称
873
- */
920
+ * 删除元素绑定事件
921
+ * @param name 元素绑定事件名称
922
+ */
874
923
  removeBindEvent(name: string): void;
875
924
 
876
925
  /**
@@ -915,10 +964,12 @@ export class ViewElement extends BaseNode {
915
964
  return params;
916
965
  }
917
966
 
967
+
968
+
918
969
  /**
919
- * 删除元素指令
920
- * @param name 元素指令名称
921
- */
970
+ * 删除元素指令
971
+ * @param name 元素指令名称
972
+ */
922
973
  removeBindDirective(name: string): void;
923
974
 
924
975
  /**
@@ -963,10 +1014,12 @@ export class ViewElement extends BaseNode {
963
1014
  return params;
964
1015
  }
965
1016
 
1017
+
1018
+
966
1019
  /**
967
- * 删除页面元素
968
- * @param name 页面元素名称
969
- */
1020
+ * 删除页面元素
1021
+ * @param name 页面元素名称
1022
+ */
970
1023
  removeViewElement(name: string): void;
971
1024
 
972
1025
  /**
@@ -1015,6 +1068,21 @@ export class ViewElement extends BaseNode {
1015
1068
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1016
1069
  // 自动生成的代码已结束。下面可以手动编写。
1017
1070
  //================================================================================
1071
+
1072
+ /* 主页面有没有权限 */
1073
+ get parentAuth() {
1074
+ const _nameSpace = this.view.getNamespace();
1075
+ const mainViewName = _nameSpace.split('.')[2];
1076
+ return this.view.parentNode.concept === 'App' ? this.view.auth : this.app.views.find((item) => item.name === mainViewName)?.auth;
1077
+ }
1078
+
1079
+ /**
1080
+ * 权限领域的资源路径
1081
+ */
1082
+ get authPath() {
1083
+ return `${this.view.path}/${this.name}`;
1084
+ }
1085
+
1018
1086
  getViewElementUniqueName(name = 'viewElement1') {
1019
1087
  return this.view?.getViewElementUniqueName(name);
1020
1088
  }
@@ -1046,48 +1114,25 @@ export class ViewElement extends BaseNode {
1046
1114
  return this.bindAttrs.find((bindAttr) => bindAttr.name === name);
1047
1115
  }
1048
1116
 
1049
- /**
1050
- * 角色
1051
- */
1052
- @property()
1053
- roles: Array<{
1054
- namespace: string;
1055
- name: string;
1056
- }> = [];
1057
-
1058
- toggleRole(role: Role) {
1059
- const index = this.roles.findIndex((roleItem) => roleItem.name === role.name);
1060
- const roles = [...this.roles];
1061
- if (index !== -1) {
1062
- roles.splice(index, 1);
1063
- } else {
1064
- roles.push({
1065
- namespace: role.getNamespace(),
1066
- name: role.name,
1067
- });
1068
- }
1069
- const object = {
1070
- roles,
1071
- };
1072
- this.update({
1073
- ...object,
1074
- });
1075
- }
1076
1117
  toHump(name: string): string {
1077
1118
  return name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase());
1078
1119
  }
1079
1120
 
1080
1121
  haveScope(node: ViewElement): boolean {
1081
- const dataSourcePcList = ['uGallery', 'uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect'];
1082
- const dataSourceH5List = ['vanListView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
1122
+ // uGallery 没有子集不需要scope
1123
+ const dataSourcePcList = ['uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect'];
1124
+ const dataSourceH5List = ['vanRadioGroup', 'vanCheckboxGroup', 'vanListView', 'vanGridView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
1083
1125
  const dataSourceList = [...dataSourcePcList, ...dataSourceH5List];
1084
1126
  return dataSourceList.includes(node.toHump(node.tag));
1085
1127
  }
1086
1128
  toEmbeddedTSDefinition(state?: TranslatorState): string {
1129
+ // 登录组件不翻译
1130
+ if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form')
1131
+ return '';
1087
1132
  let code = '';
1088
1133
  // formItem的单独处理
1089
1134
  if (this.tag === 'u-form-item') {
1090
- code = indent(state.tabSize) + `${this.name}: <nasl.ui.${this.toHump(this.tag)}`;
1135
+ code = indent(state.tabSize) + `${this.name}: nasl.ui.${this.toHump(this.tag)}`;
1091
1136
  if (Array.isArray(this.children) && this.children.length) {
1092
1137
  const tag = this.children[0].tag;
1093
1138
  if (tag === 'u-input') {
@@ -1098,7 +1143,7 @@ export class ViewElement extends BaseNode {
1098
1143
  code += '<nasl.core.Any>';
1099
1144
  }
1100
1145
  }
1101
- code += '> null,\n';
1146
+ code += ';\n';
1102
1147
  }
1103
1148
  if (this.haveScope(this)) {
1104
1149
  let genericType = 'any';
@@ -1116,9 +1161,13 @@ export class ViewElement extends BaseNode {
1116
1161
  let parentNode = this.parentNode;
1117
1162
  let haveScopeFlag = false;
1118
1163
  while (!haveScopeFlag && parentNode.concept !== 'View') {
1119
- if (this.haveScope((parentNode) as ViewElement)) {
1164
+ if (this.haveScope(parentNode as ViewElement)) {
1120
1165
  // type d = nasl.ui.GetItemTypeFromDataSource<typeof listStructure>['tableRelation']
1121
- const tsArr = expressionTs.split('.');
1166
+ const tsArr = expressionTs.replace('scope.item.', '').split('.');
1167
+ let itemStr = '';
1168
+ tsArr.forEach((item) => {
1169
+ itemStr += `['${item}']`;
1170
+ });
1122
1171
  const parentbindAttrs = (parentNode as ViewElement).bindAttrs;
1123
1172
  if (parentbindAttrs && parentbindAttrs.length) {
1124
1173
  const parentAttr = parentbindAttrs.find((item) => item.name === 'data-source');
@@ -1126,7 +1175,7 @@ export class ViewElement extends BaseNode {
1126
1175
  let parentExpressionTs = parentAttr.expression.toEmbeddedTS(shiftState(state, code));
1127
1176
  parentExpressionTs = parentExpressionTs.replaceAll(' ', '');
1128
1177
  // 如果是逻辑就推导出逻辑类型
1129
- genericType = `nasl.ui.GetItemTypeFromDataSource<nasl.ui.GetItemTypeFromDataSource<typeof ${parentExpressionTs}>['${tsArr[tsArr.length - 1]}']>`;
1178
+ genericType = `nasl.ui.GetItemTypeFromDataSource<nasl.ui.GetItemTypeFromDataSource<typeof ${parentExpressionTs}>${itemStr}>`;
1130
1179
  }
1131
1180
  }
1132
1181
  haveScopeFlag = true;
@@ -1136,9 +1185,9 @@ export class ViewElement extends BaseNode {
1136
1185
  }
1137
1186
  }
1138
1187
  }
1139
- code += indent(state.tabSize) + `${this.name}: <nasl.ui.${this.toHump(this.tag)}<${genericType}>> null,\n`;
1188
+ code += indent(state.tabSize) + `${this.name}: nasl.ui.${this.toHump(this.tag)}<${genericType}>;\n`;
1140
1189
  } else {
1141
- code = indent(state.tabSize) + `${this.name}: <nasl.ui.${this.toHump(this.tag)}<any>> null,\n`;
1190
+ code = indent(state.tabSize) + `${this.name}: nasl.ui.${this.toHump(this.tag)}<any>;\n`;
1142
1191
  }
1143
1192
  if (Array.isArray(this.children)) {
1144
1193
  this.children.forEach((element) => {
@@ -1149,13 +1198,15 @@ export class ViewElement extends BaseNode {
1149
1198
  }
1150
1199
  @withSourceMap()
1151
1200
  toEmbeddedTS(state?: TranslatorState, parentLevel?: number): string {
1201
+ if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form')
1202
+ return '';
1152
1203
  function chineseTsName(name: string) {
1153
1204
  let tsName = name;
1205
+ // 匹配所有特殊字符都转为_
1206
+ tsName = tsName.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '_');
1154
1207
  if (/^\d/.test(tsName)) {
1155
1208
  tsName = '$' + tsName;
1156
1209
  }
1157
- // 匹配所有特殊字符都转为_
1158
- tsName = tsName.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '_');
1159
1210
  return tsName;
1160
1211
  }
1161
1212
  let code = `__elements.${this.name} = new nasl.ui.${this.toHump(this.tag)}({\n`;
@@ -1165,7 +1216,7 @@ export class ViewElement extends BaseNode {
1165
1216
  hasAuth = !!this.bindDirectives.filter((directive) => directive.name === 'auth').length;
1166
1217
  }
1167
1218
  // 角色
1168
- if (hasAuth && Array.isArray(this.bindRoles)) {
1219
+ if (Array.isArray(this.bindRoles) && this.bindRoles.length) {
1169
1220
  code += indent(state.tabSize + 2);
1170
1221
  code += 'roles = [\n';
1171
1222
  this.bindRoles.forEach((role) => {
@@ -1203,25 +1254,40 @@ export class ViewElement extends BaseNode {
1203
1254
  if (Array.isArray(this.children)) {
1204
1255
  code += indent(state.tabSize + 1);
1205
1256
 
1206
- let levelIndex = parentLevel || 0;
1207
- if (this.haveScope(this)) {
1208
- code += `slotDefault: (scope${levelIndex || ''})=> [\n`;
1209
- levelIndex++;
1210
- } else {
1211
- code += `slotDefault: ()=> [\n`;
1212
- }
1213
1257
  if (Array.isArray(this.bindAttrs)) {
1214
- code += indent(state.tabSize + 2) + `() => [\n`;
1258
+ code += `bindAttr: () => [\n`;
1215
1259
  this.bindAttrs.forEach((attr) => {
1216
1260
  if (attr.expression) {
1217
1261
  code
1218
1262
  += attr.expression.toEmbeddedTS(shiftState(state, code, {
1219
- tabSize: state.tabSize + 3,
1263
+ tabSize: state.tabSize + 2,
1264
+ })) + ',\n';
1265
+ }
1266
+ if (Array.isArray(attr.rules) && attr.rules.length) {
1267
+ attr.rules.forEach((item) => {
1268
+ code += item.toEmbeddedTS(shiftState(state, code)) + ',\n';
1269
+ });
1270
+ }
1271
+ });
1272
+ this.bindDirectives.forEach((directive) => {
1273
+ if (directive.expression) {
1274
+ code
1275
+ += directive.expression.toEmbeddedTS(shiftState(state, code, {
1276
+ tabSize: state.tabSize + 2,
1220
1277
  })) + ',\n';
1221
1278
  }
1222
1279
  });
1223
1280
  code += indent(state.tabSize + 2) + '],\n';
1224
1281
  }
1282
+
1283
+ let levelIndex = parentLevel || 0;
1284
+ if (this.haveScope(this)) {
1285
+ code += `slotDefault: (scope)=> [\n`;
1286
+ levelIndex++;
1287
+ } else {
1288
+ code += `slotDefault: ()=> [\n`;
1289
+ }
1290
+
1225
1291
  this.children.forEach((element) => {
1226
1292
  code += element.toEmbeddedTS(shiftState(state, code, {
1227
1293
  tabSize: state.tabSize + 2,
@@ -1237,12 +1303,9 @@ export class ViewElement extends BaseNode {
1237
1303
  return code;
1238
1304
  }
1239
1305
 
1240
- _duplicate(options?: ElementToVueOptions) {
1241
- const code = this.toVue(options);
1242
- const element = ViewElement.fromHTML(code, {
1243
- view: this.view,
1244
- });
1245
- element.deepRenameElements();
1306
+ _duplicate() {
1307
+ const element = ViewElement.from(this.toTemplateJSON());
1308
+ element.deepRenameElements(this);
1246
1309
  return element;
1247
1310
  }
1248
1311
 
@@ -1254,10 +1317,10 @@ export class ViewElement extends BaseNode {
1254
1317
  }
1255
1318
 
1256
1319
  // 递归生成组件名
1257
- public deepRenameElements(): void {
1320
+ public deepRenameElements(node: ViewElement): void {
1258
1321
  return this.traverseChildren((ele: ViewElement) => {
1259
1322
  const tagName = ele.tag.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1260
- ele.name = this.getViewElementUniqueName(`${tagName}1`);
1323
+ ele.name = node.getViewElementUniqueName(`${tagName}1`);
1261
1324
  });
1262
1325
  }
1263
1326
 
@@ -1297,7 +1360,6 @@ export class ViewElement extends BaseNode {
1297
1360
  concept: 'ValidationRule',
1298
1361
  name: '',
1299
1362
  label: '验证规则',
1300
- folded: true,
1301
1363
  kind: 'Expression',
1302
1364
  calleeNamespace: 'nasl.validation',
1303
1365
  arguments: args,
@@ -1325,13 +1387,13 @@ export class ViewElement extends BaseNode {
1325
1387
  });
1326
1388
  astNode.children = [];
1327
1389
  }
1328
-
1329
1390
  // 将 scopedSlots 合并到 children 中
1330
1391
  if (astNode.scopedSlots) {
1331
1392
  astNode.children = astNode.children || [];
1332
1393
  Object.keys(astNode.scopedSlots).forEach((key) => {
1333
- if (!astNode.children.find((child) => key === (child as compiler.ASTElement).slotTarget))
1394
+ if (!astNode.children.find((child) => key === (child as compiler.ASTElement).slotTarget)) {
1334
1395
  astNode.children.unshift(astNode.scopedSlots[key]);
1396
+ }
1335
1397
  });
1336
1398
  delete astNode.scopedSlots;
1337
1399
  }
@@ -1352,6 +1414,12 @@ export class ViewElement extends BaseNode {
1352
1414
  }
1353
1415
  }
1354
1416
  const tagName = astNode.tag.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1417
+ let newContext: any = {};
1418
+ if (context) {
1419
+ newContext = {
1420
+ ...context,
1421
+ };
1422
+ }
1355
1423
  element = new ViewElement({
1356
1424
  tag: astNode.tag,
1357
1425
  name: astNode.attrsMap.ref || view.getViewElementUniqueName(`${tagName}1`),
@@ -1359,45 +1427,43 @@ export class ViewElement extends BaseNode {
1359
1427
  staticStyle: astNode.attrsMap.style,
1360
1428
  slotTarget: astNode.slotTarget && json5.parse(astNode.slotTarget),
1361
1429
  slotScope: astNode.slotScope === '_empty_' ? '' : astNode.slotScope,
1362
- children: astNode.children.map((item) => this._fromASTNode(item as compiler.ASTElement, context)) as unknown as Array<ViewElement>,
1430
+ children: astNode.children.map((item) => this._fromASTNode(item as compiler.ASTElement, newContext)) as unknown as Array<ViewElement>,
1363
1431
  });
1364
-
1365
- astNode.attrs
1366
- && astNode.attrs.forEach((oldAttr) => {
1367
- let attr: BindAttribute;
1368
- if (oldAttr.value === '""' && (oldAttr as any).end - (oldAttr as any).start === oldAttr.name.length) {
1369
- attr = BindAttribute.from({
1370
- type: 'static',
1432
+ astNode?.attrs?.forEach((oldAttr) => {
1433
+ let attr: BindAttribute;
1434
+ if (oldAttr.value === '""' && (oldAttr as any).end - (oldAttr as any).start === oldAttr.name.length) {
1435
+ attr = new BindAttribute({
1436
+ type: 'static',
1437
+ name: oldAttr.name,
1438
+ value: 'true',
1439
+ });
1440
+ } else {
1441
+ try {
1442
+ const tmp = json5.parse(oldAttr.value);
1443
+ const source: any = {
1444
+ type: typeof tmp === 'string' ? 'string' : 'static',
1371
1445
  name: oldAttr.name,
1372
- value: 'true',
1373
- }, element);
1374
- } else {
1375
- try {
1376
- const tmp = json5.parse(oldAttr.value);
1377
- const source: any = {
1378
- type: typeof tmp === 'string' ? 'string' : 'static',
1379
- name: oldAttr.name,
1380
- value: typeof tmp === 'string' ? tmp : oldAttr.value,
1381
- };
1382
- if (oldAttr.name === 'rules') {
1383
- source.rules = tmp?.split('|').map((ruleStr: string) => this._parseValidationRule(ruleStr.trim()));
1384
- }
1385
- attr = BindAttribute.from(source, element);
1386
- } catch (e) {
1387
- const expression = <any> this._parseExpression(oldAttr.value);
1388
- attr = BindAttribute.from({
1389
- type: 'dynamic',
1390
- name: oldAttr.name,
1391
- value: expression ? '' : oldAttr.value,
1392
- expression,
1393
- }, element);
1394
- if (astNode.attrsMap[`:${attr.name}.sync`]) {
1395
- attr.sync = true;
1396
- }
1446
+ value: typeof tmp === 'string' ? tmp : oldAttr.value,
1447
+ };
1448
+ if (oldAttr.name === 'rules') {
1449
+ source.rules = tmp?.split('|').map((ruleStr: string) => this._parseValidationRule(ruleStr.trim()));
1450
+ }
1451
+ attr = new BindAttribute(source);
1452
+ } catch (e) {
1453
+ const expression = <any> this._parseExpression(oldAttr.value);
1454
+ attr = new BindAttribute({
1455
+ type: 'dynamic',
1456
+ name: oldAttr.name,
1457
+ value: expression ? '' : oldAttr.value,
1458
+ expression,
1459
+ });
1460
+ if (astNode.attrsMap[`:${attr.name}.sync`]) {
1461
+ attr.sync = true;
1397
1462
  }
1398
1463
  }
1399
- element.bindAttrs.push(attr);
1400
- });
1464
+ }
1465
+ element.addBindAttribute(attr);
1466
+ });
1401
1467
 
1402
1468
  // compiler 处理:value.sync 时会加上update:value事件,需要过滤
1403
1469
  astNode.events
@@ -1407,24 +1473,23 @@ export class ViewElement extends BaseNode {
1407
1473
  const oldEvent = astNode.events[name] as compiler.ASTElementHandler;
1408
1474
  const str = oldEvent.value;
1409
1475
  let calleeName = str.split('(')[0];
1410
- const matchArr = str.match(/\(([^)]*)\)/);
1476
+ const matchArr = str.match(/\(([^)]*)\)/) || [];
1411
1477
  let argsStr = '';
1412
- if (matchArr.length >= 2) {
1478
+ if (matchArr?.length >= 2) {
1413
1479
  argsStr = matchArr[1];
1414
1480
  }
1415
1481
  let args: any[] = [];
1416
- if (argsStr) {
1417
- args = argsStr.split(',').map((argStr) => {
1482
+ const argStrs: string[] = argsStr.split(',');
1483
+ args = argStrs
1484
+ .filter((argStr) => !!argStr && argStr !== '_empty_')
1485
+ .map((argStr) => {
1418
1486
  const keyword = argStr.trim().split('.');
1419
1487
  return {
1420
1488
  concept: 'Argument',
1421
1489
  expression: genArgumentMemberExpression(keyword),
1422
1490
  };
1423
1491
  });
1424
- }
1425
- const viewNamespace = view?.getNamespace();
1426
- const viewName = `${view?.name}`;
1427
- let calleeNamespace = `${viewNamespace}.${viewName}.logics`;
1492
+ let calleeNamespace = '';
1428
1493
  if (calleeName) {
1429
1494
  const namespaceArr = calleeName.split('.');
1430
1495
  const start = namespaceArr.shift();
@@ -1433,12 +1498,12 @@ export class ViewElement extends BaseNode {
1433
1498
  calleeName = namespaceArr[1];
1434
1499
  }
1435
1500
  }
1436
- element.bindEvents.push(BindEvent.from({
1501
+ element.addBindEvent(new BindEvent({
1437
1502
  name,
1438
1503
  calleeNamespace,
1439
1504
  calleeName,
1440
1505
  arguments: args,
1441
- }, element));
1506
+ }));
1442
1507
  });
1443
1508
 
1444
1509
  astNode.directives
@@ -1447,73 +1512,65 @@ export class ViewElement extends BaseNode {
1447
1512
  const valueAttr = astNode.attrs && astNode.attrs.find((attr) => attr.name === 'value');
1448
1513
  if (!valueAttr) {
1449
1514
  const expression = <any> this._parseExpression(directive.value);
1450
- element.bindAttrs.push(BindAttribute.from({
1515
+ element.addBindAttribute(new BindAttribute({
1451
1516
  type: 'dynamic',
1452
1517
  name: 'value',
1453
1518
  value: expression ? '' : directive.value,
1454
1519
  expression,
1455
1520
  sync: true,
1456
- }, element));
1521
+ }));
1457
1522
  }
1458
1523
  } else {
1459
1524
  const expression = <any> this._parseExpression(directive.value);
1460
- element.bindDirectives.push(BindDirective.from({
1525
+ element.addBindDirective(new BindDirective({
1461
1526
  type: expression ? 'string' : 'dynamic',
1462
1527
  name: directive.name,
1463
1528
  rawName: directive.rawName,
1464
1529
  value: expression ? '' : directive.value,
1465
1530
  expression,
1466
1531
  arg: directive.arg,
1467
- modifiers: directive.modifiers,
1468
- }, element));
1532
+ // modifiers: directive.modifiers,
1533
+ }));
1469
1534
  }
1470
1535
  });
1471
1536
 
1472
1537
  if (astNode.if) {
1473
- element.bindDirectives.push(BindDirective.from({
1538
+ element.addBindDirective(new BindDirective({
1474
1539
  type: 'dynamic',
1475
1540
  name: 'if',
1476
1541
  rawName: 'v-if',
1477
1542
  value: '',
1478
1543
  expression: <any> this._parseExpression(astNode.if),
1479
- }, element));
1544
+ }));
1480
1545
  }
1481
1546
  } else if (astNode.type === 2) {
1482
- if (config.scope === 'h5') {
1483
- element = new ViewElement({
1484
- tag: 'van-text',
1485
- });
1486
- } else {
1487
- element = new ViewElement({
1488
- tag: 'u-text',
1489
- });
1490
- }
1547
+ const tagName = config.scope === 'h5' ? 'van-text' : 'u-text';
1548
+ const baseName = tagName.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1549
+ element = new ViewElement({
1550
+ tag: tagName,
1551
+ name: view.getViewElementUniqueName(`${baseName}1`),
1552
+ });
1491
1553
  const value = astNode.text.match(/{{(.*?)}}/)[1].trim();
1492
1554
  const expression = <any> this._parseExpression(value);
1493
- element.bindAttrs.push(new BindAttribute({
1555
+ element.addBindAttribute(new BindAttribute({
1494
1556
  type: 'dynamic',
1495
1557
  name: 'text',
1496
1558
  value: expression ? '' : value,
1497
1559
  expression,
1498
1560
  }));
1499
1561
  } else if (astNode.type === 3) {
1500
- if (config.scope === 'h5') {
1501
- element = new ViewElement({
1502
- tag: 'van-text',
1503
- });
1504
- } else {
1505
- element = new ViewElement({
1506
- tag: 'u-text',
1507
- });
1508
- }
1509
-
1510
- element.bindAttrs.push(new BindAttribute({
1562
+ const tagName = config.scope === 'h5' ? 'van-text' : 'u-text';
1563
+ const baseName = tagName.replace(ViewElement.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1564
+ element = new ViewElement({
1565
+ tag: tagName,
1566
+ name: view.getViewElementUniqueName(`${baseName}1`),
1567
+ });
1568
+ element.addBindAttribute(new BindAttribute({
1511
1569
  name: 'text',
1512
1570
  type: 'string',
1513
1571
  value: astNode.text,
1514
1572
  }));
1515
1573
  }
1516
-
1517
1574
  return element;
1518
1575
  }
1519
1576
 
@@ -1534,24 +1591,14 @@ export class ViewElement extends BaseNode {
1534
1591
  let ast = compiler.compile(html, compilerOptions).ast;
1535
1592
  if (ast.tag === 'template' && !ast.slotTarget)
1536
1593
  ast = ast.children[0] as compiler.ASTElement;
1537
-
1538
- let root: ViewElement;
1539
- utils.traverse((current) => {
1540
- // 处理 scopedSlots;
1541
- if (!current.parent)
1542
- root = this._fromASTNode(current.node, context);
1543
- else
1544
- (current.parent.children as any)[current.index] = this._fromASTNode(current.node, context);
1545
- }, { node: ast });
1546
- return root;
1594
+ return this._fromASTNode(ast, context);
1547
1595
  }
1548
1596
 
1549
1597
  /**
1550
1598
  * 从模板生成规范的 ViewElement 对象
1551
1599
  */
1552
1600
  public static fromHTML(html: string, context?: ParseContext) {
1553
- const element = this.parse(html, context);
1554
- return element;
1601
+ return this.parse(html, context);
1555
1602
  }
1556
1603
 
1557
1604
  /**
@@ -1579,7 +1626,7 @@ export class ViewElement extends BaseNode {
1579
1626
  }
1580
1627
  }
1581
1628
  if ((attr as BindAttribute).type === 'dynamic' && !(element.tag === 'u-cascade-select' && attr.name === 'categories'))
1582
- return defaultResult.replace(/:?(\w+)(?:.*?)="(.*)"/, (m, name, value) => {
1629
+ return defaultResult.replace(/:?([\w-]+)(?:.*?)="(.*)"/, (m, name, value) => {
1583
1630
  try {
1584
1631
  const tempValue = json5.parse(value);
1585
1632
  if (typeof tempValue === 'boolean' || typeof tempValue === 'number') {
@@ -1590,7 +1637,12 @@ export class ViewElement extends BaseNode {
1590
1637
  if (apiOfAttr && !apiOfAttr.type.includes('string'))
1591
1638
  return '';
1592
1639
  }
1593
- return `${name}="{{ ${value.replace(/"/g, "'")} }}"`;
1640
+ value = value
1641
+ .replace(/"/g, "'")
1642
+ .replace(/\$utils\['(.+?)'\]/g, '$1')
1643
+ .replace(/\$refs./g, 'elements.')
1644
+ .replace(/\$global./g, 'nasl.auth.');
1645
+ return `${name}="{{ ${value} }}"`;
1594
1646
  });
1595
1647
  else
1596
1648
  return defaultResult;
@@ -1602,13 +1654,31 @@ export class ViewElement extends BaseNode {
1602
1654
 
1603
1655
  const api = config.allNodesAPI[el.tag];
1604
1656
  const emptySlot = api && api.slots && api.slots.find((slot) => slot.name === 'default' && slot['empty-background']);
1605
- if (!el.children.length && emptySlot) {
1606
- let addEmpty = true;
1607
- if (el.tag === 'u-grid-view' || el.tag === 'u-list-view' || el.tag === 'van-list-view') {
1608
- const hasDataSource = el.bindAttrs.find((attr) => attr.name === 'data-source');
1609
- addEmpty = !hasDataSource;
1657
+ const hasSupport = api && api.slots && api.slots.some((slot) => slot.support);
1658
+ if (emptySlot || hasSupport) {
1659
+ let childEmpty = !el.children.length;
1660
+ const defaultSlot = el.children.find((elem) => elem.tag === 'template' && elem.slotTarget === 'default');
1661
+ if (defaultSlot) {
1662
+ childEmpty = !defaultSlot.children.length;
1663
+ }
1664
+ if (childEmpty) {
1665
+ let addEmpty = true;
1666
+ if (el.tag === 'u-grid-view' || el.tag === 'u-list-view' || el.tag === 'van-list-view' || el.tag === 'van-grid-view') {
1667
+ const hasDataSource = el.bindAttrs.find((attr) => attr.name === 'data-source');
1668
+ addEmpty = !hasDataSource;
1669
+ }
1670
+ if (el.tag === 'u-crumb') {
1671
+ const attrList = el.bindAttrs;
1672
+ const hasAuto = attrList.some((attr) => attr.name === 'auto' && String(attr.value) === 'true');
1673
+ if (hasAuto)
1674
+ addEmpty = false;
1675
+ }
1676
+ if (['u-select', 'u-dropdown', 'u-panel'].includes(el.tag)) {
1677
+ addEmpty = false;
1678
+ }
1679
+ const background = (emptySlot && emptySlot['empty-background']) || (hasSupport ? 'add-sub' : '');
1680
+ addEmpty && parts.push(`vusion-empty-background="${background}"`);
1610
1681
  }
1611
- addEmpty && parts.push(`vusion-empty-background="${emptySlot['empty-background']}"`);
1612
1682
  }
1613
1683
 
1614
1684
  return parts;
@@ -1620,7 +1690,14 @@ export class ViewElement extends BaseNode {
1620
1690
  * 转换成 Vue 的模板格式
1621
1691
  */
1622
1692
  toVue(options?: ElementToVueOptions) {
1623
- options = Object.assign({
1693
+ let scopeList: string[] = [];
1694
+ if (Array.isArray(options?.scopeList)) {
1695
+ scopeList = [...options?.scopeList];
1696
+ }
1697
+ if (this.slotScope) {
1698
+ scopeList.unshift(this.slotScope);
1699
+ }
1700
+ const newOptions: ElementToVueOptions = Object.assign({
1624
1701
  indentStyle: 'space',
1625
1702
  tabSize: 4,
1626
1703
  indentLevel: 0,
@@ -1628,27 +1705,30 @@ export class ViewElement extends BaseNode {
1628
1705
  nodePathAttr: false,
1629
1706
  getExtraParts: () => [],
1630
1707
  attrFormat: (attr: BindAttribute | BindEvent | BindDirective, element?: ViewElement, defaultResult?: string) => defaultResult,
1631
- }, options);
1632
- const tabString = ' '.repeat(options.tabSize * options.indentLevel);
1633
- const insideTabString = ' '.repeat(options.tabSize * (options.indentLevel + 1));
1708
+ }, options, {
1709
+ scopeList,
1710
+ });
1711
+ const tabString = ' '.repeat(newOptions.tabSize * newOptions.indentLevel);
1712
+ const insideTabString = ' '.repeat(newOptions.tabSize * (newOptions.indentLevel + 1));
1634
1713
  let shouldIndent = true;
1635
1714
  const content: string = !this.children ? '' : this.children
1636
1715
  .map((element) => {
1637
- const childOptions = Object.assign({}, options);
1716
+ const childOptions = Object.assign({}, newOptions);
1638
1717
  childOptions.indentLevel++;
1639
- return (shouldIndent ? '\n' + insideTabString : '') + element.toVue(childOptions);
1718
+ return (shouldIndent ? '\n' + insideTabString : '') + element?.toVue(childOptions);
1640
1719
  })
1641
1720
  .join('');
1642
- if (!content.length)
1721
+ if (!content.length) {
1643
1722
  shouldIndent = false;
1644
-
1723
+ }
1645
1724
  const parts = [];
1646
- if (options.aslIdAttr) {
1647
- if (options.aslIdAttr === true)
1648
- options.aslIdAttr = 'asl-id';
1649
- parts.push(`${options.aslIdAttr}="${this.id}"`);
1725
+ if (newOptions.aslIdAttr) {
1726
+ if (newOptions.aslIdAttr === true) {
1727
+ newOptions.aslIdAttr = 'asl-id';
1728
+ }
1729
+ parts.push(`${newOptions.aslIdAttr}="${this.id}"`);
1650
1730
  }
1651
- if (options.nodePathAttr) {
1731
+ if (newOptions.nodePathAttr) {
1652
1732
  // 注入 asl 的 node-path
1653
1733
  parts.push(`vusion-node-path="${this.nodePath}"`);
1654
1734
  }
@@ -1659,11 +1739,10 @@ export class ViewElement extends BaseNode {
1659
1739
  this.staticStyle && parts.push(`style="${this.staticStyle}"`);
1660
1740
 
1661
1741
  [].concat(this.bindAttrs, this.bindDirectives, this.bindEvents).forEach((attr: BindAttribute | BindDirective | BindEvent) => {
1662
- const result = options.attrFormat(attr, this, attr.toVue(options));
1742
+ const result = newOptions.attrFormat(attr, this, attr?.toVue(newOptions));
1663
1743
  result && parts.push(result);
1664
1744
  });
1665
-
1666
- options.getExtraParts(this).forEach((part) => parts.push(part));
1745
+ newOptions.getExtraParts(this).forEach((part) => parts.push(part));
1667
1746
 
1668
1747
  let partsLength = 0;
1669
1748
  let partsString = '';
@@ -1679,13 +1758,50 @@ export class ViewElement extends BaseNode {
1679
1758
  return `<${this.tag}${partsString.length ? partsString : ''}>` + content + (shouldIndent ? '\n' + tabString : '') + `</${this.tag}>`;
1680
1759
  }
1681
1760
 
1761
+ /**
1762
+ * 从父级删除该节点
1763
+ * @internal
1764
+ */
1765
+ delete() {
1766
+ super.delete();
1767
+ if (this.parentNode) {
1768
+ this.traverseChildren((ele: ViewElement) => {
1769
+ (this.view as any)?.removeExistingViewElement(ele);
1770
+ });
1771
+ }
1772
+ }
1773
+
1774
+ findElementByName(name: string): ViewElement {
1775
+ return utils.traverse((current) => {
1776
+ if (current.node.name === name)
1777
+ return current.node;
1778
+ }, { node: this });
1779
+ }
1780
+
1781
+ findElementByTag(tag: string): ViewElement {
1782
+ return utils.traverse((current) => {
1783
+ if (current.node.tag === tag)
1784
+ return current.node;
1785
+ }, { node: this });
1786
+ }
1787
+
1788
+ findElementByAttr(name: string, value: string): ViewElement {
1789
+ return utils.traverse((current) => {
1790
+ if (current.node.bindAttrs.some((attr) => attr.name === name && attr.value === value))
1791
+ return current.node;
1792
+ }, { node: this });
1793
+ }
1794
+
1795
+ @excludedInJSON()
1796
+ computedStyle: object = {};
1797
+
1682
1798
  //================================================================================
1683
1799
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1684
1800
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
1685
1801
  //================================================================================
1686
1802
  }
1687
1803
 
1688
- classMap.ViewElement = ViewElement;
1804
+ classMap['ViewElement'] = ViewElement;
1689
1805
  export default ViewElement;
1690
1806
  //================================================================================
1691
1807
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑