@lcap/nasl 0.3.9 → 0.3.10-beta

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 (154) hide show
  1. package/out/service/create/errHandles.js +7 -2
  2. package/out/service/create/errHandles.js.map +1 -1
  3. package/out/service/debugger/debugger.d.ts +3 -0
  4. package/out/service/debugger/debugger.js +95 -0
  5. package/out/service/debugger/debugger.js.map +1 -0
  6. package/out/service/logic/logic.d.ts +27 -0
  7. package/out/service/logic/logic.js +20 -0
  8. package/out/service/logic/logic.js.map +1 -1
  9. package/out/service/page/element.d.ts +9 -0
  10. package/out/service/page/element.js +6 -0
  11. package/out/service/page/element.js.map +1 -1
  12. package/out/service/permission/api.d.ts +57 -0
  13. package/out/service/permission/api.js +41 -0
  14. package/out/service/permission/api.js.map +1 -0
  15. package/out/service/permission/index.d.ts +2 -0
  16. package/out/service/permission/index.js +17 -0
  17. package/out/service/permission/index.js.map +1 -0
  18. package/out/service/webFile/index.js +5 -0
  19. package/out/service/webFile/index.js.map +1 -1
  20. package/out/types/app/App.d.ts +4 -1
  21. package/out/types/app/App.js +24 -0
  22. package/out/types/app/App.js.map +1 -1
  23. package/out/types/app/Service.d.ts +2 -2
  24. package/out/types/app/Service.js +28 -3
  25. package/out/types/app/Service.js.map +1 -1
  26. package/out/types/cache.d.ts +6 -0
  27. package/out/types/cache.js +54 -0
  28. package/out/types/cache.js.map +1 -0
  29. package/out/types/common/Vertex.d.ts +25 -0
  30. package/out/types/common/Vertex.js +40 -0
  31. package/out/types/common/Vertex.js.map +1 -1
  32. package/out/types/data/Entity.js +1 -0
  33. package/out/types/data/Entity.js.map +1 -1
  34. package/out/types/data/Enum.d.ts +5 -0
  35. package/out/types/data/Enum.js +5 -0
  36. package/out/types/data/Enum.js.map +1 -1
  37. package/out/types/data/Interface.js +5 -3
  38. package/out/types/data/Interface.js.map +1 -1
  39. package/out/types/data/genBlock/genCreateBlock.js +5 -5
  40. package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
  41. package/out/types/data/genBlock/genCurdBlock.js +3 -3
  42. package/out/types/data/genBlock/genCurdBlock.js.map +1 -1
  43. package/out/types/data/genBlock/genEnumSelectBlock.d.ts +1 -1
  44. package/out/types/data/genBlock/genEnumSelectBlock.js +2 -2
  45. package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
  46. package/out/types/data/genBlock/genGridViewBlock.js +12 -1
  47. package/out/types/data/genBlock/genGridViewBlock.js.map +1 -1
  48. package/out/types/data/genBlock/genListViewBlock.js +2 -2
  49. package/out/types/data/genBlock/genSelectBlock.js +2 -2
  50. package/out/types/data/genBlock/genTableBlock.js +14 -3
  51. package/out/types/data/genBlock/genTableBlock.js.map +1 -1
  52. package/out/types/data/genBlock/genUpdateBlock.js +5 -5
  53. package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
  54. package/out/types/data/systemTypes.js +47 -0
  55. package/out/types/data/systemTypes.js.map +1 -1
  56. package/out/types/enum.d.ts +6 -0
  57. package/out/types/enum.js +11 -0
  58. package/out/types/enum.js.map +1 -0
  59. package/out/types/generator/hotReload.d.ts +2 -0
  60. package/out/types/generator/hotReload.js +12 -1
  61. package/out/types/generator/hotReload.js.map +1 -1
  62. package/out/types/index.d.ts +7 -1
  63. package/out/types/index.js +11 -2
  64. package/out/types/index.js.map +1 -1
  65. package/out/types/logic/BreakPoint.d.ts +42 -0
  66. package/out/types/logic/BreakPoint.js +155 -0
  67. package/out/types/logic/BreakPoint.js.map +1 -0
  68. package/out/types/logic/Debugger.d.ts +156 -0
  69. package/out/types/logic/Debugger.js +912 -0
  70. package/out/types/logic/Debugger.js.map +1 -0
  71. package/out/types/logic/Logic.d.ts +40 -0
  72. package/out/types/logic/Logic.js +130 -31
  73. package/out/types/logic/Logic.js.map +1 -1
  74. package/out/types/logic/LogicItem.d.ts +21 -1
  75. package/out/types/logic/LogicItem.js +227 -24
  76. package/out/types/logic/LogicItem.js.map +1 -1
  77. package/out/types/logic/Param.d.ts +1 -0
  78. package/out/types/logic/Param.js +38 -20
  79. package/out/types/logic/Param.js.map +1 -1
  80. package/out/types/logic/Return.js +14 -19
  81. package/out/types/logic/Return.js.map +1 -1
  82. package/out/types/logic/Variable.js +14 -19
  83. package/out/types/logic/Variable.js.map +1 -1
  84. package/out/types/logic/translator.js +0 -2
  85. package/out/types/logic/translator.js.map +1 -1
  86. package/out/types/nuims/Nuims.d.ts +1 -1
  87. package/out/types/nuims/Nuims.js +11 -4
  88. package/out/types/nuims/Nuims.js.map +1 -1
  89. package/out/types/page/Element.d.ts +5 -0
  90. package/out/types/page/Element.js +114 -130
  91. package/out/types/page/Element.js.map +1 -1
  92. package/out/types/page/Event.js.map +1 -1
  93. package/out/types/page/Page.d.ts +1 -0
  94. package/out/types/page/Page.js +59 -27
  95. package/out/types/page/Page.js.map +1 -1
  96. package/out/types/page/View.d.ts +17 -3
  97. package/out/types/page/View.js +53 -37
  98. package/out/types/page/View.js.map +1 -1
  99. package/out/types/page/ViewParam.d.ts +1 -0
  100. package/out/types/page/ViewParam.js +23 -4
  101. package/out/types/page/ViewParam.js.map +1 -1
  102. package/out/types/page/ViewVariable.js +13 -18
  103. package/out/types/page/ViewVariable.js.map +1 -1
  104. package/out/types/permission/Permission.d.ts +41 -0
  105. package/out/types/permission/Permission.js +122 -0
  106. package/out/types/permission/Permission.js.map +1 -0
  107. package/package.json +2 -2
  108. package/src/service/create/errHandles.js +6 -2
  109. package/src/service/debugger/debugger.js +90 -0
  110. package/src/service/developPermission/api.js +37 -0
  111. package/src/service/developPermission/index.js +13 -0
  112. package/src/service/logic/logic.js +20 -0
  113. package/src/service/page/element.js +6 -0
  114. package/src/service/permission/api.js +38 -0
  115. package/src/service/permission/index.js +13 -0
  116. package/src/service/webFile/index.js +6 -1
  117. package/src/types/app/App.ts +27 -1
  118. package/src/types/app/Service.ts +32 -3
  119. package/src/types/cache.ts +50 -0
  120. package/src/types/common/Vertex.ts +30 -0
  121. package/src/types/data/Entity.ts +1 -0
  122. package/src/types/data/Enum.ts +5 -0
  123. package/src/types/data/Interface.ts +4 -3
  124. package/src/types/data/genBlock/genCreateBlock.ts +5 -5
  125. package/src/types/data/genBlock/genCurdBlock.ts +3 -3
  126. package/src/types/data/genBlock/genEnumSelectBlock.ts +2 -2
  127. package/src/types/data/genBlock/genGridViewBlock.ts +12 -1
  128. package/src/types/data/genBlock/genListViewBlock.ts +2 -2
  129. package/src/types/data/genBlock/genSelectBlock.ts +2 -2
  130. package/src/types/data/genBlock/genTableBlock.ts +14 -3
  131. package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
  132. package/src/types/data/systemTypes.ts +47 -0
  133. package/src/types/enum.ts +6 -0
  134. package/src/types/generator/hotReload.ts +10 -0
  135. package/src/types/index.ts +7 -1
  136. package/src/types/logic/BreakPoint.ts +200 -0
  137. package/src/types/logic/Debugger.ts +1140 -0
  138. package/src/types/logic/Logic.ts +133 -28
  139. package/src/types/logic/LogicItem.ts +250 -28
  140. package/src/types/logic/Param.ts +26 -8
  141. package/src/types/logic/Return.ts +4 -9
  142. package/src/types/logic/Variable.ts +4 -8
  143. package/src/types/logic/translator.d.ts +16 -0
  144. package/src/types/logic/translator.js +144 -88
  145. package/src/types/logic/translator_backup.js +5 -16
  146. package/src/types/nuims/Nuims.ts +11 -5
  147. package/src/types/page/Element.ts +63 -75
  148. package/src/types/page/Event.ts +0 -3
  149. package/src/types/page/Page.ts +73 -40
  150. package/src/types/page/View.ts +45 -18
  151. package/src/types/page/ViewParam.ts +22 -3
  152. package/src/types/page/ViewVariable.ts +4 -8
  153. package/src/types/permission/Permission.ts +112 -0
  154. package/tsconfig.json +1 -1
