@lcap/nasl 3.5.0-beta.1 → 3.5.0-beta.2

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 (768) hide show
  1. package/out/automate/engine/uniqueName.js +7 -3
  2. package/out/automate/engine/uniqueName.js.map +1 -1
  3. package/out/bak/translator.js +119 -39
  4. package/out/bak/translator.js.map +1 -1
  5. package/out/breakpoint/generator/AfterStartNode.js +1 -1
  6. package/out/breakpoint/generator/AfterStartNode.js.map +1 -1
  7. package/out/breakpoint/generator/BeforeEndNode.js +1 -1
  8. package/out/breakpoint/generator/BeforeEndNode.js.map +1 -1
  9. package/out/breakpoint/generator/BreakpointNode.d.ts +3 -0
  10. package/out/breakpoint/generator/BreakpointNode.js +12 -3
  11. package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
  12. package/out/breakpoint/generator/CallbackNode.js +15 -0
  13. package/out/breakpoint/generator/CallbackNode.js.map +1 -1
  14. package/out/breakpoint/shared/constants.js +1 -1
  15. package/out/breakpoint/shared/constants.js.map +1 -1
  16. package/out/breakpoint/shared/utils.js +12 -6
  17. package/out/breakpoint/shared/utils.js.map +1 -1
  18. package/out/common/BaseNode.d.ts +17 -12
  19. package/out/common/BaseNode.js +64 -174
  20. package/out/common/BaseNode.js.map +1 -1
  21. package/out/common/Command.js +0 -1
  22. package/out/common/Command.js.map +1 -1
  23. package/out/common/EventEmitter.js +4 -2
  24. package/out/common/EventEmitter.js.map +1 -1
  25. package/out/common/Messager.js +0 -2
  26. package/out/common/Messager.js.map +1 -1
  27. package/out/common/utils.d.ts +2 -2
  28. package/out/common/utils.js.map +1 -1
  29. package/out/concepts/Abort__.d.ts +1 -1
  30. package/out/concepts/Abort__.js +9 -16
  31. package/out/concepts/Abort__.js.map +1 -1
  32. package/out/concepts/AbstractInterface__.d.ts +1 -1
  33. package/out/concepts/AbstractInterface__.js +5 -8
  34. package/out/concepts/AbstractInterface__.js.map +1 -1
  35. package/out/concepts/Anchor__.d.ts +1 -1
  36. package/out/concepts/Anchor__.js +5 -17
  37. package/out/concepts/Anchor__.js.map +1 -1
  38. package/out/concepts/AnonymousFunction__.d.ts +1 -1
  39. package/out/concepts/AnonymousFunction__.js +22 -44
  40. package/out/concepts/AnonymousFunction__.js.map +1 -1
  41. package/out/concepts/App__.d.ts +51 -51
  42. package/out/concepts/App__.js +220 -278
  43. package/out/concepts/App__.js.map +1 -1
  44. package/out/concepts/Argument__.d.ts +1 -1
  45. package/out/concepts/Argument__.js +11 -33
  46. package/out/concepts/Argument__.js.map +1 -1
  47. package/out/concepts/Assignee__.d.ts +1 -1
  48. package/out/concepts/Assignee__.js +29 -36
  49. package/out/concepts/Assignee__.js.map +1 -1
  50. package/out/concepts/AssignmentLine__.d.ts +1 -1
  51. package/out/concepts/AssignmentLine__.js +13 -20
  52. package/out/concepts/AssignmentLine__.js.map +1 -1
  53. package/out/concepts/Assignment__.d.ts +1 -1
  54. package/out/concepts/Assignment__.js +12 -29
  55. package/out/concepts/Assignment__.js.map +1 -1
  56. package/out/concepts/Attribute__.d.ts +1 -1
  57. package/out/concepts/Attribute__.js +16 -73
  58. package/out/concepts/Attribute__.js.map +1 -1
  59. package/out/concepts/AuthInterface__.d.ts +1 -1
  60. package/out/concepts/AuthInterface__.js +11 -23
  61. package/out/concepts/AuthInterface__.js.map +1 -1
  62. package/out/concepts/AuthLogicForCallInterface__.d.ts +1 -1
  63. package/out/concepts/AuthLogicForCallInterface__.js +20 -26
  64. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
  65. package/out/concepts/AuthLogic__.d.ts +1 -1
  66. package/out/concepts/AuthLogic__.js +11 -23
  67. package/out/concepts/AuthLogic__.js.map +1 -1
  68. package/out/concepts/BackendVariable__.d.ts +1 -1
  69. package/out/concepts/BackendVariable__.js +29 -53
  70. package/out/concepts/BackendVariable__.js.map +1 -1
  71. package/out/concepts/Backend__.d.ts +1 -1
  72. package/out/concepts/Backend__.js +17 -29
  73. package/out/concepts/Backend__.js.map +1 -1
  74. package/out/concepts/BatchAssignment__.d.ts +1 -1
  75. package/out/concepts/BatchAssignment__.js +24 -36
  76. package/out/concepts/BatchAssignment__.js.map +1 -1
  77. package/out/concepts/BinaryExpression__.d.ts +3 -1
  78. package/out/concepts/BinaryExpression__.js +9 -27
  79. package/out/concepts/BinaryExpression__.js.map +1 -1
  80. package/out/concepts/BindAttribute__.d.ts +1 -1
  81. package/out/concepts/BindAttribute__.js +39 -86
  82. package/out/concepts/BindAttribute__.js.map +1 -1
  83. package/out/concepts/BindDirective__.d.ts +2 -1
  84. package/out/concepts/BindDirective__.js +36 -68
  85. package/out/concepts/BindDirective__.js.map +1 -1
  86. package/out/concepts/BindEvent__.d.ts +4 -2
  87. package/out/concepts/BindEvent__.js +69 -66
  88. package/out/concepts/BindEvent__.js.map +1 -1
  89. package/out/concepts/BindStyle__.d.ts +1 -1
  90. package/out/concepts/BindStyle__.js +17 -34
  91. package/out/concepts/BindStyle__.js.map +1 -1
  92. package/out/concepts/Block__.d.ts +1 -1
  93. package/out/concepts/Block__.js +11 -18
  94. package/out/concepts/Block__.js.map +1 -1
  95. package/out/concepts/BooleanLiteral__.d.ts +1 -1
  96. package/out/concepts/BooleanLiteral__.js +5 -17
  97. package/out/concepts/BooleanLiteral__.js.map +1 -1
  98. package/out/concepts/BusinessComponent__.d.ts +637 -0
  99. package/out/concepts/BusinessComponent__.js +1892 -0
  100. package/out/concepts/BusinessComponent__.js.map +1 -0
  101. package/out/concepts/BusinessLogic__.d.ts +38 -0
  102. package/out/concepts/BusinessLogic__.js +358 -0
  103. package/out/concepts/BusinessLogic__.js.map +1 -0
  104. package/out/concepts/CallAuthInterface__.d.ts +3 -3
  105. package/out/concepts/CallAuthInterface__.js +12 -19
  106. package/out/concepts/CallAuthInterface__.js.map +1 -1
  107. package/out/concepts/CallConnector__.d.ts +1 -1
  108. package/out/concepts/CallConnector__.js +9 -21
  109. package/out/concepts/CallConnector__.js.map +1 -1
  110. package/out/concepts/CallEvent__.d.ts +97 -0
  111. package/out/concepts/CallEvent__.js +263 -0
  112. package/out/concepts/CallEvent__.js.map +1 -0
  113. package/out/concepts/CallFunction__.d.ts +3 -1
  114. package/out/concepts/CallFunction__.js +37 -47
  115. package/out/concepts/CallFunction__.js.map +1 -1
  116. package/out/concepts/CallInterface__.d.ts +5 -3
  117. package/out/concepts/CallInterface__.js +31 -49
  118. package/out/concepts/CallInterface__.js.map +1 -1
  119. package/out/concepts/CallLogic__.d.ts +6 -3
  120. package/out/concepts/CallLogic__.js +69 -113
  121. package/out/concepts/CallLogic__.js.map +1 -1
  122. package/out/concepts/CallQueryComponent__.d.ts +1 -1
  123. package/out/concepts/CallQueryComponent__.js +128 -112
  124. package/out/concepts/CallQueryComponent__.js.map +1 -1
  125. package/out/concepts/Comment__.d.ts +1 -1
  126. package/out/concepts/Comment__.js +5 -17
  127. package/out/concepts/Comment__.js.map +1 -1
  128. package/out/concepts/CompletionProperty__.d.ts +1 -1
  129. package/out/concepts/CompletionProperty__.js +18 -61
  130. package/out/concepts/CompletionProperty__.js.map +1 -1
  131. package/out/concepts/ConfigGroup__.d.ts +1 -1
  132. package/out/concepts/ConfigGroup__.js +17 -29
  133. package/out/concepts/ConfigGroup__.js.map +1 -1
  134. package/out/concepts/ConfigPropertyValue__.d.ts +1 -1
  135. package/out/concepts/ConfigPropertyValue__.js +11 -28
  136. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  137. package/out/concepts/ConfigProperty__.d.ts +1 -1
  138. package/out/concepts/ConfigProperty__.js +17 -39
  139. package/out/concepts/ConfigProperty__.js.map +1 -1
  140. package/out/concepts/Configuration__.d.ts +1 -1
  141. package/out/concepts/Configuration__.js +17 -24
  142. package/out/concepts/Configuration__.js.map +1 -1
  143. package/out/concepts/Connection__.d.ts +1 -1
  144. package/out/concepts/Connection__.js +17 -39
  145. package/out/concepts/Connection__.js.map +1 -1
  146. package/out/concepts/ConnectorTrigger__.d.ts +1 -1
  147. package/out/concepts/ConnectorTrigger__.js +11 -33
  148. package/out/concepts/ConnectorTrigger__.js.map +1 -1
  149. package/out/concepts/Connector__.d.ts +1 -1
  150. package/out/concepts/Connector__.js +59 -96
  151. package/out/concepts/Connector__.js.map +1 -1
  152. package/out/concepts/Constant__.d.ts +1 -1
  153. package/out/concepts/Constant__.js +18 -44
  154. package/out/concepts/Constant__.js.map +1 -1
  155. package/out/concepts/CountersignPolicy__.d.ts +1 -1
  156. package/out/concepts/CountersignPolicy__.js +5 -17
  157. package/out/concepts/CountersignPolicy__.js.map +1 -1
  158. package/out/concepts/DataSource__.d.ts +1 -1
  159. package/out/concepts/DataSource__.js +18 -40
  160. package/out/concepts/DataSource__.js.map +1 -1
  161. package/out/concepts/DatabaseTypeAnnotation__.d.ts +1 -1
  162. package/out/concepts/DatabaseTypeAnnotation__.js +5 -22
  163. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
  164. package/out/concepts/DefaultValue__.d.ts +1 -1
  165. package/out/concepts/DefaultValue__.js +13 -24
  166. package/out/concepts/DefaultValue__.js.map +1 -1
  167. package/out/concepts/Destination__.d.ts +1 -1
  168. package/out/concepts/Destination__.js +23 -45
  169. package/out/concepts/Destination__.js.map +1 -1
  170. package/out/concepts/End__.d.ts +1 -1
  171. package/out/concepts/End__.js +11 -17
  172. package/out/concepts/End__.js.map +1 -1
  173. package/out/concepts/EntityIndex__.d.ts +1 -1
  174. package/out/concepts/EntityIndex__.js +15 -42
  175. package/out/concepts/EntityIndex__.js.map +1 -1
  176. package/out/concepts/EntityProperty__.d.ts +1 -1
  177. package/out/concepts/EntityProperty__.js +41 -118
  178. package/out/concepts/EntityProperty__.js.map +1 -1
  179. package/out/concepts/Entity__.d.ts +1 -6
  180. package/out/concepts/Entity__.js +34 -70
  181. package/out/concepts/Entity__.js.map +1 -1
  182. package/out/concepts/EnumItem__.d.ts +1 -1
  183. package/out/concepts/EnumItem__.js +11 -36
  184. package/out/concepts/EnumItem__.js.map +1 -1
  185. package/out/concepts/Enum__.d.ts +1 -1
  186. package/out/concepts/Enum__.js +21 -52
  187. package/out/concepts/Enum__.js.map +1 -1
  188. package/out/concepts/Event__.d.ts +11 -1
  189. package/out/concepts/Event__.js +66 -49
  190. package/out/concepts/Event__.js.map +1 -1
  191. package/out/concepts/ExternalDestination__.d.ts +1 -1
  192. package/out/concepts/ExternalDestination__.js +14 -31
  193. package/out/concepts/ExternalDestination__.js.map +1 -1
  194. package/out/concepts/ForEachStatement__.d.ts +1 -1
  195. package/out/concepts/ForEachStatement__.js +12 -44
  196. package/out/concepts/ForEachStatement__.js.map +1 -1
  197. package/out/concepts/FrontendLibrary__.d.ts +1 -1
  198. package/out/concepts/FrontendLibrary__.js +22 -39
  199. package/out/concepts/FrontendLibrary__.js.map +1 -1
  200. package/out/concepts/FrontendType__.d.ts +308 -0
  201. package/out/concepts/FrontendType__.js +605 -0
  202. package/out/concepts/FrontendType__.js.map +1 -0
  203. package/out/concepts/FrontendVariable__.d.ts +7 -3
  204. package/out/concepts/FrontendVariable__.js +20 -20
  205. package/out/concepts/FrontendVariable__.js.map +1 -1
  206. package/out/concepts/Frontend__.d.ts +1 -89
  207. package/out/concepts/Frontend__.js +40 -224
  208. package/out/concepts/Frontend__.js.map +1 -1
  209. package/out/concepts/Function__.d.ts +1 -1
  210. package/out/concepts/Function__.js +32 -54
  211. package/out/concepts/Function__.js.map +1 -1
  212. package/out/concepts/I18nInfo__.d.ts +1 -1
  213. package/out/concepts/I18nInfo__.js +5 -27
  214. package/out/concepts/I18nInfo__.js.map +1 -1
  215. package/out/concepts/Identifier__.d.ts +6 -1
  216. package/out/concepts/Identifier__.js +38 -45
  217. package/out/concepts/Identifier__.js.map +1 -1
  218. package/out/concepts/IfStatement__.d.ts +1 -1
  219. package/out/concepts/IfStatement__.js +16 -28
  220. package/out/concepts/IfStatement__.js.map +1 -1
  221. package/out/concepts/ImportedInterface__.d.ts +1 -1
  222. package/out/concepts/ImportedInterface__.js +5 -13
  223. package/out/concepts/ImportedInterface__.js.map +1 -1
  224. package/out/concepts/Integration__.d.ts +1 -1
  225. package/out/concepts/Integration__.js +17 -29
  226. package/out/concepts/Integration__.js.map +1 -1
  227. package/out/concepts/InterfaceParam__.d.ts +1 -1
  228. package/out/concepts/InterfaceParam__.js +11 -48
  229. package/out/concepts/InterfaceParam__.js.map +1 -1
  230. package/out/concepts/Interface__.d.ts +3 -3
  231. package/out/concepts/Interface__.js +35 -72
  232. package/out/concepts/Interface__.js.map +1 -1
  233. package/out/concepts/JSBlock__.d.ts +1 -1
  234. package/out/concepts/JSBlock__.js +9 -21
  235. package/out/concepts/JSBlock__.js.map +1 -1
  236. package/out/concepts/JavaLogic__.d.ts +1 -1
  237. package/out/concepts/JavaLogic__.js +5 -27
  238. package/out/concepts/JavaLogic__.js.map +1 -1
  239. package/out/concepts/LogicItem__.d.ts +2 -2
  240. package/out/concepts/LogicItem__.js +15 -42
  241. package/out/concepts/LogicItem__.js.map +1 -1
  242. package/out/concepts/Logic__.d.ts +6 -4
  243. package/out/concepts/Logic__.js +83 -122
  244. package/out/concepts/Logic__.js.map +1 -1
  245. package/out/concepts/MatchCase__.d.ts +1 -1
  246. package/out/concepts/MatchCase__.js +26 -33
  247. package/out/concepts/MatchCase__.js.map +1 -1
  248. package/out/concepts/Match__.d.ts +1 -1
  249. package/out/concepts/Match__.js +20 -37
  250. package/out/concepts/Match__.js.map +1 -1
  251. package/out/concepts/MemberExpression__.d.ts +2 -2
  252. package/out/concepts/MemberExpression__.js +28 -45
  253. package/out/concepts/MemberExpression__.js.map +1 -1
  254. package/out/concepts/MetadataType__.d.ts +1 -1
  255. package/out/concepts/MetadataType__.js +30 -52
  256. package/out/concepts/MetadataType__.js.map +1 -1
  257. package/out/concepts/MicroApp__.d.ts +1 -1
  258. package/out/concepts/MicroApp__.js +5 -47
  259. package/out/concepts/MicroApp__.js.map +1 -1
  260. package/out/concepts/Module__.d.ts +1 -1
  261. package/out/concepts/Module__.js +76 -140
  262. package/out/concepts/Module__.js.map +1 -1
  263. package/out/concepts/MsgTriggerEvent__.d.ts +1 -1
  264. package/out/concepts/MsgTriggerEvent__.js +17 -24
  265. package/out/concepts/MsgTriggerEvent__.js.map +1 -1
  266. package/out/concepts/MsgTriggerLauncher__.d.ts +1 -1
  267. package/out/concepts/MsgTriggerLauncher__.js +17 -29
  268. package/out/concepts/MsgTriggerLauncher__.js.map +1 -1
  269. package/out/concepts/MultiApprovalPolicy__.d.ts +1 -1
  270. package/out/concepts/MultiApprovalPolicy__.js +5 -12
  271. package/out/concepts/MultiApprovalPolicy__.js.map +1 -1
  272. package/out/concepts/Namespace__.d.ts +1 -1
  273. package/out/concepts/Namespace__.js +67 -94
  274. package/out/concepts/Namespace__.js.map +1 -1
  275. package/out/concepts/NewComposite__.d.ts +3 -1
  276. package/out/concepts/NewComposite__.js +37 -45
  277. package/out/concepts/NewComposite__.js.map +1 -1
  278. package/out/concepts/NewList__.d.ts +3 -1
  279. package/out/concepts/NewList__.js +16 -24
  280. package/out/concepts/NewList__.js.map +1 -1
  281. package/out/concepts/NewMap__.d.ts +3 -1
  282. package/out/concepts/NewMap__.js +20 -28
  283. package/out/concepts/NewMap__.js.map +1 -1
  284. package/out/concepts/New__.d.ts +1 -1
  285. package/out/concepts/New__.js +5 -12
  286. package/out/concepts/New__.js.map +1 -1
  287. package/out/concepts/NullLiteral__.d.ts +1 -1
  288. package/out/concepts/NullLiteral__.js +5 -12
  289. package/out/concepts/NullLiteral__.js.map +1 -1
  290. package/out/concepts/NumericLiteral__.d.ts +1 -1
  291. package/out/concepts/NumericLiteral__.js +5 -22
  292. package/out/concepts/NumericLiteral__.js.map +1 -1
  293. package/out/concepts/OqlQueryComponent__.d.ts +1 -1
  294. package/out/concepts/OqlQueryComponent__.js +12 -34
  295. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  296. package/out/concepts/OverriddenLogic__.d.ts +1 -1
  297. package/out/concepts/OverriddenLogic__.js +67 -103
  298. package/out/concepts/OverriddenLogic__.js.map +1 -1
  299. package/out/concepts/ParamWithGroup__.d.ts +39 -0
  300. package/out/concepts/ParamWithGroup__.js +85 -0
  301. package/out/concepts/ParamWithGroup__.js.map +1 -0
  302. package/out/concepts/Param__.d.ts +1 -1
  303. package/out/concepts/Param__.js +38 -62
  304. package/out/concepts/Param__.js.map +1 -1
  305. package/out/concepts/Point__.d.ts +1 -1
  306. package/out/concepts/Point__.js +5 -22
  307. package/out/concepts/Point__.js.map +1 -1
  308. package/out/concepts/ProcessComponent__.d.ts +1 -1
  309. package/out/concepts/ProcessComponent__.js +22 -49
  310. package/out/concepts/ProcessComponent__.js.map +1 -1
  311. package/out/concepts/ProcessElement__.d.ts +1 -1
  312. package/out/concepts/ProcessElement__.js +42 -99
  313. package/out/concepts/ProcessElement__.js.map +1 -1
  314. package/out/concepts/ProcessOutcome__.d.ts +1 -1
  315. package/out/concepts/ProcessOutcome__.js +9 -21
  316. package/out/concepts/ProcessOutcome__.js.map +1 -1
  317. package/out/concepts/ProcessOutcomes__.d.ts +1 -1
  318. package/out/concepts/ProcessOutcomes__.js +13 -20
  319. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  320. package/out/concepts/Process__.d.ts +1 -1
  321. package/out/concepts/Process__.js +42 -64
  322. package/out/concepts/Process__.js.map +1 -1
  323. package/out/concepts/QueryAggregateExpression__.d.ts +1 -1
  324. package/out/concepts/QueryAggregateExpression__.js +5 -27
  325. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  326. package/out/concepts/QueryFieldExpression__.d.ts +1 -1
  327. package/out/concepts/QueryFieldExpression__.js +9 -31
  328. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  329. package/out/concepts/QueryFromExpression__.d.ts +1 -1
  330. package/out/concepts/QueryFromExpression__.js +11 -33
  331. package/out/concepts/QueryFromExpression__.js.map +1 -1
  332. package/out/concepts/QueryGroupByExpression__.d.ts +1 -1
  333. package/out/concepts/QueryGroupByExpression__.js +5 -17
  334. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  335. package/out/concepts/QueryJoinExpression__.d.ts +1 -1
  336. package/out/concepts/QueryJoinExpression__.js +16 -43
  337. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  338. package/out/concepts/QueryLimitExpression__.d.ts +1 -1
  339. package/out/concepts/QueryLimitExpression__.js +5 -22
  340. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  341. package/out/concepts/QueryOrderByExpression__.d.ts +1 -1
  342. package/out/concepts/QueryOrderByExpression__.js +5 -22
  343. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  344. package/out/concepts/QuerySelectExpression__.d.ts +1 -1
  345. package/out/concepts/QuerySelectExpression__.js +20 -27
  346. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  347. package/out/concepts/Rect__.d.ts +1 -1
  348. package/out/concepts/Rect__.js +5 -32
  349. package/out/concepts/Rect__.js.map +1 -1
  350. package/out/concepts/Return__.d.ts +1 -1
  351. package/out/concepts/Return__.js +38 -57
  352. package/out/concepts/Return__.js.map +1 -1
  353. package/out/concepts/Role__.d.ts +1 -1
  354. package/out/concepts/Role__.js +15 -37
  355. package/out/concepts/Role__.js.map +1 -1
  356. package/out/concepts/SelectMembers__.d.ts +1 -1
  357. package/out/concepts/SelectMembers__.js +15 -27
  358. package/out/concepts/SelectMembers__.js.map +1 -1
  359. package/out/concepts/SequentialPolicy__.d.ts +1 -1
  360. package/out/concepts/SequentialPolicy__.js +5 -12
  361. package/out/concepts/SequentialPolicy__.js.map +1 -1
  362. package/out/concepts/Slot__.d.ts +1 -1
  363. package/out/concepts/Slot__.js +11 -48
  364. package/out/concepts/Slot__.js.map +1 -1
  365. package/out/concepts/SqlQueryComponent__.d.ts +1 -1
  366. package/out/concepts/SqlQueryComponent__.js +10 -37
  367. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  368. package/out/concepts/Start__.d.ts +1 -1
  369. package/out/concepts/Start__.js +9 -16
  370. package/out/concepts/Start__.js.map +1 -1
  371. package/out/concepts/StaticString__.d.ts +1 -1
  372. package/out/concepts/StaticString__.js +9 -21
  373. package/out/concepts/StaticString__.js.map +1 -1
  374. package/out/concepts/StringInterpolation__.d.ts +1 -1
  375. package/out/concepts/StringInterpolation__.js +11 -18
  376. package/out/concepts/StringInterpolation__.js.map +1 -1
  377. package/out/concepts/StringLiteral__.d.ts +1 -1
  378. package/out/concepts/StringLiteral__.js +9 -21
  379. package/out/concepts/StringLiteral__.js.map +1 -1
  380. package/out/concepts/StructureProperty__.d.ts +1 -1
  381. package/out/concepts/StructureProperty__.js +23 -65
  382. package/out/concepts/StructureProperty__.js.map +1 -1
  383. package/out/concepts/Structure__.d.ts +3 -3
  384. package/out/concepts/Structure__.js +22 -44
  385. package/out/concepts/Structure__.js.map +1 -1
  386. package/out/concepts/SwitchCase__.d.ts +1 -1
  387. package/out/concepts/SwitchCase__.js +11 -23
  388. package/out/concepts/SwitchCase__.js.map +1 -1
  389. package/out/concepts/SwitchStatement__.d.ts +1 -1
  390. package/out/concepts/SwitchStatement__.js +11 -18
  391. package/out/concepts/SwitchStatement__.js.map +1 -1
  392. package/out/concepts/Theme__.d.ts +1 -1
  393. package/out/concepts/Theme__.js +13 -20
  394. package/out/concepts/Theme__.js.map +1 -1
  395. package/out/concepts/Transactional__.d.ts +1 -1
  396. package/out/concepts/Transactional__.js +11 -33
  397. package/out/concepts/Transactional__.js.map +1 -1
  398. package/out/concepts/TriggerEvent__.d.ts +1 -1
  399. package/out/concepts/TriggerEvent__.js +5 -22
  400. package/out/concepts/TriggerEvent__.js.map +1 -1
  401. package/out/concepts/TriggerLauncher__.d.ts +1 -1
  402. package/out/concepts/TriggerLauncher__.js +11 -38
  403. package/out/concepts/TriggerLauncher__.js.map +1 -1
  404. package/out/concepts/TypeAnnotation__.d.ts +4 -4
  405. package/out/concepts/TypeAnnotation__.js +28 -60
  406. package/out/concepts/TypeAnnotation__.js.map +1 -1
  407. package/out/concepts/TypeParam__.d.ts +1 -1
  408. package/out/concepts/TypeParam__.js +11 -23
  409. package/out/concepts/TypeParam__.js.map +1 -1
  410. package/out/concepts/UnaryExpression__.d.ts +1 -1
  411. package/out/concepts/UnaryExpression__.js +5 -22
  412. package/out/concepts/UnaryExpression__.js.map +1 -1
  413. package/out/concepts/Unparsed__.d.ts +1 -1
  414. package/out/concepts/Unparsed__.js +5 -17
  415. package/out/concepts/Unparsed__.js.map +1 -1
  416. package/out/concepts/UseComponent__.d.ts +1 -1
  417. package/out/concepts/UseComponent__.js +5 -22
  418. package/out/concepts/UseComponent__.js.map +1 -1
  419. package/out/concepts/ValidationRule__.d.ts +1 -1
  420. package/out/concepts/ValidationRule__.js +19 -46
  421. package/out/concepts/ValidationRule__.js.map +1 -1
  422. package/out/concepts/Variable__.d.ts +2 -2
  423. package/out/concepts/Variable__.js +37 -55
  424. package/out/concepts/Variable__.js.map +1 -1
  425. package/out/concepts/ViewBlock__.d.ts +1 -1
  426. package/out/concepts/ViewBlock__.js +5 -27
  427. package/out/concepts/ViewBlock__.js.map +1 -1
  428. package/out/concepts/ViewComponent__.d.ts +1 -1
  429. package/out/concepts/ViewComponent__.js +42 -74
  430. package/out/concepts/ViewComponent__.js.map +1 -1
  431. package/out/concepts/ViewElement__.d.ts +18 -2
  432. package/out/concepts/ViewElement__.js +194 -115
  433. package/out/concepts/ViewElement__.js.map +1 -1
  434. package/out/concepts/View__.d.ts +1 -1
  435. package/out/concepts/View__.js +66 -128
  436. package/out/concepts/View__.js.map +1 -1
  437. package/out/concepts/WhileStatement__.d.ts +1 -1
  438. package/out/concepts/WhileStatement__.js +11 -23
  439. package/out/concepts/WhileStatement__.js.map +1 -1
  440. package/out/concepts/basics/stdlib/nasl.util.js +30 -30
  441. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  442. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +2 -2
  443. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -1
  444. package/out/concepts/index.d.ts +2 -2
  445. package/out/concepts/index.js +3 -3
  446. package/out/concepts/index.js.map +1 -1
  447. package/out/concepts/index__.d.ts +5 -1
  448. package/out/concepts/index__.js +5 -1
  449. package/out/concepts/index__.js.map +1 -1
  450. package/out/concepts/utils/asserts.d.ts +258 -54
  451. package/out/concepts/utils/asserts.js +351 -81
  452. package/out/concepts/utils/asserts.js.map +1 -1
  453. package/out/concepts/utils/quick-info.d.ts +13 -0
  454. package/out/concepts/utils/quick-info.js +51 -0
  455. package/out/concepts/utils/quick-info.js.map +1 -0
  456. package/out/concepts/utils/types.d.ts +20 -6
  457. package/out/generator/genBundleFiles.js +25 -11
  458. package/out/generator/genBundleFiles.js.map +1 -1
  459. package/out/generator/genReleaseBody.js +12 -3
  460. package/out/generator/genReleaseBody.js.map +1 -1
  461. package/out/generator/permission.js +3 -3
  462. package/out/generator/permission.js.map +1 -1
  463. package/out/manager/diagnostic.js +3 -1
  464. package/out/manager/diagnostic.js.map +1 -1
  465. package/out/server/extendBaseNode.js +6 -4
  466. package/out/server/extendBaseNode.js.map +1 -1
  467. package/out/server/formatTsUtils.d.ts +3 -3
  468. package/out/server/formatTsUtils.js.map +1 -1
  469. package/out/server/getConnector.js +18 -0
  470. package/out/server/getConnector.js.map +1 -1
  471. package/out/server/getLogics.js +62 -27
  472. package/out/server/getLogics.js.map +1 -1
  473. package/out/server/getMemberIdentifier.d.ts +4 -4
  474. package/out/server/getMemberIdentifier.js +6 -1
  475. package/out/server/getMemberIdentifier.js.map +1 -1
  476. package/out/server/naslServer.d.ts +3 -3
  477. package/out/server/naslServer.js +53 -103
  478. package/out/server/naslServer.js.map +1 -1
  479. package/out/server/translator.js +11 -17
  480. package/out/server/translator.js.map +1 -1
  481. package/out/service/storage/init.js +8 -20
  482. package/out/service/storage/init.js.map +1 -1
  483. package/out/templator/genCreateBlock.js +6 -6
  484. package/out/templator/genCreateBlock.js.map +1 -1
  485. package/out/templator/genCurdEditMultipleKeyBlock.js +16 -16
  486. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  487. package/out/templator/genCurdMultipleKeyBlock.js +36 -36
  488. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  489. package/out/templator/genGetBlock.js +4 -4
  490. package/out/templator/genGetBlock.js.map +1 -1
  491. package/out/templator/genGridViewBlock.js +12 -12
  492. package/out/templator/genGridViewBlock.js.map +1 -1
  493. package/out/templator/genListViewBlock.js +4 -4
  494. package/out/templator/genListViewBlock.js.map +1 -1
  495. package/out/templator/genQueryComponent.js +37 -32
  496. package/out/templator/genQueryComponent.js.map +1 -1
  497. package/out/templator/genSelectBlock.js +3 -3
  498. package/out/templator/genSelectBlock.js.map +1 -1
  499. package/out/templator/genTableBlock.js +10 -10
  500. package/out/templator/genTableBlock.js.map +1 -1
  501. package/out/templator/genUpdateBlock.js +8 -8
  502. package/out/templator/genUpdateBlock.js.map +1 -1
  503. package/out/templator/utils.d.ts +26 -21
  504. package/out/templator/utils.js +27 -17
  505. package/out/templator/utils.js.map +1 -1
  506. package/out/translator/utils.d.ts +2 -2
  507. package/out/utils/i18nInfo.js +7 -2
  508. package/out/utils/i18nInfo.js.map +1 -1
  509. package/out/utils/index.js +1 -1
  510. package/out/utils/index.js.map +1 -1
  511. package/out/utils/time-slicing/controller.js +48 -46
  512. package/out/utils/time-slicing/controller.js.map +1 -1
  513. package/out/utils/time-slicing/performance.js +0 -1
  514. package/out/utils/time-slicing/performance.js.map +1 -1
  515. package/package.json +1 -1
  516. package/sandbox/stdlib/nasl.util.ts +1 -2
  517. package/src/bak/translator.js +121 -43
  518. package/src/breakpoint/generator/BreakpointNode.ts +12 -0
  519. package/src/breakpoint/generator/CallbackNode.ts +17 -0
  520. package/src/breakpoint/shared/constants.ts +1 -1
  521. package/src/breakpoint/shared/utils.ts +13 -8
  522. package/src/common/BaseNode.ts +52 -64
  523. package/src/common/utils.ts +2 -2
  524. package/src/concepts/Abort__.ts +4 -5
  525. package/src/concepts/AbstractInterface__.ts +4 -5
  526. package/src/concepts/Anchor__.ts +4 -6
  527. package/src/concepts/AnonymousFunction__.ts +11 -15
  528. package/src/concepts/App__.ts +148 -157
  529. package/src/concepts/Argument__.ts +4 -8
  530. package/src/concepts/Assignee__.ts +7 -8
  531. package/src/concepts/AssignmentLine__.ts +4 -5
  532. package/src/concepts/Assignment__.ts +6 -9
  533. package/src/concepts/Attribute__.ts +4 -15
  534. package/src/concepts/AuthInterface__.ts +4 -6
  535. package/src/concepts/AuthLogicForCallInterface__.ts +16 -14
  536. package/src/concepts/AuthLogic__.ts +4 -6
  537. package/src/concepts/BackendVariable__.ts +14 -12
  538. package/src/concepts/Backend__.ts +5 -7
  539. package/src/concepts/BatchAssignment__.ts +6 -8
  540. package/src/concepts/BinaryExpression__.ts +9 -9
  541. package/src/concepts/BindAttribute__.ts +23 -25
  542. package/src/concepts/BindDirective__.ts +24 -18
  543. package/src/concepts/BindEvent__.ts +53 -29
  544. package/src/concepts/BindStyle__.ts +5 -8
  545. package/src/concepts/Block__.ts +5 -6
  546. package/src/concepts/BooleanLiteral__.ts +4 -6
  547. package/src/concepts/BusinessComponent__.ts +2659 -0
  548. package/src/concepts/BusinessLogic__.ts +376 -0
  549. package/src/concepts/CallAuthInterface__.ts +6 -7
  550. package/src/concepts/CallConnector__.ts +4 -6
  551. package/src/concepts/CallEvent__.ts +334 -0
  552. package/src/concepts/CallFunction__.ts +24 -15
  553. package/src/concepts/CallInterface__.ts +13 -12
  554. package/src/concepts/CallLogic__.ts +56 -83
  555. package/src/concepts/CallQueryComponent__.ts +137 -63
  556. package/src/concepts/Comment__.ts +4 -6
  557. package/src/concepts/CompletionProperty__.ts +4 -12
  558. package/src/concepts/ConfigGroup__.ts +5 -7
  559. package/src/concepts/ConfigPropertyValue__.ts +4 -7
  560. package/src/concepts/ConfigProperty__.ts +5 -9
  561. package/src/concepts/Configuration__.ts +5 -6
  562. package/src/concepts/Connection__.ts +5 -9
  563. package/src/concepts/ConnectorTrigger__.ts +4 -8
  564. package/src/concepts/Connector__.ts +11 -18
  565. package/src/concepts/Constant__.ts +9 -16
  566. package/src/concepts/CountersignPolicy__.ts +4 -6
  567. package/src/concepts/DataSource__.ts +5 -9
  568. package/src/concepts/DatabaseTypeAnnotation__.ts +4 -7
  569. package/src/concepts/DefaultValue__.ts +9 -8
  570. package/src/concepts/Destination__.ts +9 -13
  571. package/src/concepts/End__.ts +5 -5
  572. package/src/concepts/EntityIndex__.ts +4 -9
  573. package/src/concepts/EntityProperty__.ts +4 -19
  574. package/src/concepts/Entity__.ts +10 -30
  575. package/src/concepts/EnumItem__.ts +4 -7
  576. package/src/concepts/Enum__.ts +5 -9
  577. package/src/concepts/Event__.ts +62 -11
  578. package/src/concepts/ExternalDestination__.ts +8 -11
  579. package/src/concepts/ForEachStatement__.ts +6 -12
  580. package/src/concepts/FrontendLibrary__.ts +6 -9
  581. package/src/concepts/FrontendType__.ts +919 -0
  582. package/src/concepts/FrontendVariable__.ts +15 -9
  583. package/src/concepts/Frontend__.ts +10 -266
  584. package/src/concepts/Function__.ts +8 -12
  585. package/src/concepts/I18nInfo__.ts +4 -8
  586. package/src/concepts/Identifier__.ts +35 -22
  587. package/src/concepts/IfStatement__.ts +6 -8
  588. package/src/concepts/ImportedInterface__.ts +4 -6
  589. package/src/concepts/Integration__.ts +5 -7
  590. package/src/concepts/InterfaceParam__.ts +4 -11
  591. package/src/concepts/Interface__.ts +7 -14
  592. package/src/concepts/JSBlock__.ts +4 -6
  593. package/src/concepts/JavaLogic__.ts +4 -8
  594. package/src/concepts/LogicItem__.ts +5 -10
  595. package/src/concepts/Logic__.ts +52 -49
  596. package/src/concepts/MatchCase__.ts +12 -13
  597. package/src/concepts/Match__.ts +10 -12
  598. package/src/concepts/MemberExpression__.ts +20 -23
  599. package/src/concepts/MetadataType__.ts +6 -10
  600. package/src/concepts/MicroApp__.ts +4 -12
  601. package/src/concepts/Module__.ts +16 -26
  602. package/src/concepts/MsgTriggerEvent__.ts +5 -6
  603. package/src/concepts/MsgTriggerLauncher__.ts +5 -7
  604. package/src/concepts/MultiApprovalPolicy__.ts +4 -5
  605. package/src/concepts/Namespace__.ts +16 -21
  606. package/src/concepts/NewComposite__.ts +12 -14
  607. package/src/concepts/NewList__.ts +12 -10
  608. package/src/concepts/NewMap__.ts +12 -11
  609. package/src/concepts/New__.ts +4 -5
  610. package/src/concepts/NullLiteral__.ts +4 -5
  611. package/src/concepts/NumericLiteral__.ts +4 -7
  612. package/src/concepts/OqlQueryComponent__.ts +4 -8
  613. package/src/concepts/OverriddenLogic__.ts +33 -33
  614. package/src/concepts/ParamWithGroup__.ts +101 -0
  615. package/src/concepts/Param__.ts +17 -15
  616. package/src/concepts/Point__.ts +4 -7
  617. package/src/concepts/ProcessComponent__.ts +6 -11
  618. package/src/concepts/ProcessElement__.ts +10 -21
  619. package/src/concepts/ProcessOutcome__.ts +4 -6
  620. package/src/concepts/ProcessOutcomes__.ts +4 -5
  621. package/src/concepts/Process__.ts +10 -14
  622. package/src/concepts/QueryAggregateExpression__.ts +4 -8
  623. package/src/concepts/QueryFieldExpression__.ts +4 -8
  624. package/src/concepts/QueryFromExpression__.ts +5 -9
  625. package/src/concepts/QueryGroupByExpression__.ts +4 -6
  626. package/src/concepts/QueryJoinExpression__.ts +6 -11
  627. package/src/concepts/QueryLimitExpression__.ts +4 -7
  628. package/src/concepts/QueryOrderByExpression__.ts +4 -7
  629. package/src/concepts/QuerySelectExpression__.ts +6 -7
  630. package/src/concepts/Rect__.ts +4 -9
  631. package/src/concepts/Return__.ts +19 -21
  632. package/src/concepts/Role__.ts +4 -8
  633. package/src/concepts/SelectMembers__.ts +5 -7
  634. package/src/concepts/SequentialPolicy__.ts +4 -5
  635. package/src/concepts/Slot__.ts +4 -11
  636. package/src/concepts/SqlQueryComponent__.ts +4 -9
  637. package/src/concepts/Start__.ts +4 -5
  638. package/src/concepts/StaticString__.ts +4 -6
  639. package/src/concepts/StringInterpolation__.ts +5 -6
  640. package/src/concepts/StringLiteral__.ts +4 -6
  641. package/src/concepts/StructureProperty__.ts +4 -12
  642. package/src/concepts/Structure__.ts +6 -10
  643. package/src/concepts/SwitchCase__.ts +5 -7
  644. package/src/concepts/SwitchStatement__.ts +5 -6
  645. package/src/concepts/Theme__.ts +4 -5
  646. package/src/concepts/Transactional__.ts +4 -8
  647. package/src/concepts/TriggerEvent__.ts +4 -7
  648. package/src/concepts/TriggerLauncher__.ts +4 -9
  649. package/src/concepts/TypeAnnotation__.ts +9 -15
  650. package/src/concepts/TypeParam__.ts +4 -6
  651. package/src/concepts/UnaryExpression__.ts +4 -7
  652. package/src/concepts/Unparsed__.ts +4 -6
  653. package/src/concepts/UseComponent__.ts +4 -7
  654. package/src/concepts/ValidationRule__.ts +5 -10
  655. package/src/concepts/Variable__.ts +22 -19
  656. package/src/concepts/ViewBlock__.ts +4 -8
  657. package/src/concepts/ViewComponent__.ts +10 -16
  658. package/src/concepts/ViewElement__.ts +183 -59
  659. package/src/concepts/View__.ts +27 -37
  660. package/src/concepts/WhileStatement__.ts +5 -7
  661. package/src/concepts/basics/stdlib/nasl.util.ts +30 -30
  662. package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +2 -2
  663. package/src/concepts/index.ts +2 -2
  664. package/src/concepts/index__.ts +5 -1
  665. package/src/concepts/utils/asserts.ts +367 -77
  666. package/src/concepts/utils/quick-info.ts +64 -0
  667. package/src/concepts/utils/types.ts +28 -5
  668. package/src/generator/genBundleFiles.ts +33 -15
  669. package/src/generator/genReleaseBody.ts +14 -3
  670. package/src/generator/permission.ts +8 -6
  671. package/src/server/extendBaseNode.ts +22 -20
  672. package/src/server/formatTsUtils.ts +8 -8
  673. package/src/server/getConnector.ts +21 -2
  674. package/src/server/getLogics.ts +79 -41
  675. package/src/server/getMemberIdentifier.ts +11 -5
  676. package/src/server/naslServer.ts +38 -78
  677. package/src/server/translator.ts +12 -17
  678. package/src/service/storage/init.ts +3 -4
  679. package/src/templator/genCreateBlock.ts +6 -6
  680. package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -16
  681. package/src/templator/genCurdMultipleKeyBlock.ts +36 -36
  682. package/src/templator/genGetBlock.ts +4 -4
  683. package/src/templator/genGridViewBlock.ts +12 -12
  684. package/src/templator/genListViewBlock.ts +4 -4
  685. package/src/templator/genQueryComponent.ts +38 -33
  686. package/src/templator/genSelectBlock.ts +3 -3
  687. package/src/templator/genTableBlock.ts +10 -10
  688. package/src/templator/genUpdateBlock.ts +8 -8
  689. package/src/templator/utils.ts +29 -20
  690. package/src/translator/utils.ts +2 -2
  691. package/src/utils/i18nInfo.ts +7 -2
  692. package/src/utils/index.ts +1 -1
  693. package/test/concepts/binary-expression/__snapshots__/getQuickInfoOffset.spec.ts.snap +25 -0
  694. package/test/concepts/binary-expression/getQuickInfoOffset.spec.ts +19 -0
  695. package/test/concepts/call-function/__snapshots__/getQuickInfoOffset.spec.ts.snap +41 -0
  696. package/test/concepts/call-function/fixtures/from-string.json +68 -59
  697. package/test/concepts/call-function/fixtures/to-string-global-tz.json +67 -58
  698. package/test/concepts/call-function/fixtures/to-string-no-tz.json +57 -48
  699. package/test/concepts/call-function/fixtures/to-string-user-tz.json +69 -60
  700. package/test/concepts/call-function/fixtures/to-string-utc-tz.json +69 -60
  701. package/test/concepts/call-function/getQuickInfoOffset.spec.ts +19 -0
  702. package/test/concepts/call-interface/__snapshots__/getQuickInfoOffset.spec.ts.snap +86 -0
  703. package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
  704. package/test/concepts/call-interface/fixtures/only-interface.json +81 -72
  705. package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +223 -214
  706. package/test/concepts/call-interface/fixtures/with-body-no-argument.json +85 -76
  707. package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +100 -91
  708. package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +88 -79
  709. package/test/concepts/call-interface/fixtures/with-headers.json +90 -81
  710. package/test/concepts/call-interface/fixtures/with-query-no-argument.json +88 -79
  711. package/test/concepts/call-interface/fixtures/with-query.json +90 -81
  712. package/test/concepts/call-interface/getQuickInfoOffset.spec.ts +19 -0
  713. package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +4 -2
  714. package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +104 -95
  715. package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +209 -200
  716. package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +97 -88
  717. package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +124 -115
  718. package/test/concepts/call-logic/fixtures/json-deserialize.json +120 -111
  719. package/test/concepts/call-logic/fixtures/json-serialize-with-string.json +124 -115
  720. package/test/concepts/call-logic/fixtures/json-serialize.json +124 -115
  721. package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +91 -82
  722. package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +88 -79
  723. package/test/concepts/call-logic/fixtures/view-component-with-validation.json +144 -135
  724. package/test/concepts/call-logic/getQuickInfoOffset.spec.ts +2 -7
  725. package/test/concepts/identifier/fixtures/view-variable.json +145 -136
  726. package/test/concepts/new-composite/__snapshots__/getQuickInfoOffset.spec.ts.snap +104 -0
  727. package/test/concepts/new-composite/__snapshots__/toEmbeddedTS.spec.ts.snap +97 -0
  728. package/test/concepts/new-composite/__snapshots__/toJS.spec.ts.snap +43 -0
  729. package/test/concepts/new-composite/constant.ts +5 -0
  730. package/test/concepts/new-composite/fixtures/nested-transform.json +241 -0
  731. package/test/concepts/new-composite/fixtures/nested.json +146 -0
  732. package/test/concepts/new-composite/fixtures/normal.json +63 -0
  733. package/test/concepts/new-composite/getQuickInfoOffset.spec.ts +19 -0
  734. package/test/concepts/new-composite/toEmbeddedTS.spec.ts +15 -0
  735. package/test/concepts/new-composite/toJS.spec.ts +14 -0
  736. package/test/concepts/new-list/__snapshots__/getQuickInfoOffset.spec.ts.snap +165 -0
  737. package/test/concepts/new-list/__snapshots__/toEmbeddedTS.spec.ts.snap +207 -0
  738. package/test/concepts/new-list/__snapshots__/toJS.spec.ts.snap +63 -0
  739. package/test/concepts/new-list/constant.ts +5 -0
  740. package/test/concepts/new-list/fixtures/nested-map.json +117 -0
  741. package/test/concepts/new-list/fixtures/nested-tranform.json +140 -0
  742. package/test/concepts/new-list/fixtures/nested.json +107 -0
  743. package/test/concepts/new-list/fixtures/normal.json +95 -0
  744. package/test/concepts/new-list/getQuickInfoOffset.spec.ts +19 -0
  745. package/test/concepts/new-list/toEmbeddedTS.spec.ts +15 -0
  746. package/test/concepts/new-list/toJS.spec.ts +14 -0
  747. package/test/concepts/new-map/__snapshots__/getQuickInfoOffset.spec.ts.snap +115 -0
  748. package/test/concepts/new-map/__snapshots__/toEmbeddedTS.spec.ts.snap +192 -0
  749. package/test/concepts/new-map/__snapshots__/toJS.spec.ts.snap +54 -0
  750. package/test/concepts/new-map/constant.ts +5 -0
  751. package/test/concepts/new-map/fixtures/nested-transform.json +169 -0
  752. package/test/concepts/new-map/fixtures/nested.json +141 -0
  753. package/test/concepts/new-map/fixtures/normal.json +101 -0
  754. package/test/concepts/new-map/getQuickInfoOffset.spec.ts +19 -0
  755. package/test/concepts/new-map/toEmbeddedTS.spec.ts +15 -0
  756. package/test/concepts/new-map/toJS.spec.ts +14 -0
  757. package/test/concepts/utils.ts +17 -0
  758. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +1 -1
  759. package/test/concepts/view-element/fixtures/default-login.json +221 -212
  760. package/test/concepts/view-element/fixtures/default-not-found.json +183 -174
  761. package/test/concepts/view-element/fixtures/with-role-auth.json +91 -82
  762. package/test/concepts/view-element/fixtures/with-table.json +1894 -1885
  763. package/test/concepts/view-element/toVue.spec.ts +1 -0
  764. package/tsconfig.json +2 -1
  765. package/out/concepts/Paginate__.d.ts +0 -80
  766. package/out/concepts/Paginate__.js +0 -250
  767. package/out/concepts/Paginate__.js.map +0 -1
  768. package/src/concepts/Paginate__.ts +0 -287
