@lcap/nasl 2.13.0-beta → 2.13.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (570) hide show
  1. package/out/automate/engine/index.d.ts +4 -0
  2. package/out/automate/engine/index.js +436 -0
  3. package/out/automate/engine/index.js.map +1 -0
  4. package/out/automate/engine/operators.d.ts +21 -0
  5. package/out/automate/engine/operators.js +161 -0
  6. package/out/automate/engine/operators.js.map +1 -0
  7. package/out/automate/engine/uniqueName.d.ts +12 -0
  8. package/out/automate/engine/uniqueName.js +107 -0
  9. package/out/automate/engine/uniqueName.js.map +1 -0
  10. package/out/automate/engine/utils.d.ts +25 -0
  11. package/out/automate/engine/utils.js +404 -0
  12. package/out/automate/engine/utils.js.map +1 -0
  13. package/out/automate/template/process.d.ts +9 -0
  14. package/out/automate/template/process.js +10976 -0
  15. package/out/automate/template/process.js.map +1 -0
  16. package/out/bak/translator.d.ts +1 -0
  17. package/out/bak/translator.js +117 -0
  18. package/out/bak/translator.js.map +1 -0
  19. package/out/common/BaseNode.d.ts +256 -0
  20. package/out/common/BaseNode.js +891 -0
  21. package/out/common/BaseNode.js.map +1 -0
  22. package/out/common/Command.d.ts +8 -0
  23. package/out/common/Command.js +32 -0
  24. package/out/common/Command.js.map +1 -0
  25. package/out/common/ComponentAPI.d.ts +110 -0
  26. package/out/common/ComponentAPI.js +3 -0
  27. package/out/common/ComponentAPI.js.map +1 -0
  28. package/out/common/EventEmitter.d.ts +58 -0
  29. package/out/common/EventEmitter.js +68 -0
  30. package/out/common/EventEmitter.js.map +1 -0
  31. package/out/common/Messager.d.ts +86 -0
  32. package/out/common/Messager.js +187 -0
  33. package/out/common/Messager.js.map +1 -0
  34. package/out/common/classMap.d.ts +4 -0
  35. package/out/common/classMap.js +5 -0
  36. package/out/common/classMap.js.map +1 -0
  37. package/out/common/index.d.ts +4 -0
  38. package/out/common/index.js +21 -0
  39. package/out/common/index.js.map +1 -0
  40. package/out/concepts/App__.d.ts +1119 -0
  41. package/out/concepts/App__.js +1591 -0
  42. package/out/concepts/App__.js.map +1 -0
  43. package/out/concepts/Argument__.d.ts +58 -0
  44. package/out/concepts/Argument__.js +198 -0
  45. package/out/concepts/Argument__.js.map +1 -0
  46. package/out/concepts/Assignee__.d.ts +201 -0
  47. package/out/concepts/Assignee__.js +298 -0
  48. package/out/concepts/Assignee__.js.map +1 -0
  49. package/out/concepts/Assignment__.d.ts +70 -0
  50. package/out/concepts/Assignment__.js +201 -0
  51. package/out/concepts/Assignment__.js.map +1 -0
  52. package/out/concepts/Attribute__.d.ts +101 -0
  53. package/out/concepts/Attribute__.js +221 -0
  54. package/out/concepts/Attribute__.js.map +1 -0
  55. package/out/concepts/BinaryExpression__.d.ts +64 -0
  56. package/out/concepts/BinaryExpression__.js +269 -0
  57. package/out/concepts/BinaryExpression__.js.map +1 -0
  58. package/out/concepts/BindAttribute__.d.ts +231 -0
  59. package/out/concepts/BindAttribute__.js +450 -0
  60. package/out/concepts/BindAttribute__.js.map +1 -0
  61. package/out/concepts/BindDirective__.d.ts +93 -0
  62. package/out/concepts/BindDirective__.js +251 -0
  63. package/out/concepts/BindDirective__.js.map +1 -0
  64. package/out/concepts/BindEvent__.d.ts +231 -0
  65. package/out/concepts/BindEvent__.js +661 -0
  66. package/out/concepts/BindEvent__.js.map +1 -0
  67. package/out/concepts/BooleanLiteral__.d.ts +31 -0
  68. package/out/concepts/BooleanLiteral__.js +91 -0
  69. package/out/concepts/BooleanLiteral__.js.map +1 -0
  70. package/out/concepts/CallFunction__.d.ts +153 -0
  71. package/out/concepts/CallFunction__.js +381 -0
  72. package/out/concepts/CallFunction__.js.map +1 -0
  73. package/out/concepts/CallInterface__.d.ts +103 -0
  74. package/out/concepts/CallInterface__.js +443 -0
  75. package/out/concepts/CallInterface__.js.map +1 -0
  76. package/out/concepts/CallLogic__.d.ts +170 -0
  77. package/out/concepts/CallLogic__.js +604 -0
  78. package/out/concepts/CallLogic__.js.map +1 -0
  79. package/out/concepts/CallQueryComponent__.d.ts +345 -0
  80. package/out/concepts/CallQueryComponent__.js +1009 -0
  81. package/out/concepts/CallQueryComponent__.js.map +1 -0
  82. package/out/concepts/Comment__.d.ts +30 -0
  83. package/out/concepts/Comment__.js +93 -0
  84. package/out/concepts/Comment__.js.map +1 -0
  85. package/out/concepts/CompletionProperty__.d.ts +100 -0
  86. package/out/concepts/CompletionProperty__.js +236 -0
  87. package/out/concepts/CompletionProperty__.js.map +1 -0
  88. package/out/concepts/ConfigGroup__.d.ts +121 -0
  89. package/out/concepts/ConfigGroup__.js +221 -0
  90. package/out/concepts/ConfigGroup__.js.map +1 -0
  91. package/out/concepts/ConfigPropertyValue__.d.ts +43 -0
  92. package/out/concepts/ConfigPropertyValue__.js +103 -0
  93. package/out/concepts/ConfigPropertyValue__.js.map +1 -0
  94. package/out/concepts/ConfigProperty__.d.ts +129 -0
  95. package/out/concepts/ConfigProperty__.js +239 -0
  96. package/out/concepts/ConfigProperty__.js.map +1 -0
  97. package/out/concepts/Configuration__.d.ts +121 -0
  98. package/out/concepts/Configuration__.js +213 -0
  99. package/out/concepts/Configuration__.js.map +1 -0
  100. package/out/concepts/Constant__.d.ts +99 -0
  101. package/out/concepts/Constant__.js +237 -0
  102. package/out/concepts/Constant__.js.map +1 -0
  103. package/out/concepts/DataElement__.d.ts +45 -0
  104. package/out/concepts/DataElement__.js +114 -0
  105. package/out/concepts/DataElement__.js.map +1 -0
  106. package/out/concepts/DataSource__.d.ts +143 -0
  107. package/out/concepts/DataSource__.js +318 -0
  108. package/out/concepts/DataSource__.js.map +1 -0
  109. package/out/concepts/Destination__.d.ts +120 -0
  110. package/out/concepts/Destination__.js +434 -0
  111. package/out/concepts/Destination__.js.map +1 -0
  112. package/out/concepts/End__.d.ts +23 -0
  113. package/out/concepts/End__.js +84 -0
  114. package/out/concepts/End__.js.map +1 -0
  115. package/out/concepts/EntityIndex__.d.ts +94 -0
  116. package/out/concepts/EntityIndex__.js +215 -0
  117. package/out/concepts/EntityIndex__.js.map +1 -0
  118. package/out/concepts/EntityProperty__.d.ts +231 -0
  119. package/out/concepts/EntityProperty__.js +567 -0
  120. package/out/concepts/EntityProperty__.js.map +1 -0
  121. package/out/concepts/Entity__.d.ts +297 -0
  122. package/out/concepts/Entity__.js +571 -0
  123. package/out/concepts/Entity__.js.map +1 -0
  124. package/out/concepts/EnumItem__.d.ts +60 -0
  125. package/out/concepts/EnumItem__.js +136 -0
  126. package/out/concepts/EnumItem__.js.map +1 -0
  127. package/out/concepts/Enum__.d.ts +135 -0
  128. package/out/concepts/Enum__.js +293 -0
  129. package/out/concepts/Enum__.js.map +1 -0
  130. package/out/concepts/Event__.d.ts +142 -0
  131. package/out/concepts/Event__.js +242 -0
  132. package/out/concepts/Event__.js.map +1 -0
  133. package/out/concepts/ForEachStatement__.d.ts +191 -0
  134. package/out/concepts/ForEachStatement__.js +441 -0
  135. package/out/concepts/ForEachStatement__.js.map +1 -0
  136. package/out/concepts/Function__.d.ts +411 -0
  137. package/out/concepts/Function__.js +665 -0
  138. package/out/concepts/Function__.js.map +1 -0
  139. package/out/concepts/Identifier__.d.ts +45 -0
  140. package/out/concepts/Identifier__.js +203 -0
  141. package/out/concepts/Identifier__.js.map +1 -0
  142. package/out/concepts/IfStatement__.d.ts +148 -0
  143. package/out/concepts/IfStatement__.js +280 -0
  144. package/out/concepts/IfStatement__.js.map +1 -0
  145. package/out/concepts/InterfaceParam__.d.ts +112 -0
  146. package/out/concepts/InterfaceParam__.js +311 -0
  147. package/out/concepts/InterfaceParam__.js.map +1 -0
  148. package/out/concepts/Interface__.d.ts +268 -0
  149. package/out/concepts/Interface__.js +599 -0
  150. package/out/concepts/Interface__.js.map +1 -0
  151. package/out/concepts/JSBlock__.d.ts +31 -0
  152. package/out/concepts/JSBlock__.js +90 -0
  153. package/out/concepts/JSBlock__.js.map +1 -0
  154. package/out/concepts/LogicItem__.d.ts +117 -0
  155. package/out/concepts/LogicItem__.js +233 -0
  156. package/out/concepts/LogicItem__.js.map +1 -0
  157. package/out/concepts/Logic__.d.ts +616 -0
  158. package/out/concepts/Logic__.js +1269 -0
  159. package/out/concepts/Logic__.js.map +1 -0
  160. package/out/concepts/MemberExpression__.d.ts +65 -0
  161. package/out/concepts/MemberExpression__.js +238 -0
  162. package/out/concepts/MemberExpression__.js.map +1 -0
  163. package/out/concepts/Module__.d.ts +675 -0
  164. package/out/concepts/Module__.js +914 -0
  165. package/out/concepts/Module__.js.map +1 -0
  166. package/out/concepts/Namespace__.d.ts +986 -0
  167. package/out/concepts/Namespace__.js +1301 -0
  168. package/out/concepts/Namespace__.js.map +1 -0
  169. package/out/concepts/NullLiteral__.d.ts +23 -0
  170. package/out/concepts/NullLiteral__.js +73 -0
  171. package/out/concepts/NullLiteral__.js.map +1 -0
  172. package/out/concepts/NumericLiteral__.d.ts +53 -0
  173. package/out/concepts/NumericLiteral__.js +172 -0
  174. package/out/concepts/NumericLiteral__.js.map +1 -0
  175. package/out/concepts/Param__.d.ts +148 -0
  176. package/out/concepts/Param__.js +372 -0
  177. package/out/concepts/Param__.js.map +1 -0
  178. package/out/concepts/Point__.d.ts +30 -0
  179. package/out/concepts/Point__.js +75 -0
  180. package/out/concepts/Point__.js.map +1 -0
  181. package/out/concepts/ProcessComponent__.d.ts +218 -0
  182. package/out/concepts/ProcessComponent__.js +333 -0
  183. package/out/concepts/ProcessComponent__.js.map +1 -0
  184. package/out/concepts/ProcessElement__.d.ts +640 -0
  185. package/out/concepts/ProcessElement__.js +1128 -0
  186. package/out/concepts/ProcessElement__.js.map +1 -0
  187. package/out/concepts/ProcessOutcome__.d.ts +30 -0
  188. package/out/concepts/ProcessOutcome__.js +87 -0
  189. package/out/concepts/ProcessOutcome__.js.map +1 -0
  190. package/out/concepts/Process__.d.ts +544 -0
  191. package/out/concepts/Process__.js +917 -0
  192. package/out/concepts/Process__.js.map +1 -0
  193. package/out/concepts/QueryAggregateExpression__.d.ts +50 -0
  194. package/out/concepts/QueryAggregateExpression__.js +144 -0
  195. package/out/concepts/QueryAggregateExpression__.js.map +1 -0
  196. package/out/concepts/QueryFieldExpression__.d.ts +48 -0
  197. package/out/concepts/QueryFieldExpression__.js +132 -0
  198. package/out/concepts/QueryFieldExpression__.js.map +1 -0
  199. package/out/concepts/QueryFromExpression__.d.ts +95 -0
  200. package/out/concepts/QueryFromExpression__.js +192 -0
  201. package/out/concepts/QueryFromExpression__.js.map +1 -0
  202. package/out/concepts/QueryGroupByExpression__.d.ts +45 -0
  203. package/out/concepts/QueryGroupByExpression__.js +139 -0
  204. package/out/concepts/QueryGroupByExpression__.js.map +1 -0
  205. package/out/concepts/QueryJoinExpression__.d.ts +182 -0
  206. package/out/concepts/QueryJoinExpression__.js +312 -0
  207. package/out/concepts/QueryJoinExpression__.js.map +1 -0
  208. package/out/concepts/QueryLimitExpression__.d.ts +56 -0
  209. package/out/concepts/QueryLimitExpression__.js +156 -0
  210. package/out/concepts/QueryLimitExpression__.js.map +1 -0
  211. package/out/concepts/QueryOrderByExpression__.d.ts +67 -0
  212. package/out/concepts/QueryOrderByExpression__.js +169 -0
  213. package/out/concepts/QueryOrderByExpression__.js.map +1 -0
  214. package/out/concepts/QuerySelectExpression__.d.ts +114 -0
  215. package/out/concepts/QuerySelectExpression__.js +203 -0
  216. package/out/concepts/QuerySelectExpression__.js.map +1 -0
  217. package/out/concepts/Rect__.d.ts +38 -0
  218. package/out/concepts/Rect__.js +89 -0
  219. package/out/concepts/Rect__.js.map +1 -0
  220. package/out/concepts/Return__.d.ts +131 -0
  221. package/out/concepts/Return__.js +340 -0
  222. package/out/concepts/Return__.js.map +1 -0
  223. package/out/concepts/Role__.d.ts +61 -0
  224. package/out/concepts/Role__.js +164 -0
  225. package/out/concepts/Role__.js.map +1 -0
  226. package/out/concepts/Slot__.d.ts +57 -0
  227. package/out/concepts/Slot__.js +114 -0
  228. package/out/concepts/Slot__.js.map +1 -0
  229. package/out/concepts/SqlQueryComponent__.d.ts +64 -0
  230. package/out/concepts/SqlQueryComponent__.js +180 -0
  231. package/out/concepts/SqlQueryComponent__.js.map +1 -0
  232. package/out/concepts/Start__.d.ts +23 -0
  233. package/out/concepts/Start__.js +71 -0
  234. package/out/concepts/Start__.js.map +1 -0
  235. package/out/concepts/StringLiteral__.d.ts +35 -0
  236. package/out/concepts/StringLiteral__.js +125 -0
  237. package/out/concepts/StringLiteral__.js.map +1 -0
  238. package/out/concepts/StructureProperty__.d.ts +124 -0
  239. package/out/concepts/StructureProperty__.js +324 -0
  240. package/out/concepts/StructureProperty__.js.map +1 -0
  241. package/out/concepts/Structure__.d.ts +250 -0
  242. package/out/concepts/Structure__.js +440 -0
  243. package/out/concepts/Structure__.js.map +1 -0
  244. package/out/concepts/SwitchCase__.d.ts +92 -0
  245. package/out/concepts/SwitchCase__.js +229 -0
  246. package/out/concepts/SwitchCase__.js.map +1 -0
  247. package/out/concepts/SwitchStatement__.d.ts +82 -0
  248. package/out/concepts/SwitchStatement__.js +175 -0
  249. package/out/concepts/SwitchStatement__.js.map +1 -0
  250. package/out/concepts/Theme__.d.ts +36 -0
  251. package/out/concepts/Theme__.js +86 -0
  252. package/out/concepts/Theme__.js.map +1 -0
  253. package/out/concepts/Transactional__.d.ts +76 -0
  254. package/out/concepts/Transactional__.js +151 -0
  255. package/out/concepts/Transactional__.js.map +1 -0
  256. package/out/concepts/TypeAnnotation__.d.ts +147 -0
  257. package/out/concepts/TypeAnnotation__.js +444 -0
  258. package/out/concepts/TypeAnnotation__.js.map +1 -0
  259. package/out/concepts/TypeParam__.d.ts +20 -0
  260. package/out/concepts/TypeParam__.js +57 -0
  261. package/out/concepts/TypeParam__.js.map +1 -0
  262. package/out/concepts/UnaryExpression__.d.ts +46 -0
  263. package/out/concepts/UnaryExpression__.js +166 -0
  264. package/out/concepts/UnaryExpression__.js.map +1 -0
  265. package/out/concepts/Unparsed__.d.ts +29 -0
  266. package/out/concepts/Unparsed__.js +88 -0
  267. package/out/concepts/Unparsed__.js.map +1 -0
  268. package/out/concepts/UseComponent__.d.ts +30 -0
  269. package/out/concepts/UseComponent__.js +75 -0
  270. package/out/concepts/UseComponent__.js.map +1 -0
  271. package/out/concepts/ValidationRule__.d.ts +94 -0
  272. package/out/concepts/ValidationRule__.js +254 -0
  273. package/out/concepts/ValidationRule__.js.map +1 -0
  274. package/out/concepts/Variable__.d.ts +130 -0
  275. package/out/concepts/Variable__.js +338 -0
  276. package/out/concepts/Variable__.js.map +1 -0
  277. package/out/concepts/ViewComponent__.d.ts +472 -0
  278. package/out/concepts/ViewComponent__.js +644 -0
  279. package/out/concepts/ViewComponent__.js.map +1 -0
  280. package/out/concepts/ViewElement__.d.ts +490 -0
  281. package/out/concepts/ViewElement__.js +1413 -0
  282. package/out/concepts/ViewElement__.js.map +1 -0
  283. package/out/concepts/View__.d.ts +692 -0
  284. package/out/concepts/View__.js +1397 -0
  285. package/out/concepts/View__.js.map +1 -0
  286. package/out/concepts/WhileStatement__.d.ts +95 -0
  287. package/out/concepts/WhileStatement__.js +208 -0
  288. package/out/concepts/WhileStatement__.js.map +1 -0
  289. package/out/concepts/basics/stdlib/index.d.ts +4 -0
  290. package/out/concepts/basics/stdlib/index.js +26 -0
  291. package/out/concepts/basics/stdlib/index.js.map +1 -0
  292. package/out/concepts/basics/stdlib/nasl.auth.d.ts +3 -0
  293. package/out/concepts/basics/stdlib/nasl.auth.js +50 -0
  294. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -0
  295. package/out/concepts/basics/stdlib/nasl.browser.d.ts +3 -0
  296. package/out/concepts/basics/stdlib/nasl.browser.js +41 -0
  297. package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -0
  298. package/out/concepts/basics/stdlib/nasl.collection.d.ts +7 -0
  299. package/out/concepts/basics/stdlib/nasl.collection.js +83 -0
  300. package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -0
  301. package/out/concepts/basics/stdlib/nasl.configuration.d.ts +3 -0
  302. package/out/concepts/basics/stdlib/nasl.configuration.js +25 -0
  303. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -0
  304. package/out/concepts/basics/stdlib/nasl.core.d.ts +3 -0
  305. package/out/concepts/basics/stdlib/nasl.core.js +15 -0
  306. package/out/concepts/basics/stdlib/nasl.core.js.map +1 -0
  307. package/out/concepts/basics/stdlib/nasl.interface.d.ts +7 -0
  308. package/out/concepts/basics/stdlib/nasl.interface.js +43 -0
  309. package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -0
  310. package/out/concepts/basics/stdlib/nasl.process.d.ts +7 -0
  311. package/out/concepts/basics/stdlib/nasl.process.js +453 -0
  312. package/out/concepts/basics/stdlib/nasl.process.js.map +1 -0
  313. package/out/concepts/basics/stdlib/nasl.ui.d.ts +7 -0
  314. package/out/concepts/basics/stdlib/nasl.ui.js +828 -0
  315. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -0
  316. package/out/concepts/basics/stdlib/nasl.util.d.ts +3 -0
  317. package/out/concepts/basics/stdlib/nasl.util.js +1030 -0
  318. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -0
  319. package/out/concepts/basics/stdlib/nasl.validation.d.ts +3 -0
  320. package/out/concepts/basics/stdlib/nasl.validation.js +561 -0
  321. package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -0
  322. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.d.ts +5 -0
  323. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +26 -0
  324. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -0
  325. package/out/concepts/basics/types/coreTypeList.d.ts +2 -0
  326. package/out/concepts/basics/types/coreTypeList.js +19 -0
  327. package/out/concepts/basics/types/coreTypeList.js.map +1 -0
  328. package/out/concepts/basics/types/index.d.ts +13 -0
  329. package/out/concepts/basics/types/index.js +27 -0
  330. package/out/concepts/basics/types/index.js.map +1 -0
  331. package/out/concepts/index.d.ts +5 -0
  332. package/out/concepts/index.js +24 -0
  333. package/out/concepts/index.js.map +1 -0
  334. package/out/concepts/index__.d.ts +83 -0
  335. package/out/concepts/index__.js +100 -0
  336. package/out/concepts/index__.js.map +1 -0
  337. package/out/config.d.ts +42 -0
  338. package/out/config.js +71 -0
  339. package/out/config.js.map +1 -0
  340. package/out/decorators/index.d.ts +54 -0
  341. package/out/decorators/index.js +149 -0
  342. package/out/decorators/index.js.map +1 -0
  343. package/out/enums/KEYWORDS.d.ts +3 -0
  344. package/out/enums/KEYWORDS.js +1202 -0
  345. package/out/enums/KEYWORDS.js.map +1 -0
  346. package/out/enums/LEVEL_NAME_MAP.d.ts +26 -0
  347. package/out/enums/LEVEL_NAME_MAP.js +30 -0
  348. package/out/enums/LEVEL_NAME_MAP.js.map +1 -0
  349. package/out/eventBus.d.ts +3 -0
  350. package/out/eventBus.js +7 -0
  351. package/out/eventBus.js.map +1 -0
  352. package/out/generator/compileComponent.d.ts +11 -0
  353. package/out/generator/compileComponent.js +12 -0
  354. package/out/generator/compileComponent.js.map +1 -0
  355. package/out/generator/genBundleFiles.d.ts +44 -0
  356. package/out/generator/genBundleFiles.js +387 -0
  357. package/out/generator/genBundleFiles.js.map +1 -0
  358. package/out/generator/genHash.d.ts +7 -0
  359. package/out/generator/genHash.js +39 -0
  360. package/out/generator/genHash.js.map +1 -0
  361. package/out/generator/genMetaData.d.ts +36 -0
  362. package/out/generator/genMetaData.js +121 -0
  363. package/out/generator/genMetaData.js.map +1 -0
  364. package/out/generator/index.d.ts +5 -0
  365. package/out/generator/index.js +22 -0
  366. package/out/generator/index.js.map +1 -0
  367. package/out/generator/styleReplacer.d.ts +3 -0
  368. package/out/generator/styleReplacer.js +71 -0
  369. package/out/generator/styleReplacer.js.map +1 -0
  370. package/out/index.d.ts +11 -0
  371. package/out/index.js +53 -0
  372. package/out/index.js.map +1 -0
  373. package/out/manager/diagnostic.d.ts +38 -0
  374. package/out/manager/diagnostic.js +84 -0
  375. package/out/manager/diagnostic.js.map +1 -0
  376. package/out/manager/history.d.ts +0 -0
  377. package/out/manager/history.js +1 -0
  378. package/out/manager/history.js.map +1 -0
  379. package/out/manager/problem.d.ts +0 -0
  380. package/out/manager/problem.js +1 -0
  381. package/out/manager/problem.js.map +1 -0
  382. package/out/server/createUiTs.d.ts +17 -0
  383. package/out/server/createUiTs.js +231 -0
  384. package/out/server/createUiTs.js.map +1 -0
  385. package/out/server/entity2LogicNamespace.d.ts +10 -0
  386. package/out/server/entity2LogicNamespace.js +217 -0
  387. package/out/server/entity2LogicNamespace.js.map +1 -0
  388. package/out/server/extendBaseNode.d.ts +1 -0
  389. package/out/server/extendBaseNode.js +323 -0
  390. package/out/server/extendBaseNode.js.map +1 -0
  391. package/out/server/getExtensionModules.d.ts +3 -0
  392. package/out/server/getExtensionModules.js +20 -0
  393. package/out/server/getExtensionModules.js.map +1 -0
  394. package/out/server/getFunctions.d.ts +3 -0
  395. package/out/server/getFunctions.js +20 -0
  396. package/out/server/getFunctions.js.map +1 -0
  397. package/out/server/getInterfaces.d.ts +2 -0
  398. package/out/server/getInterfaces.js +48 -0
  399. package/out/server/getInterfaces.js.map +1 -0
  400. package/out/server/getLogics.d.ts +3 -0
  401. package/out/server/getLogics.js +210 -0
  402. package/out/server/getLogics.js.map +1 -0
  403. package/out/server/getMemberIdentifier.d.ts +38 -0
  404. package/out/server/getMemberIdentifier.js +557 -0
  405. package/out/server/getMemberIdentifier.js.map +1 -0
  406. package/out/server/getProcessComponents.d.ts +2 -0
  407. package/out/server/getProcessComponents.js +13 -0
  408. package/out/server/getProcessComponents.js.map +1 -0
  409. package/out/server/getProcesses.d.ts +33 -0
  410. package/out/server/getProcesses.js +566 -0
  411. package/out/server/getProcesses.js.map +1 -0
  412. package/out/server/getScope.d.ts +13 -0
  413. package/out/server/getScope.js +61 -0
  414. package/out/server/getScope.js.map +1 -0
  415. package/out/server/getValidates.d.ts +3 -0
  416. package/out/server/getValidates.js +14 -0
  417. package/out/server/getValidates.js.map +1 -0
  418. package/out/server/index.d.ts +3 -0
  419. package/out/server/index.js +36 -0
  420. package/out/server/index.js.map +1 -0
  421. package/out/server/naslServer.d.ts +142 -0
  422. package/out/server/naslServer.js +1768 -0
  423. package/out/server/naslServer.js.map +1 -0
  424. package/out/server/process2LogicNamespace.d.ts +26 -0
  425. package/out/server/process2LogicNamespace.js +97 -0
  426. package/out/server/process2LogicNamespace.js.map +1 -0
  427. package/out/server/translator.d.ts +24 -0
  428. package/out/server/translator.js +474 -0
  429. package/out/server/translator.js.map +1 -0
  430. package/out/service/creator/add.configs.d.ts +1 -0
  431. package/out/service/creator/add.configs.js +68 -0
  432. package/out/service/creator/add.configs.js.map +1 -0
  433. package/out/service/creator/errHandles.d.ts +18 -0
  434. package/out/service/creator/errHandles.js +65 -0
  435. package/out/service/creator/errHandles.js.map +1 -0
  436. package/out/service/creator/index.d.ts +1 -0
  437. package/out/service/creator/index.js +72 -0
  438. package/out/service/creator/index.js.map +1 -0
  439. package/out/service/storage/api.d.ts +18 -0
  440. package/out/service/storage/api.js +17 -0
  441. package/out/service/storage/api.js.map +1 -0
  442. package/out/service/storage/index.d.ts +2 -0
  443. package/out/service/storage/index.js +10 -0
  444. package/out/service/storage/index.js.map +1 -0
  445. package/out/service/storage/init.d.ts +13 -0
  446. package/out/service/storage/init.js +469 -0
  447. package/out/service/storage/init.js.map +1 -0
  448. package/out/service/storage/jsoner.d.ts +29 -0
  449. package/out/service/storage/jsoner.js +130 -0
  450. package/out/service/storage/jsoner.js.map +1 -0
  451. package/out/service/storage/map.d.ts +4 -0
  452. package/out/service/storage/map.js +54 -0
  453. package/out/service/storage/map.js.map +1 -0
  454. package/out/service/storage/service.d.ts +2 -0
  455. package/out/service/storage/service.js +10 -0
  456. package/out/service/storage/service.js.map +1 -0
  457. package/out/service/storage/storagePoint.d.ts +17 -0
  458. package/out/service/storage/storagePoint.js +76 -0
  459. package/out/service/storage/storagePoint.js.map +1 -0
  460. package/out/templator/genCallComponentLogic.d.ts +17 -0
  461. package/out/templator/genCallComponentLogic.js +30 -0
  462. package/out/templator/genCallComponentLogic.js.map +1 -0
  463. package/out/templator/genCreateBlock.d.ts +10 -0
  464. package/out/templator/genCreateBlock.js +333 -0
  465. package/out/templator/genCreateBlock.js.map +1 -0
  466. package/out/templator/genCurdEditMultipleKeyBlock.d.ts +2 -0
  467. package/out/templator/genCurdEditMultipleKeyBlock.js +483 -0
  468. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -0
  469. package/out/templator/genCurdMultipleKeyBlock.d.ts +14 -0
  470. package/out/templator/genCurdMultipleKeyBlock.js +688 -0
  471. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -0
  472. package/out/templator/genEditTableBlock.d.ts +51 -0
  473. package/out/templator/genEditTableBlock.js +278 -0
  474. package/out/templator/genEditTableBlock.js.map +1 -0
  475. package/out/templator/genEnumSelectBlock.d.ts +10 -0
  476. package/out/templator/genEnumSelectBlock.js +23 -0
  477. package/out/templator/genEnumSelectBlock.js.map +1 -0
  478. package/out/templator/genGetBlock.d.ts +6 -0
  479. package/out/templator/genGetBlock.js +135 -0
  480. package/out/templator/genGetBlock.js.map +1 -0
  481. package/out/templator/genGridViewBlock.d.ts +55 -0
  482. package/out/templator/genGridViewBlock.js +354 -0
  483. package/out/templator/genGridViewBlock.js.map +1 -0
  484. package/out/templator/genListViewBlock.d.ts +19 -0
  485. package/out/templator/genListViewBlock.js +141 -0
  486. package/out/templator/genListViewBlock.js.map +1 -0
  487. package/out/templator/genQueryComponent.d.ts +34 -0
  488. package/out/templator/genQueryComponent.js +322 -0
  489. package/out/templator/genQueryComponent.js.map +1 -0
  490. package/out/templator/genSelectBlock.d.ts +34 -0
  491. package/out/templator/genSelectBlock.js +143 -0
  492. package/out/templator/genSelectBlock.js.map +1 -0
  493. package/out/templator/genTableBlock.d.ts +53 -0
  494. package/out/templator/genTableBlock.js +291 -0
  495. package/out/templator/genTableBlock.js.map +1 -0
  496. package/out/templator/genUpdateBlock.d.ts +6 -0
  497. package/out/templator/genUpdateBlock.js +374 -0
  498. package/out/templator/genUpdateBlock.js.map +1 -0
  499. package/out/templator/index.d.ts +16 -0
  500. package/out/templator/index.js +34 -0
  501. package/out/templator/index.js.map +1 -0
  502. package/out/templator/utils.d.ts +653 -0
  503. package/out/templator/utils.js +427 -0
  504. package/out/templator/utils.js.map +1 -0
  505. package/out/test/fixtures/env.d.ts +5 -0
  506. package/out/test/fixtures/env.js +20 -0
  507. package/out/test/fixtures/env.js.map +1 -0
  508. package/out/test/integration/connect-create-file.d.ts +1 -0
  509. package/out/test/integration/connect-create-file.js +39 -0
  510. package/out/test/integration/connect-create-file.js.map +1 -0
  511. package/out/test/integration/connect-file.d.ts +1 -0
  512. package/out/test/integration/connect-file.js +49 -0
  513. package/out/test/integration/connect-file.js.map +1 -0
  514. package/out/test/units/baseTypes/Assignment.spec.d.ts +1 -0
  515. package/out/test/units/baseTypes/Assignment.spec.js +43 -0
  516. package/out/test/units/baseTypes/Assignment.spec.js.map +1 -0
  517. package/out/test/units/baseTypes/CallLogic.spec.d.ts +1 -0
  518. package/out/test/units/baseTypes/CallLogic.spec.js +44 -0
  519. package/out/test/units/baseTypes/CallLogic.spec.js.map +1 -0
  520. package/out/test/units/baseTypes/StringLiteral.spec.d.ts +1 -0
  521. package/out/test/units/baseTypes/StringLiteral.spec.js +75 -0
  522. package/out/test/units/baseTypes/StringLiteral.spec.js.map +1 -0
  523. package/out/test/units/baseTypes/new.spec.d.ts +1 -0
  524. package/out/test/units/baseTypes/new.spec.js +37 -0
  525. package/out/test/units/baseTypes/new.spec.js.map +1 -0
  526. package/out/test/units/common/Vertex.spec.d.ts +1 -0
  527. package/out/test/units/common/Vertex.spec.js +22 -0
  528. package/out/test/units/common/Vertex.spec.js.map +1 -0
  529. package/out/test/units/data/Entity.spec.d.ts +1 -0
  530. package/out/test/units/data/Entity.spec.js +12 -0
  531. package/out/test/units/data/Entity.spec.js.map +1 -0
  532. package/out/test/units/login.spec.d.ts +1 -0
  533. package/out/test/units/login.spec.js +12 -0
  534. package/out/test/units/login.spec.js.map +1 -0
  535. package/out/test/units/page/Block.spec.d.ts +0 -0
  536. package/out/test/units/page/Block.spec.js +13 -0
  537. package/out/test/units/page/Block.spec.js.map +1 -0
  538. package/out/test/units/page/Element.spec.d.ts +1 -0
  539. package/out/test/units/page/Element.spec.js +44 -0
  540. package/out/test/units/page/Element.spec.js.map +1 -0
  541. package/out/test/units/temp/temp.spec.d.ts +1 -0
  542. package/out/test/units/temp/temp.spec.js +68 -0
  543. package/out/test/units/temp/temp.spec.js.map +1 -0
  544. package/out/translator/index.d.ts +47 -0
  545. package/out/translator/index.js +108 -0
  546. package/out/translator/index.js.map +1 -0
  547. package/out/translator/lsp.d.ts +45 -0
  548. package/out/translator/lsp.js +6 -0
  549. package/out/translator/lsp.js.map +1 -0
  550. package/out/translator/tsp.d.ts +12 -0
  551. package/out/translator/tsp.js +3 -0
  552. package/out/translator/tsp.js.map +1 -0
  553. package/out/utils/index.d.ts +37 -0
  554. package/out/utils/index.js +125 -0
  555. package/out/utils/index.js.map +1 -0
  556. package/out/utils/logger.d.ts +3 -0
  557. package/out/utils/logger.js +11 -0
  558. package/out/utils/logger.js.map +1 -0
  559. package/out/utils/string.d.ts +38 -0
  560. package/out/utils/string.js +95 -0
  561. package/out/utils/string.js.map +1 -0
  562. package/out/utils/traverse.d.ts +36 -0
  563. package/out/utils/traverse.js +132 -0
  564. package/out/utils/traverse.js.map +1 -0
  565. package/package.json +1 -1
  566. package/src/concepts/BindEvent__.ts +15 -7
  567. package/src/concepts/Logic__.ts +2 -1
  568. package/src/concepts/Process__.ts +1 -1
  569. package/src/concepts/View__.ts +2 -2
  570. package/src/server/getProcesses.ts +2 -2
