@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,347 @@
|
|
|
1
|
+
import Namespace from './Namespace__';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
3
|
+
|
|
4
|
+
//================================================================================
|
|
5
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
6
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
7
|
+
//================================================================================
|
|
8
|
+
import { EventPayload, Params } from '../common/EventEmitter';
|
|
9
|
+
import { concept, excludedInJSON, property } from '../decorators';
|
|
10
|
+
|
|
11
|
+
import * as utils from '../utils';
|
|
12
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
13
|
+
import BaseNode from '../common/BaseNode';
|
|
14
|
+
import classMap from '../common/classMap';
|
|
15
|
+
import BackendVariable from './BackendVariable__';
|
|
16
|
+
import App from './App__';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 后端
|
|
20
|
+
*/
|
|
21
|
+
@concept('后端')
|
|
22
|
+
export class Backend extends BaseNode {
|
|
23
|
+
/**
|
|
24
|
+
* 产品概念
|
|
25
|
+
*/
|
|
26
|
+
@property()
|
|
27
|
+
concept: 'Backend' = 'Backend';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 后端标识
|
|
31
|
+
*/
|
|
32
|
+
@property()
|
|
33
|
+
name: string = undefined;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 全局变量列表
|
|
37
|
+
*/
|
|
38
|
+
@property('BackendVariable')
|
|
39
|
+
variables: Array<BackendVariable> = [];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 祖先 App
|
|
43
|
+
*/
|
|
44
|
+
get app() {
|
|
45
|
+
return this.getAncestor('App') as App;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param source 需要合并的部分参数
|
|
50
|
+
*/
|
|
51
|
+
constructor(source?: Partial<Backend>) {
|
|
52
|
+
source = Object.assign({}, Backend.getDefaultOptions(), source);
|
|
53
|
+
super(source);
|
|
54
|
+
super.subConstructor(source);
|
|
55
|
+
}
|
|
56
|
+
getClassName() {
|
|
57
|
+
return 'Backend';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static from(source: any, parentNode?: any, parentKey?: string): Backend {
|
|
61
|
+
return super.from(source, parentNode, parentKey) as Backend;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 从父级删除该节点
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
_delete() {
|
|
69
|
+
let params: Params = null;
|
|
70
|
+
if (this.parentNode) {
|
|
71
|
+
params = (this.parentNode as any)?.__removeBackend?.(this);
|
|
72
|
+
}
|
|
73
|
+
return params;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 设置后端标识
|
|
77
|
+
*/
|
|
78
|
+
setName(name: string) {
|
|
79
|
+
const object = {
|
|
80
|
+
name,
|
|
81
|
+
};
|
|
82
|
+
this.update({
|
|
83
|
+
...object,
|
|
84
|
+
field: 'name',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getVarExistingNames(excludedList: Array<BackendVariable> = []) {
|
|
89
|
+
const excludedSet = new Set(excludedList);
|
|
90
|
+
return ((this.variables as BackendVariable[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
91
|
+
}
|
|
92
|
+
getBackendVariableUniqueName(name = 'backendVariable1') {
|
|
93
|
+
return utils.unique(name, this.getVarExistingNames(), undefined, true);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 插入全局变量
|
|
98
|
+
* @internal
|
|
99
|
+
* @param name 全局变量名称,如果不填会自动生成一个唯一名称
|
|
100
|
+
*/
|
|
101
|
+
_insertBackendVariableAt(name: string, index: number): BackendVariable;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 插入全局变量
|
|
105
|
+
* @internal
|
|
106
|
+
* @param backendVariableOptions 全局变量参数
|
|
107
|
+
*/
|
|
108
|
+
_insertBackendVariableAt(backendVariableOptions: Partial<BackendVariable>, index: number): BackendVariable;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 插入全局变量
|
|
112
|
+
* @internal
|
|
113
|
+
* @param backendVariable 已有的全局变量实例
|
|
114
|
+
*/
|
|
115
|
+
_insertBackendVariableAt(backendVariable: BackendVariable, index: number): BackendVariable;
|
|
116
|
+
|
|
117
|
+
_insertBackendVariableAt(options: string | Partial<BackendVariable> | BackendVariable, index: number) {
|
|
118
|
+
const backendVariableOptions: any = {};
|
|
119
|
+
const relationOptions = { parentNode: this, parentKey: 'variables' };
|
|
120
|
+
let backendVariable: BackendVariable;
|
|
121
|
+
if (!options) {
|
|
122
|
+
backendVariable = BackendVariable.from({
|
|
123
|
+
...backendVariableOptions,
|
|
124
|
+
name: this.getBackendVariableUniqueName(),
|
|
125
|
+
}, this, 'variables');
|
|
126
|
+
} else if (typeof options === 'string') {
|
|
127
|
+
backendVariable = BackendVariable.from({
|
|
128
|
+
...backendVariableOptions,
|
|
129
|
+
name: options,
|
|
130
|
+
}, this, 'variables');
|
|
131
|
+
} else if (options instanceof BackendVariable) {
|
|
132
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
133
|
+
backendVariable = options;
|
|
134
|
+
Object.assign(backendVariable, relationOptions);
|
|
135
|
+
} else {
|
|
136
|
+
backendVariable = BackendVariable.from({
|
|
137
|
+
...backendVariableOptions,
|
|
138
|
+
...options,
|
|
139
|
+
}, this, 'variables');
|
|
140
|
+
}
|
|
141
|
+
this.variables.splice(index, 0, backendVariable);
|
|
142
|
+
return backendVariable;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 插入全局变量
|
|
147
|
+
* @param name 全局变量名称,如果不填会自动生成一个唯一名称
|
|
148
|
+
*/
|
|
149
|
+
insertBackendVariableAt(name: string, index: number): BackendVariable;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 插入全局变量
|
|
153
|
+
* @param backendVariableOptions 全局变量参数
|
|
154
|
+
*/
|
|
155
|
+
insertBackendVariableAt(backendVariableOptions: Partial<BackendVariable>, index: number): BackendVariable;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 插入全局变量
|
|
159
|
+
* @param backendVariable 已有的全局变量实例
|
|
160
|
+
*/
|
|
161
|
+
insertBackendVariableAt(backendVariable: BackendVariable, index: number): BackendVariable;
|
|
162
|
+
|
|
163
|
+
insertBackendVariableAt(options: string | Partial<BackendVariable> | BackendVariable, index: number) {
|
|
164
|
+
const node = this._insertBackendVariableAt(options as any, index);
|
|
165
|
+
node.create({
|
|
166
|
+
index,
|
|
167
|
+
parentNode: this,
|
|
168
|
+
parentKey: 'variables',
|
|
169
|
+
});
|
|
170
|
+
return node;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 添加全局变量
|
|
175
|
+
* @internal
|
|
176
|
+
* @param name 全局变量名称,如果不填会自动生成一个唯一名称
|
|
177
|
+
*/
|
|
178
|
+
_addBackendVariable(name?: string): BackendVariable;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 添加全局变量
|
|
182
|
+
* @internal
|
|
183
|
+
* @param backendVariableOptions 全局变量参数
|
|
184
|
+
*/
|
|
185
|
+
_addBackendVariable(backendVariableOptions: Partial<BackendVariable>): BackendVariable;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 添加全局变量
|
|
189
|
+
* @internal
|
|
190
|
+
* @param backendVariable 已有的全局变量实例
|
|
191
|
+
*/
|
|
192
|
+
_addBackendVariable(backendVariable: BackendVariable): BackendVariable;
|
|
193
|
+
|
|
194
|
+
_addBackendVariable(options?: string | Partial<BackendVariable> | BackendVariable) {
|
|
195
|
+
const index = this.variables.length;
|
|
196
|
+
return this._insertBackendVariableAt(options as any, index);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 添加全局变量
|
|
201
|
+
* @internal
|
|
202
|
+
* @param name 全局变量名称,如果不填会自动生成一个唯一名称
|
|
203
|
+
*/
|
|
204
|
+
addBackendVariable(name?: string): BackendVariable;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 添加全局变量
|
|
208
|
+
* @param backendVariableOptions 全局变量参数
|
|
209
|
+
*/
|
|
210
|
+
addBackendVariable(backendVariableOptions: Partial<BackendVariable>): BackendVariable;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* 添加全局变量
|
|
214
|
+
* @param backendVariable 已有的全局变量实例
|
|
215
|
+
*/
|
|
216
|
+
addBackendVariable(backendVariable: BackendVariable): BackendVariable;
|
|
217
|
+
|
|
218
|
+
addBackendVariable(options?: string | Partial<BackendVariable> | BackendVariable) {
|
|
219
|
+
const node = this._addBackendVariable(options as any);
|
|
220
|
+
const index = this.variables.indexOf(node);
|
|
221
|
+
node.create({
|
|
222
|
+
index,
|
|
223
|
+
parentNode: this,
|
|
224
|
+
parentKey: 'variables',
|
|
225
|
+
});
|
|
226
|
+
return node;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 删除全局变量
|
|
234
|
+
* @param name 全局变量名称
|
|
235
|
+
*/
|
|
236
|
+
removeBackendVariable(name: string): void;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* 删除全局变量
|
|
240
|
+
* @param backendVariable 已有的全局变量实例
|
|
241
|
+
*/
|
|
242
|
+
removeBackendVariable(backendVariable: BackendVariable): void;
|
|
243
|
+
|
|
244
|
+
removeBackendVariable(options: string | BackendVariable) {
|
|
245
|
+
let backendVariable: BackendVariable;
|
|
246
|
+
if (typeof options === 'string') {
|
|
247
|
+
backendVariable = (this.variables as BackendVariable[]).find((item) => item.name === options);
|
|
248
|
+
if (!backendVariable) {
|
|
249
|
+
throw new Error('找不到全局变量 ' + options);
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
backendVariable = options;
|
|
253
|
+
}
|
|
254
|
+
return backendVariable.delete();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
__removeBackendVariable(backendVariable: BackendVariable) {
|
|
258
|
+
const parentKey = backendVariable.parentKey;
|
|
259
|
+
const params: Params = {
|
|
260
|
+
parentNode: this,
|
|
261
|
+
parentKey,
|
|
262
|
+
index: -1,
|
|
263
|
+
object: null,
|
|
264
|
+
oldObject: backendVariable,
|
|
265
|
+
};
|
|
266
|
+
if (parentKey) {
|
|
267
|
+
params.parentKey = parentKey;
|
|
268
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
269
|
+
const index = (this as any)[parentKey].indexOf(backendVariable);
|
|
270
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
271
|
+
params.index = index;
|
|
272
|
+
} else if ((this as any)[parentKey] === backendVariable) {
|
|
273
|
+
params.index = 0;
|
|
274
|
+
(this as any)[parentKey] = undefined;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return params;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
//================================================================================
|
|
281
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
282
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
283
|
+
//================================================================================
|
|
284
|
+
getNamespace() {
|
|
285
|
+
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
286
|
+
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
287
|
+
const parentName = this.parentNode.name;
|
|
288
|
+
const arr = [parentNamespace];
|
|
289
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
290
|
+
arr.push(parentName);
|
|
291
|
+
}
|
|
292
|
+
return `${arr.join('.')}.backend`;
|
|
293
|
+
} else
|
|
294
|
+
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* 生成宿主语言的文件路径
|
|
298
|
+
* @param name 一般不用传,用于 rename
|
|
299
|
+
*/
|
|
300
|
+
getEmbeddedFilePath(name = this.name) {
|
|
301
|
+
return `/embedded/${this.rootNode?.name || this.parentNode.name}/Backend/backend.ts`;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
@withSourceMap()
|
|
305
|
+
toEmbeddedTS(state?: TranslatorState): string {
|
|
306
|
+
let code = `export namespace ${this.name} {\n`;
|
|
307
|
+
code += 'const name = ';
|
|
308
|
+
code += '"' + this.name + '";\n';
|
|
309
|
+
code += '}\n';
|
|
310
|
+
return code;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// getPath() {
|
|
314
|
+
// const path = this.path;
|
|
315
|
+
// const finalPath = path && path !== '/' ? path : '';
|
|
316
|
+
// return finalPath;
|
|
317
|
+
// }
|
|
318
|
+
toEmbeddedTSFile() {
|
|
319
|
+
let code = `namespace ${this.getNamespace()} {\n`;
|
|
320
|
+
|
|
321
|
+
const state = createCompilerState(code, { tabSize: 1 });
|
|
322
|
+
try {
|
|
323
|
+
code += this.toEmbeddedTS(state);
|
|
324
|
+
} catch (err) {
|
|
325
|
+
code += '';
|
|
326
|
+
console.log(err);
|
|
327
|
+
}
|
|
328
|
+
code += '}\n';
|
|
329
|
+
|
|
330
|
+
return {
|
|
331
|
+
code,
|
|
332
|
+
filePath: this.getEmbeddedFilePath(),
|
|
333
|
+
sourceMap: state.sourceMap,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
//================================================================================
|
|
337
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
338
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
339
|
+
//================================================================================
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
classMap.Backend = Backend;
|
|
343
|
+
export default Backend;
|
|
344
|
+
//================================================================================
|
|
345
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
346
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
347
|
+
//================================================================================
|
|
@@ -684,7 +684,7 @@ export class BindAttribute extends BaseNode {
|
|
|
684
684
|
this.emit('change', $event);
|
|
685
685
|
}
|
|
686
686
|
|
|
687
|
-
updateSource(source?: Partial<
|
|
687
|
+
updateSource(source?: Partial<BindAttribute>) {
|
|
688
688
|
const object = {
|
|
689
689
|
...source,
|
|
690
690
|
};
|
|
@@ -946,8 +946,9 @@ export class BindAttribute extends BaseNode {
|
|
|
946
946
|
// fix-bug: http://projectmanage.netease-official.lcap.163yun.com/dashboard/BugDetail?id=2613580902909440
|
|
947
947
|
if (
|
|
948
948
|
(
|
|
949
|
-
|
|
950
|
-
|
|
949
|
+
// fix: 2647986781937408 导航栏项中配置链接,取消动态绑定,直接配置为外部链接,无法跳转,且导航栏项消失
|
|
950
|
+
(this.name === 'destination' || this.name === 'href') && value && value.startsWith('/')
|
|
951
|
+
) && this.frontend?.prefixPath
|
|
951
952
|
) {
|
|
952
953
|
value = `${this.frontend?.prefixPath}${value}`;
|
|
953
954
|
} else if (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as babel from '@babel/core';
|
|
2
2
|
import LogicItem from './LogicItem__';
|
|
3
3
|
import Namespace from './Namespace__';
|
|
4
|
-
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
4
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
5
5
|
import { ElementToVueOptions } from './ViewElement__';
|
|
6
6
|
import { elementsEventsMap } from '../server/createUiTs';
|
|
7
7
|
import Param from './Param__';
|
|
@@ -862,13 +862,82 @@ export class BindEvent extends BaseNode {
|
|
|
862
862
|
// 名称规则:组件的名称 + 组件的事件 + 逻辑本身的事件 用下划线链接
|
|
863
863
|
const parentNode = this.parentNode;
|
|
864
864
|
const newName = this.name.replace(/-/g, '');
|
|
865
|
-
|
|
866
865
|
if (parentNode instanceof ViewElement) {
|
|
867
866
|
return `${parentNode.name}_${newName}`;
|
|
868
867
|
} else if (parentNode instanceof View) {
|
|
869
868
|
return `${this.view.name}_${newName}`;
|
|
869
|
+
} else {
|
|
870
|
+
// 这里编译成这个名字了 后续pctemplate 里也得按这个调用?
|
|
871
|
+
// 或者说因为会编译在不同的端里 直接 name好了
|
|
872
|
+
// return `${this.parentNode.name}_${newName}`;
|
|
873
|
+
return newName;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
toFunction(state?: TranslatorState): string {
|
|
877
|
+
// shiftState(state, code)
|
|
878
|
+
// 和 toJS一样的 只是下一行增加了 function 关键字
|
|
879
|
+
// let code = `async function ${this.getViewEventName()} (`;
|
|
880
|
+
let code = `window.${this.getViewEventName()} = async (`;
|
|
881
|
+
const params = this.getContextLogicParams();
|
|
882
|
+
code += params.map((item: Param) => item.name).toString();
|
|
883
|
+
// code += ') { \n';
|
|
884
|
+
code += ') => { \n';
|
|
885
|
+
this.logics.forEach((logic) => {
|
|
886
|
+
code += logic.toJS(shiftState(state, code), 'IIFE');
|
|
887
|
+
});
|
|
888
|
+
code += '}\n';
|
|
889
|
+
return code;
|
|
890
|
+
}
|
|
891
|
+
getTsNamespace() {
|
|
892
|
+
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
893
|
+
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
894
|
+
const parentName = this.parentNode.name;
|
|
895
|
+
const arr = [parentNamespace];
|
|
896
|
+
|
|
897
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
898
|
+
arr.push(parentName);
|
|
899
|
+
}
|
|
900
|
+
return `${arr.join('.')}.bindEvents`;
|
|
901
|
+
} else
|
|
902
|
+
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
903
|
+
}
|
|
904
|
+
toEmbeddedTSFile() {
|
|
905
|
+
let code = `namespace ${this.getTsNamespace()} {\n`;
|
|
906
|
+
const state = createCompilerState(code, {
|
|
907
|
+
tabSize: 1,
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
try {
|
|
911
|
+
code += this.toEmbeddedTS(state);
|
|
912
|
+
} catch (err) {
|
|
913
|
+
code += '';
|
|
914
|
+
console.log(err);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
code += '}\n';
|
|
918
|
+
|
|
919
|
+
return {
|
|
920
|
+
code,
|
|
921
|
+
filePath: this.getEmbeddedFilePath(),
|
|
922
|
+
sourceMap: state.sourceMap,
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* 生成宿主语言的文件路径
|
|
927
|
+
* @param name 一般不用传,用于 rename
|
|
928
|
+
*/
|
|
929
|
+
getEmbeddedFilePath(name = this.name) {
|
|
930
|
+
let pathName = name;
|
|
931
|
+
let parent = this.parentNode;
|
|
932
|
+
if (parent) {
|
|
933
|
+
while (parent && parent instanceof View) {
|
|
934
|
+
pathName = parent.name + '/' + pathName;
|
|
935
|
+
parent = parent.parentNode;
|
|
936
|
+
}
|
|
870
937
|
}
|
|
938
|
+
return `/embedded/${this.app.name}/frontends/${this.frontend.name}/bindEvents/${pathName}.ts`;
|
|
871
939
|
}
|
|
940
|
+
|
|
872
941
|
//================================================================================
|
|
873
942
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
874
943
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|