@lcap/nasl 3.5.0-beta.3 → 3.5.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 (289) hide show
  1. package/out/breakpoint/store/core.js +1 -1
  2. package/out/breakpoint/store/core.js.map +1 -1
  3. package/out/common/BaseNode.d.ts +7 -0
  4. package/out/common/BaseNode.js +15 -2
  5. package/out/common/BaseNode.js.map +1 -1
  6. package/out/concepts/AnonymousFunction__.d.ts +1 -0
  7. package/out/concepts/AnonymousFunction__.js +34 -16
  8. package/out/concepts/AnonymousFunction__.js.map +1 -1
  9. package/out/concepts/Argument__.d.ts +1 -0
  10. package/out/concepts/Argument__.js +28 -8
  11. package/out/concepts/Argument__.js.map +1 -1
  12. package/out/concepts/Assignment__.js +5 -7
  13. package/out/concepts/Assignment__.js.map +1 -1
  14. package/out/concepts/BatchAssignment__.js +5 -3
  15. package/out/concepts/BatchAssignment__.js.map +1 -1
  16. package/out/concepts/BinaryExpression__.d.ts +1 -0
  17. package/out/concepts/BinaryExpression__.js +30 -13
  18. package/out/concepts/BinaryExpression__.js.map +1 -1
  19. package/out/concepts/BindAttribute__.js +11 -3
  20. package/out/concepts/BindAttribute__.js.map +1 -1
  21. package/out/concepts/BindDirective__.js +3 -3
  22. package/out/concepts/BindDirective__.js.map +1 -1
  23. package/out/concepts/BindEvent__.js +2 -2
  24. package/out/concepts/BindEvent__.js.map +1 -1
  25. package/out/concepts/BooleanLiteral__.d.ts +1 -0
  26. package/out/concepts/BooleanLiteral__.js +6 -0
  27. package/out/concepts/BooleanLiteral__.js.map +1 -1
  28. package/out/concepts/BusinessComponent__.d.ts +4 -2
  29. package/out/concepts/BusinessComponent__.js +128 -89
  30. package/out/concepts/BusinessComponent__.js.map +1 -1
  31. package/out/concepts/CallConnector__.d.ts +1 -0
  32. package/out/concepts/CallConnector__.js +6 -0
  33. package/out/concepts/CallConnector__.js.map +1 -1
  34. package/out/concepts/CallEvent__.d.ts +4 -0
  35. package/out/concepts/CallEvent__.js +19 -2
  36. package/out/concepts/CallEvent__.js.map +1 -1
  37. package/out/concepts/CallFunction__.d.ts +1 -0
  38. package/out/concepts/CallFunction__.js +62 -8
  39. package/out/concepts/CallFunction__.js.map +1 -1
  40. package/out/concepts/CallInterface__.js +31 -22
  41. package/out/concepts/CallInterface__.js.map +1 -1
  42. package/out/concepts/CallLogic__.js +49 -38
  43. package/out/concepts/CallLogic__.js.map +1 -1
  44. package/out/concepts/CallQueryComponent__.d.ts +2 -0
  45. package/out/concepts/CallQueryComponent__.js +94 -8
  46. package/out/concepts/CallQueryComponent__.js.map +1 -1
  47. package/out/concepts/DefaultValue__.d.ts +1 -0
  48. package/out/concepts/DefaultValue__.js +7 -1
  49. package/out/concepts/DefaultValue__.js.map +1 -1
  50. package/out/concepts/Destination__.d.ts +1 -1
  51. package/out/concepts/Destination__.js +34 -22
  52. package/out/concepts/Destination__.js.map +1 -1
  53. package/out/concepts/EntityProperty__.d.ts +1 -0
  54. package/out/concepts/EntityProperty__.js +26 -2
  55. package/out/concepts/EntityProperty__.js.map +1 -1
  56. package/out/concepts/Entity__.d.ts +1 -0
  57. package/out/concepts/Entity__.js +25 -0
  58. package/out/concepts/Entity__.js.map +1 -1
  59. package/out/concepts/EnumItem__.d.ts +1 -0
  60. package/out/concepts/EnumItem__.js +12 -0
  61. package/out/concepts/EnumItem__.js.map +1 -1
  62. package/out/concepts/Enum__.d.ts +1 -0
  63. package/out/concepts/Enum__.js +16 -2
  64. package/out/concepts/Enum__.js.map +1 -1
  65. package/out/concepts/Event__.d.ts +4 -0
  66. package/out/concepts/Event__.js +12 -0
  67. package/out/concepts/Event__.js.map +1 -1
  68. package/out/concepts/ForEachStatement__.js +10 -16
  69. package/out/concepts/ForEachStatement__.js.map +1 -1
  70. package/out/concepts/FrontendType__.js +1 -0
  71. package/out/concepts/FrontendType__.js.map +1 -1
  72. package/out/concepts/Identifier__.d.ts +2 -0
  73. package/out/concepts/Identifier__.js +21 -0
  74. package/out/concepts/Identifier__.js.map +1 -1
  75. package/out/concepts/JSBlock__.js +1 -1
  76. package/out/concepts/JSBlock__.js.map +1 -1
  77. package/out/concepts/LogicItem__.d.ts +6 -0
  78. package/out/concepts/LogicItem__.js +11 -1
  79. package/out/concepts/LogicItem__.js.map +1 -1
  80. package/out/concepts/Logic__.js +24 -23
  81. package/out/concepts/Logic__.js.map +1 -1
  82. package/out/concepts/MatchCase__.js +5 -5
  83. package/out/concepts/MatchCase__.js.map +1 -1
  84. package/out/concepts/Match__.js +1 -1
  85. package/out/concepts/Match__.js.map +1 -1
  86. package/out/concepts/MemberExpression__.d.ts +1 -0
  87. package/out/concepts/MemberExpression__.js +13 -3
  88. package/out/concepts/MemberExpression__.js.map +1 -1
  89. package/out/concepts/NewComposite__.js +3 -3
  90. package/out/concepts/NewComposite__.js.map +1 -1
  91. package/out/concepts/NewList__.js +4 -4
  92. package/out/concepts/NewList__.js.map +1 -1
  93. package/out/concepts/NewMap__.d.ts +1 -1
  94. package/out/concepts/NewMap__.js +6 -5
  95. package/out/concepts/NewMap__.js.map +1 -1
  96. package/out/concepts/NullLiteral__.d.ts +2 -0
  97. package/out/concepts/NullLiteral__.js +12 -0
  98. package/out/concepts/NullLiteral__.js.map +1 -1
  99. package/out/concepts/NumericLiteral__.d.ts +1 -0
  100. package/out/concepts/NumericLiteral__.js +7 -1
  101. package/out/concepts/NumericLiteral__.js.map +1 -1
  102. package/out/concepts/OqlQueryComponent__.js +4 -2
  103. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  104. package/out/concepts/Param__.d.ts +1 -0
  105. package/out/concepts/Param__.js +41 -0
  106. package/out/concepts/Param__.js.map +1 -1
  107. package/out/concepts/ProcessElement__.js +9 -1
  108. package/out/concepts/ProcessElement__.js.map +1 -1
  109. package/out/concepts/QueryAggregateExpression__.d.ts +2 -0
  110. package/out/concepts/QueryAggregateExpression__.js +16 -0
  111. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  112. package/out/concepts/QueryFieldExpression__.d.ts +2 -0
  113. package/out/concepts/QueryFieldExpression__.js +33 -0
  114. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  115. package/out/concepts/QueryFromExpression__.d.ts +2 -0
  116. package/out/concepts/QueryFromExpression__.js +27 -0
  117. package/out/concepts/QueryFromExpression__.js.map +1 -1
  118. package/out/concepts/QueryGroupByExpression__.d.ts +2 -0
  119. package/out/concepts/QueryGroupByExpression__.js +13 -1
  120. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  121. package/out/concepts/QueryJoinExpression__.d.ts +2 -0
  122. package/out/concepts/QueryJoinExpression__.js +37 -0
  123. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  124. package/out/concepts/QueryLimitExpression__.d.ts +2 -0
  125. package/out/concepts/QueryLimitExpression__.js +16 -0
  126. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  127. package/out/concepts/QueryOrderByExpression__.d.ts +2 -0
  128. package/out/concepts/QueryOrderByExpression__.js +22 -0
  129. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  130. package/out/concepts/QuerySelectExpression__.d.ts +3 -0
  131. package/out/concepts/QuerySelectExpression__.js +41 -0
  132. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  133. package/out/concepts/SelectMembers__.d.ts +1 -0
  134. package/out/concepts/SelectMembers__.js +7 -0
  135. package/out/concepts/SelectMembers__.js.map +1 -1
  136. package/out/concepts/SqlQueryComponent__.js +4 -2
  137. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  138. package/out/concepts/StringInterpolation__.d.ts +1 -0
  139. package/out/concepts/StringInterpolation__.js +20 -2
  140. package/out/concepts/StringInterpolation__.js.map +1 -1
  141. package/out/concepts/StringLiteral__.d.ts +1 -0
  142. package/out/concepts/StringLiteral__.js +21 -1
  143. package/out/concepts/StringLiteral__.js.map +1 -1
  144. package/out/concepts/StructureProperty__.d.ts +1 -0
  145. package/out/concepts/StructureProperty__.js +19 -0
  146. package/out/concepts/StructureProperty__.js.map +1 -1
  147. package/out/concepts/Structure__.d.ts +1 -0
  148. package/out/concepts/Structure__.js +22 -7
  149. package/out/concepts/Structure__.js.map +1 -1
  150. package/out/concepts/SwitchCase__.js +1 -1
  151. package/out/concepts/SwitchCase__.js.map +1 -1
  152. package/out/concepts/TypeAnnotation__.d.ts +1 -0
  153. package/out/concepts/TypeAnnotation__.js +42 -1
  154. package/out/concepts/TypeAnnotation__.js.map +1 -1
  155. package/out/concepts/TypeParam__.d.ts +2 -1
  156. package/out/concepts/TypeParam__.js +7 -1
  157. package/out/concepts/TypeParam__.js.map +1 -1
  158. package/out/concepts/Unparsed__.js +1 -1
  159. package/out/concepts/Unparsed__.js.map +1 -1
  160. package/out/concepts/ValidationRule__.js +2 -1
  161. package/out/concepts/ValidationRule__.js.map +1 -1
  162. package/out/concepts/ViewElement__.d.ts +1 -0
  163. package/out/concepts/ViewElement__.js +72 -59
  164. package/out/concepts/ViewElement__.js.map +1 -1
  165. package/out/concepts/View__.d.ts +2 -1
  166. package/out/concepts/View__.js +6 -19
  167. package/out/concepts/View__.js.map +1 -1
  168. package/out/generator/genBundleFiles.d.ts +1 -0
  169. package/out/generator/genBundleFiles.js +4 -1
  170. package/out/generator/genBundleFiles.js.map +1 -1
  171. package/out/natural/genNaturalTS.d.ts +4 -1
  172. package/out/natural/genNaturalTS.js +38 -1
  173. package/out/natural/genNaturalTS.js.map +1 -1
  174. package/out/natural/transformTSCode.js +52 -41
  175. package/out/natural/transformTSCode.js.map +1 -1
  176. package/out/server/formatTsUtils.js +10 -9
  177. package/out/server/formatTsUtils.js.map +1 -1
  178. package/out/server/getFunctions.js +3 -3
  179. package/out/server/getFunctions.js.map +1 -1
  180. package/out/server/getProcesses.js +3 -3
  181. package/out/server/getProcesses.js.map +1 -1
  182. package/out/server/naslServer.js +52 -17
  183. package/out/server/naslServer.js.map +1 -1
  184. package/out/server/translator.js +8 -0
  185. package/out/server/translator.js.map +1 -1
  186. package/out/templator/genCurdEditMultipleKeyBlock.js +1 -1
  187. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  188. package/out/templator/genGetBlock.js +2 -1
  189. package/out/templator/genGetBlock.js.map +1 -1
  190. package/out/templator/genUpdateBlock.js +2 -1
  191. package/out/templator/genUpdateBlock.js.map +1 -1
  192. package/out/templator/utils.js +3 -3
  193. package/out/templator/utils.js.map +1 -1
  194. package/out/translator/types.d.ts +2 -0
  195. package/out/translator/utils.d.ts +2 -1
  196. package/out/translator/utils.js +44 -7
  197. package/out/translator/utils.js.map +1 -1
  198. package/out/utils/string.js +2 -2
  199. package/out/utils/string.js.map +1 -1
  200. package/out/utils/time-slicing/performance.js +3 -3
  201. package/out/utils/time-slicing/performance.js.map +1 -1
  202. package/package.json +2 -2
  203. package/src/breakpoint/store/core.ts +1 -1
  204. package/src/common/BaseNode.ts +17 -3
  205. package/src/concepts/AnonymousFunction__.ts +24 -9
  206. package/src/concepts/Argument__.ts +28 -6
  207. package/src/concepts/Assignment__.ts +5 -7
  208. package/src/concepts/BatchAssignment__.ts +6 -3
  209. package/src/concepts/BinaryExpression__.ts +30 -13
  210. package/src/concepts/BindAttribute__.ts +10 -3
  211. package/src/concepts/BindDirective__.ts +3 -3
  212. package/src/concepts/BindEvent__.ts +2 -2
  213. package/src/concepts/BooleanLiteral__.ts +5 -0
  214. package/src/concepts/BusinessComponent__.ts +144 -100
  215. package/src/concepts/CallConnector__.ts +5 -0
  216. package/src/concepts/CallEvent__.ts +20 -3
  217. package/src/concepts/CallFunction__.ts +54 -8
  218. package/src/concepts/CallInterface__.ts +31 -24
  219. package/src/concepts/CallLogic__.ts +48 -37
  220. package/src/concepts/CallQueryComponent__.ts +101 -8
  221. package/src/concepts/DefaultValue__.ts +6 -1
  222. package/src/concepts/Destination__.ts +32 -22
  223. package/src/concepts/EntityProperty__.ts +30 -2
  224. package/src/concepts/Entity__.ts +29 -0
  225. package/src/concepts/EnumItem__.ts +17 -0
  226. package/src/concepts/Enum__.ts +19 -2
  227. package/src/concepts/Event__.ts +13 -0
  228. package/src/concepts/ForEachStatement__.ts +10 -20
  229. package/src/concepts/FrontendType__.ts +1 -0
  230. package/src/concepts/Identifier__.ts +19 -0
  231. package/src/concepts/JSBlock__.ts +1 -1
  232. package/src/concepts/LogicItem__.ts +13 -1
  233. package/src/concepts/Logic__.ts +24 -24
  234. package/src/concepts/MatchCase__.ts +5 -5
  235. package/src/concepts/Match__.ts +1 -1
  236. package/src/concepts/MemberExpression__.ts +12 -3
  237. package/src/concepts/NewComposite__.ts +7 -9
  238. package/src/concepts/NewList__.ts +4 -4
  239. package/src/concepts/NewMap__.ts +6 -5
  240. package/src/concepts/NullLiteral__.ts +10 -0
  241. package/src/concepts/NumericLiteral__.ts +6 -1
  242. package/src/concepts/OqlQueryComponent__.ts +4 -2
  243. package/src/concepts/Param__.ts +39 -0
  244. package/src/concepts/ProcessElement__.ts +8 -1
  245. package/src/concepts/QueryAggregateExpression__.ts +15 -0
  246. package/src/concepts/QueryFieldExpression__.ts +34 -0
  247. package/src/concepts/QueryFromExpression__.ts +29 -0
  248. package/src/concepts/QueryGroupByExpression__.ts +11 -1
  249. package/src/concepts/QueryJoinExpression__.ts +39 -0
  250. package/src/concepts/QueryLimitExpression__.ts +14 -0
  251. package/src/concepts/QueryOrderByExpression__.ts +23 -0
  252. package/src/concepts/QuerySelectExpression__.ts +55 -0
  253. package/src/concepts/SelectMembers__.ts +7 -0
  254. package/src/concepts/SqlQueryComponent__.ts +4 -2
  255. package/src/concepts/StringInterpolation__.ts +18 -2
  256. package/src/concepts/StringLiteral__.ts +20 -1
  257. package/src/concepts/StructureProperty__.ts +22 -0
  258. package/src/concepts/Structure__.ts +24 -7
  259. package/src/concepts/SwitchCase__.ts +1 -1
  260. package/src/concepts/TypeAnnotation__.ts +37 -1
  261. package/src/concepts/TypeParam__.ts +6 -1
  262. package/src/concepts/Unparsed__.ts +1 -1
  263. package/src/concepts/ValidationRule__.ts +6 -1
  264. package/src/concepts/ViewElement__.ts +74 -58
  265. package/src/concepts/View__.ts +6 -19
  266. package/src/generator/genBundleFiles.ts +6 -1
  267. package/src/natural/genNaturalTS.ts +41 -0
  268. package/src/natural/transformTSCode.ts +50 -42
  269. package/src/server/formatTsUtils.ts +16 -11
  270. package/src/server/getFunctions.ts +3 -3
  271. package/src/server/getProcesses.ts +3 -3
  272. package/src/server/naslServer.ts +56 -18
  273. package/src/server/translator.ts +7 -0
  274. package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -1
  275. package/src/templator/genGetBlock.ts +2 -1
  276. package/src/templator/genUpdateBlock.ts +2 -1
  277. package/src/templator/utils.ts +3 -3
  278. package/src/translator/types.ts +4 -0
  279. package/src/translator/utils.ts +73 -34
  280. package/src/utils/string.ts +2 -2
  281. package/src/utils/time-slicing/performance.ts +3 -3
  282. package/test/concepts/call-interface/__snapshots__/getQuickInfoOffset.spec.ts.snap +3 -3
  283. package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
  284. package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +199 -0
  285. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +127 -6
  286. package/test/concepts/view-element/fixtures/table-data-source-calllogic-with-server-validation.json +2074 -0
  287. package/test/concepts/view-element/toVue.spec.ts +0 -1
  288. package/ts-worker/package.json +1 -1
  289. package/ts-worker/src/index.js +1 -0
