@lcap/nasl 3.3.0-alpha.1 → 3.3.0-alpha.3

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 (380) hide show
  1. package/out/automate/upgrader/2.20.js.map +1 -1
  2. package/out/bak/translator.js +52 -1
  3. package/out/bak/translator.js.map +1 -1
  4. package/out/breakpoint/shared/utils.js +0 -2
  5. package/out/breakpoint/shared/utils.js.map +1 -1
  6. package/out/common/Command.d.ts +1 -0
  7. package/out/common/Command.js +9 -1
  8. package/out/common/Command.js.map +1 -1
  9. package/out/concepts/Abort__.js +2 -1
  10. package/out/concepts/Abort__.js.map +1 -1
  11. package/out/concepts/Anchor__.js +1 -1
  12. package/out/concepts/Anchor__.js.map +1 -1
  13. package/out/concepts/AnonymousFunction__.js +2 -2
  14. package/out/concepts/AnonymousFunction__.js.map +1 -1
  15. package/out/concepts/Argument__.js +1 -1
  16. package/out/concepts/Argument__.js.map +1 -1
  17. package/out/concepts/Assignee__.js.map +1 -1
  18. package/out/concepts/AssignmentLine__.js +1 -1
  19. package/out/concepts/AssignmentLine__.js.map +1 -1
  20. package/out/concepts/Assignment__.js +2 -2
  21. package/out/concepts/Assignment__.js.map +1 -1
  22. package/out/concepts/BackendVariable__.js +1 -1
  23. package/out/concepts/BackendVariable__.js.map +1 -1
  24. package/out/concepts/Backend__.js +1 -1
  25. package/out/concepts/Backend__.js.map +1 -1
  26. package/out/concepts/BatchAssignment__.js +2 -2
  27. package/out/concepts/BatchAssignment__.js.map +1 -1
  28. package/out/concepts/BinaryExpression__.js +2 -2
  29. package/out/concepts/BinaryExpression__.js.map +1 -1
  30. package/out/concepts/BindAttribute__.d.ts +2 -0
  31. package/out/concepts/BindAttribute__.js +79 -4
  32. package/out/concepts/BindAttribute__.js.map +1 -1
  33. package/out/concepts/BindDirective__.js +1 -1
  34. package/out/concepts/BindDirective__.js.map +1 -1
  35. package/out/concepts/BindEvent__.d.ts +2 -1
  36. package/out/concepts/BindEvent__.js +44 -37
  37. package/out/concepts/BindEvent__.js.map +1 -1
  38. package/out/concepts/BindStyle__.js +1 -1
  39. package/out/concepts/BindStyle__.js.map +1 -1
  40. package/out/concepts/BooleanLiteral__.js +1 -1
  41. package/out/concepts/BooleanLiteral__.js.map +1 -1
  42. package/out/concepts/CallAuthInterface__.js +1 -1
  43. package/out/concepts/CallAuthInterface__.js.map +1 -1
  44. package/out/concepts/CallConnector__.js +1 -1
  45. package/out/concepts/CallConnector__.js.map +1 -1
  46. package/out/concepts/CallFunction__.js +2 -2
  47. package/out/concepts/CallFunction__.js.map +1 -1
  48. package/out/concepts/CallInterface__.js +2 -2
  49. package/out/concepts/CallInterface__.js.map +1 -1
  50. package/out/concepts/CallLogic__.js +69 -12
  51. package/out/concepts/CallLogic__.js.map +1 -1
  52. package/out/concepts/CallQueryComponent__.d.ts +1 -1
  53. package/out/concepts/CallQueryComponent__.js +1 -1
  54. package/out/concepts/CallQueryComponent__.js.map +1 -1
  55. package/out/concepts/Comment__.js +1 -1
  56. package/out/concepts/Comment__.js.map +1 -1
  57. package/out/concepts/ConfigProperty__.js +1 -1
  58. package/out/concepts/ConfigProperty__.js.map +1 -1
  59. package/out/concepts/Connection__.js +9 -10
  60. package/out/concepts/Connection__.js.map +1 -1
  61. package/out/concepts/Constant__.js +1 -1
  62. package/out/concepts/Constant__.js.map +1 -1
  63. package/out/concepts/DataSource__.js +1 -1
  64. package/out/concepts/DataSource__.js.map +1 -1
  65. package/out/concepts/Destination__.js +2 -2
  66. package/out/concepts/Destination__.js.map +1 -1
  67. package/out/concepts/End__.js +1 -1
  68. package/out/concepts/End__.js.map +1 -1
  69. package/out/concepts/EntityIndex__.js +1 -1
  70. package/out/concepts/EntityIndex__.js.map +1 -1
  71. package/out/concepts/EntityProperty__.js +2 -2
  72. package/out/concepts/EntityProperty__.js.map +1 -1
  73. package/out/concepts/Entity__.js +2 -2
  74. package/out/concepts/Entity__.js.map +1 -1
  75. package/out/concepts/EnumItem__.js +2 -2
  76. package/out/concepts/EnumItem__.js.map +1 -1
  77. package/out/concepts/Enum__.js +2 -2
  78. package/out/concepts/Enum__.js.map +1 -1
  79. package/out/concepts/ForEachStatement__.js +27 -37
  80. package/out/concepts/ForEachStatement__.js.map +1 -1
  81. package/out/concepts/Frontend__.js +1 -1
  82. package/out/concepts/Frontend__.js.map +1 -1
  83. package/out/concepts/Function__.js +2 -2
  84. package/out/concepts/Function__.js.map +1 -1
  85. package/out/concepts/Identifier__.js +1 -1
  86. package/out/concepts/Identifier__.js.map +1 -1
  87. package/out/concepts/IfStatement__.js +2 -2
  88. package/out/concepts/IfStatement__.js.map +1 -1
  89. package/out/concepts/Interface__.js +1 -1
  90. package/out/concepts/Interface__.js.map +1 -1
  91. package/out/concepts/JSBlock__.js +1 -1
  92. package/out/concepts/JSBlock__.js.map +1 -1
  93. package/out/concepts/JavaLogic__.js +1 -1
  94. package/out/concepts/JavaLogic__.js.map +1 -1
  95. package/out/concepts/LogicItem__.js +3 -2
  96. package/out/concepts/LogicItem__.js.map +1 -1
  97. package/out/concepts/Logic__.js +2 -1
  98. package/out/concepts/Logic__.js.map +1 -1
  99. package/out/concepts/MatchCase__.js +1 -1
  100. package/out/concepts/MatchCase__.js.map +1 -1
  101. package/out/concepts/Match__.js +2 -2
  102. package/out/concepts/Match__.js.map +1 -1
  103. package/out/concepts/MemberExpression__.d.ts +1 -0
  104. package/out/concepts/MemberExpression__.js +117 -2
  105. package/out/concepts/MemberExpression__.js.map +1 -1
  106. package/out/concepts/Module__.d.ts +1 -1
  107. package/out/concepts/Module__.js +34 -35
  108. package/out/concepts/Module__.js.map +1 -1
  109. package/out/concepts/NewComposite__.js +2 -2
  110. package/out/concepts/NewComposite__.js.map +1 -1
  111. package/out/concepts/NewList__.js +2 -2
  112. package/out/concepts/NewList__.js.map +1 -1
  113. package/out/concepts/NewMap__.js +2 -2
  114. package/out/concepts/NewMap__.js.map +1 -1
  115. package/out/concepts/New__.js +1 -1
  116. package/out/concepts/New__.js.map +1 -1
  117. package/out/concepts/NullLiteral__.js +1 -1
  118. package/out/concepts/NullLiteral__.js.map +1 -1
  119. package/out/concepts/NumericLiteral__.js +1 -1
  120. package/out/concepts/NumericLiteral__.js.map +1 -1
  121. package/out/concepts/OqlQueryComponent__.js +2 -2
  122. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  123. package/out/concepts/Param__.js +1 -1
  124. package/out/concepts/Param__.js.map +1 -1
  125. package/out/concepts/ProcessElement__.js +1 -1
  126. package/out/concepts/ProcessElement__.js.map +1 -1
  127. package/out/concepts/ProcessOutcome__.js +1 -1
  128. package/out/concepts/ProcessOutcome__.js.map +1 -1
  129. package/out/concepts/ProcessOutcomes__.js +1 -1
  130. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  131. package/out/concepts/Process__.js +1 -1
  132. package/out/concepts/Process__.js.map +1 -1
  133. package/out/concepts/QueryAggregateExpression__.js +1 -1
  134. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  135. package/out/concepts/QueryFieldExpression__.js +1 -1
  136. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  137. package/out/concepts/QueryFromExpression__.js +1 -1
  138. package/out/concepts/QueryFromExpression__.js.map +1 -1
  139. package/out/concepts/QueryJoinExpression__.js +1 -1
  140. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  141. package/out/concepts/QueryLimitExpression__.js +1 -1
  142. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  143. package/out/concepts/QueryOrderByExpression__.js +1 -1
  144. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  145. package/out/concepts/Return__.js +2 -2
  146. package/out/concepts/Return__.js.map +1 -1
  147. package/out/concepts/Role__.js +1 -1
  148. package/out/concepts/Role__.js.map +1 -1
  149. package/out/concepts/SelectMembers__.js +1 -1
  150. package/out/concepts/SelectMembers__.js.map +1 -1
  151. package/out/concepts/SqlQueryComponent__.js +2 -2
  152. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  153. package/out/concepts/Start__.js +1 -1
  154. package/out/concepts/Start__.js.map +1 -1
  155. package/out/concepts/StringInterpolation__.js +2 -2
  156. package/out/concepts/StringInterpolation__.js.map +1 -1
  157. package/out/concepts/StringLiteral__.js +1 -1
  158. package/out/concepts/StringLiteral__.js.map +1 -1
  159. package/out/concepts/StructureProperty__.js +2 -2
  160. package/out/concepts/StructureProperty__.js.map +1 -1
  161. package/out/concepts/Structure__.js +2 -2
  162. package/out/concepts/Structure__.js.map +1 -1
  163. package/out/concepts/SwitchCase__.js +1 -1
  164. package/out/concepts/SwitchCase__.js.map +1 -1
  165. package/out/concepts/SwitchStatement__.js +2 -2
  166. package/out/concepts/SwitchStatement__.js.map +1 -1
  167. package/out/concepts/TriggerLauncher__.js +1 -1
  168. package/out/concepts/TriggerLauncher__.js.map +1 -1
  169. package/out/concepts/TypeAnnotation__.d.ts +4 -3
  170. package/out/concepts/TypeAnnotation__.js +116 -75
  171. package/out/concepts/TypeAnnotation__.js.map +1 -1
  172. package/out/concepts/TypeParam__.js +1 -1
  173. package/out/concepts/TypeParam__.js.map +1 -1
  174. package/out/concepts/UnaryExpression__.js +2 -2
  175. package/out/concepts/UnaryExpression__.js.map +1 -1
  176. package/out/concepts/ValidationRule__.d.ts +14 -14
  177. package/out/concepts/ValidationRule__.js +28 -24
  178. package/out/concepts/ValidationRule__.js.map +1 -1
  179. package/out/concepts/Variable__.js +2 -2
  180. package/out/concepts/Variable__.js.map +1 -1
  181. package/out/concepts/ViewElement__.d.ts +88 -87
  182. package/out/concepts/ViewElement__.js +268 -204
  183. package/out/concepts/ViewElement__.js.map +1 -1
  184. package/out/concepts/View__.d.ts +6 -0
  185. package/out/concepts/View__.js +254 -11
  186. package/out/concepts/View__.js.map +1 -1
  187. package/out/concepts/WhileStatement__.js +2 -2
  188. package/out/concepts/WhileStatement__.js.map +1 -1
  189. package/out/concepts/basics/stdlib/nasl.browser.js +1 -0
  190. package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
  191. package/out/concepts/basics/stdlib/nasl.event.js +2 -0
  192. package/out/concepts/basics/stdlib/nasl.event.js.map +1 -1
  193. package/out/generator/genBundleFiles.js +90 -1
  194. package/out/generator/genBundleFiles.js.map +1 -1
  195. package/out/generator/genReleaseBody.js +1 -1
  196. package/out/generator/genReleaseBody.js.map +1 -1
  197. package/out/generator/permission.js +3 -3
  198. package/out/generator/permission.js.map +1 -1
  199. package/out/index.d.ts +1 -0
  200. package/out/index.js +1 -0
  201. package/out/index.js.map +1 -1
  202. package/out/natural/genNaturalTS.js +7 -3
  203. package/out/natural/genNaturalTS.js.map +1 -1
  204. package/out/natural/knowledgeMap.js +12 -12
  205. package/out/natural/knowledgeMap.js.map +1 -1
  206. package/out/natural/transformTSCode.d.ts +1 -1
  207. package/out/natural/transformTSCode.js +115 -141
  208. package/out/natural/transformTSCode.js.map +1 -1
  209. package/out/server/extendBaseNode.js +69 -44
  210. package/out/server/extendBaseNode.js.map +1 -1
  211. package/out/server/formatTsUtils.js +72 -63
  212. package/out/server/formatTsUtils.js.map +1 -1
  213. package/out/server/getLogics.js +20 -23
  214. package/out/server/getLogics.js.map +1 -1
  215. package/out/server/getMemberIdentifier.d.ts +1 -0
  216. package/out/server/getMemberIdentifier.js +149 -1
  217. package/out/server/getMemberIdentifier.js.map +1 -1
  218. package/out/server/naslServer.d.ts +3 -3
  219. package/out/server/naslServer.js +182 -132
  220. package/out/server/naslServer.js.map +1 -1
  221. package/out/server/translator.js +43 -33
  222. package/out/server/translator.js.map +1 -1
  223. package/out/service/defaultErrorMessage.json +6 -6
  224. package/out/service/storage/init.js +16 -0
  225. package/out/service/storage/init.js.map +1 -1
  226. package/out/templator/genCreateBlock.js +5 -3
  227. package/out/templator/genCreateBlock.js.map +1 -1
  228. package/out/templator/genCurdEditMultipleKeyBlock.js +12 -8
  229. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  230. package/out/templator/genCurdMultipleKeyBlock.js +8 -7
  231. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  232. package/out/templator/genEditTableBlock.d.ts +1 -1
  233. package/out/templator/genEditTableBlock.js +12 -6
  234. package/out/templator/genEditTableBlock.js.map +1 -1
  235. package/out/templator/genEnumSelectBlock.js +2 -2
  236. package/out/templator/genEnumSelectBlock.js.map +1 -1
  237. package/out/templator/genGetBlock.js +1 -1
  238. package/out/templator/genGetBlock.js.map +1 -1
  239. package/out/templator/genGridViewBlock.d.ts +2 -2
  240. package/out/templator/genGridViewBlock.js +20 -7
  241. package/out/templator/genGridViewBlock.js.map +1 -1
  242. package/out/templator/genListViewBlock.d.ts +2 -2
  243. package/out/templator/genListViewBlock.js +13 -5
  244. package/out/templator/genListViewBlock.js.map +1 -1
  245. package/out/templator/genSelectBlock.d.ts +2 -2
  246. package/out/templator/genSelectBlock.js +8 -6
  247. package/out/templator/genSelectBlock.js.map +1 -1
  248. package/out/templator/genTableBlock.d.ts +1 -1
  249. package/out/templator/genTableBlock.js +10 -5
  250. package/out/templator/genTableBlock.js.map +1 -1
  251. package/out/templator/genUpdateBlock.js +5 -3
  252. package/out/templator/genUpdateBlock.js.map +1 -1
  253. package/package.json +3 -1
  254. package/sandbox/stdlib/nasl.auth.ts +40 -44
  255. package/sandbox/stdlib/nasl.core.ts +8 -1
  256. package/sandbox/stdlib/nasl.http.ts +22 -22
  257. package/sandbox-natural/stdlib/nasl.util.ts +74 -15
  258. package/src/automate/upgrader/2.20.js +17 -13
  259. package/src/bak/translator.js +50 -1
  260. package/src/breakpoint/shared/utils.ts +0 -2
  261. package/src/common/Command.ts +8 -0
  262. package/src/concepts/Abort__.ts +2 -2
  263. package/src/concepts/Anchor__.ts +2 -2
  264. package/src/concepts/AnonymousFunction__.ts +3 -3
  265. package/src/concepts/Argument__.ts +2 -2
  266. package/src/concepts/Assignee__.ts +1 -1
  267. package/src/concepts/AssignmentLine__.ts +2 -2
  268. package/src/concepts/Assignment__.ts +3 -3
  269. package/src/concepts/BackendVariable__.ts +2 -2
  270. package/src/concepts/Backend__.ts +1 -1
  271. package/src/concepts/BatchAssignment__.ts +3 -3
  272. package/src/concepts/BinaryExpression__.ts +3 -3
  273. package/src/concepts/BindAttribute__.ts +69 -4
  274. package/src/concepts/BindDirective__.ts +2 -2
  275. package/src/concepts/BindEvent__.ts +44 -64
  276. package/src/concepts/BindStyle__.ts +2 -2
  277. package/src/concepts/BooleanLiteral__.ts +2 -2
  278. package/src/concepts/CallAuthInterface__.ts +2 -2
  279. package/src/concepts/CallConnector__.ts +2 -2
  280. package/src/concepts/CallFunction__.ts +3 -3
  281. package/src/concepts/CallInterface__.ts +3 -3
  282. package/src/concepts/CallLogic__.ts +69 -13
  283. package/src/concepts/CallQueryComponent__.ts +2 -2
  284. package/src/concepts/Comment__.ts +2 -2
  285. package/src/concepts/ConfigProperty__.ts +2 -2
  286. package/src/concepts/Connection__.ts +15 -21
  287. package/src/concepts/Constant__.ts +2 -2
  288. package/src/concepts/DataSource__.ts +1 -1
  289. package/src/concepts/Destination__.ts +3 -3
  290. package/src/concepts/End__.ts +2 -2
  291. package/src/concepts/EntityIndex__.ts +2 -2
  292. package/src/concepts/EntityProperty__.ts +3 -3
  293. package/src/concepts/Entity__.ts +2 -2
  294. package/src/concepts/EnumItem__.ts +3 -3
  295. package/src/concepts/Enum__.ts +2 -2
  296. package/src/concepts/ForEachStatement__.ts +35 -46
  297. package/src/concepts/Frontend__.ts +1 -1
  298. package/src/concepts/Function__.ts +3 -3
  299. package/src/concepts/Identifier__.ts +2 -2
  300. package/src/concepts/IfStatement__.ts +3 -3
  301. package/src/concepts/Interface__.ts +1 -1
  302. package/src/concepts/JSBlock__.ts +2 -2
  303. package/src/concepts/JavaLogic__.ts +2 -2
  304. package/src/concepts/LogicItem__.ts +3 -3
  305. package/src/concepts/Logic__.ts +2 -1
  306. package/src/concepts/MatchCase__.ts +2 -2
  307. package/src/concepts/Match__.ts +3 -3
  308. package/src/concepts/MemberExpression__.ts +112 -4
  309. package/src/concepts/Module__.ts +41 -58
  310. package/src/concepts/NewComposite__.ts +3 -3
  311. package/src/concepts/NewList__.ts +3 -3
  312. package/src/concepts/NewMap__.ts +3 -3
  313. package/src/concepts/New__.ts +2 -2
  314. package/src/concepts/NullLiteral__.ts +2 -2
  315. package/src/concepts/NumericLiteral__.ts +2 -2
  316. package/src/concepts/OqlQueryComponent__.ts +3 -3
  317. package/src/concepts/Param__.ts +2 -2
  318. package/src/concepts/ProcessElement__.ts +2 -2
  319. package/src/concepts/ProcessOutcome__.ts +2 -2
  320. package/src/concepts/ProcessOutcomes__.ts +2 -2
  321. package/src/concepts/Process__.ts +1 -1
  322. package/src/concepts/QueryAggregateExpression__.ts +2 -2
  323. package/src/concepts/QueryFieldExpression__.ts +2 -2
  324. package/src/concepts/QueryFromExpression__.ts +2 -2
  325. package/src/concepts/QueryJoinExpression__.ts +2 -2
  326. package/src/concepts/QueryLimitExpression__.ts +2 -2
  327. package/src/concepts/QueryOrderByExpression__.ts +2 -2
  328. package/src/concepts/Return__.ts +3 -3
  329. package/src/concepts/Role__.ts +1 -1
  330. package/src/concepts/SelectMembers__.ts +2 -2
  331. package/src/concepts/SqlQueryComponent__.ts +3 -3
  332. package/src/concepts/Start__.ts +2 -2
  333. package/src/concepts/StringInterpolation__.ts +3 -3
  334. package/src/concepts/StringLiteral__.ts +2 -2
  335. package/src/concepts/StructureProperty__.ts +3 -3
  336. package/src/concepts/Structure__.ts +2 -2
  337. package/src/concepts/SwitchCase__.ts +2 -2
  338. package/src/concepts/SwitchStatement__.ts +3 -3
  339. package/src/concepts/TriggerLauncher__.ts +1 -1
  340. package/src/concepts/TypeAnnotation__.ts +145 -125
  341. package/src/concepts/TypeParam__.ts +2 -2
  342. package/src/concepts/UnaryExpression__.ts +3 -3
  343. package/src/concepts/ValidationRule__.ts +554 -524
  344. package/src/concepts/Variable__.ts +3 -3
  345. package/src/concepts/ViewElement__.ts +2445 -2498
  346. package/src/concepts/View__.ts +258 -10
  347. package/src/concepts/WhileStatement__.ts +3 -3
  348. package/src/concepts/basics/stdlib/nasl.browser.ts +1 -0
  349. package/src/concepts/basics/stdlib/nasl.event.ts +2 -0
  350. package/src/generator/genBundleFiles.ts +91 -1
  351. package/src/generator/genReleaseBody.ts +1 -1
  352. package/src/generator/permission.ts +3 -3
  353. package/src/index.ts +1 -0
  354. package/src/natural/genNaturalTS.ts +8 -4
  355. package/src/natural/knowledgeMap.ts +12 -12
  356. package/src/natural/transformTSCode.ts +139 -151
  357. package/src/server/extendBaseNode.ts +71 -45
  358. package/src/server/formatTsUtils.ts +64 -64
  359. package/src/server/getLogics.ts +23 -30
  360. package/src/server/getMemberIdentifier.ts +143 -0
  361. package/src/server/naslServer.ts +174 -148
  362. package/src/server/translator.ts +40 -39
  363. package/src/service/defaultErrorMessage.json +6 -6
  364. package/src/service/storage/init.ts +17 -0
  365. package/src/templator/genCreateBlock.ts +5 -3
  366. package/src/templator/genCurdEditMultipleKeyBlock.ts +12 -8
  367. package/src/templator/genCurdMultipleKeyBlock.ts +8 -7
  368. package/src/templator/genEditTableBlock.ts +12 -7
  369. package/src/templator/genEnumSelectBlock.ts +2 -2
  370. package/src/templator/genGetBlock.ts +6 -6
  371. package/src/templator/genGridViewBlock.ts +22 -9
  372. package/src/templator/genListViewBlock.ts +14 -5
  373. package/src/templator/genSelectBlock.ts +8 -6
  374. package/src/templator/genTableBlock.ts +10 -9
  375. package/src/templator/genUpdateBlock.ts +5 -3
  376. package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +11 -0
  377. package/test/concepts/validation-rule/__snapshots__/toJS.spec.ts.snap +10 -0
  378. package/test/concepts/validation-rule/fixtures/argument-without-keyword.json +34 -0
  379. package/test/concepts/validation-rule/fixtures/empty-rule.json +9 -0
  380. package/test/concepts/validation-rule/validation-rule.spec.ts +15 -0
