@lcap/nasl 3.5.0-beta.4 → 3.6.0-alpha.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 (238) hide show
  1. package/out/bak/translator.js +39 -119
  2. package/out/bak/translator.js.map +1 -1
  3. package/out/breakpoint/generator/BreakpointNode.d.ts +0 -3
  4. package/out/breakpoint/generator/BreakpointNode.js +0 -9
  5. package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
  6. package/out/breakpoint/shared/constants.js +0 -1
  7. package/out/breakpoint/shared/constants.js.map +1 -1
  8. package/out/breakpoint/shared/utils.js +7 -31
  9. package/out/breakpoint/shared/utils.js.map +1 -1
  10. package/out/common/BaseNode.d.ts +13 -1
  11. package/out/common/BaseNode.js +52 -23
  12. package/out/common/BaseNode.js.map +1 -1
  13. package/out/common/Command.js +1 -0
  14. package/out/common/Command.js.map +1 -1
  15. package/out/common/EventEmitter.d.ts +1 -1
  16. package/out/common/EventEmitter.js +0 -4
  17. package/out/common/EventEmitter.js.map +1 -1
  18. package/out/concepts/App__.d.ts +76 -51
  19. package/out/concepts/App__.js +190 -87
  20. package/out/concepts/App__.js.map +1 -1
  21. package/out/concepts/BackendVariable__.js +2 -10
  22. package/out/concepts/BackendVariable__.js.map +1 -1
  23. package/out/concepts/BindAttribute__.js +6 -16
  24. package/out/concepts/BindAttribute__.js.map +1 -1
  25. package/out/concepts/BindDirective__.d.ts +0 -1
  26. package/out/concepts/BindDirective__.js +4 -19
  27. package/out/concepts/BindDirective__.js.map +1 -1
  28. package/out/concepts/BindEvent__.d.ts +1 -3
  29. package/out/concepts/BindEvent__.js +13 -38
  30. package/out/concepts/BindEvent__.js.map +1 -1
  31. package/out/concepts/CallFunction__.js +2 -10
  32. package/out/concepts/CallFunction__.js.map +1 -1
  33. package/out/concepts/CallLogic__.d.ts +0 -2
  34. package/out/concepts/CallLogic__.js +27 -38
  35. package/out/concepts/CallLogic__.js.map +1 -1
  36. package/out/concepts/Constant__.js +6 -7
  37. package/out/concepts/Constant__.js.map +1 -1
  38. package/out/concepts/Destination__.d.ts +1 -1
  39. package/out/concepts/Destination__.js +4 -6
  40. package/out/concepts/Destination__.js.map +1 -1
  41. package/out/concepts/End__.js +1 -2
  42. package/out/concepts/End__.js.map +1 -1
  43. package/out/concepts/Entity__.d.ts +1 -1
  44. package/out/concepts/Entity__.js +2 -0
  45. package/out/concepts/Entity__.js.map +1 -1
  46. package/out/concepts/Event__.d.ts +0 -14
  47. package/out/concepts/Event__.js +0 -61
  48. package/out/concepts/Event__.js.map +1 -1
  49. package/out/concepts/Frontend__.d.ts +88 -0
  50. package/out/concepts/Frontend__.js +143 -1
  51. package/out/concepts/Frontend__.js.map +1 -1
  52. package/out/concepts/Identifier__.d.ts +0 -5
  53. package/out/concepts/Identifier__.js +9 -19
  54. package/out/concepts/Identifier__.js.map +1 -1
  55. package/out/concepts/LogicItem__.d.ts +1 -1
  56. package/out/concepts/LogicItem__.js.map +1 -1
  57. package/out/concepts/Logic__.d.ts +1 -3
  58. package/out/concepts/Logic__.js +13 -16
  59. package/out/concepts/Logic__.js.map +1 -1
  60. package/out/concepts/MemberExpression__.d.ts +1 -1
  61. package/out/concepts/MemberExpression__.js +3 -3
  62. package/out/concepts/MemberExpression__.js.map +1 -1
  63. package/out/concepts/NewComposite__.js.map +1 -1
  64. package/out/concepts/Param__.js +3 -11
  65. package/out/concepts/Param__.js.map +1 -1
  66. package/out/concepts/ProcessElement__.js +1 -9
  67. package/out/concepts/ProcessElement__.js.map +1 -1
  68. package/out/concepts/Return__.js +9 -17
  69. package/out/concepts/Return__.js.map +1 -1
  70. package/out/concepts/Variable__.js +8 -17
  71. package/out/concepts/Variable__.js.map +1 -1
  72. package/out/concepts/ViewElement__.d.ts +2 -17
  73. package/out/concepts/ViewElement__.js +31 -143
  74. package/out/concepts/ViewElement__.js.map +1 -1
  75. package/out/concepts/View__.js +6 -6
  76. package/out/concepts/View__.js.map +1 -1
  77. package/out/concepts/index__.d.ts +0 -5
  78. package/out/concepts/index__.js +0 -5
  79. package/out/concepts/index__.js.map +1 -1
  80. package/out/concepts/utils/asserts.d.ts +3 -258
  81. package/out/concepts/utils/asserts.js +13 -351
  82. package/out/concepts/utils/asserts.js.map +1 -1
  83. package/out/concepts/utils/types.d.ts +3 -20
  84. package/out/generator/genBundleFiles.js +11 -25
  85. package/out/generator/genBundleFiles.js.map +1 -1
  86. package/out/generator/genReleaseBody.js +3 -12
  87. package/out/generator/genReleaseBody.js.map +1 -1
  88. package/out/generator/permission.js +3 -3
  89. package/out/generator/permission.js.map +1 -1
  90. package/out/natural/transformTSCode.js +1 -1
  91. package/out/natural/transformTSCode.js.map +1 -1
  92. package/out/server/extendBaseNode.js +22 -6
  93. package/out/server/extendBaseNode.js.map +1 -1
  94. package/out/server/getLogics.js +27 -62
  95. package/out/server/getLogics.js.map +1 -1
  96. package/out/server/getMemberIdentifier.js +1 -6
  97. package/out/server/getMemberIdentifier.js.map +1 -1
  98. package/out/server/naslServer.js +11 -28
  99. package/out/server/naslServer.js.map +1 -1
  100. package/out/server/translator.js +1 -6
  101. package/out/server/translator.js.map +1 -1
  102. package/out/service/storage/init.js +26 -2
  103. package/out/service/storage/init.js.map +1 -1
  104. package/out/templator/genCreateBlock.js +6 -6
  105. package/out/templator/genCreateBlock.js.map +1 -1
  106. package/out/templator/genCurdEditMultipleKeyBlock.js +16 -16
  107. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  108. package/out/templator/genCurdMultipleKeyBlock.d.ts +27 -0
  109. package/out/templator/genCurdMultipleKeyBlock.js +709 -37
  110. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  111. package/out/templator/genGetBlock.js +4 -4
  112. package/out/templator/genGetBlock.js.map +1 -1
  113. package/out/templator/genGridViewBlock.js +12 -12
  114. package/out/templator/genGridViewBlock.js.map +1 -1
  115. package/out/templator/genListViewBlock.js +4 -4
  116. package/out/templator/genListViewBlock.js.map +1 -1
  117. package/out/templator/genSelectBlock.js +3 -3
  118. package/out/templator/genSelectBlock.js.map +1 -1
  119. package/out/templator/genTableBlock.d.ts +2 -0
  120. package/out/templator/genTableBlock.js +124 -11
  121. package/out/templator/genTableBlock.js.map +1 -1
  122. package/out/templator/genUpdateBlock.js +8 -8
  123. package/out/templator/genUpdateBlock.js.map +1 -1
  124. package/out/templator/utils.d.ts +2 -2
  125. package/out/templator/utils.js.map +1 -1
  126. package/out/translator/utils.js +18 -0
  127. package/out/translator/utils.js.map +1 -1
  128. package/out/utils/i18nInfo.js +2 -7
  129. package/out/utils/i18nInfo.js.map +1 -1
  130. package/package.json +2 -2
  131. package/src/bak/translator.js +43 -121
  132. package/src/breakpoint/generator/BreakpointNode.ts +0 -12
  133. package/src/breakpoint/shared/constants.ts +0 -1
  134. package/src/breakpoint/shared/utils.ts +10 -37
  135. package/src/common/BaseNode.ts +60 -22
  136. package/src/common/Command.ts +1 -0
  137. package/src/common/EventEmitter.ts +1 -6
  138. package/src/concepts/App__.ts +251 -139
  139. package/src/concepts/BackendVariable__.ts +2 -10
  140. package/src/concepts/BindAttribute__.ts +6 -15
  141. package/src/concepts/BindDirective__.ts +4 -19
  142. package/src/concepts/BindEvent__.ts +12 -40
  143. package/src/concepts/CallFunction__.ts +2 -10
  144. package/src/concepts/CallLogic__.ts +32 -45
  145. package/src/concepts/Constant__.ts +7 -5
  146. package/src/concepts/Destination__.ts +4 -6
  147. package/src/concepts/End__.ts +0 -1
  148. package/src/concepts/Entity__.ts +3 -1
  149. package/src/concepts/Event__.ts +0 -70
  150. package/src/concepts/Frontend__.ts +251 -3
  151. package/src/concepts/Identifier__.ts +13 -29
  152. package/src/concepts/LogicItem__.ts +0 -1
  153. package/src/concepts/Logic__.ts +14 -21
  154. package/src/concepts/MemberExpression__.ts +3 -3
  155. package/src/concepts/NewComposite__.ts +6 -4
  156. package/src/concepts/Param__.ts +3 -11
  157. package/src/concepts/ProcessElement__.ts +1 -8
  158. package/src/concepts/Return__.ts +12 -15
  159. package/src/concepts/Variable__.ts +9 -17
  160. package/src/concepts/ViewElement__.ts +54 -166
  161. package/src/concepts/View__.ts +6 -8
  162. package/src/concepts/index__.ts +0 -5
  163. package/src/concepts/utils/asserts.ts +4 -367
  164. package/src/concepts/utils/types.ts +0 -28
  165. package/src/generator/genBundleFiles.ts +15 -33
  166. package/src/generator/genReleaseBody.ts +3 -14
  167. package/src/generator/permission.ts +6 -8
  168. package/src/natural/transformTSCode.ts +1 -1
  169. package/src/server/extendBaseNode.ts +41 -22
  170. package/src/server/getLogics.ts +41 -79
  171. package/src/server/getMemberIdentifier.ts +1 -7
  172. package/src/server/naslServer.ts +12 -30
  173. package/src/server/translator.ts +1 -7
  174. package/src/service/storage/init.ts +33 -2
  175. package/src/templator/genCreateBlock.ts +6 -6
  176. package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -16
  177. package/src/templator/genCurdMultipleKeyBlock.ts +817 -93
  178. package/src/templator/genGetBlock.ts +4 -4
  179. package/src/templator/genGridViewBlock.ts +12 -12
  180. package/src/templator/genListViewBlock.ts +4 -4
  181. package/src/templator/genSelectBlock.ts +3 -3
  182. package/src/templator/genTableBlock.ts +137 -12
  183. package/src/templator/genUpdateBlock.ts +8 -8
  184. package/src/templator/utils.ts +2 -2
  185. package/src/translator/utils.ts +20 -0
  186. package/src/utils/i18nInfo.ts +2 -7
  187. package/test/concepts/call-function/fixtures/from-string.json +59 -68
  188. package/test/concepts/call-function/fixtures/to-string-global-tz.json +58 -67
  189. package/test/concepts/call-function/fixtures/to-string-no-tz.json +48 -57
  190. package/test/concepts/call-function/fixtures/to-string-user-tz.json +60 -69
  191. package/test/concepts/call-function/fixtures/to-string-utc-tz.json +60 -69
  192. package/test/concepts/call-interface/fixtures/only-interface.json +72 -81
  193. package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +214 -223
  194. package/test/concepts/call-interface/fixtures/with-body-no-argument.json +76 -85
  195. package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +91 -100
  196. package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +79 -88
  197. package/test/concepts/call-interface/fixtures/with-headers.json +81 -90
  198. package/test/concepts/call-interface/fixtures/with-query-no-argument.json +79 -88
  199. package/test/concepts/call-interface/fixtures/with-query.json +81 -90
  200. package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +2 -4
  201. package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +95 -104
  202. package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +200 -209
  203. package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +88 -97
  204. package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +115 -124
  205. package/test/concepts/call-logic/fixtures/json-deserialize.json +111 -120
  206. package/test/concepts/call-logic/fixtures/json-serialize-with-string.json +115 -124
  207. package/test/concepts/call-logic/fixtures/json-serialize.json +115 -124
  208. package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +82 -91
  209. package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +79 -88
  210. package/test/concepts/call-logic/fixtures/view-component-with-validation.json +135 -144
  211. package/test/concepts/identifier/fixtures/view-variable.json +136 -145
  212. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +1 -1
  213. package/test/concepts/view-element/fixtures/default-login.json +212 -221
  214. package/test/concepts/view-element/fixtures/default-not-found.json +174 -183
  215. package/test/concepts/view-element/fixtures/with-role-auth.json +82 -91
  216. package/test/concepts/view-element/fixtures/with-table.json +1834 -1843
  217. package/test/concepts/view-element/toVue.spec.ts +0 -1
  218. package/ts-worker/package.json +1 -1
  219. package/out/concepts/BusinessComponent__.d.ts +0 -641
  220. package/out/concepts/BusinessComponent__.js +0 -1901
  221. package/out/concepts/BusinessComponent__.js.map +0 -1
  222. package/out/concepts/BusinessLogic__.d.ts +0 -38
  223. package/out/concepts/BusinessLogic__.js +0 -358
  224. package/out/concepts/BusinessLogic__.js.map +0 -1
  225. package/out/concepts/CallEvent__.d.ts +0 -97
  226. package/out/concepts/CallEvent__.js +0 -263
  227. package/out/concepts/CallEvent__.js.map +0 -1
  228. package/out/concepts/FrontendType__.d.ts +0 -308
  229. package/out/concepts/FrontendType__.js +0 -605
  230. package/out/concepts/FrontendType__.js.map +0 -1
  231. package/out/concepts/ParamWithGroup__.d.ts +0 -39
  232. package/out/concepts/ParamWithGroup__.js +0 -85
  233. package/out/concepts/ParamWithGroup__.js.map +0 -1
  234. package/src/concepts/BusinessComponent__.ts +0 -2669
  235. package/src/concepts/BusinessLogic__.ts +0 -376
  236. package/src/concepts/CallEvent__.ts +0 -334
  237. package/src/concepts/FrontendType__.ts +0 -919
  238. package/src/concepts/ParamWithGroup__.ts +0 -101
