@lcap/nasl 0.3.10-beta → 0.3.10-beta.10

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 (126) hide show
  1. package/out/service/app/api.d.ts +1 -15
  2. package/out/service/app/api.js +7 -17
  3. package/out/service/app/api.js.map +1 -1
  4. package/out/service/create/errHandles.js +12 -0
  5. package/out/service/create/errHandles.js.map +1 -1
  6. package/out/service/create/index.js +3 -0
  7. package/out/service/create/index.js.map +1 -1
  8. package/out/service/logic/logic.d.ts +26 -17
  9. package/out/service/logic/logic.js +6 -0
  10. package/out/service/logic/logic.js.map +1 -1
  11. package/out/types/app/App.d.ts +5 -4
  12. package/out/types/app/App.js +31 -25
  13. package/out/types/app/App.js.map +1 -1
  14. package/out/types/app/History.js +3 -2
  15. package/out/types/app/History.js.map +1 -1
  16. package/out/types/app/Service.d.ts +3 -0
  17. package/out/types/app/Service.js +10 -2
  18. package/out/types/app/Service.js.map +1 -1
  19. package/out/types/cacheData.js.map +1 -1
  20. package/out/types/data/Entity.d.ts +4 -0
  21. package/out/types/data/Entity.js +8 -0
  22. package/out/types/data/Entity.js.map +1 -1
  23. package/out/types/data/EntityProperty.d.ts +5 -0
  24. package/out/types/data/EntityProperty.js +16 -0
  25. package/out/types/data/EntityProperty.js.map +1 -1
  26. package/out/types/data/dataTypes.js +1 -1
  27. package/out/types/data/dataTypes.js.map +1 -1
  28. package/out/types/data/genBlock/genCurdEditTableBlock.d.ts +3 -0
  29. package/out/types/data/genBlock/genCurdEditTableBlock.js +578 -0
  30. package/out/types/data/genBlock/genCurdEditTableBlock.js.map +1 -0
  31. package/out/types/data/genBlock/genEditTableBlock.d.ts +234 -0
  32. package/out/types/data/genBlock/genEditTableBlock.js +419 -0
  33. package/out/types/data/genBlock/genEditTableBlock.js.map +1 -0
  34. package/out/types/data/genBlock/genQueryComponent.d.ts +20 -0
  35. package/out/types/data/genBlock/genQueryComponent.js +57 -1
  36. package/out/types/data/genBlock/genQueryComponent.js.map +1 -1
  37. package/out/types/data/genBlock/genTableBlock.js +9 -5
  38. package/out/types/data/genBlock/genTableBlock.js.map +1 -1
  39. package/out/types/data/genBlock/index.d.ts +2 -0
  40. package/out/types/data/genBlock/index.js +2 -0
  41. package/out/types/data/genBlock/index.js.map +1 -1
  42. package/out/types/data/genBlock/utils.d.ts +7 -0
  43. package/out/types/data/genBlock/utils.js +38 -1
  44. package/out/types/data/genBlock/utils.js.map +1 -1
  45. package/out/types/index.d.ts +2 -4
  46. package/out/types/index.js +3 -6
  47. package/out/types/index.js.map +1 -1
  48. package/out/types/logic/Logic.d.ts +4 -12
  49. package/out/types/logic/Logic.js +35 -24
  50. package/out/types/logic/Logic.js.map +1 -1
  51. package/out/types/logic/LogicItem.d.ts +1 -20
  52. package/out/types/logic/LogicItem.js +5 -191
  53. package/out/types/logic/LogicItem.js.map +1 -1
  54. package/out/types/logic/Param.js +5 -13
  55. package/out/types/logic/Param.js.map +1 -1
  56. package/out/types/logic/Return.js +3 -11
  57. package/out/types/logic/Return.js.map +1 -1
  58. package/out/types/logic/Variable.js +3 -6
  59. package/out/types/logic/Variable.js.map +1 -1
  60. package/out/types/logic/translator.js +39 -8
  61. package/out/types/logic/translator.js.map +1 -1
  62. package/out/types/page/Element.d.ts +21 -2
  63. package/out/types/page/Element.js +89 -7
  64. package/out/types/page/Element.js.map +1 -1
  65. package/out/types/page/Page.d.ts +4 -0
  66. package/out/types/page/Page.js +7 -0
  67. package/out/types/page/Page.js.map +1 -1
  68. package/out/types/page/View.d.ts +19 -16
  69. package/out/types/page/View.js +73 -15
  70. package/out/types/page/View.js.map +1 -1
  71. package/out/types/page/ViewVariable.js +0 -6
  72. package/out/types/page/ViewVariable.js.map +1 -1
  73. package/out/types/process/ProcessParam.js +3 -1
  74. package/out/types/process/ProcessParam.js.map +1 -1
  75. package/out/types/utils/index.d.ts +1 -0
  76. package/out/types/utils/index.js +16 -7
  77. package/out/types/utils/index.js.map +1 -1
  78. package/package.json +1 -2
  79. package/src/service/app/api.js +8 -17
  80. package/src/service/create/errHandles.js +12 -0
  81. package/src/service/create/index.js +4 -0
  82. package/src/service/logic/logic.js +6 -0
  83. package/src/types/app/App.ts +37 -28
  84. package/src/types/app/History.ts +3 -2
  85. package/src/types/app/Service.ts +14 -5
  86. package/src/types/cacheData.ts +7 -7
  87. package/src/types/data/Entity.ts +7 -0
  88. package/src/types/data/EntityProperty.ts +12 -0
  89. package/src/types/data/dataTypes.ts +1 -1
  90. package/src/types/data/genBlock/genCurdEditTableBlock.ts +581 -0
  91. package/src/types/data/genBlock/genEditTableBlock.ts +470 -0
  92. package/src/types/data/genBlock/genQueryComponent.ts +56 -0
  93. package/src/types/data/genBlock/genTableBlock.ts +14 -10
  94. package/src/types/data/genBlock/index.ts +2 -0
  95. package/src/types/data/genBlock/utils.ts +38 -0
  96. package/src/types/index.ts +2 -4
  97. package/src/types/logic/Logic.ts +45 -41
  98. package/src/types/logic/LogicItem.ts +12 -217
  99. package/src/types/logic/Param.ts +25 -35
  100. package/src/types/logic/Return.ts +18 -26
  101. package/src/types/logic/Variable.ts +18 -20
  102. package/src/types/logic/translator.js +125 -154
  103. package/src/types/page/Element.ts +160 -73
  104. package/src/types/page/Page.ts +7 -0
  105. package/src/types/page/View.ts +112 -61
  106. package/src/types/page/ViewVariable.ts +13 -19
  107. package/src/types/page/dist/View.js +727 -0
  108. package/src/types/process/ProcessParam.ts +4 -1
  109. package/src/types/utils/index.ts +16 -7
  110. package/tsconfig.json +1 -1
  111. package/out/service/debugger/debugger.d.ts +0 -3
  112. package/out/service/debugger/debugger.js +0 -95
  113. package/out/service/debugger/debugger.js.map +0 -1
  114. package/out/test/units/config.spec.d.ts +0 -1
  115. package/out/test/units/config.spec.js +0 -12
  116. package/out/test/units/config.spec.js.map +0 -1
  117. package/out/types/logic/BreakPoint.d.ts +0 -42
  118. package/out/types/logic/BreakPoint.js +0 -155
  119. package/out/types/logic/BreakPoint.js.map +0 -1
  120. package/out/types/logic/Debugger.d.ts +0 -156
  121. package/out/types/logic/Debugger.js +0 -912
  122. package/out/types/logic/Debugger.js.map +0 -1
  123. package/src/service/debugger/debugger.js +0 -90
  124. package/src/types/logic/BreakPoint.ts +0 -200
  125. package/src/types/logic/Debugger.ts +0 -1140
  126. package/src/types/logic/translator.d.ts +0 -16
