@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
@@ -956,30 +956,42 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
956
956
  code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
957
957
  let levelIndex = parentLevel || 0;
958
958
  code += `${self.name}: () => {\n`;
959
- const getType = (name) => {
960
- let t;
959
+ const getMultipleDefaultValue = (name) => {
960
+ let v = 'new nasl.core.BooleanFalse()';
961
961
  const attr = self.bindAttrs?.find((attr) => attr.name === name);
962
962
  if (['static', 'string'].includes(attr?.type)) {
963
- t = attr.value ? 'true' : 'false';
963
+ v = attr.value ? 'new nasl.core.BooleanTrue()' : 'new nasl.core.BooleanFalse()';
964
964
  }
965
- else if (['dynamic'].includes(attr?.type)) {
966
- t = 'nasl.core.Boolean';
967
- }
968
- else {
969
- t = false;
965
+ return v;
966
+ };
967
+ const getConverterDefaultValue = (name) => {
968
+ let v = 'new nasl.core.StringLiteral<\`\`>()';
969
+ const attr = self.bindAttrs?.find((attr) => attr.name === name);
970
+ if (['static', 'string'].includes(attr?.type)) {
971
+ if ([true, 'true'].includes(attr.value)) {
972
+ v = 'new nasl.core.BooleanTrue()';
973
+ }
974
+ else if ([false, 'false'].includes(attr.value)) {
975
+ v = 'new nasl.core.BooleanFalse()';
976
+ }
977
+ else {
978
+ v = `new nasl.core.StringLiteral<\`${attr.value}\`>()`;
979
+ }
970
980
  }
971
- return t;
981
+ return v;
972
982
  };
973
- const hasDataSource = config_1.config?.allNodesAPI?.[self.tag]?.props?.findIndex((prop) => ['dataSource', 'data-source'].includes(prop.name)) >
974
- -1;
983
+ const hasDataSource = config_1.config?.allNodesAPI?.[self.tag]?.props?.findIndex((prop) => ['dataSource', 'data-source'].includes(prop.name)) > -1;
984
+ let dataSourceSetted = false;
985
+ let staticItem = '';
975
986
  // 有数据源属性的组件 才需要生成 item
976
987
  if (hasDataSource && T) {
977
988
  const key = T1 ? '__columnItem' : '__item';
978
989
  const dataSourceAttr = self.bindAttrs?.find((attr) => attr.name === 'dataSource');
979
990
  if (dataSourceAttr?.expression) {
991
+ dataSourceSetted = true;
980
992
  if (asserts.isMemberExpression(dataSourceAttr.expression) ||
981
993
  asserts.isIdentifier(dataSourceAttr.expression) ||
982
- asserts.isCallLogic(dataSourceAttr.expression)) {
994
+ (asserts.isCallLogic(dataSourceAttr.expression) && !dataSourceAttr.expression?.calleeNamespace?.startsWith('extensions'))) {
983
995
  const value = yield* dataSourceAttr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, dataSourceAttr.expression.concept === 'CallLogic'
984
996
  ? {
985
997
  tabSize: 4,
@@ -1025,41 +1037,83 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
1025
1037
  }
1026
1038
  }
1027
1039
  else {
1028
- code += `let ${key}: any;\n`;
1040
+ // 根据静态子节点生成类型
1041
+ const attrs = {
1042
+ 'u-checkbox': 'label',
1043
+ 'u-radio': 'label',
1044
+ 'van-radio': 'name',
1045
+ 'van-checkbox': 'label',
1046
+ };
1047
+ const child = self.children?.filter((item) => item.tag !== 'template')[0];
1048
+ if (child) {
1049
+ const valueAttr = child.bindAttrs?.find((attr) => attr.name === (attrs[child.tag] || 'value'));
1050
+ if (valueAttr) {
1051
+ // 开启了绑定
1052
+ if (valueAttr.expression) {
1053
+ const attrCode = yield* valueAttr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, '', { tabSize: 0 }));
1054
+ staticItem = `${attrCode}`;
1055
+ }
1056
+ else {
1057
+ try {
1058
+ if (valueAttr.type === 'static') {
1059
+ const value = json5.parse(valueAttr.value);
1060
+ const map = {
1061
+ 'string': 'new nasl.core.String("")',
1062
+ 'number': 'new nasl.core.Long(1)',
1063
+ 'boolean': 'new nasl.core.Boolean(false)',
1064
+ };
1065
+ staticItem = map[typeof value] || 'new nasl.core.String("")';
1066
+ }
1067
+ else {
1068
+ staticItem = 'new nasl.core.String("")';
1069
+ }
1070
+ }
1071
+ catch (error) {
1072
+ // @ts-ignore
1073
+ }
1074
+ }
1075
+ }
1076
+ else {
1077
+ staticItem = 'new nasl.core.String("")';
1078
+ }
1079
+ }
1080
+ code += `let __staticItem = ${staticItem};\n`;
1081
+ code += `let ${key}: typeof __staticItem;\n`;
1029
1082
  }
1030
1083
  }
1031
1084
  // 值
1032
1085
  let valueType;
1033
1086
  if (hasDataSource && V && !T1) {
1034
1087
  const valueFieldAttr = self.bindAttrs?.find((attr) => attr.name === 'valueField');
1035
- if (['static', 'string'].includes(valueFieldAttr?.type)) {
1088
+ if (dataSourceSetted && ['static', 'string'].includes(valueFieldAttr?.type)) {
1036
1089
  valueType = `typeof __item.${valueFieldAttr.value}`;
1037
1090
  }
1038
1091
  else {
1039
- valueType = 'any';
1092
+ valueType = `typeof __staticItem`;
1040
1093
  }
1041
1094
  }
1042
1095
  // 分页
1043
- let pageableType;
1096
+ let pageableDefaultValue;
1044
1097
  if (hasDataSource && P && !T1) {
1045
- pageableType = getType('pageable');
1046
- code += `let __pageable: ${pageableType};\n`;
1098
+ pageableDefaultValue = getMultipleDefaultValue('pageable');
1099
+ code += `let __pageable = ${pageableDefaultValue};\n`;
1047
1100
  }
1048
1101
  // 多选
1049
- let multipleType;
1102
+ let multipleDefaultValue;
1050
1103
  if (hasDataSource && M && !T1) {
1051
- multipleType = getType('multiple');
1052
- code += `let __multiple: ${multipleType};\n`;
1104
+ multipleDefaultValue = getMultipleDefaultValue('multiple');
1105
+ code += `let __multiple = ${multipleDefaultValue};\n`;
1053
1106
  }
1054
1107
  if (hasDataSource && V && !T1) {
1055
1108
  code += `// @ts-ignore
1056
- let __value: ${valueType}${[true, 'true'].includes(multipleType) ? '[]' : ''};\n`;
1109
+ let __value: typeof __multiple extends nasl.core.BooleanTrue ? ${valueType}[] : ${valueType};\n`;
1057
1110
  code += `// @ts-ignore
1058
1111
  let __V: ${valueType};\n`;
1059
1112
  }
1113
+ let converterDefaultValue;
1060
1114
  if (C) {
1061
- // code += `let converter: ${getType('converter')};\n`;
1062
- code += `let __converter: any;\n`;
1115
+ converterDefaultValue = getConverterDefaultValue('converter');
1116
+ code += `let __converter = ${converterDefaultValue};\n`;
1063
1117
  }
1064
1118
  if (self.tag === 'template' && self.haveScope() && asserts.isViewElement(self.parentNode)) {
1065
1119
  const currentType = self.parentNode.tag === 'u-table-view-column-dynamic' ? 'CurrentDynamic' : 'Current';
@@ -1327,11 +1381,9 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
1327
1381
  if (shouldFilter) {
1328
1382
  return;
1329
1383
  }
1330
- let attrCode = yield* attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 }));
1384
+ let attrCode = yield* attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 }), { carryName: true });
1331
1385
  if (attrCode.trim()) {
1332
- const humpName = self.toHump(attr.name);
1333
- code += `${humpName}: `;
1334
- attrCode = yield* attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 }));
1386
+ attrCode = yield* attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 }), { carryName: true });
1335
1387
  code += attrCode;
1336
1388
  code += `,\n`;
1337
1389
  }
@@ -1412,7 +1464,8 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
1412
1464
  const param = hasScope ? `current${levelIndex === 0 ? '' : levelIndex}` : '';
1413
1465
  const levelIndexDelta = Number(hasScope);
1414
1466
  code += `slotDefault: (${param}) => [\n`;
1415
- yield* (0, time_slicing_1.wrapForEachToGenerator)(children, function* warpForEachGenerator(element) {
1467
+ const defaultArr = self.shouldHandleChildren(self) ? children : [];
1468
+ yield* (0, time_slicing_1.wrapForEachToGenerator)(defaultArr, function* warpForEachGenerator(element) {
1416
1469
  code += yield* element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
1417
1470
  tabSize: (state?.tabSize || 0) + 2,
1418
1471
  }), levelIndex + levelIndexDelta);
@@ -1433,6 +1486,25 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
1433
1486
  }
1434
1487
  return code;
1435
1488
  }
1489
+ shouldHandleChildren(element) {
1490
+ // 数据源与静态子节点不共存的组件
1491
+ const tags = [
1492
+ 'u-tabs',
1493
+ 'u-selectable-steps',
1494
+ 'van-swipe',
1495
+ 'van-steps',
1496
+ ]; // 数据源与静态子节点不共存的组件
1497
+ // 判断当前是否配置了数据源
1498
+ const isDataSourceConfigured = () => element.bindAttrs.some((attr) => {
1499
+ if (['data-source', 'dataSource'].includes(attr.name)) {
1500
+ if (attr.type === 'dynamic' && attr.expression) {
1501
+ return true;
1502
+ }
1503
+ }
1504
+ return false;
1505
+ });
1506
+ return !tags.includes(element.tag) || !isDataSourceConfigured();
1507
+ }
1436
1508
  toNaturalTS(state = (0, translator_1.createCompilerState)(), parentLevel) {
1437
1509
  let code = '';
1438
1510
  code += `$refs.${this.name} = new ${(0, utils_1.kebab2Camel)(this.tag)}({\n`;
@@ -1527,6 +1599,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
1527
1599
  code += element.toTextualNASL((0, translator_1.shiftState)(state, code, {
1528
1600
  tabSize: state.tabSize + 2,
1529
1601
  }));
1602
+ code += ',\n';
1530
1603
  });
1531
1604
  code += `${(0, translator_1.indent)(state.tabSize + 1)}] },\n`;
1532
1605
  }
@@ -1536,15 +1609,13 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
1536
1609
  });
1537
1610
  // 翻译其余的子集
1538
1611
  if (defaultArr.length) {
1539
- throw new Error('多个插槽必须都在 template 内');
1540
- // defaultArr.forEach((element) => {
1541
- // code += element.toTextualNASL(
1542
- // shiftState(state, code, {
1543
- // tabSize: state.tabSize,
1544
- // }),
1545
- // // levelIndex,
1546
- // );
1547
- // });
1612
+ // throw new Error('多个插槽必须都在 template 内');
1613
+ defaultArr.forEach((element) => {
1614
+ code += element.toTextualNASL((0, translator_1.shiftState)(state, code, {
1615
+ tabSize: state.tabSize,
1616
+ }));
1617
+ code += ',\n';
1618
+ });
1548
1619
  }
1549
1620
  }
1550
1621
  else {
@@ -2227,7 +2298,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
2227
2298
  }
2228
2299
  });
2229
2300
  }
2230
- if (options?.isExport &&
2301
+ if ((options?.isExport || options?.isRelease) &&
2231
2302
  attr?.concept === 'BindAttribute' &&
2232
2303
  attr?.name === 'src' &&
2233
2304
  /^\/assets\/(.*?)$/.test(attr?.value) &&
@@ -2264,7 +2335,6 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
2264
2335
  argsList,
2265
2336
  dataRefList,
2266
2337
  };
2267
- // debugger
2268
2338
  // 所有参数序列化之后当字符串传进指令参数 (目前不支持<div v-demo="{ color: 'white', text: 'hello!' }"></div>
2269
2339
  let expression = StringLiteral__1.StringLiteral.from({
2270
2340
  concept: 'StringLiteral',
@@ -2294,21 +2364,23 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
2294
2364
  ve?.bindAttrs?.find((attr) => {
2295
2365
  let type = attr?.expression?.object?.__TypeAnnotation;
2296
2366
  if (type) {
2297
- console.log('type: ', type);
2298
2367
  let { typeKind, typeName, typeNamespace } = type || {};
2299
- // todo 这里可能不是匿名数据结构吗
2300
2368
  if (typeKind === 'anonymousStructure') {
2301
2369
  let parent = this.getAncestorByTag('ViewElement', 'u-table-view') ||
2302
2370
  this.getAncestorByTag('ViewElement', 'u-list-view') ||
2303
2371
  this.getAncestorByTag('ViewElement', 'u-grid-view') ||
2304
2372
  this.getAncestorByTag('ViewElement', 'van-grid-view') ||
2305
2373
  this.getAncestorByTag('ViewElement', 'van-list-view');
2306
- if (parent?.tag) {
2374
+ let canAdd = parent?.tag;
2375
+ if (isGridViewLayout || isListViewLayout) {
2376
+ let nestLinearLayout = this.children.find(c => c.tag === 'u-linear-layout');
2377
+ canAdd = canAdd && !nestLinearLayout;
2378
+ }
2379
+ if (canAdd) {
2307
2380
  let dataSourceAttr = parent?.bindAttrs?.find((it) => it?.name === 'dataSource');
2308
2381
  if (dataSourceAttr?.expression?.concept === 'CallLogic') {
2309
2382
  if (dataSourceAttr?.expression?.calleeNamespace === 'app.logics') {
2310
2383
  logicName = dataSourceAttr?.expression?.calleeName;
2311
- // debugger
2312
2384
  let ref = {
2313
2385
  typeNamespace: 'app.logics',
2314
2386
  typeName: logicName,
@@ -2345,11 +2417,15 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
2345
2417
  const addDataRefDriective = (ve) => {
2346
2418
  ve?.bindAttrs?.find((attr) => {
2347
2419
  let type = attr?.expression?.object?.__TypeAnnotation;
2348
- if (type) {
2420
+ let canAdd = type;
2421
+ if (isGridViewLayout || isListViewLayout) {
2422
+ let nestLinearLayout = this.children.find(c => c.tag === 'u-linear-layout');
2423
+ canAdd = canAdd && !nestLinearLayout;
2424
+ }
2425
+ if (canAdd) {
2349
2426
  let { typeKind, typeName, typeNamespace } = type || {};
2350
2427
  if (typeKind === 'reference' && typeNamespace) {
2351
2428
  let entityPropName = attr?.expression?.property?.name;
2352
- // debugger;
2353
2429
  let ref = {
2354
2430
  typeNamespace,
2355
2431
  typeName,
@@ -2488,7 +2564,14 @@ let ViewElement = ViewElement_1 = class ViewElement extends Annotatable__1.defau
2488
2564
  * 从父级删除该节点
2489
2565
  * @internal
2490
2566
  */
2491
- delete() { }
2567
+ delete() {
2568
+ super.delete();
2569
+ if (this.parentNode) {
2570
+ this.traverseChildren((ele) => {
2571
+ this.likeComponent?.removeExistingViewElement(ele);
2572
+ });
2573
+ }
2574
+ }
2492
2575
  findElementByName(name) {
2493
2576
  return utils.traverse((current) => {
2494
2577
  if (current.node.name === name)