@@ -1,25 +1,26 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
1
  import LogicItem from './LogicItem__';
3
2
  import Namespace from './Namespace__';
4
3
  import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
5
- import ViewElement, { ElementToVueOptions } from './ViewElement__';
4
+ import { ElementToVueOptions } from './ViewElement__';
6
5
  import { elementsEventsMap } from '../server/createUiTs';
7
6
  import Param from './Param__';
8
7
  import TypeAnnotation from './TypeAnnotation__';
9
8
  import Process from './Process__';
10
9
 
11
- //= ===============================================================================
10
+ //================================================================================
12
11
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
13
12
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
14
- //= ===============================================================================
13
+ //================================================================================
15
14
  import { EventPayload, Params } from '../common/EventEmitter';
16
15
  import { concept, excludedInJSON, property } from '../decorators';
17
16
 
18
17
  import * as utils from '../utils';
18
+ import { v4 as uuidv4 } from 'uuid';
19
19
  import BaseNode from '../common/BaseNode';
20
20
  import classMap from '../common/classMap';
21
21
  import Logic from './Logic__';
22
22
  import Argument from './Argument__';
23
+ import ViewElement from './ViewElement__';
23
24
  import View from './View__';
24
25
  import Module from './Module__';
25
26
  import App from './App__';
@@ -72,28 +73,24 @@ export class BindEvent extends BaseNode {
72
73
  get element() {
73
74
  return this.getAncestor('ViewElement') as ViewElement;
74
75
  }
75
-
76
76
  /**
77
77
  * 祖先 View
78
78
  */
79
79
  get view() {
80
80
  return this.getAncestor('View') as View;
81
81
  }
82
-
83
82
  /**
84
83
  * 祖先 Module
85
84
  */
86
85
  get module() {
87
86
  return this.getAncestor('Module') as Module;
88
87
  }
89
-
90
88
  /**
91
89
  * 祖先 App
92
90
  */
93
91
  get app() {
94
92
  return this.getAncestor('App') as App;
95
93
  }
96
-
97
94
  /**
98
95
  * 祖先 Frontend
99
96
  */
@@ -105,12 +102,10 @@ export class BindEvent extends BaseNode {
105
102
  * @param source 需要合并的部分参数
106
103
  */
107
104
  constructor(source?: Partial<BindEvent>) {
108
- // @ts-ignore
109
- source = { ...BindEvent.getDefaultOptions(), ...source };
105
+ source = Object.assign({}, BindEvent.getDefaultOptions(), source);
110
106
  super(source);
111
107
  super.subConstructor(source);
112
108
  }
113
-
114
109
  getClassName() {
115
110
  return 'BindEvent';
116
111
  }
@@ -130,7 +125,6 @@ export class BindEvent extends BaseNode {
130
125
  }
131
126
  return params;
132
127
  }
133
-
134
128
  /**
135
129
  * 设置元素绑定事件名称
136
130
  */
@@ -172,7 +166,6 @@ export class BindEvent extends BaseNode {
172
166
  const excludedSet = new Set(excludedList);
173
167
  return ((this.logics as Logic[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
174
168
  }
175
-
176
169
  getLogicUniqueName(name = 'logic1') {
177
170
  return utils.unique(name, this.getLogicExistingNames(), undefined, true);
178
171
  }
@@ -439,7 +432,7 @@ export class BindEvent extends BaseNode {
439
432
  if (typeof options === 'string') {
440
433
  logic = (this.logics as Logic[]).find((item) => item.name === options);
441
434
  if (!logic) {
442
- throw new Error(`找不到逻辑 ${options}`);
435
+ throw new Error('找不到逻辑 ' + options);
443
436
  }
444
437
  } else {
445
438
  logic = options;
@@ -448,7 +441,7 @@ export class BindEvent extends BaseNode {
448
441
  }
449
442
 
450
443
  __removeLogic(logic: Logic) {
451
- const { parentKey } = logic;
444
+ const parentKey = logic.parentKey;
452
445
  const params: Params = {
453
446
  parentNode: this,
454
447
  parentKey,
@@ -482,7 +475,7 @@ export class BindEvent extends BaseNode {
482
475
  }
483
476
 
484
477
  __removeLogicItem(logicItem: LogicItem) {
485
- const { parentKey } = logicItem;
478
+ const parentKey = logicItem.parentKey;
486
479
  const params: Params = {
487
480
  parentNode: this,
488
481
  parentKey,
@@ -504,10 +497,10 @@ export class BindEvent extends BaseNode {
504
497
  return params;
505
498
  }
506
499
 
507
- //= ===============================================================================
500
+ //================================================================================
508
501
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
509
502
  // 自动生成的代码已结束。下面可以手动编写。
510
- //= ===============================================================================
503
+ //================================================================================
511
504
  get process() {
512
505
  return this.getAncestor('Process') as Process;
513
506
  }
@@ -523,32 +516,30 @@ export class BindEvent extends BaseNode {
523
516
  }
524
517
 
525
518
  get calleeKey(): string {
526
- const { tsCalleeNamespace } = this;
519
+ const tsCalleeNamespace = this.tsCalleeNamespace;
527
520
  if (!tsCalleeNamespace) {
528
521
  return `${this.calleeName}`;
529
522
  }
530
523
  // elements单独处理相对路径,和后缀的问题
531
524
  if (tsCalleeNamespace.startsWith('elements') && tsCalleeNamespace.endsWith('logics')) {
532
525
  const methodName = tsCalleeNamespace.substring(0, tsCalleeNamespace.length - '.logics'.length);
533
- return `__${methodName}.${this.calleeName}`;
526
+ return '__' + methodName + `.${this.calleeName}`;
534
527
  }
535
528
  return `${tsCalleeNamespace}.${this.calleeName}`;
536
529
  }
537
-
538
530
  // 用于展示的value
539
531
  get randerValue() {
540
532
  const randerNameSpace = this.tsCalleeNamespace;
541
533
  if (!randerNameSpace) {
542
- return `${this.calleeName}`;
534
+ return '' + this.calleeName;
543
535
  }
544
536
  // elements单独处理相对路径,和后缀的问题
545
537
  if (randerNameSpace.startsWith('elements') && randerNameSpace.endsWith('logics')) {
546
538
  const methodName = randerNameSpace.substring('elements.'.length, randerNameSpace.length);
547
- return `$refs.${methodName}.${this.calleeName}`;
539
+ return '$refs.' + methodName + `.${this.calleeName}`;
548
540
  }
549
541
  return `${randerNameSpace}.${this.calleeName}`;
550
542
  }
551
-
552
543
  // 绑定事件转驼峰
553
544
  toHump = (name: string) => (name ? name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase()) : '');
554
545
 
@@ -582,7 +573,7 @@ export class BindEvent extends BaseNode {
582
573
  if (logic.view) {
583
574
  const logicName = logic.name;
584
575
  if ((logic.parentNode as BindEvent)?.element) {
585
- logic.name = `__${logic.view.name}${(logic.parentNode as BindEvent).element.name}${logic.name}`;
576
+ logic.name = '__' + logic.view.name + (logic.parentNode as BindEvent).element.name + logic.name;
586
577
  }
587
578
 
588
579
  logic.name = logic.name.replace(/-/g, '');
@@ -642,7 +633,7 @@ export class BindEvent extends BaseNode {
642
633
  if (logic.view) {
643
634
  const logicName = logic.name;
644
635
  if ((logic.parentNode as BindEvent)?.element) {
645
- logic.name = `__${logic.view.name}${(logic.parentNode as BindEvent).element.name}${logic.name}`;
636
+ logic.name = '__' + logic.view.name + (logic.parentNode as BindEvent).element.name + logic.name;
646
637
  }
647
638
 
648
639
  logic.name = logic.name.replace(/-/g, '');
@@ -675,7 +666,7 @@ export class BindEvent extends BaseNode {
675
666
  }
676
667
 
677
668
  @withSourceMap()
678
- toNaturalTS(state?: TranslatorState, isPageCycle?: Boolean): string {
669
+ toNaturalTS(state = createCompilerState(), isPageCycle?: Boolean): string {
679
670
  // 如果有绑定的事件名
680
671
  let code = ``;
681
672
  if (isPageCycle) {
@@ -762,6 +753,7 @@ export class BindEvent extends BaseNode {
762
753
  } else if (ref.includes('basicTypes')) {
763
754
  // 不要删除,用于转换类型
764
755
  type = ref.replace('#/basicTypes/', 'nasl.core.');
756
+ type = type.replace('Integer', 'Long');
765
757
  }
766
758
  code = `${type}`;
767
759
  }
@@ -810,10 +802,8 @@ export class BindEvent extends BaseNode {
810
802
  arr.push(parentName);
811
803
  }
812
804
  return `${arr.join('.')}.${ns || 'bindEvent'}`;
813
- }
814
- throw new Error('无法获取命名空间,请设置 parentNode!');
805
+ } else throw new Error('无法获取命名空间,请设置 parentNode!');
815
806
  }
816
-
817
807
  /**
818
808
  * 转换成 Vue 的模板格式
819
809
  */
@@ -827,7 +817,7 @@ export class BindEvent extends BaseNode {
827
817
  let index = 0;
828
818
  while (parent && parent.concept !== 'View') {
829
819
  if ((parent as ViewElement).slotScope) {
830
- argsList.unshift(index === 0 ? 'current' : `current${index}`);
820
+ argsList.unshift(index === 0 ? 'current' : 'current' + index);
831
821
  index++;
832
822
  }
833
823
  parent = parent.parentNode;
@@ -857,7 +847,7 @@ export class BindEvent extends BaseNode {
857
847
  let index = 0;
858
848
  while (parent && parent.concept !== 'View') {
859
849
  if ((parent as ViewElement).slotScope) {
860
- argsList.unshift(index === 0 ? 'current' : `current${index}`);
850
+ argsList.unshift(index === 0 ? 'current' : 'current' + index);
861
851
  index++;
862
852
  }
863
853
  parent = parent.parentNode;
@@ -870,7 +860,7 @@ export class BindEvent extends BaseNode {
870
860
  // 获取bindEvent上的logic的参数从上文获取
871
861
  getContextRenderLogicParams(logic: Logic) {
872
862
  const argsList: Param[] = [];
873
- const { virtualParams } = logic;
863
+ const virtualParams = logic.virtualParams;
874
864
  if (this.logics?.length) {
875
865
  let parent = this.parentNode;
876
866
  let index = 0;
@@ -878,7 +868,7 @@ export class BindEvent extends BaseNode {
878
868
  argsList.push(event);
879
869
  while (parent && parent.concept !== 'View') {
880
870
  if ((parent as ViewElement).slotScope) {
881
- const param = Param.from({ name: index === 0 ? 'current' : `current${index}`, typeAnnotation: null }, logic, 'virtualParams');
871
+ const param = Param.from({ name: index === 0 ? 'current' : 'current' + index, typeAnnotation: null }, logic, 'virtualParams');
882
872
  argsList.push(param);
883
873
  index++;
884
874
  }
@@ -918,9 +908,8 @@ export class BindEvent extends BaseNode {
918
908
 
919
909
  const cap = suffixRE.exec(event?.title);
920
910
  if (cap) return `${event.title.replace(suffixRE, '')}“${parent.title || parent.name}”页面${cap[0]}`;
921
- return `${event.title}“${parent.title || parent.name}”页面`;
922
- }
923
- if (parent instanceof ViewElement) {
911
+ else return `${event.title}“${parent.title || parent.name}”页面`;
912
+ } else if (parent instanceof ViewElement) {
924
913
  const eventName = `${parent.tag}-${this.name}`;
925
914
  if (elementsEventsMap[eventName]) {
926
915
  const event = elementsEventsMap[eventName];
@@ -937,9 +926,8 @@ export class BindEvent extends BaseNode {
937
926
 
938
927
  const cap = suffixRE.exec(event?.title);
939
928
  if (cap) return `${event.title.replace(suffixRE, '')}${title ? `“${title}”` : ''}${parent.name}${cap[0]}`;
940
- return `${event.title}${title ? `“${title}”` : ''}${parent.name}`;
941
- }
942
- if (['click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'focus', 'blur'].includes(this.name)) {
929
+ else return `${event.title}${title ? `“${title}”` : ''}${parent.name}`;
930
+ } else if (['click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'focus', 'blur'].includes(this.name)) {
943
931
  const event = elementsEventsMap[this.name];
944
932
 
945
933
  let title = '';
@@ -954,7 +942,7 @@ export class BindEvent extends BaseNode {
954
942
 
955
943
  const cap = suffixRE.exec(event?.title);
956
944
  if (cap) return `${event.title.replace(suffixRE, '')}${title ? `“${title}”` : ''}${parent.name}${cap[0]}`;
957
- return `${event.title}${title ? `“${title}”` : ''}${parent.name}`;
945
+ else return `${event.title}${title ? `“${title}”` : ''}${parent.name}`;
958
946
  }
959
947
  return `${parent.name}-${this.name}`;
960
948
  }
@@ -965,37 +953,33 @@ export class BindEvent extends BaseNode {
965
953
  if (parent instanceof View) {
966
954
  const event = elementsEventsMap[this.name];
967
955
  return `${event.title}`;
968
- }
969
- if (parent instanceof ViewElement) {
956
+ } else if (parent instanceof ViewElement) {
970
957
  const eventName = `${parent.tag}-${this.name}`;
971
958
  if (elementsEventsMap[eventName]) {
972
959
  const event = elementsEventsMap[eventName];
973
960
  return `${event.title}`;
974
- }
975
- if (['click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'focus', 'blur'].includes(this.name)) {
961
+ } else if (['click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'focus', 'blur'].includes(this.name)) {
976
962
  const event = elementsEventsMap[this.name];
977
963
  return `${event.title}`;
978
964
  }
979
965
  return `${this.name}`;
980
966
  }
981
967
  }
982
-
983
968
  getViewEventName() {
984
969
  // 名称规则:组件的名称 + 组件的事件 + 逻辑本身的事件 用下划线链接
985
- const { parentNode } = this;
970
+ const parentNode = this.parentNode;
986
971
  const newName = this.name.replace(/-/g, '');
987
972
  if (parentNode instanceof ViewElement) {
988
973
  return `${parentNode.name}_${newName}`;
989
- }
990
- if (parentNode instanceof View) {
974
+ } else if (parentNode instanceof View) {
991
975
  return `${this.view.name}_${newName}`;
976
+ } else {
977
+ // 这里编译成这个名字了 后续pctemplate 里也得按这个调用?
978
+ // 或者说因为会编译在不同的端里 直接 name好了
979
+ // return `${this.parentNode.name}_${newName}`;
980
+ return newName;
992
981
  }
993
- // 这里编译成这个名字了 后续pctemplate 里也得按这个调用?
994
- // 或者说因为会编译在不同的端里 直接 name好了
995
- // return `${this.parentNode.name}_${newName}`;
996
- return newName;
997
982
  }
998
-
999
983
  toFunction(state?: TranslatorState): string {
1000
984
  // shiftState(state, code)
1001
985
  // 和 toJS一样的 只是下一行增加了 function 关键字
@@ -1011,7 +995,6 @@ export class BindEvent extends BaseNode {
1011
995
  code += '}\n';
1012
996
  return code;
1013
997
  }
1014
-
1015
998
  getTsNamespace() {
1016
999
  if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
1017
1000
  const parentNamespace = (this.parentNode as Namespace).getNamespace();
@@ -1022,10 +1005,8 @@ export class BindEvent extends BaseNode {
1022
1005
  arr.push(parentName);
1023
1006
  }
1024
1007
  return `${arr.join('.')}.bindEvents`;
1025
- }
1026
- throw new Error('无法获取命名空间,请设置 parentNode!');
1008
+ } else throw new Error('无法获取命名空间,请设置 parentNode!');
1027
1009
  }
1028
-
1029
1010
  toEmbeddedTSFile() {
1030
1011
  let code = `namespace ${this.getTsNamespace()} {\n`;
1031
1012
  const state = createCompilerState(code, {
@@ -1047,7 +1028,6 @@ export class BindEvent extends BaseNode {
1047
1028
  sourceMap: state.sourceMap,
1048
1029
  };
1049
1030
  }
1050
-
1051
1031
  /**
1052
1032
  * 生成宿主语言的文件路径
1053
1033
  * @param name 一般不用传,用于 rename
@@ -1057,22 +1037,22 @@ export class BindEvent extends BaseNode {
1057
1037
  let parent = this.parentNode;
1058
1038
  if (parent) {
1059
1039
  while (parent && parent instanceof View) {
1060
- pathName = `${parent.name}/${pathName}`;
1040
+ pathName = parent.name + '/' + pathName;
1061
1041
  parent = parent.parentNode;
1062
1042
  }
1063
1043
  }
1064
1044
  return `/embedded/${this.app.name}/frontends/${this.frontend.name}/bindEvents/${pathName}.ts`;
1065
1045
  }
1066
1046
 
1067
- //= ===============================================================================
1047
+ //================================================================================
1068
1048
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1069
1049
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
1070
- //= ===============================================================================
1050
+ //================================================================================
1071
1051
  }
1072
1052
 
1073
1053
  classMap.BindEvent = BindEvent;
1074
1054
  export default BindEvent;
1075
- //= ===============================================================================
1055
+ //================================================================================
1076
1056
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1077
1057
  // 自动生成的代码已结束。下面可以手动编写。
1078
- //= ===============================================================================
1058
+ //================================================================================
@@ -1,5 +1,5 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
2
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
3
3
  import ViewElement, { ElementToVueOptions } from './ViewElement__';
4
4
  import MemberExpression from './MemberExpression__';
5
5
  //= ===============================================================================
@@ -480,7 +480,7 @@ export class BindStyle extends BaseNode {
480
480
  }
481
481
 
482
482
  @withSourceMap()
483
- toEmbeddedTS(state?: TranslatorState): string {
483
+ toEmbeddedTS(state = createCompilerState()): string {
484
484
  let code = '()=>{';
485
485
  if (this.expression) {
486
486
  code += this.expression.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
@@ -1,5 +1,5 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
- import { TranslatorState, withSourceMap } from '../translator';
2
+ import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
3
3
  import { ElementToVueOptions } from './ViewElement__';
4
4
  //= ===============================================================================
5
5
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -69,7 +69,7 @@ export class BooleanLiteral extends LogicItem {
69
69
  }
70
70
 
71
71
  @withSourceMap()
72
- toEmbeddedTS(state?: TranslatorState) {
72
+ toEmbeddedTS(state = createCompilerState()) {
73
73
  return `new nasl.core.Boolean(${this.value})`;
74
74
  }
75
75
 
@@ -1,6 +1,6 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
2
  import Param from './Param__';
3
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
3
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
4
4
  import { getNodeByNodeCallee } from '../automate/engine/utils.js';
5
5
  import AuthLogicForCallInterface from './AuthLogicForCallInterface__';
6
6
  import LogicItem from './LogicItem__';
@@ -330,7 +330,7 @@ export class CallAuthInterface extends CallInterface {
330
330
  }
331
331
 
332
332
  @withSourceMap()
333
- toEmbeddedTS(state?: TranslatorState): string {
333
+ toEmbeddedTS(state = createCompilerState()): string {
334
334
  let code = this.tsAuthLogicKey;
335
335
  // 目前没有任何其他范型,故这里先支持默认俩范型
336
336
  // FIXME
@@ -6,7 +6,7 @@ import Argument from './Argument__';
6
6
  import Identifier from './Identifier__';
7
7
  import TypeAnnotation from './TypeAnnotation__';
8
8
  import Connection from './Connection__';
9
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
9
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
10
10
 
11
11
  //= ===============================================================================
12
12
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -190,7 +190,7 @@ export class CallConnector extends CallLogic {
190
190
  }
191
191
 
192
192
  @withSourceMap()
193
- toEmbeddedTS(state?: TranslatorState): string {
193
+ toEmbeddedTS(state = createCompilerState()): string {
194
194
  let code = '';
195
195
  if (this.handleError) {
196
196
  code += 'nasl.util.autoHandleError(';
@@ -1,5 +1,5 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
2
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
3
3
  import Function from './Function__';
4
4
  import { ElementToVueOptions } from './ViewElement__';
5
5
  import Identifier from './Identifier__';
@@ -558,7 +558,7 @@ export class CallFunction extends LogicItem {
558
558
  }
559
559
 
560
560
  @withSourceMap()
561
- toEmbeddedTS(state?: TranslatorState): string {
561
+ toEmbeddedTS(state = createCompilerState()): string {
562
562
  let code = '';
563
563
  const { calleeKey } = this;
564
564
  if (['nasl.util.Convert', 'nasl.util.FromString'].includes(calleeKey)) {
@@ -596,7 +596,7 @@ export class CallFunction extends LogicItem {
596
596
  }
597
597
 
598
598
  @withSourceMap()
599
- toNaturalTS(state?: TranslatorState): string {
599
+ toNaturalTS(state = createCompilerState()): string {
600
600
  let code = '';
601
601
  code = this.calleeKey;
602
602
  if (Array.isArray(this.typeArguments) && this.typeArguments.length) {
@@ -1,5 +1,5 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
2
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
3
3
  import Interface from './Interface__';
4
4
  import NullLiteral from './NullLiteral__';
5
5
  import { ElementToVueOptions } from './ViewElement__';
@@ -402,7 +402,7 @@ export class CallInterface extends LogicItem {
402
402
  }
403
403
 
404
404
  @withSourceMap()
405
- toEmbeddedTS(state?: TranslatorState): string {
405
+ toEmbeddedTS(state = createCompilerState()): string {
406
406
  const { completeArguments, parentNode, parentKey, tsCalleeKey } = this;
407
407
 
408
408
  let code = `${tsCalleeKey}(`;
@@ -437,7 +437,7 @@ export class CallInterface extends LogicItem {
437
437
  }
438
438
 
439
439
  @withSourceMap()
440
- toNaturalTS(state?: TranslatorState): string {
440
+ toNaturalTS(state = createCompilerState()): string {
441
441
  const { completeArguments, parentNode, parentKey, tsCalleeKey } = this;
442
442
 
443
443
  let code = `${tsCalleeKey}(`;
@@ -1,10 +1,10 @@
1
1
  import * as JSON5 from 'json5';
2
2
  import { v4 as uuidv4 } from 'uuid';
3
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
3
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
4
4
  import Logic from './Logic__';
5
5
  import Param from './Param__';
6
6
  import View from './View__';
7
- import { ElementToVueOptions } from './ViewElement__';
7
+ import ViewElement, { ElementToVueOptions } from './ViewElement__';
8
8
  import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
9
9
  import { findConceptKeyWordIndexFromNamespace } from '../utils';
10
10
  import { config } from '../config';
@@ -702,14 +702,64 @@ export class CallLogic extends LogicItem {
702
702
  ) {
703
703
  code += '$global.';
704
704
  }
705
- code += this.calleeName;
706
- code += '(';
707
- const { completeArguments } = this;
708
- completeArguments.forEach((arg, index) => {
709
- code += arg?.toVue(options);
710
- if (index !== completeArguments.length - 1) code += ', ';
711
- });
712
- code += ')';
705
+ const completeArguments = this.completeArguments;
706
+ if (this.concept === 'CallLogic' && this.getAncestor('BindAttribute')?.name === 'data-source') {
707
+ const currentElement = this.getAncestor('ViewElement') as ViewElement
708
+ code += '(params) => {\n'
709
+ code += `this['__${currentElement.name}_params'] = {...params};\n`
710
+ code += `return this.$logics['${this.calleeNamespace ? `${this.calleeNamespace}.${this.calleeName}` : this.calleeName}']`
711
+ code += `({
712
+ config: {
713
+ download: false,
714
+ },
715
+ query: {},`;
716
+ code += `
717
+ headers: {
718
+ "lcap-calllogic-uuid": "${this.uuid}",
719
+ },
720
+ `;
721
+ code += `path: {},
722
+ body: {`;
723
+ const logic = getNodeByNodeCallee(this.app, this.calleewholeKey, (key: string, tempPoint: any) => {
724
+ // 处理 NASL 中未定义的假的节点
725
+ if (key === tempPoint?.name) {
726
+ return {
727
+ tempPoint,
728
+ state: 1,
729
+ };
730
+ }
731
+ const t = tempPoint?.[key];
732
+ return {
733
+ tempPoint: t,
734
+ state: Array.isArray(t) ? 2 : 1,
735
+ };
736
+ });
737
+ const args = logic?.params || [];
738
+ const argsStr = args
739
+ .map((arg: any, index: number) => {
740
+ const actualArg = completeArguments[index];
741
+ return {
742
+ keyword: arg?.name,
743
+ arg: actualArg,
744
+ };
745
+ })
746
+ .map((obj: any) => `\n${obj?.keyword}: ${obj?.arg?.toVue(options)}`)
747
+ .join(', ');
748
+ code += argsStr;
749
+ if (Array.isArray(this.typeArguments) && this.typeArguments.length) {
750
+ code += `,\n__typeArguments: ${JSON5.stringify(this.typeArguments)}`;
751
+ }
752
+ code += '\n}';
753
+ code += '}';
754
+ } else {
755
+ code += this.calleeName;
756
+ code += '(';
757
+ completeArguments.forEach((arg, index) => {
758
+ code += arg?.toVue(options);
759
+ if (index !== completeArguments.length - 1) code += ', ';
760
+ });
761
+ }
762
+ code += ')}';
713
763
  return code;
714
764
  }
715
765
 
@@ -739,6 +789,9 @@ export class CallLogic extends LogicItem {
739
789
  });
740
790
  }
741
791
  code += ')';
792
+ if (this.concept === 'CallLogic' && this.getAncestor('BindAttribute')?.name === 'data-source') {
793
+ return this.calleeName
794
+ }
742
795
 
743
796
  return code;
744
797
  }
@@ -1092,7 +1145,7 @@ export class CallLogic extends LogicItem {
1092
1145
  }
1093
1146
 
1094
1147
  @withSourceMap()
1095
- toEmbeddedTS(state?: TranslatorState): string {
1148
+ toEmbeddedTS(state = createCompilerState()): string {
1096
1149
  let code = '';
1097
1150
 
1098
1151
  const {
@@ -1136,6 +1189,9 @@ export class CallLogic extends LogicItem {
1136
1189
  });
1137
1190
  code += ')';
1138
1191
  } else if (completeArguments.length) {
1192
+ if (['expression'].includes(parentKey) && this.getAncestor('BindAttribute')?.name === 'data-source' && (state as any)?.noNeedParams) {
1193
+ return
1194
+ }
1139
1195
  code += '(';
1140
1196
  completeArguments.forEach((arg, index) => {
1141
1197
  // 取到是不是必填放入参数中
@@ -1152,7 +1208,7 @@ export class CallLogic extends LogicItem {
1152
1208
  const setEndSemi = () => {
1153
1209
  const { concept: parentConcept } = parentNode ?? {};
1154
1210
  if (
1155
- !['test', 'patterns', 'returnExpression'].includes(parentKey) &&
1211
+ !['test', 'patterns', 'returnExpression', 'expression'].includes(parentKey) &&
1156
1212
  ![
1157
1213
  'Argument',
1158
1214
  'Assignment',
@@ -1211,7 +1267,7 @@ export class CallLogic extends LogicItem {
1211
1267
  }
1212
1268
 
1213
1269
  @withSourceMap()
1214
- toNaturalTS(state?: TranslatorState): string {
1270
+ toNaturalTS(state = createCompilerState()): string {
1215
1271
  const {
1216
1272
  handleError,
1217
1273
  calleeKey,
@@ -1,5 +1,5 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
2
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
3
3
  import QueryJoinExpression from './QueryJoinExpression__';
4
4
  import Entity from './Entity__';
5
5
  import Structure from './Structure__';
@@ -953,7 +953,7 @@ export class CallQueryComponent extends LogicItem {
953
953
  }
954
954
 
955
955
  @withSourceMap()
956
- toEmbeddedTS(state?: TranslatorState): string {
956
+ toEmbeddedTS(state = createCompilerState()): string {
957
957
  if (!this.typeAnnotation)
958
958
  return `(function () {
959
959
  return;
@@ -1,5 +1,5 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
- import { TranslatorState, withSourceMap, indent } from '../translator';
2
+ import { TranslatorState, withSourceMap, indent, createCompilerState } from '../translator';
3
3
  //= ===============================================================================
4
4
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
5
5
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -75,7 +75,7 @@ export class Comment extends LogicItem {
75
75
  }
76
76
 
77
77
  @withSourceMap()
78
- toEmbeddedTS(state?: TranslatorState): string {
78
+ toEmbeddedTS(state = createCompilerState()): string {
79
79
  let code = '';
80
80
  code += `\n${indent(state?.tabSize || 0)}
81
81
  /**