@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
@@ -308,6 +308,7 @@ function genLoadLogic(getLogic: Logic, nameGroup: NameGroup) {
308
308
  // 生成修改区块
309
309
  export function genUpdateBlock(entity: Entity, oldNode: ViewElement) {
310
310
  const likeComponent = oldNode?.likeComponent;
311
+ const isBusinessComponent = likeComponent.concept === 'BusinessComponent';
311
312
  const dataSource = entity.parentNode as DataSource;
312
313
  const module = dataSource.app;
313
314
  const { ns } = entity;
@@ -357,7 +358,7 @@ export function genUpdateBlock(entity: Entity, oldNode: ViewElement) {
357
358
  {
358
359
  "viewParams": [
359
360
  {
360
- "concept": "Param",
361
+ "concept": "${isBusinessComponent ? 'ParamWithGroup' : 'Param'}",
361
362
  "name": "${nameGroup.viewParamId}",
362
363
  "typeAnnotation": ${JSON.stringify(NaslCoreTypeAnnotation.Long)}
363
364
  }
@@ -137,11 +137,11 @@ export function genUniqueQueryNameGroup(
137
137
  suffix: string = ''
138
138
  ) {
139
139
  const result: NameGroup = {};
140
- result.viewLogicLoad = view.getLogicUniqueName(`load${defaultInView ? '' : capFirstLetter(componentName)}${suffix ? capFirstLetter(suffix) : ''}`);
141
- result.logic = scope.getLogicUniqueName(
140
+ result.viewLogicLoad = view?.getLogicUniqueName?.(`load${defaultInView ? '' : capFirstLetter(componentName)}${suffix ? capFirstLetter(suffix) : ''}`);
141
+ result.logic = scope?.getLogicUniqueName?.(
142
142
  `load${capFirstLetter(view.name)}${componentName ? capFirstLetter(componentName) : ''}${suffix ? capFirstLetter(suffix) : ''}`
143
143
  );
144
- result.structure = scope.getStructureUniqueName(utils.firstUpperCase(`${result.logic}Structure`));
144
+ result.structure = scope?.getStructureUniqueName?.(utils.firstUpperCase(`${result.logic}Structure`));
145
145
  return result;
146
146
  }
147
147
 
@@ -48,6 +48,10 @@ export interface TranslatorState {
48
48
  finalCode?: boolean;
49
49
  focusedNodePath?: string;
50
50
  getVuePrototype?: boolean;
51
+
52
+ // CallLogic 节点翻译时不使用立即运行函数
53
+ callLogicNoIife?: boolean;
54
+ blankNodePath?: string;
51
55
  }
52
56
 
53
57
  export type SourceMapItem = Range;
@@ -31,6 +31,8 @@ export function createCompilerState(startCode: string = '', options?: Partial<Tr
31
31
  export function shiftPosition(pos: Position, code: string = ''): Position {
32
32
  const res = { ...pos};
33
33
  if (code) {
34
+ if (typeof code !== 'string')
35
+ console.log(code);
34
36
  const arr = code.split('\n');
35
37
  res.offset += code.length;
36
38
  res.line += arr.length - 1;
@@ -61,7 +63,7 @@ export function isSameRange(rangeA: Range, rangeB : Range) {
61
63
  /**
62
64
  * 翻译方法修饰器
63
65
  *
64
- * @deprecated
66
+ * 只为 toNaturalTS 用
65
67
  * @description 旧的翻译方法修饰器,现在用`withSourceMapGenerator`
66
68
  */
67
69
  export function withSourceMap() {
@@ -72,6 +74,7 @@ export function withSourceMap() {
72
74
  descriptor.value = function (this: BaseNode, state?: TranslatorState, ...args: any[]) {
73
75
  // 重新生成ts代码就先把类型清除掉
74
76
  // 注意排查错误的时候,调用了这个方法,就会把节点上缓存的__TypeAnnotation清除
77
+
75
78
  try {
76
79
  this.__isCorrectTypeAnnotation = false;
77
80
  } catch (err) {}
@@ -79,43 +82,45 @@ export function withSourceMap() {
79
82
  // 没有状态不生成 SourceMap
80
83
  return oldMethod.call(this, state, ...args);
81
84
  }
82
- // state = Object.freeze(Object.assign({
83
- // position: { line: 0, character: 0, offset: 0 },
84
- // tabSize: 0,
85
- // }, state));
86
-
87
- let before: string = '';
88
- if (!state.inline) {
89
- before = indent((state?.tabSize || 0));
90
- state = shiftState(state, before);
91
- } else {
92
- state = shiftState(state, before, {
93
- inline: undefined,
94
- });
95
- }
85
+
86
+ // state = Object.freeze(Object.assign({
87
+ // position: { line: 0, character: 0, offset: 0 },
88
+ // tabSize: 0,
89
+ // }, state));
90
+
91
+ let before: string = '';
92
+ if (!state.inline) {
93
+ before = indent((state?.tabSize || 0));
94
+ state = shiftState(state, before);
95
+ } else {
96
+ // state = shiftState(state, before, {
97
+ // inline: undefined,
98
+ // });
99
+ }
96
100
 
97
- if (isNatural && state.focusedNodePath) {
98
- const needAddComment = this.nodePath === state.focusedNodePath;
99
- // if (!needAddComment) {
100
- // const parts = state.focusedNodePath.split('.');
101
- // const lastPart = parts.pop();
102
- // }
103
- if (needAddComment) {
104
- const beforeComment = `// 当前位置\n${before}`;
105
- before += beforeComment;
106
- state = shiftState(state, beforeComment);
107
- }
101
+ if (isNatural && state.focusedNodePath) {
102
+ const needAddComment = this.nodePath === state.focusedNodePath;
103
+ // if (!needAddComment) {
104
+ // const parts = state.focusedNodePath.split('.');
105
+ // const lastPart = parts.pop();
106
+ // }
107
+ if (needAddComment) {
108
+ const beforeComment = `// 当前位置\n${before}`;
109
+ before += beforeComment;
110
+ state = shiftState(state, beforeComment);
108
111
  }
112
+ }
109
113
 
110
- // 调用真实方法, 可能有剩余参数
111
- const code = oldMethod.call(this, state, ...args);
114
+ // 调用真实方法, 可能有剩余参数
115
+ // ${(this as any).tsKeyword || '__IDENTIFIER__'}:
116
+ const code = target && this.nodePath === state.blankNodePath ? (this.concept === 'Argument' && args[1] ? `__BLANK__` : '__BLANK__') : oldMethod.call(this, state, ...args);
112
117
 
113
- state.sourceMap?.set(this, {
114
- start: state.position,
115
- end: shiftPosition(state.position, code),
116
- });
118
+ state.sourceMap?.set(this, {
119
+ start: state.position,
120
+ end: shiftPosition(state.position, code),
121
+ });
117
122
 
118
- return before + code;
123
+ return before + code;
119
124
  };
120
125
 
121
126
  return descriptor;
@@ -160,8 +165,19 @@ export function withSourceMapGenerator(target: any, key: string, descriptor: Pro
160
165
  const code = yield* oldMethod.call(this, state, ...args);
161
166
  yield;
162
167
 
168
+ const start = {
169
+ ...state.position
170
+ };
171
+ if (this.concept === 'BusinessComponent') {
172
+ const lines: string[] = code.split('\n');
173
+ const lineOffset = lines.findIndex((item) => item.startsWith('export class '));
174
+ if (lineOffset) {
175
+ start.line = start.line + lineOffset + 1;
176
+ start.offset = 13;
177
+ }
178
+ }
163
179
  state.sourceMap?.set(this, {
164
- start: state.position,
180
+ start,
165
181
  end: shiftPosition(state.position, code),
166
182
  });
167
183
 
@@ -222,3 +238,26 @@ export function transfromUnionTypeAnnotation(expTypeAnnotation: TypeAnnotation,
222
238
  })
223
239
  }
224
240
  }
241
+
242
+ export function createDecoratorCode<T>(state: TranslatorState, node: T, properties: Array<keyof T>) {
243
+ let code = '@(';
244
+
245
+ for (const prop of properties) {
246
+ const value = node[prop] as any;
247
+ if (value === undefined || value === null) continue;
248
+
249
+ if (properties.length > 1) code += `\n${indent(state.tabSize + 1)}`;
250
+ if (value === true)
251
+ code += `${String(prop)}`;
252
+ else
253
+ code += `${String(prop)} = ${JSON.stringify(value)}`;
254
+
255
+ if (properties.length > 1) code += `,`;
256
+ }
257
+
258
+ if (code === '@(') return '';
259
+ if (properties.length > 1) code += `\n${indent(state.tabSize)}`;
260
+
261
+ code += `)\n${indent(state.tabSize)}`;
262
+ return code;
263
+ }
@@ -69,11 +69,11 @@ export function unique(
69
69
  }
70
70
  if (Array.isArray(set))
71
71
  // return set.includes(_key);
72
- return set.some((s) => s.toLowerCase() === lkey);
72
+ return set.some((s) => s?.toLowerCase?.() === lkey);
73
73
 
74
74
  // return set[_key];
75
75
  const keys = Object.keys(set);
76
- return keys.some((k) => k.toLowerCase() === lkey);
76
+ return keys.some((k) => k?.toLowerCase?.() === lkey);
77
77
  };
78
78
  } else {
79
79
  has = (_key: string) => {
@@ -28,16 +28,16 @@ export class Performance {
28
28
  }
29
29
 
30
30
  mark(name: string) {
31
- return performance.mark(this.getPerformanceId(name));
31
+ return performance?.mark?.(this.getPerformanceId(name));
32
32
  }
33
33
 
34
34
  measure(name: string, startMark: string, endMark: string) {
35
- return performance.measure(this.getPerformanceId(name), this.getPerformanceId(startMark), this.getPerformanceId(endMark));
35
+ return performance?.measure?.(this.getPerformanceId(name), this.getPerformanceId(startMark), this.getPerformanceId(endMark));
36
36
  }
37
37
 
38
38
  clearByNames(...names: string[]) {
39
39
  for (const name of names) {
40
- const entry = performance.getEntriesByName(this.getPerformanceId(name))[0];
40
+ const entry = performance?.getEntriesByName?.(this.getPerformanceId(name))[0];
41
41
 
42
42
  if (entry) {
43
43
  this.clearEntry(entry);
@@ -33,7 +33,7 @@ Object {
33
33
 
34
34
  exports[`call-interface:getQuickInfoOffset with-body-no-argument 1`] = `
35
35
  Object {
36
- "code": "apis.a123456.interfaces.with_body({param1:__IDENTIFIER__});
36
+ "code": "apis.a123456.interfaces.with_body({param1:undefined});
37
37
  ",
38
38
  "line": 1,
39
39
  "offset": 25,
@@ -60,7 +60,7 @@ Object {
60
60
 
61
61
  exports[`call-interface:getQuickInfoOffset with-headers-no-argument 1`] = `
62
62
  Object {
63
- "code": "apis.a123456.interfaces.with_headers({param1:__IDENTIFIER__, param2:__IDENTIFIER__});
63
+ "code": "apis.a123456.interfaces.with_headers({param1:__IDENTIFIER__, param2:undefined});
64
64
  ",
65
65
  "line": 1,
66
66
  "offset": 25,
@@ -78,7 +78,7 @@ Object {
78
78
 
79
79
  exports[`call-interface:getQuickInfoOffset with-query-no-argument 1`] = `
80
80
  Object {
81
- "code": "apis.a123456.interfaces.with_query({param1:__IDENTIFIER__, param2:__IDENTIFIER__});
81
+ "code": "apis.a123456.interfaces.with_query({param1:__IDENTIFIER__, param2:undefined});
82
82
  ",
83
83
  "line": 1,
84
84
  "offset": 25,
@@ -28,7 +28,7 @@ exports[`call-interface:toEmbeddedTS with-body-complex-argument 1`] = `
28
28
  `;
29
29
 
30
30
  exports[`call-interface:toEmbeddedTS with-body-no-argument 1`] = `
31
- "apis.a123456.interfaces.with_body({ param1: __IDENTIFIER__ });
31
+ "apis.a123456.interfaces.with_body({ param1: undefined });
32
32
  "
33
33
  `;
34
34
 
@@ -50,7 +50,7 @@ exports[`call-interface:toEmbeddedTS with-headers 1`] = `
50
50
  exports[`call-interface:toEmbeddedTS with-headers-no-argument 1`] = `
51
51
  "apis.a123456.interfaces.with_headers({
52
52
  param1: __IDENTIFIER__,
53
- param2: __IDENTIFIER__,
53
+ param2: undefined,
54
54
  });
55
55
  "
56
56
  `;
@@ -65,7 +65,7 @@ exports[`call-interface:toEmbeddedTS with-query 1`] = `
65
65
  exports[`call-interface:toEmbeddedTS with-query-no-argument 1`] = `
66
66
  "apis.a123456.interfaces.with_query({
67
67
  param1: __IDENTIFIER__,
68
- param2: __IDENTIFIER__,
68
+ param2: undefined,
69
69
  });
70
70
  "
71
71
  `;
@@ -116,6 +116,205 @@ exports[`view-element:toEmbeddedTS default-not-found 1`] = `
116
116
  "
117
117
  `;
118
118
 
119
+ exports[`view-element:toEmbeddedTS table-data-source-calllogic-with-server-validation 1`] = `
120
+ "new nasl.ui.uLinearLayout({
121
+ name: __elements.uLinearLayout1,
122
+ bindAttr: () => [() => {}, () => {}],
123
+ slotDefault: () => {
124
+ return [
125
+ new nasl.ui.uLinearLayout({
126
+ name: __elements.linear_layout_1,
127
+ bindAttr: () => [() => {}],
128
+ slotDefault: () => {
129
+ type datasourceNametableView_1 = nasl.ui.GetItemTypeFromDataSource<
130
+ typeof app.logics.loadTestTableView_1
131
+ >;
132
+
133
+ return [
134
+ new nasl.ui.uTableView<datasourceNametableView_1>({
135
+ name: __elements.tableView_1,
136
+ bindAttr: () => [
137
+ () => {
138
+ (() => {
139
+ const wrapper = nasl.util.callLogicWithChecker(
140
+ app.logics.loadTestTableView_1,
141
+ (page, size, sort, order, filter) => {
142
+ () => {};
143
+ }
144
+ );
145
+ return wrapper(
146
+ __elements_completionProperty[\\"tableView_1\\"].pageNumber,
147
+ __elements_completionProperty[\\"tableView_1\\"].pageSize,
148
+ __elements_completionProperty[\\"tableView_1\\"].sorting
149
+ .field,
150
+ __elements_completionProperty[\\"tableView_1\\"].sorting
151
+ .order,
152
+ filter
153
+ );
154
+ })();
155
+ },
156
+ () => {},
157
+ () => {},
158
+ () => {},
159
+ () => {},
160
+ () => {},
161
+ () => {},
162
+ ],
163
+ slotDefault: () => {
164
+ return [
165
+ new nasl.ui.uTableViewColumn({
166
+ name: __elements.table_view_column_1,
167
+ bindAttr: () => [() => {}, () => {}],
168
+ slotExpander: (current) => {
169
+ return [
170
+ new nasl.ui.uTableViewExpander({
171
+ name: __elements.table_view_expander_1,
172
+ bindAttr: () => [
173
+ () => {
174
+ current.item;
175
+ },
176
+ ],
177
+ slotDefault: () => {
178
+ return [];
179
+ },
180
+ }),
181
+ ];
182
+ },
183
+ slotCell: (current) => {
184
+ return [];
185
+ },
186
+ slotTitle: () => {
187
+ return [
188
+ new nasl.ui.uText({
189
+ name: __elements.text_9,
190
+ bindAttr: () => [() => {}],
191
+ slotDefault: () => {
192
+ return [];
193
+ },
194
+ }),
195
+ ];
196
+ },
197
+ }),
198
+
199
+ new nasl.ui.uTableViewColumn({
200
+ name: __elements.table_view_column_2,
201
+ bindAttr: () => [() => {}],
202
+ slotExpander: (current) => {
203
+ return [
204
+ new nasl.ui.uTableViewExpander({
205
+ name: __elements.table_view_expander_2,
206
+ bindAttr: () => [
207
+ () => {
208
+ current.item;
209
+ },
210
+ ],
211
+ slotDefault: () => {
212
+ return [];
213
+ },
214
+ }),
215
+ ];
216
+ },
217
+ slotCell: (current) => {
218
+ return [
219
+ new nasl.ui.uLinearLayout({
220
+ name: __elements.linear_layout_4,
221
+ bindAttr: () => [() => {}],
222
+ slotDefault: () => {
223
+ return [
224
+ new nasl.ui.uText({
225
+ name: __elements.text_10,
226
+ bindAttr: () => [
227
+ () => {
228
+ current.item.entity1.createdTime;
229
+ },
230
+ ],
231
+ slotDefault: () => {
232
+ return [];
233
+ },
234
+ }),
235
+ ];
236
+ },
237
+ }),
238
+ ];
239
+ },
240
+ slotTitle: () => {
241
+ return [
242
+ new nasl.ui.uText({
243
+ name: __elements.text_11,
244
+ bindAttr: () => [() => {}],
245
+ slotDefault: () => {
246
+ return [];
247
+ },
248
+ }),
249
+ ];
250
+ },
251
+ }),
252
+
253
+ new nasl.ui.uTableViewColumn({
254
+ name: __elements.table_view_column_3,
255
+ bindAttr: () => [() => {}],
256
+ slotExpander: (current) => {
257
+ return [
258
+ new nasl.ui.uTableViewExpander({
259
+ name: __elements.table_view_expander_3,
260
+ bindAttr: () => [
261
+ () => {
262
+ current.item;
263
+ },
264
+ ],
265
+ slotDefault: () => {
266
+ return [];
267
+ },
268
+ }),
269
+ ];
270
+ },
271
+ slotCell: (current) => {
272
+ return [
273
+ new nasl.ui.uLinearLayout({
274
+ name: __elements.linear_layout_5,
275
+ bindAttr: () => [() => {}],
276
+ slotDefault: () => {
277
+ return [
278
+ new nasl.ui.uText({
279
+ name: __elements.text_12,
280
+ bindAttr: () => [
281
+ () => {
282
+ current.item.entity1.updatedTime;
283
+ },
284
+ ],
285
+ slotDefault: () => {
286
+ return [];
287
+ },
288
+ }),
289
+ ];
290
+ },
291
+ }),
292
+ ];
293
+ },
294
+ slotTitle: () => {
295
+ return [
296
+ new nasl.ui.uText({
297
+ name: __elements.text_13,
298
+ bindAttr: () => [() => {}],
299
+ slotDefault: () => {
300
+ return [];
301
+ },
302
+ }),
303
+ ];
304
+ },
305
+ }),
306
+ ];
307
+ },
308
+ }),
309
+ ];
310
+ },
311
+ }),
312
+ ];
313
+ },
314
+ });
315
+ "
316
+ `;
317
+
119
318
  exports[`view-element:toEmbeddedTS with-role-auth 1`] = `
120
319
  "new nasl.ui.uLinearLayout({
121
320
  name: __elements.uLinearLayout1,
@@ -4,14 +4,14 @@ exports[`view-element:toVue default-login 1`] = `
4
4
  "<template>
5
5
  <u-linear-layout
6
6
  :ref=\\"\`uLinearLayout1\`\\"
7
+ :alignment=\\"\`center\`\\"
8
+ :justify=\\"\`center\`\\"
9
+ :type=\\"\`flex\`\\"
7
10
  style=\\"
8
11
  background: url('/assets/login-bg-1.jpg') no-repeat;
9
12
  background-size: cover;
10
13
  height: 100vh;
11
14
  \\"
12
- :alignment=\\"\`center\`\\"
13
- :justify=\\"\`center\`\\"
14
- :type=\\"\`flex\`\\"
15
15
  >
16
16
  <u-linear-layout
17
17
  :ref=\\"\`uLinearLayout2\`\\"
@@ -49,10 +49,10 @@ exports[`view-element:toVue default-not-found 1`] = `
49
49
  "<template>
50
50
  <u-linear-layout
51
51
  :ref=\\"\`uLinearLayout1\`\\"
52
- style=\\"height: 100vh\\"
53
52
  :justify=\\"\`center\`\\"
54
53
  :type=\\"\`flex\`\\"
55
54
  :alignment=\\"\`center\`\\"
55
+ style=\\"height: 100vh\\"
56
56
  >
57
57
  <u-linear-layout
58
58
  :ref=\\"\`uLinearLayout2\`\\"
@@ -88,14 +88,135 @@ exports[`view-element:toVue default-not-found 1`] = `
88
88
  "
89
89
  `;
90
90
 
91
- exports[`view-element:toVue with-role-auth 1`] = `
91
+ exports[`view-element:toVue table-data-source-calllogic-with-server-validation 1`] = `
92
92
  "<template>
93
93
  <u-linear-layout
94
94
  :ref=\\"\`uLinearLayout1\`\\"
95
+ :type=\\"\`root\`\\"
96
+ :gap=\\"\`none\`\\"
95
97
  style=\\"height: 100%; --custom-start: auto; min-height: 200px\\"
98
+ >
99
+ <u-linear-layout
100
+ :ref=\\"\`linear_layout_1\`\\"
101
+ :direction=\\"\`vertical\`\\"
102
+ style=\\"--custom-start: auto\\"
103
+ >
104
+ <u-table-view
105
+ :ref=\\"\`tableView_1\`\\"
106
+ :data-source=\\"__tableView_1_dataSourceLoad\\"
107
+ :data-schema=\\"\`LoadTestTableView_1Structure\`\\"
108
+ :value-field=\\"\`entity1.id\`\\"
109
+ :pagination=\\"true\\"
110
+ :show-sizer=\\"true\\"
111
+ :page-size=\\"20\\"
112
+ :page-number=\\"1\\"
113
+ key=\\"tableView_1\\"
114
+ >
115
+ <u-table-view-column
116
+ :ref=\\"\`table_view_column_1\`\\"
117
+ :type=\\"\`index\`\\"
118
+ :width=\\"\`60\`\\"
119
+ >
120
+ <template #expander=\\"current\\" :ref=\\"\`template_9\`\\">
121
+ <u-table-view-expander
122
+ :ref=\\"\`table_view_expander_1_\${
123
+ (current || {}).__nodeKey || (current || {}).index
124
+ }\`\\"
125
+ :item=\\"(current || {}).item\\"
126
+ ></u-table-view-expander>
127
+ </template>
128
+ <template #cell=\\"current\\" :ref=\\"\`template_10\`\\"></template>
129
+ <template #title :ref=\\"\`template_11\`\\">
130
+ <u-text :ref=\\"\`text_9\`\\" :text=\\"\`序号\`\\"></u-text>
131
+ </template>
132
+ </u-table-view-column>
133
+ <u-table-view-column
134
+ :ref=\\"\`table_view_column_2\`\\"
135
+ :field=\\"\`entity1.createdTime\`\\"
136
+ >
137
+ <template #expander=\\"current\\" :ref=\\"\`template_12\`\\">
138
+ <u-table-view-expander
139
+ :ref=\\"\`table_view_expander_2_\${
140
+ (current || {}).__nodeKey || (current || {}).index
141
+ }\`\\"
142
+ :item=\\"(current || {}).item\\"
143
+ ></u-table-view-expander>
144
+ </template>
145
+ <template #cell=\\"current\\" :ref=\\"\`template_13\`\\">
146
+ <u-linear-layout
147
+ :ref=\\"\`linear_layout_4_\${
148
+ (current || {}).__nodeKey || (current || {}).index
149
+ }\`\\"
150
+ :gap=\\"\`small\`\\"
151
+ >
152
+ <u-text
153
+ :ref=\\"\`text_10_\${
154
+ (current || {}).__nodeKey || (current || {}).index
155
+ }\`\\"
156
+ :text=\\"
157
+ $utils['ToString'](
158
+ 'undefined',
159
+ (((current || {}).item || {}).entity1 || {}).createdTime
160
+ )
161
+ \\"
162
+ ></u-text>
163
+ </u-linear-layout>
164
+ </template>
165
+ <template #title :ref=\\"\`template_14\`\\">
166
+ <u-text :ref=\\"\`text_11\`\\" :text=\\"\`创建时间\`\\"></u-text>
167
+ </template>
168
+ </u-table-view-column>
169
+ <u-table-view-column
170
+ :ref=\\"\`table_view_column_3\`\\"
171
+ :field=\\"\`entity1.updatedTime\`\\"
172
+ >
173
+ <template #expander=\\"current\\" :ref=\\"\`template_15\`\\">
174
+ <u-table-view-expander
175
+ :ref=\\"\`table_view_expander_3_\${
176
+ (current || {}).__nodeKey || (current || {}).index
177
+ }\`\\"
178
+ :item=\\"(current || {}).item\\"
179
+ ></u-table-view-expander>
180
+ </template>
181
+ <template #cell=\\"current\\" :ref=\\"\`template_16\`\\">
182
+ <u-linear-layout
183
+ :ref=\\"\`linear_layout_5_\${
184
+ (current || {}).__nodeKey || (current || {}).index
185
+ }\`\\"
186
+ :gap=\\"\`small\`\\"
187
+ >
188
+ <u-text
189
+ :ref=\\"\`text_12_\${
190
+ (current || {}).__nodeKey || (current || {}).index
191
+ }\`\\"
192
+ :text=\\"
193
+ $utils['ToString'](
194
+ 'undefined',
195
+ (((current || {}).item || {}).entity1 || {}).updatedTime
196
+ )
197
+ \\"
198
+ ></u-text>
199
+ </u-linear-layout>
200
+ </template>
201
+ <template #title :ref=\\"\`template_17\`\\">
202
+ <u-text :ref=\\"\`text_13\`\\" :text=\\"\`更新时间\`\\"></u-text>
203
+ </template>
204
+ </u-table-view-column>
205
+ </u-table-view>
206
+ </u-linear-layout>
207
+ </u-linear-layout>
208
+ </template>
209
+ "
210
+ `;
211
+
212
+ exports[`view-element:toVue with-role-auth 1`] = `
213
+ "<template>
214
+ <u-linear-layout
215
+ :ref=\\"\`uLinearLayout1\`\\"
96
216
  :type=\\"\`root\`\\"
97
217
  :gap=\\"\`none\`\\"
98
218
  v-if=\\"$auth.has('/pc/test_2/uLinearLayout1')\\"
219
+ style=\\"height: 100%; --custom-start: auto; min-height: 200px\\"
99
220
  >
100
221
  <u-router-view :ref=\\"\`router_view1\`\\"></u-router-view>
101
222
  </u-linear-layout>
@@ -107,9 +228,9 @@ exports[`view-element:toVue with-table 1`] = `
107
228
  "<template>
108
229
  <u-linear-layout
109
230
  :ref=\\"\`uLinearLayout1\`\\"
110
- style=\\"height: 100%; --custom-start: auto; min-height: 200px\\"
111
231
  :type=\\"\`root\`\\"
112
232
  :gap=\\"\`none\`\\"
233
+ style=\\"height: 100%; --custom-start: auto; min-height: 200px\\"
113
234
  >
114
235
  <u-linear-layout :ref=\\"\`linear_layout1\`\\" :direction=\\"\`vertical\`\\">
115
236
  <u-linear-layout :ref=\\"\`linear_layout2\`\\" :justify=\\"\`space-between\`\\">