@lcap/nasl 2.20.0-beta.4 → 2.20.1-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/out/automate/engine/2.14-components.d.ts +1115 -0
- package/out/automate/engine/2.14-components.js +1087 -0
- package/out/automate/engine/2.14-components.js.map +1 -0
- package/out/automate/engine/operators.d.ts +0 -9
- package/out/automate/engine/viewCache.d.ts +0 -1
- package/out/automate/template/myProcess.d.ts +0 -1
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/Command.d.ts +1 -1
- package/out/common/EventEmitter.d.ts +1 -1
- package/out/concepts/Anchor__.js.map +1 -1
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.js +13 -0
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/Attribute__.d.ts +9 -14
- package/out/concepts/Attribute__.js +12 -39
- package/out/concepts/Attribute__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +1 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.js +1 -1
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +13 -6
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigPropertyValue__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js +8 -6
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataElement__.js.map +1 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.js +1 -1
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +1 -1
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +1 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ExternalDestination__.js +1 -1
- package/out/concepts/ExternalDestination__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +212 -0
- package/out/concepts/FrontendLibrary__.js +349 -0
- package/out/concepts/FrontendLibrary__.js.map +1 -0
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +26 -13
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +49 -49
- package/out/concepts/Module__.js +50 -50
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/New__.js.map +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Point__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Rect__.js.map +1 -1
- package/out/concepts/Return__.js +3 -0
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/Slot__.d.ts +16 -0
- package/out/concepts/Slot__.js +43 -0
- package/out/concepts/Slot__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +1 -1
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +1 -1
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/UseComponent__.js.map +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +3 -0
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewBlock__.d.ts +34 -0
- package/out/concepts/ViewBlock__.js +82 -0
- package/out/concepts/ViewBlock__.js.map +1 -0
- package/out/concepts/ViewComponent__.d.ts +85 -0
- package/out/concepts/ViewComponent__.js +104 -0
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -0
- package/out/concepts/View__.js +13 -8
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/index__.d.ts +2 -0
- package/out/concepts/index__.js +2 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/config.d.ts +1 -1
- package/out/decorators/index.d.ts +2 -2
- package/out/generator/permission.d.ts +1 -1
- package/out/server/getLogics.js +12 -0
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getProcesses.d.ts +3 -3
- package/out/server/getScope.d.ts +1 -1
- package/out/server/naslServer.d.ts +1 -1
- package/out/server/naslServer.js +70 -36
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +1 -1
- package/out/service/storage/init.js +1 -1
- package/out/service/storage/init.js.map +1 -1
- package/out/translator/index.d.ts +1 -1
- package/out/translator/lsp.d.ts +3 -3
- package/out/utils/index.d.ts +4 -4
- package/package.json +1 -1
- package/src/concepts/App__.ts +13 -0
- package/src/concepts/Attribute__.ts +10 -59
- package/src/concepts/BindAttribute__.ts +11 -12
- package/src/concepts/BindDirective__.ts +16 -1
- package/src/concepts/BindStyle__.ts +16 -1
- package/src/concepts/CallLogic__.ts +12 -37
- package/src/concepts/ConfigProperty__.ts +8 -6
- package/src/concepts/Destination__.ts +19 -1
- package/src/concepts/ExternalDestination__.ts +6 -6
- package/src/concepts/FrontendLibrary__.ts +518 -0
- package/src/concepts/Frontend__.ts +12 -1
- package/src/concepts/Identifier__.ts +9 -0
- package/src/concepts/Logic__.ts +27 -14
- package/src/concepts/Module__.ts +92 -121
- package/src/concepts/Param__.ts +4 -0
- package/src/concepts/ProcessElement__.ts +23 -1
- package/src/concepts/Process__.ts +16 -1
- package/src/concepts/Return__.ts +2 -0
- package/src/concepts/Slot__.ts +55 -0
- package/src/concepts/StringInterpolation__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +9 -9
- package/src/concepts/Variable__.ts +2 -0
- package/src/concepts/ViewBlock__.ts +91 -0
- package/src/concepts/ViewComponent__.ts +199 -0
- package/src/concepts/View__.ts +39 -10
- package/src/concepts/index__.ts +2 -0
- package/src/server/getLogics.ts +13 -0
- package/src/server/naslServer.ts +66 -34
- package/src/server/translator.ts +1 -1
- package/src/service/storage/init.ts +1 -1
- package/yarn-error.log +2087 -0
- package/sandbox/stdlib/dist/nasl.logging.js +0 -0
- package/sandbox/stdlib/dist/nasl.util.js +0 -0
- package/src/automate/engine/dist/index.dev.js +0 -517
- package/src/common/dist/BaseNode.js +0 -1101
- package/src/concepts/basics/stdlib/dist/nasl.util.js +0 -1602
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +0 -24
- package/src/concepts/dist/BindAttribute__.js +0 -795
- package/src/concepts/dist/BindEvent__.js +0 -732
- package/src/concepts/dist/CallFunction__.js +0 -527
- package/src/concepts/dist/CallLogic__.js +0 -932
- package/src/concepts/dist/Destination__.js +0 -708
- package/src/concepts/dist/ExternalDestination__.js +0 -298
- package/src/concepts/dist/Identifier__.js +0 -311
- package/src/concepts/dist/StringInterpolation__.js +0 -231
- package/src/concepts/dist/TypeAnnotation__.js +0 -834
- package/src/concepts/dist/ViewElement__.js +0 -1692
- package/src/concepts/dist/View__.js +0 -1601
- package/src/generator/dist/genBundleFiles.js +0 -261
- package/src/generator/dist/genMetaData.js +0 -245
- package/src/generator/dist/permission.js +0 -405
- package/src/service/storage/dist/init.js +0 -579
- package/src/templator/dist/genEditTableBlock.js +0 -204
- package/src/templator/dist/genGridViewBlock.js +0 -265
- package/src/templator/dist/genListViewBlock.js +0 -84
- package/src/templator/dist/genTableBlock.js +0 -209
- package/src/templator/dist/utils.js +0 -527
|
@@ -330,12 +330,14 @@ export class ConfigProperty extends BaseNode {
|
|
|
330
330
|
@withSourceMap()
|
|
331
331
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
332
332
|
let code = `let ${this.name}: nasl.core.String; \n`;
|
|
333
|
-
this.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
333
|
+
if (this.parentNode.name === 'custom') {
|
|
334
|
+
this.values.forEach((value) => {
|
|
335
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
336
|
+
if (!value.value) {
|
|
337
|
+
code += `const __${value.env}ConfigValueEmpty: any = null;\n`;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
339
341
|
return code;
|
|
340
342
|
}
|
|
341
343
|
|
|
@@ -66,6 +66,8 @@ export class Destination extends LogicItem {
|
|
|
66
66
|
@property()
|
|
67
67
|
target: string = '_self';
|
|
68
68
|
|
|
69
|
+
|
|
70
|
+
|
|
69
71
|
/**
|
|
70
72
|
* @param source 需要合并的部分参数
|
|
71
73
|
*/
|
|
@@ -79,6 +81,7 @@ export class Destination extends LogicItem {
|
|
|
79
81
|
return super.from(source, parentNode, parentKey) as Destination;
|
|
80
82
|
}
|
|
81
83
|
|
|
84
|
+
|
|
82
85
|
/**
|
|
83
86
|
* 设置viewNamespace
|
|
84
87
|
*/
|
|
@@ -130,6 +133,10 @@ export class Destination extends LogicItem {
|
|
|
130
133
|
});
|
|
131
134
|
}
|
|
132
135
|
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
133
140
|
/**
|
|
134
141
|
* 插入实际参数
|
|
135
142
|
* @internal
|
|
@@ -162,6 +169,8 @@ export class Destination extends LogicItem {
|
|
|
162
169
|
return argument;
|
|
163
170
|
}
|
|
164
171
|
|
|
172
|
+
|
|
173
|
+
|
|
165
174
|
/**
|
|
166
175
|
* 插入实际参数
|
|
167
176
|
* @param argumentOptions 实际参数参数
|
|
@@ -184,6 +193,8 @@ export class Destination extends LogicItem {
|
|
|
184
193
|
return node;
|
|
185
194
|
}
|
|
186
195
|
|
|
196
|
+
|
|
197
|
+
|
|
187
198
|
/**
|
|
188
199
|
* 添加实际参数
|
|
189
200
|
* @internal
|
|
@@ -203,6 +214,8 @@ export class Destination extends LogicItem {
|
|
|
203
214
|
return this._insertArgumentAt(options as any, index);
|
|
204
215
|
}
|
|
205
216
|
|
|
217
|
+
|
|
218
|
+
|
|
206
219
|
/**
|
|
207
220
|
* 添加实际参数
|
|
208
221
|
* @param argumentOptions 实际参数参数
|
|
@@ -226,6 +239,9 @@ export class Destination extends LogicItem {
|
|
|
226
239
|
return node;
|
|
227
240
|
}
|
|
228
241
|
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
229
245
|
/**
|
|
230
246
|
* 删除实际参数
|
|
231
247
|
* @param argument 已有的实际参数实例
|
|
@@ -233,10 +249,12 @@ export class Destination extends LogicItem {
|
|
|
233
249
|
removeArgumentInArguments(argument: Argument): void;
|
|
234
250
|
|
|
235
251
|
removeArgumentInArguments(options: Argument) {
|
|
236
|
-
|
|
252
|
+
let argument: Argument = options;
|
|
237
253
|
return argument.delete();
|
|
238
254
|
}
|
|
239
255
|
|
|
256
|
+
|
|
257
|
+
|
|
240
258
|
/**
|
|
241
259
|
* 删除锚点参数
|
|
242
260
|
* @param name 锚点参数名称
|
|
@@ -47,7 +47,7 @@ export class ExternalDestination extends LogicItem {
|
|
|
47
47
|
@property('Anchor')
|
|
48
48
|
anchor: Anchor = undefined;
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* @param source 需要合并的部分参数
|
|
@@ -62,7 +62,7 @@ export class ExternalDestination extends LogicItem {
|
|
|
62
62
|
return super.from(source, parentNode, parentKey) as ExternalDestination;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
/**
|
|
67
67
|
* 设置外部链接
|
|
68
68
|
*/
|
|
@@ -105,9 +105,9 @@ export class ExternalDestination extends LogicItem {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* 删除逻辑项
|
|
@@ -134,7 +134,7 @@ export class ExternalDestination extends LogicItem {
|
|
|
134
134
|
return link.delete();
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* 删除锚点参数
|
|
@@ -223,7 +223,7 @@ export class ExternalDestination extends LogicItem {
|
|
|
223
223
|
|
|
224
224
|
toVue(options?: ElementToVueOptions) {
|
|
225
225
|
let url = '`';
|
|
226
|
-
const tempLink = this.link ? this.link.toVue(options) : '';
|
|
226
|
+
const tempLink = this.link ? this.link.toVue(options) : "''";
|
|
227
227
|
url += '${';
|
|
228
228
|
url += `${tempLink}`;
|
|
229
229
|
url += '}';
|
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import Namespace from './Namespace__';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
3
|
+
//================================================================================
|
|
4
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
5
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
6
|
+
//================================================================================
|
|
7
|
+
import { EventPayload, Params } from '../common/EventEmitter';
|
|
8
|
+
import { concept, excludedInJSON, property } from '../decorators';
|
|
9
|
+
|
|
10
|
+
import * as utils from '../utils';
|
|
11
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
12
|
+
import BaseNode from '../common/BaseNode';
|
|
13
|
+
import classMap from '../common/classMap';
|
|
14
|
+
import Logic from './Logic__';
|
|
15
|
+
import ViewComponent from './ViewComponent__';
|
|
16
|
+
import Module from './Module__';
|
|
17
|
+
import App from './App__';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 端包
|
|
21
|
+
*/
|
|
22
|
+
@concept('端包')
|
|
23
|
+
export class FrontendLibrary extends BaseNode {
|
|
24
|
+
/**
|
|
25
|
+
* 产品概念
|
|
26
|
+
*/
|
|
27
|
+
@property()
|
|
28
|
+
concept: 'FrontendLibrary' = 'FrontendLibrary';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 名称与type保持一致
|
|
32
|
+
*/
|
|
33
|
+
@property()
|
|
34
|
+
name: 'pc' | 'h5' = undefined;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* PC/H5 端
|
|
38
|
+
*/
|
|
39
|
+
@property()
|
|
40
|
+
type: 'pc' | 'h5' = undefined;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 逻辑列表
|
|
44
|
+
*/
|
|
45
|
+
@property('Logic')
|
|
46
|
+
logics: Array<Logic> = [];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 页面组件列表
|
|
50
|
+
*/
|
|
51
|
+
@property('ViewComponent')
|
|
52
|
+
viewComponents: Array<ViewComponent> = [];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 祖先 Module
|
|
56
|
+
*/
|
|
57
|
+
get module() {
|
|
58
|
+
return this.getAncestor('Module') as Module;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 祖先 App
|
|
62
|
+
*/
|
|
63
|
+
get app() {
|
|
64
|
+
return this.getAncestor('App') as App;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @param source 需要合并的部分参数
|
|
69
|
+
*/
|
|
70
|
+
constructor(source?: Partial<FrontendLibrary>) {
|
|
71
|
+
source = Object.assign({}, FrontendLibrary.getDefaultOptions(), source);
|
|
72
|
+
super(source);
|
|
73
|
+
super.subConstructor(source);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static from(source: any, parentNode?: any, parentKey?: string): FrontendLibrary {
|
|
77
|
+
return super.from(source, parentNode, parentKey) as FrontendLibrary;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 从父级删除该节点
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
_delete() {
|
|
85
|
+
let params: Params = null;
|
|
86
|
+
if (this.parentNode) {
|
|
87
|
+
params = (this.parentNode as any)?.__removeFrontendLibrary?.(this);
|
|
88
|
+
}
|
|
89
|
+
return params;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
getLogicExistingNames(excludedList: Array<Logic> = []) {
|
|
94
|
+
const excludedSet = new Set(excludedList);
|
|
95
|
+
return ((this.logics as Logic[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
96
|
+
}
|
|
97
|
+
getLogicUniqueName(name = 'logic1') {
|
|
98
|
+
return utils.unique(name, this.getLogicExistingNames(), undefined, true);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 插入逻辑
|
|
103
|
+
* @internal
|
|
104
|
+
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
105
|
+
*/
|
|
106
|
+
_insertLogicAt(name: string, index: number): Logic;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 插入逻辑
|
|
110
|
+
* @internal
|
|
111
|
+
* @param logicOptions 逻辑参数
|
|
112
|
+
*/
|
|
113
|
+
_insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 插入逻辑
|
|
117
|
+
* @internal
|
|
118
|
+
* @param logic 已有的逻辑实例
|
|
119
|
+
*/
|
|
120
|
+
_insertLogicAt(logic: Logic, index: number): Logic;
|
|
121
|
+
|
|
122
|
+
_insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
|
|
123
|
+
const logicOptions: any = {};
|
|
124
|
+
const relationOptions = { parentNode: this, parentKey: 'logics' };
|
|
125
|
+
let logic: Logic;
|
|
126
|
+
if (!options) {
|
|
127
|
+
logic = Logic.from({
|
|
128
|
+
...logicOptions,
|
|
129
|
+
name: this.getLogicUniqueName(),
|
|
130
|
+
}, this, 'logics');
|
|
131
|
+
} else if (typeof options === 'string') {
|
|
132
|
+
logic = Logic.from({
|
|
133
|
+
...logicOptions,
|
|
134
|
+
name: options,
|
|
135
|
+
}, this, 'logics');
|
|
136
|
+
} else if (options instanceof Logic) {
|
|
137
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
138
|
+
logic = options;
|
|
139
|
+
Object.assign(logic, relationOptions);
|
|
140
|
+
} else {
|
|
141
|
+
logic = Logic.from({
|
|
142
|
+
...logicOptions,
|
|
143
|
+
...options,
|
|
144
|
+
}, this, 'logics');
|
|
145
|
+
}
|
|
146
|
+
this.logics.splice(index, 0, logic);
|
|
147
|
+
return logic;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 插入逻辑
|
|
152
|
+
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
153
|
+
*/
|
|
154
|
+
insertLogicAt(name: string, index: number): Logic;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 插入逻辑
|
|
158
|
+
* @param logicOptions 逻辑参数
|
|
159
|
+
*/
|
|
160
|
+
insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 插入逻辑
|
|
164
|
+
* @param logic 已有的逻辑实例
|
|
165
|
+
*/
|
|
166
|
+
insertLogicAt(logic: Logic, index: number): Logic;
|
|
167
|
+
|
|
168
|
+
insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
|
|
169
|
+
const node = this._insertLogicAt(options as any, index);
|
|
170
|
+
node.create({
|
|
171
|
+
index,
|
|
172
|
+
parentNode: this,
|
|
173
|
+
parentKey: 'logics',
|
|
174
|
+
});
|
|
175
|
+
return node;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 添加逻辑
|
|
180
|
+
* @internal
|
|
181
|
+
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
182
|
+
*/
|
|
183
|
+
_addLogic(name?: string): Logic;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 添加逻辑
|
|
187
|
+
* @internal
|
|
188
|
+
* @param logicOptions 逻辑参数
|
|
189
|
+
*/
|
|
190
|
+
_addLogic(logicOptions: Partial<Logic>): Logic;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* 添加逻辑
|
|
194
|
+
* @internal
|
|
195
|
+
* @param logic 已有的逻辑实例
|
|
196
|
+
*/
|
|
197
|
+
_addLogic(logic: Logic): Logic;
|
|
198
|
+
|
|
199
|
+
_addLogic(options?: string | Partial<Logic> | Logic) {
|
|
200
|
+
const index = this.logics.length;
|
|
201
|
+
return this._insertLogicAt(options as any, index);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 添加逻辑
|
|
206
|
+
* @internal
|
|
207
|
+
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
208
|
+
*/
|
|
209
|
+
addLogic(name?: string): Logic;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* 添加逻辑
|
|
213
|
+
* @param logicOptions 逻辑参数
|
|
214
|
+
*/
|
|
215
|
+
addLogic(logicOptions: Partial<Logic>): Logic;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 添加逻辑
|
|
219
|
+
* @param logic 已有的逻辑实例
|
|
220
|
+
*/
|
|
221
|
+
addLogic(logic: Logic): Logic;
|
|
222
|
+
|
|
223
|
+
addLogic(options?: string | Partial<Logic> | Logic) {
|
|
224
|
+
const node = this._addLogic(options as any);
|
|
225
|
+
const index = this.logics.indexOf(node);
|
|
226
|
+
node.create({
|
|
227
|
+
index,
|
|
228
|
+
parentNode: this,
|
|
229
|
+
parentKey: 'logics',
|
|
230
|
+
});
|
|
231
|
+
return node;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
getViewComponentExistingNames(excludedList: Array<ViewComponent> = []) {
|
|
236
|
+
const excludedSet = new Set(excludedList);
|
|
237
|
+
return ((this.viewComponents as ViewComponent[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
238
|
+
}
|
|
239
|
+
getViewComponentUniqueName(name = 'viewComponent1') {
|
|
240
|
+
return utils.unique(name, this.getViewComponentExistingNames(), undefined, false);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 插入页面组件
|
|
245
|
+
* @internal
|
|
246
|
+
* @param name 页面组件名称,如果不填会自动生成一个唯一名称
|
|
247
|
+
*/
|
|
248
|
+
_insertViewComponentAt(name: string, index: number): ViewComponent;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* 插入页面组件
|
|
252
|
+
* @internal
|
|
253
|
+
* @param viewComponentOptions 页面组件参数
|
|
254
|
+
*/
|
|
255
|
+
_insertViewComponentAt(viewComponentOptions: Partial<ViewComponent>, index: number): ViewComponent;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 插入页面组件
|
|
259
|
+
* @internal
|
|
260
|
+
* @param viewComponent 已有的页面组件实例
|
|
261
|
+
*/
|
|
262
|
+
_insertViewComponentAt(viewComponent: ViewComponent, index: number): ViewComponent;
|
|
263
|
+
|
|
264
|
+
_insertViewComponentAt(options: string | Partial<ViewComponent> | ViewComponent, index: number) {
|
|
265
|
+
const viewComponentOptions: any = {};
|
|
266
|
+
const relationOptions = { parentNode: this, parentKey: 'viewComponents' };
|
|
267
|
+
let viewComponent: ViewComponent;
|
|
268
|
+
if (!options) {
|
|
269
|
+
viewComponent = ViewComponent.from({
|
|
270
|
+
...viewComponentOptions,
|
|
271
|
+
name: this.getViewComponentUniqueName(),
|
|
272
|
+
}, this, 'viewComponents');
|
|
273
|
+
} else if (typeof options === 'string') {
|
|
274
|
+
viewComponent = ViewComponent.from({
|
|
275
|
+
...viewComponentOptions,
|
|
276
|
+
name: options,
|
|
277
|
+
}, this, 'viewComponents');
|
|
278
|
+
} else if (options instanceof ViewComponent) {
|
|
279
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
280
|
+
viewComponent = options;
|
|
281
|
+
Object.assign(viewComponent, relationOptions);
|
|
282
|
+
} else {
|
|
283
|
+
viewComponent = ViewComponent.from({
|
|
284
|
+
...viewComponentOptions,
|
|
285
|
+
...options,
|
|
286
|
+
}, this, 'viewComponents');
|
|
287
|
+
}
|
|
288
|
+
this.viewComponents.splice(index, 0, viewComponent);
|
|
289
|
+
return viewComponent;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* 插入页面组件
|
|
294
|
+
* @param name 页面组件名称,如果不填会自动生成一个唯一名称
|
|
295
|
+
*/
|
|
296
|
+
insertViewComponentAt(name: string, index: number): ViewComponent;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* 插入页面组件
|
|
300
|
+
* @param viewComponentOptions 页面组件参数
|
|
301
|
+
*/
|
|
302
|
+
insertViewComponentAt(viewComponentOptions: Partial<ViewComponent>, index: number): ViewComponent;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* 插入页面组件
|
|
306
|
+
* @param viewComponent 已有的页面组件实例
|
|
307
|
+
*/
|
|
308
|
+
insertViewComponentAt(viewComponent: ViewComponent, index: number): ViewComponent;
|
|
309
|
+
|
|
310
|
+
insertViewComponentAt(options: string | Partial<ViewComponent> | ViewComponent, index: number) {
|
|
311
|
+
const node = this._insertViewComponentAt(options as any, index);
|
|
312
|
+
node.create({
|
|
313
|
+
index,
|
|
314
|
+
parentNode: this,
|
|
315
|
+
parentKey: 'viewComponents',
|
|
316
|
+
});
|
|
317
|
+
return node;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* 添加页面组件
|
|
322
|
+
* @internal
|
|
323
|
+
* @param name 页面组件名称,如果不填会自动生成一个唯一名称
|
|
324
|
+
*/
|
|
325
|
+
_addViewComponent(name?: string): ViewComponent;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* 添加页面组件
|
|
329
|
+
* @internal
|
|
330
|
+
* @param viewComponentOptions 页面组件参数
|
|
331
|
+
*/
|
|
332
|
+
_addViewComponent(viewComponentOptions: Partial<ViewComponent>): ViewComponent;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* 添加页面组件
|
|
336
|
+
* @internal
|
|
337
|
+
* @param viewComponent 已有的页面组件实例
|
|
338
|
+
*/
|
|
339
|
+
_addViewComponent(viewComponent: ViewComponent): ViewComponent;
|
|
340
|
+
|
|
341
|
+
_addViewComponent(options?: string | Partial<ViewComponent> | ViewComponent) {
|
|
342
|
+
const index = this.viewComponents.length;
|
|
343
|
+
return this._insertViewComponentAt(options as any, index);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* 添加页面组件
|
|
348
|
+
* @internal
|
|
349
|
+
* @param name 页面组件名称,如果不填会自动生成一个唯一名称
|
|
350
|
+
*/
|
|
351
|
+
addViewComponent(name?: string): ViewComponent;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* 添加页面组件
|
|
355
|
+
* @param viewComponentOptions 页面组件参数
|
|
356
|
+
*/
|
|
357
|
+
addViewComponent(viewComponentOptions: Partial<ViewComponent>): ViewComponent;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* 添加页面组件
|
|
361
|
+
* @param viewComponent 已有的页面组件实例
|
|
362
|
+
*/
|
|
363
|
+
addViewComponent(viewComponent: ViewComponent): ViewComponent;
|
|
364
|
+
|
|
365
|
+
addViewComponent(options?: string | Partial<ViewComponent> | ViewComponent) {
|
|
366
|
+
const node = this._addViewComponent(options as any);
|
|
367
|
+
const index = this.viewComponents.indexOf(node);
|
|
368
|
+
node.create({
|
|
369
|
+
index,
|
|
370
|
+
parentNode: this,
|
|
371
|
+
parentKey: 'viewComponents',
|
|
372
|
+
});
|
|
373
|
+
return node;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* 删除逻辑
|
|
381
|
+
* @param name 逻辑名称
|
|
382
|
+
*/
|
|
383
|
+
removeLogic(name: string): void;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* 删除逻辑
|
|
387
|
+
* @param logic 已有的逻辑实例
|
|
388
|
+
*/
|
|
389
|
+
removeLogic(logic: Logic): void;
|
|
390
|
+
|
|
391
|
+
removeLogic(options: string | Logic) {
|
|
392
|
+
let logic: Logic;
|
|
393
|
+
if (typeof options === 'string') {
|
|
394
|
+
logic = (this.logics as Logic[]).find((item) => item.name === options);
|
|
395
|
+
if (!logic) {
|
|
396
|
+
throw new Error('找不到逻辑 ' + options);
|
|
397
|
+
}
|
|
398
|
+
} else {
|
|
399
|
+
logic = options;
|
|
400
|
+
}
|
|
401
|
+
return logic.delete();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
__removeLogic(logic: Logic) {
|
|
405
|
+
const parentKey = logic.parentKey;
|
|
406
|
+
const params: Params = {
|
|
407
|
+
parentNode: this,
|
|
408
|
+
parentKey,
|
|
409
|
+
index: -1,
|
|
410
|
+
object: null,
|
|
411
|
+
oldObject: logic,
|
|
412
|
+
};
|
|
413
|
+
if (parentKey) {
|
|
414
|
+
params.parentKey = parentKey;
|
|
415
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
416
|
+
const index = (this as any)[parentKey].indexOf(logic);
|
|
417
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
418
|
+
params.index = index;
|
|
419
|
+
} else if ((this as any)[parentKey] === logic) {
|
|
420
|
+
params.index = 0;
|
|
421
|
+
(this as any)[parentKey] = undefined;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return params;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* 删除页面组件
|
|
431
|
+
* @param name 页面组件名称
|
|
432
|
+
*/
|
|
433
|
+
removeViewComponent(name: string): void;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* 删除页面组件
|
|
437
|
+
* @param viewComponent 已有的页面组件实例
|
|
438
|
+
*/
|
|
439
|
+
removeViewComponent(viewComponent: ViewComponent): void;
|
|
440
|
+
|
|
441
|
+
removeViewComponent(options: string | ViewComponent) {
|
|
442
|
+
let viewComponent: ViewComponent;
|
|
443
|
+
if (typeof options === 'string') {
|
|
444
|
+
viewComponent = (this.viewComponents as ViewComponent[]).find((item) => item.name === options);
|
|
445
|
+
if (!viewComponent) {
|
|
446
|
+
throw new Error('找不到页面组件 ' + options);
|
|
447
|
+
}
|
|
448
|
+
} else {
|
|
449
|
+
viewComponent = options;
|
|
450
|
+
}
|
|
451
|
+
return viewComponent.delete();
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
__removeViewComponent(viewComponent: ViewComponent) {
|
|
455
|
+
const parentKey = viewComponent.parentKey;
|
|
456
|
+
const params: Params = {
|
|
457
|
+
parentNode: this,
|
|
458
|
+
parentKey,
|
|
459
|
+
index: -1,
|
|
460
|
+
object: null,
|
|
461
|
+
oldObject: viewComponent,
|
|
462
|
+
};
|
|
463
|
+
if (parentKey) {
|
|
464
|
+
params.parentKey = parentKey;
|
|
465
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
466
|
+
const index = (this as any)[parentKey].indexOf(viewComponent);
|
|
467
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
468
|
+
params.index = index;
|
|
469
|
+
} else if ((this as any)[parentKey] === viewComponent) {
|
|
470
|
+
params.index = 0;
|
|
471
|
+
(this as any)[parentKey] = undefined;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return params;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
//================================================================================
|
|
478
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
479
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
480
|
+
//================================================================================
|
|
481
|
+
getNamespace() {
|
|
482
|
+
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
483
|
+
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
484
|
+
const parentName = this.parentNode.name;
|
|
485
|
+
const arr = [parentNamespace];
|
|
486
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
487
|
+
arr.push(parentName);
|
|
488
|
+
}
|
|
489
|
+
return `${arr.join('.')}.frontends`;
|
|
490
|
+
} else
|
|
491
|
+
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
getTsNamespace() {
|
|
495
|
+
if (this.parentNode && (this.parentNode as Namespace).getTsNamespace) {
|
|
496
|
+
const parentNamespace = (this.parentNode as Namespace).getTsNamespace();
|
|
497
|
+
const parentName = this.parentNode.tsName || this.parentNode.name;
|
|
498
|
+
const arr = [parentNamespace];
|
|
499
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
500
|
+
arr.push(parentName);
|
|
501
|
+
}
|
|
502
|
+
return `${arr.join('.')}.frontends`;
|
|
503
|
+
} else
|
|
504
|
+
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
//================================================================================
|
|
508
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
509
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
510
|
+
//================================================================================
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
classMap.FrontendLibrary = FrontendLibrary;
|
|
514
|
+
export default FrontendLibrary;
|
|
515
|
+
//================================================================================
|
|
516
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
517
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
518
|
+
//================================================================================
|