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

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 (249) hide show
  1. package/.mocharc.js +1 -0
  2. package/out/common/BaseNode.d.ts +21 -5
  3. package/out/common/BaseNode.js +94 -12
  4. package/out/common/BaseNode.js.map +1 -1
  5. package/out/concepts/AbstractInterface__.js.map +1 -1
  6. package/out/concepts/Annotation__.js +1 -1
  7. package/out/concepts/Annotation__.js.map +1 -1
  8. package/out/concepts/App__.d.ts +3 -0
  9. package/out/concepts/App__.js +985 -6
  10. package/out/concepts/App__.js.map +1 -1
  11. package/out/concepts/Argument__.js +3 -3
  12. package/out/concepts/Argument__.js.map +1 -1
  13. package/out/concepts/BatchAssignment__.d.ts +1 -1
  14. package/out/concepts/BatchAssignment__.js +2 -2
  15. package/out/concepts/BatchAssignment__.js.map +1 -1
  16. package/out/concepts/BindAttribute__.js +7 -7
  17. package/out/concepts/BindAttribute__.js.map +1 -1
  18. package/out/concepts/BindDirective__.js +3 -4
  19. package/out/concepts/BindDirective__.js.map +1 -1
  20. package/out/concepts/BindStyle__.js +1 -1
  21. package/out/concepts/BindStyle__.js.map +1 -1
  22. package/out/concepts/BusinessComponent__.d.ts +2 -0
  23. package/out/concepts/BusinessComponent__.js +48 -0
  24. package/out/concepts/BusinessComponent__.js.map +1 -1
  25. package/out/concepts/BusinessLogic__.d.ts +1 -0
  26. package/out/concepts/BusinessLogic__.js +10 -0
  27. package/out/concepts/BusinessLogic__.js.map +1 -1
  28. package/out/concepts/CallEvent__.d.ts +2 -0
  29. package/out/concepts/CallEvent__.js +75 -0
  30. package/out/concepts/CallEvent__.js.map +1 -1
  31. package/out/concepts/CallInterface__.d.ts +1 -0
  32. package/out/concepts/CallInterface__.js +26 -15
  33. package/out/concepts/CallInterface__.js.map +1 -1
  34. package/out/concepts/CallLogic__.d.ts +4 -0
  35. package/out/concepts/CallLogic__.js +65 -5
  36. package/out/concepts/CallLogic__.js.map +1 -1
  37. package/out/concepts/Entity__.d.ts +3 -3
  38. package/out/concepts/Entity__.js +4 -0
  39. package/out/concepts/Entity__.js.map +1 -1
  40. package/out/concepts/EnumItem__.d.ts +13 -0
  41. package/out/concepts/EnumItem__.js +31 -0
  42. package/out/concepts/EnumItem__.js.map +1 -1
  43. package/out/concepts/Event__.d.ts +2 -0
  44. package/out/concepts/Event__.js +30 -0
  45. package/out/concepts/Event__.js.map +1 -1
  46. package/out/concepts/FrontendType__.d.ts +2 -0
  47. package/out/concepts/FrontendType__.js +32 -0
  48. package/out/concepts/FrontendType__.js.map +1 -1
  49. package/out/concepts/Frontend__.d.ts +2 -0
  50. package/out/concepts/Frontend__.js +48 -0
  51. package/out/concepts/Frontend__.js.map +1 -1
  52. package/out/concepts/IfStatement__.js +6 -6
  53. package/out/concepts/IfStatement__.js.map +1 -1
  54. package/out/concepts/InterfaceParam__.d.ts +1 -0
  55. package/out/concepts/InterfaceParam__.js +23 -4
  56. package/out/concepts/InterfaceParam__.js.map +1 -1
  57. package/out/concepts/Interface__.d.ts +2 -1
  58. package/out/concepts/Interface__.js +29 -5
  59. package/out/concepts/Interface__.js.map +1 -1
  60. package/out/concepts/JSBlock__.d.ts +1 -0
  61. package/out/concepts/JSBlock__.js +6 -0
  62. package/out/concepts/JSBlock__.js.map +1 -1
  63. package/out/concepts/LogicDeclaration__.d.ts +1 -0
  64. package/out/concepts/LogicDeclaration__.js +58 -7
  65. package/out/concepts/LogicDeclaration__.js.map +1 -1
  66. package/out/concepts/Logic__.js +46 -27
  67. package/out/concepts/Logic__.js.map +1 -1
  68. package/out/concepts/MatchCase__.js +1 -2
  69. package/out/concepts/MatchCase__.js.map +1 -1
  70. package/out/concepts/Match__.js +3 -18
  71. package/out/concepts/Match__.js.map +1 -1
  72. package/out/concepts/MemberExpression__.js +4 -4
  73. package/out/concepts/MemberExpression__.js.map +1 -1
  74. package/out/concepts/Module__.d.ts +4 -0
  75. package/out/concepts/Module__.js +92 -0
  76. package/out/concepts/Module__.js.map +1 -1
  77. package/out/concepts/NewComposite__.d.ts +1 -1
  78. package/out/concepts/NewComposite__.js +2 -2
  79. package/out/concepts/NewComposite__.js.map +1 -1
  80. package/out/concepts/NullLiteral__.js +6 -0
  81. package/out/concepts/NullLiteral__.js.map +1 -1
  82. package/out/concepts/Paginate__.d.ts +1 -0
  83. package/out/concepts/Paginate__.js +15 -7
  84. package/out/concepts/Paginate__.js.map +1 -1
  85. package/out/concepts/QueryFromExpression__.js +2 -2
  86. package/out/concepts/QueryFromExpression__.js.map +1 -1
  87. package/out/concepts/StringLiteral__.js +3 -4
  88. package/out/concepts/StringLiteral__.js.map +1 -1
  89. package/out/concepts/StructureProperty__.d.ts +13 -0
  90. package/out/concepts/StructureProperty__.js +31 -0
  91. package/out/concepts/StructureProperty__.js.map +1 -1
  92. package/out/concepts/TypeAnnotation__.js +1 -0
  93. package/out/concepts/TypeAnnotation__.js.map +1 -1
  94. package/out/concepts/ViewElement__.d.ts +2 -0
  95. package/out/concepts/ViewElement__.js +61 -41
  96. package/out/concepts/ViewElement__.js.map +1 -1
  97. package/out/concepts/View__.d.ts +1 -0
  98. package/out/concepts/View__.js +55 -1
  99. package/out/concepts/View__.js.map +1 -1
  100. package/out/concepts/basics/stdlib/nasl.processV2.js +1 -1
  101. package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
  102. package/out/generator/genBundleFiles.js +36 -22
  103. package/out/generator/genBundleFiles.js.map +1 -1
  104. package/out/generator/genHash.d.ts +2 -2
  105. package/out/generator/genHash.js +30 -30
  106. package/out/generator/genHash.js.map +1 -1
  107. package/out/generator/genMetaData.js +7 -49
  108. package/out/generator/genMetaData.js.map +1 -1
  109. package/out/generator/permission.d.ts +8 -1
  110. package/out/generator/permission.js +321 -23
  111. package/out/generator/permission.js.map +1 -1
  112. package/out/generator/release-body/body.d.ts +5 -0
  113. package/out/generator/release-body/body.js +62 -12
  114. package/out/generator/release-body/body.js.map +1 -1
  115. package/out/generator/release-body/data.js +6 -2
  116. package/out/generator/release-body/data.js.map +1 -1
  117. package/out/generator/release-body/index.d.ts +1 -0
  118. package/out/generator/release-body/index.js +1 -0
  119. package/out/generator/release-body/index.js.map +1 -1
  120. package/out/generator/release-body/utils.js +3 -3
  121. package/out/generator/release-body/utils.js.map +1 -1
  122. package/out/generator/release-body/validation.js +2 -2
  123. package/out/generator/release-body/validation.js.map +1 -1
  124. package/out/index.d.ts +1 -1
  125. package/out/index.js.map +1 -1
  126. package/out/natural/genNaturalTS.d.ts +24 -56
  127. package/out/natural/genNaturalTS.js +116 -184
  128. package/out/natural/genNaturalTS.js.map +1 -1
  129. package/out/natural/getContext/getUILib.js +2 -3
  130. package/out/natural/getContext/getUILib.js.map +1 -1
  131. package/out/natural/getContext/index.d.ts +26 -35
  132. package/out/natural/getContext/index.js +172 -311
  133. package/out/natural/getContext/index.js.map +1 -1
  134. package/out/natural/index.d.ts +0 -1
  135. package/out/natural/index.js +0 -1
  136. package/out/natural/index.js.map +1 -1
  137. package/out/natural/transformTS2UI.js +31 -14
  138. package/out/natural/transformTS2UI.js.map +1 -1
  139. package/out/natural/transformTSCode.js +26 -10
  140. package/out/natural/transformTSCode.js.map +1 -1
  141. package/out/server/entity2LogicNamespace.d.ts +2 -2
  142. package/out/server/entity2LogicNamespace.js +321 -310
  143. package/out/server/entity2LogicNamespace.js.map +1 -1
  144. package/out/server/extendBaseNode.js +25 -0
  145. package/out/server/extendBaseNode.js.map +1 -1
  146. package/out/server/getLogics.js +1 -1
  147. package/out/server/getLogics.js.map +1 -1
  148. package/out/server/naslServer.d.ts +10 -4
  149. package/out/server/naslServer.js +77 -19
  150. package/out/server/naslServer.js.map +1 -1
  151. package/out/server/translator.js +12 -0
  152. package/out/server/translator.js.map +1 -1
  153. package/out/templator/genCreateBlock.js +3 -3
  154. package/out/templator/genCreateBlock.js.map +1 -1
  155. package/out/templator/genCurdEditMultipleKeyBlock.js +2 -2
  156. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  157. package/out/templator/genCurdMultipleKeyBlock.js +5 -5
  158. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  159. package/out/templator/genEditTableBlock.js +1 -1
  160. package/out/templator/genEditTableBlock.js.map +1 -1
  161. package/out/templator/genGetBlock.js.map +1 -1
  162. package/out/templator/genGridViewBlock.js.map +1 -1
  163. package/out/templator/genSelectBlock.js.map +1 -1
  164. package/out/templator/genTableBlock.js.map +1 -1
  165. package/out/templator/genUpdateBlock.js +3 -3
  166. package/out/templator/genUpdateBlock.js.map +1 -1
  167. package/out/templator/utils.js +1 -1
  168. package/out/templator/utils.js.map +1 -1
  169. package/out/translator/types.d.ts +2 -0
  170. package/package.json +5 -5
  171. package/sandbox/stdlib/nasl.processV2.ts +1 -1
  172. package/sandbox/stdlib/nasl.ui.definition.ts +0 -18
  173. package/src/common/BaseNode.ts +100 -16
  174. package/src/concepts/AbstractInterface__.ts +1 -0
  175. package/src/concepts/Annotation__.ts +1 -1
  176. package/src/concepts/App__.ts +126 -6
  177. package/src/concepts/Argument__.ts +3 -3
  178. package/src/concepts/BatchAssignment__.ts +2 -2
  179. package/src/concepts/BindAttribute__.ts +7 -7
  180. package/src/concepts/BindDirective__.ts +3 -4
  181. package/src/concepts/BindStyle__.ts +1 -1
  182. package/src/concepts/BusinessComponent__.ts +54 -1
  183. package/src/concepts/BusinessLogic__.ts +10 -1
  184. package/src/concepts/CallEvent__.ts +66 -0
  185. package/src/concepts/CallInterface__.ts +21 -9
  186. package/src/concepts/CallLogic__.ts +66 -5
  187. package/src/concepts/Entity__.ts +7 -1
  188. package/src/concepts/EnumItem__.ts +40 -1
  189. package/src/concepts/Event__.ts +32 -0
  190. package/src/concepts/FrontendType__.ts +34 -1
  191. package/src/concepts/Frontend__.ts +51 -0
  192. package/src/concepts/IfStatement__.ts +6 -6
  193. package/src/concepts/InterfaceParam__.ts +23 -4
  194. package/src/concepts/Interface__.ts +29 -5
  195. package/src/concepts/JSBlock__.ts +5 -0
  196. package/src/concepts/LogicDeclaration__.ts +65 -7
  197. package/src/concepts/Logic__.ts +49 -31
  198. package/src/concepts/MatchCase__.ts +1 -2
  199. package/src/concepts/Match__.ts +3 -21
  200. package/src/concepts/MemberExpression__.ts +4 -4
  201. package/src/concepts/Module__.ts +109 -0
  202. package/src/concepts/NewComposite__.ts +2 -2
  203. package/src/concepts/NullLiteral__.ts +7 -0
  204. package/src/concepts/Paginate__.ts +14 -7
  205. package/src/concepts/QueryFromExpression__.ts +2 -2
  206. package/src/concepts/StringLiteral__.ts +3 -4
  207. package/src/concepts/StructureProperty__.ts +41 -0
  208. package/src/concepts/TypeAnnotation__.ts +1 -0
  209. package/src/concepts/ViewElement__.ts +40 -19
  210. package/src/concepts/View__.ts +56 -1
  211. package/src/concepts/basics/stdlib/nasl.processV2.ts +1 -1
  212. package/src/generator/genBundleFiles.ts +39 -26
  213. package/src/generator/genHash.ts +32 -6
  214. package/src/generator/genMetaData.ts +11 -32
  215. package/src/generator/permission.ts +333 -23
  216. package/src/generator/release-body/body.ts +74 -15
  217. package/src/generator/release-body/data.ts +7 -2
  218. package/src/generator/release-body/index.ts +1 -0
  219. package/src/generator/release-body/utils.ts +3 -3
  220. package/src/generator/release-body/validation.ts +1 -1
  221. package/src/index.ts +13 -1
  222. package/src/natural/genNaturalTS.ts +148 -330
  223. package/src/natural/getContext/getUILib.ts +2 -3
  224. package/src/natural/getContext/index.ts +188 -357
  225. package/src/natural/index.ts +0 -1
  226. package/src/natural/transformTS2UI.ts +28 -14
  227. package/src/natural/transformTSCode.ts +25 -10
  228. package/src/server/entity2LogicNamespace.ts +13 -1
  229. package/src/server/extendBaseNode.ts +31 -0
  230. package/src/server/getLogics.ts +1 -1
  231. package/src/server/naslServer.ts +107 -27
  232. package/src/server/translator.ts +15 -0
  233. package/src/templator/genCreateBlock.ts +4 -4
  234. package/src/templator/genCurdEditMultipleKeyBlock.ts +2 -2
  235. package/src/templator/genCurdMultipleKeyBlock.ts +8 -8
  236. package/src/templator/genEditTableBlock.ts +4 -4
  237. package/src/templator/genGetBlock.ts +1 -1
  238. package/src/templator/genGridViewBlock.ts +2 -2
  239. package/src/templator/genSelectBlock.ts +3 -3
  240. package/src/templator/genTableBlock.ts +2 -2
  241. package/src/templator/genUpdateBlock.ts +6 -6
  242. package/src/templator/utils.ts +1 -1
  243. package/src/translator/types.ts +2 -0
  244. package/test/concepts/string-literal/__snapshots__/toVue.spec.ts.snap +1 -1
  245. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +6 -2
  246. package/out/natural/tools.d.ts +0 -11
  247. package/out/natural/tools.js +0 -155
  248. package/out/natural/tools.js.map +0 -1
  249. package/src/natural/tools.ts +0 -130
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCurrentNodeContextForUI = exports.getCurrentNodeContext = exports.getFrontendViewsCode = exports.getFrontendViews = exports.getChildrenViews = exports.getFrontendVariables = exports.getDependenciesCode = exports.getDependencies = exports.getConnectorsCode = exports.getConnectors = exports.getConnections = exports.getModuleInterfacesCode = exports.getModuleInterfaces = exports.getLogicsCode = exports.getLogics = exports.getStructuresCode = exports.getStructures = exports.getEntitiesCode = exports.getEntities = exports.getEnumsCode = exports.getEnums = exports.getNaslOQL = exports.getNaslUIOld = exports.getNaslUICode = exports.getNaslUI = exports.getNaslUtil = exports.getNaslCore = exports.getLogicWithStructuresCode = exports.getReferenceStructures = exports.wrapTSBlock = void 0;
4
- const concepts_1 = require("../../concepts");
3
+ exports.getCurrentNodeContextForUI = exports.getCurrentNodeContext = exports.getFrontendViews = exports.getChildrenViews = exports.getFrontendVariables = exports.getDependencies = exports.getConnectors = exports.getModuleInterfaces = exports.getLogics = exports.getStructures = exports.getEntities = exports.getEnums = exports.getNaslOQL = exports.getNaslUIOld = exports.getNaslUI = exports.getNaslUtil = exports.getNaslCore = exports.getLogicStructures = exports.wrapTSBlock = void 0;
5
4
  const translator_1 = require("../../translator");