@@ -0,0 +1,1140 @@
1
+ const { io } = require('socket.io-client');
2
+ import { Vertex, View, App, Logic, BreakPoint, EventEmitter, vertexsMap, LogicItem, LogicNode, Variable, ViewVariable, Param, ViewParam, Return, FrontEndsourceMap } from '..';
3
+ import { createSocketClient, breakpointService, sourceMapService } from '../../service/debugger/debugger';
4
+
5
+ const LOGIC_BRANCH = ['IfStatement', 'WhileStatement', 'SwitchStatement', 'ForEachStatement'];
6
+ const parentAttrRoot = [undefined, 'consequent', 'alternate', 'cases'];
7
+ function getScopeVariableNames(node: Logic): {
8
+ variables: Array<string>,
9
+ params: Array<string>,
10
+ returns: Array<string>,
11
+ } {
12
+ let variables: Array<Variable|ViewVariable> = [];
13
+ let params: Array<Param|ViewParam> = [];
14
+ let returns: Array<Return> = [];
15
+ if (node?.view) {
16
+ variables = [...node.view.$def.variables];
17
+ params = [...node.view.$def.params];
18
+ }
19
+
20
+ if (node) {
21
+ variables = [...variables, ...node.variables];
22
+ params = [...params, ...node.params];
23
+ returns = [...returns, ...node.returns];
24
+ }
25
+
26
+ return {
27
+ variables: variables.map((v) => v.name),
28
+ params: params.map((p) => p.name),
29
+ returns: returns.map((r) => r.name),
30
+ };
31
+ }
32
+ interface ScopeValue {
33
+ name: string,
34
+ result: {
35
+ type: string,
36
+ value: unknown,
37
+ }
38
+ }
39
+ function matchVariableValue(names: Array<string>, originData: {
40
+ [key: string]: unknown
41
+ }) {
42
+ return names.map((n) => {
43
+ const value = originData[n];
44
+ const type = typeof value;
45
+ return {
46
+ name: n,
47
+ result: {
48
+ type,
49
+ value,
50
+ },
51
+ };
52
+ });
53
+ }
54
+ interface middleBreakPoint {
55
+ componentId: string,
56
+ line: number,
57
+ isTemporary: boolean,
58
+ type: string,
59
+ }
60
+
61
+ function resolveFrontEndTarget(componentId: string, lineNumber: number) {
62
+ const view = Vertex.getVertexByRef(componentId) as View;
63
+ const sourceMap = view.sourceMap;
64
+
65
+ const targets = Object.values(sourceMap).filter((m) => {
66
+ if (m.node?.type === 'JSBlock')
67
+ return lineNumber >= m.from && lineNumber <= m.to;
68
+ else
69
+ return lineNumber === m.from;
70
+ });
71
+ // const arr = targets.map((item) => vertexsMap.get(item.vertexId));
72
+ // let target;
73
+ // for (let i = 0; i < arr.length; i++) {
74
+ // if (!arr[i] || arr.includes(arr[i].parent)) {
75
+ // continue;
76
+ // }
77
+ // target = targets[i];
78
+ // break;
79
+ // }
80
+ // return {
81
+ // ...target,
82
+ // node: Vertex.getVertexByRef(target.vertexId),
83
+ // };
84
+ let target;
85
+ const arr = targets.map((item) => vertexsMap.get(item.node.id) as LogicItem);
86
+ for (let i = 0; i < arr.length; i++) {
87
+ if (!arr[i] || arr.includes(arr[i].parent))
88
+ continue;
89
+
90
+ target = targets[i];
91
+ }
92
+ if (!target) {
93
+ return null;
94
+ }
95
+ return {
96
+ ...target,
97
+ node: Vertex.getVertexByRef(target.node.id) as LogicItem,
98
+ };
99
+ }
100
+
101
+ interface cf {
102
+ componentId: string,
103
+ callFrameId: number,
104
+ line: number,
105
+ invokeLocation: {
106
+ line: number,
107
+ componentId: string
108
+ }
109
+ }
110
+ interface backcf {
111
+ className: string,
112
+ lineNumber: number,
113
+ }
114
+ interface sourceMapFrontObj{
115
+ isLogic: boolean,
116
+ node: LogicItem,
117
+ from: number,
118
+ to: number,
119
+ }
120
+ interface CallFrame{
121
+ target: {
122
+ node: LogicItem | Logic | sourceMapFrontObj,
123
+ },
124
+ invokeItem: LogicItem,
125
+ callFrameId: number,
126
+ className: string,
127
+ lineNumber: number,
128
+ }
129
+
130
+
131
+ function resolveFrontEndCallFrame(callFrames: Array<cf>, currentBreakTarget: sourceMapFrontObj): Array<Partial<CallFrame> | Partial<cf>> {
132
+ const functionStack = callFrames.map((cf) => {
133
+ const view = Vertex.getVertexByRef(cf.componentId) as View;
134
+ const sourceMap = view.sourceMap;
135
+ const target = Object.values(sourceMap).find((m) => cf.line >= m.from && cf.line <= m.to && m.isLogic);
136
+
137
+ // const viewInvoke = Vertex.getVertexByRef(cf.componentId);
138
+ // const sourceMapInvoke = view.sourceMap;
139
+ const invokeItem = Object.values(sourceMap).find((m) => m.from === cf.invokeLocation.line && m.node.type === 'CallLogic');
140
+
141
+ return {
142
+ ...cf,
143
+ target,
144
+ invokeItem,
145
+ };
146
+ });
147
+
148
+ return [{
149
+ target: currentBreakTarget,
150
+ }, ...functionStack];
151
+ }
152
+
153
+ function resolveCallFrameSimple(callFrames: Array<Partial<cf>>) : Array<Partial<CallFrame> | Partial<cf> | Partial<backcf>> {
154
+ return callFrames.map((cf) => {
155
+ const view = Vertex.getVertexByRef(cf.componentId) as View;
156
+ const sourceMap = view.sourceMap;
157
+ // const target = Object.values(sourceMap).find((m) => cf.line >= m.from && cf.line <= m.to && m.isLogic);
158
+ const target = Object.values(sourceMap).find((m) => m.from === cf.line && m.node.type === 'CallLogic');
159
+ return {
160
+ ...cf,
161
+ target,
162
+ };
163
+ });
164
+ }
165
+ class SocketEvent extends EventEmitter {
166
+ public app: App;
167
+ public debuggerClient: any = null;
168
+
169
+ // emitSocket(eventName: string, payload: any) {
170
+ // this.debuggerClient.emit('debug', {
171
+ // event: eventName,
172
+ // payload,
173
+ // });
174
+ // }
175
+
176
+ emitSocket(payload: any) {
177
+ this.debuggerClient.emit('debug', payload);
178
+ }
179
+ }
180
+ interface FrontEndResponsePayload {
181
+ code: number,
182
+ data: {
183
+ result: {
184
+ value: unknown
185
+ },
186
+ sourceCodeId: string,
187
+ id: string,
188
+ breakpointId: string,
189
+ requestId: string,
190
+ callFramesResolved: Array<cf>,
191
+ location: {
192
+ componentId: string,
193
+ line: number,
194
+ }
195
+ },
196
+ }
197
+ interface FrontEndResponse {
198
+ event: string,
199
+ payload: FrontEndResponsePayload
200
+ }
201
+ const FrontEndProtocol = {
202
+ setbreakpoint(bp: BreakPoint) {
203
+ return {
204
+ target: 'Frontend',
205
+ event: 'setbreakpoint',
206
+ payload: {
207
+ componentId: bp.componentId,
208
+ line: bp.lineNumberStart,
209
+ id: bp._uuid,
210
+ isTemporary: bp.isTemporary,
211
+ },
212
+ };
213
+ },
214
+ removeBreakpoint(bp: BreakPoint) {
215
+ return {
216
+ target: 'Frontend',
217
+ event: 'removeBreakpoint',
218
+ payload: {
219
+ breakpointId: bp.remoteBreakpointId,
220
+ id: bp._uuid,
221
+ },
222
+ };
223
+ },
224
+ breakPointReceived() {
225
+ return {
226
+ target: 'Frontend',
227
+ event: 'breakPointReceived',
228
+ };
229
+ },
230
+ step(posibleBps: Array<middleBreakPoint>) {
231
+ return {
232
+ target: 'Frontend',
233
+ event: 'step',
234
+ payload: {
235
+ posibleBps,
236
+ },
237
+ };
238
+ },
239
+ resume() {
240
+ return {
241
+ target: 'Frontend',
242
+ event: 'resume',
243
+ };
244
+ },
245
+
246
+ normalizeResponse(data: FrontEndResponse) {
247
+ if (data.event) {
248
+ return {
249
+ event: data.event,
250
+ payload: data.payload,
251
+ source: 'Frontend',
252
+ };
253
+ }
254
+ return null;
255
+ },
256
+ evaluatescope(payload: {
257
+ callFrameId: number,
258
+ variables: Array<string>,
259
+ params: Array<string>,
260
+ returns: Array<string>,
261
+ }) {
262
+ return {
263
+ target: 'Frontend',
264
+ event: 'evaluatescope',
265
+ payload,
266
+ };
267
+ },
268
+
269
+ evaluate(payload: {
270
+ callFrameId: number,
271
+ expression: string,
272
+ }) {
273
+ return {
274
+ target: 'Frontend',
275
+ event: 'evaluate',
276
+ payload,
277
+ };
278
+ },
279
+ };
280
+ interface BackendResponseData {
281
+ status: string,
282
+ name: string,
283
+ threadId: string,
284
+ requestId: string,
285
+ className: string,
286
+ lineNumber: number,
287
+ stackFrames: { className: string, lineNumber: number }[],
288
+ variables: { [key: string]: unknown },
289
+ }
290
+ interface BackEndResponse {
291
+ type: string,
292
+ message: string,
293
+ data: BackendResponseData,
294
+ }
295
+
296
+ interface BackendSourceMapResponse {
297
+ vertexMap: {
298
+ [id: string]: {
299
+ classIdentify: string,
300
+ from: number,
301
+ lineFrom: number,
302
+ end: number,
303
+ vertexId: string,
304
+ }
305
+ },
306
+ logicIdClassMap: {
307
+ [id: string]: string
308
+ },
309
+ classLogicIdMap: {
310
+ [id: string]: string
311
+ }
312
+ }
313
+ const BackEndProtocol = {
314
+ setbreakpoint(bp: BreakPoint) {
315
+ return {
316
+ target: 'Backend',
317
+ operation: {
318
+ appId: bp.appId,
319
+ className: bp.classIdentify,
320
+ lineNumber: bp.lineNumberStart,
321
+ eventType: 'BREAKPOINT',
322
+ breakpointStatus: 'ENABLED',
323
+ },
324
+ };
325
+ },
326
+
327
+ removeBreakpoint(bp: BreakPoint) {
328
+ return {
329
+ target: 'Backend',
330
+ operation: {
331
+ appId: bp.appId,
332
+ className: bp.classIdentify,
333
+ lineNumber: bp.lineNumberStart,
334
+ eventType: 'BREAKPOINT',
335
+ breakpointStatus: 'DELETED',
336
+ },
337
+ };
338
+ },
339
+ resume(appid: string, threadId: string) {
340
+ return {
341
+ target: 'Backend',
342
+ operation: {
343
+ appId: appid,
344
+ eventType: 'RESUME',
345
+ threadId,
346
+ },
347
+ };
348
+ },
349
+ step(appid: string, threadId: string) {
350
+ return {
351
+ target: 'Backend',
352
+ operation: {
353
+ appId: appid,
354
+ eventType: 'STEP_OVER',
355
+ threadId,
356
+ },
357
+ };
358
+ },
359
+ normalizeResponse(data: BackEndResponse) {
360
+ switch (data.type) {
361
+ case 'DebugInfo':
362
+ return {
363
+ event: 'paused',
364
+ payload: data.data,
365
+ source: 'Backend',
366
+ };
367
+ case 'ConnectionInfo':
368
+ return {
369
+ event: 'connection',
370
+ payload: data.data,
371
+ source: 'Backend',
372
+ };
373
+ case 'ExceptionInfo':
374
+ return {
375
+ event: 'exception',
376
+ payload: data.message,
377
+ source: 'Backend',
378
+ };
379
+
380
+ default:
381
+ return null;
382
+ }
383
+ },
384
+ };
385
+
386
+ interface Thread {
387
+ id: string,
388
+ requestId: string,
389
+ frontendStack: Array<Partial<cf>>;
390
+ callFrameId: number;
391
+ breakPoint: BreakPoint;
392
+ evaluateValue: {[id:string]: unknown};
393
+ callFrames: Array<Partial<CallFrame>>;
394
+ callFrameScope: Array<{
395
+ variables: Array<ScopeValue>,
396
+ params: Array<ScopeValue>,
397
+ returns: Array<ScopeValue>,
398
+ }>;
399
+ evaluateExpression: string,
400
+ }
401
+ export class Debugger extends EventEmitter {
402
+ public app: App;
403
+ public debuggerClient: any = null;
404
+ public currentThread: Partial<Thread> = null;
405
+ public threads: Array<Partial<Thread>> = [];
406
+ public currentFrontEndThread: Thread = null;
407
+
408
+ // 以下为前端单独使用的断点状态,断点状态唯一
409
+
410
+ public socketEventEmitter: SocketEvent;
411
+
412
+ public frontendConnection: boolean = false;
413
+ public backendConnection: boolean = false;
414
+ public ideConnection: boolean = false;
415
+
416
+ public breakPoints: Array<BreakPoint> = [];
417
+ public temporaryBreakPoint: BreakPoint = null;
418
+ private temporaryBreakPointTriggered = false;
419
+
420
+ public logicIdClassMap: {[id: string]: string} = {};
421
+ public classLogicIdMap: {[id: string]: string} = {};
422
+
423
+ public booting: boolean = false;
424
+
425
+ public temporaryLogicCallStack: {
426
+ callFramesResolved: Array<Partial<cf>>
427
+ }; // 把临时的调用栈缓存起来,后端调用逻辑断点时,做调用栈拼接
428
+
429
+ get isConnected() {
430
+ // return this.frontendConnection;
431
+ // return this.backendConnection;
432
+ return this.frontendConnection && this.backendConnection;
433
+ }
434
+
435
+ get isBreak() {
436
+ return (this.currentThread && this.currentThread.breakPoint);
437
+ }
438
+
439
+ get isInFrontendThread() {
440
+ return this.currentFrontEndThread === this.currentThread;
441
+ }
442
+
443
+ constructor() {
444
+ super();
445
+ this.on('backendConnected', this.onConnectionEnd.bind(this));
446
+ this.on('frontendConnected', this.onConnectionEnd.bind(this));
447
+ }
448
+
449
+ public async closeConnect() {
450
+ if (this.debuggerClient) {
451
+ await new Promise((resolve) => {
452
+ this.debuggerClient.on('disconnect', (reason: string) => {
453
+ if (reason === 'io client disconnect') {
454
+ this.debuggerClient = null;
455
+ this.frontendConnection = false;
456
+ this.backendConnection = false;
457
+ this.ideConnection = false;
458
+ resolve('closed');
459
+ }
460
+ });
461
+ this.debuggerClient.disconnect();
462
+ });
463
+ }
464
+ }
465
+
466
+ public async boot() {
467
+ try {
468
+ if (this.debuggerClient) {
469
+ return;
470
+ }
471
+ this.ideConnection = false;
472
+ this.debuggerClient = await createSocketClient(this.app.appId);
473
+ this.ideConnection = true;
474
+ this.socketEventEmitter = new SocketEvent();
475
+ this.socketEventEmitter.debuggerClient = this.debuggerClient;
476
+ // this.debuggerClient.emit('debug', { source: 'ide' });
477
+
478
+ this.debuggerClient.on('debug', (data: FrontEndResponse | BackEndResponse) => {
479
+ if (typeof data === 'object') {
480
+ const {
481
+ event,
482
+ payload,
483
+ source,
484
+ } = FrontEndProtocol.normalizeResponse(data as FrontEndResponse) || BackEndProtocol.normalizeResponse(data as BackEndResponse);
485
+ this.socketEventEmitter.emit(event, payload, source);
486
+ }
487
+ });
488
+ this.socketEventEmitter.on('getBreakPoint', this.onFetchBreakPoint.bind(this));
489
+ this.socketEventEmitter.on('connection', this.onConnection.bind(this));
490
+
491
+ this.socketEventEmitter.on('breakpointsettle', this.onBreakPointSettle.bind(this));
492
+
493
+ this.socketEventEmitter.on('removeBreakpointsettle', this.onRemoveBreakpointsettle.bind(this));
494
+
495
+ this.socketEventEmitter.on('paused', this.onPaused.bind(this));
496
+
497
+ this.socketEventEmitter.on('evaluateresult', this.onEvaluateResult.bind(this));
498
+
499
+ this.socketEventEmitter.on('evaluatescoperesult', ({ code, data }) => {
500
+ if (code !== 200) {
501
+ return;
502
+ }
503
+ // const result = data.result.value;
504
+ this.currentFrontEndThread.callFrameScope = data;
505
+ });
506
+ this.socketEventEmitter.on('logictrace', this.onLogicTrace.bind(this));
507
+ this.socketEventEmitter.on('logictraceend', this.onLogicTraceEnd.bind(this));
508
+ this.socketEventEmitter.on('exception', this.onBackEndException.bind(this));
509
+ } catch (err) {
510
+ console.error(err);
511
+ throw '连接失败';
512
+ }
513
+ }
514
+ /*combineCallFrameScope(data) {
515
+ const {
516
+ variables,
517
+ params,
518
+ returns,
519
+ } = data;
520
+
521
+ const {
522
+ variables: currVariable,
523
+ params: currParams,
524
+ returns: currReturns,
525
+ } = this.currentCallFrameScope;
526
+ function comparePart(part, oldpart) {
527
+ const list
528
+ = part.forEach(({ name, result }) => {
529
+ if (result.subtype === 'error') {
530
+ return oldpart.find((v) => v.name === name);
531
+ }
532
+ });
533
+ }
534
+ }*/
535
+
536
+ resetState() {
537
+ this.currentThread = null;
538
+ this.threads = [];
539
+ this.currentFrontEndThread = null;
540
+ this.temporaryBreakPoint = null;
541
+ this.temporaryBreakPointTriggered = false;
542
+ }
543
+
544
+ async onFetchBreakPoint(data: Partial<FrontEndResponsePayload>) {
545
+ const componentId = data.data.sourceCodeId;
546
+ const promises: Array<Promise<BreakPoint>> = [];
547
+ this.breakPoints.forEach((bp) => {
548
+ if (bp.status === 'Enabled' && bp.componentId === componentId) {
549
+ const attachResult = bp.attachSourceMap();
550
+ if (attachResult) {
551
+ promises.push(this.setRemoteBreakPointRoundTrip(bp));
552
+ }
553
+ }
554
+ });
555
+ await Promise.all(promises);
556
+ this.socketEventEmitter.emitSocket(FrontEndProtocol.breakPointReceived());
557
+ }
558
+
559
+ onBreakPointSettle(data: Partial<FrontEndResponsePayload>) {
560
+ // if(!data.data || !data.data.id) {
561
+ // bp.emit('bpsettled', false);
562
+ // return;
563
+ // }
564
+ const bpid = data.data.id;
565
+ const bp = this.breakPoints.find((bp) => bp._uuid === bpid) || this.temporaryBreakPoint;
566
+ if (data.code !== 200) {
567
+ bp.emit('bpsettled', false);
568
+ return;
569
+ }
570
+ if (bp) {
571
+ bp.remoteBreakpointId = data.data.breakpointId;
572
+ bp.emit('bpsettled', true);
573
+ }
574
+ }
575
+ onRemoveBreakpointsettle(data: FrontEndResponsePayload) {
576
+ const bpid = data.data.id;
577
+ const bp = this.breakPoints.find((bp) => bp._uuid === bpid);
578
+ bp.emit('bpremoved');
579
+ }
580
+
581
+ async onConnection(data: Partial<FrontEndResponsePayload> | Partial<BackendResponseData>, source: string) {
582
+ if (source === 'Frontend') {
583
+ this.onFrontEndConnection(data as Partial<FrontEndResponsePayload>);
584
+ }
585
+ if (source === 'Backend') {
586
+ await this.onBackEndConnection(data as Partial<BackendResponseData>);
587
+ }
588
+ }
589
+
590
+ onFrontEndConnection(data: Partial<FrontEndResponsePayload>) {
591
+ if (data.code === 200) {
592
+ this.frontendConnection = true;
593
+
594
+ const currentRequestId = data.data.requestId;
595
+ const idx = this.threads.findIndex((t) => t === this.currentFrontEndThread);
596
+ ~idx && this.threads.splice(idx, 1);
597
+ this.currentFrontEndThread = {
598
+ id: null,
599
+ requestId: currentRequestId,
600
+ frontendStack: null,
601
+ callFrameId: null,
602
+ breakPoint: null,
603
+ evaluateExpression: null,
604
+ evaluateValue: null,
605
+ callFrames: null,
606
+ callFrameScope: null,
607
+ };
608
+ this.threads.unshift(this.currentFrontEndThread);
609
+ this.emit('frontendConnected');
610
+ } else {
611
+ this.frontendConnection = false;
612
+ this.emit('frontendConnectionFailed');
613
+ }
614
+ }
615
+
616
+ async onBackEndConnection(data: Partial<BackendResponseData>) {
617
+ if (data.status === 'Connected') {
618
+ await this.loadBackEndSourceMap();
619
+ this.backendConnection = true;
620
+ this.emit('backendConnected');
621
+ } else {
622
+ if (data.name === 'Frontend') {
623
+ this.frontendConnection = false;
624
+ this.emit('frontendConnectionFailed');
625
+ } else {
626
+ this.backendConnection = false;
627
+ this.emit('backendConnectionFailed');
628
+ }
629
+ }
630
+ }
631
+
632
+ async loadBackEndSourceMap() {
633
+ const response = await sourceMapService.getSourceMap({
634
+ query: {
635
+ appId: this.app.firstMicroService.id,
636
+ },
637
+ }) as BackendSourceMapResponse;
638
+ const {
639
+ vertexMap,
640
+ logicIdClassMap,
641
+ classLogicIdMap,
642
+ } = response;
643
+ this.logicIdClassMap = logicIdClassMap || {};
644
+ this.classLogicIdMap = classLogicIdMap || {};
645
+ const map = Object.values(vertexMap || {});
646
+ Object.keys(this.logicIdClassMap).forEach((logicId) => {
647
+ const classname = this.logicIdClassMap[logicId];
648
+ const logic = Vertex.getVertexByRef(logicId) as Logic;
649
+ const sourcemap: {
650
+ [id: string]: {
651
+ classIdentify: string,
652
+ from: number,
653
+ lineFrom: number,
654
+ end: number
655
+ }
656
+ } = {};
657
+ map.forEach((m) => {
658
+ if (m.classIdentify === classname) {
659
+ sourcemap[m.vertexId] = m;
660
+ }
661
+ });
662
+ logic.sourceMap = sourcemap;
663
+ });
664
+ }
665
+
666
+ onConnectionEnd() {
667
+ // if (this.isConnected) {
668
+ // this.breakPoints.forEach((bp) => {
669
+ // if (bp.status === 'Enabled') {
670
+ // const attachResult = bp.attachSourceMap();
671
+ // if (attachResult) {
672
+ // this.setRemoteBreakPointRoundTrip(bp);
673
+ // }
674
+ // }
675
+ // });
676
+ // }
677
+ }
678
+
679
+ onLogicTrace(data: Partial<FrontEndResponsePayload>) {
680
+ this.temporaryLogicCallStack = data.data;
681
+ }
682
+
683
+ onLogicTraceEnd() {
684
+ // 跳出后端逻辑
685
+ this.currentFrontEndThread.frontendStack = null;
686
+ this.currentFrontEndThread.id = null;
687
+ }
688
+
689
+ onPaused(data: Partial<FrontEndResponsePayload> | Partial<BackendResponseData>, source: string) {
690
+ if (source === 'Frontend') {
691
+ this.onFrontEndPaused(data as Partial<FrontEndResponsePayload>);
692
+ }
693
+ if (source === 'Backend') {
694
+ this.onBackEndPaused(data as Partial<BackendResponseData>);
695
+ }
696
+ }
697
+
698
+ onFrontEndPaused({ code, data }: Partial<FrontEndResponsePayload>) {
699
+ if (code !== 200) {
700
+ return;
701
+ }
702
+ // const requestId = data.requestId;
703
+ const location = data.location;
704
+ // const isTemporaryBreakPoint = data.isTemporaryBreakPoint;
705
+ // const callFrames = data.payload.callFrames;
706
+
707
+ const target = resolveFrontEndTarget(location.componentId, location.line);
708
+ // const view = Vertex.getVertexByRef(location.componentId);
709
+ // const sourceMap = view.sourceMap;
710
+ // const targets = Object.values(sourceMap).filter((m) => {
711
+ // if (m.node?.type === 'JSBlock')
712
+ // return location.line >= m.from && location.line <= m.to;
713
+ // else
714
+ // return location.line === m.from && m.node?.level === 'logicNode';
715
+ // });
716
+ // function getTarget(targets) {
717
+ // const arr = targets.map((item) => vertexsMap.get(item.node.id));
718
+ // for (let i = 0; i < arr.length; i++) {
719
+ // if (!arr[i] || arr.includes(arr[i].parent))
720
+ // continue;
721
+
722
+ // return targets[i];
723
+ // }
724
+ // }
725
+ // const target = getTarget(targets);
726
+ if (target) {
727
+ const currentFrontEndThread = this.currentFrontEndThread;
728
+ const logicItem = target.node;
729
+
730
+ let breakPoint = logicItem.getBreakPointByLineNumber(location.line);
731
+ if (!breakPoint) {
732
+ breakPoint = logicItem.addTemperaryBreakPoint();
733
+ this.temporaryBreakPoint = breakPoint;
734
+ this.temporaryBreakPointTriggered = true;
735
+ }
736
+ currentFrontEndThread.breakPoint = breakPoint;// isTemporaryBreakPoint ? this.temporaryBreakPoint : ;
737
+
738
+ const callframes = resolveFrontEndCallFrame(data.callFramesResolved, target);
739
+ currentFrontEndThread.callFrames = callframes;
740
+ const currentCallFrame = callframes[1];
741
+ const logic = logicItem.logic;
742
+ const frameVariables = getScopeVariableNames(logic);
743
+ this.socketEventEmitter.emitSocket(FrontEndProtocol.evaluatescope(Object.assign({}, frameVariables, {
744
+ callFrameId: currentCallFrame.callFrameId,
745
+ })));
746
+ currentFrontEndThread.callFrameId = currentCallFrame.callFrameId;
747
+
748
+ logicItem.folded = false;
749
+ this.app.emit('openLogicItem', logicItem);
750
+ this.app.emit('openDebugger');
751
+ this.currentThread = currentFrontEndThread;
752
+ }
753
+ }
754
+
755
+ async resolveBackEndTarget(className: string, lineNumber: number) {
756
+ const logicId = this.classLogicIdMap[className];
757
+ const logic = Vertex.getVertexByRef(logicId) as Logic;
758
+
759
+ const sourceMap = logic.sourceMap;
760
+ const targets = Object.values(sourceMap).filter((m) => lineNumber === m.lineFrom);
761
+ const arr = await Promise.all(targets.map(async (item) => {
762
+ const p = vertexsMap.get(item.vertexId) as LogicItem;
763
+ if (!p) {
764
+ const logic = Vertex.getVertexByRef(item.logicId) as Logic;
765
+ await logic.load();
766
+ return vertexsMap.get(item.vertexId) as LogicItem;
767
+ }
768
+ return p;
769
+ }));
770
+ let target;
771
+ for (let i = 0; i < arr.length; i++) {
772
+ if (!arr[i] || arr.includes(arr[i].parent)) {
773
+ continue;
774
+ }
775
+ target = targets[i];
776
+ break;
777
+ }
778
+ return {
779
+ ...target,
780
+ node: Vertex.getVertexByRef(target.vertexId) as LogicItem,
781
+ };
782
+ }
783
+
784
+ async onBackEndPaused(data: Partial<BackendResponseData>) {
785
+ const {
786
+ threadId,
787
+ requestId: backReqId,
788
+ className,
789
+ lineNumber,
790
+ stackFrames,
791
+ variables,
792
+ } = data;
793
+
794
+ const target = await this.resolveBackEndTarget(className, lineNumber);
795
+ if (target) {
796
+ const logicItem = Vertex.getVertexByRef(target.vertexId) as LogicItem;
797
+ let breakPoint = logicItem.getBreakPointByLineNumber(lineNumber);
798
+ if (!breakPoint) {
799
+ breakPoint = logicItem.addTemperaryBreakPoint();
800
+ this.temporaryBreakPoint = breakPoint;
801
+ this.temporaryBreakPointTriggered = true;
802
+ }
803
+
804
+ let threadCurrent;
805
+ if (this.currentFrontEndThread.requestId === backReqId) {
806
+ threadCurrent = this.currentFrontEndThread;
807
+ if (threadCurrent.id !== threadId) {
808
+ Object.assign(this.currentFrontEndThread, {
809
+ id: threadId,
810
+ frontendStack: this.temporaryLogicCallStack?.callFramesResolved,
811
+ });
812
+ }
813
+ } else {
814
+ threadCurrent = this.threads.find((t) => t.id === threadId);
815
+ if (!threadCurrent) {
816
+ threadCurrent = {
817
+ id: threadId,
818
+ frontendStack: null,
819
+ breakPoint: null,
820
+ evaluateValue: null,
821
+ callFrames: null,
822
+ callFrameScope: null,
823
+ };
824
+ this.threads.push(threadCurrent);
825
+ }
826
+ }
827
+
828
+ // TODO resolve frames and scope
829
+ let callFrames: Array<Partial<CallFrame>> = await Promise.all(stackFrames.map(async (cf) => {
830
+ const {
831
+ className,
832
+ lineNumber,
833
+ } = cf;
834
+ const target = await this.resolveBackEndTarget(className, lineNumber);
835
+ return {
836
+ ...cf,
837
+ target,
838
+ };
839
+ }));
840
+ const frontendStack = threadCurrent.frontendStack;
841
+ if (frontendStack) {
842
+ callFrames = callFrames.concat(resolveCallFrameSimple(frontendStack));
843
+ }
844
+ const logic = logicItem.logic;
845
+ const frameVariables = getScopeVariableNames(logic);
846
+
847
+ const callFrameScope = {
848
+ variables: matchVariableValue(frameVariables.variables, variables),
849
+ params: matchVariableValue(frameVariables.params, variables),
850
+ returns: matchVariableValue(frameVariables.returns, variables),
851
+ };
852
+
853
+ Object.assign(threadCurrent, {
854
+ breakPoint,
855
+ evaluateValue: null,
856
+ callFrames,
857
+ callFrameScope,
858
+ });
859
+ this.currentThread = threadCurrent;
860
+
861
+ this.app.emit('openLogicItem', logicItem);
862
+ this.app.emit('openDebugger');
863
+ }
864
+ }
865
+
866
+ onBackEndException(data: BackendResponseData) {
867
+
868
+ }
869
+
870
+ onEvaluateResult({ code, data }: FrontEndResponsePayload) {
871
+ if (code !== 200) {
872
+ return;
873
+ }
874
+ const result = data.result.value;
875
+ const currentFrontEndThread = this.currentFrontEndThread;
876
+ currentFrontEndThread.evaluateValue = {
877
+ [currentFrontEndThread.evaluateExpression]: result,
878
+ };
879
+ }
880
+
881
+ evaluateExpression(expression: string) {
882
+ const currentFrontEndThread = this.currentFrontEndThread;
883
+ currentFrontEndThread.evaluateExpression = expression;
884
+ this.socketEventEmitter.emitSocket(FrontEndProtocol.evaluate({
885
+ callFrameId: currentFrontEndThread.callFrameId,
886
+ expression,
887
+ }));
888
+ }
889
+
890
+ async setRemoteBreakPoint(bp: BreakPoint) {
891
+ if (bp.isTemporary) {
892
+ this.temporaryBreakPoint = bp;
893
+ }
894
+ await this.setRemoteBreakPointRoundTrip(bp);
895
+ }
896
+
897
+ async removeAllBreakPoint() {
898
+ await breakpointService.removeAllBreakPoints({
899
+ query: {
900
+ appId: this.app.id,
901
+ },
902
+ });
903
+
904
+ await Promise.all(this.breakPoints.map(async (bp) => {
905
+ if (this.isConnected) {
906
+ await this.removeRemoteBreakPointRoundTrip(bp);
907
+ }
908
+ bp.removeOnLogicItem();
909
+ }));
910
+
911
+ this.breakPoints = [];
912
+ }
913
+
914
+ async enableAllBreakPoint() {
915
+ await breakpointService.updateAllBreakPointState({
916
+ query: {
917
+ appId: this.app.id,
918
+ status: 'Enabled',
919
+ },
920
+ });
921
+
922
+ await Promise.all(this.breakPoints.map(async (bp) => {
923
+ if (this.isConnected && bp.status === 'Disabled') {
924
+ await this.setRemoteBreakPointRoundTrip(bp);
925
+ }
926
+ bp.status = 'Enabled';
927
+ }));
928
+ }
929
+
930
+ async disableAllBreakPoint() {
931
+ await breakpointService.updateAllBreakPointState({
932
+ query: {
933
+ appId: this.app.id,
934
+ status: 'Disabled',
935
+ },
936
+ });
937
+
938
+ await Promise.all(this.breakPoints.map(async (bp) => {
939
+ if (this.isConnected && bp.status === 'Enabled') {
940
+ await this.removeRemoteBreakPointRoundTrip(bp);
941
+ }
942
+ bp.status = 'Disabled';
943
+ }));
944
+ }
945
+
946
+ async removeRemoteBreakPoint(bp: BreakPoint) {
947
+ const index = this.breakPoints.findIndex((b) => b === bp);
948
+ if (index !== -1) {
949
+ if (this.isConnected) {
950
+ await this.removeRemoteBreakPointRoundTrip(bp);
951
+ }
952
+ this.breakPoints.splice(index, 1);
953
+ }
954
+ }
955
+
956
+ async removeRemoteBreakPointRoundTrip(bp: BreakPoint) {
957
+ await new Promise((resolve) => {
958
+ let payload;
959
+ if (bp.target === 'Frontend') {
960
+ payload = FrontEndProtocol.removeBreakpoint(bp);
961
+ bp.once('bpremoved', () => {
962
+ resolve(bp);
963
+ });
964
+ }
965
+ if (bp.target === 'Backend') {
966
+ payload = BackEndProtocol.removeBreakpoint(bp);
967
+ resolve(bp);
968
+ }
969
+
970
+ this.socketEventEmitter.emitSocket(payload);
971
+ });
972
+ }
973
+
974
+ async setRemoteBreakPointRoundTrip(bp: BreakPoint) {
975
+ const result = await new Promise<BreakPoint>((resolve) => {
976
+ let payload;
977
+ if (bp.target === 'Frontend') {
978
+ payload = FrontEndProtocol.setbreakpoint(bp);
979
+ bp.once('bpsettled', () => {
980
+ resolve(bp);
981
+ });
982
+ }
983
+ if (bp.target === 'Backend') {
984
+ payload = BackEndProtocol.setbreakpoint(bp);
985
+ resolve(bp);
986
+ }
987
+ this.socketEventEmitter.emitSocket(payload);
988
+ });
989
+ return result;
990
+ }
991
+
992
+ async step() {
993
+ if (!this.isBreak) {
994
+ return;
995
+ }
996
+ this.resetTemporaryBreakPoint();
997
+ if (this.currentThread) {
998
+ // 后端
999
+ if (this.currentThread === this.currentFrontEndThread && !this.currentThread.id) {
1000
+ const thread = this.currentThread;
1001
+ const logicitem = thread.breakPoint.logicItem;
1002
+ const logic = logicitem.logic;
1003
+ const componentId = logic.view.id;
1004
+ const sourceMap = logic.view.sourceMap;
1005
+ const breakpointTemporary: Array<middleBreakPoint> = [];
1006
+ function addBp(logicItem: LogicItem) {
1007
+ breakpointTemporary.push({
1008
+ componentId,
1009
+ line: sourceMap[logicItem.id].from,
1010
+ isTemporary: true,
1011
+ type: logicitem.type,
1012
+ });
1013
+ }
1014
+ function searchLogicItemPosibleBreakPoint(logicItem: LogicNode) {
1015
+ const type = logicItem.type;
1016
+ if (logicItem.level !== 'logicNode') {
1017
+ return;
1018
+ }
1019
+ if (LOGIC_BRANCH.includes(type)) {
1020
+ if (type === 'IfStatement') {
1021
+ addBp(logicItem);
1022
+ (logicItem.consequent || []).forEach(searchLogicItemPosibleBreakPoint);
1023
+ (logicItem.alternate || []).forEach(searchLogicItemPosibleBreakPoint);
1024
+ }
1025
+ if (type === 'WhileStatement') {
1026
+ addBp(logicItem);
1027
+ (logicItem.body || []).forEach(searchLogicItemPosibleBreakPoint);
1028
+ }
1029
+ if (type === 'SwitchStatement') {
1030
+ addBp(logicItem);
1031
+ const l = (logicItem.cases || []).length - 1;
1032
+ (logicItem.cases || []).forEach((c: LogicNode, idx: number) => {
1033
+ if (idx !== l) {
1034
+ searchLogicItemPosibleBreakPoint(c);
1035
+ }
1036
+ (c.consequent || []).forEach(searchLogicItemPosibleBreakPoint);
1037
+ (c.alternate || []).forEach(searchLogicItemPosibleBreakPoint);
1038
+ });
1039
+ }
1040
+ if (type === 'ForEachStatement') {
1041
+ addBp(logicItem);
1042
+ (logicItem.body || []).forEach(searchLogicItemPosibleBreakPoint);
1043
+ }
1044
+ } else {
1045
+ if (logicItem.hasBreakPoint && logicItem.breakPoint && logicItem.breakPoint.status === 'Enabled') {
1046
+ return;
1047
+ }
1048
+ addBp(logicItem);
1049
+ }
1050
+ }
1051
+ logic.body.forEach(searchLogicItemPosibleBreakPoint);
1052
+ this.socketEventEmitter.emitSocket(FrontEndProtocol.step(breakpointTemporary));
1053
+ // const index = logicitem.logic.body.findIndex((l) => l === logicitem);
1054
+ // const nextLogicItem = logicitem.logic.body[index + 1];
1055
+ // if (nextLogicItem && nextLogicItem.type !== 'End') {
1056
+ // const breakPoint = nextLogicItem.addTemperaryBreakPoint();
1057
+ // await this.setRemoteBreakPoint(breakPoint);
1058
+ // this.resume();
1059
+ // }
1060
+ } else {
1061
+ this.socketEventEmitter.emitSocket(BackEndProtocol.step(this.app.id, this.currentThread.id));
1062
+ }
1063
+ }
1064
+ }
1065
+
1066
+ async stepInto() {
1067
+ // TODO
1068
+ // if (!this.currentBreakPoint) {
1069
+ // return;
1070
+ // }
1071
+ // this.resetTemporaryBreakPoint();
1072
+ // const logicitem = this.currentBreakPoint.logicItem;
1073
+ // if (logicitem.type === 'CallLogic' && logicitem.callee) {
1074
+ // const logicId = logicitem.callee.split('/').pop();
1075
+ // const logic = Vertex.getVertexByRef(logicId);
1076
+ // const logicItem = logic.body[1];
1077
+ // const breakPoint = logicItem.addTemperaryBreakPoint();
1078
+ // await this.setRemoteBreakPoint(breakPoint);
1079
+ // this.resume();
1080
+ // }
1081
+ }
1082
+
1083
+ async stepOut() {
1084
+ // TODO
1085
+ // if (!this.currentBreakPoint) {
1086
+ // return;
1087
+ // }
1088
+ // if (this.currentCallFrames.length < 2) {
1089
+ // return;
1090
+ // }
1091
+ // this.resetTemporaryBreakPoint();
1092
+ // const callFrame = this.currentCallFrames[1];
1093
+ // const invokeLogicNode = callFrame.invokeItem.node;
1094
+ // const logicItem = Vertex.getVertexByRef(invokeLogicNode.id);
1095
+ // const invokeLogic = logicItem.logic;
1096
+ // const idx = invokeLogic.body.findIndex((i) => i === logicItem);
1097
+ // const nextItem = invokeLogic.body[idx + 1];
1098
+ // if (nextItem && nextItem.type !== 'End') {
1099
+ // const breakPoint = nextItem.addTemperaryBreakPoint();
1100
+ // await this.setRemoteBreakPoint(breakPoint);
1101
+ // this.resume();
1102
+ // }
1103
+ }
1104
+
1105
+ resetTemporaryBreakPoint() {
1106
+ if (this.temporaryBreakPointTriggered) {
1107
+ this.temporaryBreakPoint.logicItem.temporaryBreakPoint = null;
1108
+ this.temporaryBreakPoint = null;
1109
+ this.temporaryBreakPointTriggered = false;
1110
+ }
1111
+ }
1112
+
1113
+ resumeUserAction() {
1114
+ this.resetTemporaryBreakPoint();
1115
+ this.resume();
1116
+ }
1117
+
1118
+ resume() {
1119
+ if (this.currentThread) {
1120
+ if (this.currentThread === this.currentFrontEndThread) {
1121
+ if (this.currentFrontEndThread.id) {
1122
+ this.socketEventEmitter.emitSocket(BackEndProtocol.resume(this.app.id, this.currentFrontEndThread.id));
1123
+ } else {
1124
+ this.socketEventEmitter.emitSocket(FrontEndProtocol.resume());
1125
+ }
1126
+ } else {
1127
+ this.socketEventEmitter.emitSocket(BackEndProtocol.resume(this.app.id, this.currentThread.id));
1128
+ }
1129
+
1130
+ Object.assign(this.currentThread, {
1131
+ callFrameId: null,
1132
+ breakPoint: null,
1133
+ evaluateExpression: null,
1134
+ evaluateValue: null,
1135
+ callFrames: null,
1136
+ callFrameScope: null,
1137
+ });
1138
+ }
1139
+ }
1140
+ }