@lcap/nasl-concepts 4.0.0-beta.9 → 4.0.0-creator.1

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 (180) hide show
  1. package/out/common/BaseNode.d.ts +1 -1
  2. package/out/common/BaseNode.d.ts.map +1 -1
  3. package/out/common/BaseNode.js +9 -3
  4. package/out/common/BaseNode.js.map +1 -1
  5. package/out/concepts/App__.js +4 -4
  6. package/out/concepts/App__.js.map +1 -1
  7. package/out/concepts/BackendVariable__.d.ts.map +1 -1
  8. package/out/concepts/BackendVariable__.js +0 -22
  9. package/out/concepts/BackendVariable__.js.map +1 -1
  10. package/out/concepts/BatchAssignment__.d.ts.map +1 -1
  11. package/out/concepts/BatchAssignment__.js +5 -15
  12. package/out/concepts/BatchAssignment__.js.map +1 -1
  13. package/out/concepts/BinaryExpression__.js +1 -1
  14. package/out/concepts/BinaryExpression__.js.map +1 -1
  15. package/out/concepts/BindAttribute__.d.ts +1 -0
  16. package/out/concepts/BindAttribute__.d.ts.map +1 -1
  17. package/out/concepts/BindAttribute__.js +67 -9
  18. package/out/concepts/BindAttribute__.js.map +1 -1
  19. package/out/concepts/BindDirective__.d.ts +1 -0
  20. package/out/concepts/BindDirective__.d.ts.map +1 -1
  21. package/out/concepts/BindDirective__.js +26 -5
  22. package/out/concepts/BindDirective__.js.map +1 -1
  23. package/out/concepts/BindEvent__.d.ts +8 -2
  24. package/out/concepts/BindEvent__.d.ts.map +1 -1
  25. package/out/concepts/BindEvent__.js +61 -8
  26. package/out/concepts/BindEvent__.js.map +1 -1
  27. package/out/concepts/BindStyle__.d.ts +1 -0
  28. package/out/concepts/BindStyle__.d.ts.map +1 -1
  29. package/out/concepts/BindStyle__.js +10 -0
  30. package/out/concepts/BindStyle__.js.map +1 -1
  31. package/out/concepts/BusinessComponent__.d.ts +1 -0
  32. package/out/concepts/BusinessComponent__.d.ts.map +1 -1
  33. package/out/concepts/BusinessComponent__.js +5 -13
  34. package/out/concepts/BusinessComponent__.js.map +1 -1
  35. package/out/concepts/CallFunction__.d.ts +1 -1
  36. package/out/concepts/CallFunction__.js +2 -2
  37. package/out/concepts/CallFunction__.js.map +1 -1
  38. package/out/concepts/CallInterface__.d.ts.map +1 -1
  39. package/out/concepts/CallInterface__.js +12 -4
  40. package/out/concepts/CallInterface__.js.map +1 -1
  41. package/out/concepts/CallLogic__.d.ts.map +1 -1
  42. package/out/concepts/CallLogic__.js +38 -30
  43. package/out/concepts/CallLogic__.js.map +1 -1
  44. package/out/concepts/CallQueryComponent__.d.ts.map +1 -1
  45. package/out/concepts/CallQueryComponent__.js +4 -2
  46. package/out/concepts/CallQueryComponent__.js.map +1 -1
  47. package/out/concepts/Connector__.d.ts.map +1 -1
  48. package/out/concepts/Connector__.js.map +1 -1
  49. package/out/concepts/Destination__.js +5 -5
  50. package/out/concepts/Destination__.js.map +1 -1
  51. package/out/concepts/End__.d.ts.map +1 -1
  52. package/out/concepts/End__.js +32 -30
  53. package/out/concepts/End__.js.map +1 -1
  54. package/out/concepts/Enum__.d.ts +1 -1
  55. package/out/concepts/Enum__.d.ts.map +1 -1
  56. package/out/concepts/Enum__.js +17 -16
  57. package/out/concepts/Enum__.js.map +1 -1
  58. package/out/concepts/Frontend__.d.ts.map +1 -1
  59. package/out/concepts/Frontend__.js +19 -11
  60. package/out/concepts/Frontend__.js.map +1 -1
  61. package/out/concepts/Identifier__.d.ts +2 -2
  62. package/out/concepts/Identifier__.d.ts.map +1 -1
  63. package/out/concepts/Identifier__.js +25 -26
  64. package/out/concepts/Identifier__.js.map +1 -1
  65. package/out/concepts/IfStatement__.js +2 -2
  66. package/out/concepts/IfStatement__.js.map +1 -1
  67. package/out/concepts/Interface__.d.ts +1 -1
  68. package/out/concepts/Interface__.d.ts.map +1 -1
  69. package/out/concepts/Interface__.js +14 -12
  70. package/out/concepts/Interface__.js.map +1 -1
  71. package/out/concepts/Logic__.d.ts +1 -1
  72. package/out/concepts/Logic__.d.ts.map +1 -1
  73. package/out/concepts/Logic__.js +20 -20
  74. package/out/concepts/Logic__.js.map +1 -1
  75. package/out/concepts/MatchCase__.js +1 -1
  76. package/out/concepts/MatchCase__.js.map +1 -1
  77. package/out/concepts/MemberExpression__.d.ts.map +1 -1
  78. package/out/concepts/MemberExpression__.js +7 -3
  79. package/out/concepts/MemberExpression__.js.map +1 -1
  80. package/out/concepts/MetadataType__.js +1 -1
  81. package/out/concepts/MetadataType__.js.map +1 -1
  82. package/out/concepts/NewComposite__.d.ts.map +1 -1
  83. package/out/concepts/NewComposite__.js +5 -15
  84. package/out/concepts/NewComposite__.js.map +1 -1
  85. package/out/concepts/OverriddenLogic__.d.ts +1 -1
  86. package/out/concepts/OverriddenLogic__.d.ts.map +1 -1
  87. package/out/concepts/Param__.d.ts +2 -2
  88. package/out/concepts/Param__.d.ts.map +1 -1
  89. package/out/concepts/Param__.js +18 -25
  90. package/out/concepts/Param__.js.map +1 -1
  91. package/out/concepts/ProcessV2__.js +2 -2
  92. package/out/concepts/ProcessV2__.js.map +1 -1
  93. package/out/concepts/QuerySelectExpression__.js +1 -1
  94. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  95. package/out/concepts/Return__.d.ts +1 -1
  96. package/out/concepts/Return__.d.ts.map +1 -1
  97. package/out/concepts/Return__.js +11 -22
  98. package/out/concepts/Return__.js.map +1 -1
  99. package/out/concepts/StringLiteral__.d.ts.map +1 -1
  100. package/out/concepts/StringLiteral__.js +4 -12
  101. package/out/concepts/StringLiteral__.js.map +1 -1
  102. package/out/concepts/StructureProperty__.d.ts +4 -4
  103. package/out/concepts/StructureProperty__.d.ts.map +1 -1
  104. package/out/concepts/StructureProperty__.js +14 -14
  105. package/out/concepts/StructureProperty__.js.map +1 -1
  106. package/out/concepts/Structure__.d.ts +1 -1
  107. package/out/concepts/Structure__.d.ts.map +1 -1
  108. package/out/concepts/Structure__.js +11 -11
  109. package/out/concepts/Structure__.js.map +1 -1
  110. package/out/concepts/SwitchCase__.js +1 -1
  111. package/out/concepts/SwitchCase__.js.map +1 -1
  112. package/out/concepts/TypeAnnotation__.d.ts +8 -7
  113. package/out/concepts/TypeAnnotation__.d.ts.map +1 -1
  114. package/out/concepts/TypeAnnotation__.js +90 -65
  115. package/out/concepts/TypeAnnotation__.js.map +1 -1
  116. package/out/concepts/TypeParam__.d.ts +1 -1
  117. package/out/concepts/TypeParam__.d.ts.map +1 -1
  118. package/out/concepts/TypeParam__.js +11 -11
  119. package/out/concepts/TypeParam__.js.map +1 -1
  120. package/out/concepts/Variable__.d.ts +1 -1
  121. package/out/concepts/Variable__.d.ts.map +1 -1
  122. package/out/concepts/Variable__.js +11 -22
  123. package/out/concepts/Variable__.js.map +1 -1
  124. package/out/concepts/ViewElement__.d.ts +3 -0
  125. package/out/concepts/ViewElement__.d.ts.map +1 -1
  126. package/out/concepts/ViewElement__.js +118 -4
  127. package/out/concepts/ViewElement__.js.map +1 -1
  128. package/out/concepts/View__.d.ts +18 -1
  129. package/out/concepts/View__.d.ts.map +1 -1
  130. package/out/concepts/View__.js +170 -60
  131. package/out/concepts/View__.js.map +1 -1
  132. package/out/concepts/basics/index.d.ts +1 -1
  133. package/out/concepts/basics/index.d.ts.map +1 -1
  134. package/out/concepts/basics/index.js +2 -1
  135. package/out/concepts/basics/index.js.map +1 -1
  136. package/out/concepts/basics/stdlib/nasl.processV2.d.ts +1 -0
  137. package/out/concepts/basics/stdlib/nasl.processV2.d.ts.map +1 -1
  138. package/out/concepts/basics/stdlib/nasl.processV2.js +7 -1
  139. package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
  140. package/out/concepts/basics/stdlib/sqlFunctions.json +5797 -0
  141. package/out/index.d.ts +1 -1
  142. package/out/index.d.ts.map +1 -1
  143. package/out/index.js +2 -1
  144. package/out/index.js.map +1 -1
  145. package/out/semantics/localVarCollector.d.ts +2 -1
  146. package/out/semantics/localVarCollector.d.ts.map +1 -1
  147. package/out/semantics/localVarCollector.js +11 -1
  148. package/out/semantics/localVarCollector.js.map +1 -1
  149. package/out/semantics/semanticData.d.ts +4 -2
  150. package/out/semantics/semanticData.d.ts.map +1 -1
  151. package/out/semantics/semanticData.js +33 -16
  152. package/out/semantics/semanticData.js.map +1 -1
  153. package/out/service/genSlotVarRef.d.ts +2 -3
  154. package/out/service/genSlotVarRef.d.ts.map +1 -1
  155. package/out/service/genSlotVarRef.js +76 -20
  156. package/out/service/genSlotVarRef.js.map +1 -1
  157. package/out/service/getMemberIdentifier.d.ts +1 -1
  158. package/out/service/getMemberIdentifier.d.ts.map +1 -1
  159. package/out/service/getMemberIdentifier.js +26 -14
  160. package/out/service/getMemberIdentifier.js.map +1 -1
  161. package/out/service/getSqlFunction.d.ts +63 -0
  162. package/out/service/getSqlFunction.d.ts.map +1 -0
  163. package/out/service/getSqlFunction.js +35 -0
  164. package/out/service/getSqlFunction.js.map +1 -0
  165. package/out/service/index.d.ts +1 -0
  166. package/out/service/index.d.ts.map +1 -1
  167. package/out/service/index.js +1 -0
  168. package/out/service/index.js.map +1 -1
  169. package/out/utils/bak-translator/composition.d.ts.map +1 -1
  170. package/out/utils/bak-translator/composition.js +60 -33
  171. package/out/utils/bak-translator/composition.js.map +1 -1
  172. package/out/utils/bak-translator/legacy.d.ts +9 -1
  173. package/out/utils/bak-translator/legacy.d.ts.map +1 -1
  174. package/out/utils/bak-translator/legacy.js +140 -30
  175. package/out/utils/bak-translator/legacy.js.map +1 -1
  176. package/out/utils/constant.d.ts +1 -0
  177. package/out/utils/constant.d.ts.map +1 -1
  178. package/out/utils/constant.js +8 -1
  179. package/out/utils/constant.js.map +1 -1
  180. package/package.json +7 -6