6
5
  const getUILib_1 = require("./getUILib");
7
6
  const naslStdlibMap_1 = require("./naslStdlibMap");
@@ -9,35 +8,8 @@ const wrapTSBlock = (code) => {
9
8
  return `\`\`\`ts\n${code.trimEnd()}\n\`\`\`\n`;
10
9
  };
11
10
  exports.wrapTSBlock = wrapTSBlock;
12
- // 获取有引用的 structures
13
- function getReferenceStructures(referenceStructures, structures) {
14
- const relationStructures = [];
15
- referenceStructures?.forEach((reference) => {
16
- structures?.filter((structure) => structure?.name === reference?.typeName)
17
- ?.forEach((structure) => {
18
- structure.properties?.forEach((property) => {
19
- if (property?.typeAnnotation?.typeKind === 'reference') {
20
- const { typeNamespace, typeName } = property?.typeAnnotation || {};
21
- relationStructures.push({ typeNamespace, typeName });
22
- }
23
- if (property?.typeAnnotation?.typeArguments?.length) {
24
- property?.typeAnnotation?.typeArguments?.forEach((typeArg) => {
25
- if (typeArg.typeKind === 'reference') {
26
- const { typeNamespace, typeName } = typeArg || {};
27
- relationStructures.push({ typeNamespace, typeName });
28
- }
29
- });
30
- }
31
- });
32
- });
33
- });
34
- if (!relationStructures.length)
35
- return relationStructures;
36
- return [...relationStructures, ...getReferenceStructures(relationStructures, structures)];
37
- }
38
- exports.getReferenceStructures = getReferenceStructures;
39
11
  // 获取logic用到的数据结构(带属性版)