@@ -1,34 +1,24 @@
1
1
  import { immutable, excludedInJSON, circular, action } from '../decorators';
2
- import { config, history, utils, Vertex, LEVEL_ENUM, Interface, Param, Return, Variable, vertexsMap, typeCheck, ProcessComponent, ProcessInterface, Process, ActionOptions } from '..';
2
+ import { config, utils, Vertex, LEVEL_ENUM, Interface, Param, Return, Variable, vertexsMap, typeCheck, ProcessComponent, ProcessInterface, Process, ActionOptions } from '..';
3
3
  import { logicService, paramService } from '../../service/logic';
4
- import { sourceMapService } from '../../service/debugger/debugger';
5
4
  import View from '../page/View';
6
5
  import { ExpressionNode, LogicItem, LogicNode } from './LogicItem';
7
6
  import { convert2SchemaType } from '../data/dataTypeUtils';
8
7
  import { isPlainObject, throttle } from 'lodash';
9
- interface sourceMapObj {
10
- node: LogicItem,
11
- classIdentify: string,
12
- from: number,
13
- lineFrom: number,
14
- end: number
15
- vertexId: string,
16
- logicId: string,
17
- }
18
8
  import { refreshInterfaces, refreshView, refreshPages } from '../cache';
19
9
  import { BusinessCode } from '../enum';