@@ -1618,7 +1618,7 @@ let ViewElement = class ViewElement extends Annotatable__1.default {
1618
1618
  code += event.toNaturalTS((0, nasl_translator_1.shiftState)(state, code, {
1619
1619
  tabSize: state.tabSize + 1,
1620
1620
  }));
1621
- code += ',\n';
1621
+ code += '\n';
1622
1622
  });
1623
1623
  if (this.children.find((item) => item.tag === 'template' && item.slotTarget)) {
1624
1624
  const defaultArr = [];
@@ -1668,6 +1668,99 @@ let ViewElement = class ViewElement extends Annotatable__1.default {
1668
1668
  code += `${(0, nasl_translator_1.indent)(state.tabSize)}})`;
1669
1669
  return code;
1670
1670
  }
1671
+ toNaturalTSX(state = (0, nasl_translator_1.createCompilerState)(), parentLevel) {
1672
+ let code = '';
1673
+ const tagName = (0, utils_2.kebab2Camel)(this.tag);
1674
+ code += `<${tagName} ref="${this.name}"`;
1675
+ this.bindDirectives.forEach((directive) => {
1676
+ const subCode = directive.toNaturalTSX((0, nasl_translator_1.shiftState)(state, code, {
1677
+ tabSize: state.tabSize + 1,
1678
+ inline: false,
1679
+ }));
1680
+ if (subCode.trim())
1681
+ code += '\n' + subCode;
1682
+ });
1683
+ this.bindAttrs.forEach((attr) => {
1684
+ const subCode = attr.toNaturalTSX((0, nasl_translator_1.shiftState)(state, code, {
1685
+ tabSize: state.tabSize + 1,
1686
+ inline: false,
1687
+ }));
1688
+ if (subCode.trim())
1689
+ code += '\n' + subCode;
1690
+ });
1691
+ this.bindStyles.forEach((style) => {
1692
+ const subCode = style.toNaturalTSX((0, nasl_translator_1.shiftState)(state, code, {
1693
+ tabSize: state.tabSize + 1,
1694
+ inline: false,
1695
+ }));
1696
+ if (subCode.trim())
1697
+ code += '\n' + subCode;
1698
+ });
1699
+ this.bindEvents.forEach((event) => {
1700
+ code += '\n' + event.toNaturalTSX((0, nasl_translator_1.shiftState)(state, code, {
1701
+ tabSize: state.tabSize + 1,
1702
+ inline: false,
1703
+ }));
1704
+ });
1705
+ if (this.staticStyle) {
1706
+ code += `\n${(0, nasl_translator_1.indent)(state.tabSize + 1)}style="${this.staticStyle}"`;
1707
+ }
1708
+ const defaultArr = [];
1709
+ if (this.children.find((item) => item.tag === 'template' && item.slotTarget)) {
1710
+ // 先把插槽翻译了
1711
+ this.children.forEach((element) => {
1712
+ if (element.tag === 'template' && !(element.slotTarget === 'default' && !element.slotScope)) {
1713
+ if (element.children.length) {
1714
+ code += '\n' + `${(0, nasl_translator_1.indent)(state.tabSize + 1)}slot${utils.firstUpperCase((0, utils_2.kebab2Camel)(element.slotTarget || ''))}={(${element.slotScope || ''}) => `;
1715
+ if (element.children.length === 1) {
1716
+ code += typeof element.children[0]?.toNaturalTSX === 'function' ? element.children[0].toNaturalTSX((0, nasl_translator_1.shiftState)(state, code, {
1717
+ tabSize: state.tabSize + 1,
1718
+ inline: true,
1719
+ })) : '';
1720
+ }
1721
+ else { // 为多个元素
1722
+ code += `<>\n`;
1723
+ element.children.forEach((element) => {
1724
+ code += typeof element?.toNaturalTSX === 'function' ? element.toNaturalTSX((0, nasl_translator_1.shiftState)(state, code, {
1725
+ tabSize: state.tabSize + 2,
1726
+ inline: false,
1727
+ })) : '';
1728
+ code += '\n';
1729
+ });
1730
+ code += `${(0, nasl_translator_1.indent)(state.tabSize + 1)}</>`;
1731
+ }
1732
+ code += `}`;
1733
+ }
1734
+ }
1735
+ else if (element.tag === 'template' && element.slotTarget === 'default') {
1736
+ defaultArr.push(...element.children);
1737
+ }
1738
+ else {
1739
+ defaultArr.push(element);
1740
+ }
1741
+ });
1742
+ }
1743
+ else {
1744
+ defaultArr.push(...this.children);
1745
+ }
1746
+ // 翻译其余的子集
1747
+ const umodalSpecialCase = ['u-modal', 'UModal'].includes(this.tag) && this.children.find((item) => item.tag === 'template' && item.slotTarget == 'body');
1748
+ if (defaultArr.length && !umodalSpecialCase) {
1749
+ code += '>\n';
1750
+ defaultArr.forEach((element) => {
1751
+ code += typeof element?.toNaturalTSX === 'function' ? element?.toNaturalTSX((0, nasl_translator_1.shiftState)(state, code, {
1752
+ tabSize: state.tabSize + 1,
1753
+ inline: false,
1754
+ })) : '';
1755
+ code += '\n';
1756
+ });
1757
+ code += (0, nasl_translator_1.indent)(state.tabSize) + `</${tagName}>`;
1758
+ }
1759
+ else {
1760
+ code += ' />';
1761
+ }
1762
+ return code;
1763
+ }
1671
1764
  toTextualNASL(state = (0, nasl_translator_1.createCompilerState)(), parentLevel) {
1672
1765
  let code = '';
1673
1766
  code += (0, nasl_translator_1.createDecoratorCode)(state, this, ['name']);
@@ -2407,7 +2500,16 @@ let ViewElement = class ViewElement extends Annotatable__1.default {
2407
2500
  .map((element) => {
2408
2501
  const childOptions = Object.assign({}, newOptions);
2409
2502
  childOptions.indentLevel++;
2410
- return (shouldIndent ? '\n' + insideTabString : '') + element?.toVue(childOptions);
2503
+ let elementCode = '';
2504
+ // 如果当前子节点需要拆成组件,则返回组件标签,不进行 toVue 模板代码翻译
2505
+ if (options?.autoSplitComponent && this.view.viewSplitComponentInfos) {
2506
+ const item = this.view.viewSplitComponentInfos.find((item) => item.nodePath === element.nodePath);
2507
+ if (item) {
2508
+ elementCode = `<${item.templateCompName} />`;
2509
+ }
2510
+ }
2511
+ elementCode = elementCode || element?.toVue(childOptions);
2512
+ return (shouldIndent ? '\n' + insideTabString : '') + elementCode;
2411
2513
  })
2412
2514
  .join('');
2413
2515
  if (newOptions.aslIdAttr) {
@@ -2808,8 +2910,17 @@ let ViewElement = class ViewElement extends Annotatable__1.default {
2808
2910
  content +
2809
2911
  (shouldIndent ? '\n' + tabString : '') +
2810
2912
  `</${tag}>`;
2811
- if (!content.trim() && selfClosingTag.includes(tag)) {
2812
- htmlContent = `<${tag}${partsString.length ? partsString : ''} />`;
2913
+ const frameworkKind = this.frontend?.frameworkKind;
2914
+ // 处理没有内容的标签
2915
+ if (!content.trim()) {
2916
+ // 支持自闭合标签
2917
+ if (selfClosingTag.includes(tag)) {
2918
+ return `<${tag}${partsString.length ? partsString : ''} />`;
2919
+ }
2920
+ // Vue3 template标签
2921
+ if (frameworkKind === 'vue3' && tag === 'template') {
2922
+ return '';
2923
+ }
2813
2924
  }
2814
2925
  return htmlContent;
2815
2926
  }
@@ -3191,6 +3302,9 @@ __decorate([
3191
3302
  __decorate([
3192
3303
  (0, nasl_translator_1.withSourceMap)()
3193
3304
  ], ViewElement.prototype, "toNaturalTS", null);
3305
+ __decorate([
3306
+ (0, nasl_translator_1.withSourceMap)()
3307
+ ], ViewElement.prototype, "toNaturalTSX", null);
3194
3308
  __decorate([
3195
3309
  (0, nasl_translator_1.withSourceMap)()
3196
3310
  ], ViewElement.prototype, "toTextualNASL", null);