@@ -0,0 +1,1413 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __importDefault = (this && this.__importDefault) || function (mod) {
32
+ return (mod && mod.__esModule) ? mod : { "default": mod };
33
+ };
34
+ var ViewElement_1;
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ViewElement = void 0;
37
+ const translator_1 = require("../translator");
38
+ const babelParser = __importStar(require("@babel/parser"));
39
+ const json5 = __importStar(require("json5"));
40
+ const compiler = __importStar(require("vue-template-compiler"));
41
+ const LogicItem__1 = __importDefault(require("./LogicItem__"));
42
+ const __1 = require("..");
43
+ function genArgumentMemberExpression(arr) {
44
+ let expressionNode;
45
+ const propertyName = arr.pop();
46
+ if (arr.length >= 1) {
47
+ expressionNode = {
48
+ concept: 'MemberExpression',
49
+ name: '',
50
+ kind: 'Expression',
51
+ object: genArgumentMemberExpression(arr),
52
+ property: {
53
+ concept: 'Identifier',
54
+ kind: 'Expression',
55
+ name: propertyName,
56
+ },
57
+ };
58
+ }
59
+ else {
60
+ return {
61
+ concept: 'Identifier',
62
+ kind: 'Expression',
63
+ name: propertyName,
64
+ };
65
+ }
66
+ return expressionNode;
67
+ }
68
+ function transAstNodeToNaslNode(astNode, namespace) {
69
+ let node = null;
70
+ if (astNode.type === 'CallExpression' && astNode.callee.object.name === '$utils') {
71
+ const calleeName = astNode.callee.property.name || astNode.callee.property.value;
72
+ if (calleeName === 'EnumList') {
73
+ const args = astNode.arguments;
74
+ let name = '';
75
+ let namespace = 'app.enums';
76
+ if (Array.isArray(args)) {
77
+ name = args[0]?.value;
78
+ namespace = args[1]?.value ? args[1]?.value : 'app.enums';
79
+ }
80
+ node = {
81
+ concept: 'Identifier',
82
+ name,
83
+ namespace,
84
+ kind: 'Expression',
85
+ };
86
+ }
87
+ else {
88
+ node = {
89
+ concept: 'CallFunction',
90
+ name: '',
91
+ label: '调用内置函数',
92
+ kind: 'Expression',
93
+ calleeNamespace: 'nasl.util',
94
+ calleeName,
95
+ arguments: astNode.arguments.map((argument) => ({
96
+ concept: 'Argument',
97
+ name: '',
98
+ kind: 'Statement',
99
+ keyword: '',
100
+ expression: transAstNodeToNaslNode(Object.assign({}, argument)),
101
+ })),
102
+ };
103
+ }
104
+ }
105
+ else if (astNode.type === 'MemberExpression') {
106
+ if (astNode.object?.name === '$global') {
107
+ // 目前只有权限相关的
108
+ node = transAstNodeToNaslNode(astNode.property, 'nasl.auth');
109
+ }
110
+ else {
111
+ node = {
112
+ concept: 'MemberExpression',
113
+ name: '',
114
+ kind: 'Expression',
115
+ object: transAstNodeToNaslNode(astNode.object),
116
+ property: transAstNodeToNaslNode(astNode.property),
117
+ };
118
+ }
119
+ }
120
+ else if (astNode.type === 'Identifier') {
121
+ node = {
122
+ concept: 'Identifier',
123
+ namespace: namespace || '',
124
+ name: astNode.name,
125
+ kind: 'Expression',
126
+ };
127
+ }
128
+ else if (astNode.type === 'ArrayExpression' || astNode.type === 'ObjectExpression') {
129
+ node = {
130
+ concept: 'Unparsed',
131
+ label: '原子项',
132
+ code: astNode.value,
133
+ };
134
+ }
135
+ else if (astNode.type === 'StringLiteral') {
136
+ node = {
137
+ concept: 'StringLiteral',
138
+ kind: 'Expression',
139
+ name: '',
140
+ value: astNode.value,
141
+ };
142
+ }
143
+ else if (astNode.type === 'UnaryExpression') {
144
+ node = {
145
+ concept: 'UnaryExpression',
146
+ kind: 'Expression',
147
+ name: '',
148
+ operator: astNode.operator,
149
+ argument: transAstNodeToNaslNode(astNode.argument),
150
+ };
151
+ }
152
+ else {
153
+ node = astNode;
154
+ node.concept = astNode.type;
155
+ }
156
+ return node;
157
+ }
158
+ const decorators_1 = require("../decorators");
159
+ const utils = __importStar(require("../utils"));
160
+ const BaseNode_1 = __importDefault(require("../common/BaseNode"));
161
+ const classMap_1 = __importDefault(require("../common/classMap"));
162
+ const BindAttribute__1 = __importDefault(require("./BindAttribute__"));
163
+ const BindEvent__1 = __importDefault(require("./BindEvent__"));
164
+ const BindDirective__1 = __importDefault(require("./BindDirective__"));
165
+ /**
166
+ * 页面元素
167
+ */
168
+ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
169
+ /**
170
+ * 产品概念
171
+ */
172
+ concept = 'ViewElement';
173
+ /**
174
+ * 类型
175
+ */
176
+ type = undefined;
177
+ /**
178
+ * 元素标签
179
+ */
180
+ tag = undefined;
181
+ /**
182
+ * 页面元素名称
183
+ */
184
+ name = undefined;
185
+ /**
186
+ * 静态 class 名
187
+ */
188
+ staticClass = undefined;
189
+ /**
190
+ * 静态 style
191
+ */
192
+ staticStyle = undefined;
193
+ /**
194
+ * 插槽目标
195
+ */
196
+ slotTarget = undefined;
197
+ /**
198
+ * 插槽 scope 表达式
199
+ */
200
+ slotScope = undefined;
201
+ /**
202
+ * 元素绑定属性列表
203
+ */
204
+ bindAttrs = [];
205
+ /**
206
+ * 元素绑定事件列表
207
+ */
208
+ bindEvents = [];
209
+ /**
210
+ * 元素指令列表
211
+ */
212
+ bindDirectives = [];
213
+ /**
214
+ * 绑定的角色
215
+ */
216
+ bindRoles = [];
217
+ /**
218
+ * 子元素列表
219
+ */
220
+ children = [];
221
+ /**
222
+ * 祖先 View
223
+ */
224
+ get view() {
225
+ return this.getAncestor('View');
226
+ }
227
+ /**
228
+ * 祖先 Module
229
+ */
230
+ get module() {
231
+ return this.getAncestor('Module');
232
+ }
233
+ /**
234
+ * 祖先 App
235
+ */
236
+ get app() {
237
+ return this.getAncestor('App');
238
+ }
239
+ /**
240
+ * @param source 需要合并的部分参数
241
+ */
242
+ constructor(source) {
243
+ source = Object.assign({}, ViewElement_1.getDefaultOptions(), source);
244
+ super(source);
245
+ super.subConstructor(source);
246
+ }
247
+ /**
248
+ * 从父级删除该节点
249
+ * @internal
250
+ */
251
+ _delete() {
252
+ let params = null;
253
+ if (this.parentNode) {
254
+ params = this.parentNode?.__removeViewElement?.(this);
255
+ }
256
+ return params;
257
+ }
258
+ /**
259
+ * 设置页面元素名称
260
+ */
261
+ setName(name) {
262
+ const object = {
263
+ name,
264
+ };
265
+ this.update({
266
+ ...object,
267
+ field: 'name',
268
+ });
269
+ }
270
+ /**
271
+ * 设置静态 style
272
+ */
273
+ setStaticStyle(staticStyle) {
274
+ const object = {
275
+ staticStyle,
276
+ };
277
+ this.update({
278
+ ...object,
279
+ });
280
+ }
281
+ getBindAttributeExistingNames(excludedList = []) {
282
+ const excludedSet = new Set(excludedList);
283
+ return (this.bindAttrs || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
284
+ }
285
+ getBindAttributeUniqueName(name = 'bindAttribute1') {
286
+ return utils.unique(name, this.getBindAttributeExistingNames(), undefined, false);
287
+ }
288
+ _insertBindAttributeAt(options, index) {
289
+ const bindAttributeOptions = {};
290
+ const relationOptions = { parentNode: this, parentKey: 'bindAttrs' };
291
+ let bindAttribute;
292
+ if (!options) {
293
+ bindAttribute = BindAttribute__1.default.from({
294
+ ...bindAttributeOptions,
295
+ name: this.getBindAttributeUniqueName(),
296
+ }, this, 'bindAttrs');
297
+ }
298
+ else if (typeof options === 'string') {
299
+ bindAttribute = BindAttribute__1.default.from({
300
+ ...bindAttributeOptions,
301
+ name: options,
302
+ }, this, 'bindAttrs');
303
+ }
304
+ else if (options instanceof BindAttribute__1.default) {
305
+ options.ensureDelete(); // 同一实例不支持多处存在
306
+ bindAttribute = options;
307
+ Object.assign(bindAttribute, relationOptions);
308
+ }
309
+ else {
310
+ bindAttribute = BindAttribute__1.default.from({
311
+ ...bindAttributeOptions,
312
+ ...options,
313
+ }, this, 'bindAttrs');
314
+ }
315
+ this.bindAttrs.splice(index, 0, bindAttribute);
316
+ return bindAttribute;
317
+ }
318
+ insertBindAttributeAt(options, index) {
319
+ const node = this._insertBindAttributeAt(options, index);
320
+ node.create({
321
+ index,
322
+ parentNode: this,
323
+ parentKey: 'bindAttrs',
324
+ });
325
+ return node;
326
+ }
327
+ _addBindAttribute(options) {
328
+ const index = this.bindAttrs.length;
329
+ return this._insertBindAttributeAt(options, index);
330
+ }
331
+ addBindAttribute(options) {
332
+ const node = this._addBindAttribute(options);
333
+ const index = this.bindAttrs.indexOf(node);
334
+ node.create({
335
+ index,
336
+ parentNode: this,
337
+ parentKey: 'bindAttrs',
338
+ });
339
+ return node;
340
+ }
341
+ getBindEventExistingNames(excludedList = []) {
342
+ const excludedSet = new Set(excludedList);
343
+ return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
344
+ }
345
+ getBindEventUniqueName(name = 'bindEvent1') {
346
+ return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
347
+ }
348
+ _insertBindEventAt(options, index) {
349
+ const bindEventOptions = {};
350
+ const relationOptions = { parentNode: this, parentKey: 'bindEvents' };
351
+ let bindEvent;
352
+ if (!options) {
353
+ bindEvent = BindEvent__1.default.from({
354
+ ...bindEventOptions,
355
+ name: this.getBindEventUniqueName(),
356
+ }, this, 'bindEvents');
357
+ }
358
+ else if (typeof options === 'string') {
359
+ bindEvent = BindEvent__1.default.from({
360
+ ...bindEventOptions,
361
+ name: options,
362
+ }, this, 'bindEvents');
363
+ }
364
+ else if (options instanceof BindEvent__1.default) {
365
+ options.ensureDelete(); // 同一实例不支持多处存在
366
+ bindEvent = options;
367
+ Object.assign(bindEvent, relationOptions);
368
+ }
369
+ else {
370
+ bindEvent = BindEvent__1.default.from({
371
+ ...bindEventOptions,
372
+ ...options,
373
+ }, this, 'bindEvents');
374
+ }
375
+ this.bindEvents.splice(index, 0, bindEvent);
376
+ return bindEvent;
377
+ }
378
+ insertBindEventAt(options, index) {
379
+ const node = this._insertBindEventAt(options, index);
380
+ node.create({
381
+ index,
382
+ parentNode: this,
383
+ parentKey: 'bindEvents',
384
+ });
385
+ return node;
386
+ }
387
+ _addBindEvent(options) {
388
+ const index = this.bindEvents.length;
389
+ return this._insertBindEventAt(options, index);
390
+ }
391
+ addBindEvent(options) {
392
+ const node = this._addBindEvent(options);
393
+ const index = this.bindEvents.indexOf(node);
394
+ node.create({
395
+ index,
396
+ parentNode: this,
397
+ parentKey: 'bindEvents',
398
+ });
399
+ return node;
400
+ }
401
+ getBindDirectiveExistingNames(excludedList = []) {
402
+ const excludedSet = new Set(excludedList);
403
+ return (this.bindDirectives || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
404
+ }
405
+ getBindDirectiveUniqueName(name = 'bindDirective1') {
406
+ return utils.unique(name, this.getBindDirectiveExistingNames(), undefined, false);
407
+ }
408
+ _insertBindDirectiveAt(options, index) {
409
+ const bindDirectiveOptions = {};
410
+ const relationOptions = { parentNode: this, parentKey: 'bindDirectives' };
411
+ let bindDirective;
412
+ if (!options) {
413
+ bindDirective = BindDirective__1.default.from({
414
+ ...bindDirectiveOptions,
415
+ name: this.getBindDirectiveUniqueName(),
416
+ }, this, 'bindDirectives');
417
+ }
418
+ else if (typeof options === 'string') {
419
+ bindDirective = BindDirective__1.default.from({
420
+ ...bindDirectiveOptions,
421
+ name: options,
422
+ }, this, 'bindDirectives');
423
+ }
424
+ else if (options instanceof BindDirective__1.default) {
425
+ options.ensureDelete(); // 同一实例不支持多处存在
426
+ bindDirective = options;
427
+ Object.assign(bindDirective, relationOptions);
428
+ }
429
+ else {
430
+ bindDirective = BindDirective__1.default.from({
431
+ ...bindDirectiveOptions,
432
+ ...options,
433
+ }, this, 'bindDirectives');
434
+ }
435
+ this.bindDirectives.splice(index, 0, bindDirective);
436
+ return bindDirective;
437
+ }
438
+ insertBindDirectiveAt(options, index) {
439
+ const node = this._insertBindDirectiveAt(options, index);
440
+ node.create({
441
+ index,
442
+ parentNode: this,
443
+ parentKey: 'bindDirectives',
444
+ });
445
+ return node;
446
+ }
447
+ _addBindDirective(options) {
448
+ const index = this.bindDirectives.length;
449
+ return this._insertBindDirectiveAt(options, index);
450
+ }
451
+ addBindDirective(options) {
452
+ const node = this._addBindDirective(options);
453
+ const index = this.bindDirectives.indexOf(node);
454
+ node.create({
455
+ index,
456
+ parentNode: this,
457
+ parentKey: 'bindDirectives',
458
+ });
459
+ return node;
460
+ }
461
+ _insertViewElementAt(options, index) {
462
+ const viewElementOptions = {};
463
+ const relationOptions = { parentNode: this, parentKey: 'children' };
464
+ let viewElement;
465
+ if (!options) {
466
+ viewElement = ViewElement_1.from({
467
+ ...viewElementOptions,
468
+ name: this.getViewElementUniqueName(),
469
+ }, this, 'children');
470
+ }
471
+ else if (typeof options === 'string') {
472
+ viewElement = ViewElement_1.from({
473
+ ...viewElementOptions,
474
+ name: options,
475
+ }, this, 'children');
476
+ }
477
+ else if (options instanceof ViewElement_1) {
478
+ options.ensureDelete(); // 同一实例不支持多处存在
479
+ viewElement = options;
480
+ Object.assign(viewElement, relationOptions);
481
+ }
482
+ else {
483
+ viewElement = ViewElement_1.from({
484
+ ...viewElementOptions,
485
+ ...options,
486
+ }, this, 'children');
487
+ }
488
+ this.children.splice(index, 0, viewElement);
489
+ return viewElement;
490
+ }
491
+ insertViewElementAt(options, index) {
492
+ const node = this._insertViewElementAt(options, index);
493
+ node.create({
494
+ index,
495
+ parentNode: this,
496
+ parentKey: 'children',
497
+ });
498
+ return node;
499
+ }
500
+ _addViewElement(options) {
501
+ const index = this.children.length;
502
+ return this._insertViewElementAt(options, index);
503
+ }
504
+ addViewElement(options) {
505
+ const node = this._addViewElement(options);
506
+ const index = this.children.indexOf(node);
507
+ node.create({
508
+ index,
509
+ parentNode: this,
510
+ parentKey: 'children',
511
+ });
512
+ return node;
513
+ }
514
+ removeBindAttribute(options) {
515
+ let bindAttribute;
516
+ if (typeof options === 'string') {
517
+ bindAttribute = this.bindAttrs.find((item) => item.name === options);
518
+ if (!bindAttribute) {
519
+ throw new Error('找不到元素绑定属性 ' + options);
520
+ }
521
+ }
522
+ else {
523
+ bindAttribute = options;
524
+ }
525
+ return bindAttribute.delete();
526
+ }
527
+ __removeBindAttribute(bindAttribute) {
528
+ const parentKey = bindAttribute.parentKey;
529
+ const params = {
530
+ parentNode: this,
531
+ parentKey,
532
+ index: -1,
533
+ object: null,
534
+ oldObject: bindAttribute,
535
+ };
536
+ if (parentKey) {
537
+ params.parentKey = parentKey;
538
+ if (Array.isArray(this[parentKey])) {
539
+ const index = this[parentKey].indexOf(bindAttribute);
540
+ ~index && this[parentKey].splice(index, 1);
541
+ params.index = index;
542
+ }
543
+ else if (this[parentKey] === bindAttribute) {
544
+ params.index = 0;
545
+ this[parentKey] = undefined;
546
+ }
547
+ }
548
+ return params;
549
+ }
550
+ removeBindEvent(options) {
551
+ let bindEvent;
552
+ if (typeof options === 'string') {
553
+ bindEvent = this.bindEvents.find((item) => item.name === options);
554
+ if (!bindEvent) {
555
+ throw new Error('找不到元素绑定事件 ' + options);
556
+ }
557
+ }
558
+ else {
559
+ bindEvent = options;
560
+ }
561
+ return bindEvent.delete();
562
+ }
563
+ __removeBindEvent(bindEvent) {
564
+ const parentKey = bindEvent.parentKey;
565
+ const params = {
566
+ parentNode: this,
567
+ parentKey,
568
+ index: -1,
569
+ object: null,
570
+ oldObject: bindEvent,
571
+ };
572
+ if (parentKey) {
573
+ params.parentKey = parentKey;
574
+ if (Array.isArray(this[parentKey])) {
575
+ const index = this[parentKey].indexOf(bindEvent);
576
+ ~index && this[parentKey].splice(index, 1);
577
+ params.index = index;
578
+ }
579
+ else if (this[parentKey] === bindEvent) {
580
+ params.index = 0;
581
+ this[parentKey] = undefined;
582
+ }
583
+ }
584
+ return params;
585
+ }
586
+ removeBindDirective(options) {
587
+ let bindDirective;
588
+ if (typeof options === 'string') {
589
+ bindDirective = this.bindDirectives.find((item) => item.name === options);
590
+ if (!bindDirective) {
591
+ throw new Error('找不到元素指令 ' + options);
592
+ }
593
+ }
594
+ else {
595
+ bindDirective = options;
596
+ }
597
+ return bindDirective.delete();
598
+ }
599
+ __removeBindDirective(bindDirective) {
600
+ const parentKey = bindDirective.parentKey;
601
+ const params = {
602
+ parentNode: this,
603
+ parentKey,
604
+ index: -1,
605
+ object: null,
606
+ oldObject: bindDirective,
607
+ };
608
+ if (parentKey) {
609
+ params.parentKey = parentKey;
610
+ if (Array.isArray(this[parentKey])) {
611
+ const index = this[parentKey].indexOf(bindDirective);
612
+ ~index && this[parentKey].splice(index, 1);
613
+ params.index = index;
614
+ }
615
+ else if (this[parentKey] === bindDirective) {
616
+ params.index = 0;
617
+ this[parentKey] = undefined;
618
+ }
619
+ }
620
+ return params;
621
+ }
622
+ removeViewElement(options) {
623
+ let viewElement;
624
+ if (typeof options === 'string') {
625
+ viewElement = this.children.find((item) => item.name === options);
626
+ if (!viewElement) {
627
+ throw new Error('找不到页面元素 ' + options);
628
+ }
629
+ }
630
+ else {
631
+ viewElement = options;
632
+ }
633
+ return viewElement.delete();
634
+ }
635
+ __removeViewElement(viewElement) {
636
+ const parentKey = viewElement.parentKey;
637
+ const params = {
638
+ parentNode: this,
639
+ parentKey,
640
+ index: -1,
641
+ object: null,
642
+ oldObject: viewElement,
643
+ };
644
+ if (parentKey) {
645
+ params.parentKey = parentKey;
646
+ if (Array.isArray(this[parentKey])) {
647
+ const index = this[parentKey].indexOf(viewElement);
648
+ ~index && this[parentKey].splice(index, 1);
649
+ params.index = index;
650
+ }
651
+ else if (this[parentKey] === viewElement) {
652
+ params.index = 0;
653
+ this[parentKey] = undefined;
654
+ }
655
+ }
656
+ return params;
657
+ }
658
+ //================================================================================
659
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
660
+ // 自动生成的代码已结束。下面可以手动编写。
661
+ //================================================================================
662
+ /* 主页面有没有权限 */
663
+ get parentAuth() {
664
+ const _nameSpace = this.view.getNamespace();
665
+ const mainViewName = _nameSpace.split('.')[2];
666
+ return this.view.parentNode.concept === 'App' ? this.view.auth : this.app.views.find((item) => item.name === mainViewName)?.auth;
667
+ }
668
+ /**
669
+ * 权限领域的资源路径
670
+ */
671
+ get authPath() {
672
+ return `${this.view.path}/${this.name}`;
673
+ }
674
+ getViewElementUniqueName(name = 'viewElement1') {
675
+ return this.view?.getViewElementUniqueName(name);
676
+ }
677
+ static TAG_NAME_PREFIX_REG = /^([lieu]|van)[-_]/;
678
+ static from(source, parentNode, parentKey) {
679
+ const node = super.from(source, parentNode, parentKey);
680
+ if (!node.name) {
681
+ const tagName = node.tag.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
682
+ node.name = node.getViewElementUniqueName(`${tagName}1`);
683
+ }
684
+ return node;
685
+ }
686
+ /**
687
+ * 设置组件权限
688
+ */
689
+ setBindRoles(bindRoles) {
690
+ const object = {
691
+ bindRoles,
692
+ };
693
+ this.update({
694
+ ...object,
695
+ });
696
+ }
697
+ getBindAttribute(name) {
698
+ return this.bindAttrs.find((bindAttr) => bindAttr.name === name);
699
+ }
700
+ toHump(name) {
701
+ return name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase());
702
+ }
703
+ haveScope(node) {
704
+ // uGallery 没有子集不需要scope
705
+ const dataSourcePcList = ['uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect', 'devopsDragTable', 'uTreeViewNew', 'uTreeSelectNew'];
706
+ const dataSourceH5List = ['vanRadioGroup', 'vanCheckboxGroup', 'vanListView', 'vanGridView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
707
+ const dataSourceList = [...dataSourcePcList, ...dataSourceH5List];
708
+ return dataSourceList.includes(node.toHump(node.tag));
709
+ }
710
+ toEmbeddedTSDefinition(state) {
711
+ // 登录组件不翻译
712
+ if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form')
713
+ return '';
714
+ let code = '';
715
+ // formItem的单独处理
716
+ if (this.tag === 'u-form-item') {
717
+ code = (0, translator_1.indent)((state?.tabSize || 0)) + `${this.name}: nasl.ui.${this.toHump(this.tag)}`;
718
+ if (Array.isArray(this.children) && this.children.length) {
719
+ const tag = this.children[0].tag;
720
+ if (tag === 'u-input') {
721
+ code += '<nasl.core.String>';
722
+ }
723
+ else if (tag === 'u-input-number') {
724
+ code += '<nasl.core.Integer>';
725
+ }
726
+ else {
727
+ code += '<nasl.core.Any>';
728
+ }
729
+ }
730
+ code += ';\n';
731
+ }
732
+ if (this.haveScope(this)) {
733
+ let genericType = 'any';
734
+ const bindAttrs = this.bindAttrs;
735
+ if (bindAttrs && bindAttrs.length) {
736
+ const attr = bindAttrs.find((item) => item.name === 'data-source');
737
+ if (attr && attr.expression) {
738
+ let expressionTs = attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code));
739
+ expressionTs = expressionTs.replaceAll(' ', '');
740
+ // 如果是逻辑就推导出逻辑类型
741
+ genericType = `nasl.ui.GetItemTypeFromDataSource<typeof ${expressionTs}>`;
742
+ // 如果是scope的类型,需要单独处理
743
+ if (expressionTs.startsWith('scope') && expressionTs.includes('.item.')) {
744
+ let parentNode = this.parentNode;
745
+ let haveScopeFlag = false;
746
+ while (!haveScopeFlag && parentNode.concept !== 'View') {
747
+ if (this.haveScope(parentNode)) {
748
+ // type d = nasl.ui.GetItemTypeFromDataSource<typeof listStructure>['tableRelation']
749
+ const tsArr = expressionTs.replace('scope.item.', '').split('.');
750
+ let itemStr = '';
751
+ tsArr.forEach((item) => {
752
+ itemStr += `['${item}']`;
753
+ });
754
+ const parentbindAttrs = parentNode.bindAttrs;
755
+ if (parentbindAttrs && parentbindAttrs.length) {
756
+ const parentAttr = parentbindAttrs.find((item) => item.name === 'data-source');
757
+ if (parentAttr && parentAttr.expression) {
758
+ let parentExpressionTs = parentAttr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code));
759
+ parentExpressionTs = parentExpressionTs.replaceAll(' ', '');
760
+ // 如果是逻辑就推导出逻辑类型
761
+ genericType = `nasl.ui.GetItemTypeFromDataSource<nasl.ui.GetItemTypeFromDataSource<typeof ${parentExpressionTs}>${itemStr}>`;
762
+ }
763
+ }
764
+ haveScopeFlag = true;
765
+ }
766
+ parentNode = parentNode.parentNode;
767
+ }
768
+ }
769
+ }
770
+ }
771
+ code += (0, translator_1.indent)((state?.tabSize || 0)) + `${this.name}: nasl.ui.${this.toHump(this.tag)}<${genericType}>;\n`;
772
+ }
773
+ else {
774
+ code = (0, translator_1.indent)((state?.tabSize || 0)) + `${this.name}: nasl.ui.${this.toHump(this.tag)}<any>;\n`;
775
+ }
776
+ if (Array.isArray(this.children)) {
777
+ this.children.forEach((element) => {
778
+ code += element.toEmbeddedTSDefinition((0, translator_1.shiftState)(state, code));
779
+ });
780
+ }
781
+ return code;
782
+ }
783
+ toEmbeddedTS(state, parentLevel) {
784
+ if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form')
785
+ return '';
786
+ function chineseTsName(name) {
787
+ let tsName = name;
788
+ // 匹配所有特殊字符都转为_
789
+ tsName = tsName.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '_');
790
+ if (/^\d/.test(tsName)) {
791
+ tsName = '$' + tsName;
792
+ }
793
+ return tsName;
794
+ }
795
+ let code = `__elements.${this.name} = new nasl.ui.${this.toHump(this.tag)}({\n`;
796
+ // 是否开启权限
797
+ let hasAuth = false;
798
+ if (Array.isArray(this.bindDirectives)) {
799
+ hasAuth = !!this.bindDirectives.filter((directive) => directive.name === 'auth').length;
800
+ }
801
+ // 角色
802
+ if (Array.isArray(this.bindRoles) && this.bindRoles.length) {
803
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
804
+ code += 'roles = [\n';
805
+ this.bindRoles.forEach((role) => {
806
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 3);
807
+ code += `${this.app.getNamespace()}.roles.${chineseTsName(role)}.${chineseTsName(role)},`;
808
+ code += '\n';
809
+ });
810
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
811
+ code += '],\n';
812
+ }
813
+ // 绑定属性
814
+ if (Array.isArray(this.bindAttrs)) {
815
+ this.bindAttrs.forEach((attr) => {
816
+ // 跳转页面
817
+ if (attr.destination) {
818
+ code += attr.destination.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
819
+ tabSize: (state?.tabSize || 0),
820
+ }));
821
+ }
822
+ });
823
+ code += '\n';
824
+ }
825
+ // 事件
826
+ if (Array.isArray(this.bindEvents)) {
827
+ this.bindEvents.forEach((event) => {
828
+ code += event.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
829
+ tabSize: (state?.tabSize || 0) + 2,
830
+ }));
831
+ code += '\n';
832
+ });
833
+ }
834
+ // 子元素
835
+ if (Array.isArray(this.children)) {
836
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
837
+ if (Array.isArray(this.bindAttrs)) {
838
+ code += `bindAttr: () => [\n`;
839
+ this.bindAttrs.forEach((attr) => {
840
+ if (attr.expression) {
841
+ code
842
+ += attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
843
+ tabSize: (state?.tabSize || 0) + 2,
844
+ })) + ',\n';
845
+ }
846
+ if (Array.isArray(attr.rules) && attr.rules.length) {
847
+ attr.rules.forEach((item) => {
848
+ code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code)) + ',\n';
849
+ });
850
+ }
851
+ });
852
+ this.bindDirectives.forEach((directive) => {
853
+ if (directive.expression) {
854
+ code
855
+ += directive.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
856
+ tabSize: (state?.tabSize || 0) + 2,
857
+ })) + ',\n';
858
+ }
859
+ });
860
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 2) + '],\n';
861
+ }
862
+ let levelIndex = parentLevel || 0;
863
+ if (this.haveScope(this)) {
864
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
865
+ // code += `slotDefault: (scope${levelIndex === 0 ? '' : levelIndex})=> [\n`;
866
+ code += `slotDefault: (scope)=> [\n`;
867
+ levelIndex++;
868
+ }
869
+ else {
870
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
871
+ code += `slotDefault: ()=> [\n`;
872
+ }
873
+ this.children.forEach((element) => {
874
+ code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
875
+ tabSize: (state?.tabSize || 0) + 2,
876
+ }), levelIndex);
877
+ code += '\n';
878
+ });
879
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
880
+ code += ']\n';
881
+ }
882
+ code += (0, translator_1.indent)((state?.tabSize || 0)) + '}),\n';
883
+ return code;
884
+ }
885
+ _duplicate() {
886
+ const element = ViewElement_1.from(this.toTemplateJSON());
887
+ element.deepRenameElements(this);
888
+ return element;
889
+ }
890
+ // 递归遍历组件
891
+ traverseChildren(cb) {
892
+ utils.traverse((current) => {
893
+ cb(current.node);
894
+ }, { node: this });
895
+ }
896
+ // 递归生成组件名
897
+ deepRenameElements(node) {
898
+ return this.traverseChildren((ele) => {
899
+ const tagName = ele.tag.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
900
+ ele.name = node.getViewElementUniqueName(`${tagName}1`);
901
+ });
902
+ }
903
+ /**
904
+ * 解析属性中的表达式
905
+ * @param value
906
+ * @param $def 目前 $def 只用来查找 $def.variables 和 $def.structures
907
+ * @param dataSchema
908
+ */
909
+ static _parseExpression(value) {
910
+ try {
911
+ const ast = babelParser.parseExpression(value);
912
+ const node = transAstNodeToNaslNode(ast);
913
+ return LogicItem__1.default.from(node, null, null);
914
+ }
915
+ catch (e) {
916
+ return null;
917
+ }
918
+ }
919
+ static _parseValidationRule(value) {
920
+ let calleeName = value;
921
+ let args = [];
922
+ try {
923
+ const ast = babelParser.parseExpression(value);
924
+ if (ast.type === 'CallExpression') {
925
+ calleeName = ast.callee.property.name || ast.callee.property.value;
926
+ args = ast.arguments.map((argument) => ({
927
+ concept: 'Argument',
928
+ name: '',
929
+ kind: 'Statement',
930
+ keyword: '',
931
+ expression: transAstNodeToNaslNode(Object.assign({}, argument)),
932
+ }));
933
+ }
934
+ }
935
+ catch (error) { }
936
+ return {
937
+ concept: 'ValidationRule',
938
+ name: '',
939
+ label: '验证规则',
940
+ kind: 'Expression',
941
+ calleeNamespace: 'nasl.validation',
942
+ arguments: args,
943
+ calleeName,
944
+ };
945
+ }
946
+ /**
947
+ * 从 Vue 的 ASTNode 转换成 ASL 元素
948
+ * @param astNode Vue 的 ASTNode
949
+ */
950
+ static _fromASTNode(astNode, context) {
951
+ const view = context?.view;
952
+ // 临时处理组件的 text
953
+ //h5-mock
954
+ if (['u-text', 'van-text', 'u-link', 'u-button', 'u-label', 'u-radio', 'u-checkbox', 'u-navbar-item', 'u-sidebar-item', 'u-menu-item'].includes(astNode.tag)
955
+ && astNode.children.length === 1
956
+ && astNode.children[0].type === 3) {
957
+ astNode.attrs = astNode.attrs || [];
958
+ astNode.attrs.push({
959
+ name: 'text',
960
+ value: JSON.stringify(astNode.children[0].text),
961
+ });
962
+ astNode.children = [];
963
+ }
964
+ // 将 scopedSlots 合并到 children 中
965
+ if (astNode.scopedSlots) {
966
+ astNode.children = astNode.children || [];
967
+ Object.keys(astNode.scopedSlots).forEach((key) => {
968
+ if (!astNode.children.find((child) => key === child.slotTarget)) {
969
+ astNode.children.unshift(astNode.scopedSlots[key]);
970
+ }
971
+ });
972
+ delete astNode.scopedSlots;
973
+ }
974
+ // 提示不支持的字段
975
+ ['component', 'inlineTemplate', 'pre', 'ns', 'transition', 'transitionOnAppear', 'transitionMode', 'slotName', 'classBinding', 'styleBinding'].forEach((key) => {
976
+ if (astNode[key])
977
+ console.warn(`[warn] ViewElement NASL unsupports '${key}' field in node `, astNode);
978
+ });
979
+ let element;
980
+ if (astNode.type === 1) {
981
+ if (astNode.tag === 'router-view') {
982
+ if (__1.config.scope === 'h5') {
983
+ astNode.tag = 'van-router-view';
984
+ }
985
+ else {
986
+ astNode.tag = 'u-router-view';
987
+ }
988
+ }
989
+ const tagName = astNode.tag.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
990
+ let newContext = {};
991
+ if (context) {
992
+ newContext = {
993
+ ...context,
994
+ };
995
+ }
996
+ element = new ViewElement_1({
997
+ tag: astNode.tag,
998
+ name: astNode.attrsMap.ref || view.getViewElementUniqueName(`${tagName}1`),
999
+ staticClass: astNode.attrsMap.class,
1000
+ staticStyle: astNode.attrsMap.style,
1001
+ slotTarget: astNode.slotTarget && json5.parse(astNode.slotTarget),
1002
+ slotScope: astNode.slotScope === '_empty_' ? '' : astNode.slotScope,
1003
+ children: astNode.children.map((item) => this._fromASTNode(item, newContext)),
1004
+ });
1005
+ astNode?.attrs?.forEach((oldAttr) => {
1006
+ let attr;
1007
+ if (oldAttr.value === '""' && oldAttr.end - oldAttr.start === oldAttr.name.length) {
1008
+ attr = new BindAttribute__1.default({
1009
+ type: 'static',
1010
+ name: oldAttr.name,
1011
+ value: 'true',
1012
+ });
1013
+ }
1014
+ else {
1015
+ try {
1016
+ const tmp = json5.parse(oldAttr.value);
1017
+ const source = {
1018
+ type: typeof tmp === 'string' ? 'string' : 'static',
1019
+ name: oldAttr.name,
1020
+ value: typeof tmp === 'string' ? tmp : oldAttr.value,
1021
+ };
1022
+ if (oldAttr.name === 'rules') {
1023
+ source.rules = tmp?.split('|').map((ruleStr) => this._parseValidationRule(ruleStr.trim()));
1024
+ }
1025
+ attr = new BindAttribute__1.default(source);
1026
+ }
1027
+ catch (e) {
1028
+ const expression = this._parseExpression(oldAttr.value);
1029
+ attr = new BindAttribute__1.default({
1030
+ type: 'dynamic',
1031
+ name: oldAttr.name,
1032
+ value: expression ? '' : oldAttr.value,
1033
+ expression,
1034
+ });
1035
+ if (astNode.attrsMap[`:${attr.name}.sync`]) {
1036
+ attr.sync = true;
1037
+ }
1038
+ }
1039
+ }
1040
+ element.addBindAttribute(attr);
1041
+ });
1042
+ // compiler 处理:value.sync 时会加上update:value事件,需要过滤
1043
+ astNode.events
1044
+ && Object.keys(astNode.events)
1045
+ .filter((name) => !name.startsWith('update:'))
1046
+ .forEach((name) => {
1047
+ const oldEvent = astNode.events[name];
1048
+ const str = oldEvent.value;
1049
+ const calleeName = str.split('(')[0];
1050
+ const matchArr = str.match(/\(([^)]*)\)/) || [];
1051
+ let argsStr = '';
1052
+ if (matchArr?.length >= 2) {
1053
+ argsStr = matchArr[1];
1054
+ }
1055
+ let args = [];
1056
+ const argStrs = argsStr.split(',');
1057
+ args = argStrs
1058
+ .filter((argStr) => !!argStr && argStr !== '_empty_')
1059
+ .map((argStr) => {
1060
+ const keyword = argStr.trim().split('.');
1061
+ return {
1062
+ concept: 'Argument',
1063
+ expression: genArgumentMemberExpression(keyword),
1064
+ };
1065
+ });
1066
+ const viewLogics = context?.definition?.viewLogics || [];
1067
+ const currentLogic = viewLogics.find((item) => item.name === calleeName);
1068
+ if (currentLogic) {
1069
+ element.addBindEvent(new BindEvent__1.default({
1070
+ name,
1071
+ calleeNamespace: '',
1072
+ calleeName: '',
1073
+ arguments: args,
1074
+ logics: [currentLogic],
1075
+ }));
1076
+ }
1077
+ });
1078
+ astNode.directives
1079
+ && astNode.directives.forEach((directive) => {
1080
+ if (directive.name === 'model') {
1081
+ const valueAttr = astNode.attrs && astNode.attrs.find((attr) => attr.name === 'value');
1082
+ if (!valueAttr) {
1083
+ const expression = this._parseExpression(directive.value);
1084
+ element.addBindAttribute(new BindAttribute__1.default({
1085
+ type: 'dynamic',
1086
+ name: 'value',
1087
+ value: expression ? '' : directive.value,
1088
+ expression,
1089
+ sync: true,
1090
+ }));
1091
+ }
1092
+ }
1093
+ else {
1094
+ const expression = this._parseExpression(directive.value);
1095
+ element.addBindDirective(new BindDirective__1.default({
1096
+ type: expression ? 'string' : 'dynamic',
1097
+ name: directive.name,
1098
+ rawName: directive.rawName,
1099
+ value: expression ? '' : directive.value,
1100
+ expression,
1101
+ arg: directive.arg,
1102
+ // modifiers: directive.modifiers,
1103
+ }));
1104
+ }
1105
+ });
1106
+ if (astNode.if) {
1107
+ element.addBindDirective(new BindDirective__1.default({
1108
+ type: 'dynamic',
1109
+ name: 'if',
1110
+ rawName: 'v-if',
1111
+ value: '',
1112
+ expression: this._parseExpression(astNode.if),
1113
+ }));
1114
+ }
1115
+ }
1116
+ else if (astNode.type === 2) {
1117
+ const tagName = __1.config.scope === 'h5' ? 'van-text' : 'u-text';
1118
+ const baseName = tagName.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1119
+ element = new ViewElement_1({
1120
+ tag: tagName,
1121
+ name: view.getViewElementUniqueName(`${baseName}1`),
1122
+ });
1123
+ const value = astNode.text?.match(/{{(.*?)}}/)[1].trim();
1124
+ const expression = this._parseExpression(value);
1125
+ element.addBindAttribute(new BindAttribute__1.default({
1126
+ type: 'dynamic',
1127
+ name: 'text',
1128
+ value: expression ? '' : value,
1129
+ expression,
1130
+ }));
1131
+ }
1132
+ else if (astNode.type === 3) {
1133
+ const tagName = __1.config.scope === 'h5' ? 'van-text' : 'u-text';
1134
+ const baseName = tagName.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
1135
+ element = new ViewElement_1({
1136
+ tag: tagName,
1137
+ name: view.getViewElementUniqueName(`${baseName}1`),
1138
+ });
1139
+ element.addBindAttribute(new BindAttribute__1.default({
1140
+ name: 'text',
1141
+ type: 'string',
1142
+ value: astNode.text?.trim(),
1143
+ }));
1144
+ }
1145
+ return element;
1146
+ }
1147
+ /**
1148
+ * 解析 Vue 模板
1149
+ * 该方法不会绑定 view 和 parent,如果是添加元素优先使用 fromHTML
1150
+ * @param html Vue 的模板
1151
+ * @TODO 处理多个元素的问题
1152
+ */
1153
+ static parse(html, context) {
1154
+ html = html || '<div></div>';
1155
+ const compilerOptions = {
1156
+ preserveWhitespace: false,
1157
+ outputSourceRange: true,
1158
+ };
1159
+ let ast = compiler.compile(html, compilerOptions).ast;
1160
+ if (ast.tag === 'template' && !ast.slotTarget)
1161
+ ast = ast.children[0];
1162
+ return this._fromASTNode(ast, context);
1163
+ }
1164
+ /**
1165
+ * 从模板生成规范的 ViewElement 对象
1166
+ */
1167
+ static fromHTML(html, context) {
1168
+ return this.parse(html, context);
1169
+ }
1170
+ /**
1171
+ * 转换成设计器中使用的 Vue 文件
1172
+ * @param options
1173
+ */
1174
+ toDesignerVue() {
1175
+ return this.toVue({
1176
+ finalCode: false,
1177
+ nodePathAttr: true,
1178
+ attrFormat: (attr, element, defaultResult) => {
1179
+ if (attr.concept === 'BindAttribute') {
1180
+ const api = __1.config.allNodesAPI[element.tag];
1181
+ const apiOfAttr = api && api.attrs && api.attrs.find((_attr) => _attr.name === attr.name);
1182
+ if (apiOfAttr && apiOfAttr['designer-value'] !== undefined) {
1183
+ let designerValue = apiOfAttr['designer-value'];
1184
+ //对流程模板拖拽进行特判
1185
+ element.bindAttrs.forEach((property) => {
1186
+ if (property.name === 'repeat' && property.value === '1')
1187
+ designerValue = '[{}, {}]';
1188
+ });
1189
+ if (typeof designerValue === 'string') {
1190
+ designerValue = designerValue.replace(/"/g, "'");
1191
+ }
1192
+ try {
1193
+ json5.parse(designerValue);
1194
+ return `:${attr.name}="${designerValue}"`;
1195
+ }
1196
+ catch (e) {
1197
+ return `${attr.name}="${designerValue}"`;
1198
+ }
1199
+ }
1200
+ if (attr.type === 'dynamic' && !(element.tag === 'u-cascade-select' && attr.name === 'categories'))
1201
+ return defaultResult.replace(/:?([\w-]+)(?:.*?)="(.*)"/, (m, name, value) => {
1202
+ try {
1203
+ const tempValue = json5.parse(value);
1204
+ if (typeof tempValue === 'boolean' || typeof tempValue === 'number') {
1205
+ // 简单类型走属性
1206
+ return `:${name}="${value.replace(/"/g, "'")}"`;
1207
+ }
1208
+ }
1209
+ catch (e) {
1210
+ if (apiOfAttr && !apiOfAttr.type.includes('string'))
1211
+ return '';
1212
+ }
1213
+ value = value
1214
+ .replace(/"/g, "'")
1215
+ .replace(/\$utils\['(.+?)'\]/g, '$1')
1216
+ .replace(/\$refs./g, 'elements.')
1217
+ .replace(/\$global./g, 'nasl.auth.');
1218
+ return `${name}="{{ ${value} }}"`;
1219
+ });
1220
+ else
1221
+ return defaultResult;
1222
+ }
1223
+ return false;
1224
+ },
1225
+ getExtraParts: (el) => {
1226
+ const parts = [];
1227
+ const api = __1.config.allNodesAPI[el.tag];
1228
+ const emptySlot = api && api.slots && api.slots.find((slot) => slot.name === 'default' && slot['empty-background']);
1229
+ const hasSupport = api && api.slots && api.slots.some((slot) => slot.support);
1230
+ if (emptySlot || hasSupport) {
1231
+ let childEmpty = !el.children.length;
1232
+ const defaultSlot = el.children.find((elem) => elem.tag === 'template' && elem.slotTarget === 'default');
1233
+ if (defaultSlot) {
1234
+ childEmpty = !defaultSlot.children.length;
1235
+ }
1236
+ if (childEmpty) {
1237
+ let addEmpty = true;
1238
+ if (el.tag === 'u-grid-view' || el.tag === 'u-list-view' || el.tag === 'van-list-view' || el.tag === 'van-grid-view') {
1239
+ const hasDataSource = el.bindAttrs.find((attr) => attr.name === 'data-source');
1240
+ addEmpty = !hasDataSource;
1241
+ }
1242
+ if (el.tag === 'u-crumb') {
1243
+ const attrList = el.bindAttrs;
1244
+ const hasAuto = attrList.some((attr) => attr.name === 'auto' && String(attr.value) === 'true');
1245
+ if (hasAuto)
1246
+ addEmpty = false;
1247
+ }
1248
+ if (['u-select', 'u-dropdown', 'u-panel', 'u-toc', 'u-toc-item', 'u-tree-view-new', 'u-tree-view-node-new', 'u-tree-select', 'u-tree-select-new', 'u-anchor'].includes(el.tag)) {
1249
+ addEmpty = false;
1250
+ }
1251
+ const background = (emptySlot && emptySlot['empty-background']) || (hasSupport ? 'add-sub' : '');
1252
+ addEmpty && parts.push(`vusion-empty-background="${background}"`);
1253
+ }
1254
+ }
1255
+ return parts;
1256
+ },
1257
+ });
1258
+ }
1259
+ /**
1260
+ * 转换成 Vue 的模板格式
1261
+ */
1262
+ toVue(options) {
1263
+ let scopeList = [];
1264
+ if (Array.isArray(options?.scopeList)) {
1265
+ scopeList = [...options?.scopeList];
1266
+ }
1267
+ if (this.slotScope) {
1268
+ scopeList.unshift(this.slotScope);
1269
+ }
1270
+ const newOptions = Object.assign({
1271
+ indentStyle: 'space',
1272
+ tabSize: 4,
1273
+ indentLevel: 0,
1274
+ aslIdAttr: false,
1275
+ nodePathAttr: false,
1276
+ getExtraParts: () => [],
1277
+ attrFormat: (attr, element, defaultResult) => defaultResult,
1278
+ }, options, {
1279
+ scopeList,
1280
+ });
1281
+ const tabString = ' '.repeat(newOptions.tabSize * newOptions.indentLevel);
1282
+ const insideTabString = ' '.repeat(newOptions.tabSize * (newOptions.indentLevel + 1));
1283
+ let shouldIndent = true;
1284
+ const content = !this.children ? '' : this.children
1285
+ .map((element) => {
1286
+ const childOptions = Object.assign({}, newOptions);
1287
+ childOptions.indentLevel++;
1288
+ return (shouldIndent ? '\n' + insideTabString : '') + element?.toVue(childOptions);
1289
+ })
1290
+ .join('');
1291
+ if (!content.length) {
1292
+ shouldIndent = false;
1293
+ }
1294
+ const parts = [];
1295
+ if (newOptions.aslIdAttr) {
1296
+ if (newOptions.aslIdAttr === true) {
1297
+ newOptions.aslIdAttr = 'asl-id';
1298
+ }
1299
+ parts.push(`${newOptions.aslIdAttr}="${this.id}"`);
1300
+ }
1301
+ if (newOptions.nodePathAttr) {
1302
+ // 注入 asl 的 node-path
1303
+ parts.push(`vusion-node-path="${this.nodePath}"`);
1304
+ }
1305
+ this.slotTarget && parts.push(`#${this.slotTarget}` + (this.slotScope ? `="${this.slotScope}"` : ''));
1306
+ this.name && parts.push(`ref="${this.name}"`);
1307
+ this.staticClass && parts.push(`class="${this.staticClass}"`);
1308
+ this.staticStyle && parts.push(`style="${this.staticStyle}"`);
1309
+ [].concat(this.bindAttrs, this.bindDirectives, this.bindEvents).forEach((attr) => {
1310
+ const result = newOptions.attrFormat(attr, this, attr?.toVue(newOptions));
1311
+ result && parts.push(result);
1312
+ });
1313
+ newOptions.getExtraParts(this).forEach((part) => parts.push(part));
1314
+ let partsLength = 0;
1315
+ let partsString = '';
1316
+ parts.forEach((part) => {
1317
+ if (partsLength >= 120 || part.length >= 120) {
1318
+ partsString += '\n' + tabString + ' '.repeat(3); // ' '.repeat(el.tag.length + 1);
1319
+ partsLength = 0;
1320
+ }
1321
+ partsString += ' ' + part;
1322
+ partsLength += part.length;
1323
+ });
1324
+ return `<${this.tag}${partsString.length ? partsString : ''}>` + content + (shouldIndent ? '\n' + tabString : '') + `</${this.tag}>`;
1325
+ }
1326
+ /**
1327
+ * 从父级删除该节点
1328
+ * @internal
1329
+ */
1330
+ delete() {
1331
+ super.delete();
1332
+ if (this.parentNode) {
1333
+ this.traverseChildren((ele) => {
1334
+ this.view?.removeExistingViewElement(ele);
1335
+ });
1336
+ }
1337
+ }
1338
+ findElementByName(name) {
1339
+ return utils.traverse((current) => {
1340
+ if (current.node.name === name)
1341
+ return current.node;
1342
+ }, { node: this });
1343
+ }
1344
+ findElementByTag(tag) {
1345
+ return utils.traverse((current) => {
1346
+ if (current.node.tag === tag)
1347
+ return current.node;
1348
+ }, { node: this });
1349
+ }
1350
+ findElementByAttr(name, value) {
1351
+ return utils.traverse((current) => {
1352
+ if (current.node.bindAttrs.some((attr) => attr.name === name && attr.value === value))
1353
+ return current.node;
1354
+ }, { node: this });
1355
+ }
1356
+ computedStyle = {};
1357
+ };
1358
+ __decorate([
1359
+ (0, decorators_1.property)()
1360
+ ], ViewElement.prototype, "concept", void 0);
1361
+ __decorate([
1362
+ (0, decorators_1.property)()
1363
+ ], ViewElement.prototype, "type", void 0);
1364
+ __decorate([
1365
+ (0, decorators_1.property)()
1366
+ ], ViewElement.prototype, "tag", void 0);
1367
+ __decorate([
1368
+ (0, decorators_1.property)()
1369
+ ], ViewElement.prototype, "name", void 0);
1370
+ __decorate([
1371
+ (0, decorators_1.property)()
1372
+ ], ViewElement.prototype, "staticClass", void 0);
1373
+ __decorate([
1374
+ (0, decorators_1.property)()
1375
+ ], ViewElement.prototype, "staticStyle", void 0);
1376
+ __decorate([
1377
+ (0, decorators_1.property)()
1378
+ ], ViewElement.prototype, "slotTarget", void 0);
1379
+ __decorate([
1380
+ (0, decorators_1.property)()
1381
+ ], ViewElement.prototype, "slotScope", void 0);
1382
+ __decorate([
1383
+ (0, decorators_1.property)('BindAttribute')
1384
+ ], ViewElement.prototype, "bindAttrs", void 0);
1385
+ __decorate([
1386
+ (0, decorators_1.property)('BindEvent')
1387
+ ], ViewElement.prototype, "bindEvents", void 0);
1388
+ __decorate([
1389
+ (0, decorators_1.property)('BindDirective')
1390
+ ], ViewElement.prototype, "bindDirectives", void 0);
1391
+ __decorate([
1392
+ (0, decorators_1.property)()
1393
+ ], ViewElement.prototype, "bindRoles", void 0);
1394
+ __decorate([
1395
+ (0, decorators_1.property)('ViewElement')
1396
+ ], ViewElement.prototype, "children", void 0);
1397
+ __decorate([
1398
+ (0, translator_1.withSourceMap)()
1399
+ ], ViewElement.prototype, "toEmbeddedTS", null);
1400
+ __decorate([
1401
+ (0, decorators_1.excludedInJSON)()
1402
+ ], ViewElement.prototype, "computedStyle", void 0);
1403
+ ViewElement = ViewElement_1 = __decorate([
1404
+ (0, decorators_1.concept)('页面元素')
1405
+ ], ViewElement);
1406
+ exports.ViewElement = ViewElement;
1407
+ classMap_1.default.ViewElement = ViewElement;
1408
+ exports.default = ViewElement;
1409
+ //================================================================================
1410
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1411
+ // 自动生成的代码已结束。下面可以手动编写。
1412
+ //================================================================================
1413
+ //# sourceMappingURL=ViewElement__.js.map