@@ -25,14 +25,14 @@ class Performance {
25
25
  }
26
26
  }
27
27
  mark(name) {
28
- return performance.mark(this.getPerformanceId(name));
28
+ return performance?.mark?.(this.getPerformanceId(name));
29
29
  }
30
30
  measure(name, startMark, endMark) {
31
- return performance.measure(this.getPerformanceId(name), this.getPerformanceId(startMark), this.getPerformanceId(endMark));
31
+ return performance?.measure?.(this.getPerformanceId(name), this.getPerformanceId(startMark), this.getPerformanceId(endMark));
32
32
  }
33
33
  clearByNames(...names) {
34
34
  for (const name of names) {
35
- const entry = performance.getEntriesByName(this.getPerformanceId(name))[0];
35
+ const entry = performance?.getEntriesByName?.(this.getPerformanceId(name))[0];
36
36
  if (entry) {
37
37
  this.clearEntry(entry);
38
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"performance.js","sourceRoot":"","sources":["../../../src/utils/time-slicing/performance.ts"],"names":[],"mappings":";;;AAAA,IAAK,SAGJ;AAHD,WAAK,SAAS;IACZ,0BAAa,CAAA;IACb,gCAAmB,CAAA;AACrB,CAAC,EAHI,SAAS,KAAT,SAAS,QAGb;AAED,MAAa,WAAW;IAGtB,YAAY,EAAU;QACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,IAAI,MAAM;QACR,OAAO,kBAAkB,IAAI,CAAC,EAAE,EAAE,CAAC;IACrC,CAAC;IAEO,gBAAgB,CAAC,IAAY;QACnC,OAAO,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;IAClC,CAAC;IAEO,UAAU,CAAC,KAAuB;QACxC,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,EAAE;YACtC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACpC;aACI,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,OAAO,EAAE;YAC9C,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvC;IACH,CAAC;IAED,IAAI,CAAC,IAAY;QACf,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,CAAC,IAAY,EAAE,SAAiB,EAAE,OAAe;QACtD,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5H,CAAC;IAED,YAAY,CAAC,GAAG,KAAe;QAC7B,KAAK,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AC9C,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC;CACF;AAlDD,kCAkDC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lcap/nasl",
3
3
  "description": "NetEase Application Specific Language",
4
- "version": "3.5.0-beta.3",
4
+ "version": "3.5.0-beta.5",
5
5
  "author": "Forrest <rainforest92@126.com>",
6
6
  "scripts": {
7
7
  "clear": "rimraf ./out",
@@ -37,7 +37,7 @@
37
37
  "@babel/generator": "7.22.15",
38
38
  "@babel/parser": "7.22.15",
39
39
  "@babel/preset-typescript": "7.22.15",
40
- "axios": "0.21.4",
40
+ "axios": "1.6.2",
41
41
  "compare-versions": "4.1.3",
42
42
  "date-fns": "2.6.0",
43
43
  "decimal.js": "10.4.3",
@@ -138,7 +138,7 @@ const isFrontend = (node: BaseNode) => {
138
138
 
139
139
  const { getAncestor } = node;
140
140
 
141
- return getAncestor && getAncestor.call(node, 'View');
141
+ return getAncestor && getAncestor.call(node, 'FrontendType');
142
142
  };
143
143
 
144
144
  const updateToBackend = (node: BaseNode) => {
@@ -1,7 +1,7 @@
1
1
  import { at } from 'lodash';
2
2
  import { v4 as uuidv4 } from 'uuid';
3
3
 
4
- import { SourceMap } from '../translator';
4
+ import { SourceMap, createCompilerState, withSourceMap } from '../translator';
5
5
  import { getSourceFromMap } from '../service/storage/map';
6
6
 
7
7
  import * as utils from '../utils';
@@ -576,7 +576,9 @@ export class BaseNode extends EventEmitter {
576
576
  }
577
577
 
578
578
  // 更新实例上的属性
579
- this.updateInstance(newObject);
579
+ // 有时候需要把实例对象挂载上去,如:
580
+ // 批量赋值-把这个变量往这个clone里边拖的时候报内部出错 http://projectmanage.netease-official.lcap.163yun.com/dashboard/BugDetail?id=2766199685126400
581
+ this.updateInstance(object);
580
582
 
581
583
  if (process.env.NODE_ENV === 'development') {
582
584
  console.log('[更新节点]', 'path:', path, 'oldObject:', oldObject, 'newObject:', newObject);
@@ -730,6 +732,7 @@ export class BaseNode extends EventEmitter {
730
732
  // 有一些继承的情况
731
733
  const Ctor = classMap.get(source?.concept) || this;
732
734
  if (Ctor && source instanceof Ctor) {
735
+ console.warn('传入的对象已经是一个实例,请确认逻辑是否存在问题!')
733
736
  if (parentNode) {
734
737
  source.parentNode = parentNode;
735
738
  }
@@ -1299,6 +1302,7 @@ export class BaseNode extends EventEmitter {
1299
1302
  * 迭代所有属性
1300
1303
  *
1301
1304
  * @description 是所有属性!!不是所有子节点!!
1305
+ * @deprecated 请使用`traverseStrictChildren`方法
1302
1306
  */
1303
1307
  traverseChildren(cb: (el: any) => void): void {
1304
1308
  function traverse(node: any) {
@@ -1506,7 +1510,7 @@ export class BaseNode extends EventEmitter {
1506
1510
  nodes.push(self);
1507
1511
  }
1508
1512
 
1509
- this.traverseChildren((current) => {
1513
+ this.traverseStrictChildren((current) => {
1510
1514
  if (pre(current)) {
1511
1515
  nodes.push(current);
1512
1516
  }
@@ -1519,6 +1523,16 @@ export class BaseNode extends EventEmitter {
1519
1523
  return '';
1520
1524
  }
1521
1525
 
1526
+ /**
1527
+ * 生成文本化代码
1528
+ * @param state 编译状态
1529
+ * @returns 生成的代码
1530
+ */
1531
+ // @withSourceMap()
1532
+ toTextualNASL() {
1533
+ return '[编译方法未实现]';
1534
+ }
1535
+
1522
1536
  /**
1523
1537
  * 调试用的 ToTS 接口
1524
1538
  */
@@ -579,26 +579,41 @@ export class AnonymousFunction extends LogicItem {
579
579
  @withSourceMap()
580
580
  toNaturalTS(state = createCompilerState()): string {
581
581
  let code = '';
582
- if (this.body) {
583
582
  code += `(`;
584
583
  this.params.forEach((param, index) => {
585
584
  code += param.toNaturalTS(shiftState(state, code, { inline: true }));
586
585
  if (index !== this.params.length - 1) code += ', ';
587
586
  });
588
587
  code += `)`;
589
- code += ` => (`;
590
-
588
+ code += ` => `;
591
589
  if (this.body) {
592
590
  code +=
593
591
  this.body.toNaturalTS &&
594
592
  this.body.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1, inline: true }));
593
+ // code += `${indent(state.tabSize)}}`;
594
+ } else {
595
+ code += '__IDENTIFIER__';
595
596
  }
596
- code += ')';
597
- code += ';';
598
- code += `${indent(state.tabSize)}}`;
599
- } else {
600
- code += '__IDENTIFIER__';
601
- }
597
+
598
+ return code;
599
+ }
600
+
601
+ @withSourceMap()
602
+ toTextualNASL(state = createCompilerState()): string {
603
+ let code = `{ `;
604
+ this.params.forEach((param, index) => {
605
+ code += param.toTextualNASL(shiftState(state, code, { inline: true }));
606
+ if (index !== this.params.length - 1) code += ', ';
607
+ });
608
+ code += ` => `;
609
+ if (this.body) {
610
+ code +=
611
+ this.body.toTextualNASL &&
612
+ this.body.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1, inline: true }));
613
+ } else {
614
+ code += '__IDENTIFIER__';
615
+ }
616
+ code += ` }`;
602
617
 
603
618
  return code;
604
619
  }
@@ -140,7 +140,7 @@ export class Argument extends LogicItem {
140
140
  params.index = index;
141
141
  } else {
142
142
  const q = (t as any)[parentKey];
143
- if ((q.__v_raw || q) === n) {
143
+ if ((q?.__v_raw || q) === n) {
144
144
  params.index = 0;
145
145
  (this as any)[parentKey] = undefined;
146
146
  }
@@ -256,15 +256,37 @@ export class Argument extends LogicItem {
256
256
  @withSourceMap()
257
257
  toNaturalTS(state = createCompilerState(), isRequired: boolean = true, isHaveKeyWord?: boolean): string {
258
258
  let code = this.spread ? '...' : '';
259
+
260
+ if (isHaveKeyWord) {
261
+ code += `${this.tsKeyword || '__IDENTIFIER__'}: `;
262
+ }
263
+ if (this.expression) {
264
+ // if ((this.expression as StringLiteral).name === 'ListDistinctByTargetDefaultExpression') {
265
+ // code += runSync((this.expression as NewList).toEmbeddedIgnoreTS(shiftState(state, code)));
266
+ // } else {
267
+ code += (this.expression as StringLiteral).toNaturalTS(shiftState(state, code), isRequired);
268
+ // }
269
+ } else {
270
+ code += isRequired ? '__IDENTIFIER__' : 'undefined';
271
+ }
272
+
273
+ // if ((this.parentNode as any)?.tsCalleeKey === 'apis.up_mod_api_prod.interfaces.commentPage')
274
+ // console.log('CallInterface:', (this.parentNode as any)?.tsCalleeKey, this.tsKeyword, code);
275
+ return code;
276
+ }
277
+
278
+ @withSourceMap()
279
+ toTextualNASL(state = createCompilerState(), isRequired: boolean = true, isHaveKeyWord?: boolean): string {
280
+ let code = this.spread ? '...' : '';
259
281
  if (isHaveKeyWord) {
260
282
  code += `${this.tsKeyword}:`;
261
283
  }
262
284
  if (this.expression) {
263
- if ((this.expression as StringLiteral).name === 'ListDistinctByTargetDefaultExpression') {
264
- code += runSync((this.expression as NewList).toEmbeddedIgnoreTS(shiftState(state, code)));
265
- } else {
266
- code += (this.expression as StringLiteral).toNaturalTS(shiftState(state, code), isRequired);
267
- }
285
+ // if ((this.expression as StringLiteral).name === 'ListDistinctByTargetDefaultExpression') {
286
+ // code += runSync((this.expression as NewList).toEmbeddedIgnoreTS(shiftState(state, code)));
287
+ // } else {
288
+ code += this.expression.toTextualNASL(shiftState(state, code));
289
+ // }
268
290
  } else {
269
291
  code += isRequired ? '__IDENTIFIER__' : 'undefined';
270
292
  }
@@ -177,12 +177,12 @@ export class Assignment extends LogicItem {
177
177
  const n = logicItem.__v_raw || logicItem;
178
178
  if (Array.isArray((t as any)[parentKey])) {
179
179
  // @ts-ignore
180
- const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
181
- ~index && (this as any)[parentKey].splice(index, 1);
180
+ const index = (t as any)[parentKey]?.findIndex?.((el) => (el?.__v_raw || el) === n);
181
+ ~index && (this as any)[parentKey]?.splice?.(index, 1);
182
182
  params.index = index;
183
183
  } else {
184
184
  const q = (t as any)[parentKey];
185
- if ((q.__v_raw || q) === n) {
185
+ if ((q?.__v_raw || q) === n) {
186
186
  params.index = 0;
187
187
  (this as any)[parentKey] = undefined;
188
188
  }
@@ -346,7 +346,7 @@ export class Assignment extends LogicItem {
346
346
  toNaturalTS(state = createCompilerState()): string {
347
347
  let code = '';
348
348
 
349
- code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
349
+ code += this.left?.toNaturalTS(shiftState(state, code, { inline: true })) || '__LEFT__';
350
350
  code += ' = ';
351
351
  // 因为右侧枚举要赋值就得new 一下;
352
352
  if (
@@ -358,9 +358,7 @@ export class Assignment extends LogicItem {
358
358
  code += 'new ';
359
359
  }
360
360
  code +=
361
- this.right && this.right.toNaturalTS
362
- ? this.right.toNaturalTS(shiftState(state, code, { inline: true }))
363
- : '__RIGHT__';
361
+ this.right && this.right?.toNaturalTS(shiftState(state, code, { inline: true })) || '__RIGHT__';
364
362
 
365
363
  return code;
366
364
  }
@@ -7,6 +7,7 @@ import {
7
7
  withSourceMapGenerator,
8
8
  withGenerator,
9
9
  TranslatorGenerator,
10
+ indent,
10
11
  } from '../translator';
11
12
  import { ElementToVueOptions } from './ViewElement__';
12
13
  import type MemberExpression from './MemberExpression__';
@@ -1091,18 +1092,20 @@ export class BatchAssignment extends LogicItem {
1091
1092
  toNaturalTS(state = createCompilerState()): string {
1092
1093
  let code = '';
1093
1094
  // 根据连线状态,拆分成多个单赋值
1094
- this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1095
+ this.assignmentLines.forEach(({ leftIndex, rightIndex }, index) => {
1096
+ if (index > 0)
1097
+ code += indent(state.tabSize);
1095
1098
  const leftValue =
1096
1099
  leftIndex.length === 1
1097
1100
  ? this.left.expression.toNaturalTS(shiftState(state, code, { inline: true }))
1098
1101
  : this.left.members[leftIndex[1]]?.toNaturalTS(shiftState(state, code, { inline: true }));
1099
- code += `${leftValue}`;
1102
+ code += `${leftValue.trim() || '__LEFT__'}`;
1100
1103
  code += ' = ';
1101
1104
  const rightValue =
1102
1105
  rightIndex.length === 1
1103
1106
  ? this.rights[rightIndex[0]]?.expression?.toNaturalTS(shiftState(state, code, { inline: true }))
1104
1107
  : this.rights[rightIndex[0]]?.members[rightIndex[1]]?.toNaturalTS(shiftState(state, code, { inline: true }));
1105
- code += `${rightValue}`;
1108
+ code += `${rightValue.trim() || '__RIGHT__'}`;
1106
1109
  code += ';';
1107
1110
  code += '\n';
1108
1111
  });
@@ -239,12 +239,12 @@ export class BinaryExpression extends LogicItem {
239
239
  const n = logicItem.__v_raw || logicItem;
240
240
  if (Array.isArray((t as any)[parentKey])) {
241
241
  // @ts-ignore
242
- const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
243
- ~index && (this as any)[parentKey].splice(index, 1);
242
+ const index = (t as any)[parentKey]?.findIndex((el) => ((el.__v_raw || el) === n));
243
+ ~index && (this as any)[parentKey]?.splice(index, 1);
244
244
  params.index = index;
245
245
  } else {
246
246
  const q = (t as any)[parentKey];
247
- if ((q.__v_raw || q) === n) {
247
+ if ((q?.__v_raw || q) === n) {
248
248
  params.index = 0;
249
249
  (this as any)[parentKey] = undefined;
250
250
  }
@@ -396,7 +396,7 @@ export class BinaryExpression extends LogicItem {
396
396
  }
397
397
 
398
398
  toBrief(): string {
399
- return `(${this.left.toBrief()} ${this.operator} ${this.right.toBrief()})`;
399
+ return `(${this.left?.toBrief?.()} ${this.operator} ${this.right?.toBrief?.()})`;
400
400
  }
401
401
 
402
402
  @withSourceMapGenerator
@@ -445,33 +445,50 @@ export class BinaryExpression extends LogicItem {
445
445
  if (['startwith', 'endwith', 'like', 'in'].includes(this.operator)) {
446
446
  const fnName = this.operator.toUpperCase();
447
447
  let code = '';
448
- code += `nasl.langUtil.${fnName}(`;
449
- code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
448
+ code += `${fnName}(`;
449
+ code += this.left?.toNaturalTS(shiftState(state, code, { inline: true })) || '__LEFT__';
450
450
  code += ', ';
451
- code += this.right ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
451
+ code += this.right?.toNaturalTS(shiftState(state, code, { inline: true })) || '__RIGHT__';
452
452
  code += ')';
453
453
  return code;
454
454
  }
455
455
  if (['&&', '||', '+', '-', '*', '/', '%', '==', '!=', '>', '<', '>=', '<='].includes(this.operator)) {
456
456
  let code = '';
457
457
  if (this.left && this.left.concept === 'BinaryExpression') {
458
- code += this.left ? `(${this.left.toNaturalTS(shiftState(state, code, { inline: true }))})` : '__LEFT__';
458
+ code += this.left ? `(${this.left?.toNaturalTS(shiftState(state, code, { inline: true })) || '__LEFT__'})` : '__LEFT__';
459
459
  } else {
460
- code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
460
+ code += this.left?.toNaturalTS(shiftState(state, code, { inline: true })) || '__LEFT__';
461
461
  }
462
462
  code += ` ${this.operator} `;
463
463
  if (this.right && this.right.concept === 'BinaryExpression') {
464
- code += this.right ? `(${this.right.toNaturalTS(shiftState(state, code, { inline: true }))})` : '__RIGHT__';
464
+ code += this.right ? `(${this.right.toNaturalTS(shiftState(state, code, { inline: true })) || '__RIGHT__'})` : '__RIGHT__';
465
465
  } else {
466
- code += this.right ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
466
+ code += this.right?.toNaturalTS(shiftState(state, code, { inline: true })) || '__RIGHT__';
467
467
  }
468
468
  return code;
469
469
  }
470
470
 
471
471
  let code = '';
472
- code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
472
+ code += this.left?.toNaturalTS(shiftState(state, code, { inline: true })) || '__LEFT__';
473
473
  code += ` ${this.operator} `;
474
- code += this.right ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
474
+ code += this.right?.toNaturalTS(shiftState(state, code, { inline: true })) || '__RIGHT__';
475
+ return code;
476
+ }
477
+
478
+ @withSourceMap()
479
+ toTextualNASL(state = createCompilerState()): string {
480
+ const isDataQuery = false; // !!this.getAncestor('CallQueryComponent');
481
+ const operatorMap = {
482
+ '==': '=',
483
+ '&&': 'and',
484
+ '||': 'or',
485
+ }
486
+ const operator = isDataQuery ? operatorMap[this.operator as keyof typeof operatorMap] || this.operator : this.operator;
487
+
488
+ let code = '';
489
+ code += this.left ? this.left.toTextualNASL(shiftState(state, code, { inline: true })) : '__LEFT__';
490
+ code += ` ${operator} `;
491
+ code += this.right ? this.right.toTextualNASL(shiftState(state, code, { inline: true })) : '__RIGHT__';
475
492
  return code;
476
493
  }
477
494
 
@@ -1089,7 +1089,10 @@ export class BindAttribute extends BaseNode {
1089
1089
  // 业务组件
1090
1090
  const isBusinessComponent = self.viewElement?.isCorrespondingBusinessComponent;
1091
1091
  if (isBusinessComponent) {
1092
- code += `${name}: `;
1092
+ if (type === 'dynamic') {
1093
+ code += `${name}: (() => {
1094
+ return `;
1095
+ }
1093
1096
  } else if (self?.name === 'data-source' && self?.expression?.concept === 'CallLogic') {
1094
1097
  code += `() => {\n`;
1095
1098
  } else {
@@ -1131,13 +1134,17 @@ export class BindAttribute extends BaseNode {
1131
1134
  code += ';\n';
1132
1135
  }
1133
1136
  }
1134
- if (type === 'dynamic' && !isBusinessComponent) {
1137
+ if (type === 'dynamic') {
1135
1138
  yield* wrapForEach(playground, function* warpForEachGenerator(item, index) {
1136
1139
  code += yield* item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1137
1140
  code += ';\n';
1138
1141
  });
1139
1142
  }
1140
- if (!isBusinessComponent) {
1143
+ if (isBusinessComponent) {
1144
+ if (type === 'dynamic') {
1145
+ code += '\n})()';
1146
+ }
1147
+ } else {
1141
1148
  code += '\n}';
1142
1149
  }
1143
1150
  return code;
@@ -331,12 +331,12 @@ export class BindDirective extends BaseNode {
331
331
  const n = logicItem.__v_raw || logicItem;
332
332
  if (Array.isArray((t as any)[parentKey])) {
333
333
  // @ts-ignore
334
- const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
335
- ~index && (this as any)[parentKey].splice(index, 1);
334
+ const index = (t as any)[parentKey]?.findIndex((el) => (el.__v_raw || el) === n);
335
+ ~index && (this as any)[parentKey]?.splice(index, 1);
336
336
  params.index = index;
337
337
  } else {
338
338
  const q = (t as any)[parentKey];
339
- if ((q.__v_raw || q) === n) {
339
+ if ((q?.__v_raw || q) === n) {
340
340
  params.index = 0;
341
341
  (this as any)[parentKey] = undefined;
342
342
  }
@@ -774,7 +774,7 @@ export class BindEvent extends BaseNode {
774
774
  let code = '';
775
775
  if (!Object.keys(elementsEventsMap).length) return;
776
776
  // 业务组件
777
- const businessComponent = this.element.correspondingBusinessComponent;
777
+ const businessComponent = this.element?.correspondingBusinessComponent;
778
778
  // 已有的点击事件,已知类型的,就直接取值
779
779
  if (
780
780
  [
@@ -1092,7 +1092,7 @@ export class BindEvent extends BaseNode {
1092
1092
  const newName = this.name.replace(/-/g, '');
1093
1093
  if (asserts.isViewElement(parentNode)) {
1094
1094
  return `${parentNode.name}_${newName}`;
1095
- } else if (asserts.isView(parentNode)) {
1095
+ } else if (asserts.isView(parentNode) || asserts.isBusinessComponent(parentNode)) {
1096
1096
  return `${this.likeComponent.name}_${newName}`;
1097
1097
  } else {
1098
1098
  // 这里编译成这个名字了 后续pctemplate 里也得按这个调用?
@@ -88,6 +88,11 @@ export class BooleanLiteral extends LogicItem {
88
88
  return this.value;
89
89
  }
90
90
 
91
+ @withSourceMap()
92
+ toTextualNASL(): string {
93
+ return this.value;
94
+ }
95
+
91
96
  /**
92
97
  * 设置布尔值内容
93
98
  */