@lcap/nasl 3.8.0-beta.3 → 3.8.0-beta.5

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 (320) hide show
  1. package/out/automate/engine/utils.js +1 -2
  2. package/out/automate/engine/utils.js.map +1 -1
  3. package/out/bak/translator.js +1 -1
  4. package/out/bak/translator.js.map +1 -1
  5. package/out/common/BaseNode.js +7 -2
  6. package/out/common/BaseNode.js.map +1 -1
  7. package/out/concepts/App__.js +6 -1
  8. package/out/concepts/App__.js.map +1 -1
  9. package/out/concepts/Argument__.js +11 -5
  10. package/out/concepts/Argument__.js.map +1 -1
  11. package/out/concepts/AuthLogicForCallInterface__.js +3 -0
  12. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
  13. package/out/concepts/BinaryExpression__.js +49 -2
  14. package/out/concepts/BinaryExpression__.js.map +1 -1
  15. package/out/concepts/BindAttribute__.d.ts +4 -3
  16. package/out/concepts/BindAttribute__.js +121 -42
  17. package/out/concepts/BindAttribute__.js.map +1 -1
  18. package/out/concepts/BindEvent__.js +5 -42
  19. package/out/concepts/BindEvent__.js.map +1 -1
  20. package/out/concepts/BusinessComponent__.d.ts +1 -0
  21. package/out/concepts/BusinessComponent__.js +16 -0
  22. package/out/concepts/BusinessComponent__.js.map +1 -1
  23. package/out/concepts/BusinessLogic__.js +3 -0
  24. package/out/concepts/BusinessLogic__.js.map +1 -1
  25. package/out/concepts/CallConnector__.js +1 -1
  26. package/out/concepts/CallConnector__.js.map +1 -1
  27. package/out/concepts/CallFunction__.js +1 -1
  28. package/out/concepts/CallFunction__.js.map +1 -1
  29. package/out/concepts/CallLogic__.d.ts +6 -1
  30. package/out/concepts/CallLogic__.js +58 -17
  31. package/out/concepts/CallLogic__.js.map +1 -1
  32. package/out/concepts/Connection__.d.ts +4 -0
  33. package/out/concepts/Connection__.js +15 -0
  34. package/out/concepts/Connection__.js.map +1 -1
  35. package/out/concepts/DatabaseTypeAnnotation__.d.ts +2 -0
  36. package/out/concepts/DatabaseTypeAnnotation__.js +20 -0
  37. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
  38. package/out/concepts/End__.js +5 -1
  39. package/out/concepts/End__.js.map +1 -1
  40. package/out/concepts/EntityProperty__.js +2 -0
  41. package/out/concepts/EntityProperty__.js.map +1 -1
  42. package/out/concepts/Entity__.d.ts +1 -0
  43. package/out/concepts/Entity__.js +24 -1
  44. package/out/concepts/Entity__.js.map +1 -1
  45. package/out/concepts/EnumItem__.d.ts +12 -0
  46. package/out/concepts/EnumItem__.js +49 -5
  47. package/out/concepts/EnumItem__.js.map +1 -1
  48. package/out/concepts/Enum__.js +4 -1
  49. package/out/concepts/Enum__.js.map +1 -1
  50. package/out/concepts/ForEachStatement__.js +1 -1
  51. package/out/concepts/ForEachStatement__.js.map +1 -1
  52. package/out/concepts/FrontendLibrary__.d.ts +46 -46
  53. package/out/concepts/FrontendLibrary__.js +34 -36
  54. package/out/concepts/FrontendLibrary__.js.map +1 -1
  55. package/out/concepts/I18nInfo__.d.ts +1 -0
  56. package/out/concepts/I18nInfo__.js +7 -0
  57. package/out/concepts/I18nInfo__.js.map +1 -1
  58. package/out/concepts/IfStatement__.js +2 -2
  59. package/out/concepts/IfStatement__.js.map +1 -1
  60. package/out/concepts/Interface__.js +4 -1
  61. package/out/concepts/Interface__.js.map +1 -1
  62. package/out/concepts/Logic__.d.ts +2 -3
  63. package/out/concepts/Logic__.js +33 -8
  64. package/out/concepts/Logic__.js.map +1 -1
  65. package/out/concepts/MatchCase__.d.ts +2 -2
  66. package/out/concepts/MatchCase__.js +7 -7
  67. package/out/concepts/MatchCase__.js.map +1 -1
  68. package/out/concepts/NewComposite__.js +2 -1
  69. package/out/concepts/NewComposite__.js.map +1 -1
  70. package/out/concepts/NewList__.js +2 -1
  71. package/out/concepts/NewList__.js.map +1 -1
  72. package/out/concepts/NewMap__.js +2 -1
  73. package/out/concepts/NewMap__.js.map +1 -1
  74. package/out/concepts/OqlQueryComponent__.js +3 -11
  75. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  76. package/out/concepts/OverriddenLogic__.js +7 -0
  77. package/out/concepts/OverriddenLogic__.js.map +1 -1
  78. package/out/concepts/Param__.js +2 -1
  79. package/out/concepts/Param__.js.map +1 -1
  80. package/out/concepts/ProcessElementV2__.d.ts +4 -5
  81. package/out/concepts/ProcessElementV2__.js +12 -17
  82. package/out/concepts/ProcessElementV2__.js.map +1 -1
  83. package/out/concepts/ProcessElement__.d.ts +3 -4
  84. package/out/concepts/ProcessElement__.js +44 -46
  85. package/out/concepts/ProcessElement__.js.map +1 -1
  86. package/out/concepts/ProcessV2__.d.ts +5 -0
  87. package/out/concepts/ProcessV2__.js +30 -2
  88. package/out/concepts/ProcessV2__.js.map +1 -1
  89. package/out/concepts/Process__.d.ts +5 -0
  90. package/out/concepts/Process__.js +28 -0
  91. package/out/concepts/Process__.js.map +1 -1
  92. package/out/concepts/QueryFromExpression__.js +2 -2
  93. package/out/concepts/QueryFromExpression__.js.map +1 -1
  94. package/out/concepts/QueryJoinExpression__.js +2 -2
  95. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  96. package/out/concepts/Return__.d.ts +1 -1
  97. package/out/concepts/Return__.js +2 -1
  98. package/out/concepts/Return__.js.map +1 -1
  99. package/out/concepts/StaticString__.d.ts +4 -0
  100. package/out/concepts/StaticString__.js +11 -0
  101. package/out/concepts/StaticString__.js.map +1 -1
  102. package/out/concepts/StructureProperty__.js +5 -2
  103. package/out/concepts/StructureProperty__.js.map +1 -1
  104. package/out/concepts/Structure__.js +9 -3
  105. package/out/concepts/Structure__.js.map +1 -1
  106. package/out/concepts/SubLogic__.d.ts +1 -3
  107. package/out/concepts/SubLogic__.js +14 -8
  108. package/out/concepts/SubLogic__.js.map +1 -1
  109. package/out/concepts/Transactional__.d.ts +1 -0
  110. package/out/concepts/Transactional__.js +7 -0
  111. package/out/concepts/Transactional__.js.map +1 -1
  112. package/out/concepts/TypeParam__.d.ts +4 -0
  113. package/out/concepts/TypeParam__.js +3 -0
  114. package/out/concepts/TypeParam__.js.map +1 -1
  115. package/out/concepts/ValidationRule__.d.ts +1 -6
  116. package/out/concepts/ValidationRule__.js +9 -6
  117. package/out/concepts/ValidationRule__.js.map +1 -1
  118. package/out/concepts/Variable__.d.ts +1 -1
  119. package/out/concepts/Variable__.js +7 -2
  120. package/out/concepts/Variable__.js.map +1 -1
  121. package/out/concepts/ViewElement__.d.ts +2 -0
  122. package/out/concepts/ViewElement__.js +130 -47
  123. package/out/concepts/ViewElement__.js.map +1 -1
  124. package/out/concepts/View__.d.ts +8 -0
  125. package/out/concepts/View__.js +123 -7
  126. package/out/concepts/View__.js.map +1 -1
  127. package/out/concepts/basics/stdlib/nasl.processV2.js +2 -2
  128. package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
  129. package/out/concepts/basics/stdlib/nasl.ui.js +1 -1
  130. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  131. package/out/concepts/basics/stdlib/nasl.validation.js +110 -4
  132. package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
  133. package/out/generator/genBundleFiles.d.ts +2 -0
  134. package/out/generator/genBundleFiles.js +51 -37
  135. package/out/generator/genBundleFiles.js.map +1 -1
  136. package/out/generator/genMetaData.js +20 -26
  137. package/out/generator/genMetaData.js.map +1 -1
  138. package/out/generator/release-body/body.js +8 -6
  139. package/out/generator/release-body/body.js.map +1 -1
  140. package/out/generator/release-body/index.d.ts +1 -0
  141. package/out/generator/release-body/index.js +1 -0
  142. package/out/generator/release-body/index.js.map +1 -1
  143. package/out/generator/release-body/utils.js +1 -1
  144. package/out/generator/release-body/utils.js.map +1 -1
  145. package/out/natural/genNaturalTS.d.ts +56 -24
  146. package/out/natural/genNaturalTS.js +182 -112
  147. package/out/natural/genNaturalTS.js.map +1 -1
  148. package/out/natural/getContext/getUILib.js +4 -2
  149. package/out/natural/getContext/getUILib.js.map +1 -1
  150. package/out/natural/getContext/index.d.ts +34 -25
  151. package/out/natural/getContext/index.js +304 -157
  152. package/out/natural/getContext/index.js.map +1 -1
  153. package/out/natural/index.d.ts +1 -0
  154. package/out/natural/index.js +1 -0
  155. package/out/natural/index.js.map +1 -1
  156. package/out/natural/tools.d.ts +11 -0
  157. package/out/natural/tools.js +155 -0
  158. package/out/natural/tools.js.map +1 -0
  159. package/out/natural/transformTS2UI.js +84 -22
  160. package/out/natural/transformTS2UI.js.map +1 -1
  161. package/out/natural/transformTSCode.js +83 -22
  162. package/out/natural/transformTSCode.js.map +1 -1
  163. package/out/server/formatTsUtils.js +17 -1
  164. package/out/server/formatTsUtils.js.map +1 -1
  165. package/out/server/getLogics.js +1 -4
  166. package/out/server/getLogics.js.map +1 -1
  167. package/out/server/naslServer.js +285 -32
  168. package/out/server/naslServer.js.map +1 -1
  169. package/out/server/translator.js +5 -1
  170. package/out/server/translator.js.map +1 -1
  171. package/out/templator/genCreateBlock.js +5 -18
  172. package/out/templator/genCreateBlock.js.map +1 -1
  173. package/out/templator/genCurdMultipleKeyBlock.js +11 -32
  174. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  175. package/out/templator/genGetBlock.js +1 -2
  176. package/out/templator/genGetBlock.js.map +1 -1
  177. package/out/templator/genListViewBlock.js +6 -4
  178. package/out/templator/genListViewBlock.js.map +1 -1
  179. package/out/templator/genSelectBlock.js +82 -59
  180. package/out/templator/genSelectBlock.js.map +1 -1
  181. package/out/templator/genTableBlock.js +4 -4
  182. package/out/templator/genTableBlock.js.map +1 -1
  183. package/out/templator/genUpdateBlock.js +2 -15
  184. package/out/templator/genUpdateBlock.js.map +1 -1
  185. package/out/templator/utils.d.ts +1 -1
  186. package/out/templator/utils.js +1 -1
  187. package/out/templator/utils.js.map +1 -1
  188. package/out/translator/types.d.ts +4 -0
  189. package/out/translator/utils.d.ts +1 -0
  190. package/out/translator/utils.js +6 -1
  191. package/out/translator/utils.js.map +1 -1
  192. package/out/utils/env.d.ts +4 -0
  193. package/out/utils/env.js +6 -3
  194. package/out/utils/env.js.map +1 -1
  195. package/out/utils/index.d.ts +19 -0
  196. package/out/utils/index.js +61 -1
  197. package/out/utils/index.js.map +1 -1
  198. package/out/utils/language-cache/constant.d.ts +18 -0
  199. package/out/utils/language-cache/constant.js +35 -0
  200. package/out/utils/language-cache/constant.js.map +1 -0
  201. package/out/utils/language-cache/index.d.ts +2 -0
  202. package/out/utils/language-cache/index.js +19 -0
  203. package/out/utils/language-cache/index.js.map +1 -0
  204. package/out/utils/language-cache/nasl.d.ts +10 -0
  205. package/out/utils/language-cache/nasl.js +98 -0
  206. package/out/utils/language-cache/nasl.js.map +1 -0
  207. package/out/utils/language-cache/types.d.ts +44 -0
  208. package/out/utils/language-cache/types.js +4 -0
  209. package/out/utils/language-cache/types.js.map +1 -0
  210. package/out/utils/time-slicing/controller.js.map +1 -1
  211. package/out/utils/types.d.ts +17 -0
  212. package/package.json +3 -2
  213. package/sandbox/stdlib/nasl.core.ts +15 -11
  214. package/sandbox/stdlib/nasl.oql.ts +5 -1
  215. package/sandbox/stdlib/nasl.processV2.ts +5 -4
  216. package/sandbox/stdlib/nasl.ui.components.pc.ts +225 -225
  217. package/sandbox/stdlib/nasl.ui.ts +10 -0
  218. package/sandbox/stdlib/nasl.util.ts +11 -0
  219. package/sandbox/stdlib/nasl.validation.ts +3 -2
  220. package/sandbox-natural/stdlib/nasl.ui.pre.d.ts +1 -1
  221. package/sandbox-natural/stdlib/nasl.ui.ts +2 -2
  222. package/sandbox-natural/stdlib/nasl.util.ts +2 -2
  223. package/src/automate/engine/utils.js +1 -2
  224. package/src/bak/translator.js +1 -1
  225. package/src/common/BaseNode.ts +7 -3
  226. package/src/concepts/App__.ts +9 -1
  227. package/src/concepts/Argument__.ts +10 -5
  228. package/src/concepts/AuthLogicForCallInterface__.ts +3 -0
  229. package/src/concepts/BinaryExpression__.ts +46 -2
  230. package/src/concepts/BindAttribute__.ts +144 -46
  231. package/src/concepts/BindEvent__.ts +8 -47
  232. package/src/concepts/BusinessComponent__.ts +17 -0
  233. package/src/concepts/BusinessLogic__.ts +3 -0
  234. package/src/concepts/CallConnector__.ts +1 -1
  235. package/src/concepts/CallFunction__.ts +1 -1
  236. package/src/concepts/CallLogic__.ts +63 -17
  237. package/src/concepts/Connection__.ts +16 -0
  238. package/src/concepts/DatabaseTypeAnnotation__.ts +11 -0
  239. package/src/concepts/End__.ts +5 -1
  240. package/src/concepts/EntityProperty__.ts +5 -0
  241. package/src/concepts/Entity__.ts +29 -1
  242. package/src/concepts/EnumItem__.ts +64 -1
  243. package/src/concepts/Enum__.ts +6 -1
  244. package/src/concepts/ForEachStatement__.ts +1 -1
  245. package/src/concepts/FrontendLibrary__.ts +78 -80
  246. package/src/concepts/I18nInfo__.ts +5 -0
  247. package/src/concepts/IfStatement__.ts +2 -2
  248. package/src/concepts/Interface__.ts +6 -1
  249. package/src/concepts/Logic__.ts +39 -10
  250. package/src/concepts/MatchCase__.ts +8 -9
  251. package/src/concepts/NewComposite__.ts +2 -1
  252. package/src/concepts/NewList__.ts +2 -1
  253. package/src/concepts/NewMap__.ts +2 -1
  254. package/src/concepts/OqlQueryComponent__.ts +3 -11
  255. package/src/concepts/OverriddenLogic__.ts +7 -0
  256. package/src/concepts/Param__.ts +1 -0
  257. package/src/concepts/ProcessElementV2__.ts +14 -16
  258. package/src/concepts/ProcessElement__.ts +16 -16
  259. package/src/concepts/ProcessV2__.ts +39 -3
  260. package/src/concepts/Process__.ts +36 -0
  261. package/src/concepts/QueryFromExpression__.ts +2 -2
  262. package/src/concepts/QueryJoinExpression__.ts +2 -2
  263. package/src/concepts/Return__.ts +2 -1
  264. package/src/concepts/StaticString__.ts +12 -0
  265. package/src/concepts/StructureProperty__.ts +7 -2
  266. package/src/concepts/Structure__.ts +11 -3
  267. package/src/concepts/SubLogic__.ts +15 -9
  268. package/src/concepts/Transactional__.ts +5 -0
  269. package/src/concepts/TypeParam__.ts +6 -0
  270. package/src/concepts/ValidationRule__.ts +7 -6
  271. package/src/concepts/Variable__.ts +7 -2
  272. package/src/concepts/ViewElement__.ts +130 -47
  273. package/src/concepts/View__.ts +157 -8
  274. package/src/concepts/basics/stdlib/nasl.processV2.ts +2 -2
  275. package/src/concepts/basics/stdlib/nasl.ui.ts +1 -1
  276. package/src/concepts/basics/stdlib/nasl.validation.ts +111 -4
  277. package/src/generator/genBundleFiles.ts +53 -39
  278. package/src/generator/genMetaData.ts +21 -26
  279. package/src/generator/release-body/body.ts +9 -6
  280. package/src/generator/release-body/index.ts +1 -0
  281. package/src/generator/release-body/utils.ts +4 -2
  282. package/src/natural/genNaturalTS.ts +327 -141
  283. package/src/natural/getContext/getUILib.ts +4 -2
  284. package/src/natural/getContext/index.ts +348 -171
  285. package/src/natural/index.ts +1 -0
  286. package/src/natural/tools.ts +130 -0
  287. package/src/natural/transformTS2UI.ts +84 -22
  288. package/src/natural/transformTSCode.ts +83 -22
  289. package/src/server/formatTsUtils.ts +21 -1
  290. package/src/server/getLogics.ts +1 -4
  291. package/src/server/naslServer.ts +302 -33
  292. package/src/server/translator.ts +5 -1
  293. package/src/templator/genCreateBlock.ts +5 -18
  294. package/src/templator/genCurdMultipleKeyBlock.ts +14 -32
  295. package/src/templator/genGetBlock.ts +2 -4
  296. package/src/templator/genListViewBlock.ts +6 -4
  297. package/src/templator/genSelectBlock.ts +88 -61
  298. package/src/templator/genTableBlock.ts +4 -4
  299. package/src/templator/genUpdateBlock.ts +2 -15
  300. package/src/templator/utils.ts +1 -1
  301. package/src/translator/types.ts +4 -0
  302. package/src/translator/utils.ts +6 -0
  303. package/src/utils/env.ts +5 -4
  304. package/src/utils/index.ts +50 -1
  305. package/src/utils/language-cache/constant.ts +37 -0
  306. package/src/utils/language-cache/index.ts +2 -0
  307. package/src/utils/language-cache/nasl.ts +83 -0
  308. package/src/utils/language-cache/types.ts +48 -0
  309. package/src/utils/time-slicing/controller.ts +0 -1
  310. package/src/utils/types.ts +20 -0
  311. package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +13 -13
  312. package/test/concepts/call-logic/__snapshots__/toEmbeddedTS.spec.ts.snap +12 -12
  313. package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +1 -2
  314. package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +221 -217
  315. package/ts-worker/bundle.js +1 -1
  316. package/ts-worker/src/index.js +0 -1
  317. package/out/utils/delay/index.d.ts +0 -0
  318. package/out/utils/delay/index.js +0 -1
  319. package/out/utils/delay/index.js.map +0 -1
  320. package/src/utils/delay/index.ts +0 -0
