@lcap/nasl 2.18.0-beta.7 → 2.19.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/out/automate/template/myProcess.js +1 -1
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/bak/translator.js +2 -1
- package/out/bak/translator.js.map +1 -1
- package/out/common/Command.d.ts +1 -0
- package/out/common/Command.js +5 -1
- package/out/common/Command.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +1 -0
- package/out/concepts/AnonymousFunction__.js +40 -2
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +10 -0
- package/out/concepts/App__.js +132 -0
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js +4 -3
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +2 -0
- package/out/concepts/BatchAssignment__.js +45 -1
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +8 -1
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/CallFunction__.js +51 -18
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +6 -4
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +87 -15
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +4 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +2 -0
- package/out/concepts/DataSource__.js +55 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -0
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +1 -0
- package/out/concepts/Identifier__.js +18 -7
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -0
- package/out/concepts/Logic__.js +27 -14
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.js +13 -8
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +345 -0
- package/out/concepts/NewComposite__.js +1067 -0
- package/out/concepts/NewComposite__.js.map +1 -0
- package/out/concepts/NewList__.d.ts +130 -0
- package/out/concepts/NewList__.js +353 -0
- package/out/concepts/NewList__.js.map +1 -0
- package/out/concepts/NewMap__.d.ts +221 -0
- package/out/concepts/NewMap__.js +492 -0
- package/out/concepts/NewMap__.js.map +1 -0
- package/out/concepts/New__.d.ts +19 -0
- package/out/concepts/New__.js +66 -0
- package/out/concepts/New__.js.map +1 -0
- package/out/concepts/Param__.d.ts +2 -0
- package/out/concepts/Param__.js +40 -3
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +31 -10
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.d.ts +30 -0
- package/out/concepts/{ConstructArgument__.js → ProcessOutcomes__.js} +27 -48
- package/out/concepts/ProcessOutcomes__.js.map +1 -0
- package/out/concepts/Return__.js +2 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/SelectMembers__.js +3 -3
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +12 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +4 -0
- package/out/concepts/TypeAnnotation__.js +66 -12
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +2 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +12 -0
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -0
- package/out/concepts/View__.js +9 -0
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.logging.js +5 -0
- package/out/concepts/basics/stdlib/nasl.logging.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +2 -0
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +151 -19
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/index__.d.ts +5 -0
- package/out/concepts/index__.js +5 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +1 -0
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genMetaData.js +1 -6
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -0
- package/out/generator/genReleaseBody.js +18 -1
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/index.d.ts +1 -0
- package/out/generator/index.js +1 -0
- package/out/generator/index.js.map +1 -1
- package/out/generator/permission.d.ts +9 -0
- package/out/generator/permission.js +235 -0
- package/out/generator/permission.js.map +1 -0
- package/out/index.d.ts +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +69 -9
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +7 -3
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.js +6 -0
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.d.ts +2 -1
- package/out/server/getLogics.js +11 -0
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +1 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +1 -1
- package/out/server/naslServer.js +161 -22
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +8 -0
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +53 -8
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/add.configs.js +4 -0
- package/out/service/creator/add.configs.js.map +1 -1
- package/out/service/datasource/api.d.ts +12 -0
- package/out/service/datasource/api.js +14 -0
- package/out/service/datasource/api.js.map +1 -0
- package/out/service/datasource/index.d.ts +2 -0
- package/out/service/datasource/index.js +10 -0
- package/out/service/datasource/index.js.map +1 -0
- package/out/service/storage/init.js +8 -1
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genEditTableBlock.js +4 -5
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +4 -3
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +16 -14
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +5 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +6 -10
- package/out/templator/genTableBlock.js.map +1 -1
- package/package.json +1 -1
- package/sandbox/stdlib/dist/nasl.util.js +0 -0
- package/sandbox/stdlib/nasl.auth.ts +1 -1
- package/sandbox/stdlib/nasl.core.ts +4 -0
- package/sandbox/stdlib/nasl.logging.ts +4 -4
- package/sandbox/stdlib/nasl.util.ts +13 -4
- package/src/automate/template/myProcess.js +1 -1
- package/src/bak/translator.js +4 -1
- package/src/common/Command.ts +4 -0
- package/src/concepts/AnonymousFunction__.ts +48 -2
- package/src/concepts/App__.ts +140 -41
- package/src/concepts/Assignee__.ts +4 -3
- package/src/concepts/BatchAssignment__.ts +45 -1
- package/src/concepts/BindAttribute__.ts +9 -2
- package/src/concepts/CallFunction__.ts +65 -31
- package/src/concepts/CallInterface__.ts +6 -22
- package/src/concepts/CallLogic__.ts +62 -13
- package/src/concepts/CallQueryComponent__.ts +4 -1
- package/src/concepts/DataSource__.ts +56 -1
- package/src/concepts/ForEachStatement__.ts +2 -0
- package/src/concepts/Identifier__.ts +18 -7
- package/src/concepts/LogicItem__.ts +1 -1
- package/src/concepts/Logic__.ts +48 -32
- package/src/concepts/Match__.ts +12 -8
- package/src/concepts/NewComposite__.ts +1356 -0
- package/src/concepts/NewList__.ts +444 -0
- package/src/concepts/NewMap__.ts +678 -0
- package/src/concepts/New__.ts +73 -0
- package/src/concepts/Param__.ts +238 -199
- package/src/concepts/ProcessElement__.ts +32 -10
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/ProcessOutcomes__.ts +90 -0
- package/src/concepts/Return__.ts +4 -1
- package/src/concepts/SelectMembers__.ts +3 -3
- package/src/concepts/StringInterpolation__.ts +21 -11
- package/src/concepts/TypeAnnotation__.ts +71 -50
- package/src/concepts/ValidationRule__.ts +19 -1
- package/src/concepts/Variable__.ts +4 -1
- package/src/concepts/ViewElement__.ts +38 -1
- package/src/concepts/View__.ts +12 -2
- package/src/concepts/basics/stdlib/dist/nasl.util.js +133 -34
- package/src/concepts/basics/stdlib/nasl.auth.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.logging.ts +5 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +2 -0
- package/src/concepts/basics/stdlib/nasl.util.ts +153 -19
- package/src/concepts/dist/BindAttribute__.js +760 -0
- package/src/concepts/dist/BindEvent__.js +732 -0
- package/src/concepts/dist/CallFunction__.js +21 -7
- package/src/concepts/dist/CallLogic__.js +50 -10
- package/src/concepts/dist/Identifier__.js +311 -0
- package/src/concepts/dist/StringInterpolation__.js +231 -0
- package/src/concepts/dist/TypeAnnotation__.js +834 -0
- package/src/concepts/dist/ViewElement__.js +12 -0
- package/src/concepts/dist/View__.js +1601 -0
- package/src/concepts/index__.ts +5 -0
- package/src/enums/KEYWORDS.ts +1 -0
- package/src/generator/dist/genMetaData.js +1 -5
- package/src/generator/dist/permission.js +392 -0
- package/src/generator/genMetaData.ts +1 -6
- package/src/generator/genReleaseBody.ts +21 -3
- package/src/generator/index.ts +1 -0
- package/src/generator/permission.ts +271 -0
- package/src/index.ts +1 -1
- package/src/server/dist/naslServer.js +385 -269
- package/src/server/entity2LogicNamespace.ts +70 -10
- package/src/server/extendBaseNode.ts +7 -3
- package/src/server/formatTsUtils.ts +6 -0
- package/src/server/getLogics.ts +13 -1
- package/src/server/getMemberIdentifier.ts +1 -1
- package/src/server/naslServer.ts +162 -29
- package/src/server/process2LogicNamespace.ts +8 -0
- package/src/server/translator.ts +52 -9
- package/src/service/creator/add.configs.js +4 -0
- package/src/service/dataSource/api.js +11 -0
- package/src/service/dataSource/index.js +6 -0
- package/src/service/storage/dist/init.js +8 -1
- package/src/service/storage/init.ts +9 -2
- package/src/service/video/VideoTranscribe.js +1 -0
- package/src/templator/dist/genEditTableBlock.js +204 -0
- package/src/templator/dist/genGridViewBlock.js +265 -0
- package/src/templator/dist/genListViewBlock.js +84 -0
- package/src/templator/dist/genTableBlock.js +209 -0
- package/src/templator/dist/utils.js +527 -0
- package/src/templator/genEditTableBlock.ts +8 -16
- package/src/templator/genGetBlock.ts +18 -19
- package/src/templator/genGridViewBlock.ts +18 -18
- package/src/templator/genListViewBlock.ts +8 -11
- package/src/templator/genTableBlock.ts +6 -10
- package/ts-worker/dist/webpack.config.dev.js +1 -3
- package/ts-worker/lib/tsserver.js +8 -1
- package/out/automate/engine/2.14-components.d.ts +0 -1115
- package/out/automate/engine/2.14-components.js +0 -1087
- package/out/automate/engine/2.14-components.js.map +0 -1
- package/out/concepts/ConstructArgument__.d.ts +0 -40
- package/out/concepts/ConstructArgument__.js.map +0 -1
- package/out/concepts/Construct__.d.ts +0 -189
- package/out/concepts/Construct__.js +0 -340
- package/out/concepts/Construct__.js.map +0 -1
- package/out/concepts/MatchExpression__.d.ts +0 -97
- package/out/concepts/MatchExpression__.js +0 -281
- package/out/concepts/MatchExpression__.js.map +0 -1
- package/out/templator/sql-parser/index.d.ts +0 -1
- package/out/templator/sql-parser/index.js +0 -228
- package/out/templator/sql-parser/index.js.map +0 -1
- package/out/templator/sql-parser/parser.js +0 -26664
- package/out/templator/sql-parser/parser.js.map +0 -1
- package/src/concepts/dist/Anchor__.js +0 -179
- package/src/concepts/dist/Assignment__.js +0 -301
- package/src/concepts/dist/CallInterface__.js +0 -533
- package/src/concepts/dist/ForEachStatement__.js +0 -426
- package/src/concepts/dist/MatchCase__.js +0 -587
- package/src/concepts/dist/Match__.js +0 -631
- package/src/concepts/dist/MemberExpression__.js +0 -348
- package/src/concepts/dist/Param__.js +0 -538
- package/src/concepts/dist/Return__.js +0 -494
- package/src/concepts/dist/Variable__.js +0 -537
- package/src/server/dist/formatTsUtils.js +0 -683
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import { ElementToVueOptions } from './ViewElement__';
|
|
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 TypeAnnotation from './TypeAnnotation__';
|
|
15
|
+
import LogicItem from './LogicItem__';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* list构造器
|
|
19
|
+
*/
|
|
20
|
+
@concept('list构造器')
|
|
21
|
+
export class NewList extends LogicItem {
|
|
22
|
+
/**
|
|
23
|
+
* 产品概念
|
|
24
|
+
*/
|
|
25
|
+
@property()
|
|
26
|
+
concept: 'NewList' = 'NewList';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 类型
|
|
30
|
+
*/
|
|
31
|
+
@property('TypeAnnotation')
|
|
32
|
+
typeAnnotation: TypeAnnotation = undefined;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 成员表达式
|
|
36
|
+
*/
|
|
37
|
+
@property('LogicItem')
|
|
38
|
+
items: Array<LogicItem> = [];
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param source 需要合并的部分参数
|
|
44
|
+
*/
|
|
45
|
+
constructor(source?: Partial<NewList>) {
|
|
46
|
+
source = Object.assign({}, NewList.getDefaultOptions(), source);
|
|
47
|
+
super(source);
|
|
48
|
+
super.subConstructor(source);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static from(source: any, parentNode?: any, parentKey?: string): NewList {
|
|
52
|
+
return super.from(source, parentNode, parentKey) as NewList;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 设置类型
|
|
58
|
+
*/
|
|
59
|
+
setTypeAnnotation(typeAnnotation: TypeAnnotation) {
|
|
60
|
+
typeAnnotation._delete();
|
|
61
|
+
const relationOptions = { parentNode: this, parentKey: 'typeAnnotation' };
|
|
62
|
+
Object.assign(typeAnnotation, relationOptions);
|
|
63
|
+
const object = {
|
|
64
|
+
typeAnnotation,
|
|
65
|
+
};
|
|
66
|
+
this.update({
|
|
67
|
+
...object,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 设置成员表达式
|
|
73
|
+
*/
|
|
74
|
+
setItems(items: Array<LogicItem>) {
|
|
75
|
+
const object = {
|
|
76
|
+
items,
|
|
77
|
+
};
|
|
78
|
+
this.update({
|
|
79
|
+
...object,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getItemExistingNames(excludedList: Array<LogicItem> = []) {
|
|
84
|
+
const excludedSet = new Set(excludedList);
|
|
85
|
+
return ((this.items as LogicItem[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
86
|
+
}
|
|
87
|
+
getItemUniqueName(name = 'logicItem1') {
|
|
88
|
+
return utils.unique(name, this.getItemExistingNames(), undefined, false);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 插入逻辑项
|
|
93
|
+
* @internal
|
|
94
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
95
|
+
*/
|
|
96
|
+
_insertItemAt(name: string, index: number): LogicItem;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 插入逻辑项
|
|
100
|
+
* @internal
|
|
101
|
+
* @param logicItemOptions 逻辑项参数
|
|
102
|
+
*/
|
|
103
|
+
_insertItemAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 插入逻辑项
|
|
107
|
+
* @internal
|
|
108
|
+
* @param logicItem 已有的逻辑项实例
|
|
109
|
+
*/
|
|
110
|
+
_insertItemAt(logicItem: LogicItem, index: number): LogicItem;
|
|
111
|
+
|
|
112
|
+
_insertItemAt(options: string | Partial<LogicItem> | LogicItem, index: number) {
|
|
113
|
+
const logicItemOptions: any = {};
|
|
114
|
+
const relationOptions = { parentNode: this, parentKey: 'items' };
|
|
115
|
+
let logicItem: LogicItem;
|
|
116
|
+
if (!options) {
|
|
117
|
+
logicItem = LogicItem.from({
|
|
118
|
+
...logicItemOptions,
|
|
119
|
+
name: this.getItemUniqueName(),
|
|
120
|
+
}, this, 'items');
|
|
121
|
+
} else if (typeof options === 'string') {
|
|
122
|
+
logicItem = LogicItem.from({
|
|
123
|
+
...logicItemOptions,
|
|
124
|
+
name: options,
|
|
125
|
+
}, this, 'items');
|
|
126
|
+
} else if (options instanceof LogicItem) {
|
|
127
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
128
|
+
logicItem = options;
|
|
129
|
+
Object.assign(logicItem, relationOptions);
|
|
130
|
+
} else {
|
|
131
|
+
logicItem = LogicItem.from({
|
|
132
|
+
...logicItemOptions,
|
|
133
|
+
...options,
|
|
134
|
+
}, this, 'items');
|
|
135
|
+
}
|
|
136
|
+
this.items.splice(index, 0, logicItem);
|
|
137
|
+
return logicItem;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 插入逻辑项
|
|
142
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
143
|
+
*/
|
|
144
|
+
insertItemAt(name: string, index: number): LogicItem;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 插入逻辑项
|
|
148
|
+
* @param logicItemOptions 逻辑项参数
|
|
149
|
+
*/
|
|
150
|
+
insertItemAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 插入逻辑项
|
|
154
|
+
* @param logicItem 已有的逻辑项实例
|
|
155
|
+
*/
|
|
156
|
+
insertItemAt(logicItem: LogicItem, index: number): LogicItem;
|
|
157
|
+
|
|
158
|
+
insertItemAt(options: string | Partial<LogicItem> | LogicItem, index: number) {
|
|
159
|
+
const node = this._insertItemAt(options as any, index);
|
|
160
|
+
node.create({
|
|
161
|
+
index,
|
|
162
|
+
parentNode: this,
|
|
163
|
+
parentKey: 'items',
|
|
164
|
+
});
|
|
165
|
+
return node;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 添加逻辑项
|
|
170
|
+
* @internal
|
|
171
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
172
|
+
*/
|
|
173
|
+
_addItem(name?: string): LogicItem;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 添加逻辑项
|
|
177
|
+
* @internal
|
|
178
|
+
* @param logicItemOptions 逻辑项参数
|
|
179
|
+
*/
|
|
180
|
+
_addItem(logicItemOptions: Partial<LogicItem>): LogicItem;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 添加逻辑项
|
|
184
|
+
* @internal
|
|
185
|
+
* @param logicItem 已有的逻辑项实例
|
|
186
|
+
*/
|
|
187
|
+
_addItem(logicItem: LogicItem): LogicItem;
|
|
188
|
+
|
|
189
|
+
_addItem(options?: string | Partial<LogicItem> | LogicItem) {
|
|
190
|
+
const index = this.items.length;
|
|
191
|
+
return this._insertItemAt(options as any, index);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 添加逻辑项
|
|
196
|
+
* @internal
|
|
197
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
198
|
+
*/
|
|
199
|
+
addItem(name?: string): LogicItem;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 添加逻辑项
|
|
203
|
+
* @param logicItemOptions 逻辑项参数
|
|
204
|
+
*/
|
|
205
|
+
addItem(logicItemOptions: Partial<LogicItem>): LogicItem;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 添加逻辑项
|
|
209
|
+
* @param logicItem 已有的逻辑项实例
|
|
210
|
+
*/
|
|
211
|
+
addItem(logicItem: LogicItem): LogicItem;
|
|
212
|
+
|
|
213
|
+
addItem(options?: string | Partial<LogicItem> | LogicItem) {
|
|
214
|
+
const node = this._addItem(options as any);
|
|
215
|
+
const index = this.items.indexOf(node);
|
|
216
|
+
node.create({
|
|
217
|
+
index,
|
|
218
|
+
parentNode: this,
|
|
219
|
+
parentKey: 'items',
|
|
220
|
+
});
|
|
221
|
+
return node;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 删除类型标注
|
|
229
|
+
* @param name 类型标注名称
|
|
230
|
+
*/
|
|
231
|
+
removeTypeAnnotation(name: string): void;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 删除类型标注
|
|
235
|
+
* @param typeAnnotation 已有的类型标注实例
|
|
236
|
+
*/
|
|
237
|
+
removeTypeAnnotation(typeAnnotation: TypeAnnotation): void;
|
|
238
|
+
|
|
239
|
+
removeTypeAnnotation(options: string | TypeAnnotation) {
|
|
240
|
+
let typeAnnotation: TypeAnnotation;
|
|
241
|
+
if (typeof options === 'string') {
|
|
242
|
+
typeAnnotation = this.typeAnnotation;
|
|
243
|
+
if (!typeAnnotation) {
|
|
244
|
+
throw new Error('找不到类型标注 ' + options);
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
typeAnnotation = options;
|
|
248
|
+
}
|
|
249
|
+
return typeAnnotation.delete();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
__removeTypeAnnotation(typeAnnotation: TypeAnnotation) {
|
|
253
|
+
const parentKey = typeAnnotation.parentKey;
|
|
254
|
+
const params: Params = {
|
|
255
|
+
parentNode: this,
|
|
256
|
+
parentKey,
|
|
257
|
+
index: -1,
|
|
258
|
+
object: null,
|
|
259
|
+
oldObject: typeAnnotation,
|
|
260
|
+
};
|
|
261
|
+
if (parentKey) {
|
|
262
|
+
params.parentKey = parentKey;
|
|
263
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
264
|
+
const index = (this as any)[parentKey].indexOf(typeAnnotation);
|
|
265
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
266
|
+
params.index = index;
|
|
267
|
+
} else if ((this as any)[parentKey] === typeAnnotation) {
|
|
268
|
+
params.index = 0;
|
|
269
|
+
(this as any)[parentKey] = undefined;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return params;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* 删除逻辑项
|
|
279
|
+
* @param name 逻辑项名称
|
|
280
|
+
*/
|
|
281
|
+
removeItem(name: string): void;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* 删除逻辑项
|
|
285
|
+
* @param logicItem 已有的逻辑项实例
|
|
286
|
+
*/
|
|
287
|
+
removeItem(logicItem: LogicItem): void;
|
|
288
|
+
|
|
289
|
+
removeItem(options: string | LogicItem) {
|
|
290
|
+
let logicItem: LogicItem;
|
|
291
|
+
if (typeof options === 'string') {
|
|
292
|
+
logicItem = (this.items as LogicItem[]).find((item) => item.name === options);
|
|
293
|
+
if (!logicItem) {
|
|
294
|
+
throw new Error('找不到逻辑项 ' + options);
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
logicItem = options;
|
|
298
|
+
}
|
|
299
|
+
return logicItem.delete();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
__removeLogicItem(logicItem: LogicItem) {
|
|
303
|
+
const parentKey = logicItem.parentKey;
|
|
304
|
+
const params: Params = {
|
|
305
|
+
parentNode: this,
|
|
306
|
+
parentKey,
|
|
307
|
+
index: -1,
|
|
308
|
+
object: null,
|
|
309
|
+
oldObject: logicItem,
|
|
310
|
+
};
|
|
311
|
+
if (parentKey) {
|
|
312
|
+
params.parentKey = parentKey;
|
|
313
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
314
|
+
const index = (this as any)[parentKey].indexOf(logicItem);
|
|
315
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
316
|
+
params.index = index;
|
|
317
|
+
} else if ((this as any)[parentKey] === logicItem) {
|
|
318
|
+
params.index = 0;
|
|
319
|
+
(this as any)[parentKey] = undefined;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return params;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
//================================================================================
|
|
326
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
327
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
328
|
+
//================================================================================
|
|
329
|
+
toUI(state?: TranslatorState): string {
|
|
330
|
+
let code = '';
|
|
331
|
+
code += '[';
|
|
332
|
+
this.items.forEach((item, index) => {
|
|
333
|
+
code += item.toUI(shiftState(state, code, { inline: true }));
|
|
334
|
+
if (index + 1 < this.items.length)
|
|
335
|
+
code += ', ';
|
|
336
|
+
});
|
|
337
|
+
code += ']';
|
|
338
|
+
return code;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
toJS(state?: TranslatorState): string {
|
|
342
|
+
let code = '';
|
|
343
|
+
code += 'await (async () => {\n';
|
|
344
|
+
code += 'const arr = [\n';
|
|
345
|
+
this.items.forEach((item, index) => {
|
|
346
|
+
code += item.toJS(shiftState(state, code, { inline: true }));
|
|
347
|
+
if (index + 1 < this.items.length)
|
|
348
|
+
code += ', ';
|
|
349
|
+
});
|
|
350
|
+
code += '\n];\n';
|
|
351
|
+
code += `return arr;\n`;
|
|
352
|
+
code += '})()';
|
|
353
|
+
return code;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
@withSourceMap()
|
|
357
|
+
toEmbeddedTS(state?: TranslatorState): string {
|
|
358
|
+
let code = '';
|
|
359
|
+
if (this.typeAnnotation) {
|
|
360
|
+
code += '(() => { \n';
|
|
361
|
+
// ts报错检查
|
|
362
|
+
code += 'function __newComposite() {\n';
|
|
363
|
+
const typeCode = `nasl.util.New<${this.typeAnnotation.sortedTypeKey}>()`;
|
|
364
|
+
this.items.forEach((item, index) => {
|
|
365
|
+
code += `nasl.util.Add(${typeCode}, `;
|
|
366
|
+
code += item.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
367
|
+
code += ');';
|
|
368
|
+
code += '\n';
|
|
369
|
+
});
|
|
370
|
+
code += `return ${typeCode};\n`;
|
|
371
|
+
code += '};\n';
|
|
372
|
+
|
|
373
|
+
code += 'return __newComposite();\n';
|
|
374
|
+
code += '})()';
|
|
375
|
+
} else {
|
|
376
|
+
code += '(() => { \n';
|
|
377
|
+
const arr: any = [];
|
|
378
|
+
this.items.forEach((item, index) => {
|
|
379
|
+
if (item.concept === 'Unparsed')
|
|
380
|
+
return;
|
|
381
|
+
arr.push(item.toEmbeddedTS(shiftState(state, code, { inline: true })));
|
|
382
|
+
code += arr[index];
|
|
383
|
+
code += '; ';
|
|
384
|
+
});
|
|
385
|
+
code += '\n';
|
|
386
|
+
if (!arr.length || arr.every((item: any) => ['__IDENTIFIER__', '__IDENTIFIER__()', 'null'].includes(item)))
|
|
387
|
+
code += '__IDENTIFIER__;\n';
|
|
388
|
+
// ts报错检查
|
|
389
|
+
code += 'function __newComposite() {\n';
|
|
390
|
+
if (this.items.length === 0) {
|
|
391
|
+
code += 'return nasl.util.NewList();\n';
|
|
392
|
+
} else {
|
|
393
|
+
code += 'let arr = [';
|
|
394
|
+
this.items.forEach((item, index) => {
|
|
395
|
+
code += ['__IDENTIFIER__', '__IDENTIFIER__()'].includes(arr[index]) ? null : arr[index];
|
|
396
|
+
if (index + 1 < this.items.length)
|
|
397
|
+
code += ', ';
|
|
398
|
+
});
|
|
399
|
+
code += ']\n';
|
|
400
|
+
code += 'return nasl.util.NewList(...arr);\n';
|
|
401
|
+
}
|
|
402
|
+
code += '};\n';
|
|
403
|
+
|
|
404
|
+
code += 'return __newComposite();\n';
|
|
405
|
+
code += '})()';
|
|
406
|
+
}
|
|
407
|
+
return code;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
getInitCode(state?: TranslatorState): string {
|
|
411
|
+
let code = '';
|
|
412
|
+
code += '(() => { \n';
|
|
413
|
+
code += 'function __newComposite() {\n';
|
|
414
|
+
if (this.items.length === 0) {
|
|
415
|
+
code += 'return nasl.util.NewList();\n';
|
|
416
|
+
} else {
|
|
417
|
+
code += 'let arr = [';
|
|
418
|
+
this.items.forEach((item, index) => {
|
|
419
|
+
const ts = item.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
420
|
+
code += ['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts;
|
|
421
|
+
if (index + 1 < this.items.length)
|
|
422
|
+
code += ', ';
|
|
423
|
+
});
|
|
424
|
+
code += ']\n';
|
|
425
|
+
code += 'return nasl.util.NewList(...arr);\n';
|
|
426
|
+
}
|
|
427
|
+
code += '};\n';
|
|
428
|
+
|
|
429
|
+
code += 'return __newComposite();\n';
|
|
430
|
+
code += '})()';
|
|
431
|
+
return code;
|
|
432
|
+
}
|
|
433
|
+
//================================================================================
|
|
434
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
435
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
436
|
+
//================================================================================
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
classMap.NewList = NewList;
|
|
440
|
+
export default NewList;
|
|
441
|
+
//================================================================================
|
|
442
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
443
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
444
|
+
//================================================================================
|