20
10
 
21
11
  export function catchFn(logic: Logic) {
22
12
  return async (err: any) => {
23
13
  const code = err?.code;
24
- if([BusinessCode.ElementExist, BusinessCode.ElementNotExist].includes(code)) {
25
- if(logic.interface) {
14
+ if ([BusinessCode.ElementExist, BusinessCode.ElementNotExist].includes(code)) {
15
+ if (logic.interface) {
26
16
  await refreshInterfaces();
27
- } else if(logic.view) {
17
+ } else if (logic.view) {
28
18
  await refreshView(logic.view);
29
19
  }
30
- } else if(code === BusinessCode.ParentElementNotExist) { // 父节点不存在。视图添加逻辑,发现视图不存在
31
- if(logic.view) {
20
+ } else if (code === BusinessCode.ParentElementNotExist) { // 父节点不存在。视图添加逻辑,发现视图不存在
21
+ if (logic.view) {
32
22
  await refreshPages();
33
23
  }
34
24
  } else
@@ -37,7 +27,7 @@ export function catchFn(logic: Logic) {
37
27
  config.defaultApp?.history.load();
38
28
 
39
29
  throw err;
40
- }
30
+ };
41
31
  }
42
32
 
43
33
  /**
@@ -149,10 +139,6 @@ export class Logic extends Vertex {
149
139
  */
150
140
  @excludedInJSON()
151
141
  public contentPromise: Promise<any> = undefined;
152
- @excludedInJSON()
153
- public sourceMap: {
154
- [id: string]: Partial<sourceMapObj>
155
- } = {};
156
142
  /**
157
143
  * 树组件的子节点字段
158
144
  */
@@ -192,12 +178,10 @@ export class Logic extends Vertex {
192
178
  config.defaultApp?.emit('saving');
193
179
 
194
180
  const body = this.toJSON();
195
- // body.params.forEach((param: any) => convert2SchemaType(param.schema));
196
- // body.returns.forEach((ret: any) => convert2SchemaType(ret.schema));
197
- // body.variables.forEach((variable: any) => convert2SchemaType(variable.schema));
198
181
  utils.logger.debug('添加逻辑', body);
199
182
  const result: Logic = await logicService.create({
200
183
  headers: {
184
+ moduleType: this.moduleType,
201
185
  appId: config.defaultApp?.id,
202
186
  operationAction: actionOptions?.actionName || 'Logic.create',
203
187
  operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.name}"`,
@@ -244,6 +228,7 @@ export class Logic extends Vertex {
244
228
 
245
229
  await logicService.delete({
246
230
  headers: {
231
+ moduleType: this.moduleType,
247
232
  appId: config.defaultApp?.id,
248
233
  operationAction: actionOptions?.actionName || 'Logic.delete',
249
234
  operationDesc: actionOptions?.actionDesc || `删除逻辑"${this.name}"`,
@@ -262,7 +247,6 @@ export class Logic extends Vertex {
262
247
  typeCheck.delete(node.id);
263
248
  });
264
249
 
265
- // const index =
266
250
  this.destroy();
267
251
  if (this.view) {
268
252
  this.view.page.service.emit('pageTreeChange');
@@ -288,8 +272,9 @@ export class Logic extends Vertex {
288
272
 
289
273
  const body = this.toPlainJSON();
290
274
  utils.logger.debug('修改逻辑', body);
291
- const result = await logicService.update({
275
+ await logicService.update({
292
276
  headers: {
277
+ moduleType: this.moduleType,
293
278
  appId: config.defaultApp?.id,
294
279
  operationAction: actionOptions?.actionName || 'Logic.update',
295
280
  operationDesc: actionOptions?.actionDesc || `修改逻辑"${this.name}"`,
@@ -302,6 +287,35 @@ export class Logic extends Vertex {
302
287
  config.defaultApp?.emit('saved');
303
288
  return this;
304
289
  }
290
+ /**
291
+ * 更新所有调用了此Logic的LogicNode
292
+ */
293
+ async callLogicUpdate(actionOptions?: ActionOptions) {
294
+ config.defaultApp?.emit('saving');
295
+
296
+ const body = this.toPlainJSON();
297
+ body.params = this.params;
298
+ const result = await logicService.callLogicUpdate({
299
+ headers: {
300
+ appId: config.defaultApp?.id,
301
+ operationAction: actionOptions?.actionName || 'Logic.callLogicUpdate',
302
+ operationDesc: actionOptions?.actionDesc || `修改调用逻辑"${this.name}"`,
303
+ },
304
+ body,
305
+ }).catch((err: Error) => console.log(err)); // 报错不应影响参数的添加流程
306
+
307
+ (result || []).forEach(async (item: LogicNode) => {
308
+ if (vertexsMap.has(item.id)) {
309
+ const logicNode = vertexsMap.get(item.id) as LogicNode;
310
+ await logicNode.logic.load();
311
+ await logicNode.checkType();
312
+ }
313
+ });
314
+
315
+ // await config.defaultApp?.history.load();
316
+ config.defaultApp?.emit('saved');
317
+ return this;
318
+ }
305
319
  /**
306
320
  * 设置逻辑名称
307
321
  */
@@ -342,7 +356,7 @@ export class Logic extends Vertex {
342
356
  /**
343
357
  * 按当前 id 加载逻辑数据
344
358
  */
345
- async load() {
359
+ load() {
346
360
  if (!this.id)
347
361
  return;
348
362
 
@@ -378,6 +392,10 @@ export class Logic extends Vertex {
378
392
  });
379
393
 
380
394
  const results = await paramService.addList({
395
+ headers: {
396
+ moduleType: this.moduleType,
397
+ appId: config.defaultApp?.id,
398
+ },
381
399
  body,
382
400
  });
383
401
  params.forEach((param, index) => param.pick(results[index], ['id']));
@@ -391,10 +409,6 @@ export class Logic extends Vertex {
391
409
  if (isPlainObject(item)) {
392
410
  item = LogicItem.from(item, this, null);
393
411
  }
394
- // if (!this.children.includes(child)) {
395
- // const index = child._posIndex === undefined ? this.children.length : child._posIndex;
396
- // this.children.splice(index, 0, child);
397
- // }
398
412
  const parent = item.parentAttr ? vertexsMap.get(item.parentId) as LogicItem : undefined;
399
413
  return item.create({
400
414
  parent,
@@ -432,16 +446,6 @@ export class Logic extends Vertex {
432
446
 
433
447
  return result as LogicItem;
434
448
  }
435
- // async loadSourceMap() {
436
- // if (!logic.view) {
437
- // const result = await sourceMapService.getSourceMap({
438
- // query: {
439
- // scopeId: this.id,
440
- // },
441
- // });
442
- // this.sourceMap = result;
443
- // }
444
- // }
445
449
  /**
446
450
  * 从后端 JSON 生成规范的 Logic 对象
447
451
  */
@@ -1,5 +1,5 @@
1
1
  import { immutable, excludedInJSON, action } from '../decorators';
2
- import { config, typeCheck, utils, Vertex, LEVEL_ENUM, Logic, Schema, ActionOptions, ACTION_MODE, BreakPoint } from '..';
2
+ import { config, typeCheck, utils, Vertex, LEVEL_ENUM, Logic, Schema, ActionOptions, ACTION_MODE } from '..';
3
3
  import { logicService } from '../../service/logic';
4
4
  import { traverse } from '../utils';
5
5
  import { vertexsMap } from '../cacheData';
@@ -89,11 +89,11 @@ export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): st
89
89
 
90
90
  if (node.type === 'BinaryExpression') {
91
91
  let left: string = evaluate(<LogicNode>node.left, finalCode);
92
- if (!atomicList.includes(node.left?.type as LOGIC_TYPE) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
92
+ if (!atomicList.includes((node.left as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
93
93
  left = `(${left})`;
94
94
 
95
95
  let right: string = evaluate(<LogicNode>node.right, finalCode);
96
- if (!atomicList.includes(node.right?.type as LOGIC_TYPE) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
96
+ if (!atomicList.includes((node.right as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
97
97
  right = `(${right})`;
98
98
 
99
99
  return `${left} ${node.operator} ${right}`;
@@ -101,10 +101,10 @@ export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): st
101
101
 
102
102
  if (node.type === 'LogicalExpression') {
103
103
  let left: string = evaluate(<LogicNode>node.left, finalCode);
104
- if (!atomicList.includes(node.left?.type as LOGIC_TYPE) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
104
+ if (!atomicList.includes((node.left as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
105
105
  left = `(${left})`;
106
106
  let right: string = evaluate(<LogicNode>node.right, finalCode);
107
- if (!atomicList.includes(node.right?.type as LOGIC_TYPE) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
107
+ if (!atomicList.includes((node.right as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
108
108
  right = `(${right})`;
109
109
  return `${left} ${node.operator} ${right}`;
110
110
  }
@@ -310,14 +310,6 @@ export class LogicItem extends Vertex {
310
310
  public readonly pageParamKey: any = undefined;
311
311
  @immutable()
312
312
  public readonly pageParamKeyValue: any = undefined;
313
-
314
- /**
315
- 断点集合
316
- */
317
- @immutable()
318
- @excludedInJSON()
319
- public breakPoints: Array<BreakPoint> = [];
320
- public temporaryBreakPoint: BreakPoint = null;
321
313
  /**
322
314
  * CallQueryComponent 对应的 structure 的 id
323
315
  */
@@ -456,6 +448,7 @@ export class LogicItem extends Vertex {
456
448
  body.logicId = this.logic && this.logic.id;
457
449
  result = await logicService.addItem({
458
450
  headers: {
451
+ moduleType: this.logic && this.logic.moduleType,
459
452
  appId: config.defaultApp?.id,
460
453
  serviceId: this.logic?.interface?.serviceId,
461
454
  operationAction: 'LogicItem.create',
@@ -556,8 +549,9 @@ export class LogicItem extends Vertex {
556
549
  if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
557
550
  utils.logger.debug(`在该逻辑节点的属性"${parentAttr}"上插入一个节点"`, body);
558
551
 
559
- const result: LogicItem = await logicService.moveItem({
552
+ await logicService.moveItem({
560
553
  headers: {
554
+ moduleType: this.logic && this.logic.moduleType,
561
555
  appId: config.defaultApp?.id,
562
556
  operationAction: 'LogicItem.move',
563
557
  operationDesc: actionOptions?.actionDesc || `移动逻辑项"${this.label || this.type}"`,
@@ -608,7 +602,7 @@ export class LogicItem extends Vertex {
608
602
  await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
609
603
  operationAction: 'LogicItem.move',
610
604
  operationBeforeImage: null,
611
- operationAfterImage: null, // JSON.parse(JSON.stringify(this)),
605
+ operationAfterImage: null,
612
606
  operationDesc: `移动逻辑项"${this.label || this.type}"`,
613
607
  });
614
608
  config.defaultApp?.emit('saved');
@@ -806,8 +800,6 @@ export class LogicItem extends Vertex {
806
800
 
807
801
  if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
808
802
  if (this.id) {
809
- await this.removeAllBreakPointsOfDescendants();
810
-
811
803
  const body = this.toPlainJSON();
812
804
  /// @TODO: 不知道哪里来的 index
813
805
  delete body.index;
@@ -815,11 +807,11 @@ export class LogicItem extends Vertex {
815
807
 
816
808
  await logicService.removeItem({
817
809
  headers: {
810
+ moduleType: this.logic.moduleType,
818
811
  appId: config.defaultApp?.id,
819
812
  serviceId: this.logic?.interface?.serviceId,
820
813
  operationAction: 'LogicItem.delete',
821
814
  operationDesc: `删除逻辑项"${this.label || this.type}"`,
822
-
823
815
  },
824
816
  body,
825
817
  }).catch(catchFn(this.logic));
@@ -888,7 +880,6 @@ export class LogicItem extends Vertex {
888
880
  }
889
881
  this.assign(source);
890
882
  }
891
- // const body = this.toPlainJSON();
892
883
  const body = this.toJSON();
893
884
 
894
885
  body.params = (this as any).params && JSON.parse(JSON.stringify((this as any).params));
@@ -907,6 +898,7 @@ export class LogicItem extends Vertex {
907
898
  if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
908
899
  const result = await logicService.updateItem({
909
900
  headers: {
901
+ moduleType: this.logic.moduleType,
910
902
  appId: config.defaultApp?.id,
911
903
  operationAction: 'LogicItem.update',
912
904
  operationDesc: `修改逻辑项"${this.label || this.type}"`,
@@ -914,7 +906,6 @@ export class LogicItem extends Vertex {
914
906
  },
915
907
  body,
916
908
  }).catch(catchFn(this.logic));
917
- // this.deepPick(result, ['id', 'parentId', 'parentAttr']);
918
909
 
919
910
  // 合并params里的id
920
911
  if (body.params && body.params.length) {
@@ -934,7 +925,6 @@ export class LogicItem extends Vertex {
934
925
  let eachSchema = getSchemaOfExpressionNode(each);
935
926
  if (eachSchema) {
936
927
  eachSchema = eachSchema.schema || eachSchema;
937
- // eachSchema = convert2SchemaType(eachSchema);
938
928
  (item as any).schema = eachSchema.items; // 兼容老的items形式
939
929
  if (eachSchema.type === 'genericType') {
940
930
  (item as any).schema = eachSchema.typeInstantiation.typeParams[0].typeParamValue;
@@ -955,7 +945,7 @@ export class LogicItem extends Vertex {
955
945
 
956
946
  await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
957
947
  operationAction: 'LogicItem.update',
958
- operationBeforeImage: null, // JSON.parse(JSON.stringify(this)),
948
+ operationBeforeImage: null,
959
949
  operationAfterImage: null,
960
950
  operationDesc: `修改逻辑项"${this.label || this.type}"`,
961
951
  });
@@ -1092,7 +1082,6 @@ export class LogicItem extends Vertex {
1092
1082
  if (!typeCheckResult || !logicItem || typeof typeCheckResult !== 'object')
1093
1083
  return;
1094
1084
 
1095
- // if(logicItem.id === typeCheckResult.id)
1096
1085
  logicItem.typeCheckNote = typeCheckResult.typeCheckNote;
1097
1086
 
1098
1087
  for (const [key, object] of Object.entries(typeCheckResult)) {
@@ -1149,158 +1138,6 @@ export class LogicItem extends Vertex {
1149
1138
  parentAttr: activeImage.parentAttr,
1150
1139
  };
1151
1140
  }
1152
-
1153
- addBreakPointInstance(bp: BreakPoint) {
1154
- const finded = this.breakPoints.find((item) => item.offset === bp.offset);
1155
- if (!finded) {
1156
- this.breakPoints.push(bp);
1157
- }
1158
- }
1159
-
1160
- async addBreakPoint(appId: string, offsetLine = 0) {
1161
- let bp = this.breakPoints.find((bp) => bp.offset === offsetLine);
1162
- if (bp) {
1163
- return bp;
1164
- }
1165
- bp = new BreakPoint();
1166
- await bp.create({
1167
- appId,
1168
- logicItem: this,
1169
- offset: offsetLine,
1170
- });
1171
- this.breakPoints.push(bp);
1172
- const app = config.defaultApp;
1173
- app.debuggerClient.breakPoints.push(bp);
1174
- return bp;
1175
- }
1176
-
1177
- getBreakPointByLineNumber(lineNumber: number) {
1178
- return this.breakPoints.find((bp) => bp.lineNumberStart === lineNumber);
1179
- }
1180
-
1181
- addTemperaryBreakPoint(offsetLine = 0) {
1182
- const bp = new BreakPoint({
1183
- target: this.logic && this.logic.view ? 'Frontend' : 'Backend',
1184
- logicItem: this,
1185
- logicItemId: this.id,
1186
- componentId: this.logic && this.logic.view && this.logic.view.id,
1187
- component: this.logic && this.logic.view,
1188
- logic: this.logic,
1189
- status: 'Enabled',
1190
- offset: offsetLine,
1191
- isTemporary: true,
1192
- });
1193
- bp.attachSourceMap();
1194
- this.temporaryBreakPoint = bp;
1195
- return bp;
1196
- }
1197
-
1198
- get breakPoint(): BreakPoint {
1199
- if (this.parent?.type === 'SwitchCase' && this.parentAttr === 'test')
1200
- return this.parent.breakPoint;
1201
-
1202
- return this.breakPoints?.find((bp) => bp.offset === 0);
1203
- }
1204
-
1205
- get hasBreakPoint(): boolean {
1206
- if (this.parent?.type === 'SwitchCase' && this.parentAttr === 'test')
1207
- return this.parent.hasBreakPoint;
1208
-
1209
- return !!(this.temporaryBreakPoint || this.breakPoint);
1210
- }
1211
-
1212
- get isBreakPointEnabled(): boolean {
1213
- if (this.parent?.type === 'SwitchCase' && this.parentAttr === 'test')
1214
- return this.parent.isBreakPointEnabled;
1215
-
1216
- return this.breakPoint?.status === 'Enabled';
1217
- }
1218
-
1219
- get isBreakPointDisabled(): boolean {
1220
- if (this.parent?.type === 'SwitchCase' && this.parentAttr === 'test')
1221
- return this.parent.isBreakPointDisabled;
1222
-
1223
- return this.breakPoint?.status === 'Disabled';
1224
- }
1225
-
1226
- get isBreakPointActive(): boolean {
1227
- if (this.parent?.type === 'SwitchCase' && this.parentAttr === 'test')
1228
- return this.parent.isBreakPointActive;
1229
- if (config.defaultApp.debuggerClient?.currentThread) {
1230
- const bp = this.temporaryBreakPoint || this.breakPoint;
1231
- return bp === config.defaultApp.debuggerClient?.currentThread.breakPoint;
1232
- }
1233
- return false;
1234
- // if (this.temporaryBreakPoint) {
1235
- // return true;
1236
- // }
1237
- // return this.breakPoint === config.defaultApp.debuggerClient?.currentBreakPoint;
1238
- }
1239
-
1240
- async setBreakPoint(offsetLine = 0) {
1241
- const app = config.defaultApp;
1242
- if (app.debuggerClient?.isConnected) {
1243
- const breakPoint = new BreakPoint({
1244
- target: this.logic && this.logic.view ? 'Frontend' : 'Backend',
1245
- logicItem: this,
1246
- logicItemId: this.id,
1247
- componentId: this.logic && this.logic.view && this.logic.view.id,
1248
- component: this.logic && this.logic.view,
1249
- logic: this.logic,
1250
- status: 'Enabled',
1251
- offset: offsetLine,
1252
- });
1253
- const attachResult = breakPoint.attachSourceMap();
1254
- if (attachResult) {
1255
- await app.debuggerClient.setRemoteBreakPoint(breakPoint);
1256
- await this.addBreakPoint(app.id, offsetLine);
1257
- } else {
1258
- this.emit('breakpointattacherror', {
1259
- message: '未在sourceMap中找到'
1260
- });
1261
- }
1262
- } else {
1263
- await this.addBreakPoint(app.id, offsetLine);
1264
- }
1265
- }
1266
-
1267
- async removeBreakPoint(offsetLine = 0) {
1268
- const app = config.defaultApp;
1269
- const breakPoints = this.parent?.type === 'SwitchCase' && this.parentAttr === 'test' ? this.parent.breakPoints : this.breakPoints;
1270
- const breakPoint = breakPoints.find((bp) => bp.offset === offsetLine);
1271
- await app.debuggerClient?.removeRemoteBreakPoint(breakPoint);
1272
- await breakPoint?.remove();
1273
- }
1274
-
1275
- async removeAllBreakPointsOfDescendants() {
1276
- const promises: Array<Promise<void>> = [];
1277
- utils.traverse(({ node }) => {
1278
- if (node.breakPoints?.length > 0) {
1279
- node.breakPoints.forEach((bp) => {
1280
- promises.push(node.removeBreakPoint(bp.offset));
1281
- });
1282
- }
1283
- }, { node: this }, {
1284
- mode: 'anyObject',
1285
- excludedKeySet: this.JSON_EXCLUDED_KEYS,
1286
- });
1287
- await Promise.all(promises);
1288
- }
1289
-
1290
- async disableAllBreakPointsOfDescendants() {
1291
- const promises: Array<Promise<void>> = [];
1292
- utils.traverse(({ node }) => {
1293
- if (node.breakPoints?.length > 0) {
1294
- node.breakPoints.forEach((bp) => {
1295
- promises.push(bp.disable());
1296
- });
1297
- }
1298
- }, { node: this }, {
1299
- mode: 'anyObject',
1300
- excludedKeySet: this.JSON_EXCLUDED_KEYS,
1301
- });
1302
- await Promise.all(promises);
1303
- }
1304
1141
  }
1305
1142
 
1306
1143
  export class LogicNode extends LogicItem {
@@ -1382,8 +1219,6 @@ export class LogicNode extends LogicItem {
1382
1219
  const hasInstantiated = source && source.id && vertexsMap.get(source.id) instanceof LogicNode;
1383
1220
  if (hasInstantiated) {
1384
1221
  console.warn(`LogicNode (${source.id}) 多次实例化`);
1385
- // Object.assign(vertexsMap.get(source.id), source);
1386
- // return vertexsMap.get(source.id) as LogicNode;
1387
1222
  }
1388
1223
 
1389
1224
  source && this.assign(source);
@@ -1436,44 +1271,4 @@ export class ExpressionNode extends LogicItem {
1436
1271
  super();
1437
1272
  source && this.assign(source);
1438
1273
  }
1439
-
1440
- addBreakPoint(appId: string, offsetLine = 0) {
1441
- // let switchParent = this.parent;
1442
- // let switchCase;
1443
- // while (switchParent && switchParent.type !== 'SwitchStatement') {
1444
- // if (switchParent.type === 'SwitchCase') {
1445
- // switchCase = switchParent;
1446
- // }
1447
- // switchParent = switchParent.parent;
1448
- // }
1449
-
1450
- // switchCase 是个 logicNode,直接加好了
1451
- if (this.parent?.type === 'SwitchCase' && this.parentAttr === 'test')
1452
- return this.parent.addBreakPoint(appId, offsetLine);
1453
- // const index = switchParent.cases.findIndex((c) => c === switchCase);
1454
- // const id = switchCase.id;
1455
-
1456
- // const view = this.logic.view;
1457
- // const sourceMap = view.sourceMap;
1458
- // const componentId = view.id;
1459
- // // const id = `${switchParent.id}-case${index}`;
1460
- // const map = sourceMap[id];
1461
- // if (map) {
1462
- // const lineNumberStart = map.from + offsetLine;
1463
- // let bp = this.breakPoints.find((bp) => bp.lineNumberStart === lineNumberStart);
1464
- // if (bp) {
1465
- // return bp;
1466
- // }
1467
- // bp = new BreakPoint({
1468
- // lineNumberStart,
1469
- // logicItem: switchCase,
1470
- // logicItemId: switchCase.id,
1471
- // componentId,
1472
- // });
1473
- // switchCase.breakPoints.push(bp);
1474
- // return bp;
1475
- // }
1476
- // return null;
1477
- return super.addBreakPoint(appId, offsetLine);
1478
- }
1479
1274
  }