@lcap/nasl 2.22.0-beta.5 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/docs/classes/Module.html +15 -15
- package/docs/classes/Namespace.html +15 -15
- package/docs/classes/ViewComponent.html +19 -19
- package/out/automate/engine/utils.js +4 -0
- package/out/automate/engine/utils.js.map +1 -1
- package/out/breakpoint/generator/AfterStartNode.d.ts +7 -0
- package/out/breakpoint/generator/AfterStartNode.js +27 -0
- package/out/breakpoint/generator/AfterStartNode.js.map +1 -0
- package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -0
- package/out/breakpoint/generator/BeforeEndNode.js +27 -0
- package/out/breakpoint/generator/BeforeEndNode.js.map +1 -0
- package/out/breakpoint/generator/BreakpointNode.d.ts +14 -0
- package/out/breakpoint/generator/BreakpointNode.js +166 -0
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -0
- package/out/breakpoint/generator/index.d.ts +4 -0
- package/out/breakpoint/generator/index.js +98 -0
- package/out/breakpoint/generator/index.js.map +1 -0
- package/out/breakpoint/index.d.ts +3 -0
- package/out/breakpoint/index.js +20 -0
- package/out/breakpoint/index.js.map +1 -0
- package/out/breakpoint/shared/constants.d.ts +30 -0
- package/out/breakpoint/shared/constants.js +87 -0
- package/out/breakpoint/shared/constants.js.map +1 -0
- package/out/breakpoint/shared/index.d.ts +3 -0
- package/out/breakpoint/shared/index.js +33 -0
- package/out/breakpoint/shared/index.js.map +1 -0
- package/out/breakpoint/shared/operations.d.ts +10 -0
- package/out/breakpoint/shared/operations.js +25 -0
- package/out/breakpoint/shared/operations.js.map +1 -0
- package/out/breakpoint/shared/socket.d.ts +47 -0
- package/out/breakpoint/shared/socket.js +210 -0
- package/out/breakpoint/shared/socket.js.map +1 -0
- package/out/breakpoint/shared/utils.d.ts +20 -0
- package/out/breakpoint/shared/utils.js +133 -0
- package/out/breakpoint/shared/utils.js.map +1 -0
- package/out/breakpoint/store/core.d.ts +30 -0
- package/out/breakpoint/store/core.js +341 -0
- package/out/breakpoint/store/core.js.map +1 -0
- package/out/breakpoint/store/dock.d.ts +1 -0
- package/out/breakpoint/store/dock.js +127 -0
- package/out/breakpoint/store/dock.js.map +1 -0
- package/out/breakpoint/store/index.d.ts +2 -0
- package/out/breakpoint/store/index.js +19 -0
- package/out/breakpoint/store/index.js.map +1 -0
- package/out/common/BaseNode.d.ts +8 -0
- package/out/common/BaseNode.js +19 -0
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +365 -16
- package/out/concepts/App__.js +431 -10
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/AuthInterface__.d.ts +37 -0
- package/out/concepts/AuthInterface__.js +141 -0
- package/out/concepts/AuthInterface__.js.map +1 -0
- package/out/concepts/AuthLogicForCallInterface__.d.ts +138 -0
- package/out/concepts/AuthLogicForCallInterface__.js +493 -0
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -0
- package/out/concepts/AuthLogic__.d.ts +66 -0
- package/out/concepts/AuthLogic__.js +206 -0
- package/out/concepts/AuthLogic__.js.map +1 -0
- package/out/concepts/BackendVariable__.d.ts +137 -0
- package/out/concepts/BackendVariable__.js +422 -0
- package/out/concepts/BackendVariable__.js.map +1 -0
- package/out/concepts/Backend__.d.ts +134 -0
- package/out/concepts/Backend__.js +274 -0
- package/out/concepts/Backend__.js.map +1 -0
- package/out/concepts/BindAttribute__.d.ts +1 -1
- package/out/concepts/BindAttribute__.js +3 -1
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +12 -0
- package/out/concepts/BindEvent__.js +68 -0
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.d.ts +126 -0
- package/out/concepts/CallAuthInterface__.js +408 -0
- package/out/concepts/CallAuthInterface__.js.map +1 -0
- package/out/concepts/CallInterface__.d.ts +6 -1
- package/out/concepts/CallInterface__.js +9 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +3 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +9 -7
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Destination__.js +1 -1
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +29 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -2
- package/out/concepts/Entity__.js +1 -31
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +9 -4
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +29 -29
- package/out/concepts/FrontendLibrary__.js +2 -2
- package/out/concepts/FrontendVariable__.d.ts +21 -0
- package/out/concepts/FrontendVariable__.js +64 -0
- package/out/concepts/FrontendVariable__.js.map +1 -0
- package/out/concepts/Frontend__.d.ts +151 -47
- package/out/concepts/Frontend__.js +188 -32
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.js +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +1 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +18 -3
- package/out/concepts/LogicItem__.js +22 -4
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +14 -9
- package/out/concepts/Logic__.js +43 -5
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +29 -29
- package/out/concepts/Namespace__.js +2 -2
- package/out/concepts/NewComposite__.js +2 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.d.ts +643 -0
- package/out/concepts/OverriddenLogic__.js +1602 -0
- package/out/concepts/OverriddenLogic__.js.map +1 -0
- package/out/concepts/Param__.d.ts +6 -0
- package/out/concepts/Param__.js +10 -0
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +2 -0
- package/out/concepts/QueryFieldExpression__.js +9 -0
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.d.ts +2 -2
- package/out/concepts/QuerySelectExpression__.js +2 -2
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +6 -6
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +10 -0
- package/out/concepts/Variable__.js +12 -0
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.d.ts +33 -33
- package/out/concepts/ViewComponent__.js +7 -7
- package/out/concepts/ViewElement__.d.ts +6 -0
- package/out/concepts/ViewElement__.js +104 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +2 -2
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +2 -1
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +24 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -0
- package/out/concepts/basics/stdlib/nasl.http.js +167 -0
- package/out/concepts/basics/stdlib/nasl.http.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.process.js +68 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +4 -19
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +83 -17
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +4 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +8 -0
- package/out/concepts/index__.js +8 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +0 -1
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.js +27 -0
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +4 -1
- package/out/generator/genMetaData.js +14 -0
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -1
- package/out/generator/genReleaseBody.js +2 -1
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/index.d.ts +2 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/server/extendBaseNode.js +16 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +39 -4
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getExtensionModules.d.ts +2 -2
- package/out/server/getExtensionModules.js +16 -2
- package/out/server/getExtensionModules.js.map +1 -1
- package/out/server/getLogics.js +5 -5
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +34 -7
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +64 -64
- package/out/server/naslServer.js +249 -121
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +2 -0
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/translator.d.ts +1 -0
- package/out/server/translator.js +67 -2
- package/out/server/translator.js.map +1 -1
- package/out/service/defaultErrorMessage.json +1 -0
- package/out/service/storage/api.d.ts +10 -1
- package/out/service/storage/api.js +6 -0
- package/out/service/storage/api.js.map +1 -1
- package/out/service/storage/init.d.ts +4 -0
- package/out/service/storage/init.js +55 -35
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/service.d.ts +3 -0
- package/out/service/storage/service.js +14 -0
- package/out/service/storage/service.js.map +1 -1
- package/out/utils/sortTsString.d.ts +1 -0
- package/out/utils/sortTsString.js +36 -0
- package/out/utils/sortTsString.js.map +1 -0
- package/out/utils/traverse.js +2 -2
- package/out/utils/traverse.js.map +1 -1
- package/package.json +7 -2
- package/sandbox/stdlib/nasl.auth.ts +8 -4
- package/sandbox/stdlib/nasl.core.d.ts +206 -0
- package/sandbox/stdlib/nasl.core.js +1 -0
- package/sandbox/stdlib/nasl.core.js.map +1 -0
- package/sandbox/stdlib/nasl.http.ts +35 -0
- package/sandbox/stdlib/nasl.process.ts +13 -0
- package/sandbox/stdlib/nasl.ui.ts +0 -5
- package/src/automate/engine/utils.js +4 -1
- package/src/breakpoint/generator/AfterStartNode.ts +27 -0
- package/src/breakpoint/generator/BeforeEndNode.ts +27 -0
- package/src/breakpoint/generator/BreakpointNode.ts +228 -0
- package/src/breakpoint/generator/index.ts +114 -0
- package/src/breakpoint/index.ts +3 -0
- package/src/breakpoint/shared/constants.ts +95 -0
- package/src/breakpoint/shared/index.ts +3 -0
- package/src/breakpoint/shared/operations.ts +25 -0
- package/src/breakpoint/shared/socket.ts +326 -0
- package/src/breakpoint/shared/utils.ts +195 -0
- package/src/breakpoint/store/core.ts +411 -0
- package/src/breakpoint/store/dock.ts +166 -0
- package/src/breakpoint/store/index.ts +2 -0
- package/src/breakpoint/types/index.d.ts +19 -0
- package/src/common/BaseNode.ts +19 -1
- package/src/concepts/App__.ts +828 -26
- package/src/concepts/Assignment__.ts +1 -1
- package/src/concepts/AuthInterface__.ts +148 -0
- package/src/concepts/AuthLogicForCallInterface__.ts +573 -0
- package/src/concepts/AuthLogic__.ts +225 -0
- package/src/concepts/BackendVariable__.ts +466 -0
- package/src/concepts/Backend__.ts +347 -0
- package/src/concepts/BindAttribute__.ts +4 -3
- package/src/concepts/BindEvent__.ts +71 -2
- package/src/concepts/CallAuthInterface__.ts +490 -0
- package/src/concepts/CallInterface__.ts +10 -2
- package/src/concepts/CallLogic__.ts +3 -1
- package/src/concepts/CallQueryComponent__.ts +67 -7
- package/src/concepts/Destination__.ts +19 -1
- package/src/concepts/End__.ts +31 -3
- package/src/concepts/EntityProperty__.ts +6 -0
- package/src/concepts/Entity__.ts +8 -31
- package/src/concepts/ForEachStatement__.ts +9 -4
- package/src/concepts/FrontendLibrary__.ts +30 -30
- package/src/concepts/FrontendVariable__.ts +76 -0
- package/src/concepts/Frontend__.ts +352 -89
- package/src/concepts/Function__.ts +1 -1
- package/src/concepts/Identifier__.ts +5 -5
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/LogicItem__.ts +26 -6
- package/src/concepts/Logic__.ts +86 -8
- package/src/concepts/Module__.ts +32 -2
- package/src/concepts/Namespace__.ts +30 -30
- package/src/concepts/NewComposite__.ts +2 -3
- package/src/concepts/OverriddenLogic__.ts +2165 -0
- package/src/concepts/Param__.ts +13 -3
- package/src/concepts/QueryFieldExpression__.ts +18 -0
- package/src/concepts/QuerySelectExpression__.ts +11 -3
- package/src/concepts/TypeAnnotation__.ts +45 -6
- package/src/concepts/Variable__.ts +14 -0
- package/src/concepts/ViewComponent__.ts +35 -35
- package/src/concepts/ViewElement__.ts +104 -1
- package/src/concepts/View__.ts +24 -2
- package/src/concepts/basics/stdlib/index.ts +2 -1
- package/src/concepts/basics/stdlib/nasl.auth.ts +24 -0
- package/src/concepts/basics/stdlib/nasl.http.ts +166 -0
- package/src/concepts/basics/stdlib/nasl.process.ts +68 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +4 -19
- package/src/concepts/basics/stdlib/nasl.util.ts +83 -17
- package/src/concepts/basics/types/index.ts +5 -4
- package/src/concepts/index__.ts +8 -0
- package/src/enums/KEYWORDS.ts +0 -1
- package/src/generator/genBundleFiles.ts +36 -2
- package/src/generator/genMetaData.ts +16 -1
- package/src/generator/genReleaseBody.ts +4 -1
- package/src/index.ts +2 -1
- package/src/server/extendBaseNode.ts +18 -7
- package/src/server/formatTsUtils.ts +37 -5
- package/src/server/getExtensionModules.ts +18 -3
- package/src/server/getLogics.ts +6 -6
- package/src/server/getMemberIdentifier.ts +35 -9
- package/src/server/naslServer.ts +250 -124
- package/src/server/naslStdlibMap.ts +2 -0
- package/src/server/translator.ts +67 -1
- package/src/service/defaultErrorMessage.json +1 -0
- package/src/service/storage/api.js +7 -1
- package/src/service/storage/init.ts +66 -35
- package/src/service/storage/service.ts +18 -2
- package/src/utils/sortTsString.ts +32 -0
- package/src/utils/traverse.ts +2 -2
- package/test/examples/app-simple.json +73635 -0
- package/ts-worker/lib/tsserver.js +3 -3
- package/ts-worker/package.json +1 -1
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { BaseNode, Argument } from '../../concepts';
|
|
2
|
+
|
|
3
|
+
import { getUniqueIdFromNode, getRealNode } from '../shared/utils';
|
|
4
|
+
|
|
5
|
+
type Options = {
|
|
6
|
+
logic?: BaseNode;
|
|
7
|
+
variable?: BaseNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const MATCH_CONCEPT = 'Match';
|
|
11
|
+
const MATCH_CASE_CONCEPT = 'MatchCase';
|
|
12
|
+
const ASSIGNMENT_CONCEPT = 'Assignment';
|
|
13
|
+
const CALL_LOGIC_CONCEPT = 'CallLogic';
|
|
14
|
+
const WHILE_STATEMENT_CONCEPT = 'WhileStatement';
|
|
15
|
+
|
|
16
|
+
const BEFORE_LOGIC_CONCEPTS = [
|
|
17
|
+
MATCH_CONCEPT,
|
|
18
|
+
'ForEachStatement',
|
|
19
|
+
'SwitchStatement',
|
|
20
|
+
'IfStatement',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const attribute = '[Symbol.for(\'breakpoint\')]';
|
|
24
|
+
const parse = `(code) => eval(code)`;
|
|
25
|
+
|
|
26
|
+
const callLogicGenerator = (instance: BreakpointNode) => (breaker: string) => {
|
|
27
|
+
const { _nodePath, logic, variable } = instance;
|
|
28
|
+
const node = logic || variable;
|
|
29
|
+
|
|
30
|
+
if (!node) {
|
|
31
|
+
return breaker;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const source = node as any;
|
|
35
|
+
const { concept, isViewLogic } = source;
|
|
36
|
+
|
|
37
|
+
if (concept !== CALL_LOGIC_CONCEPT) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { arguments: args } = source;
|
|
42
|
+
|
|
43
|
+
const wrapper = <T extends Function>(callback: T) => {
|
|
44
|
+
if (isViewLogic) {
|
|
45
|
+
return callback();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const logic = source.getCallNode() || {};
|
|
49
|
+
const { params: logicParams } = logic;
|
|
50
|
+
|
|
51
|
+
const logicBase = logicParams || [];
|
|
52
|
+
logic.params = logicBase.concat({ name: attribute });
|
|
53
|
+
|
|
54
|
+
const result = callback();
|
|
55
|
+
logic.params = logicParams;
|
|
56
|
+
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const breakpointExpression = new BreakpointNode();
|
|
61
|
+
const breakpointArgument = new Argument();
|
|
62
|
+
const base = args || [];
|
|
63
|
+
|
|
64
|
+
breakpointArgument.name = attribute;
|
|
65
|
+
breakpointArgument.expression = breakpointExpression as any;
|
|
66
|
+
breakpointExpression._nodePath = _nodePath;
|
|
67
|
+
source.arguments = base.concat(breakpointArgument);
|
|
68
|
+
|
|
69
|
+
const callback = () => source.toJS();
|
|
70
|
+
const code = wrapper(callback);
|
|
71
|
+
source.arguments = args;
|
|
72
|
+
|
|
73
|
+
return code;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const variableGenerator = (instance: BreakpointNode) => (breaker: string) => {
|
|
77
|
+
const { _nodePath, variable } = instance;
|
|
78
|
+
|
|
79
|
+
if (!variable) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const promise = (variable as any)?.toJS() || '';
|
|
84
|
+
return `await $breaker.generateBreakpoint('${_nodePath}', ${parse})(${promise})`;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const assignmentGenerator = (instance: BreakpointNode) => (breaker: string) => {
|
|
88
|
+
const { _nodePath, logic } = instance;
|
|
89
|
+
|
|
90
|
+
if (!logic) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const source = logic as any;
|
|
95
|
+
const { concept, right } = source;
|
|
96
|
+
|
|
97
|
+
if (concept !== ASSIGNMENT_CONCEPT) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const options = { variable: right };
|
|
102
|
+
const breakpointRight = new BreakpointNode(options);
|
|
103
|
+
|
|
104
|
+
breakpointRight._nodePath = _nodePath;
|
|
105
|
+
source.right = breakpointRight as any;
|
|
106
|
+
|
|
107
|
+
const code = source.toJS();
|
|
108
|
+
source.right = right;
|
|
109
|
+
|
|
110
|
+
return code;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const whileStatementGenerator = (instance: BreakpointNode) => (breaker: string) => {
|
|
114
|
+
const { _nodePath, logic } = instance;
|
|
115
|
+
|
|
116
|
+
if (!logic) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const source = logic as any;
|
|
121
|
+
const { concept, body = [] } = source;
|
|
122
|
+
|
|
123
|
+
if (concept !== WHILE_STATEMENT_CONCEPT) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const item = new BreakpointNode();
|
|
128
|
+
item._nodePath = _nodePath;
|
|
129
|
+
source.body = body.concat(item);
|
|
130
|
+
|
|
131
|
+
const code = source.toJS();
|
|
132
|
+
source.body = body;
|
|
133
|
+
|
|
134
|
+
return `${breaker}\n${code}`;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const matchCaseLogicGenerator = (instance: BreakpointNode) => (breaker: string) => {
|
|
138
|
+
const { _nodePath, logic } = instance;
|
|
139
|
+
|
|
140
|
+
if (!logic) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const source = logic as any;
|
|
145
|
+
|
|
146
|
+
const parentConcept = source?.parentNode?.concept;
|
|
147
|
+
const underMatch = parentConcept === MATCH_CASE_CONCEPT;
|
|
148
|
+
|
|
149
|
+
const ancestor = source.getAncestor(MATCH_CONCEPT) || {};
|
|
150
|
+
const { isExpression } = ancestor;
|
|
151
|
+
|
|
152
|
+
if (!underMatch || !isExpression) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const breakpoint = new BreakpointNode({ variable: source });
|
|
157
|
+
breakpoint._nodePath = _nodePath;
|
|
158
|
+
|
|
159
|
+
return breakpoint.toJS();
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const logicGenerator = (instance: BreakpointNode) => (breaker: string) => {
|
|
163
|
+
const { logic } = instance;
|
|
164
|
+
|
|
165
|
+
if (!logic) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const promise = (logic as any)?.toJS() || '';
|
|
170
|
+
const { concept } = logic as any;
|
|
171
|
+
|
|
172
|
+
const shouldSetBefore = BEFORE_LOGIC_CONCEPTS.includes(concept);
|
|
173
|
+
const code = shouldSetBefore ? [breaker, promise] : [promise, breaker];
|
|
174
|
+
|
|
175
|
+
return code.join('\n');
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// 不要更换顺序
|
|
179
|
+
const generators = [
|
|
180
|
+
callLogicGenerator,
|
|
181
|
+
variableGenerator,
|
|
182
|
+
assignmentGenerator,
|
|
183
|
+
whileStatementGenerator,
|
|
184
|
+
matchCaseLogicGenerator,
|
|
185
|
+
logicGenerator,
|
|
186
|
+
];
|
|
187
|
+
|
|
188
|
+
export default class BreakpointNode extends BaseNode {
|
|
189
|
+
_nodePath: string = '';
|
|
190
|
+
|
|
191
|
+
variable: BaseNode = undefined;
|
|
192
|
+
logic: BaseNode = undefined;
|
|
193
|
+
|
|
194
|
+
constructor(options: Options = {}) {
|
|
195
|
+
super();
|
|
196
|
+
this.logic = options.logic;
|
|
197
|
+
this.variable = options.variable;
|
|
198
|
+
|
|
199
|
+
this.init();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
init() {
|
|
203
|
+
const source = this.logic || this.variable;
|
|
204
|
+
const node = getRealNode(source);
|
|
205
|
+
|
|
206
|
+
if (!node) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
this._nodePath = getUniqueIdFromNode(node);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
toJS(): string {
|
|
214
|
+
const node = this.logic || this.variable;
|
|
215
|
+
const id = this._nodePath;
|
|
216
|
+
const breaker = id && `await $breaker.generateBreakpoint('${id}', ${parse})()`;
|
|
217
|
+
|
|
218
|
+
if (!node) {
|
|
219
|
+
return breaker;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const result = generators.reduce((result, generator) => {
|
|
223
|
+
return result || generator(this)(breaker);
|
|
224
|
+
}, '');
|
|
225
|
+
|
|
226
|
+
return result || breaker;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { App, BaseNode } from '../../concepts';
|
|
2
|
+
|
|
3
|
+
import { VARIABLE_KEYS, STACK_KEYS, NODE_KEYS } from '../shared/constants';
|
|
4
|
+
import { isBreakable, getLogics } from '../shared/utils';
|
|
5
|
+
|
|
6
|
+
import AfterStartNode from './AfterStartNode';
|
|
7
|
+
import BeforeEndNode from './BeforeEndNode';
|
|
8
|
+
import BreakpointNode from './BreakpointNode';
|
|
9
|
+
|
|
10
|
+
const START_CONCEPT = 'Start';
|
|
11
|
+
const END_CONCEPT = 'End';
|
|
12
|
+
|
|
13
|
+
const addBreakpointNodes = (node: BaseNode | any) => {
|
|
14
|
+
if (!node) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const wrap = (key: string) => (value: BaseNode) => {
|
|
19
|
+
if (!key) {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const useful = value instanceof BaseNode;
|
|
24
|
+
const breakable = useful && isBreakable(value);
|
|
25
|
+
|
|
26
|
+
if (!useful) {
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
addBreakpointNodes(value);
|
|
31
|
+
|
|
32
|
+
if (breakable) {
|
|
33
|
+
return new BreakpointNode({ [key]: value });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
switch (value.concept) {
|
|
37
|
+
case START_CONCEPT: {
|
|
38
|
+
return new AfterStartNode({ [key]: value });
|
|
39
|
+
}
|
|
40
|
+
case END_CONCEPT: {
|
|
41
|
+
return new BeforeEndNode({ [key]: value });
|
|
42
|
+
}
|
|
43
|
+
default: {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
NODE_KEYS.forEach((key) => {
|
|
50
|
+
const { [key]: value } = node;
|
|
51
|
+
|
|
52
|
+
const isVaribale = VARIABLE_KEYS.includes(key);
|
|
53
|
+
const isStack = STACK_KEYS.includes(key);
|
|
54
|
+
const isArray = Array.isArray(value);
|
|
55
|
+
|
|
56
|
+
if (isVaribale) {
|
|
57
|
+
const warpper = wrap('variable');
|
|
58
|
+
|
|
59
|
+
if (isArray) {
|
|
60
|
+
node[key] = value.map(warpper);
|
|
61
|
+
} else {
|
|
62
|
+
node[key] = warpper(value);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (isStack && isArray) {
|
|
67
|
+
const warpper = wrap('logic');
|
|
68
|
+
|
|
69
|
+
node[key] = value.map(warpper);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const removeBreakpointNodes = (node: BaseNode | any) => {
|
|
75
|
+
if (!node) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const getter = (value: BaseNode) => {
|
|
80
|
+
if (value instanceof BreakpointNode) {
|
|
81
|
+
value = value.variable || value.logic;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (value instanceof BaseNode) {
|
|
85
|
+
removeBreakpointNodes(value);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return value;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
NODE_KEYS.forEach((key) => {
|
|
92
|
+
const { [key]: value } = node;
|
|
93
|
+
|
|
94
|
+
if (Array.isArray(value)) {
|
|
95
|
+
node[key] = value.map(getter);
|
|
96
|
+
} else {
|
|
97
|
+
node[key] = getter(value);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const genBreakpoints = (app: App) => {
|
|
103
|
+
const logics = getLogics(app);
|
|
104
|
+
|
|
105
|
+
logics.forEach(addBreakpointNodes);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const clearBreakpoints = (app: App) => {
|
|
109
|
+
const logics = getLogics(app);
|
|
110
|
+
|
|
111
|
+
logics.forEach(removeBreakpointNodes);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default genBreakpoints;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export const VARIABLE_KEYS = [
|
|
2
|
+
'test',
|
|
3
|
+
'left',
|
|
4
|
+
'right',
|
|
5
|
+
'rights',
|
|
6
|
+
'patterns',
|
|
7
|
+
'arguments',
|
|
8
|
+
'expression',
|
|
9
|
+
'expressions',
|
|
10
|
+
'cases',
|
|
11
|
+
'each',
|
|
12
|
+
'end',
|
|
13
|
+
'start',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
export const STACK_KEYS = [
|
|
17
|
+
'body',
|
|
18
|
+
'consequent',
|
|
19
|
+
'alternate',
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export const NODE_KEYS = [
|
|
23
|
+
...VARIABLE_KEYS,
|
|
24
|
+
...STACK_KEYS,
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export const TRAVERSE_NODE_KEYS = [
|
|
28
|
+
'playground',
|
|
29
|
+
...NODE_KEYS,
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export const BREAKPOINT_CONCEPTS = [
|
|
33
|
+
'IfStatement',
|
|
34
|
+
'Match',
|
|
35
|
+
'SwitchStatement',
|
|
36
|
+
'ForEachStatement',
|
|
37
|
+
'WhileStatement',
|
|
38
|
+
// 'StringInterpolation',
|
|
39
|
+
'New',
|
|
40
|
+
'NewMap',
|
|
41
|
+
'NewList',
|
|
42
|
+
'NewComposite',
|
|
43
|
+
'Unparsed',
|
|
44
|
+
'CallFunction',
|
|
45
|
+
'CallLogic',
|
|
46
|
+
'CallInterface',
|
|
47
|
+
'Assignment',
|
|
48
|
+
'BatchAssignment',
|
|
49
|
+
// 'CallConsoleLog',
|
|
50
|
+
'CallMessageShow',
|
|
51
|
+
'Destination',
|
|
52
|
+
'ExternalDestination',
|
|
53
|
+
'JSBlock',
|
|
54
|
+
// 'BinaryExpression',
|
|
55
|
+
// 'UnaryExpression',
|
|
56
|
+
// 'End',
|
|
57
|
+
// 'JSONSerialize',
|
|
58
|
+
// 'JSONDeserialize',
|
|
59
|
+
'SqlQueryComponent',
|
|
60
|
+
'OqlQueryComponent',
|
|
61
|
+
'CallQueryComponent',
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export const EVENT_DISCONNECT = 'disconnect';
|
|
65
|
+
export const EVENT_RECONNECT = 'reconnect';
|
|
66
|
+
|
|
67
|
+
export const STATUS_ENABLED = 'ENABLED';
|
|
68
|
+
export const STATUS_DELETED = 'DELETED';
|
|
69
|
+
export const STATUS_DISABLED = 'DISABLED';
|
|
70
|
+
|
|
71
|
+
export const TARGET_FRONTEND = 'Frontend';
|
|
72
|
+
export const TARGET_BACKEND = 'Backend';
|
|
73
|
+
|
|
74
|
+
export const EVENT_TYPE_PAGE_INFO = 'PAGE_INFO';
|
|
75
|
+
export const EVENT_TYPE_OBJECT_INFO = 'OBJECT_INFO';
|
|
76
|
+
|
|
77
|
+
export const EVENT_TYPE_SYNC_BREAKPOINTS = 'SYNC_BREAKPOINTS';
|
|
78
|
+
export const EVENT_TYPE_BREAKPOINT = 'BREAKPOINT';
|
|
79
|
+
export const EVENT_TYPE_STEP_OVER = 'STEP_OVER';
|
|
80
|
+
export const EVENT_TYPE_RESOLVE = 'RESOLVE';
|
|
81
|
+
export const EVENT_TYPE_PARSE = 'PARSE';
|
|
82
|
+
export const EVENT_TYPE_CACHE = 'CACHE';
|
|
83
|
+
|
|
84
|
+
export const RESPONSE_TYPE_FRONTEND_INFO = 'FrontendInfo';
|
|
85
|
+
export const RESPONSE_TYPE_OBJECT_INFO = 'ObjectInfo';
|
|
86
|
+
export const RESPONSE_TYPE_PAGE_INFO = 'PageInfo';
|
|
87
|
+
export const RESPONSE_TYPE_DEBUG_INFO = 'DebugInfo';
|
|
88
|
+
export const RESPONSE_TYPE_CONNECTION_INFO = 'ConnectionInfo';
|
|
89
|
+
export const RESPONSE_TYPE_EXCEPTION_INFO = 'ExceptionInfo';
|
|
90
|
+
|
|
91
|
+
export const CONNECTION_NAME_FRONTEND = 'Frontend';
|
|
92
|
+
export const CONNECTION_NAME_BACKEND = 'Backend';
|
|
93
|
+
|
|
94
|
+
export const CONNECTION_STATUS_CONNECTED = 'Connected';
|
|
95
|
+
export const CONNECTION_STATUS_DISCONNECTED = 'Disconnected';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type Callback = (...args: any[]) => void;
|
|
2
|
+
|
|
3
|
+
let createCallback: Callback;
|
|
4
|
+
let updateCallback: Callback;
|
|
5
|
+
let deleteCallback: Callback;
|
|
6
|
+
|
|
7
|
+
const operators = {
|
|
8
|
+
create: (...args: any[]) => createCallback && createCallback(...args),
|
|
9
|
+
update: (...args: any[]) => updateCallback && updateCallback(...args),
|
|
10
|
+
delete: (...args: any[]) => deleteCallback && deleteCallback(...args),
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const setCreate = (callback: Callback) => {
|
|
14
|
+
createCallback = callback;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const setUpdate = (callback: Callback) => {
|
|
18
|
+
updateCallback = callback;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const setDelete = (callback: Callback) => {
|
|
22
|
+
deleteCallback = callback;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default operators;
|