@@ -342,20 +342,12 @@ export class Variable extends BaseNode {
342
342
  toJS(state?: TranslatorState): string {
343
343
  const context = this.view ? 'this' : 'Vue.prototype';
344
344
  const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
345
- let { sortedTypeKey, typeKind, typeName, typeNamespace } = typeAnnotation || {};
346
- if (typeNamespace?.endsWith('.metadataTypes')) {
347
- const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
348
- const typeAn = referenceNode.typeAnnotation || {};
349
- sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
350
- typeKind = typeAn.typeKind;
351
- typeName = typeAn.typeName;
352
- }
353
345
  const needGenInitFromSchema =
354
346
  typeAnnotation &&
355
- (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
347
+ (!['primitive', 'union'].includes(typeAnnotation.typeKind) || typeAnnotation.typeName === 'DateTime');
356
348
  let code = `${this.name} = `;
357
349
  if (needGenInitFromSchema) {
358
- code += `${context}.$genInitFromSchema('${sortedTypeKey}',`;
350
+ code += `${context}.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}',`;
359
351
  }
360
352
 
361
353
  if (this.defaultValue?.expression) {
@@ -465,9 +457,7 @@ export class Variable extends BaseNode {
465
457
  * @param name 一般不用传,用于 rename
466
458
  */
467
459
  getEmbeddedFilePath(name = this.name) {
468
- return `/embedded/${this.getAncestor('App')?.name}/frontendTypes/${
469
- this.getAncestor('FrontendType')?.name
470
- }/frontends/${this.getAncestor('Frontend')?.name}/variables/${name}.ts`;
460
+ return `/embedded/${this.app.name}/frontends/${this.parentNode.name}/variables/${name}.ts`;
471
461
  }
472
462
 
473
463
  *toEmbeddedTSFile(): EmbeddedTSFileGenerator {
@@ -500,13 +490,15 @@ export class Variable extends BaseNode {
500
490
  }
501
491
  if (this.typeAnnotation) {
502
492
  code += `: `;
503
- if (this.defaultValue?.expression) {
493
+ if (
494
+ this.defaultValue?.expression &&
495
+ !(this.typeAnnotation && ['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(typeKey))
496
+ ) {
497
+ code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
498
+ } else {
504
499
  if (['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(typeKey)) {
505
500
  code += yield* this.defaultValue.toEmbeddedTS(shiftState(state, code), true);
506
- } else {
507
- code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
508
501
  }
509
- } else {
510
502
  code += 'undefined';
511
503
  }
512
504
  code += ' as ';
@@ -21,8 +21,6 @@ import { config } from '../config';
21
21
  import type MemberExpression from './MemberExpression__';
22
22
  import type Identifier from './Identifier__';
23
23
  import { PAGE_COMPONENT_INCLUDE_TAG_MAP } from './View__';
24
- import type BusinessComponent from './BusinessComponent__';
25
- import type FrontendType from './FrontendType__';
26
24
 
27
25
  import { kebab2Camel } from '../utils';
28
26
  export interface ParseContext {
@@ -74,8 +72,6 @@ function genArgumentMemberExpression(arr: string[]) {
74
72
  return expressionNode;
75
73
  }
76
74
  export interface ElementToVueOptions {
77
- isRoot?: boolean;
78
- asCompontent?: boolean;
79
75
  indentStyle?: 'space' | 'tab';
80
76
  tabSize?: number;
81
77
  indentLevel?: number;
@@ -90,6 +86,7 @@ export interface ElementToVueOptions {
90
86
  bindStylesFormat?: (bindStyles: BindStyle[], element?: ViewElement, defaultResult?: string) => string | false;
91
87
  finalCode?: boolean;
92
88
  currentList?: string[];
89
+ isDev?: boolean;
93
90
  }
94
91
 
95
92
  function transAstNodeToNaslNode(astNode: any, namespace?: string): any {
@@ -267,6 +264,14 @@ function transAstNodeToNaslTypeNode(astNode: any, namespace?: string): any {
267
264
  }
268
265
  return node;
269
266
  }
267
+
268
+ function isLockField(node?:any):boolean {
269
+ if (!node || node.concept !== 'ViewElement') return false;
270
+ const attr = node?.bindAttrs?.find((attr: any) => ['FormDesignerLocked','TableDesignerLocked'].includes(attr.name))?.value
271
+ if (attr === undefined) return !!isLockField(node?.parentNode);
272
+ else return !!attr
273
+ }
274
+
270
275
  //================================================================================
271
276
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
272
277
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -1546,10 +1551,6 @@ export class ViewElement extends BaseNode {
1546
1551
  // 自动生成的代码已结束。下面可以手动编写。
1547
1552
  //================================================================================
1548
1553
 
1549
- get likeComponent(): View | BusinessComponent {
1550
- return this.view || (this?.getAncestor('BusinessComponent') as BusinessComponent);
1551
- }
1552
-
1553
1554
  /* 主页面有没有权限 */
1554
1555
  get parentAuth() {
1555
1556
  const _nameSpace = this.view.getNamespace();
@@ -1576,11 +1577,11 @@ export class ViewElement extends BaseNode {
1576
1577
  }
1577
1578
 
1578
1579
  getViewElementUniqueName(name = 'viewElement1') {
1579
- return this.likeComponent?.getViewElementUniqueName(name);
1580
+ return this.view?.getViewElementUniqueName(name);
1580
1581
  }
1581
1582
 
1582
1583
  getViewElementUniqueNameOld(name = 'viewElement1') {
1583
- return this.likeComponent?.getViewElementUniqueNameOld(name);
1584
+ return this.view?.getViewElementUniqueNameOld(name);
1584
1585
  }
1585
1586
 
1586
1587
  public static readonly TAG_NAME_PREFIX_REG?: RegExp = /^([lieu]|van)[-_]/;
@@ -1626,16 +1627,16 @@ export class ViewElement extends BaseNode {
1626
1627
  const self = this;
1627
1628
  let code = '';
1628
1629
  code += indent((state?.tabSize || 0) + 1);
1629
- if (self.isCorrespondingBusinessComponent) {
1630
- code += `${self.name}: ${self.correspondingBusinessComponentNamespace}.${self.tag.replace('bs-', '')};\n`;
1631
- } else if (self.toHump(self.tag) === 'lcapLogin' || self.staticClass === 'login-form') { // 登录组件不翻译
1630
+ // 登录组件不翻译
1631
+ if (self.toHump(self.tag) === 'lcapLogin' || self.staticClass === 'login-form') {
1632
1632
  code += `${self.name}: nasl.ui.div<any>;\n`;
1633
1633
  } else if (self.tag === 'u-table-view-column-dynamic') {
1634
1634
  code += `${self.name}: nasl.ui.${self.toHump(self.tag)}<any, any>;\n`;
1635
1635
  } else if (Object.keys(PAGE_COMPONENT_INCLUDE_TAG_MAP).includes(self.tag)) {
1636
1636
  if (self.bindAttrs?.findIndex((attr) => attr.name === 'data-source') > -1) {
1637
- code += `${self.name}: nasl.ui.${self.toHump(self.tag)}<__elements_completionProperty['${self.name
1638
- }']['dataSource']>;\n`;
1637
+ code += `${self.name}: nasl.ui.${self.toHump(self.tag)}<__elements_completionProperty['${
1638
+ self.name
1639
+ }']['dataSource']>;\n`;
1639
1640
  } else {
1640
1641
  code += `${self.name}: nasl.ui.${self.toHump(self.tag)}<any>;\n`;
1641
1642
  }
@@ -1721,8 +1722,9 @@ export class ViewElement extends BaseNode {
1721
1722
  const _this = self.parentNode;
1722
1723
  let genericity = '';
1723
1724
  if (_this.tag === 'u-table-view-column-dynamic') {
1724
- genericity += `<${(_this.parentNode as any).__tsVariableDataSourceTypeName}, ${(_this as any).__tsVariableDataSourceTypeName
1725
- }>`;
1725
+ genericity += `<${(_this.parentNode as any).__tsVariableDataSourceTypeName}, ${
1726
+ (_this as any).__tsVariableDataSourceTypeName
1727
+ }>`;
1726
1728
  } else {
1727
1729
  let targetNode: any = _this;
1728
1730
  while (!targetNode.__tsVariableDataSourceTypeName && asserts.isViewElement(targetNode?.parentNode)) {
@@ -1864,39 +1866,10 @@ export class ViewElement extends BaseNode {
1864
1866
  code += indent((state?.tabSize || 0) + 2);
1865
1867
  return code;
1866
1868
  }
1867
-
1868
- // 获取端类型
1869
- get frontendType() {
1870
- return this.getAncestor('FrontendType') as FrontendType;
1871
- }
1872
-
1873
- // 对应业务组件
1874
- get isCorrespondingBusinessComponent() {
1875
- return this.tag.startsWith('bs-');
1876
- }
1877
-
1878
- // 对应的业务组件的Namespace
1879
- get correspondingBusinessComponentNamespace() {
1880
- return `${this.frontendType?.getNamespace()}.${this.frontendType?.name}.businessComponents`;
1881
- }
1882
-
1883
- // 获取对应的业务组件
1884
- get correspondingBusinessComponent() {
1885
- if (this.isCorrespondingBusinessComponent) {
1886
- // 端下的业务组件
1887
- const businessComponents = this.frontendType?.businessComponents;
1888
- const businessComponent = businessComponents.find((businessComponent) => {
1889
- return `bs-${businessComponent?.name}` === this.tag;
1890
- });
1891
- return businessComponent;
1892
- }
1893
- }
1894
-
1895
-
1896
1869
  @withSourceMapGenerator
1897
1870
  *toEmbeddedTS(state = createCompilerState(), parentLevel?: number): TranslatorGenerator {
1898
1871
  const self = this;
1899
- const { parentNode, app, tag, staticClass, name, bindRoles, bindEvents, children } = self;
1872
+ const { parentNode, app, tag, staticClass, name, bindDirectives, bindRoles, bindEvents, children } = self;
1900
1873
  const chineseTsName = (name: string) => {
1901
1874
  let tsName = name;
1902
1875
  // 匹配所有特殊字符都转为_
@@ -1972,12 +1945,8 @@ export class ViewElement extends BaseNode {
1972
1945
  code += '},\n';
1973
1946
  return code;
1974
1947
  }
1975
- let namespace = `nasl.ui.${self.toHump(tag)}`;
1976
- if (self.isCorrespondingBusinessComponent) {
1977
- namespace = `${self.correspondingBusinessComponentNamespace}.${self.tag.replace('bs-', '')}`;
1978
- }
1979
1948
  // 后面那个name是为了查找引用的时候用的
1980
- let code = `new ${namespace}${self.getTypeArgmentsStr(state)}({name: __elements.${name},\n`;
1949
+ let code = `new nasl.ui.${self.toHump(tag)}${self.getTypeArgmentsStr(state)}({name: __elements.${name},\n`;
1981
1950
  // 是否开启权限
1982
1951
  // const hasAuth = Array.isArray(bindDirectives)
1983
1952
  // ? !!bindDirectives.filter((directive) => directive.name === 'auth').length
@@ -2009,18 +1978,8 @@ export class ViewElement extends BaseNode {
2009
1978
  if (Array.isArray(children)) {
2010
1979
  code += indent((state?.tabSize || 0) + 1);
2011
1980
  if (Array.isArray(self.bindAttrs)) {
2012
- code += `bindAttr: `;
2013
- if (self.isCorrespondingBusinessComponent) {
2014
- code += `{\n`;
2015
- } else {
2016
- code += `() => [\n`;
2017
- }
1981
+ code += `bindAttr: () => [\n`;
2018
1982
  yield* wrapForEach(self.bindAttrs, function* warpForEachGenerator(attr) {
2019
- // 过滤自由布局的key
2020
- const shouldFilter = self.isCorrespondingBusinessComponent && !(name === 'key' && !attr.expression);
2021
- if (shouldFilter) {
2022
- return;
2023
- }
2024
1983
  code += (yield* attr.toEmbeddedTS(shiftState(state, code, { tabSize: 1 }))) + ',\n';
2025
1984
  });
2026
1985
  yield* wrapForEach(self.bindDirectives, function* warpForEachGenerator(directive) {
@@ -2029,12 +1988,7 @@ export class ViewElement extends BaseNode {
2029
1988
  yield* wrapForEach(self.bindStyles, function* warpForEachGenerator(bindStyle) {
2030
1989
  code += (yield* bindStyle.toEmbeddedTS(shiftState(state, code, { tabSize: 1 }))) + ',\n';
2031
1990
  });
2032
- code += indent((state?.tabSize || 0) + 2)
2033
- if (self.isCorrespondingBusinessComponent) {
2034
- code += '},\n';
2035
- } else {
2036
- code += '],\n';
2037
- }
1991
+ code += indent((state?.tabSize || 0) + 2) + '],\n';
2038
1992
  }
2039
1993
  // 如果子集中有插槽的就
2040
1994
  if (children.find((item) => item.tag === 'template' && item.slotTarget)) {
@@ -2095,7 +2049,7 @@ export class ViewElement extends BaseNode {
2095
2049
  }
2096
2050
  code += indent(state?.tabSize || 0) + '})';
2097
2051
  // 顶层元素是单独的表达式
2098
- if (parentNode.concept === 'View' || asserts.isBusinessComponent(parentNode)) {
2052
+ if (parentNode.concept === 'View') {
2099
2053
  code += ';\n';
2100
2054
  } else {
2101
2055
  code += ',\n';
@@ -2208,20 +2162,10 @@ export class ViewElement extends BaseNode {
2208
2162
  { mode: 'anyObject', excludedKeySet: element.JSON_EXCLUDED_KEYS },
2209
2163
  );
2210
2164
 
2211
- this.likeComponent?.existingViewElement.clear();
2165
+ this.view.existingViewElement.clear();
2212
2166
  return element;
2213
2167
  }
2214
2168
 
2215
- setTag(tag: string) {
2216
- const object = {
2217
- tag,
2218
- };
2219
- this.update({
2220
- ...object,
2221
-
2222
- });
2223
- }
2224
-
2225
2169
  // 递归遍历组件
2226
2170
  public traverseChildren(cb: (ele: ViewElement) => void): void {
2227
2171
  utils.traverse(
@@ -2280,7 +2224,7 @@ export class ViewElement extends BaseNode {
2280
2224
  expression: transAstNodeToNaslNode(Object.assign({}, argument)),
2281
2225
  }));
2282
2226
  }
2283
- } catch (error) { }
2227
+ } catch (error) {}
2284
2228
 
2285
2229
  return {
2286
2230
  concept: 'ValidationRule',
@@ -2575,10 +2519,8 @@ export class ViewElement extends BaseNode {
2575
2519
  * 转换成设计器中使用的 Vue 文件
2576
2520
  * @param options
2577
2521
  */
2578
- toDesignerVue(options?: { isRoot: boolean; asCompontent?: boolean }) {
2522
+ toDesignerVue() {
2579
2523
  return this.toVue({
2580
- isRoot: options?.isRoot,
2581
- asCompontent: options?.asCompontent,
2582
2524
  finalCode: false,
2583
2525
  nodePathAttr: true,
2584
2526
  attrFormat: (attr: BindAttribute | BindEvent | BindDirective, element?: ViewElement, defaultResult?: string) => {
@@ -2637,6 +2579,10 @@ export class ViewElement extends BaseNode {
2637
2579
  .replace(/\$global./g, 'nasl.')
2638
2580
  .replace(/\bscope\.item\.\b/g, '')
2639
2581
  .replace(/\bcurrent\.item\.\b/g, '');
2582
+
2583
+ if (isLockField(element)) {
2584
+ return element.tag === 'u-text' ? `${name}="--"` : `${name}=""`
2585
+ }
2640
2586
  return `${name}="{{ ${value} }}"`;
2641
2587
  });
2642
2588
  else return defaultResult;
@@ -2705,19 +2651,16 @@ export class ViewElement extends BaseNode {
2705
2651
 
2706
2652
  return parts;
2707
2653
  },
2654
+ isDev: true,
2708
2655
  });
2709
2656
  }
2710
2657
 
2711
- isLikeComponent(node: types.SyntaxNode) {
2712
- return ['View', 'BusinessComponent'].includes(node?.concept);
2713
- }
2714
-
2715
2658
  // 获取currentList
2716
2659
  getCurrentList() {
2717
2660
  const argsList: string[] = [];
2718
2661
  let parent = this.parentNode;
2719
2662
  let index = 0;
2720
- while (parent && !this.isLikeComponent(parent)) {
2663
+ while (parent && parent.concept !== 'View') {
2721
2664
  if ((parent as ViewElement).slotScope) {
2722
2665
  argsList.push(index === 0 ? 'current' : 'current' + index);
2723
2666
  index++;
@@ -2757,73 +2700,16 @@ export class ViewElement extends BaseNode {
2757
2700
  return null;
2758
2701
  }
2759
2702
 
2760
- get businessComponent() {
2761
- return this.getAncestor('BusinessComponent');
2762
- }
2763
-
2764
2703
  /**
2765
2704
  * 转换成 Vue 的模板格式
2766
2705
  */
2767
2706
  toVue(options?: ElementToVueOptions) {
2768
- const { finalCode, asCompontent } = options || {};
2769
- const parts: string[] = [];
2770
- if (finalCode === false) {
2771
- if (this.tag === 'slot') {
2772
- if (asCompontent) {
2773
- return `<div vusion-slot-name="${this.name}">
2774
- <slot name="${this.name}">
2775
- <div s-empty="true" style="background: #f7f8fa;
2776
- border: 1px dashed #c3c3c3;
2777
- text-align: center;
2778
- color: #999;
2779
- min-height: 32px;
2780
- min-width: 32px;
2781
- width: 100%;
2782
- align-items: center;
2783
- display: inline-flex;
2784
- justify-content: center;">
2785
- +
2786
- </div>
2787
- </slot>
2788
- </div>`;
2789
- } else {
2790
- return `<div vusion-node-path="${this.nodePath}"
2791
- style="background: linear-gradient(-45deg,#fff 25%,#f3f5fa 0,#f3f5fa 50%,#fff 0,#fff 75%,#f3f5fa 0);
2792
- background-size: 45px 45px;
2793
- background-repeat: repeat;
2794
- line-height: 32px;
2795
- min-height: 32px;
2796
- color: var(--font-second-color);
2797
- text-align: center;">
2798
- 组件占位,可在使用业务组件时插入任意组件
2799
- </div>`;
2800
- }
2801
- } else if (this.businessComponent?.name === this.tag) {
2802
- // 组件内部使用自身的情况
2803
- return `<div vusion-node-path="${this.nodePath}"
2804
- style="background: linear-gradient(-45deg,#fff 25%,#f3f5fa 0,#f3f5fa 50%,#fff 0,#fff 75%,#f3f5fa 0);
2805
- background-size: 45px 45px;
2806
- background-repeat: repeat;
2807
- line-height: 32px;
2808
- min-height: 32px;
2809
- color: var(--font-second-color);
2810
- text-align: center;">
2811
- 在组件内部使用自身可能会导致循环引用,请谨慎使用
2812
- </div>`;
2813
- }
2814
- const isRoot = options.isRoot;
2815
- if (isRoot && !options?.asCompontent) {
2816
- parts.push('type="root"');
2817
- if (this.frontendType?.kind === 'h5') {
2818
- parts.push('class="l-root-h5"');
2819
- } else {
2820
- parts.push('style="height:100%; --custom-start: auto; min-height: 200px;"');
2821
- }
2822
- }
2823
- }
2824
- if (options) {
2825
- options.isRoot = false;
2707
+
2708
+ // lockField 不翻译modal
2709
+ if (options?.isDev && this?.tag === 'u-modal' && isLockField(this)) {
2710
+ return ``;
2826
2711
  }
2712
+
2827
2713
  let currentList: string[] = [];
2828
2714
  if (Array.isArray(options?.currentList)) {
2829
2715
  currentList = [...options?.currentList];
@@ -2862,15 +2748,16 @@ export class ViewElement extends BaseNode {
2862
2748
  const content: string = !this.children
2863
2749
  ? ''
2864
2750
  : this.children
2865
- .map((element) => {
2866
- const childOptions = Object.assign({}, newOptions);
2867
- childOptions.indentLevel++;
2868
- return (shouldIndent ? '\n' + insideTabString : '') + element?.toVue(childOptions);
2869
- })
2870
- .join('');
2751
+ .map((element) => {
2752
+ const childOptions = Object.assign({}, newOptions);
2753
+ childOptions.indentLevel++;
2754
+ return (shouldIndent ? '\n' + insideTabString : '') + element?.toVue(childOptions);
2755
+ })
2756
+ .join('');
2871
2757
  if (!content.length) {
2872
2758
  shouldIndent = false;
2873
2759
  }
2760
+ const parts: string[] = [];
2874
2761
  if (newOptions.aslIdAttr) {
2875
2762
  if (newOptions.aslIdAttr === true) {
2876
2763
  newOptions.aslIdAttr = 'asl-id';
@@ -2885,9 +2772,9 @@ export class ViewElement extends BaseNode {
2885
2772
  this.slotTarget &&
2886
2773
  parts.push(
2887
2774
  `#${this.slotTarget}` +
2888
- (this.slotScope
2889
- ? `="${currentList.length > 1 ? this.slotScope + (currentList.length - 1) : this.slotScope}"`
2890
- : ''),
2775
+ (this.slotScope
2776
+ ? `="${currentList.length > 1 ? this.slotScope + (currentList.length - 1) : this.slotScope}"`
2777
+ : ''),
2891
2778
  );
2892
2779
  this.refName && parts.push(`:ref="\`${this.refName}\`"`);
2893
2780
  this.keyName && parts.push(`:key="\`${this.keyName}\`"`);
@@ -2933,9 +2820,7 @@ export class ViewElement extends BaseNode {
2933
2820
  ) {
2934
2821
  this.name && parts.push(`key="${this.name}"`);
2935
2822
  }
2936
- if (this.tag === 'slot') {
2937
- this.name && parts.push(`name="${this.name}"`);
2938
- }
2823
+
2939
2824
  let partsLength = 0;
2940
2825
  let partsString = '';
2941
2826
  parts.forEach((part) => {
@@ -2946,6 +2831,8 @@ export class ViewElement extends BaseNode {
2946
2831
  partsString += ' ' + part;
2947
2832
  partsLength += part.length;
2948
2833
  });
2834
+
2835
+
2949
2836
  let htmlContent =
2950
2837
  `<${this.tag}${partsString.length ? partsString : ''}>` +
2951
2838
  content +
@@ -2954,6 +2841,7 @@ export class ViewElement extends BaseNode {
2954
2841
  if (!content.trim() && selfClosingTag.includes(this.tag)) {
2955
2842
  htmlContent = `<${this.tag}${partsString.length ? partsString : ''} />`;
2956
2843
  }
2844
+
2957
2845
  return htmlContent;
2958
2846
  }
2959
2847
 
@@ -2965,7 +2853,7 @@ export class ViewElement extends BaseNode {
2965
2853
  super.delete();
2966
2854
  if (this.parentNode) {
2967
2855
  this.traverseChildren((ele: ViewElement) => {
2968
- (this.likeComponent as any)?.removeExistingViewElement(ele);
2856
+ (this.view as any)?.removeExistingViewElement(ele);
2969
2857
  });
2970
2858
  }
2971
2859
  }
@@ -3003,7 +2891,7 @@ export class ViewElement extends BaseNode {
3003
2891
  let current = 'current';
3004
2892
  let parent = this.parentNode;
3005
2893
  let index = 0;
3006
- while (parent && !this.isLikeComponent(parent)) {
2894
+ while (parent && parent.concept !== 'View') {
3007
2895
  if ((parent as ViewElement).slotScope) {
3008
2896
  index++;
3009
2897
  }
@@ -1552,7 +1552,7 @@ export class View extends BaseNode {
1552
1552
  // @ts-ignore
1553
1553
  const t = this.__v_raw || this;
1554
1554
  // @ts-ignore
1555
- const n = bindEvent.__v_raw || bindEvent;
1555
+ const n = bindEvent?.__v_raw || bindEvent;
1556
1556
  if (Array.isArray((t as any)[parentKey])) {
1557
1557
  // @ts-ignore
1558
1558
  const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
@@ -1560,7 +1560,7 @@ export class View extends BaseNode {
1560
1560
  params.index = index;
1561
1561
  } else {
1562
1562
  const q = (t as any)[parentKey];
1563
- if ((q.__v_raw || q) === n) {
1563
+ if ((q?.__v_raw || q) === n) {
1564
1564
  params.index = 0;
1565
1565
  (this as any)[parentKey] = undefined;
1566
1566
  }
@@ -1690,7 +1690,7 @@ export class View extends BaseNode {
1690
1690
  newName = name.replace(/\d*$/, (m) => `_${BranchCopyUniCode}_${m}`);
1691
1691
  }
1692
1692
  // 主分支无 BranchCopyUniCode
1693
- if (!BranchCopyUniCode && prefix?.at(-1) !== '_') {
1693
+ if (!BranchCopyUniCode && prefix.at(-1) !== '_') {
1694
1694
  newName = name.replace(/\d*$/, (m) => `_${m}`);
1695
1695
  }
1696
1696
  const newPrefix = newName.replace(/\d*$/, '');
@@ -1867,7 +1867,7 @@ export class View extends BaseNode {
1867
1867
  logics: [newLogic],
1868
1868
  },
1869
1869
  this,
1870
- 'bindEvents',
1870
+ 'events',
1871
1871
  );
1872
1872
  this.addBindEvent(event);
1873
1873
  } else {
@@ -1990,7 +1990,7 @@ export class View extends BaseNode {
1990
1990
  .join('\n')}
1991
1991
  }
1992
1992
  }
1993
- };\n`;
1993
+ };`;
1994
1994
  code += keyboardEventMixinCode;
1995
1995
  if (this.script) {
1996
1996
  mixin = this.script.trim().replace(/export default |module\.exports +=/, 'const mixin = ');
@@ -2069,9 +2069,7 @@ export class View extends BaseNode {
2069
2069
  parent = parent.parentNode;
2070
2070
  }
2071
2071
  }
2072
- return `/embedded/${this.getAncestor('App')?.name}/frontendTypes/${
2073
- this.getAncestor('FrontendType')?.name
2074
- }/frontends/${this.getAncestor('Frontend')?.name}/views/${pathName}.ts`;
2072
+ return `/embedded/${this.app.name}/frontends/${this.frontend.name}/views/${pathName}.ts`;
2075
2073
  }
2076
2074
 
2077
2075
  getNamespace(): string {
@@ -1,7 +1,6 @@
1
1
  export * from './App__';
2
2
  export * from './Module__';
3
3
  export * from './Namespace__';
4
- export * from './FrontendType__';
5
4
  export * from './Frontend__';
6
5
  export * from './Backend__';
7
6
  export * from './Integration__';
@@ -25,7 +24,6 @@ export * from './BindDirective__';
25
24
  export * from './BindEvent__';
26
25
  export * from './BindStyle__';
27
26
  export * from './ViewComponent__';
28
- export * from './BusinessComponent__';
29
27
  export * from './Attribute__';
30
28
  export * from './Event__';
31
29
  export * from './Slot__';
@@ -33,12 +31,10 @@ export * from './Theme__';
33
31
  export * from './StaticString__';
34
32
  export * from './Logic__';
35
33
  export * from './AuthLogic__';
36
- export * from './BusinessLogic__';
37
34
  export * from './AuthLogicForCallInterface__';
38
35
  export * from './OverriddenLogic__';
39
36
  export * from './AbstractInterface__';
40
37
  export * from './Param__';
41
- export * from './ParamWithGroup__';
42
38
  export * from './Return__';
43
39
  export * from './Variable__';
44
40
  export * from './BackendVariable__';
@@ -64,7 +60,6 @@ export * from './Assignment__';
64
60
  export * from './BatchAssignment__';
65
61
  export * from './Comment__';
66
62
  export * from './CallLogic__';
67
- export * from './CallEvent__';
68
63
  export * from './CallFunction__';
69
64
  export * from './CallInterface__';
70
65
  export * from './Destination__';