@@ -81,6 +81,7 @@ function genArgumentMemberExpression(arr: string[]) {
81
81
  export interface ElementToVueOptions {
82
82
  filterAttr?: Array<string>;
83
83
  isExport?: boolean;
84
+ isRelease?: boolean;
84
85
  isRoot?: boolean;
85
86
  asCompontent?: boolean;
86
87
  indentStyle?: 'space' | 'tab';
@@ -1633,31 +1634,44 @@ export class ViewElement extends Annotatable {
1633
1634
  let levelIndex = parentLevel || 0;
1634
1635
  code += `${self.name}: () => {\n`;
1635
1636
 
1636
- const getType = (name: string) => {
1637
- let t;
1637
+ const getMultipleDefaultValue = (name: string) => {
1638
+ let v = 'new nasl.core.BooleanFalse()';
1638
1639
  const attr = self.bindAttrs?.find((attr) => attr.name === name);
1639
1640
  if (['static', 'string'].includes(attr?.type)) {
1640
- t = attr.value ? 'true' : 'false';
1641
- } else if (['dynamic'].includes(attr?.type)) {
1642
- t = 'nasl.core.Boolean';
1643
- } else {
1644
- t = false;
1641
+ v = attr.value ? 'new nasl.core.BooleanTrue()' : 'new nasl.core.BooleanFalse()';
1645
1642
  }
1646
1643
 
1647
- return t;
1644
+ return v;
1648
1645
  };
1649
- const hasDataSource =
1650
- config?.allNodesAPI?.[self.tag]?.props?.findIndex((prop) => ['dataSource', 'data-source'].includes(prop.name)) >
1651
- -1;
1646
+ const getConverterDefaultValue = (name: string) => {
1647
+ let v = 'new nasl.core.StringLiteral<\`\`>()';
1648
+ const attr = self.bindAttrs?.find((attr) => attr.name === name);
1649
+ if (['static', 'string'].includes(attr?.type)) {
1650
+ if ([true, 'true'].includes(attr.value)) {
1651
+ v = 'new nasl.core.BooleanTrue()';
1652
+ } else if ([false, 'false'].includes(attr.value)) {
1653
+ v = 'new nasl.core.BooleanFalse()';
1654
+ } else {
1655
+ v = `new nasl.core.StringLiteral<\`${attr.value}\`>()`;
1656
+ }
1657
+ }
1658
+
1659
+ return v;
1660
+ }
1661
+
1662
+ const hasDataSource = config?.allNodesAPI?.[self.tag]?.props?.findIndex((prop) => ['dataSource', 'data-source'].includes(prop.name)) > -1;
1663
+ let dataSourceSetted = false;
1664
+ let staticItem = '';
1652
1665
  // 有数据源属性的组件 才需要生成 item
1653
1666
  if (hasDataSource && T) {
1654
1667
  const key = T1 ? '__columnItem' : '__item';
1655
1668
  const dataSourceAttr = self.bindAttrs?.find((attr) => attr.name === 'dataSource');
1656
1669
  if (dataSourceAttr?.expression) {
1670
+ dataSourceSetted = true;
1657
1671
  if (
1658
1672
  asserts.isMemberExpression(dataSourceAttr.expression) ||
1659
1673
  asserts.isIdentifier(dataSourceAttr.expression) ||
1660
- asserts.isCallLogic(dataSourceAttr.expression)
1674
+ (asserts.isCallLogic(dataSourceAttr.expression) && !dataSourceAttr.expression?.calleeNamespace?.startsWith('extensions'))
1661
1675
  ) {
1662
1676
  const value = yield* dataSourceAttr.expression.toEmbeddedTS(
1663
1677
  shiftState(
@@ -1711,40 +1725,80 @@ export class ViewElement extends Annotatable {
1711
1725
  code += `let ${key}: nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof _load>>;\n`;
1712
1726
  }
1713
1727
  } else {
1714
- code += `let ${key}: any;\n`;
1728
+ // 根据静态子节点生成类型
1729
+ const attrs: Record<string, string> = {
1730
+ 'u-checkbox': 'label',
1731
+ 'u-radio': 'label',
1732
+ 'van-radio': 'name',
1733
+ 'van-checkbox': 'label',
1734
+ }
1735
+ const child = self.children?.filter((item) => item.tag !== 'template')[0];
1736
+ if (child as ViewElement) {
1737
+ const valueAttr = child.bindAttrs?.find((attr) => attr.name === (attrs[child.tag] || 'value'));
1738
+ if (valueAttr) {
1739
+ // 开启了绑定
1740
+ if (valueAttr.expression) {
1741
+ const attrCode = yield* valueAttr.expression.toEmbeddedTS(shiftState(state, '', { tabSize: 0 }));
1742
+ staticItem = `${attrCode}`;
1743
+ } else {
1744
+ try {
1745
+ if (valueAttr.type === 'static') {
1746
+ const value = json5.parse(valueAttr.value);
1747
+ const map: Record<string, string> = {
1748
+ 'string': 'new nasl.core.String("")',
1749
+ 'number': 'new nasl.core.Long(1)',
1750
+ 'boolean': 'new nasl.core.Boolean(false)',
1751
+ }
1752
+
1753
+ staticItem = map[typeof value] || 'new nasl.core.String("")';
1754
+ } else {
1755
+ staticItem = 'new nasl.core.String("")';
1756
+ }
1757
+ } catch (error) {
1758
+ // @ts-ignore
1759
+ }
1760
+ }
1761
+ } else {
1762
+ staticItem = 'new nasl.core.String("")';
1763
+ }
1764
+ }
1765
+ code += `let __staticItem = ${staticItem};\n`;
1766
+ code += `let ${key}: typeof __staticItem;\n`;
1715
1767
  }
1716
1768
  }
1717
1769
  // 值
1718
1770
  let valueType: string;
1719
1771
  if (hasDataSource && V && !T1) {
1720
1772
  const valueFieldAttr = self.bindAttrs?.find((attr) => attr.name === 'valueField');
1721
- if (['static', 'string'].includes(valueFieldAttr?.type)) {
1773
+ if (dataSourceSetted && ['static', 'string'].includes(valueFieldAttr?.type)) {
1722
1774
  valueType = `typeof __item.${valueFieldAttr.value}`;
1723
1775
  } else {
1724
- valueType = 'any';
1776
+ valueType = `typeof __staticItem`;
1725
1777
  }
1726
1778
  }
1727
1779
  // 分页
1728
- let pageableType: string | boolean;
1780
+ let pageableDefaultValue: string;
1729
1781
  if (hasDataSource && P && !T1) {
1730
- pageableType = getType('pageable');
1731
- code += `let __pageable: ${pageableType};\n`;
1782
+ pageableDefaultValue = getMultipleDefaultValue('pageable');
1783
+ code += `let __pageable = ${pageableDefaultValue};\n`;
1732
1784
  }
1733
1785
  // 多选
1734
- let multipleType: string | boolean;
1786
+ let multipleDefaultValue: string;
1735
1787
  if (hasDataSource && M && !T1) {
1736
- multipleType = getType('multiple');
1737
- code += `let __multiple: ${multipleType};\n`;
1788
+ multipleDefaultValue = getMultipleDefaultValue('multiple');
1789
+ code += `let __multiple = ${multipleDefaultValue};\n`;
1738
1790
  }
1739
1791
  if (hasDataSource && V && !T1) {
1740
1792
  code += `// @ts-ignore
1741
- let __value: ${valueType}${[true, 'true'].includes(multipleType) ? '[]' : ''};\n`;
1793
+ let __value: typeof __multiple extends nasl.core.BooleanTrue ? ${valueType}[] : ${valueType};\n`;
1742
1794
  code += `// @ts-ignore
1743
1795
  let __V: ${valueType};\n`;
1744
1796
  }
1797
+
1798
+ let converterDefaultValue: string;
1745
1799
  if (C) {
1746
- // code += `let converter: ${getType('converter')};\n`;
1747
- code += `let __converter: any;\n`;
1800
+ converterDefaultValue = getConverterDefaultValue('converter');
1801
+ code += `let __converter = ${converterDefaultValue};\n`;
1748
1802
  }
1749
1803
 
1750
1804
  if (self.tag === 'template' && self.haveScope() && asserts.isViewElement(self.parentNode)) {
@@ -2055,12 +2109,10 @@ export class ViewElement extends Annotatable {
2055
2109
  return;
2056
2110
  }
2057
2111
 
2058
- let attrCode = yield* attr.toEmbeddedTS(shiftState(state, code, { tabSize: 1 }));
2112
+ let attrCode = yield* attr.toEmbeddedTS(shiftState(state, code, { tabSize: 1 }), { carryName: true });
2059
2113
 
2060
2114
  if (attrCode.trim()) {
2061
- const humpName = self.toHump(attr.name);
2062
- code += `${humpName}: `;
2063
- attrCode = yield* attr.toEmbeddedTS(shiftState(state, code, { tabSize: 1 }));
2115
+ attrCode = yield* attr.toEmbeddedTS(shiftState(state, code, { tabSize: 1 }), { carryName: true });
2064
2116
  code += attrCode;
2065
2117
  code += `,\n`;
2066
2118
  }
@@ -2149,7 +2201,8 @@ export class ViewElement extends Annotatable {
2149
2201
  const param = hasScope ? `current${levelIndex === 0 ? '' : levelIndex}` : '';
2150
2202
  const levelIndexDelta = Number(hasScope);
2151
2203
  code += `slotDefault: (${param}) => [\n`;
2152
- yield* wrapForEach(children, function* warpForEachGenerator(element) {
2204
+ const defaultArr = self.shouldHandleChildren(self) ? children : [];
2205
+ yield* wrapForEach(defaultArr, function* warpForEachGenerator(element) {
2153
2206
  code += yield* element.toEmbeddedTS(
2154
2207
  shiftState(state, code, {
2155
2208
  tabSize: (state?.tabSize || 0) + 2,
@@ -2173,6 +2226,29 @@ export class ViewElement extends Annotatable {
2173
2226
  return code;
2174
2227
  }
2175
2228
 
2229
+ shouldHandleChildren(element: ViewElement) {
2230
+ // 数据源与静态子节点不共存的组件
2231
+ const tags = [
2232
+ 'u-tabs',
2233
+ 'u-selectable-steps',
2234
+ 'van-swipe',
2235
+ 'van-steps',
2236
+ ]; // 数据源与静态子节点不共存的组件
2237
+
2238
+ // 判断当前是否配置了数据源
2239
+ const isDataSourceConfigured = () => element.bindAttrs.some((attr) => {
2240
+ if (['data-source', 'dataSource'].includes(attr.name)) {
2241
+ if (attr.type === 'dynamic' && attr.expression) {
2242
+ return true;
2243
+ }
2244
+ }
2245
+
2246
+ return false;
2247
+ })
2248
+
2249
+ return !tags.includes(element.tag) || !isDataSourceConfigured();
2250
+ }
2251
+
2176
2252
  @withSourceMap()
2177
2253
  toNaturalTS(state = createCompilerState(), parentLevel?: number): string {
2178
2254
  let code = '';
@@ -2306,6 +2382,7 @@ export class ViewElement extends Annotatable {
2306
2382
  }),
2307
2383
  // levelIndex,
2308
2384
  );
2385
+ code += ',\n';
2309
2386
  });
2310
2387
 
2311
2388
  code += `${indent(state.tabSize + 1)}] },\n`;
@@ -2315,15 +2392,16 @@ export class ViewElement extends Annotatable {
2315
2392
  });
2316
2393
  // 翻译其余的子集
2317
2394
  if (defaultArr.length) {
2318
- throw new Error('多个插槽必须都在 template 内');
2319
- // defaultArr.forEach((element) => {
2320
- // code += element.toTextualNASL(
2321
- // shiftState(state, code, {
2322
- // tabSize: state.tabSize,
2323
- // }),
2324
- // // levelIndex,
2325
- // );
2326
- // });
2395
+ // throw new Error('多个插槽必须都在 template 内');
2396
+ defaultArr.forEach((element) => {
2397
+ code += element.toTextualNASL(
2398
+ shiftState(state, code, {
2399
+ tabSize: state.tabSize,
2400
+ }),
2401
+ // levelIndex,
2402
+ );
2403
+ code += ',\n';
2404
+ });
2327
2405
  }
2328
2406
  } else {
2329
2407
  if (this.children.length) {
@@ -3079,7 +3157,7 @@ export class ViewElement extends Annotatable {
3079
3157
  })
3080
3158
  }
3081
3159
  if (
3082
- options?.isExport &&
3160
+ (options?.isExport || options?.isRelease )&&
3083
3161
  attr?.concept === 'BindAttribute' &&
3084
3162
  attr?.name === 'src' &&
3085
3163
  /^\/assets\/(.*?)$/.test(attr?.value) &&
@@ -3119,7 +3197,6 @@ export class ViewElement extends Annotatable {
3119
3197
  argsList,
3120
3198
  dataRefList,
3121
3199
  };
3122
- // debugger
3123
3200
  // 所有参数序列化之后当字符串传进指令参数 (目前不支持<div v-demo="{ color: 'white', text: 'hello!' }"></div>
3124
3201
  let expression = StringLiteral.from({
3125
3202
  concept: 'StringLiteral',
@@ -3150,22 +3227,24 @@ export class ViewElement extends Annotatable {
3150
3227
  ve?.bindAttrs?.find((attr: any) => {
3151
3228
  let type = attr?.expression?.object?.__TypeAnnotation;
3152
3229
  if (type) {
3153
- console.log('type: ', type);
3154
3230
  let { typeKind, typeName, typeNamespace } = type || {};
3155
- // todo 这里可能不是匿名数据结构吗
3156
- if (typeKind === 'anonymousStructure') {
3231
+ if (typeKind === 'anonymousStructure') {
3157
3232
  let parent: any =
3158
3233
  this.getAncestorByTag('ViewElement', 'u-table-view') ||
3159
3234
  this.getAncestorByTag('ViewElement', 'u-list-view') ||
3160
3235
  this.getAncestorByTag('ViewElement', 'u-grid-view') ||
3161
3236
  this.getAncestorByTag('ViewElement', 'van-grid-view') ||
3162
3237
  this.getAncestorByTag('ViewElement', 'van-list-view');
3163
- if (parent?.tag) {
3238
+ let canAdd = parent?.tag
3239
+ if(isGridViewLayout ||isListViewLayout){
3240
+ let nestLinearLayout = this.children.find(c=>c.tag ==='u-linear-layout')
3241
+ canAdd = canAdd && !nestLinearLayout
3242
+ }
3243
+ if (canAdd) {
3164
3244
  let dataSourceAttr = parent?.bindAttrs?.find((it: any) => it?.name === 'dataSource');
3165
3245
  if (dataSourceAttr?.expression?.concept === 'CallLogic') {
3166
3246
  if (dataSourceAttr?.expression?.calleeNamespace === 'app.logics') {
3167
3247
  logicName = dataSourceAttr?.expression?.calleeName;
3168
- // debugger
3169
3248
  let ref = {
3170
3249
  typeNamespace: 'app.logics',
3171
3250
  typeName: logicName,
@@ -3202,11 +3281,15 @@ export class ViewElement extends Annotatable {
3202
3281
  const addDataRefDriective = (ve: ViewElement) => {
3203
3282
  ve?.bindAttrs?.find((attr: any) => {
3204
3283
  let type = attr?.expression?.object?.__TypeAnnotation;
3205
- if (type) {
3284
+ let canAdd = type
3285
+ if(isGridViewLayout || isListViewLayout){
3286
+ let nestLinearLayout = this.children.find(c=>c.tag ==='u-linear-layout')
3287
+ canAdd = canAdd && !nestLinearLayout
3288
+ }
3289
+ if (canAdd) {
3206
3290
  let { typeKind, typeName, typeNamespace } = type || {};
3207
3291
  if (typeKind === 'reference' && typeNamespace) {
3208
3292
  let entityPropName = attr?.expression?.property?.name;
3209
- // debugger;
3210
3293
  let ref = {
3211
3294
  typeNamespace,
3212
3295
  typeName,
@@ -31,6 +31,8 @@ import type Interface from './Interface__'; // 临时记录删除的页面元素
31
31
  import { getNodeByNodeCallee } from '../automate/engine/utils.js'; // 临时记录删除的页面元素计数的最大值
32
32
  import type LogicItem from './LogicItem__';
33
33
  import type CallFunction from './CallFunction__';
34
+ import type BaseNode from '../common/BaseNode';
35
+ import type SubLogic from './SubLogic__';
34
36
 
35
37
  import App from './App__';
36
38
  import Module from './Module__';
@@ -1661,6 +1663,93 @@ export class View extends Annotatable {
1661
1663
  }
1662
1664
  }
1663
1665
 
1666
+ mergeDefinitions2(code: string) {
1667
+ const Logic = getConceptConstructor('Logic');
1668
+ const Param = getConceptConstructor('Param');
1669
+ const Variable = getConceptConstructor('Variable');
1670
+ const BindEvent = getConceptConstructor('BindEvent');
1671
+ const definitionStr = utils.sliceTagContent(code, 'definition') || '{}';
1672
+ const definition: any = JSON.parse(definitionStr);
1673
+ // 服务端逻辑
1674
+ if (Array.isArray(definition.logics)) {
1675
+ definition.logics.forEach((logicOption: any) => {
1676
+ const logic = Logic.from(
1677
+ {
1678
+ ...logicOption,
1679
+ },
1680
+ this.rootNode,
1681
+ 'logics',
1682
+ );
1683
+ (this.rootNode as App).addLogic(logic);
1684
+ });
1685
+ }
1686
+
1687
+ // 全局结构体
1688
+ if (Array.isArray(definition.structures)) {
1689
+ definition.structures.forEach((structureOption: any) => {
1690
+ const structure = Structure.from(
1691
+ {
1692
+ ...structureOption,
1693
+ },
1694
+ this.rootNode,
1695
+ 'structures',
1696
+ );
1697
+ (this.rootNode as App).addStructure(structure);
1698
+ });
1699
+ }
1700
+
1701
+ // 页面入参
1702
+ if (Array.isArray(definition.viewParams)) {
1703
+ definition.viewParams.forEach((paramsOption: any) => {
1704
+ const param = Param.from(
1705
+ {
1706
+ ...paramsOption,
1707
+ },
1708
+ this,
1709
+ 'params',
1710
+ );
1711
+ this.addParam(param);
1712
+ });
1713
+ }
1714
+ // 页面变量
1715
+ if (Array.isArray(definition.viewVariables)) {
1716
+ definition.viewVariables.forEach((variableOption: any) => {
1717
+ const variable = Variable.from(
1718
+ {
1719
+ ...variableOption,
1720
+ },
1721
+ this,
1722
+ 'variables',
1723
+ );
1724
+ this.addVariable(variable);
1725
+ });
1726
+ }
1727
+
1728
+ // 页面事件
1729
+ if (Array.isArray(definition.viewBindEvents)) {
1730
+ definition.viewBindEvents.forEach((eventOption: any) => {
1731
+ const newLogic = definition.viewLogics.find((logic: Logic) => eventOption.calleeName === logic.name);
1732
+ const bindEvent = this.bindEvents.find((currentEventItem) => currentEventItem.name === eventOption.name);
1733
+
1734
+ // 如果没有event对象就先新增一个,如果已经有了就在内部添加logic
1735
+ if (!bindEvent) {
1736
+ const event = BindEvent.from(
1737
+ {
1738
+ ...eventOption,
1739
+ calleeName: '',
1740
+ logics: [newLogic],
1741
+ },
1742
+ this,
1743
+ 'bindEvents',
1744
+ );
1745
+ this.addBindEvent(event);
1746
+ } else {
1747
+ bindEvent.addLogic(newLogic);
1748
+ }
1749
+ });
1750
+ }
1751
+ }
1752
+
1664
1753
  onChange($event?: EventPayload): void {
1665
1754
  this.emit('change', $event);
1666
1755
  }
@@ -1788,7 +1877,8 @@ export class View extends Annotatable {
1788
1877
  };\n`;
1789
1878
  code += keyboardEventMixinCode;
1790
1879
  const processDetailFrom: ViewElement = this.getViewProcessForm(),
1791
- hasProcessDetailFrom = !!processDetailFrom, processV2 = this.getDestinationProcessV2();
1880
+ hasProcessDetailFrom = !!processDetailFrom,
1881
+ processV2 = this.getDestinationProcessV2();
1792
1882
  if (hasProcessDetailFrom) {
1793
1883
  const processDetailFromMixinCode = `const processDetailFromMixin = {
1794
1884
  data() {
@@ -1874,13 +1964,7 @@ export class View extends Annotatable {
1874
1964
  }
1875
1965
  },
1876
1966
  methods:{
1877
- // 将vmRoot的方法名包含handleDataSourceLoad的方法挂载到当前vm实例上
1878
- ...Object.keys(vmRoot).reduce((acc, cur) => {
1879
- if (cur.includes('handleDataSourceLoad')) {
1880
- acc[cur] = vmRoot[cur]
1881
- }
1882
- return acc
1883
- }, {}),
1967
+ ..._self.$options.methods
1884
1968
  }
1885
1969
  }).$mount()
1886
1970
  var parentElement = container.parentNode
@@ -2095,6 +2179,8 @@ export class View extends Annotatable {
2095
2179
  @withSourceMapGenerator
2096
2180
  *toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
2097
2181
  const self = this;
2182
+ // 获取所有子节点用于树上填充
2183
+ self.getSubLogics();
2098
2184
  function chineseTsName(name: string) {
2099
2185
  let tsName = name;
2100
2186
  // 匹配所有特殊字符都转为_
@@ -2131,6 +2217,9 @@ export class View extends Annotatable {
2131
2217
  // 内置函数对集合类型的推导
2132
2218
  (asserts.isCallFunction(el) && el.derivablecollection?.name))
2133
2219
  ) {
2220
+ if (el?.getAncestor('SubLogic')) {
2221
+ return;
2222
+ }
2134
2223
  // 子页面内部逻辑过滤
2135
2224
  if (el.view !== self) return;
2136
2225
  if (asserts.isAssignment(el)) {
@@ -2789,6 +2878,10 @@ export class View extends Annotatable {
2789
2878
  const calleeLogic = this.app.logics.find((l) => l.name === calleeName);
2790
2879
  return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
2791
2880
  }
2881
+ // 调用依赖库逻辑可能会有子逻辑,子逻辑拼接可能有ts忽略先去掉
2882
+ if (asserts.isCallLogic(rightNode) && rightNode.calleeNamespace?.startsWith('extensions.')) {
2883
+ code = code.replaceAll('// @ts-ignore', '');
2884
+ }
2792
2885
 
2793
2886
  // view 局部变量,申明提升前增加判断,使用 logic 内的 result 直接替换成对应 logic,logic 内部变量替换成 null
2794
2887
  if (logicRtn && code.includes(logicRtn.name)) {
@@ -2965,6 +3058,54 @@ export class View extends Annotatable {
2965
3058
  };
2966
3059
  }
2967
3060
 
3061
+ subLogics: Array<SubLogic> = [];
3062
+
3063
+ getSubLogics() {
3064
+ const subLogics = this.findNaslNodeByBFS((node: BaseNode) => {
3065
+ if (asserts.isSubLogic(node)) {
3066
+ // 仅仅是为了处理数据源中的子逻辑,Logic 下面的,交由Logic 自己处理
3067
+ if (node?.getAncestor('Logic')) {
3068
+ return false;
3069
+ }
3070
+ return true;
3071
+ }
3072
+ });
3073
+ this.subLogics = subLogics as Array<SubLogic>;
3074
+ }
3075
+
3076
+ existingSubLogic: Set<string> = new Set<string>();
3077
+
3078
+ collectExistSubLogic() {
3079
+ const existSubLogics: SubLogic[] = [];
3080
+ this.findNaslNodeByBFS((node: BaseNode) => {
3081
+ if (asserts.isSubLogic(node)) {
3082
+ existSubLogics.push(node);
3083
+ }
3084
+ return false;
3085
+ });
3086
+ return existSubLogics;
3087
+ }
3088
+
3089
+ // 获取当前逻辑中已经存在的子逻辑名称
3090
+ getSubLogicExistingNames(excludedList: Array<SubLogic> = []) {
3091
+ if (!this.existingSubLogic.size) {
3092
+ const subLogics = this.collectExistSubLogic();
3093
+ subLogics.forEach((subLogic) => {
3094
+ if (!excludedList.includes(subLogic)) {
3095
+ this.existingSubLogic.add(subLogic.name);
3096
+ }
3097
+ });
3098
+ }
3099
+ return Array.from(this.existingSubLogic);
3100
+ }
3101
+
3102
+ getSubLogicUniqueName(name = 'subLogic1', excludedNames: Array<string> = []) {
3103
+ const existingNames = this.getSubLogicExistingNames();
3104
+ const uniqueName = utils.unique(name, existingNames.concat(excludedNames), undefined, false);
3105
+ this.existingSubLogic.add(uniqueName);
3106
+ return uniqueName;
3107
+ }
3108
+
2968
3109
  //================================================================================
2969
3110
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
2970
3111
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -3485,6 +3626,14 @@ export const ComponentCompletionPropertyMap: Record<string, any> = {
3485
3626
  state: 'currentData',
3486
3627
  label: '数据',
3487
3628
  },
3629
+ order: {
3630
+ prop: 'sorting',
3631
+ label: '排序方式',
3632
+ },
3633
+ filter:{
3634
+ prop:'filter',
3635
+ label:'筛选条件'
3636
+ },
3488
3637
  },
3489
3638
  List: {
3490
3639
  current: {
@@ -205,7 +205,7 @@ export function initialize() {
205
205
  }),
206
206
  new StructureProperty({
207
207
  name: 'procInstStatus',
208
- typeAnnotation: TypeAnnotation.createReference('ProcInstStatusEnum', { typeNamespace: 'nasl.processV2' }),
208
+ typeAnnotation: TypeAnnotation.createReference('ProcInstStatusEnum', { typeNamespace: 'nasl.processV2.enums' }),
209
209
  }),
210
210
  new StructureProperty({
211
211
  name: 'procInstCurrNodes',
@@ -220,7 +220,7 @@ export function initialize() {
220
220
  ],
221
221
  }),
222
222
  new Structure({
223
- name: 'getTaskOperationPermission',
223
+ name: 'TaskOperationPermission',
224
224
  properties: [
225
225
  new StructureProperty({
226
226
  name: 'name',
@@ -525,7 +525,7 @@ export function initialize() {
525
525
  ],
526
526
  }),
527
527
  new Structure({
528
- name: 'ValidateEvent',
528
+ name: 'ValidateResult',
529
529
  properties: [
530
530
  new StructureProperty({
531
531
  name: 'rawValue',