@lcap/nasl 3.5.0-beta.4 → 3.6.0-alpha.2

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 (98) hide show
  1. package/out/breakpoint/shared/utils.js +1 -19
  2. package/out/breakpoint/shared/utils.js.map +1 -1
  3. package/out/breakpoint/store/core.js +1 -1
  4. package/out/breakpoint/store/core.js.map +1 -1
  5. package/out/common/BaseNode.d.ts +9 -0
  6. package/out/common/BaseNode.js +15 -0
  7. package/out/common/BaseNode.js.map +1 -1
  8. package/out/common/Command.js +1 -0
  9. package/out/common/Command.js.map +1 -1
  10. package/out/common/EventEmitter.d.ts +1 -1
  11. package/out/common/EventEmitter.js +0 -4
  12. package/out/common/EventEmitter.js.map +1 -1
  13. package/out/concepts/AnonymousFunction__.d.ts +6 -1
  14. package/out/concepts/AnonymousFunction__.js +34 -16
  15. package/out/concepts/AnonymousFunction__.js.map +1 -1
  16. package/out/concepts/App__.d.ts +29 -0
  17. package/out/concepts/App__.js +120 -21
  18. package/out/concepts/App__.js.map +1 -1
  19. package/out/concepts/BindAttribute__.js.map +1 -1
  20. package/out/concepts/BindEvent__.js +2 -2
  21. package/out/concepts/BindEvent__.js.map +1 -1
  22. package/out/concepts/BusinessComponent__.d.ts +1 -1
  23. package/out/concepts/BusinessComponent__.js +107 -87
  24. package/out/concepts/BusinessComponent__.js.map +1 -1
  25. package/out/concepts/CallEvent__.d.ts +4 -0
  26. package/out/concepts/CallEvent__.js +18 -1
  27. package/out/concepts/CallEvent__.js.map +1 -1
  28. package/out/concepts/CallFunction__.d.ts +0 -1
  29. package/out/concepts/CallFunction__.js +0 -8
  30. package/out/concepts/CallFunction__.js.map +1 -1
  31. package/out/concepts/Destination__.js +3 -3
  32. package/out/concepts/Destination__.js.map +1 -1
  33. package/out/concepts/Entity__.d.ts +1 -1
  34. package/out/concepts/Entity__.js +2 -0
  35. package/out/concepts/Entity__.js.map +1 -1
  36. package/out/concepts/Logic__.js +15 -8
  37. package/out/concepts/Logic__.js.map +1 -1
  38. package/out/concepts/Match__.d.ts +1 -1
  39. package/out/concepts/ValidationRule__.js +2 -1
  40. package/out/concepts/ValidationRule__.js.map +1 -1
  41. package/out/concepts/ViewElement__.d.ts +1 -0
  42. package/out/concepts/ViewElement__.js +20 -3
  43. package/out/concepts/ViewElement__.js.map +1 -1
  44. package/out/concepts/View__.js +19 -18
  45. package/out/concepts/View__.js.map +1 -1
  46. package/out/server/extendBaseNode.js +18 -0
  47. package/out/server/extendBaseNode.js.map +1 -1
  48. package/out/server/getProcesses.js +3 -3
  49. package/out/server/getProcesses.js.map +1 -1
  50. package/out/server/naslServer.js +16 -12
  51. package/out/server/naslServer.js.map +1 -1
  52. package/out/service/storage/init.js +24 -1
  53. package/out/service/storage/init.js.map +1 -1
  54. package/out/templator/genCurdMultipleKeyBlock.d.ts +27 -0
  55. package/out/templator/genCurdMultipleKeyBlock.js +673 -1
  56. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  57. package/out/templator/genGetBlock.js +2 -1
  58. package/out/templator/genGetBlock.js.map +1 -1
  59. package/out/templator/genTableBlock.d.ts +2 -0
  60. package/out/templator/genTableBlock.js +114 -1
  61. package/out/templator/genTableBlock.js.map +1 -1
  62. package/out/templator/genUpdateBlock.js +2 -1
  63. package/out/templator/genUpdateBlock.js.map +1 -1
  64. package/out/translator/utils.js +30 -1
  65. package/out/translator/utils.js.map +1 -1
  66. package/out/utils/index.d.ts +17 -0
  67. package/out/utils/index.js +184 -1
  68. package/out/utils/index.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/breakpoint/shared/utils.ts +2 -24
  71. package/src/breakpoint/store/core.ts +1 -1
  72. package/src/common/BaseNode.ts +19 -0
  73. package/src/common/Command.ts +1 -0
  74. package/src/common/EventEmitter.ts +1 -6
  75. package/src/concepts/AnonymousFunction__.ts +36 -18
  76. package/src/concepts/App__.ts +132 -21
  77. package/src/concepts/BindAttribute__.ts +0 -1
  78. package/src/concepts/BindEvent__.ts +2 -2
  79. package/src/concepts/BusinessComponent__.ts +122 -98
  80. package/src/concepts/CallEvent__.ts +19 -2
  81. package/src/concepts/CallFunction__.ts +0 -11
  82. package/src/concepts/Destination__.ts +3 -3
  83. package/src/concepts/Entity__.ts +3 -1
  84. package/src/concepts/Logic__.ts +15 -9
  85. package/src/concepts/ValidationRule__.ts +6 -1
  86. package/src/concepts/ViewElement__.ts +26 -3
  87. package/src/concepts/View__.ts +19 -18
  88. package/src/server/extendBaseNode.ts +21 -0
  89. package/src/server/getProcesses.ts +3 -3
  90. package/src/server/naslServer.ts +17 -11
  91. package/src/service/storage/init.ts +31 -1
  92. package/src/templator/genCurdMultipleKeyBlock.ts +781 -57
  93. package/src/templator/genGetBlock.ts +2 -1
  94. package/src/templator/genTableBlock.ts +127 -2
  95. package/src/templator/genUpdateBlock.ts +2 -1
  96. package/src/translator/utils.ts +32 -1
  97. package/src/utils/index.ts +211 -1
  98. package/ts-worker/src/index.js +1 -0