40
- function getLogicWithStructuresCode(logic, type, desc, namespace) {
12
+ function getLogicStructures(logic, type, desc, namespace) {
41
13
  const { params, returns } = logic || {};
42
14
  if (!params?.length && !returns?.length)
43
15
  return '';
@@ -59,28 +31,29 @@ function getLogicWithStructuresCode(logic, type, desc, namespace) {
59
31
  });
60
32
  }
61
33
  });
62
- let structures = [];
63
- if (type === 'connector') {
64
- structures = logic?.connector?.structures;
65
- }
66
- else if (type === 'extension' || type === 'interface') {
67
- structures = logic?.parentNode?.structures;
68
- }
69
- const relationStructures = getReferenceStructures(referenceStructures, structures);
70
- const newRelationStructures = [...relationStructures, ...referenceStructures];
71
- if (namespace && newRelationStructures?.length) {
34
+ if (namespace && referenceStructures?.length) {
72
35
  code += `declare namespace ${namespace} {\n`;
73
36
  }
74
- newRelationStructures?.forEach((reference) => {
75
- const { typeName } = reference || {};
37
+ referenceStructures?.forEach((reference) => {
38
+ const { typeNamespace, typeName } = reference || {};
76
39
  const state = (0, translator_1.createCompilerState)();
77
40
  const tabSize = namespace ? (0, translator_1.shiftState)(state, code, { tabSize: 1 }) : undefined;
78
- structures?.filter((structure) => structure?.name === typeName)
79
- ?.forEach((structure) => {
80
- code += `${structure?.toNaturalTS(tabSize)}\n`;
81
- });
41
+ if (typeNamespace?.includes('extensions.') && type === 'connector') {
42
+ logic?.connector?.structures
43
+ ?.filter((structure) => structure?.name === typeName)
44
+ ?.forEach((structure) => {
45
+ code += `${structure?.toNaturalTS(tabSize)}\n`;
46
+ });
47
+ }
48
+ if ((typeNamespace?.includes('extensions.') && type === 'extension') || (typeNamespace?.includes('apis.') && type === 'interface')) {
49
+ logic?.parentNode?.structures
50
+ ?.filter((structure) => structure?.name === typeName)
51
+ ?.forEach((structure) => {
52
+ code += `${structure?.toNaturalTS(tabSize)}\n`;
53
+ });
54
+ }
82
55
  });
83
- if (namespace && newRelationStructures?.length) {
56
+ if (namespace && referenceStructures?.length) {
84
57
  code += `}\n`;
85
58
  }
86
59
  const { description, codeStr } = desc || {};
@@ -91,7 +64,7 @@ function getLogicWithStructuresCode(logic, type, desc, namespace) {
91
64
  code = (0, exports.wrapTSBlock)(code);
92
65
  return code;
93
66
  }
94
- exports.getLogicWithStructuresCode = getLogicWithStructuresCode;
67
+ exports.getLogicStructures = getLogicStructures;
95
68
  function getNaslCore(logicType) {
96
69
  let naslCore = `${(0, naslStdlibMap_1.getNASLStdlibMap)('nasl.core.ts')}\n`;
97
70
  if (logicType === 'global_logic')
@@ -108,43 +81,31 @@ function getNaslUtil() {
108
81
  return { code, naslUtil };
109
82
  }
110
83
  exports.getNaslUtil = getNaslUtil;
111
- const getNaslUI = (app, frontendType, material) => {
112
- let naslUI = [];
113
- if (material.basicMaterials) {
114
- naslUI = typeof material.basicMaterials === 'string' ? (0, getUILib_1.getUILib)(material.basicMaterials) : (0, getUILib_1.handleMaterial)(material.basicMaterials);
84
+ const getNaslUI = (app, frontendType, material, requiredIndexes) => {
85
+ const hasModuleIndexList = requiredIndexes?.length > 0;
86
+ const uiLib = typeof material === 'string' ? (0, getUILib_1.getUILib)(material) : (0, getUILib_1.handleMaterial)(material.basicMaterials);
87
+ const extensionMaterials = typeof material === 'string' ? (0, getUILib_1.getExtensionsMaterial)(app, frontendType) : material.extensionMaterials || [];
88
+ uiLib.push(...extensionMaterials);
89
+ if (!hasModuleIndexList) {
90
+ const naslUI = uiLib;
91
+ const code = naslUI.map((item, index) => `[3-${index}] ${item.name} | ${item.title} | ${item.description}`).join('\n');
92
+ return { code, naslUI };
115
93
  }
116
- const extensionMaterials = typeof material.extensionMaterials === 'string' ? (0, getUILib_1.getExtensionsMaterial)(app, frontendType) : material.extensionMaterials || [];
117
- naslUI.push(...extensionMaterials);
118
- return { naslUI };
119
- };
120
- exports.getNaslUI = getNaslUI;
121
- const getNaslUICode = (naslUI, codeType, requiredIndexes) => {
122
- let code = '';
123
94
  const preDeclaration = (0, getUILib_1.getPreDeclaration)();
124
- let uiLib = naslUI;
125
- if (requiredIndexes?.length) {
126
- // 过滤出需要的组件
127
- uiLib = naslUI.filter((item, index) => requiredIndexes.includes(`3-${index}`) ||
128
- item.name.endsWith('LinearLayout') ||
129
- item.name.endsWith('Text') ||
130
- item.name.endsWith('Link') ||
131
- item.name.endsWith('Button'));
132
- }
133
- if (codeType === 'detail') {
134
- code = (0, exports.wrapTSBlock)(`${preDeclaration}\n${uiLib
135
- .map((item) => `/**
95
+ const naslUI = uiLib.filter((item, index) => requiredIndexes.includes(`3-${index}`) ||
96
+ item.name.endsWith('LinearLayout') ||
97
+ item.name.endsWith('Text') ||
98
+ item.name.endsWith('Link') ||
99
+ item.name.endsWith('Button'));
100
+ const code = (0, exports.wrapTSBlock)(`${preDeclaration}\n${naslUI.map((item) => `/**
136
101
  * ${item.name}
137
102
  * ${item.title}
138
103
  * ${item.description}
139
104
  */
140
105
  ${item.tsDeclaration}`).join('\n')}`);
141
- }
142
- else {
143
- code += uiLib.map((item, index) => `[3-${index}] ${item.name} | ${item.title} | ${item.description}`).join('\n');
144
- }
145
- return code;
106
+ return { code, naslUI };
146
107
  };
147
- exports.getNaslUICode = getNaslUICode;
108
+ exports.getNaslUI = getNaslUI;
148
109
  const getNaslUIOld = () => {
149
110
  const naslUI = `${(0, naslStdlibMap_1.getNASLStdlibMap)('nasl.ui.ts')}\n`;
150
111
  const code = (0, exports.wrapTSBlock)(naslUI);
@@ -157,114 +118,89 @@ function getNaslOQL() {
157
118
  return { code, naslOql };
158
119
  }
159
120
  exports.getNaslOQL = getNaslOQL;
160
- function getEnums(app, state) {
121
+ function getEnums(app, state, requiredIndexes) {
122
+ const needNamespace = requiredIndexes?.length >= 0;
161
123
  const namespace = 'app.enums';
162
124
  const data = [];
125
+ let code = '';
126
+ code += `declare namespace ${namespace} {\n`;
163
127
  app.enums.forEach((enumeration) => {
164
- const temp = `${enumeration?.toNaturalTS({ ...state, needNamespace: true })}`;
128
+ const temp = `${enumeration?.toNaturalTS({ ...state, needNamespace })}`;
129
+ code += temp;
165
130
  data.push({ description: enumeration?.description || enumeration?.name, code: temp });
166
131
  });
167
- return { namespace, enums: { namespace, data } };
168
- }
169
- exports.getEnums = getEnums;
170
- const getEnumsCode = (enums) => {
171
- let code = '';
172
- code += `declare namespace ${enums?.namespace} {\n`;
173
- enums?.data?.forEach((item) => {
174
- code += item?.description ? `/* ${item.description} */ \n` : '';
175
- code += `${item.code}\n`;
176
- });
177
132
  code += `}\n`;
178
133
  code = (0, exports.wrapTSBlock)(code);
179
- return code;
180
- };
181
- exports.getEnumsCode = getEnumsCode;
182
- function getEntities(app, state) {
134
+ return { code, namespace, enums: { namespace, data } };
135
+ }
136
+ exports.getEnums = getEnums;
137
+ function getEntities(app, state, requiredIndexes) {
138
+ const needNamespace = requiredIndexes?.length >= 0;
183
139
  const entities = [];
140
+ let code = '';
184
141
  app.dataSources.forEach((dataSource) => {
185
142
  const data = [];
186
143
  const namespace = `app.dataSources.${dataSource?.name}.entities`;
144
+ code += `declare namespace ${namespace} {\n`;
187
145
  dataSource.entities
188
146
  .filter((entity) => !entity.name.startsWith('LCAP') || entity.name === 'LCAPUser')
189
147
  .forEach((entity) => {
190
- const entityName = `app.dataSources.${dataSource?.name}.entities.${entity?.name}`;
191
- const tempCode = `${entity?.toNaturalTS({ ...state, needNamespace: true }, entityName)}`;
148
+ const entityName = needNamespace ? `app.dataSources.${dataSource?.name}.entities.${entity?.name}` : undefined;
149
+ const tempCode = `${entity?.toNaturalTS({ ...state, needNamespace }, entityName)}`;
150
+ code += tempCode;
192
151
  data.push({ description: entity?.description || entity?.name, code: tempCode });
193
152
  });
194
153
  entities.push({ namespace, data });
195
- });
196
- return { entities };
197
- }
198
- exports.getEntities = getEntities;
199
- const getEntitiesCode = (entities) => {
200
- let code = '';
201
- entities?.forEach((entity) => {
202
- code += `declare namespace ${entity?.namespace} {\n`;
203
- entity?.data?.forEach((item) => {
204
- code += item?.description ? `/* ${item.description} */ \n` : '';
205
- code += `${item.code}\n`;
206
- });
207
154
  code += `}\n`;
208
155
  });
209
156
  code = (0, exports.wrapTSBlock)(code);
210
- return code;
211
- };
212
- exports.getEntitiesCode = getEntitiesCode;
213
- function getStructures(app, state) {
157
+ return { code, entities };
158
+ }
159
+ exports.getEntities = getEntities;
160
+ function getStructures(app, state, requiredIndexes) {
161
+ const needNamespace = requiredIndexes?.length >= 0;
214
162
  const data = [];
215
163
  const namespace = `app.structures`;
164
+ let code = '';
165
+ code += `declare namespace ${namespace} {\n`;
216
166
  app.structures
217
167
  .filter((entity) => !entity.name.startsWith('LCAP'))
218
168
  .forEach((structure) => {
219
- const tempCode = `${structure?.toNaturalTS({ ...state, needNamespace: true })}`;
169
+ const tempCode = `${structure?.toNaturalTS({ ...state, needNamespace })}`;
170
+ code += tempCode;
220
171
  data.push({ description: structure?.description || structure?.name, code: tempCode });
221
172
  });
222
- return { structures: { namespace, data } };
223
- }
224
- exports.getStructures = getStructures;
225
- const getStructuresCode = (structures) => {
226
- let code = '';
227
- code += `declare namespace ${structures?.namespace} {\n`;
228
- structures?.data?.forEach((item) => {
229
- code += item?.description ? `/* ${item.description} */ \n` : '';
230
- code += `${item.code}\n`;
231
- });
232
173
  code += `}\n`;
233
174
  code = (0, exports.wrapTSBlock)(code);
234
- return code;
235
- };
236
- exports.getStructuresCode = getStructuresCode;
237
- function getLogics(app, currentNode) {
175
+ return { code, structures: { namespace, data } };
176
+ }
177
+ exports.getStructures = getStructures;
178
+ function getLogics(app, currentNode, requiredIndexes) {
179
+ const hasModuleIndexList = requiredIndexes?.length > 0;
238
180
  const data = [];
239
181
  const namespace = `app.logics`;
182
+ let code = '';
240
183
  app?.logics
241
184
  ?.filter((logic) => logic !== currentNode && !logic.name.startsWith('LCAP'))
242
- ?.forEach((logic) => {
243
- const rename = logic?.calleewholeKey;
244
- const tempCode = `${logic?.toNaturalTS({ needNamespace: true, rename, declaration: true })}`;
185
+ ?.forEach((logic, index) => {
186
+ const logicIndex = `6-${index}`;
187
+ if (hasModuleIndexList && !requiredIndexes?.includes(logicIndex))
188
+ return;
189
+ const rename = requiredIndexes?.length >= 0 ? logic?.calleewholeKey : undefined;
190
+ const needNamespace = requiredIndexes?.length >= 0;
191
+ const tempCode = `${logic?.toNaturalTS({ needNamespace, rename, declaration: true })}`;
245
192
  const description = logic?.description || '';
193
+ code += `[${logicIndex}] ${description ? `${description}: ` : ''}\`${tempCode}\`\n`;
246
194
  data.push({ description, code: tempCode });
247
195
  });
248
- return { appLogics: { namespace, data } };
196
+ return { code, appLogics: { namespace, data } };
249
197
  }
250
198
  exports.getLogics = getLogics;
251
- const getLogicsCode = (appLogics, codeType, requiredIndexes) => {
252
- let code = '';
253
- appLogics?.data?.forEach((item, index) => {
254
- const logicIndex = `6-${index}`;
255
- if (requiredIndexes?.length && !requiredIndexes?.includes(logicIndex))
256
- return;
257
- const tempCode = codeType === 'short' ? item.code.replace(`${appLogics.namespace}.`, '') : item.code;
258
- code += `[${logicIndex}] ${item.description ? `${item.description}: ` : ''}\`${tempCode}\`\n`;
259
- });
260
- return code;
261
- };
262
- exports.getLogicsCode = getLogicsCode;
263
- function getModuleInterfaces(modules, state) {
199
+ function getModuleInterfaces(app, state, requiredIndexes) {
200
+ const hasModuleIndexList = requiredIndexes?.length > 0;
264
201
  const interfaceDependencies = [];
265
- modules?.forEach((interfaceDependency) => {
266
- interfaceDependency = new concepts_1.Module(interfaceDependency);
267
- interfaceDependency.parentKey = 'interfaceDependencies';
202
+ let code = '';
203
+ app?.interfaceDependencies?.forEach((interfaceDependency, moduleIndex) => {
268
204
  const name = interfaceDependency?.name;
269
205
  let structures = {};
270
206
  let logics = {};
@@ -278,42 +214,33 @@ function getModuleInterfaces(modules, state) {
278
214
  structures = { namespace: structureNamespace, data: structureData };
279
215
  const logicNamespace = `${namespace}.interfaces`;
280
216
  const logicData = [];
281
- interfaceDependency?.interfaces?.forEach((interface_) => {
217
+ interfaceDependency?.interfaces?.forEach((interface_, index) => {
218
+ const interfaceIndex = `7-${moduleIndex}-${index}`;
219
+ if (hasModuleIndexList && !requiredIndexes?.includes(interfaceIndex))
220
+ return;
282
221
  const description = interface_?.description || '';
283
- const interfaceName = interface_?.calleewholeKey;
284
- const tempCode = interface_?.toNaturalTS((0, translator_1.createCompilerState)('', { needNamespace: true }), interfaceName);
285
- const codeWithDetail = getLogicWithStructuresCode(interface_, 'interface', { description, codeStr: tempCode }, structureNamespace);
286
- logicData.push({ description, code: tempCode, codeWithDetail });
222
+ const interfaceName = requiredIndexes?.length >= 0 ? interface_?.calleewholeKey : undefined;
223
+ const needNamespace = requiredIndexes?.length >= 0;
224
+ const tempCode = interface_?.toNaturalTS((0, translator_1.createCompilerState)('', { needNamespace }), interfaceName);
225
+ logicData.push({ description, code: tempCode });
226
+ if (requiredIndexes?.includes(interfaceIndex)) {
227
+ code += getLogicStructures(interface_, 'interface', { description, codeStr: tempCode }, structureNamespace);
228
+ }
229
+ else {
230
+ code += `[${interfaceIndex}] ${description ? `${description}: ` : ''}\`${tempCode}\`\n`;
231
+ }
287
232
  });
288
233
  logics = { namespace: logicNamespace, data: logicData };
289
234
  interfaceDependencies.push({ name, structures, logics });
290
235
  });
291
- return { interfaceDependencies };
236
+ return { code, interfaceDependencies };
292
237
  }
293
238
  exports.getModuleInterfaces = getModuleInterfaces;
294
- const getModuleInterfacesCode = (interfaceDependencies, codeType, requiredIndexes) => {
295
- let code = '';
296
- interfaceDependencies.forEach((interfaceDependency, index) => {
297
- interfaceDependency?.logics?.data?.forEach((item, idx) => {
298
- const interfaceIndex = `7-${index}-${idx}`;
299
- if (requiredIndexes?.length && !requiredIndexes?.includes(interfaceIndex))
300
- return;
301
- if (codeType === 'short') {
302
- const tempCode = item.code.replace(`${interfaceDependency?.logics.namespace}.`, '');
303
- code += `[${interfaceIndex}] ${item.description ? `${item.description}: ` : ''}\`${tempCode}\`\n`;
304
- }
305
- else {
306
- code += item.codeWithDetail;
307
- }
308
- });
309
- });
310
- return code;
311
- };
312
- exports.getModuleInterfacesCode = getModuleInterfacesCode;
313
- // 连接
314
- function getConnections(modules, state) {
239
+ function getConnectors(app, state, requiredIndexes) {
240
+ const hasModuleIndexList = requiredIndexes?.length > 0;
315
241
  const connections = [];
316
- modules?.forEach((connection) => {
242
+ let code = '';
243
+ app?.connections?.forEach((connection, connectionIndex) => {
317
244
  const name = connection?.name;
318
245
  let structures = {};
319
246
  let logics = {};
@@ -325,110 +252,59 @@ function getConnections(modules, state) {
325
252
  structureData.push({ description: structure?.description || structure?.name, code: tempCode });
326
253
  });
327
254
  structures = { namespace: structureNamespace, data: structureData };
255
+ code += `[8-${connectionIndex}] ${connection?.connector?.title}\n`;
328
256
  const logicData = [];
329
- connection?.connector?.namespaces?.forEach((namespace) => {
330
- const curNameSpace = `${connectionNamespace}.${namespace?.name}`;
331
- namespace?.logics?.forEach((logic) => {
257
+ connection?.connector?.namespaces?.forEach((namespace, namespaceIndex) => {
258
+ namespace?.logics?.forEach((logic, index) => {
259
+ const logicIndex = `8-${connectionIndex}-${namespaceIndex}-${index}`;
260
+ if (hasModuleIndexList && !requiredIndexes?.includes(logicIndex))
261
+ return;
332
262
  const description = `${logic?.description || logic?.title || ''}`;
333
- const rename = `${connection?.name}.${logic?.calleewholeKey}`;
334
- const tempCode = `${logic?.toNaturalTS((0, translator_1.shiftState)(state, '', { needNamespace: true, rename, declaration: true }))}`;
335
- const codeWithDetail = getLogicWithStructuresCode(logic, 'connector', { description, codeStr: tempCode }, structureNamespace);
336
- logicData.push({ description, code: tempCode, codeWithDetail, namespace: curNameSpace });
263
+ const rename = requiredIndexes?.length >= 0 ? `${connection?.name}.${logic?.calleewholeKey}` : undefined;
264
+ const needNamespace = requiredIndexes?.length >= 0;
265
+ const tempCode = `${logic?.toNaturalTS((0, translator_1.shiftState)(state, code, { needNamespace, rename, declaration: true }))}`;
266
+ logicData.push({ description, code: tempCode });
267
+ if (requiredIndexes?.includes(logicIndex)) {
268
+ code += getLogicStructures(logic, 'connector', { description, codeStr: tempCode }, structureNamespace);
269
+ }
270
+ else {
271
+ code += `[${logicIndex}] ${description ? `${description}: ` : ''}\`${tempCode}\`\n`;
272
+ }
337
273
  });
338
274
  });
339
275
  if (!connection?.connector?.namespaces?.length && connection?.connector?.logics?.length) {
340
- connection?.connector?.logics.forEach((logic) => {
276
+ connection?.connector?.logics.forEach((logic, index) => {
277
+ const logicIndex = `8-${connectionIndex}-${index}`;
278
+ if (hasModuleIndexList && !requiredIndexes?.includes(logicIndex))
279
+ return;
341
280
  const description = logic?.description || '';
342
- const rename = `${connection?.name}.${logic?.calleewholeKey}`;
343
- const tempCode = `${logic?.toNaturalTS((0, translator_1.shiftState)(state, '', { needNamespace: true, rename, declaration: true }))}`;
344
- const codeWithDetail = getLogicWithStructuresCode(logic, 'connector', { description, codeStr: tempCode }, structureNamespace);
345
- logicData.push({ description, code: tempCode, codeWithDetail });
281
+ const rename = requiredIndexes?.length >= 0 ? `${connection?.name}.${logic?.calleewholeKey}` : undefined;
282
+ const needNamespace = requiredIndexes?.length >= 0;
283
+ const tempCode = `${logic?.toNaturalTS((0, translator_1.shiftState)(state, code, { needNamespace, rename, declaration: true }))}`;
284
+ logicData.push({ description, code: tempCode });
285
+ if (requiredIndexes?.includes(logicIndex)) {
286
+ code += getLogicStructures(logic, 'connector', { description, codeStr: tempCode }, structureNamespace);
287
+ }
288
+ else {
289
+ code += `[${logicIndex}] ${description ? `${description}: ` : ''}\`${tempCode}\`\n`;
290
+ }
346
291
  });
347
292
  }
348
293
  logics = { namespace: connectionNamespace, data: logicData };
349
294
  connections.push({ name, structures, logics });
350
295
  });
351
- return { connections };
352
- }
353
- exports.getConnections = getConnections;
354
- // 连接器
355
- function getConnectors(modules, state) {
356
- const connectors = [];
357
- modules?.forEach((connector) => {
358
- connector = new concepts_1.Connector(connector);
359
- connector.parentKey = 'connectorDependencies';
360
- const { name } = connector;
361
- let structures = {};
362
- let logics = {};
363
- const connectorNamespace = `${name}.connector.${name}`;
364
- const structureNamespace = `connector.${name}.structures`;
365
- const structureData = [];
366
- connector?.structures?.forEach((structure) => {
367
- const tempCode = `${structure?.toNaturalTS({ ...state, needNamespace: true })}`;
368
- structureData.push({ description: structure?.description || structure?.name, code: tempCode });
369
- });
370
- structures = { namespace: structureNamespace, data: structureData };
371
- const logicData = [];
372
- connector?.namespaces?.forEach((namespace) => {
373
- const curNameSpace = `${connectorNamespace}.${namespace?.name}`;
374
- namespace?.logics?.forEach((logic) => {
375
- const description = `${logic?.description || logic?.title || ''}`;
376
- const rename = `${name}.${logic?.calleewholeKey}`;
377
- const tempCode = `${logic?.toNaturalTS((0, translator_1.shiftState)(state, '', { needNamespace: true, rename, declaration: true }))}`;
378
- const codeWithDetail = getLogicWithStructuresCode(logic, 'connector', { description, codeStr: tempCode }, structureNamespace);
379
- logicData.push({ description, code: tempCode, codeWithDetail, namespace: curNameSpace });
380
- });
381
- });
382
- if (!connector?.namespaces?.length && connector?.logics?.length) {
383
- connector?.logics.forEach((logic) => {
384
- const description = logic?.description || '';
385
- const rename = `${name}.${logic?.calleewholeKey}`;
386
- const tempCode = `${logic?.toNaturalTS((0, translator_1.shiftState)(state, '', { needNamespace: true, rename, declaration: true }))}`;
387
- const codeWithDetail = getLogicWithStructuresCode(logic, 'connector', { description, codeStr: tempCode }, structureNamespace);
388
- logicData.push({ description, code: tempCode, codeWithDetail });
389
- });
390
- }
391
- logics = { namespace: connectorNamespace, data: logicData };
392
- connectors.push({ name, structures, logics });
393
- });
394
- return { connectors };
296
+ return { code, connections };
395
297
  }
396
298
  exports.getConnectors = getConnectors;
397
- const getConnectorsCode = (connections, codeType, requiredIndexes) => {
398
- let code = '';
399
- connections.forEach((connection, index) => {
400
- connection?.logics?.data?.forEach((item, idx) => {
401
- const interfaceIndex = `8-${index}-${idx}`;
402
- if (requiredIndexes?.length && !requiredIndexes?.includes(interfaceIndex))
403
- return;
404
- if (codeType === 'short') {
405
- const namespace = item?.namespace || connection?.logics.namespace;
406
- const tempCode = item.code.replace(`${namespace}.`, '');
407
- code += `[${interfaceIndex}] ${item.description ? `${item.description}: ` : ''}\`${tempCode}\`\n`;
408
- }
409
- else {
410
- code += item.codeWithDetail;
411
- }
412
- });
413
- });
414
- return code;
415
- };
416
- exports.getConnectorsCode = getConnectorsCode;
417
- function getDependencies(modules, state, logicType, frontendType) {
299
+ function getDependencies(app, state, requiredIndexes) {
300
+ const hasModuleIndexList = requiredIndexes?.length > 0;
418
301
  const dependencies = [];
419
- modules?.forEach((module) => {
420
- module = new concepts_1.Module(module);
421
- module.parentKey = 'dependencies';
422
- // 根据类型获取对应的逻辑
423
- let curLogics = module?.logics;
424
- if (logicType !== 'global_logic' && frontendType) {
425
- module?.frontends?.forEach((frontend) => {
426
- if (frontend.type === frontendType) {
427
- curLogics = curLogics.concat([...frontend?.logics]);
428
- }
429
- });
430
- }
431
- if (curLogics?.length) {
302
+ let code = '';
303
+ app?.dependencies
304
+ ?.filter((dependency) => dependency.concept === 'Module')
305
+ ?.forEach((module, moduleIndex) => {
306
+ // 区分一下扩展组件和依赖库
307
+ if (module?.logics?.length) {
432
308
  const name = module?.name;
433
309
  let structures = {};
434
310
  let logics = {};
@@ -436,46 +312,35 @@ function getDependencies(modules, state, logicType, frontendType) {
436
312
  const structureNamespace = `${namespace}.structures`;
437
313
  const structureData = [];
438
314
  module?.structures?.forEach((structure) => {
439
- const tempCode = structure?.toNaturalTS ? `${structure?.toNaturalTS({ ...state, needNamespace: true })}` : '';
315
+ const tempCode = `${structure?.toNaturalTS({ ...state, needNamespace: true })}`;
440
316
  structureData.push({ description: structure?.description || structure?.name, code: tempCode });
441
317
  });
442
318
  structures = { namespace: structureNamespace, data: structureData };
443
- let logicsNamespace = '';
319
+ const logicsNamespace = `${namespace}.logics`;
444
320
  const logicData = [];
445
- curLogics?.forEach((logic) => {
321
+ module?.logics?.forEach((logic, index) => {
322
+ const logicIndex = `9-${moduleIndex}-${index}`;
323
+ if (hasModuleIndexList && !requiredIndexes?.includes(logicIndex))
324
+ return;
446
325
  const description = logic?.description || '';
447
- const rename = logic?.calleewholeKey;
448
- logicsNamespace = logic?.calleewholeKey.replace(`.${logic.name}`, '');
449
- const tempCode = `${logic?.toNaturalTS((0, translator_1.shiftState)(state, '', { needNamespace: true, rename, declaration: true }))}`;
450
- const codeWithDetail = getLogicWithStructuresCode(logic, 'extension', { description, codeStr: tempCode }, structureNamespace);
451
- logicData.push({ description, code: tempCode, codeWithDetail });
326
+ const rename = requiredIndexes?.length >= 0 ? logic?.calleewholeKey : undefined;
327
+ const needNamespace = requiredIndexes?.length >= 0;
328
+ const tempCode = `${logic?.toNaturalTS((0, translator_1.shiftState)(state, code, { needNamespace, rename, declaration: true }))}`;
329
+ logicData.push({ description, code: tempCode });
330
+ if (requiredIndexes?.includes(logicIndex)) {
331
+ code += getLogicStructures(logic, 'extension', { description, codeStr: tempCode }, structureNamespace);
332
+ }
333
+ else {
334
+ code += `[${logicIndex}] ${description ? `${description}: ` : ''}\`${tempCode}\`\n`;
335
+ }
452
336
  });
453
337
  logics = { namespace: logicsNamespace, data: logicData };
454
338
  dependencies.push({ name, structures, logics });
455
339
  }
456
340
  });
457
- return { dependencies };
341
+ return { code, dependencies };
458
342
  }
459
343
  exports.getDependencies = getDependencies;
460
- const getDependenciesCode = (dependencies, codeType, requiredIndexes) => {
461
- let code = '';
462
- dependencies.forEach((dependency, index) => {
463
- dependency?.logics?.data?.forEach((item, idx) => {
464
- const logicIndex = `9-${index}-${idx}`;
465
- if (requiredIndexes?.length && !requiredIndexes?.includes(logicIndex))
466
- return;
467
- if (codeType === 'short') {
468
- const tempCode = item.code.replace(`${dependency?.logics.namespace}.`, '');
469
- code += `[${logicIndex}] ${item.description ? `${item.description}: ` : ''}\`${tempCode}\`\n`;
470
- }
471
- else {
472
- code += item.codeWithDetail;
473
- }
474
- });
475
- });
476
- return code;
477
- };
478
- exports.getDependenciesCode = getDependenciesCode;
479
344
  function getFrontendVariables(frontend, state) {
480
345
  let code = '';
481
346
  frontend?.variables?.forEach((variable) => {
@@ -531,17 +396,7 @@ function getFrontendViews(frontend, state, currentNode, convertChildren) {
531
396
  return { code: (0, exports.wrapTSBlock)(code), views: { namespace, data } };
532
397
  }
533
398
  exports.getFrontendViews = getFrontendViews;
534
- const getFrontendViewsCode = (views) => {
535
- let code = '';
536
- views?.data?.forEach((item) => {
537
- code += `/* ${item.description} */ \n`;
538
- code += item.code;
539
- code += `\n`;
540
- });
541
- return (0, exports.wrapTSBlock)(code);
542
- };
543
- exports.getFrontendViewsCode = getFrontendViewsCode;
544
- function getCurrentNodeContext(currentNode, focusedNodePath) {
399
+ function getCurrentNodeContext(currentNode, focusedNodePath, experimental) {
545
400
  let code = '';
546
401
  let view;
547
402
  if (currentNode?.concept === 'View') {
@@ -568,14 +423,20 @@ function getCurrentNodeContext(currentNode, focusedNodePath) {
568
423
  needNamespace: true,
569
424
  }), function (state) {
570
425
  let code = '';
571
- code += `\n${(0, translator_1.indent)(state.tabSize + 1)}const $refs = {\n`;
572
- // 生成所有的name和类型定义
573
- this.elements.forEach((element) => {
574
- code += element.toNaturalTSDefinition((0, translator_1.shiftState)(state, code, {
575
- tabSize: state.tabSize + 1,
576
- }));
577
- });
578
- code += `${(0, translator_1.indent)(state.tabSize + 1)}}\n`;
426
+ code += `\n${(0, translator_1.indent)(state.tabSize)}`;
427
+ if (experimental) {
428
+ code += this.elements[0].toNaturalTS((0, translator_1.shiftState)(state, code, { tabSize: state.tabSize + 1 }));
429
+ }
430
+ else {
431
+ code += `const $refs = {\n`;
432
+ // 生成所有的name和类型定义
433
+ this.elements.forEach((element) => {
434
+ code += element.toNaturalTSDefinition((0, translator_1.shiftState)(state, code, {
435
+ tabSize: state.tabSize + 1,
436
+ }));
437
+ });
438
+ code += `${(0, translator_1.indent)(state.tabSize + 1)}}\n`;
439
+ }
579
440
  // 逻辑
580
441
  if (currentNode?.concept === 'Logic') {
581
442
  code += '\n';