@@ -0,0 +1,2659 @@
1
+ import {
2
+ wrapForEachToGenerator as wrapForEach,
3
+ wrapIteratorToGenerator as wrapIterator,
4
+ returnOrigin,
5
+ } from '../utils/time-slicing';
6
+ import type { EmbeddedTSFileGenerator } from '../utils';
7
+ import { shiftState, indent, createCompilerState, withSourceMapGenerator, TranslatorGenerator } from '../translator';
8
+ import type Assignment from './Assignment__';
9
+ import type BatchAssignment from './BatchAssignment__';
10
+ import type Interface from './Interface__';
11
+ import type App from './App__';
12
+ import type FrontendType from './FrontendType__';
13
+ import type Match from './Match__';
14
+ import { ElementToVueOptions } from './ViewElement__';
15
+ import translator from '../bak/translator';
16
+
17
+ type AttrObject = {
18
+ value: string;
19
+ label: string;
20
+ };
21
+
22
+ const PAGE_COMPONENT_INCLUDE_TAG_MAP: Record<string, Record<string, AttrObject>> = {
23
+ 'u-list-view': {
24
+ 'page-size': {
25
+ value: 'size',
26
+ label: '分页大小',
27
+ },
28
+ 'page-number': {
29
+ value: 'page',
30
+ label: '当前页数',
31
+ },
32
+ 'data-source': {
33
+ value: 'data',
34
+ label: '数据',
35
+ },
36
+ },
37
+ 'u-grid-view': {
38
+ 'page-size': {
39
+ value: 'size',
40
+ label: '分页大小',
41
+ },
42
+ 'page-number': {
43
+ value: 'page',
44
+ label: '当前页数',
45
+ },
46
+ 'data-source': {
47
+ value: 'data',
48
+ label: '数据',
49
+ },
50
+ },
51
+ 'u-list-components': {
52
+ 'data-source': {
53
+ value: 'data',
54
+ label: '数据',
55
+ },
56
+ },
57
+ 'u-table-view': {
58
+ 'page-size': {
59
+ value: 'size',
60
+ label: '分页大小',
61
+ },
62
+ 'page-number': {
63
+ value: 'page',
64
+ label: '当前页数',
65
+ },
66
+ sorting: {
67
+ value: 'sort',
68
+ label: '排序属性',
69
+ },
70
+ value: {
71
+ value: 'value',
72
+ label: '单选选中值',
73
+ },
74
+ values: {
75
+ value: 'values',
76
+ label: '多选选中值',
77
+ },
78
+ 'data-source': {
79
+ value: 'data',
80
+ label: '数据',
81
+ },
82
+ },
83
+ 'u-radios': {
84
+ value: {
85
+ value: 'value',
86
+ label: '选中值',
87
+ },
88
+ 'data-source': {
89
+ value: 'data',
90
+ label: '数据',
91
+ },
92
+ },
93
+ 'u-checkboxes': {
94
+ value: {
95
+ value: 'value',
96
+ label: '选中值',
97
+ },
98
+ 'data-source': {
99
+ value: 'data',
100
+ label: '数据',
101
+ },
102
+ },
103
+ 'u-select': {
104
+ value: {
105
+ value: 'value',
106
+ label: '选中值',
107
+ },
108
+ 'data-source': {
109
+ value: 'data',
110
+ label: '数据',
111
+ },
112
+ opened: {
113
+ value: 'opened',
114
+ label: '弹出状态',
115
+ },
116
+ 'page-size': {
117
+ value: 'size',
118
+ label: '分页大小',
119
+ },
120
+ 'page-number': {
121
+ value: 'page',
122
+ label: '当前页数',
123
+ },
124
+ },
125
+ 'u-cascader': {
126
+ value: {
127
+ value: 'value',
128
+ label: '选中值',
129
+ },
130
+ 'data-source': {
131
+ value: 'data',
132
+ label: '数据',
133
+ },
134
+ },
135
+ 'u-tree-select-new': {
136
+ value: {
137
+ value: 'value',
138
+ label: '选中值',
139
+ },
140
+ 'data-source': {
141
+ value: 'data',
142
+ label: '数据',
143
+ },
144
+ },
145
+ 'van-radio-group': {
146
+ value: {
147
+ value: 'value',
148
+ label: '选中值',
149
+ },
150
+ 'data-source': {
151
+ value: 'data',
152
+ label: '数据',
153
+ },
154
+ },
155
+ 'van-checkbox-group': {
156
+ value: {
157
+ value: 'value',
158
+ label: '选中值',
159
+ },
160
+ 'data-source': {
161
+ value: 'data',
162
+ label: '数据',
163
+ },
164
+ },
165
+ 'van-pickerson': {
166
+ pvalue: {
167
+ value: 'value',
168
+ label: '选中值',
169
+ },
170
+ 'data-source': {
171
+ value: 'data',
172
+ label: '数据',
173
+ },
174
+ 'page-size': {
175
+ value: 'size',
176
+ label: '分页大小',
177
+ },
178
+ 'page-number': {
179
+ value: 'page',
180
+ label: '当前页数',
181
+ },
182
+ },
183
+ 'van-cascader': {
184
+ value: {
185
+ value: 'value',
186
+ label: '选中值',
187
+ },
188
+ 'data-source': {
189
+ value: 'data',
190
+ label: '数据',
191
+ },
192
+ },
193
+ 'van-list-view': {
194
+ 'page-size': {
195
+ value: 'size',
196
+ label: '分页大小',
197
+ },
198
+ 'page-number': {
199
+ value: 'page',
200
+ label: '当前页数',
201
+ },
202
+ 'data-source': {
203
+ value: 'data',
204
+ label: '数据',
205
+ },
206
+ },
207
+ 'van-grid-view': {
208
+ 'page-size': {
209
+ value: 'size',
210
+ label: '分页大小',
211
+ },
212
+ 'page-number': {
213
+ value: 'page',
214
+ label: '当前页数',
215
+ },
216
+ 'data-source': {
217
+ value: 'data',
218
+ label: '数据',
219
+ },
220
+ },
221
+ 'van-for-components': {
222
+ 'data-source': {
223
+ value: 'data',
224
+ label: '数据',
225
+ },
226
+ },
227
+ };
228
+
229
+ const getBranchCopyUniCode = () => (window as any)?.BranchCopyUniCode;
230
+ const removedViewElementCache: {
231
+ [key: string]: number | bigint;
232
+ } = {}; // 临时记录删除的页面元素计数的最大值
233
+
234
+ //================================================================================
235
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
236
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
237
+ //================================================================================
238
+ import { EventPayload, Params } from '../common/EventEmitter';
239
+ import { concept, excludedInJSON, property, getConceptConstructor, getBaseNode } from '../decorators';
240
+
241
+ import * as utils from '../utils';
242
+ import * as types from './utils/types';
243
+ import * as asserts from './utils/asserts';
244
+ import { v4 as uuidv4 } from 'uuid';
245
+ import BaseNode from '../common/BaseNode';
246
+ import type Event from './Event__';
247
+ import type ParamWithGroup from './ParamWithGroup__';
248
+ import type Variable from './Variable__';
249
+ import type BindEvent from './BindEvent__';
250
+ import type BusinessLogic from './BusinessLogic__';
251
+ import type ViewElement from './ViewElement__';
252
+ import type Param from './Param__';
253
+ import type Logic from './Logic__';
254
+
255
+ /**
256
+ * 业务组件
257
+ */
258
+ @concept('业务组件')
259
+ export class BusinessComponent extends BaseNode {
260
+ /** 类名 */
261
+ static readonly ConceptName: string = 'BusinessComponent';
262
+
263
+ /** 继承链 */
264
+ static readonly inheritanceChain: string[] = ['BaseNode'];
265
+
266
+ /**
267
+ * 产品概念
268
+ */
269
+ @property('concept')
270
+ // @ts-ignore
271
+ readonly concept!: 'BusinessComponent';
272
+
273
+ /**
274
+ * 业务组件名称
275
+ */
276
+ @property()
277
+ name!: string;
278
+
279
+ /**
280
+ * 业务组件标题
281
+ */
282
+ @property()
283
+ title!: string;
284
+
285
+ /**
286
+ * 业务组件描述
287
+ */
288
+ @property()
289
+ description!: string;
290
+
291
+ /**
292
+ * 组件事件列表
293
+ */
294
+ @property({
295
+ objectRef: 'Event',
296
+ isArray: true,
297
+ defaultValue: [],
298
+ })
299
+ events: Array<Event> = [];
300
+
301
+ /**
302
+ * 参数分组列表
303
+ */
304
+ @property({
305
+ objectRef: 'ParamWithGroup',
306
+ isArray: true,
307
+ defaultValue: [],
308
+ })
309
+ params: Array<ParamWithGroup> = [];
310
+
311
+ /**
312
+ * 变量列表
313
+ */
314
+ @property({
315
+ objectRef: 'Variable',
316
+ isArray: true,
317
+ defaultValue: [],
318
+ })
319
+ variables: Array<Variable> = [];
320
+
321
+ /**
322
+ * 元素绑定事件列表
323
+ */
324
+ @property({
325
+ objectRef: 'BindEvent',
326
+ isArray: true,
327
+ defaultValue: [],
328
+ })
329
+ bindEvents: Array<BindEvent> = [];
330
+
331
+ /**
332
+ * 业务组件逻辑列表
333
+ */
334
+ @property({
335
+ objectRef: 'BusinessLogic',
336
+ isArray: true,
337
+ defaultValue: [],
338
+ })
339
+ logics: Array<BusinessLogic> = [];
340
+
341
+ /**
342
+ * 页面元素列表
343
+ */
344
+ @property({
345
+ objectRef: 'ViewElement',
346
+ isArray: true,
347
+ defaultValue: [],
348
+ })
349
+ elements: Array<ViewElement> = [];
350
+
351
+ /**
352
+ * icon
353
+ */
354
+ @property()
355
+ icon!: string;
356
+
357
+ /**
358
+ * @param source 需要合并的部分参数
359
+ */
360
+ constructor(source?: Partial<BusinessComponent>) {
361
+ source = Object.assign({}, BusinessComponent.getDefaultOptions(), source);
362
+ super(source);
363
+ super.subConstructor(source);
364
+ }
365
+
366
+ static from(source: any, parentNode?: any, parentKey?: string): BusinessComponent {
367
+ return super.from(source, parentNode, parentKey) as BusinessComponent;
368
+ }
369
+
370
+ /**
371
+ * 从父级删除该节点
372
+ * @internal
373
+ */
374
+ _delete() {
375
+ let params: Params = null;
376
+ if (this.parentNode) {
377
+ params = (this.parentNode as any)?.__removeBusinessComponent?.(this);
378
+ }
379
+ return params;
380
+ }
381
+ /**
382
+ * 设置业务组件名称
383
+ */
384
+ setName(name: string) {
385
+ const object = {
386
+ name,
387
+ };
388
+ this.update({
389
+ ...object,
390
+ field: 'name',
391
+ });
392
+ }
393
+
394
+ /**
395
+ * 设置业务组件标题
396
+ */
397
+ setTitle(title: string) {
398
+ const object = {
399
+ title,
400
+ };
401
+ this.update({
402
+ ...object,
403
+ });
404
+ }
405
+
406
+ /**
407
+ * 设置业务组件描述
408
+ */
409
+ setDescription(description: string) {
410
+ const object = {
411
+ description,
412
+ };
413
+ this.update({
414
+ ...object,
415
+ });
416
+ }
417
+
418
+ /**
419
+ * 设置icon
420
+ */
421
+ setIcon(icon: string) {
422
+ const object = {
423
+ icon,
424
+ };
425
+ this.update({
426
+ ...object,
427
+ });
428
+ }
429
+
430
+ getEventExistingNames(excludedList: Array<Event> = []) {
431
+ const excludedSet = new Set(excludedList);
432
+ return ((this.events as Event[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item?.name);
433
+ }
434
+ getEventUniqueName(name = 'event1') {
435
+ return utils.unique(name, this.getEventExistingNames(), undefined, false);
436
+ }
437
+
438
+ /**
439
+ * 插入组件事件
440
+ * @internal
441
+ * @param name 组件事件名称,如果不填会自动生成一个唯一名称
442
+ */
443
+ _insertEventAt(name: string, index: number): Event;
444
+
445
+ /**
446
+ * 插入组件事件
447
+ * @internal
448
+ * @param eventOptions 组件事件参数
449
+ */
450
+ _insertEventAt(eventOptions: Partial<Event>, index: number): Event;
451
+
452
+ /**
453
+ * 插入组件事件
454
+ * @internal
455
+ * @param event 已有的组件事件实例
456
+ */
457
+ _insertEventAt(event: Event, index: number): Event;
458
+
459
+ _insertEventAt(options: string | Partial<Event> | Event, index: number) {
460
+ const eventOptions: any = {};
461
+ const relationOptions = { parentNode: this, parentKey: 'events' };
462
+ const Event = getConceptConstructor('Event');
463
+ let event: Event;
464
+ if (!options) {
465
+ event = Event.from(
466
+ {
467
+ ...eventOptions,
468
+ name: this.getEventUniqueName(),
469
+ },
470
+ this,
471
+ 'events',
472
+ );
473
+ } else if (typeof options === 'string') {
474
+ event = Event.from(
475
+ {
476
+ ...eventOptions,
477
+ name: options,
478
+ },
479
+ this,
480
+ 'events',
481
+ );
482
+ } else if (asserts.isEvent(options)) {
483
+ options.ensureDelete(); // 同一实例不支持多处存在
484
+ event = options;
485
+ Object.assign(event, relationOptions);
486
+ } else {
487
+ event = Event.from(
488
+ {
489
+ ...eventOptions,
490
+ ...options,
491
+ },
492
+ this,
493
+ 'events',
494
+ );
495
+ }
496
+ this.events.splice(index, 0, event);
497
+ return event;
498
+ }
499
+
500
+ /**
501
+ * 插入组件事件
502
+ * @param name 组件事件名称,如果不填会自动生成一个唯一名称
503
+ */
504
+ insertEventAt(name: string, index: number): Event;
505
+
506
+ /**
507
+ * 插入组件事件
508
+ * @param eventOptions 组件事件参数
509
+ */
510
+ insertEventAt(eventOptions: Partial<Event>, index: number): Event;
511
+
512
+ /**
513
+ * 插入组件事件
514
+ * @param event 已有的组件事件实例
515
+ */
516
+ insertEventAt(event: Event, index: number): Event;
517
+
518
+ insertEventAt(options: string | Partial<Event> | Event, index: number) {
519
+ const node = this._insertEventAt(options as any, index);
520
+ node.create({
521
+ index,
522
+ parentNode: this,
523
+ parentKey: 'events',
524
+ });
525
+ return node;
526
+ }
527
+
528
+ /**
529
+ * 添加组件事件
530
+ * @internal
531
+ * @param name 组件事件名称,如果不填会自动生成一个唯一名称
532
+ */
533
+ _addEvent(name?: string): Event;
534
+
535
+ /**
536
+ * 添加组件事件
537
+ * @internal
538
+ * @param eventOptions 组件事件参数
539
+ */
540
+ _addEvent(eventOptions: Partial<Event>): Event;
541
+
542
+ /**
543
+ * 添加组件事件
544
+ * @internal
545
+ * @param event 已有的组件事件实例
546
+ */
547
+ _addEvent(event: Event): Event;
548
+
549
+ _addEvent(options?: string | Partial<Event> | Event) {
550
+ const index = this.events.length;
551
+ return this._insertEventAt(options as any, index);
552
+ }
553
+
554
+ /**
555
+ * 添加组件事件
556
+ * @internal
557
+ * @param name 组件事件名称,如果不填会自动生成一个唯一名称
558
+ */
559
+ addEvent(name?: string): Event;
560
+
561
+ /**
562
+ * 添加组件事件
563
+ * @param eventOptions 组件事件参数
564
+ */
565
+ addEvent(eventOptions: Partial<Event>): Event;
566
+
567
+ /**
568
+ * 添加组件事件
569
+ * @param event 已有的组件事件实例
570
+ */
571
+ addEvent(event: Event): Event;
572
+
573
+ addEvent(options?: string | Partial<Event> | Event) {
574
+ const node = this._addEvent(options as any);
575
+ const index = this.events.indexOf(node);
576
+ node.create({
577
+ index,
578
+ parentNode: this,
579
+ parentKey: 'events',
580
+ });
581
+ return node;
582
+ }
583
+
584
+ getParamUniqueName(name = 'param1') {
585
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
586
+ }
587
+
588
+ /**
589
+ * 插入参数分组
590
+ * @internal
591
+ * @param name 参数分组名称,如果不填会自动生成一个唯一名称
592
+ */
593
+ _insertParamAt(name: string, index: number): ParamWithGroup;
594
+
595
+ /**
596
+ * 插入参数分组
597
+ * @internal
598
+ * @param paramOptions 参数分组参数
599
+ */
600
+ _insertParamAt(paramOptions: Partial<ParamWithGroup>, index: number): ParamWithGroup;
601
+
602
+ /**
603
+ * 插入参数分组
604
+ * @internal
605
+ * @param param 已有的参数分组实例
606
+ */
607
+ _insertParamAt(param: ParamWithGroup, index: number): ParamWithGroup;
608
+
609
+ _insertParamAt(options: string | Partial<ParamWithGroup> | ParamWithGroup, index: number) {
610
+ const paramOptions: any = {};
611
+ const relationOptions = { parentNode: this, parentKey: 'params' };
612
+ const ParamWithGroup = getConceptConstructor('ParamWithGroup');
613
+ let param: ParamWithGroup;
614
+ if (!options) {
615
+ param = ParamWithGroup.from(
616
+ {
617
+ ...paramOptions,
618
+ name: this.getParamUniqueName(),
619
+ },
620
+ this,
621
+ 'params',
622
+ );
623
+ } else if (typeof options === 'string') {
624
+ param = ParamWithGroup.from(
625
+ {
626
+ ...paramOptions,
627
+ name: options,
628
+ },
629
+ this,
630
+ 'params',
631
+ );
632
+ } else if (asserts.isParamWithGroup(options)) {
633
+ options.ensureDelete(); // 同一实例不支持多处存在
634
+ param = options;
635
+ Object.assign(param, relationOptions);
636
+ } else {
637
+ param = ParamWithGroup.from(
638
+ {
639
+ ...paramOptions,
640
+ ...options,
641
+ },
642
+ this,
643
+ 'params',
644
+ );
645
+ }
646
+ this.params.splice(index, 0, param);
647
+ return param;
648
+ }
649
+
650
+ /**
651
+ * 插入参数分组
652
+ * @param name 参数分组名称,如果不填会自动生成一个唯一名称
653
+ */
654
+ insertParamAt(name: string, index: number): ParamWithGroup;
655
+
656
+ /**
657
+ * 插入参数分组
658
+ * @param paramOptions 参数分组参数
659
+ */
660
+ insertParamAt(paramOptions: Partial<ParamWithGroup>, index: number): ParamWithGroup;
661
+
662
+ /**
663
+ * 插入参数分组
664
+ * @param param 已有的参数分组实例
665
+ */
666
+ insertParamAt(param: ParamWithGroup, index: number): ParamWithGroup;
667
+
668
+ insertParamAt(options: string | Partial<ParamWithGroup> | ParamWithGroup, index: number) {
669
+ const node = this._insertParamAt(options as any, index);
670
+ node.create({
671
+ index,
672
+ parentNode: this,
673
+ parentKey: 'params',
674
+ });
675
+ return node;
676
+ }
677
+
678
+ /**
679
+ * 添加参数分组
680
+ * @internal
681
+ * @param name 参数分组名称,如果不填会自动生成一个唯一名称
682
+ */
683
+ _addParam(name?: string): ParamWithGroup;
684
+
685
+ /**
686
+ * 添加参数分组
687
+ * @internal
688
+ * @param paramOptions 参数分组参数
689
+ */
690
+ _addParam(paramOptions: Partial<ParamWithGroup>): ParamWithGroup;
691
+
692
+ /**
693
+ * 添加参数分组
694
+ * @internal
695
+ * @param param 已有的参数分组实例
696
+ */
697
+ _addParam(param: ParamWithGroup): ParamWithGroup;
698
+
699
+ _addParam(options?: string | Partial<ParamWithGroup> | ParamWithGroup) {
700
+ const index = this.params.length;
701
+ return this._insertParamAt(options as any, index);
702
+ }
703
+
704
+ /**
705
+ * 添加参数分组
706
+ * @internal
707
+ * @param name 参数分组名称,如果不填会自动生成一个唯一名称
708
+ */
709
+ addParam(name?: string): ParamWithGroup;
710
+
711
+ /**
712
+ * 添加参数分组
713
+ * @param paramOptions 参数分组参数
714
+ */
715
+ addParam(paramOptions: Partial<ParamWithGroup>): ParamWithGroup;
716
+
717
+ /**
718
+ * 添加参数分组
719
+ * @param param 已有的参数分组实例
720
+ */
721
+ addParam(param: ParamWithGroup): ParamWithGroup;
722
+
723
+ addParam(options?: string | Partial<ParamWithGroup> | ParamWithGroup) {
724
+ const node = this._addParam(options as any);
725
+ const index = this.params.indexOf(node);
726
+ node.create({
727
+ index,
728
+ parentNode: this,
729
+ parentKey: 'params',
730
+ });
731
+ return node;
732
+ }
733
+
734
+ getVariableUniqueName(name = 'variable1') {
735
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
736
+ }
737
+
738
+ /**
739
+ * 插入变量
740
+ * @internal
741
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
742
+ */
743
+ _insertVariableAt(name: string, index: number): Variable;
744
+
745
+ /**
746
+ * 插入变量
747
+ * @internal
748
+ * @param variableOptions 变量参数
749
+ */
750
+ _insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
751
+
752
+ /**
753
+ * 插入变量
754
+ * @internal
755
+ * @param variable 已有的变量实例
756
+ */
757
+ _insertVariableAt(variable: Variable, index: number): Variable;
758
+
759
+ _insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
760
+ const variableOptions: any = {};
761
+ const relationOptions = { parentNode: this, parentKey: 'variables' };
762
+ const Variable = getConceptConstructor('Variable');
763
+ let variable: Variable;
764
+ if (!options) {
765
+ variable = Variable.from(
766
+ {
767
+ ...variableOptions,
768
+ name: this.getVariableUniqueName(),
769
+ },
770
+ this,
771
+ 'variables',
772
+ );
773
+ } else if (typeof options === 'string') {
774
+ variable = Variable.from(
775
+ {
776
+ ...variableOptions,
777
+ name: options,
778
+ },
779
+ this,
780
+ 'variables',
781
+ );
782
+ } else if (asserts.isVariable(options)) {
783
+ options.ensureDelete(); // 同一实例不支持多处存在
784
+ variable = options;
785
+ Object.assign(variable, relationOptions);
786
+ } else {
787
+ variable = Variable.from(
788
+ {
789
+ ...variableOptions,
790
+ ...options,
791
+ },
792
+ this,
793
+ 'variables',
794
+ );
795
+ }
796
+ this.variables.splice(index, 0, variable);
797
+ return variable;
798
+ }
799
+
800
+ /**
801
+ * 插入变量
802
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
803
+ */
804
+ insertVariableAt(name: string, index: number): Variable;
805
+
806
+ /**
807
+ * 插入变量
808
+ * @param variableOptions 变量参数
809
+ */
810
+ insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
811
+
812
+ /**
813
+ * 插入变量
814
+ * @param variable 已有的变量实例
815
+ */
816
+ insertVariableAt(variable: Variable, index: number): Variable;
817
+
818
+ insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
819
+ const node = this._insertVariableAt(options as any, index);
820
+ node.create({
821
+ index,
822
+ parentNode: this,
823
+ parentKey: 'variables',
824
+ });
825
+ return node;
826
+ }
827
+
828
+ /**
829
+ * 添加变量
830
+ * @internal
831
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
832
+ */
833
+ _addVariable(name?: string): Variable;
834
+
835
+ /**
836
+ * 添加变量
837
+ * @internal
838
+ * @param variableOptions 变量参数
839
+ */
840
+ _addVariable(variableOptions: Partial<Variable>): Variable;
841
+
842
+ /**
843
+ * 添加变量
844
+ * @internal
845
+ * @param variable 已有的变量实例
846
+ */
847
+ _addVariable(variable: Variable): Variable;
848
+
849
+ _addVariable(options?: string | Partial<Variable> | Variable) {
850
+ const index = this.variables.length;
851
+ return this._insertVariableAt(options as any, index);
852
+ }
853
+
854
+ /**
855
+ * 添加变量
856
+ * @internal
857
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
858
+ */
859
+ addVariable(name?: string): Variable;
860
+
861
+ /**
862
+ * 添加变量
863
+ * @param variableOptions 变量参数
864
+ */
865
+ addVariable(variableOptions: Partial<Variable>): Variable;
866
+
867
+ /**
868
+ * 添加变量
869
+ * @param variable 已有的变量实例
870
+ */
871
+ addVariable(variable: Variable): Variable;
872
+
873
+ addVariable(options?: string | Partial<Variable> | Variable) {
874
+ const node = this._addVariable(options as any);
875
+ const index = this.variables.indexOf(node);
876
+ node.create({
877
+ index,
878
+ parentNode: this,
879
+ parentKey: 'variables',
880
+ });
881
+ return node;
882
+ }
883
+
884
+ getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
885
+ const excludedSet = new Set(excludedList);
886
+ return ((this.bindEvents as BindEvent[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item?.name);
887
+ }
888
+ getBindEventUniqueName(name = 'bindEvent1') {
889
+ return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
890
+ }
891
+
892
+ /**
893
+ * 插入元素绑定事件
894
+ * @internal
895
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
896
+ */
897
+ _insertBindEventAt(name: string, index: number): BindEvent;
898
+
899
+ /**
900
+ * 插入元素绑定事件
901
+ * @internal
902
+ * @param bindEventOptions 元素绑定事件参数
903
+ */
904
+ _insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
905
+
906
+ /**
907
+ * 插入元素绑定事件
908
+ * @internal
909
+ * @param bindEvent 已有的元素绑定事件实例
910
+ */
911
+ _insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
912
+
913
+ _insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
914
+ const bindEventOptions: any = {};
915
+ const relationOptions = { parentNode: this, parentKey: 'bindEvents' };
916
+ const BindEvent = getConceptConstructor('BindEvent');
917
+ let bindEvent: BindEvent;
918
+ if (!options) {
919
+ bindEvent = BindEvent.from(
920
+ {
921
+ ...bindEventOptions,
922
+ name: this.getBindEventUniqueName(),
923
+ },
924
+ this,
925
+ 'bindEvents',
926
+ );
927
+ } else if (typeof options === 'string') {
928
+ bindEvent = BindEvent.from(
929
+ {
930
+ ...bindEventOptions,
931
+ name: options,
932
+ },
933
+ this,
934
+ 'bindEvents',
935
+ );
936
+ } else if (asserts.isBindEvent(options)) {
937
+ options.ensureDelete(); // 同一实例不支持多处存在
938
+ bindEvent = options;
939
+ Object.assign(bindEvent, relationOptions);
940
+ } else {
941
+ bindEvent = BindEvent.from(
942
+ {
943
+ ...bindEventOptions,
944
+ ...options,
945
+ },
946
+ this,
947
+ 'bindEvents',
948
+ );
949
+ }
950
+ this.bindEvents.splice(index, 0, bindEvent);
951
+ return bindEvent;
952
+ }
953
+
954
+ /**
955
+ * 插入元素绑定事件
956
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
957
+ */
958
+ insertBindEventAt(name: string, index: number): BindEvent;
959
+
960
+ /**
961
+ * 插入元素绑定事件
962
+ * @param bindEventOptions 元素绑定事件参数
963
+ */
964
+ insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
965
+
966
+ /**
967
+ * 插入元素绑定事件
968
+ * @param bindEvent 已有的元素绑定事件实例
969
+ */
970
+ insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
971
+
972
+ insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
973
+ const node = this._insertBindEventAt(options as any, index);
974
+ node.create({
975
+ index,
976
+ parentNode: this,
977
+ parentKey: 'bindEvents',
978
+ });
979
+ return node;
980
+ }
981
+
982
+ /**
983
+ * 添加元素绑定事件
984
+ * @internal
985
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
986
+ */
987
+ _addBindEvent(name?: string): BindEvent;
988
+
989
+ /**
990
+ * 添加元素绑定事件
991
+ * @internal
992
+ * @param bindEventOptions 元素绑定事件参数
993
+ */
994
+ _addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
995
+
996
+ /**
997
+ * 添加元素绑定事件
998
+ * @internal
999
+ * @param bindEvent 已有的元素绑定事件实例
1000
+ */
1001
+ _addBindEvent(bindEvent: BindEvent): BindEvent;
1002
+
1003
+ _addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
1004
+ const index = this.bindEvents.length;
1005
+ return this._insertBindEventAt(options as any, index);
1006
+ }
1007
+
1008
+ /**
1009
+ * 添加元素绑定事件
1010
+ * @internal
1011
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
1012
+ */
1013
+ addBindEvent(name?: string): BindEvent;
1014
+
1015
+ /**
1016
+ * 添加元素绑定事件
1017
+ * @param bindEventOptions 元素绑定事件参数
1018
+ */
1019
+ addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
1020
+
1021
+ /**
1022
+ * 添加元素绑定事件
1023
+ * @param bindEvent 已有的元素绑定事件实例
1024
+ */
1025
+ addBindEvent(bindEvent: BindEvent): BindEvent;
1026
+
1027
+ addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
1028
+ const node = this._addBindEvent(options as any);
1029
+ const index = this.bindEvents.indexOf(node);
1030
+ node.create({
1031
+ index,
1032
+ parentNode: this,
1033
+ parentKey: 'bindEvents',
1034
+ });
1035
+ return node;
1036
+ }
1037
+
1038
+ getLogicExistingNames(excludedList: Array<BusinessLogic> = []) {
1039
+ const excludedSet = new Set(excludedList);
1040
+ return ((this.logics as BusinessLogic[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item?.name);
1041
+ }
1042
+ getLogicUniqueName(name = 'logic1') {
1043
+ return utils.unique(name, this.getLogicExistingNames(), undefined, false);
1044
+ }
1045
+
1046
+ /**
1047
+ * 插入业务组件逻辑
1048
+ * @internal
1049
+ * @param name 业务组件逻辑名称,如果不填会自动生成一个唯一名称
1050
+ */
1051
+ _insertLogicAt(name: string, index: number): BusinessLogic;
1052
+
1053
+ /**
1054
+ * 插入业务组件逻辑
1055
+ * @internal
1056
+ * @param logicOptions 业务组件逻辑参数
1057
+ */
1058
+ _insertLogicAt(logicOptions: Partial<BusinessLogic>, index: number): BusinessLogic;
1059
+
1060
+ /**
1061
+ * 插入业务组件逻辑
1062
+ * @internal
1063
+ * @param logic 已有的业务组件逻辑实例
1064
+ */
1065
+ _insertLogicAt(logic: BusinessLogic, index: number): BusinessLogic;
1066
+
1067
+ _insertLogicAt(options: string | Partial<BusinessLogic> | BusinessLogic, index: number) {
1068
+ const logicOptions: any = {};
1069
+ const relationOptions = { parentNode: this, parentKey: 'logics' };
1070
+ const BusinessLogic = getConceptConstructor('BusinessLogic');
1071
+ let logic: BusinessLogic;
1072
+ if (!options) {
1073
+ logic = BusinessLogic.from(
1074
+ {
1075
+ ...logicOptions,
1076
+ name: this.getLogicUniqueName(),
1077
+ },
1078
+ this,
1079
+ 'logics',
1080
+ );
1081
+ } else if (typeof options === 'string') {
1082
+ logic = BusinessLogic.from(
1083
+ {
1084
+ ...logicOptions,
1085
+ name: options,
1086
+ },
1087
+ this,
1088
+ 'logics',
1089
+ );
1090
+ } else if (asserts.isBusinessLogic(options)) {
1091
+ options.ensureDelete(); // 同一实例不支持多处存在
1092
+ logic = options;
1093
+ Object.assign(logic, relationOptions);
1094
+ } else {
1095
+ logic = BusinessLogic.from(
1096
+ {
1097
+ ...logicOptions,
1098
+ ...options,
1099
+ },
1100
+ this,
1101
+ 'logics',
1102
+ );
1103
+ }
1104
+ this.logics.splice(index, 0, logic);
1105
+ return logic;
1106
+ }
1107
+
1108
+ /**
1109
+ * 插入业务组件逻辑
1110
+ * @param name 业务组件逻辑名称,如果不填会自动生成一个唯一名称
1111
+ */
1112
+ insertLogicAt(name: string, index: number): BusinessLogic;
1113
+
1114
+ /**
1115
+ * 插入业务组件逻辑
1116
+ * @param logicOptions 业务组件逻辑参数
1117
+ */
1118
+ insertLogicAt(logicOptions: Partial<BusinessLogic>, index: number): BusinessLogic;
1119
+
1120
+ /**
1121
+ * 插入业务组件逻辑
1122
+ * @param logic 已有的业务组件逻辑实例
1123
+ */
1124
+ insertLogicAt(logic: BusinessLogic, index: number): BusinessLogic;
1125
+
1126
+ insertLogicAt(options: string | Partial<BusinessLogic> | BusinessLogic, index: number) {
1127
+ const node = this._insertLogicAt(options as any, index);
1128
+ node.create({
1129
+ index,
1130
+ parentNode: this,
1131
+ parentKey: 'logics',
1132
+ });
1133
+ return node;
1134
+ }
1135
+
1136
+ /**
1137
+ * 添加业务组件逻辑
1138
+ * @internal
1139
+ * @param name 业务组件逻辑名称,如果不填会自动生成一个唯一名称
1140
+ */
1141
+ _addLogic(name?: string): BusinessLogic;
1142
+
1143
+ /**
1144
+ * 添加业务组件逻辑
1145
+ * @internal
1146
+ * @param logicOptions 业务组件逻辑参数
1147
+ */
1148
+ _addLogic(logicOptions: Partial<BusinessLogic>): BusinessLogic;
1149
+
1150
+ /**
1151
+ * 添加业务组件逻辑
1152
+ * @internal
1153
+ * @param logic 已有的业务组件逻辑实例
1154
+ */
1155
+ _addLogic(logic: BusinessLogic): BusinessLogic;
1156
+
1157
+ _addLogic(options?: string | Partial<BusinessLogic> | BusinessLogic) {
1158
+ const index = this.logics.length;
1159
+ return this._insertLogicAt(options as any, index);
1160
+ }
1161
+
1162
+ /**
1163
+ * 添加业务组件逻辑
1164
+ * @internal
1165
+ * @param name 业务组件逻辑名称,如果不填会自动生成一个唯一名称
1166
+ */
1167
+ addLogic(name?: string): BusinessLogic;
1168
+
1169
+ /**
1170
+ * 添加业务组件逻辑
1171
+ * @param logicOptions 业务组件逻辑参数
1172
+ */
1173
+ addLogic(logicOptions: Partial<BusinessLogic>): BusinessLogic;
1174
+
1175
+ /**
1176
+ * 添加业务组件逻辑
1177
+ * @param logic 已有的业务组件逻辑实例
1178
+ */
1179
+ addLogic(logic: BusinessLogic): BusinessLogic;
1180
+
1181
+ addLogic(options?: string | Partial<BusinessLogic> | BusinessLogic) {
1182
+ const node = this._addLogic(options as any);
1183
+ const index = this.logics.indexOf(node);
1184
+ node.create({
1185
+ index,
1186
+ parentNode: this,
1187
+ parentKey: 'logics',
1188
+ });
1189
+ return node;
1190
+ }
1191
+
1192
+ /**
1193
+ * 插入页面元素
1194
+ * @internal
1195
+ * @param name 页面元素名称,如果不填会自动生成一个唯一名称
1196
+ */
1197
+ _insertViewElementAt(name: string, index: number): ViewElement;
1198
+
1199
+ /**
1200
+ * 插入页面元素
1201
+ * @internal
1202
+ * @param viewElementOptions 页面元素参数
1203
+ */
1204
+ _insertViewElementAt(viewElementOptions: Partial<ViewElement>, index: number): ViewElement;
1205
+
1206
+ /**
1207
+ * 插入页面元素
1208
+ * @internal
1209
+ * @param viewElement 已有的页面元素实例
1210
+ */
1211
+ _insertViewElementAt(viewElement: ViewElement, index: number): ViewElement;
1212
+
1213
+ _insertViewElementAt(options: string | Partial<ViewElement> | ViewElement, index: number) {
1214
+ const viewElementOptions: any = {};
1215
+ const relationOptions = { parentNode: this, parentKey: 'elements' };
1216
+ const ViewElement = getConceptConstructor('ViewElement');
1217
+ let viewElement: ViewElement;
1218
+ if (!options) {
1219
+ viewElement = ViewElement.from(
1220
+ {
1221
+ ...viewElementOptions,
1222
+ name: this.getViewElementUniqueName(),
1223
+ },
1224
+ this,
1225
+ 'elements',
1226
+ );
1227
+ } else if (typeof options === 'string') {
1228
+ viewElement = ViewElement.from(
1229
+ {
1230
+ ...viewElementOptions,
1231
+ name: options,
1232
+ },
1233
+ this,
1234
+ 'elements',
1235
+ );
1236
+ } else if (asserts.isViewElement(options)) {
1237
+ options.ensureDelete(); // 同一实例不支持多处存在
1238
+ viewElement = options;
1239
+ Object.assign(viewElement, relationOptions);
1240
+ } else {
1241
+ viewElement = ViewElement.from(
1242
+ {
1243
+ ...viewElementOptions,
1244
+ ...options,
1245
+ },
1246
+ this,
1247
+ 'elements',
1248
+ );
1249
+ }
1250
+ this.elements.splice(index, 0, viewElement);
1251
+ return viewElement;
1252
+ }
1253
+
1254
+ /**
1255
+ * 插入页面元素
1256
+ * @param name 页面元素名称,如果不填会自动生成一个唯一名称
1257
+ */
1258
+ insertViewElementAt(name: string, index: number): ViewElement;
1259
+
1260
+ /**
1261
+ * 插入页面元素
1262
+ * @param viewElementOptions 页面元素参数
1263
+ */
1264
+ insertViewElementAt(viewElementOptions: Partial<ViewElement>, index: number): ViewElement;
1265
+
1266
+ /**
1267
+ * 插入页面元素
1268
+ * @param viewElement 已有的页面元素实例
1269
+ */
1270
+ insertViewElementAt(viewElement: ViewElement, index: number): ViewElement;
1271
+
1272
+ insertViewElementAt(options: string | Partial<ViewElement> | ViewElement, index: number) {
1273
+ const node = this._insertViewElementAt(options as any, index);
1274
+ node.create({
1275
+ index,
1276
+ parentNode: this,
1277
+ parentKey: 'elements',
1278
+ });
1279
+ return node;
1280
+ }
1281
+
1282
+ /**
1283
+ * 添加页面元素
1284
+ * @internal
1285
+ * @param name 页面元素名称,如果不填会自动生成一个唯一名称
1286
+ */
1287
+ _addViewElement(name?: string): ViewElement;
1288
+
1289
+ /**
1290
+ * 添加页面元素
1291
+ * @internal
1292
+ * @param viewElementOptions 页面元素参数
1293
+ */
1294
+ _addViewElement(viewElementOptions: Partial<ViewElement>): ViewElement;
1295
+
1296
+ /**
1297
+ * 添加页面元素
1298
+ * @internal
1299
+ * @param viewElement 已有的页面元素实例
1300
+ */
1301
+ _addViewElement(viewElement: ViewElement): ViewElement;
1302
+
1303
+ _addViewElement(options?: string | Partial<ViewElement> | ViewElement) {
1304
+ const index = this.elements.length;
1305
+ return this._insertViewElementAt(options as any, index);
1306
+ }
1307
+
1308
+ /**
1309
+ * 添加页面元素
1310
+ * @internal
1311
+ * @param name 页面元素名称,如果不填会自动生成一个唯一名称
1312
+ */
1313
+ addViewElement(name?: string): ViewElement;
1314
+
1315
+ /**
1316
+ * 添加页面元素
1317
+ * @param viewElementOptions 页面元素参数
1318
+ */
1319
+ addViewElement(viewElementOptions: Partial<ViewElement>): ViewElement;
1320
+
1321
+ /**
1322
+ * 添加页面元素
1323
+ * @param viewElement 已有的页面元素实例
1324
+ */
1325
+ addViewElement(viewElement: ViewElement): ViewElement;
1326
+
1327
+ addViewElement(options?: string | Partial<ViewElement> | ViewElement) {
1328
+ const node = this._addViewElement(options as any);
1329
+ const index = this.elements.indexOf(node);
1330
+ node.create({
1331
+ index,
1332
+ parentNode: this,
1333
+ parentKey: 'elements',
1334
+ });
1335
+ return node;
1336
+ }
1337
+
1338
+ /**
1339
+ * 删除组件事件
1340
+ * @param name 组件事件名称
1341
+ */
1342
+ removeEvent(name: string): void;
1343
+
1344
+ /**
1345
+ * 删除组件事件
1346
+ * @param event 已有的组件事件实例
1347
+ */
1348
+ removeEvent(event: Event): void;
1349
+
1350
+ removeEvent(options: string | Event) {
1351
+ let event: Event;
1352
+ if (typeof options === 'string') {
1353
+ event = (this.events as Event[]).find((item) => item.name === options);
1354
+ if (!event) {
1355
+ throw new Error('找不到组件事件 ' + options);
1356
+ }
1357
+ } else {
1358
+ event = options;
1359
+ }
1360
+ return event.delete();
1361
+ }
1362
+
1363
+ __removeEvent(event: Event) {
1364
+ const parentKey = event.parentKey;
1365
+ const params: Params = {
1366
+ parentNode: this,
1367
+ parentKey,
1368
+ index: -1,
1369
+ object: null,
1370
+ oldObject: event,
1371
+ };
1372
+ if (parentKey) {
1373
+ params.parentKey = parentKey;
1374
+ // @ts-ignore
1375
+ const t = this.__v_raw || this;
1376
+ // @ts-ignore
1377
+ const n = event.__v_raw || event;
1378
+ if (Array.isArray((t as any)[parentKey])) {
1379
+ // @ts-ignore
1380
+ const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
1381
+ ~index && (this as any)[parentKey].splice(index, 1);
1382
+ params.index = index;
1383
+ } else {
1384
+ const q = (t as any)[parentKey];
1385
+ if ((q.__v_raw || q) === n) {
1386
+ params.index = 0;
1387
+ (this as any)[parentKey] = undefined;
1388
+ }
1389
+ }
1390
+ }
1391
+ return params;
1392
+ }
1393
+
1394
+ /**
1395
+ * 删除参数分组
1396
+ * @param name 参数分组名称
1397
+ */
1398
+ removeParam(name: string): void;
1399
+
1400
+ /**
1401
+ * 删除参数分组
1402
+ * @param param 已有的参数分组实例
1403
+ */
1404
+ removeParam(param: ParamWithGroup): void;
1405
+
1406
+ removeParam(options: string | ParamWithGroup) {
1407
+ let param: ParamWithGroup;
1408
+ if (typeof options === 'string') {
1409
+ param = (this.params as ParamWithGroup[]).find((item) => item.name === options);
1410
+ if (!param) {
1411
+ throw new Error('找不到参数分组 ' + options);
1412
+ }
1413
+ } else {
1414
+ param = options;
1415
+ }
1416
+ return param.delete();
1417
+ }
1418
+
1419
+ __removeParam(param: Param) {
1420
+ const parentKey = param.parentKey;
1421
+ const params: Params = {
1422
+ parentNode: this,
1423
+ parentKey,
1424
+ index: -1,
1425
+ object: null,
1426
+ oldObject: param,
1427
+ };
1428
+ if (parentKey) {
1429
+ params.parentKey = parentKey;
1430
+ // @ts-ignore
1431
+ const t = this.__v_raw || this;
1432
+ // @ts-ignore
1433
+ const n = param.__v_raw || param;
1434
+ if (Array.isArray((t as any)[parentKey])) {
1435
+ // @ts-ignore
1436
+ const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
1437
+ ~index && (this as any)[parentKey].splice(index, 1);
1438
+ params.index = index;
1439
+ } else {
1440
+ const q = (t as any)[parentKey];
1441
+ if ((q.__v_raw || q) === n) {
1442
+ params.index = 0;
1443
+ (this as any)[parentKey] = undefined;
1444
+ }
1445
+ }
1446
+ }
1447
+ return params;
1448
+ }
1449
+
1450
+ /**
1451
+ * 删除变量
1452
+ * @param name 变量名称
1453
+ */
1454
+ removeVariable(name: string): void;
1455
+
1456
+ /**
1457
+ * 删除变量
1458
+ * @param variable 已有的变量实例
1459
+ */
1460
+ removeVariable(variable: Variable): void;
1461
+
1462
+ removeVariable(options: string | Variable) {
1463
+ let variable: Variable;
1464
+ if (typeof options === 'string') {
1465
+ variable = (this.variables as Variable[]).find((item) => item.name === options);
1466
+ if (!variable) {
1467
+ throw new Error('找不到变量 ' + options);
1468
+ }
1469
+ } else {
1470
+ variable = options;
1471
+ }
1472
+ return variable.delete();
1473
+ }
1474
+
1475
+ __removeVariable(variable: Variable) {
1476
+ const parentKey = variable.parentKey;
1477
+ const params: Params = {
1478
+ parentNode: this,
1479
+ parentKey,
1480
+ index: -1,
1481
+ object: null,
1482
+ oldObject: variable,
1483
+ };
1484
+ if (parentKey) {
1485
+ params.parentKey = parentKey;
1486
+ // @ts-ignore
1487
+ const t = this.__v_raw || this;
1488
+ // @ts-ignore
1489
+ const n = variable.__v_raw || variable;
1490
+ if (Array.isArray((t as any)[parentKey])) {
1491
+ // @ts-ignore
1492
+ const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
1493
+ ~index && (this as any)[parentKey].splice(index, 1);
1494
+ params.index = index;
1495
+ } else {
1496
+ const q = (t as any)[parentKey];
1497
+ if ((q.__v_raw || q) === n) {
1498
+ params.index = 0;
1499
+ (this as any)[parentKey] = undefined;
1500
+ }
1501
+ }
1502
+ }
1503
+ return params;
1504
+ }
1505
+
1506
+ /**
1507
+ * 删除元素绑定事件
1508
+ * @param name 元素绑定事件名称
1509
+ */
1510
+ removeBindEvent(name: string): void;
1511
+
1512
+ /**
1513
+ * 删除元素绑定事件
1514
+ * @param bindEvent 已有的元素绑定事件实例
1515
+ */
1516
+ removeBindEvent(bindEvent: BindEvent): void;
1517
+
1518
+ removeBindEvent(options: string | BindEvent) {
1519
+ let bindEvent: BindEvent;
1520
+ if (typeof options === 'string') {
1521
+ bindEvent = (this.bindEvents as BindEvent[]).find((item) => item.name === options);
1522
+ if (!bindEvent) {
1523
+ throw new Error('找不到元素绑定事件 ' + options);
1524
+ }
1525
+ } else {
1526
+ bindEvent = options;
1527
+ }
1528
+ return bindEvent.delete();
1529
+ }
1530
+
1531
+ __removeBindEvent(bindEvent: BindEvent) {
1532
+ const parentKey = bindEvent.parentKey;
1533
+ const params: Params = {
1534
+ parentNode: this,
1535
+ parentKey,
1536
+ index: -1,
1537
+ object: null,
1538
+ oldObject: bindEvent,
1539
+ };
1540
+ if (parentKey) {
1541
+ params.parentKey = parentKey;
1542
+ // @ts-ignore
1543
+ const t = this.__v_raw || this;
1544
+ // @ts-ignore
1545
+ const n = bindEvent.__v_raw || bindEvent;
1546
+ if (Array.isArray((t as any)[parentKey])) {
1547
+ // @ts-ignore
1548
+ const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
1549
+ ~index && (this as any)[parentKey].splice(index, 1);
1550
+ params.index = index;
1551
+ } else {
1552
+ const q = (t as any)[parentKey];
1553
+ if ((q.__v_raw || q) === n) {
1554
+ params.index = 0;
1555
+ (this as any)[parentKey] = undefined;
1556
+ }
1557
+ }
1558
+ }
1559
+ return params;
1560
+ }
1561
+
1562
+ /**
1563
+ * 删除业务组件逻辑
1564
+ * @param name 业务组件逻辑名称
1565
+ */
1566
+ removeLogic(name: string): void;
1567
+
1568
+ /**
1569
+ * 删除业务组件逻辑
1570
+ * @param logic 已有的业务组件逻辑实例
1571
+ */
1572
+ removeLogic(logic: BusinessLogic): void;
1573
+
1574
+ removeLogic(options: string | BusinessLogic) {
1575
+ let logic: BusinessLogic;
1576
+ if (typeof options === 'string') {
1577
+ logic = (this.logics as BusinessLogic[]).find((item) => item.name === options);
1578
+ if (!logic) {
1579
+ throw new Error('找不到业务组件逻辑 ' + options);
1580
+ }
1581
+ } else {
1582
+ logic = options;
1583
+ }
1584
+ return logic.delete();
1585
+ }
1586
+
1587
+ __removeLogic(logic: Logic) {
1588
+ const parentKey = logic.parentKey;
1589
+ const params: Params = {
1590
+ parentNode: this,
1591
+ parentKey,
1592
+ index: -1,
1593
+ object: null,
1594
+ oldObject: logic,
1595
+ };
1596
+ if (parentKey) {
1597
+ params.parentKey = parentKey;
1598
+ // @ts-ignore
1599
+ const t = this.__v_raw || this;
1600
+ // @ts-ignore
1601
+ const n = logic.__v_raw || logic;
1602
+ if (Array.isArray((t as any)[parentKey])) {
1603
+ // @ts-ignore
1604
+ const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
1605
+ ~index && (this as any)[parentKey].splice(index, 1);
1606
+ params.index = index;
1607
+ } else {
1608
+ const q = (t as any)[parentKey];
1609
+ if ((q.__v_raw || q) === n) {
1610
+ params.index = 0;
1611
+ (this as any)[parentKey] = undefined;
1612
+ }
1613
+ }
1614
+ }
1615
+ return params;
1616
+ }
1617
+
1618
+ /**
1619
+ * 删除页面元素
1620
+ * @param name 页面元素名称
1621
+ */
1622
+ removeViewElement(name: string): void;
1623
+
1624
+ /**
1625
+ * 删除页面元素
1626
+ * @param viewElement 已有的页面元素实例
1627
+ */
1628
+ removeViewElement(viewElement: ViewElement): void;
1629
+
1630
+ removeViewElement(options: string | ViewElement) {
1631
+ let viewElement: ViewElement;
1632
+ if (typeof options === 'string') {
1633
+ viewElement = (this.elements as ViewElement[]).find((item) => item.name === options);
1634
+ if (!viewElement) {
1635
+ throw new Error('找不到页面元素 ' + options);
1636
+ }
1637
+ } else {
1638
+ viewElement = options;
1639
+ }
1640
+ return viewElement.delete();
1641
+ }
1642
+
1643
+ __removeViewElement(viewElement: ViewElement) {
1644
+ const parentKey = viewElement.parentKey;
1645
+ const params: Params = {
1646
+ parentNode: this,
1647
+ parentKey,
1648
+ index: -1,
1649
+ object: null,
1650
+ oldObject: viewElement,
1651
+ };
1652
+ if (parentKey) {
1653
+ params.parentKey = parentKey;
1654
+ // @ts-ignore
1655
+ const t = this.__v_raw || this;
1656
+ // @ts-ignore
1657
+ const n = viewElement.__v_raw || viewElement;
1658
+ if (Array.isArray((t as any)[parentKey])) {
1659
+ // @ts-ignore
1660
+ const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
1661
+ ~index && (this as any)[parentKey].splice(index, 1);
1662
+ params.index = index;
1663
+ } else {
1664
+ const q = (t as any)[parentKey];
1665
+ if ((q.__v_raw || q) === n) {
1666
+ params.index = 0;
1667
+ (this as any)[parentKey] = undefined;
1668
+ }
1669
+ }
1670
+ }
1671
+ return params;
1672
+ }
1673
+
1674
+ //================================================================================
1675
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1676
+ // 自动生成的代码已结束。下面可以手动编写。
1677
+ //================================================================================
1678
+ static getDefaultOptions() {
1679
+ return {
1680
+ title: '业务组件',
1681
+ };
1682
+ }
1683
+
1684
+ getNamespace(): string {
1685
+ if (this.parentNode && (this.parentNode as FrontendType).getNamespace) {
1686
+ const parentNamespace = (this.parentNode as FrontendType).getNamespace();
1687
+ const parentName = this.parentNode.name;
1688
+ const arr = [parentNamespace];
1689
+ if (this.parentNode.concept !== 'App' && parentName) {
1690
+ arr.push(parentName);
1691
+ }
1692
+ return `${arr.join('.')}.businessComponents`;
1693
+ }
1694
+ throw new Error('无法获取命名空间,请设置 parentNode!');
1695
+ }
1696
+
1697
+ getTsNamespace() {
1698
+ const parentNodeNamespace = this.getNamespace();
1699
+ let tsCalleeNamespace = parentNodeNamespace.replace(/\.[0-9]/g, (m) => m.replace('.', '.$'));
1700
+ tsCalleeNamespace = tsCalleeNamespace.replace(/-/g, '_');
1701
+ return tsCalleeNamespace;
1702
+ }
1703
+
1704
+ /**
1705
+ * 获取当前业务组件下所有elements上bindEvents下的logic
1706
+ */
1707
+ elementLogicRoot: any[] = [];
1708
+
1709
+ getElementLogicRoot() {
1710
+ const Param = getConceptConstructor('Param');
1711
+ const logics: Array<Logic> = [];
1712
+ // 页面上的绑定的事件
1713
+ this.bindEvents.forEach((bindEvent) => {
1714
+ bindEvent.logics.forEach((logic) => {
1715
+ // 键盘事件
1716
+ if (['keydown', 'keyup'].includes(bindEvent.name)) {
1717
+ logic.virtualParams = [
1718
+ Param.from(
1719
+ {
1720
+ name: 'event',
1721
+ typeAnnotation: null,
1722
+ },
1723
+ logic,
1724
+ 'virtualParams',
1725
+ ),
1726
+ ];
1727
+ }
1728
+ // 生命周期没有event
1729
+ logics.push(logic);
1730
+ });
1731
+ });
1732
+ this.elements.forEach((item) => {
1733
+ utils.traverse(
1734
+ (current) => {
1735
+ current.node.bindEvents.forEach((bindEvent) => {
1736
+ bindEvent.logics.forEach((logic) => {
1737
+ if (logic.name.startsWith('__')) {
1738
+ return;
1739
+ }
1740
+ // 绑定参数才有 event 的 current
1741
+ logic.virtualParams = bindEvent.getContextRenderLogicParams(logic);
1742
+ logics.push(logic);
1743
+ });
1744
+ });
1745
+ },
1746
+ { node: item },
1747
+ );
1748
+ });
1749
+ if (logics.length) {
1750
+ const expanded = (this.elementLogicRoot.length && this.elementLogicRoot[0].expanded) || false;
1751
+ this.elementLogicRoot = [
1752
+ {
1753
+ concept: 'elementLogicRoot',
1754
+ expanded,
1755
+ children: logics,
1756
+ },
1757
+ ];
1758
+ } else {
1759
+ this.elementLogicRoot = [];
1760
+ }
1761
+ }
1762
+
1763
+ getVarExistingNames(excludedList: Array<Param | Variable> = []) {
1764
+ const excludedSet = new Set(excludedList);
1765
+ const varList: any[] = [];
1766
+ if (Array.isArray(this.params)) {
1767
+ varList.push(...this.params);
1768
+ }
1769
+ if (Array.isArray(this.variables)) {
1770
+ varList.push(...this.variables);
1771
+ }
1772
+ if (Array.isArray(this.logics)) {
1773
+ this.logics.forEach((logic) => {
1774
+ varList.push(logic);
1775
+ if (Array.isArray(logic.params)) {
1776
+ varList.push(...logic.params);
1777
+ }
1778
+ if (Array.isArray(logic.returns)) {
1779
+ varList.push(...logic.returns);
1780
+ }
1781
+ if (Array.isArray(logic.variables)) {
1782
+ varList.push(...logic.variables);
1783
+ }
1784
+ });
1785
+ }
1786
+ // 事件逻辑的变量不允许和页面逻辑下的重复
1787
+ if (Array.isArray(this.elementLogicRoot) && this.elementLogicRoot.length) {
1788
+ this.elementLogicRoot[0]?.children.forEach((logic: Logic) => {
1789
+ if (Array.isArray(logic.variables)) {
1790
+ varList.push(...logic.variables);
1791
+ }
1792
+ });
1793
+ }
1794
+ return varList.filter((item) => !excludedSet.has(item)).map((item) => item.name);
1795
+ }
1796
+
1797
+ existingViewElement: Set<string> = new Set<string>();
1798
+
1799
+ // 收集已经存在的ViewElement
1800
+ collectExistingViewElementName(excludedList: Array<ViewElement> = []) {
1801
+ const excludedSet = new Set(excludedList);
1802
+ this.elements.forEach((element) => {
1803
+ utils.traverse(
1804
+ ({ node }) => {
1805
+ if (!excludedSet.has(node)) {
1806
+ this.existingViewElement.add(node.name);
1807
+ }
1808
+ },
1809
+ {
1810
+ node: element,
1811
+ },
1812
+ );
1813
+ });
1814
+ }
1815
+
1816
+ // 获取当前业务组件的所有组件的名字
1817
+ getViewElementExistingNames(excludedList: Array<ViewElement> = []) {
1818
+ if (!this.existingViewElement.size) {
1819
+ this.collectExistingViewElementName();
1820
+ }
1821
+ return Array.from(this.existingViewElement);
1822
+ }
1823
+
1824
+ getViewElementUniqueNameOld(name = 'viewElement1') {
1825
+ this.collectExistingViewElementName();
1826
+ const viewElementUniqueName = utils.unique(name, this.existingViewElement);
1827
+ this.existingViewElement.add(viewElementUniqueName);
1828
+ return viewElementUniqueName;
1829
+ }
1830
+
1831
+ getViewElementUniqueName(name = 'viewElement_1') {
1832
+ this.collectExistingViewElementName();
1833
+ const BranchCopyUniCode = getBranchCopyUniCode();
1834
+ let newName = name;
1835
+ const prefix = name.replace(/\d*$/, '');
1836
+ if (BranchCopyUniCode && prefix.indexOf(`_${BranchCopyUniCode}_`) === -1) {
1837
+ newName = name.replace(/\d*$/, (m) => `_${BranchCopyUniCode}_${m}`);
1838
+ }
1839
+ // 主分支无 BranchCopyUniCode
1840
+ if (!BranchCopyUniCode && prefix.at(-1) !== '_') {
1841
+ newName = name.replace(/\d*$/, (m) => `_${m}`);
1842
+ }
1843
+ const newPrefix = newName.replace(/\d*$/, '');
1844
+ const newPrefixNum = removedViewElementCache?.[newPrefix] ? removedViewElementCache[newPrefix] : 1;
1845
+ const startNum =
1846
+ newPrefixNum < Number.MAX_SAFE_INTEGER ? (newPrefixNum as number) + 1 : BigInt(newPrefixNum) + BigInt(1);
1847
+ const viewElementUniqueName = utils.uniqueMax(
1848
+ newName,
1849
+ this.existingViewElement,
1850
+ removedViewElementCache?.[newPrefix] ? startNum : newPrefixNum,
1851
+ );
1852
+ this.existingViewElement.add(viewElementUniqueName);
1853
+ return viewElementUniqueName;
1854
+ }
1855
+
1856
+ // 获取当前element,铺平
1857
+ elementsMethods(elements: Array<ViewElement>, allMethods: Array<ViewElement>, parentNodeNames: Array<string>) {
1858
+ if (elements) {
1859
+ elements.forEach((item: ViewElement) => {
1860
+ const { bindAttrs = [], name } = item;
1861
+ const isDataSource = bindAttrs.some((attr) => attr.name === 'data-source');
1862
+ const isInclude = parentNodeNames.includes(name);
1863
+
1864
+ allMethods.push(item);
1865
+ if (item.children) {
1866
+ if (isDataSource) {
1867
+ if (isInclude) {
1868
+ this.elementsMethods(item.children, allMethods, parentNodeNames);
1869
+ }
1870
+ } else {
1871
+ this.elementsMethods(item.children, allMethods, parentNodeNames);
1872
+ }
1873
+ }
1874
+ });
1875
+ }
1876
+ }
1877
+
1878
+ mergeBlock({ code, nodePath, position, cb }: { code: string; nodePath: string; position: string; cb?: Function }) {
1879
+ const ViewElement = getConceptConstructor('ViewElement');
1880
+ const Logic = getConceptConstructor('Logic');
1881
+ const ParamWithGroup = getConceptConstructor('ParamWithGroup');
1882
+ const Variable = getConceptConstructor('Variable');
1883
+ const BindEvent = getConceptConstructor('BindEvent');
1884
+ const Structure = getConceptConstructor('Structure');
1885
+ const template = utils.sliceTagContent(code, 'template');
1886
+ let targetNode = (this.getAncestor('App') as App)?.findNodeByPath(nodePath);
1887
+ let parentNode = position === 'append' ? targetNode : targetNode.parentNode;
1888
+ const definitionStr = utils.sliceTagContent(code, 'definition') || '{}';
1889
+ const definition: any = JSON.parse(definitionStr);
1890
+ let node = null;
1891
+ if (template) {
1892
+ node = ViewElement.fromHTML(template, {
1893
+ view: this,
1894
+ definition,
1895
+ });
1896
+ if (!parentNode) {
1897
+ return;
1898
+ }
1899
+ if (position === 'append') {
1900
+ parentNode.addViewElement(node);
1901
+ cb && cb(parentNode, node);
1902
+ } else {
1903
+ const index = targetNode.getIndexOfParent();
1904
+ if (position === 'insertBefore') {
1905
+ parentNode.insertViewElementAt(node, index);
1906
+ } else if (position === 'insertAfter') {
1907
+ parentNode.insertViewElementAt(node, index + 1);
1908
+ }
1909
+ }
1910
+ }
1911
+
1912
+ // 服务端逻辑
1913
+ if (Array.isArray(definition.logics)) {
1914
+ definition.logics.forEach((logicOption: any) => {
1915
+ const logic = Logic.from(
1916
+ {
1917
+ ...logicOption,
1918
+ },
1919
+ this.rootNode,
1920
+ 'logics',
1921
+ );
1922
+ (this.rootNode as App).addLogic(logic);
1923
+ });
1924
+ }
1925
+
1926
+ // 全局结构体
1927
+ if (Array.isArray(definition.structures)) {
1928
+ definition.structures.forEach((structureOption: any) => {
1929
+ const structure = Structure.from(
1930
+ {
1931
+ ...structureOption,
1932
+ },
1933
+ this.rootNode,
1934
+ 'structures',
1935
+ );
1936
+ (this.rootNode as App).addStructure(structure);
1937
+ });
1938
+ }
1939
+
1940
+ // 页面入参
1941
+ if (Array.isArray(definition.viewParams)) {
1942
+ definition.viewParams.forEach((paramsOption: any) => {
1943
+ const param = ParamWithGroup.from(
1944
+ {
1945
+ ...paramsOption,
1946
+ },
1947
+ this,
1948
+ 'params',
1949
+ );
1950
+ this._addParam(param);
1951
+ param.addParamsPrepare();
1952
+ });
1953
+ }
1954
+ // 页面变量
1955
+ if (Array.isArray(definition.viewVariables)) {
1956
+ definition.viewVariables.forEach((variableOption: any) => {
1957
+ const variable = Variable.from(
1958
+ {
1959
+ ...variableOption,
1960
+ },
1961
+ this,
1962
+ 'variables',
1963
+ );
1964
+ this.addVariable(variable);
1965
+ });
1966
+ }
1967
+
1968
+ // 页面事件
1969
+ if (Array.isArray(definition.viewBindEvents)) {
1970
+ definition.viewBindEvents.forEach((eventOption: any) => {
1971
+ const newLogic = definition.viewLogics.find((logic: Logic) => eventOption.calleeName === logic.name);
1972
+ const bindEvent = this.bindEvents.find((currentEventItem) => currentEventItem.name === eventOption.name);
1973
+
1974
+ // 如果没有event对象就先新增一个,如果已经有了就在内部添加logic
1975
+ if (!bindEvent) {
1976
+ const event = BindEvent.from(
1977
+ {
1978
+ ...eventOption,
1979
+ calleeName: '',
1980
+ logics: [newLogic],
1981
+ },
1982
+ this,
1983
+ 'events',
1984
+ );
1985
+ this.addBindEvent(event);
1986
+ } else {
1987
+ bindEvent.addLogic(newLogic);
1988
+ }
1989
+ });
1990
+ }
1991
+ return node;
1992
+ }
1993
+
1994
+ onChange($event?: EventPayload): void {
1995
+ this.emit('change', $event);
1996
+ }
1997
+
1998
+ /**
1999
+ * 转换成设计器中使用的 Vue template 内容
2000
+ * @param options
2001
+ */
2002
+ genDesignerVueTemplate(options?: { asCompontent?: boolean }) {
2003
+ return this.elements
2004
+ .map(
2005
+ (element) =>
2006
+ `${element.toDesignerVue({
2007
+ isRoot: true,
2008
+ asCompontent: options?.asCompontent,
2009
+ })}\n`,
2010
+ )
2011
+ .join('');
2012
+ }
2013
+
2014
+ get frontendType() {
2015
+ return this.getAncestor('FrontendType') as FrontendType;
2016
+ }
2017
+
2018
+ get path() {
2019
+ return `/${this.frontendType?.kind}/${this.name}`;
2020
+ }
2021
+
2022
+ get slotElems() {
2023
+ const slotElems: ViewElement[] = [];
2024
+ this.elements.forEach((element) => {
2025
+ utils.traverse(
2026
+ ({ node }) => {
2027
+ if (node.tag === 'slot') {
2028
+ slotElems.push(node);
2029
+ }
2030
+ },
2031
+ {
2032
+ node: element,
2033
+ },
2034
+ );
2035
+ });
2036
+ return slotElems;
2037
+ }
2038
+
2039
+ /**
2040
+ * 生成宿主语言的文件路径
2041
+ * @param name 一般不用传,用于 rename
2042
+ */
2043
+ getEmbeddedFilePath(name = this.name) {
2044
+ return `/embedded/${this.rootNode?.name || this.parentNode.name}/frontendTypes/${this.getAncestor('FrontendType')?.name
2045
+ }/${name}.ts`;
2046
+ }
2047
+
2048
+ *toEmbeddedTSFile(): EmbeddedTSFileGenerator {
2049
+ let code = `namespace ${this.getTsNamespace()} {\n`;
2050
+ const state = createCompilerState(code, {
2051
+ tabSize: 1,
2052
+ });
2053
+
2054
+ try {
2055
+ code += yield* this.toEmbeddedTS(state);
2056
+ } catch (err) {
2057
+ code += '';
2058
+ console.log(err);
2059
+ }
2060
+
2061
+ code += '}\n';
2062
+
2063
+ return {
2064
+ code,
2065
+ filePath: this.getEmbeddedFilePath(),
2066
+ sourceMap: state.sourceMap,
2067
+ };
2068
+ }
2069
+
2070
+ getAncestorViewElementsWithDataSource(logic: Logic): ViewElement[] {
2071
+ let element: types.SyntaxNode = logic;
2072
+ const viewElements: ViewElement[] = [];
2073
+ while (element) {
2074
+ if (
2075
+ element.concept &&
2076
+ element.concept === 'ViewElement' &&
2077
+ (element as ViewElement).bindAttrs.find((bAttr) => bAttr.name === 'data-source')
2078
+ ) {
2079
+ viewElements.push(element as ViewElement);
2080
+ }
2081
+ element = element.parentNode;
2082
+ }
2083
+ return viewElements;
2084
+ }
2085
+
2086
+ *handleCurrentItemCode(code: string, logic: Logic) {
2087
+ const viewElementsWithDataSource: ViewElement[] = this.getAncestorViewElementsWithDataSource(logic);
2088
+ yield* wrapForEach(viewElementsWithDataSource, function* wrapForEach(viewElement, index) {
2089
+ const currentIndex = viewElementsWithDataSource.length - 1 - index;
2090
+ const currentItemCode = `current${currentIndex === 0 ? '' : currentIndex}.item`;
2091
+ if (code.includes(currentItemCode)) {
2092
+ const dataSource = viewElement.bindAttrs.find((bAttr) => bAttr.name === 'data-source');
2093
+ if (dataSource) {
2094
+ const businessComponent = viewElement.getAncestor('BusinessComponent') as BusinessComponent;
2095
+ const dataSourceTS = yield* dataSource.expression.toEmbeddedTS();
2096
+ const logic = businessComponent.logics.find((logic) => logic.name === dataSourceTS);
2097
+ if (logic) {
2098
+ code = code.replaceAll(
2099
+ currentItemCode,
2100
+ `nasl.ui.getCurrentItemType(${dataSourceTS}(${logic.params.map(() => 'null').join(',')}))`,
2101
+ );
2102
+ } else {
2103
+ const variable = businessComponent.variables.find((variable) => variable.name === dataSourceTS);
2104
+ code = code.replaceAll(
2105
+ currentItemCode,
2106
+ `nasl.ui.getCurrentItemType(${variable ? variable.name : dataSourceTS})`,
2107
+ );
2108
+ }
2109
+ }
2110
+ }
2111
+ });
2112
+ return code;
2113
+ }
2114
+
2115
+ removeExistingViewElement(viewElement: ViewElement) {
2116
+ if (this.existingViewElement.has(viewElement.name)) {
2117
+ this.existingViewElement.delete(viewElement.name);
2118
+ }
2119
+
2120
+ const prefix = viewElement?.name.replace(/\d*$/, '');
2121
+ let lastDigit = viewElement?.name.match(/\d+$/)?.[0];
2122
+ if (lastDigit === undefined) return;
2123
+
2124
+ //@ts-ignore
2125
+ lastDigit = lastDigit < Number.MAX_SAFE_INTEGER ? parseInt(lastDigit) : BigInt(lastDigit);
2126
+
2127
+ if (removedViewElementCache?.[prefix]) {
2128
+ //@ts-ignore
2129
+ if (lastDigit > removedViewElementCache[prefix])
2130
+ //@ts-ignore
2131
+ removedViewElementCache[prefix] = lastDigit;
2132
+ } else {
2133
+ //@ts-ignore
2134
+ removedViewElementCache[prefix] = lastDigit;
2135
+ }
2136
+ }
2137
+
2138
+ *getRightCode(code: string, assignment: Assignment | BatchAssignment, rightNode: any) {
2139
+ code = code.replaceAll('\n', ' ');
2140
+ const logic = assignment.logic;
2141
+ const logicRtn = logic?.returns[0];
2142
+ // 调用接口,参数替换成 null
2143
+ if (asserts.isCallInterface(rightNode)) {
2144
+ const { _interface } = rightNode.getModuleInterface();
2145
+ return _interface
2146
+ ? `${rightNode.tsCalleeKey}(${(_interface as Interface).params.map(() => 'null').join(',')})`
2147
+ : null;
2148
+ }
2149
+
2150
+ // 调用服务端逻辑,参数替换成 null
2151
+ if (asserts.isCallLogic(rightNode) && rightNode.calleeNamespace === 'app.logics') {
2152
+ const calleeName = rightNode?.calleeName;
2153
+ const calleeLogic = (this.getAncestor('App') as App).logics.find((l) => l.name === calleeName);
2154
+ return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
2155
+ }
2156
+
2157
+ // view 局部变量,申明提升前增加判断,使用 logic 内的 result 直接替换成对应 logic,logic 内部变量替换成 null
2158
+ if (logicRtn && code.includes(logicRtn.name)) {
2159
+ if (code === logicRtn.name) return `${logic.name}(${logic.params.map(() => 'null').join(',')})`;
2160
+
2161
+ code = this.handleReplaceCode(code, logicRtn.name, `${logic.name}(${logic.params.map(() => 'null').join(',')})`);
2162
+ logic.params.forEach((param) => {
2163
+ if (code.includes(param.name)) code = this.handleReplaceCode(code, param.name, 'null');
2164
+ });
2165
+ logic.variables.forEach((variable) => {
2166
+ if (code.includes(variable.name)) code = this.handleReplaceCode(code, variable.name, 'null');
2167
+ });
2168
+ return code;
2169
+ }
2170
+
2171
+ // 处理 current.item、current1.item 等数据
2172
+ if (/current(\d)*\.item/.test(code)) {
2173
+ code = yield* this.handleCurrentItemCode(code, logic);
2174
+ return code;
2175
+ }
2176
+
2177
+ // 直接赋值 logic 内局部变量、输入参数直接提示系统无法推断类型
2178
+ const useLogicVar =
2179
+ logic.params.find((param) => code.includes(param.name)) ||
2180
+ logic.variables.find((variable) => code.includes(variable.name));
2181
+ return useLogicVar ? 'null' : code;
2182
+ }
2183
+
2184
+ handleReplaceCode(code: string, variable: string, replaceCode: string) {
2185
+ return code.replace(/\S+/g, ($1) => {
2186
+ if ($1 === `${variable},`) return `${replaceCode},`;
2187
+ if ($1 === variable) return replaceCode;
2188
+
2189
+ let fnCode = $1;
2190
+ if ($1.startsWith(`${variable}.`)) fnCode = $1.replaceAll(`${variable}.`, `${replaceCode}.`);
2191
+ if ($1.startsWith(`${variable},`)) fnCode = $1.replaceAll(`${variable},`, `${replaceCode},`);
2192
+ if ($1.includes(`(${variable},`)) fnCode = $1.replaceAll(`(${variable},`, `(${replaceCode},`);
2193
+ if ($1.includes(`(${variable}.`)) fnCode = $1.replaceAll(`(${variable}.`, `(${replaceCode}.`);
2194
+ if ($1.includes(`(${variable})`)) fnCode = $1.replaceAll(`(${variable})`, `(${replaceCode})`);
2195
+ if ($1.includes(`,${variable},`)) fnCode = $1.replaceAll(`,${variable},`, `,${replaceCode},`);
2196
+ if ($1.includes(`,${variable}.`)) fnCode = $1.replaceAll(`,${variable}.`, `,${replaceCode}.`);
2197
+ if ($1.includes(`,${variable})`)) fnCode = $1.replaceAll(`,${variable})`, `,${replaceCode})`);
2198
+ return fnCode;
2199
+ });
2200
+ }
2201
+
2202
+ // 获取当前element,铺平
2203
+ elementsAttrs(elements: Array<ViewElement>, componentList: Array<ViewElement>) {
2204
+ if (elements) {
2205
+ elements.forEach((item: ViewElement) => {
2206
+ if (PAGE_COMPONENT_INCLUDE_TAG_MAP?.[item.tag]) {
2207
+ componentList.push(item);
2208
+ }
2209
+ if (item.children.length > 0) {
2210
+ this.elementsAttrs(item.children, componentList);
2211
+ }
2212
+ });
2213
+ }
2214
+ }
2215
+
2216
+ elementsAttrsAll(elements: Array<ViewElement>, componentListExtra: Array<ViewElement>) {
2217
+ if (elements) {
2218
+ elements.forEach((item: ViewElement) => {
2219
+ if (!PAGE_COMPONENT_INCLUDE_TAG_MAP?.[item.tag]) {
2220
+ componentListExtra.push(item);
2221
+ }
2222
+ if (item.children.length > 0) {
2223
+ this.elementsAttrsAll(item.children, componentListExtra);
2224
+ }
2225
+ });
2226
+ }
2227
+ }
2228
+
2229
+ @withSourceMapGenerator
2230
+ *toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
2231
+ const self = this;
2232
+ // 获取虚拟logic的参数和内容
2233
+ // 用作展示和tots查找引用
2234
+ self.getElementLogicRoot();
2235
+ let code = `export class ${self.tsName} extends nasl.ui.VueComponent {\n`;
2236
+ // 需要类型推导的局部变量/返回值需要调整申明顺序
2237
+ code += `constructor(
2238
+ options?: {
2239
+ [propname: string]: any,
2240
+ bindAttr?: {
2241
+ __NASLIF?: nasl.core.Boolean,
2242
+ `;
2243
+ if (Array.isArray(self.params)) {
2244
+ yield* wrapForEach(self.params, function* warpForEachGenerator(param, index) {
2245
+ code += `${param.name}?: `;
2246
+ code += yield* param.typeAnnotation.toEmbeddedTS(shiftState(state, code));
2247
+ code += ',\n';
2248
+ });
2249
+ }
2250
+ code += `
2251
+ },
2252
+ slotDefault?: () => Array<any>,
2253
+ }) {
2254
+ super();\n`;
2255
+
2256
+ // 绑定事件
2257
+ if (Array.isArray(self.bindEvents)) {
2258
+ yield* wrapForEach(self.bindEvents, function* warpForEachGenerator(event) {
2259
+ code += yield* event.toEmbeddedTS(
2260
+ shiftState(state, code, {
2261
+ tabSize: state?.tabSize || 0,
2262
+ }),
2263
+ true,
2264
+ );
2265
+ code += '\n';
2266
+ });
2267
+ }
2268
+ code += `\n}`;
2269
+ // 自定义事件的定义
2270
+ if (Array.isArray(self.events) && self.events.length) {
2271
+ code += indent((state?.tabSize || 0) + 1);
2272
+ yield* wrapForEach(self.events, function* warpForEachGenerator(event) {
2273
+ code += yield* event.toEmbeddedTS(
2274
+ shiftState(state, code, {
2275
+ tabSize: (state?.tabSize || 0) + 2,
2276
+ }),
2277
+ );
2278
+ code += '\n';
2279
+ });
2280
+ code += indent((state?.tabSize || 0) + 1);
2281
+ }
2282
+ // 逻辑
2283
+ if (Array.isArray(self.logics) && self.logics.length) {
2284
+ code += indent((state?.tabSize || 0) + 1);
2285
+ yield* wrapForEach(self.logics, function* warpForEachGenerator(logic) {
2286
+ code += yield* logic.toEmbeddedTS(
2287
+ shiftState(state, code, {
2288
+ tabSize: (state?.tabSize || 0) + 2,
2289
+ }),
2290
+ 'noExport',
2291
+ );
2292
+ code += '\n';
2293
+ });
2294
+ code += indent((state?.tabSize || 0) + 1);
2295
+ }
2296
+ // render函数
2297
+ code += `\n${indent((state?.tabSize || 0) + 1)}`;
2298
+ code += `__render(`;
2299
+ code += `){\n`;
2300
+ code += indent(state?.tabSize || 0);
2301
+ // elements 元素
2302
+ if (Array.isArray(self.elements)) {
2303
+ // 生成嵌套式的内容
2304
+ yield* wrapForEach(self.elements, function* warpForEachGenerator(element) {
2305
+ code += yield* element.toEmbeddedTS(
2306
+ shiftState(state, code, {
2307
+ tabSize: (state?.tabSize || 0) + 3,
2308
+ }),
2309
+ );
2310
+ code += '\n';
2311
+ });
2312
+ }
2313
+ code += `\n${indent((state?.tabSize || 0) + 1)}}\n`;
2314
+ if (Array.isArray(self.params)) {
2315
+ code += `${indent((state?.tabSize || 0) + 1)}$destination(options: {`;
2316
+ yield* wrapForEach(self.params, function* warpForEachGenerator(param, index) {
2317
+ code += `${param.name}?: `;
2318
+ code += yield* param.typeAnnotation.toEmbeddedTS(shiftState(state, code));
2319
+ code += ', ';
2320
+ });
2321
+ // 锚点
2322
+ code += `_anchor?: nasl.core.String`;
2323
+ code += '}){}\n';
2324
+ }
2325
+ code += `${indent(state?.tabSize || 0)}}\n`;
2326
+
2327
+ // elements类型声明定义
2328
+ code += `interface __elements {\n`;
2329
+ // 生成所有的name和类型定义
2330
+ yield* wrapForEach(self.elements, function* warpForEachGenerator(element) {
2331
+ code += yield* element.toEmbeddedTSDefinition(
2332
+ shiftState(state, code, {
2333
+ tabSize: (state?.tabSize || 0) + 1,
2334
+ }),
2335
+ );
2336
+ });
2337
+ code += `${indent((state?.tabSize || 0) + 1)}}\n`;
2338
+ code += `let __elements: __elements;\n`;
2339
+
2340
+ if (Array.isArray(self.elements)) {
2341
+ code += `${indent((state?.tabSize || 0) + 1)}interface `;
2342
+ code += `__elements_completionProperty {\n`;
2343
+ const componentList: Array<ViewElement> = [];
2344
+ self.elementsAttrs(self.elements, componentList);
2345
+ const variableList: string[] = [];
2346
+ yield* wrapForEach(self.elements, function* warpForEachGenerator(item) {
2347
+ code += yield* item.toEmbeddedTSVariableDefinition(shiftState(state, code, { inline: true }), variableList);
2348
+ });
2349
+ code += indent((state?.tabSize || 0) + 1) + `}\n`;
2350
+ code += indent((state?.tabSize || 0) + 1);
2351
+ code += `let __elements_completionProperty: __elements_completionProperty;\n`;
2352
+ code += indent((state?.tabSize || 0) + 1);
2353
+ code += `let __elements_variable_function = {\n`;
2354
+ yield* wrapForEach(self.elements, function* warpForEachGenerator(item) {
2355
+ code += yield* item.toEmbeddedTSVariableFunctionDefinition(shiftState(state, code, { inline: true }));
2356
+ });
2357
+ code += indent((state?.tabSize || 0) + 1) + `}\n`;
2358
+ code += indent((state?.tabSize || 0) + 1);
2359
+ code += `let __elements_stashFunctionVariable = {\n`;
2360
+ yield* wrapForEach(variableList, function* warpForEachGenerator(item) {
2361
+ code += indent((state?.tabSize || 0) + 2);
2362
+ code += `${item}`;
2363
+ });
2364
+ code += indent((state?.tabSize || 0) + 1) + `}\n`;
2365
+ }
2366
+
2367
+ const advanceMap: Map<Variable, Assignment | BatchAssignment> = new Map();
2368
+ yield* self.traverseChildrenGenerator(function* traverseChildrenGenerator(el) {
2369
+ if (el && (asserts.isBatchAssignment(el) || (asserts.isAssignment(el) && el.left?.name))) {
2370
+ if (asserts.isAssignment(el)) {
2371
+ const advanceVar = self.variables?.find(
2372
+ (variable) => !variable.typeAnnotation && el.left?.name === variable.name,
2373
+ );
2374
+ if (advanceVar && !advanceMap.get(advanceVar)) {
2375
+ advanceMap.set(advanceVar, el);
2376
+ }
2377
+ } else if (asserts.isBatchAssignment(el)) {
2378
+ yield* wrapForEach(el.assignmentLines, function* warpForEachGenerator({ leftIndex }) {
2379
+ const leftCode =
2380
+ leftIndex.length === 1
2381
+ ? yield* el.left?.expression?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
2382
+ returnOrigin('')
2383
+ : yield* el.left?.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
2384
+ returnOrigin('');
2385
+ const advanceVar = self.variables?.find(
2386
+ (variable) => !variable.typeAnnotation && leftCode === variable.name,
2387
+ );
2388
+ if (advanceVar && !advanceMap.get(advanceVar)) {
2389
+ advanceMap.set(advanceVar, el);
2390
+ }
2391
+ });
2392
+ }
2393
+ }
2394
+ });
2395
+
2396
+ // 用来储存默认值翻译结构是__IDENTIFIER__或者__IDENTIFIER__()的节点
2397
+ const IDENTIFIERMAP = new Set<Variable>();
2398
+ if (Array.isArray(self.params)) {
2399
+ yield* wrapForEach(self.params, function* warpForEachGenerator(param) {
2400
+ code += `let ${indent((state?.tabSize || 0) + 1)}`;
2401
+ code += yield* param.toEmbeddedTS(shiftState(state, code, { inline: true }));
2402
+ code += ';\n';
2403
+ });
2404
+ }
2405
+ if (Array.isArray(self.variables)) {
2406
+ yield* wrapForEach(self.variables, function* warpForEachGenerator(variable) {
2407
+ const ts = yield* variable.defaultValue?.toEmbeddedTS?.() ?? returnOrigin('');
2408
+ if (['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
2409
+ IDENTIFIERMAP.add(variable);
2410
+ }
2411
+ if (!advanceMap.get(variable)) {
2412
+ code += `let ${indent((state?.tabSize || 0) + 1)}`;
2413
+ code += yield* variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
2414
+ code += ';\n';
2415
+ }
2416
+ });
2417
+ }
2418
+ yield* wrapIterator(advanceMap.entries(), function* warpForEachGenerator([variable, assignment]) {
2419
+ // 有默认值的用默认值来推导类型, 但是如果是__IDENTIFIER__或者__IDENTIFIER__(),就不需要默认值来推导了
2420
+ if (variable.defaultValue?.expression && !IDENTIFIERMAP.has(variable)) {
2421
+ code += `let ${indent((state?.tabSize || 0) + 1)}`;
2422
+ code += yield* variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
2423
+ return;
2424
+ }
2425
+ code += `${indent((state?.tabSize || 0) + 1)}// @ts-ignore\n`;
2426
+ code += `let ${indent((state?.tabSize || 0) + 1)}`;
2427
+ code += yield* variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
2428
+ code += ' = ';
2429
+ if (asserts.isBatchAssignment(assignment)) {
2430
+ yield* wrapForEach(assignment.assignmentLines, function* warpForEachGenerator({ leftIndex, rightIndex }) {
2431
+ const leftCode =
2432
+ leftIndex.length === 1
2433
+ ? yield* assignment.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true }))
2434
+ : yield* assignment.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
2435
+ returnOrigin('');
2436
+ if (leftCode === variable.name) {
2437
+ const rightNode =
2438
+ rightIndex.length === 1
2439
+ ? assignment.rights[rightIndex[0]]?.expression
2440
+ : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
2441
+ const rightCode = yield* rightNode?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
2442
+ returnOrigin('');
2443
+ code += yield* self.getRightCode(rightCode, assignment, rightNode);
2444
+ }
2445
+ });
2446
+ } else {
2447
+ let rightCode = '';
2448
+ // 因为右侧枚举要赋值就得new 一下;
2449
+ if (
2450
+ assignment.right &&
2451
+ asserts.isIdentifier(assignment.right) &&
2452
+ assignment.right.namespace &&
2453
+ assignment.right.namespace.endsWith('enums')
2454
+ ) {
2455
+ rightCode += 'new ';
2456
+ }
2457
+ rightCode +=
2458
+ assignment.right && assignment.right.toEmbeddedTS
2459
+ ? yield* assignment.right.toEmbeddedTS(shiftState(state, code, { inline: true }))
2460
+ : '__RIGHT__';
2461
+ code += yield* self.getRightCode(rightCode, assignment, assignment.right);
2462
+ }
2463
+ code += ';\n';
2464
+ });
2465
+
2466
+ /* 默认值草稿区 ---------------------------*/
2467
+ code += `${indent((state?.tabSize || 0) + 1)}function __playground(){\n`;
2468
+
2469
+ /* 参数的默认值是__IDENTIFIER__或者__IDENTIFIER__()时不赋默认值,但是需要ts翻译出来进行报错校验 */
2470
+ for (const node of IDENTIFIERMAP.values()) {
2471
+ code += `${indent((state?.tabSize || 0) + 2)}`;
2472
+ code += yield* node.defaultValue.toEmbeddedTS(shiftState(state, code, { inline: true }));
2473
+ code += '; ';
2474
+ }
2475
+
2476
+ code += '\n';
2477
+ code += `${indent((state?.tabSize || 0) + 2)}return\n`;
2478
+
2479
+ function* setPlaygroundCode(arr: Variable[] | ParamWithGroup[], name: string) {
2480
+ if (arr.length) {
2481
+ code += `${indent((state?.tabSize || 0) + 1)}/* -----以下是 ${name} 的默认值草稿------ */\n`;
2482
+ }
2483
+
2484
+ for (const item1 of arr) {
2485
+ for (const item of item1.defaultValue?.playground ?? []) {
2486
+ code += yield* item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
2487
+ code += ';\n';
2488
+ }
2489
+ }
2490
+ }
2491
+ yield* setPlaygroundCode(self.variables, 'variables');
2492
+ yield* setPlaygroundCode(self.params, 'params');
2493
+
2494
+ code += `${indent((state?.tabSize || 0) + 1)}}\n`;
2495
+ return code;
2496
+ }
2497
+
2498
+ /**
2499
+ * 转换成 VueOptions
2500
+ * @TODO 后面 template 可以优化成 render 函数
2501
+ */
2502
+ toVueOptions(options?: ElementToVueOptions) {
2503
+ return {
2504
+ template: this.genVueTemplate(options),
2505
+ script: this.genScript(),
2506
+ };
2507
+ }
2508
+
2509
+ genVueTemplate(options?: ElementToVueOptions) {
2510
+ return this.elements?.map((element) => `${element?.toVue(options)}\n`).join('');
2511
+ }
2512
+
2513
+ getViewBindEvents() {
2514
+ const bindEvents: Array<BindEvent> = [];
2515
+ // 页面上的绑定的事件
2516
+ this.bindEvents.forEach((bindEvent) => {
2517
+ bindEvents.push(bindEvent);
2518
+ });
2519
+ this.elements.forEach((item) => {
2520
+ utils.traverse(
2521
+ (current) => {
2522
+ current.node.bindEvents.forEach((bindEvent) => {
2523
+ bindEvents.push(bindEvent);
2524
+ });
2525
+ },
2526
+ { node: item },
2527
+ );
2528
+ });
2529
+ return bindEvents;
2530
+ }
2531
+
2532
+ // 获取页面上需要替换的表达式
2533
+ getViewExpressions() {
2534
+ const bindExpressions: any[] = [];
2535
+ this.elements.forEach((item) => {
2536
+ utils.traverse(
2537
+ (current) => {
2538
+ const { node } = current as any;
2539
+ const playgroundNodePath = (node?.nodePath || '').split('.').find((nodePathNode: string) => {
2540
+ return nodePathNode.match(/(.+)\[.+\]/)?.[1] === 'playground';
2541
+ });
2542
+ if (!playgroundNodePath) {
2543
+ //// 处理三种情况
2544
+ //if (
2545
+ // ['BindAttribute', 'BindDirective', 'BindStyle'].includes(node.concept)
2546
+ // && node.needReplaceWithIdentifier
2547
+ //) {
2548
+ // bindExpressions.push(node);
2549
+ //}
2550
+ if (node?.concept === 'Match') {
2551
+ bindExpressions.push(node as Match);
2552
+ }
2553
+ }
2554
+ },
2555
+ {
2556
+ node: item,
2557
+ },
2558
+ {
2559
+ mode: 'anyObject',
2560
+ depthFirst: true,
2561
+ excludedKeySet: new Set([
2562
+ 'bindEvents',
2563
+ 'parentNode',
2564
+ 'sourceMap',
2565
+ 'storageJSON',
2566
+ 'tsErrorDetail',
2567
+ 'NaslAnnotatedJSON',
2568
+ 'calledFrom',
2569
+ '_events',
2570
+ '_collectingList',
2571
+ '_historyList',
2572
+ ]),
2573
+ },
2574
+ );
2575
+ });
2576
+ return bindExpressions;
2577
+ }
2578
+
2579
+ /**
2580
+ * 生成 Vue 中需要的 JS 代码
2581
+ * @TODO 这一版先做成 componentOptions 式的,后面再美化
2582
+ */
2583
+ genScript() {
2584
+ const componentList: Array<ViewElement> = [];
2585
+ const componentListExtra: Array<ViewElement> = [];
2586
+ this.elementsAttrs(this.elements, componentList);
2587
+ this.elementsAttrsAll(this.elements, componentListExtra);
2588
+ const definition = {
2589
+ params: this.params,
2590
+ variables: this.variables,
2591
+ logics: this.logics,
2592
+ events: this.bindEvents,
2593
+ title: this.title,
2594
+ viewBindEvents: this.getViewBindEvents(),
2595
+ viewExpressions: this.getViewExpressions(),
2596
+ elements: componentList,
2597
+ elementsAll: componentListExtra,
2598
+ };
2599
+ let code = '';
2600
+ const keyboardEventMixinCode = `const keyboardEventMixin = {
2601
+ mounted() {
2602
+ document.addEventListener('keydown', this.onKeyDown);
2603
+ document.addEventListener('keyup', this.onKeyUp);
2604
+ },
2605
+ beforeDestory() {
2606
+ document.removeEventListener('keydown', this.onKeyDown);
2607
+ document.removeEventListener('keyup', this.onKeyUp);
2608
+ },
2609
+ methods: {
2610
+ async onKeyDown(e) {
2611
+ ${this.bindEvents
2612
+ .filter((event) => ['keydown'].includes(event.name))
2613
+ .map((event) => `await this.${event.view.name}_${event.name}(e);`)
2614
+ .join('\n')}
2615
+ },
2616
+ async onKeyUp(e) {
2617
+ ${this.bindEvents
2618
+ .filter((event) => ['keyup'].includes(event.name))
2619
+ .map((event) => `await this.${event.view.name}_${event.name}(e);`)
2620
+ .join('\n')}
2621
+ }
2622
+ }
2623
+ };\n`;
2624
+ code += keyboardEventMixinCode;
2625
+ code += 'export default {\n';
2626
+ code += 'mixins: [';
2627
+ const mixins = [];
2628
+ // 键盘事件mixin
2629
+ mixins.push('keyboardEventMixin');
2630
+ code += mixins.join(',');
2631
+ code += '],';
2632
+ code += translator(definition, this);
2633
+ code += '};\n';
2634
+ return code;
2635
+ }
2636
+
2637
+ // 生成预览的模板
2638
+ genPreviewTemplate() {
2639
+ return `<template>
2640
+ <bs-${this.name}>
2641
+ ${this.slotElems.map((slotElem) => {
2642
+ const slotName = slotElem.name;
2643
+ return `<template #${slotName}></template>`;
2644
+ }).join('')}
2645
+ </bs-${this.name}>
2646
+ </template>`;
2647
+ }
2648
+
2649
+ //================================================================================
2650
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
2651
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
2652
+ //================================================================================
2653
+ }
2654
+
2655
+ export default BusinessComponent;
2656
+ //================================================================================
2657
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
2658
+ // 自动生成的代码已结束。下面可以手动编写。
2659
+ //================================================================================