@@ -1035,10 +1035,6 @@ export class BusinessComponent extends BaseNode {
1035
1035
  return node;
1036
1036
  }
1037
1037
 
1038
- getLogicExistingNames(excludedList: Array<BusinessLogic> = []) {
1039
- const excludedSet = new Set(excludedList);
1040
- return ((this.logics as BusinessLogic[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item?.name);
1041
- }
1042
1038
  getLogicUniqueName(name = 'logic1') {
1043
1039
  return utils.unique(name, this.getLogicExistingNames(), undefined, false);
1044
1040
  }
@@ -1675,6 +1671,28 @@ export class BusinessComponent extends BaseNode {
1675
1671
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1676
1672
  // 自动生成的代码已结束。下面可以手动编写。
1677
1673
  //================================================================================
1674
+ getLogicExistingNames(excludedList: Array<Logic> = []) {
1675
+ const excludedSet = new Set(excludedList);
1676
+ const varList: any[] = [];
1677
+ if (Array.isArray(this.params)) {
1678
+ varList.push(...this.params);
1679
+ }
1680
+ if (Array.isArray(this.variables)) {
1681
+ varList.push(...this.variables);
1682
+ }
1683
+ if (Array.isArray(this.logics)) {
1684
+ varList.push(...this.logics);
1685
+ }
1686
+ if (Array.isArray(this.bindEvents)) {
1687
+ this.bindEvents.forEach((bindEvent) => {
1688
+ if (Array.isArray(bindEvent.logics)) {
1689
+ varList.push(...bindEvent.logics);
1690
+ }
1691
+ });
1692
+ }
1693
+ return varList.filter((item) => !excludedSet.has(item)).map((item) => item.name);
1694
+ }
1695
+
1678
1696
  static getDefaultOptions() {
1679
1697
  return {
1680
1698
  title: '业务组件',
@@ -2242,100 +2260,12 @@ export class BusinessComponent extends BaseNode {
2242
2260
  // 获取虚拟logic的参数和内容
2243
2261
  // 用作展示和tots查找引用
2244
2262
  self.getElementLogicRoot();
2245
- let code = `export class ${self.tsName} extends nasl.ui.VueComponent {\n`;
2246
- // 需要类型推导的局部变量/返回值需要调整申明顺序
2247
- code += `constructor(
2248
- options?: {
2249
- [propname: string]: any,
2250
- bindAttr?: {
2251
- __NASLIF?: nasl.core.Boolean,
2252
- `;
2253
- if (Array.isArray(self.params)) {
2254
- yield* wrapForEach(self.params, function* warpForEachGenerator(param, index) {
2255
- code += `${param.name}?: `;
2256
- code += yield* param.typeAnnotation.toEmbeddedTS(shiftState(state, code));
2257
- code += ',\n';
2258
- });
2259
- }
2260
- code += `
2261
- },
2262
- slotDefault?: () => Array<any>,
2263
- }) {
2264
- super();\n`;
2265
-
2266
- // 绑定事件
2267
- if (Array.isArray(self.bindEvents)) {
2268
- yield* wrapForEach(self.bindEvents, function* warpForEachGenerator(event) {
2269
- code += yield* event.toEmbeddedTS(
2270
- shiftState(state, code, {
2271
- tabSize: state?.tabSize || 0,
2272
- }),
2273
- true,
2274
- );
2275
- code += '\n';
2276
- });
2277
- }
2278
- code += `\n}`;
2279
- // 自定义事件的定义
2280
- if (Array.isArray(self.events) && self.events.length) {
2281
- code += indent((state?.tabSize || 0) + 1);
2282
- yield* wrapForEach(self.events, function* warpForEachGenerator(event) {
2283
- code += yield* event.toEmbeddedTS(
2284
- shiftState(state, code, {
2285
- tabSize: (state?.tabSize || 0) + 2,
2286
- }),
2287
- );
2288
- code += '\n';
2289
- });
2290
- code += indent((state?.tabSize || 0) + 1);
2291
- }
2292
- // 逻辑
2293
- if (Array.isArray(self.logics) && self.logics.length) {
2294
- code += indent((state?.tabSize || 0) + 1);
2295
- yield* wrapForEach(self.logics, function* warpForEachGenerator(logic) {
2296
- code += yield* logic.toEmbeddedTS(
2297
- shiftState(state, code, {
2298
- tabSize: (state?.tabSize || 0) + 2,
2299
- }),
2300
- 'noExport',
2301
- );
2302
- code += '\n';
2303
- });
2304
- code += indent((state?.tabSize || 0) + 1);
2305
- }
2306
- // render函数
2307
- code += `\n${indent((state?.tabSize || 0) + 1)}`;
2308
- code += `__render(`;
2309
- code += `){\n`;
2310
- code += indent(state?.tabSize || 0);
2311
- // elements 元素
2312
- if (Array.isArray(self.elements)) {
2313
- // 生成嵌套式的内容
2314
- yield* wrapForEach(self.elements, function* warpForEachGenerator(element) {
2315
- code += yield* element.toEmbeddedTS(
2316
- shiftState(state, code, {
2317
- tabSize: (state?.tabSize || 0) + 3,
2318
- }),
2319
- );
2320
- code += '\n';
2321
- });
2322
- }
2323
- code += `\n${indent((state?.tabSize || 0) + 1)}}\n`;
2324
- if (Array.isArray(self.params)) {
2325
- code += `${indent((state?.tabSize || 0) + 1)}$destination(options: {`;
2326
- yield* wrapForEach(self.params, function* warpForEachGenerator(param, index) {
2327
- code += `${param.name}?: `;
2328
- code += yield* param.typeAnnotation.toEmbeddedTS(shiftState(state, code));
2329
- code += ', ';
2330
- });
2331
- // 锚点
2332
- code += `_anchor?: nasl.core.String`;
2333
- code += '}){}\n';
2334
- }
2335
- code += `${indent(state?.tabSize || 0)}}\n`;
2336
2263
 
2264
+ /**
2265
+ * 这部分需要先执行
2266
+ **/
2337
2267
  // elements类型声明定义
2338
- code += `interface __elements {\n`;
2268
+ let code = `interface __elements {\n`;
2339
2269
  // 生成所有的name和类型定义
2340
2270
  yield* wrapForEach(self.elements, function* warpForEachGenerator(element) {
2341
2271
  code += yield* element.toEmbeddedTSDefinition(
@@ -2407,7 +2337,7 @@ export class BusinessComponent extends BaseNode {
2407
2337
  const IDENTIFIERMAP = new Set<Variable>();
2408
2338
  if (Array.isArray(self.params)) {
2409
2339
  yield* wrapForEach(self.params, function* warpForEachGenerator(param) {
2410
- code += `let ${indent((state?.tabSize || 0) + 1)}`;
2340
+ code += `${indent((state?.tabSize || 0) + 1)}let `;
2411
2341
  code += yield* param.toEmbeddedTS(shiftState(state, code, { inline: true }));
2412
2342
  code += ';\n';
2413
2343
  });
@@ -2419,7 +2349,7 @@ export class BusinessComponent extends BaseNode {
2419
2349
  IDENTIFIERMAP.add(variable);
2420
2350
  }
2421
2351
  if (!advanceMap.get(variable)) {
2422
- code += `let ${indent((state?.tabSize || 0) + 1)}`;
2352
+ code += `${indent((state?.tabSize || 0) + 1)}let `;
2423
2353
  code += yield* variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
2424
2354
  code += ';\n';
2425
2355
  }
@@ -2486,6 +2416,7 @@ export class BusinessComponent extends BaseNode {
2486
2416
  code += '\n';
2487
2417
  code += `${indent((state?.tabSize || 0) + 2)}return\n`;
2488
2418
 
2419
+
2489
2420
  function* setPlaygroundCode(arr: Variable[] | ParamWithGroup[], name: string) {
2490
2421
  if (arr.length) {
2491
2422
  code += `${indent((state?.tabSize || 0) + 1)}/* -----以下是 ${name} 的默认值草稿------ */\n`;
@@ -2501,6 +2432,99 @@ export class BusinessComponent extends BaseNode {
2501
2432
  yield* setPlaygroundCode(self.variables, 'variables');
2502
2433
  yield* setPlaygroundCode(self.params, 'params');
2503
2434
 
2435
+ code += `${indent(state?.tabSize || 0)}}\n`;
2436
+
2437
+ code += `export class ${self.tsName} extends nasl.ui.VueComponent {\n`;
2438
+
2439
+ // 需要类型推导的局部变量/返回值需要调整申明顺序
2440
+ code += `constructor(
2441
+ options?: {
2442
+ [propname: string]: any,
2443
+ bindAttr?: {
2444
+ __NASLIF?: nasl.core.Boolean,
2445
+ `;
2446
+ if (Array.isArray(self.params)) {
2447
+ yield* wrapForEach(self.params, function* warpForEachGenerator(param, index) {
2448
+ code += `${param.name}?: `;
2449
+ code += yield* param.typeAnnotation.toEmbeddedTS(shiftState(state, code));
2450
+ code += ',\n';
2451
+ });
2452
+ }
2453
+ code += `
2454
+ },
2455
+ slotDefault?: () => Array<any>,
2456
+ }) {
2457
+ super();\n`;
2458
+
2459
+ // 绑定事件
2460
+ if (Array.isArray(self.bindEvents)) {
2461
+ yield* wrapForEach(self.bindEvents, function* warpForEachGenerator(event) {
2462
+ code += yield* event.toEmbeddedTS(
2463
+ shiftState(state, code, {
2464
+ tabSize: state?.tabSize || 0,
2465
+ }),
2466
+ true,
2467
+ );
2468
+ code += '\n';
2469
+ });
2470
+ }
2471
+ code += `\n}`;
2472
+ // 自定义事件的定义
2473
+ if (Array.isArray(self.events) && self.events.length) {
2474
+ code += indent((state?.tabSize || 0) + 1);
2475
+ yield* wrapForEach(self.events, function* warpForEachGenerator(event) {
2476
+ code += yield* event.toEmbeddedTS(
2477
+ shiftState(state, code, {
2478
+ tabSize: (state?.tabSize || 0) + 2,
2479
+ }),
2480
+ );
2481
+ code += '\n';
2482
+ });
2483
+ code += indent((state?.tabSize || 0) + 1);
2484
+ }
2485
+ // 逻辑
2486
+ if (Array.isArray(self.logics) && self.logics.length) {
2487
+ code += indent((state?.tabSize || 0) + 1);
2488
+ yield* wrapForEach(self.logics, function* warpForEachGenerator(logic) {
2489
+ code += yield* logic.toEmbeddedTS(
2490
+ shiftState(state, code, {
2491
+ tabSize: (state?.tabSize || 0) + 2,
2492
+ }),
2493
+ 'noExport',
2494
+ );
2495
+ code += '\n';
2496
+ });
2497
+ code += indent((state?.tabSize || 0) + 1);
2498
+ }
2499
+ // render函数
2500
+ code += `\n${indent((state?.tabSize || 0) + 1)}`;
2501
+ code += `__render(`;
2502
+ code += `){\n`;
2503
+ code += indent(state?.tabSize || 0);
2504
+ // elements 元素
2505
+ if (Array.isArray(self.elements)) {
2506
+ // 生成嵌套式的内容
2507
+ yield* wrapForEach(self.elements, function* warpForEachGenerator(element) {
2508
+ code += yield* element.toEmbeddedTS(
2509
+ shiftState(state, code, {
2510
+ tabSize: (state?.tabSize || 0) + 3,
2511
+ }),
2512
+ );
2513
+ code += '\n';
2514
+ });
2515
+ }
2516
+ code += `\n${indent((state?.tabSize || 0) + 1)}}\n`;
2517
+ if (Array.isArray(self.params)) {
2518
+ code += `${indent((state?.tabSize || 0) + 1)}$destination(options: {`;
2519
+ yield* wrapForEach(self.params, function* warpForEachGenerator(param, index) {
2520
+ code += `${param.name}?: `;
2521
+ code += yield* param.typeAnnotation.toEmbeddedTS(shiftState(state, code));
2522
+ code += ', ';
2523
+ });
2524
+ // 锚点
2525
+ code += `_anchor?: nasl.core.String`;
2526
+ code += '}){}\n';
2527
+ }
2504
2528
  code += `${indent((state?.tabSize || 0) + 1)}}\n`;
2505
2529
  return code;
2506
2530
  }
@@ -82,6 +82,18 @@ export class CallEvent extends LogicItem {
82
82
  return super.from(source, parentNode, parentKey) as CallEvent;
83
83
  }
84
84
 
85
+ /**
86
+ * 设置calleeName
87
+ */
88
+ setCalleeName(calleeName: string) {
89
+ const object = {
90
+ calleeName,
91
+ };
92
+ this.update({
93
+ ...object,
94
+ });
95
+ }
96
+
85
97
  /**
86
98
  * 插入实际参数
87
99
  * @internal
@@ -309,9 +321,14 @@ export class CallEvent extends LogicItem {
309
321
  let code = '';
310
322
  code += `this.$emit('${this.calleeName}', {\n`;
311
323
  if (Array.isArray(completeArguments) && completeArguments.length) {
324
+ const eventNode = this.getCallNode();
325
+ const eventParams = eventNode?.params;
312
326
  completeArguments.forEach((arg, index) => {
313
- const argStr = arg?.toJS(shiftState(state, code));
314
-
327
+ let argStr = arg?.toJS(shiftState(state, code));
328
+ const paramDefaultValue = eventParams?.[index]?.defaultValue?.toJS?.();
329
+ if (paramDefaultValue) {
330
+ argStr = `${argStr} !== undefined ? ${argStr} : ${paramDefaultValue}`;
331
+ }
315
332
  code += `${arg.keyword}: ${argStr}`;
316
333
  if (index !== completeArguments?.length - 1) {
317
334
  code += ', ';
@@ -16,7 +16,6 @@ import type Function from './Function__';
16
16
  import { ElementToVueOptions } from './ViewElement__';
17
17
  import type Identifier from './Identifier__';
18
18
  import { getBuildInFunction } from '../server/getFunctions';
19
- import type AnonymousFunction from './AnonymousFunction__';
20
19
  import type MemberExpression from './MemberExpression__';
21
20
  import asyncFuncMap from '../common/asyncFuncMap';
22
21
 
@@ -721,16 +720,6 @@ export class CallFunction extends LogicItem {
721
720
  return code;
722
721
  }
723
722
 
724
- checkParamNameOfAnonymousFunction() {
725
- const fns = this.arguments
726
- .map((arg) => arg.expression)
727
- .filter((exp) => asserts.isAnonymousFunction(exp)) as unknown as AnonymousFunction[];
728
-
729
- fns.forEach((fn) => {
730
- fn.checkParamName();
731
- });
732
- }
733
-
734
723
  getQuickInfoOffset(range: Range, getCode: GetCode) {
735
724
  return getCallExpressionQuickInfo(range, getCode);
736
725
  }
@@ -358,7 +358,8 @@ export class Destination extends LogicItem {
358
358
  if (this.viewName) {
359
359
  viewArr.push(this.viewName);
360
360
  }
361
- // 第一个是端名,需要去掉
361
+ // 端名和端类型名都需要去掉
362
+ viewArr.shift();
362
363
  viewArr.shift();
363
364
  return viewArr;
364
365
  }
@@ -690,6 +691,7 @@ export class Destination extends LogicItem {
690
691
  }
691
692
  });
692
693
  }
694
+ console.log(viewNameAttr);
693
695
  if (this.viewNode) {
694
696
  return `${this.viewNode?.frontend?.prefixPath}/${viewNameAttr.join('/')}`;
695
697
  }
@@ -702,8 +704,6 @@ export class Destination extends LogicItem {
702
704
  // const tab = indent((state?.tabSize || 0));
703
705
  if (self.tsCalleeNamespace && self.tsName) {
704
706
  const destinationName = self.parentNode.name.replace('-', '_');
705
- // 跳转页面拿不到自己任务下的输出参数,所以不需要__ProcessIdentification__标注
706
- prevCode = prevCode.replace('__ProcessIdentification__', '');
707
707
  let code = `${destinationName}: function() {\n`;
708
708
  code += prevCode;
709
709
  code += '\n';
@@ -77,7 +77,7 @@ export class Entity extends BaseNode {
77
77
  * 实体来源
78
78
  */
79
79
  @property()
80
- origin: 'ide' | 'sql' | 'table' | 'excel' = 'ide';
80
+ origin: 'ide' | 'sql' | 'table' | 'excel' | 'form' = 'ide';
81
81
 
82
82
  /**
83
83
  * 实体属性列表
@@ -951,6 +951,8 @@ export class Entity extends BaseNode {
951
951
  ns.path = this.getNamespace();
952
952
  return ns;
953
953
  }
954
+ // @excludedInJSON()
955
+ // nslogic: Namespace;
954
956
 
955
957
  get logics() {
956
958
  return this.ns.logics;
@@ -1557,15 +1557,21 @@ export class Logic extends BaseNode {
1557
1557
  varList.push(...this.likeComponent.variables);
1558
1558
  }
1559
1559
  }
1560
-
1561
- this.traverseChildren((el) => {
1562
- if (el?.concept === 'ForEachStatement') {
1563
- if ((el as ForEachStatement)?.item) {
1564
- varList.push((el as ForEachStatement)?.item);
1565
- }
1566
- if ((el as ForEachStatement)?.index) {
1567
- varList.push((el as ForEachStatement)?.index);
1568
- }
1560
+ this.traverseChildren((node) => {
1561
+ switch (node?.concept) {
1562
+ case 'ForEachStatement':
1563
+ if (node.item) {
1564
+ varList.push(node?.item);
1565
+ }
1566
+ if (node.index) {
1567
+ varList.push(node?.index);
1568
+ }
1569
+ break;
1570
+ case 'AnonymousFunction':
1571
+ node.params?.forEach((param: Param) => {
1572
+ varList.push(param);
1573
+ });
1574
+ break;
1569
1575
  }
1570
1576
  });
1571
1577
  return varList.filter((item) => !excludedSet.has(item)).map((item) => item?.name);
@@ -500,7 +500,12 @@ export class ValidationRule extends LogicItem {
500
500
  const { calleeName, target, calleeKey, arguments: args, errorMessage, view } = self;
501
501
  if (calleeName) {
502
502
  // 调用逻辑时绑定的验证器
503
- if (self?.parentNode?.parentKey !== 'metadataTypes' && (self.getAncestor('CallLogic') || !view)) {
503
+ if (
504
+ self?.parentNode?.parentKey !== 'metadataTypes'
505
+ && (
506
+ self.getAncestor('CallLogic') || !(view || this.getAncestor('BusinessComponent'))
507
+ )
508
+ ) {
504
509
  code += yield* target.toEmbeddedTS(shiftState(state, code));
505
510
  code += ';\n';
506
511
  }
@@ -90,6 +90,7 @@ export interface ElementToVueOptions {
90
90
  bindStylesFormat?: (bindStyles: BindStyle[], element?: ViewElement, defaultResult?: string) => string | false;
91
91
  finalCode?: boolean;
92
92
  currentList?: string[];
93
+ isDev?: boolean;
93
94
  }
94
95
 
95
96
  function transAstNodeToNaslNode(astNode: any, namespace?: string): any {
@@ -267,6 +268,14 @@ function transAstNodeToNaslTypeNode(astNode: any, namespace?: string): any {
267
268
  }
268
269
  return node;
269
270
  }
271
+
272
+ function isLockField(node?:any):boolean {
273
+ if (!node || node.concept !== 'ViewElement') return false;
274
+ const attr = node?.bindAttrs?.find((attr: any) => ['FormDesignerLocked','TableDesignerLocked'].includes(attr.name))?.value
275
+ if (attr === undefined) return !!isLockField(node?.parentNode);
276
+ else return !!attr
277
+ }
278
+
270
279
  //================================================================================
271
280
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
272
281
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -1725,7 +1734,7 @@ export class ViewElement extends BaseNode {
1725
1734
  }>`;
1726
1735
  } else {
1727
1736
  let targetNode: any = _this;
1728
- while (!targetNode.__tsVariableDataSourceTypeName && asserts.isViewElement(targetNode?.parentNode)) {
1737
+ while ((!targetNode.__tsVariableDataSourceTypeName || targetNode.__tsVariableDataSourceTypeName === 'any') && asserts.isViewElement(targetNode?.parentNode)) {
1729
1738
  targetNode = targetNode.parentNode;
1730
1739
  }
1731
1740
  genericity += `<${(targetNode as any).__tsVariableDataSourceTypeName ?? 'any'}>`;
@@ -2017,7 +2026,7 @@ export class ViewElement extends BaseNode {
2017
2026
  }
2018
2027
  yield* wrapForEach(self.bindAttrs, function* warpForEachGenerator(attr) {
2019
2028
  // 过滤自由布局的key
2020
- const shouldFilter = self.isCorrespondingBusinessComponent && !(name === 'key' && !attr.expression);
2029
+ const shouldFilter = self.isCorrespondingBusinessComponent && (attr.name === 'key' && !attr.expression);
2021
2030
  if (shouldFilter) {
2022
2031
  return;
2023
2032
  }
@@ -2637,6 +2646,10 @@ export class ViewElement extends BaseNode {
2637
2646
  .replace(/\$global./g, 'nasl.')
2638
2647
  .replace(/\bscope\.item\.\b/g, '')
2639
2648
  .replace(/\bcurrent\.item\.\b/g, '');
2649
+
2650
+ if (isLockField(element)) {
2651
+ return element.tag === 'u-text' ? `${name}="--"` : `${name}=""`
2652
+ }
2640
2653
  return `${name}="{{ ${value} }}"`;
2641
2654
  });
2642
2655
  else return defaultResult;
@@ -2705,6 +2718,7 @@ export class ViewElement extends BaseNode {
2705
2718
 
2706
2719
  return parts;
2707
2720
  },
2721
+ isDev: true,
2708
2722
  });
2709
2723
  }
2710
2724
 
@@ -2765,6 +2779,12 @@ export class ViewElement extends BaseNode {
2765
2779
  * 转换成 Vue 的模板格式
2766
2780
  */
2767
2781
  toVue(options?: ElementToVueOptions) {
2782
+
2783
+ // lockField 不翻译modal
2784
+ if (options?.isDev && this?.tag === 'u-modal' && isLockField(this)) {
2785
+ return ``;
2786
+ }
2787
+
2768
2788
  const { finalCode, asCompontent } = options || {};
2769
2789
  const parts: string[] = [];
2770
2790
  if (finalCode === false) {
@@ -2772,7 +2792,7 @@ export class ViewElement extends BaseNode {
2772
2792
  if (asCompontent) {
2773
2793
  return `<div vusion-slot-name="${this.name}">
2774
2794
  <slot name="${this.name}">
2775
- <div s-empty="true" style="background: #f7f8fa;
2795
+ <div s-empty="true" bs-empty="true" style="background: #f7f8fa;
2776
2796
  border: 1px dashed #c3c3c3;
2777
2797
  text-align: center;
2778
2798
  color: #999;
@@ -2946,6 +2966,8 @@ export class ViewElement extends BaseNode {
2946
2966
  partsString += ' ' + part;
2947
2967
  partsLength += part.length;
2948
2968
  });
2969
+
2970
+
2949
2971
  let htmlContent =
2950
2972
  `<${this.tag}${partsString.length ? partsString : ''}>` +
2951
2973
  content +
@@ -2954,6 +2976,7 @@ export class ViewElement extends BaseNode {
2954
2976
  if (!content.trim() && selfClosingTag.includes(this.tag)) {
2955
2977
  htmlContent = `<${this.tag}${partsString.length ? partsString : ''} />`;
2956
2978
  }
2979
+
2957
2980
  return htmlContent;
2958
2981
  }
2959
2982
 
@@ -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
  }
@@ -1836,22 +1836,6 @@ export class View extends BaseNode {
1836
1836
  });
1837
1837
  }
1838
1838
 
1839
- // 页面逻辑
1840
- if (Array.isArray(definition.viewLogics)) {
1841
- definition.viewLogics.forEach((logicOption: any) => {
1842
- // 页面逻辑只有load函数的走之前的逻辑其余不用创建
1843
- if (logicOption.name.startsWith('load')) {
1844
- // const logic = Logic.from(
1845
- // {
1846
- // ...logicOption,
1847
- // },
1848
- // this,
1849
- // 'logics'
1850
- // );
1851
- // this.addLogic(logic);
1852
- }
1853
- });
1854
- }
1855
1839
  // 页面事件
1856
1840
  if (Array.isArray(definition.viewBindEvents)) {
1857
1841
  definition.viewBindEvents.forEach((eventOption: any) => {
@@ -1935,6 +1919,23 @@ export class View extends BaseNode {
1935
1919
  }
1936
1920
  });
1937
1921
  }
1922
+ this.traverseChildren((node) => {
1923
+ switch (node?.concept) {
1924
+ case 'ForEachStatement':
1925
+ if (node.item) {
1926
+ varList.push(node?.item);
1927
+ }
1928
+ if (node.index) {
1929
+ varList.push(node?.index);
1930
+ }
1931
+ break;
1932
+ case 'AnonymousFunction':
1933
+ node.params?.forEach((param: Param) => {
1934
+ varList.push(param);
1935
+ });
1936
+ break;
1937
+ }
1938
+ });
1938
1939
  return varList.filter((item) => !excludedSet.has(item)).map((item) => item.name);
1939
1940
  }
1940
1941
 
@@ -220,6 +220,27 @@ BaseNode.prototype.changeName = async function changeName(newValue: string, upda
220
220
  }
221
221
  };
222
222
 
223
+ BaseNode.prototype.removeBindEntityPropertyViewEelment = async function removeBindEntityPropertyViewEelment() {
224
+ const app = this.getAncestor('App');
225
+ const naslServer = (app as any).naslServer as NaslServer;
226
+ const refsList = await naslServer._isHaveRef(this); // 查找到引用链
227
+
228
+ refsList.forEach(record => {
229
+ const fileNode = naslServer.file2NodeMap.get(record.file);
230
+ if (!fileNode) return null;
231
+ const minRange: MinRange = naslServer._findMinRange(record, fileNode as FileNode); // 查找到引用节点
232
+
233
+ let node = minRange.node;
234
+ while (node) {
235
+ if (node instanceof ViewElement && node.getBindAttribute('bindEntityProperty')) {
236
+ node.delete();
237
+ }
238
+ node = node.parentNode;
239
+ }
240
+ })
241
+
242
+ }
243
+
223
244
  /** 删除连接器 */
224
245
  function delConnection(node: Connection) {
225
246
  const app = node.rootNode as App;
@@ -267,7 +267,7 @@ export function syncMemberExpression(elem: ProcessElement | Process, callback: (
267
267
  }
268
268
  });
269
269
  }
270
- if (el.type === 'ExclusiveGateway' || el.type === 'AutoTask') {
270
+ if (['ExclusiveGateway', 'AutoTask', 'InclusiveGateway'].includes(el.type)) {
271
271
  travelDown(el.logic, (node) => {
272
272
  if (node instanceof MemberExpression) {
273
273
  callback(node);
@@ -435,7 +435,7 @@ export function getProcessVariableSuggestions(node: LogicItem, abandonConstant:
435
435
  ],
436
436
  });
437
437
  processVariables.icon = 'Process';
438
- if (processElem.type === 'ExclusiveGateway') {
438
+ if (['ExclusiveGateway', 'InclusiveGateway'].includes(processElem.type)) {
439
439
  const scopeVariable = new CompletionProperty({
440
440
  name: processElem.name,
441
441
  value: processElem.name,
@@ -589,7 +589,7 @@ export function getProcessVariableSuggestionsAll(node: ProcessElement, exitConst
589
589
  });
590
590
  processVariables.expanded = true;
591
591
  processVariables.icon = 'Process';
592
- if (processElem.type === 'ExclusiveGateway') {
592
+ if (['ExclusiveGateway', 'AutoTask', 'InclusiveGateway'].includes(processElem.type)) {
593
593
  const scopeVariable = new CompletionProperty({
594
594
  name: processElem.name,
595
595
  value: processElem.name,