@lcap/nasl 2.20.0-beta.1 → 2.20.0-beta.2
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/index.d.ts +1 -1
- package/out/automate/engine/index.js +7 -7
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +1 -1
- package/out/automate/engine/uniqueName.js +3 -3
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/template/myProcess.js +1 -1
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/bak/translator.js +38 -85
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +10 -6
- package/out/common/BaseNode.js +53 -7
- package/out/common/BaseNode.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 +89 -261
- package/out/concepts/App__.js +315 -367
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.d.ts +5 -5
- package/out/concepts/AssignmentLine__.js +6 -6
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -2
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +62 -60
- package/out/concepts/BatchAssignment__.js +113 -42
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +24 -0
- package/out/concepts/BindAttribute__.js +54 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +5 -0
- package/out/concepts/BindDirective__.js +6 -0
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +5 -0
- package/out/concepts/BindEvent__.js +6 -0
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +7 -2
- package/out/concepts/BindStyle__.js +9 -3
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +0 -8
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +90 -38
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +7 -0
- package/out/concepts/CallInterface__.js +54 -7
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +2 -1
- package/out/concepts/CallLogic__.js +171 -37
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +16 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js +3 -0
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.d.ts +5 -0
- package/out/concepts/Constant__.js +6 -0
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +8 -0
- package/out/concepts/DataSource__.js +96 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +11 -2
- package/out/concepts/Destination__.js +156 -51
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +21 -8
- package/out/concepts/EntityProperty__.js +109 -23
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +32 -0
- package/out/concepts/Entity__.js +117 -2
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +0 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ExternalDestination__.d.ts +73 -0
- package/out/concepts/ExternalDestination__.js +264 -0
- package/out/concepts/ExternalDestination__.js.map +1 -0
- package/out/concepts/ForEachStatement__.d.ts +0 -4
- package/out/concepts/ForEachStatement__.js +4 -8
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +370 -0
- package/out/concepts/Frontend__.js +669 -0
- package/out/concepts/Frontend__.js.map +1 -0
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +1 -0
- package/out/concepts/Identifier__.js +33 -10
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.d.ts +8 -0
- package/out/concepts/IfStatement__.js +22 -0
- 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/LogicItem__.d.ts +6 -1
- package/out/concepts/LogicItem__.js +6 -0
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +91 -80
- package/out/concepts/Logic__.js +178 -59
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +1 -1
- package/out/concepts/MatchCase__.js +15 -8
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.d.ts +21 -19
- package/out/concepts/Match__.js +118 -26
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +4 -1
- package/out/concepts/MemberExpression__.js +30 -15
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +345 -0
- package/out/concepts/NewComposite__.js +1068 -0
- package/out/concepts/NewComposite__.js.map +1 -0
- package/out/concepts/NewList__.d.ts +130 -0
- package/out/concepts/NewList__.js +349 -0
- package/out/concepts/NewList__.js.map +1 -0
- package/out/concepts/NewMap__.d.ts +221 -0
- package/out/concepts/NewMap__.js +480 -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/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.d.ts +7 -3
- package/out/concepts/OqlQueryComponent__.js +56 -95
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.d.ts +8 -1
- package/out/concepts/Param__.js +85 -6
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +42 -13
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.d.ts +30 -0
- package/out/concepts/ProcessOutcomes__.js +87 -0
- package/out/concepts/ProcessOutcomes__.js.map +1 -0
- package/out/concepts/Process__.d.ts +4 -20
- package/out/concepts/Process__.js +0 -7
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +3 -3
- package/out/concepts/QueryOrderByExpression__.js +3 -3
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +5 -0
- package/out/concepts/Return__.js +45 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +1 -1
- package/out/concepts/SelectMembers__.js +5 -5
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +2 -4
- package/out/concepts/SqlQueryComponent__.js +9 -88
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringInterpolation__.d.ts +113 -0
- package/out/concepts/StringInterpolation__.js +227 -0
- package/out/concepts/StringInterpolation__.js.map +1 -0
- package/out/concepts/StringLiteral__.js +0 -7
- 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/Transactional__.d.ts +5 -0
- package/out/concepts/Transactional__.js +6 -0
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +4 -0
- package/out/concepts/TypeAnnotation__.js +67 -15
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +1 -0
- package/out/concepts/TypeParam__.js +2 -0
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +6 -9
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +87 -22
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +5 -0
- package/out/concepts/Variable__.js +46 -3
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +35 -29
- package/out/concepts/ViewElement__.js +138 -54
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +10 -3
- package/out/concepts/View__.js +116 -86
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +1 -1
- package/out/concepts/WhileStatement__.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.browser.js +50 -0
- package/out/concepts/basics/stdlib/nasl.browser.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 +38 -4
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +214 -62
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/index__.d.ts +9 -0
- package/out/concepts/index__.js +9 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.d.ts +1 -0
- package/out/enums/KEYWORDS.js +9 -1
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +10 -4
- package/out/generator/genBundleFiles.js +127 -162
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +2 -11
- package/out/generator/genMetaData.js +185 -51
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +57 -0
- package/out/generator/genReleaseBody.js +380 -0
- package/out/generator/genReleaseBody.js.map +1 -0
- package/out/generator/index.d.ts +2 -0
- package/out/generator/index.js +2 -0
- package/out/generator/index.js.map +1 -1
- package/out/generator/permission.d.ts +17 -0
- package/out/generator/permission.js +221 -0
- package/out/generator/permission.js.map +1 -0
- package/out/index.d.ts +3 -2
- package/out/index.js +7 -1
- package/out/index.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +100 -20
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +33 -20
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +1 -2
- package/out/server/formatTsUtils.js +46 -64
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.d.ts +2 -1
- package/out/server/getLogics.js +24 -6
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +11 -11
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +1 -1
- package/out/server/getProcesses.js +1 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/index.d.ts +0 -1
- package/out/server/index.js +2 -27
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +50 -8
- package/out/server/naslServer.js +816 -429
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +30 -28
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/process2LogicNamespace.js +8 -0
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +90 -12
- 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/defaultErrorMessage.json +97 -0
- package/out/service/logic/api.d.ts +9 -0
- package/out/service/logic/api.js +11 -0
- package/out/service/logic/api.js.map +1 -0
- package/out/service/logic/index.d.ts +2 -0
- package/out/service/logic/index.js +10 -0
- package/out/service/logic/index.js.map +1 -0
- package/out/service/storage/init.js +48 -7
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -4
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +7 -4
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +7 -5
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +4 -5
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +5 -2
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +4 -3
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +18 -16
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -7
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.d.ts +2 -2
- package/out/templator/genQueryComponent.js +4 -1
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genTableBlock.js +8 -12
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +4 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/node-nasl-server.js +10 -38
- package/out/test/integration/node-nasl-server.js.map +1 -1
- package/out/translator/index.d.ts +1 -0
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +1 -0
- package/out/utils/index.js +38 -1
- package/out/utils/index.js.map +1 -1
- package/out/utils/string.d.ts +15 -2
- package/out/utils/string.js +18 -3
- package/out/utils/string.js.map +1 -1
- package/package.json +1 -1
- package/src/concepts/App__.ts +11 -36
- package/src/concepts/Frontend__.ts +8 -0
- package/src/concepts/ViewElement__.ts +7 -28
- package/src/concepts/View__.ts +1 -1
- package/src/server/getLogics.ts +2 -2
- package/src/server/naslServer.ts +8 -8
- package/src/service/storage/init.ts +3 -4
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { TranslatorState } from '../translator';
|
|
2
|
+
import { Params } from '../common/EventEmitter';
|
|
3
|
+
import TypeAnnotation from './TypeAnnotation__';
|
|
4
|
+
import LogicItem from './LogicItem__';
|
|
5
|
+
/**
|
|
6
|
+
* map构造器
|
|
7
|
+
*/
|
|
8
|
+
export declare class NewMap extends LogicItem {
|
|
9
|
+
/**
|
|
10
|
+
* 产品概念
|
|
11
|
+
*/
|
|
12
|
+
concept: 'NewMap';
|
|
13
|
+
/**
|
|
14
|
+
* 类型
|
|
15
|
+
*/
|
|
16
|
+
typeAnnotation: TypeAnnotation;
|
|
17
|
+
/**
|
|
18
|
+
* 键
|
|
19
|
+
*/
|
|
20
|
+
keys: Array<LogicItem>;
|
|
21
|
+
/**
|
|
22
|
+
* 键对应的值
|
|
23
|
+
*/
|
|
24
|
+
values: Array<LogicItem>;
|
|
25
|
+
/**
|
|
26
|
+
* @param source 需要合并的部分参数
|
|
27
|
+
*/
|
|
28
|
+
constructor(source?: Partial<NewMap>);
|
|
29
|
+
static from(source: any, parentNode?: any, parentKey?: string): NewMap;
|
|
30
|
+
/**
|
|
31
|
+
* 设置类型
|
|
32
|
+
*/
|
|
33
|
+
setTypeAnnotation(typeAnnotation: TypeAnnotation): void;
|
|
34
|
+
/**
|
|
35
|
+
* 设置键
|
|
36
|
+
*/
|
|
37
|
+
setKeys(keys: Array<LogicItem>): void;
|
|
38
|
+
/**
|
|
39
|
+
* 设置键对应的值
|
|
40
|
+
*/
|
|
41
|
+
setValues(values: Array<LogicItem>): void;
|
|
42
|
+
getItemExistingNames(excludedList?: Array<LogicItem>): string[];
|
|
43
|
+
getItemUniqueName(name?: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* 插入逻辑项
|
|
46
|
+
* @internal
|
|
47
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
48
|
+
*/
|
|
49
|
+
_insertItemInKeysAt(name: string, index: number): LogicItem;
|
|
50
|
+
/**
|
|
51
|
+
* 插入逻辑项
|
|
52
|
+
* @internal
|
|
53
|
+
* @param logicItemOptions 逻辑项参数
|
|
54
|
+
*/
|
|
55
|
+
_insertItemInKeysAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
56
|
+
/**
|
|
57
|
+
* 插入逻辑项
|
|
58
|
+
* @internal
|
|
59
|
+
* @param logicItem 已有的逻辑项实例
|
|
60
|
+
*/
|
|
61
|
+
_insertItemInKeysAt(logicItem: LogicItem, index: number): LogicItem;
|
|
62
|
+
/**
|
|
63
|
+
* 插入逻辑项
|
|
64
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
65
|
+
*/
|
|
66
|
+
insertItemInKeysAt(name: string, index: number): LogicItem;
|
|
67
|
+
/**
|
|
68
|
+
* 插入逻辑项
|
|
69
|
+
* @param logicItemOptions 逻辑项参数
|
|
70
|
+
*/
|
|
71
|
+
insertItemInKeysAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
72
|
+
/**
|
|
73
|
+
* 插入逻辑项
|
|
74
|
+
* @param logicItem 已有的逻辑项实例
|
|
75
|
+
*/
|
|
76
|
+
insertItemInKeysAt(logicItem: LogicItem, index: number): LogicItem;
|
|
77
|
+
/**
|
|
78
|
+
* 添加逻辑项
|
|
79
|
+
* @internal
|
|
80
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
81
|
+
*/
|
|
82
|
+
_addItemInKeys(name?: string): LogicItem;
|
|
83
|
+
/**
|
|
84
|
+
* 添加逻辑项
|
|
85
|
+
* @internal
|
|
86
|
+
* @param logicItemOptions 逻辑项参数
|
|
87
|
+
*/
|
|
88
|
+
_addItemInKeys(logicItemOptions: Partial<LogicItem>): LogicItem;
|
|
89
|
+
/**
|
|
90
|
+
* 添加逻辑项
|
|
91
|
+
* @internal
|
|
92
|
+
* @param logicItem 已有的逻辑项实例
|
|
93
|
+
*/
|
|
94
|
+
_addItemInKeys(logicItem: LogicItem): LogicItem;
|
|
95
|
+
/**
|
|
96
|
+
* 添加逻辑项
|
|
97
|
+
* @internal
|
|
98
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
99
|
+
*/
|
|
100
|
+
addItemInKeys(name?: string): LogicItem;
|
|
101
|
+
/**
|
|
102
|
+
* 添加逻辑项
|
|
103
|
+
* @param logicItemOptions 逻辑项参数
|
|
104
|
+
*/
|
|
105
|
+
addItemInKeys(logicItemOptions: Partial<LogicItem>): LogicItem;
|
|
106
|
+
/**
|
|
107
|
+
* 添加逻辑项
|
|
108
|
+
* @param logicItem 已有的逻辑项实例
|
|
109
|
+
*/
|
|
110
|
+
addItemInKeys(logicItem: LogicItem): LogicItem;
|
|
111
|
+
/**
|
|
112
|
+
* 插入逻辑项
|
|
113
|
+
* @internal
|
|
114
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
115
|
+
*/
|
|
116
|
+
_insertItemInValuesAt(name: string, index: number): LogicItem;
|
|
117
|
+
/**
|
|
118
|
+
* 插入逻辑项
|
|
119
|
+
* @internal
|
|
120
|
+
* @param logicItemOptions 逻辑项参数
|
|
121
|
+
*/
|
|
122
|
+
_insertItemInValuesAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
123
|
+
/**
|
|
124
|
+
* 插入逻辑项
|
|
125
|
+
* @internal
|
|
126
|
+
* @param logicItem 已有的逻辑项实例
|
|
127
|
+
*/
|
|
128
|
+
_insertItemInValuesAt(logicItem: LogicItem, index: number): LogicItem;
|
|
129
|
+
/**
|
|
130
|
+
* 插入逻辑项
|
|
131
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
132
|
+
*/
|
|
133
|
+
insertItemInValuesAt(name: string, index: number): LogicItem;
|
|
134
|
+
/**
|
|
135
|
+
* 插入逻辑项
|
|
136
|
+
* @param logicItemOptions 逻辑项参数
|
|
137
|
+
*/
|
|
138
|
+
insertItemInValuesAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
139
|
+
/**
|
|
140
|
+
* 插入逻辑项
|
|
141
|
+
* @param logicItem 已有的逻辑项实例
|
|
142
|
+
*/
|
|
143
|
+
insertItemInValuesAt(logicItem: LogicItem, index: number): LogicItem;
|
|
144
|
+
/**
|
|
145
|
+
* 添加逻辑项
|
|
146
|
+
* @internal
|
|
147
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
148
|
+
*/
|
|
149
|
+
_addItemInValues(name?: string): LogicItem;
|
|
150
|
+
/**
|
|
151
|
+
* 添加逻辑项
|
|
152
|
+
* @internal
|
|
153
|
+
* @param logicItemOptions 逻辑项参数
|
|
154
|
+
*/
|
|
155
|
+
_addItemInValues(logicItemOptions: Partial<LogicItem>): LogicItem;
|
|
156
|
+
/**
|
|
157
|
+
* 添加逻辑项
|
|
158
|
+
* @internal
|
|
159
|
+
* @param logicItem 已有的逻辑项实例
|
|
160
|
+
*/
|
|
161
|
+
_addItemInValues(logicItem: LogicItem): LogicItem;
|
|
162
|
+
/**
|
|
163
|
+
* 添加逻辑项
|
|
164
|
+
* @internal
|
|
165
|
+
* @param name 逻辑项名称,如果不填会自动生成一个唯一名称
|
|
166
|
+
*/
|
|
167
|
+
addItemInValues(name?: string): LogicItem;
|
|
168
|
+
/**
|
|
169
|
+
* 添加逻辑项
|
|
170
|
+
* @param logicItemOptions 逻辑项参数
|
|
171
|
+
*/
|
|
172
|
+
addItemInValues(logicItemOptions: Partial<LogicItem>): LogicItem;
|
|
173
|
+
/**
|
|
174
|
+
* 添加逻辑项
|
|
175
|
+
* @param logicItem 已有的逻辑项实例
|
|
176
|
+
*/
|
|
177
|
+
addItemInValues(logicItem: LogicItem): LogicItem;
|
|
178
|
+
/**
|
|
179
|
+
* 删除类型标注
|
|
180
|
+
* @param name 类型标注名称
|
|
181
|
+
*/
|
|
182
|
+
removeTypeAnnotation(name: string): void;
|
|
183
|
+
/**
|
|
184
|
+
* 删除类型标注
|
|
185
|
+
* @param typeAnnotation 已有的类型标注实例
|
|
186
|
+
*/
|
|
187
|
+
removeTypeAnnotation(typeAnnotation: TypeAnnotation): void;
|
|
188
|
+
__removeTypeAnnotation(typeAnnotation: TypeAnnotation): Params;
|
|
189
|
+
/**
|
|
190
|
+
* 删除逻辑项
|
|
191
|
+
* @param name 逻辑项名称
|
|
192
|
+
*/
|
|
193
|
+
removeItemInKeys(name: string): void;
|
|
194
|
+
/**
|
|
195
|
+
* 删除逻辑项
|
|
196
|
+
* @param logicItem 已有的逻辑项实例
|
|
197
|
+
*/
|
|
198
|
+
removeItemInKeys(logicItem: LogicItem): void;
|
|
199
|
+
/**
|
|
200
|
+
* 删除逻辑项
|
|
201
|
+
* @param name 逻辑项名称
|
|
202
|
+
*/
|
|
203
|
+
removeItemInValues(name: string): void;
|
|
204
|
+
/**
|
|
205
|
+
* 删除逻辑项
|
|
206
|
+
* @param logicItem 已有的逻辑项实例
|
|
207
|
+
*/
|
|
208
|
+
removeItemInValues(logicItem: LogicItem): void;
|
|
209
|
+
__removeLogicItem(logicItem: LogicItem): Params;
|
|
210
|
+
getIterator(): {
|
|
211
|
+
key: LogicItem;
|
|
212
|
+
value: LogicItem;
|
|
213
|
+
uid: string;
|
|
214
|
+
}[];
|
|
215
|
+
addPair(): void;
|
|
216
|
+
removePair(idx: number): void;
|
|
217
|
+
toJS(state?: TranslatorState): string;
|
|
218
|
+
toEmbeddedTS(state?: TranslatorState): string;
|
|
219
|
+
getInitCode(state?: TranslatorState): string;
|
|
220
|
+
}
|
|
221
|
+
export default NewMap;
|
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
var NewMap_1;
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NewMap = void 0;
|
|
37
|
+
const translator_1 = require("../translator");
|
|
38
|
+
const decorators_1 = require("../decorators");
|
|
39
|
+
const utils = __importStar(require("../utils"));
|
|
40
|
+
const uuid_1 = require("uuid");
|
|
41
|
+
const classMap_1 = __importDefault(require("../common/classMap"));
|
|
42
|
+
const LogicItem__1 = __importDefault(require("./LogicItem__"));
|
|
43
|
+
/**
|
|
44
|
+
* map构造器
|
|
45
|
+
*/
|
|
46
|
+
let NewMap = NewMap_1 = class NewMap extends LogicItem__1.default {
|
|
47
|
+
/**
|
|
48
|
+
* 产品概念
|
|
49
|
+
*/
|
|
50
|
+
concept = 'NewMap';
|
|
51
|
+
/**
|
|
52
|
+
* 类型
|
|
53
|
+
*/
|
|
54
|
+
typeAnnotation = undefined;
|
|
55
|
+
/**
|
|
56
|
+
* 键
|
|
57
|
+
*/
|
|
58
|
+
keys = [];
|
|
59
|
+
/**
|
|
60
|
+
* 键对应的值
|
|
61
|
+
*/
|
|
62
|
+
values = [];
|
|
63
|
+
/**
|
|
64
|
+
* @param source 需要合并的部分参数
|
|
65
|
+
*/
|
|
66
|
+
constructor(source) {
|
|
67
|
+
source = Object.assign({}, NewMap_1.getDefaultOptions(), source);
|
|
68
|
+
super(source);
|
|
69
|
+
super.subConstructor(source);
|
|
70
|
+
}
|
|
71
|
+
static from(source, parentNode, parentKey) {
|
|
72
|
+
return super.from(source, parentNode, parentKey);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 设置类型
|
|
76
|
+
*/
|
|
77
|
+
setTypeAnnotation(typeAnnotation) {
|
|
78
|
+
typeAnnotation._delete();
|
|
79
|
+
const relationOptions = { parentNode: this, parentKey: 'typeAnnotation' };
|
|
80
|
+
Object.assign(typeAnnotation, relationOptions);
|
|
81
|
+
const object = {
|
|
82
|
+
typeAnnotation,
|
|
83
|
+
};
|
|
84
|
+
this.update({
|
|
85
|
+
...object,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 设置键
|
|
90
|
+
*/
|
|
91
|
+
setKeys(keys) {
|
|
92
|
+
const object = {
|
|
93
|
+
keys,
|
|
94
|
+
};
|
|
95
|
+
this.update({
|
|
96
|
+
...object,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 设置键对应的值
|
|
101
|
+
*/
|
|
102
|
+
setValues(values) {
|
|
103
|
+
const object = {
|
|
104
|
+
values,
|
|
105
|
+
};
|
|
106
|
+
this.update({
|
|
107
|
+
...object,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
getItemExistingNames(excludedList = []) {
|
|
111
|
+
const excludedSet = new Set(excludedList);
|
|
112
|
+
return (this.keys || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
113
|
+
}
|
|
114
|
+
getItemUniqueName(name = 'logicItem1') {
|
|
115
|
+
return utils.unique(name, this.getItemExistingNames(), undefined, false);
|
|
116
|
+
}
|
|
117
|
+
_insertItemInKeysAt(options, index) {
|
|
118
|
+
const logicItemOptions = {};
|
|
119
|
+
const relationOptions = { parentNode: this, parentKey: 'keys' };
|
|
120
|
+
let logicItem;
|
|
121
|
+
if (!options) {
|
|
122
|
+
logicItem = LogicItem__1.default.from({
|
|
123
|
+
...logicItemOptions,
|
|
124
|
+
name: this.getItemUniqueName(),
|
|
125
|
+
}, this, 'keys');
|
|
126
|
+
}
|
|
127
|
+
else if (typeof options === 'string') {
|
|
128
|
+
logicItem = LogicItem__1.default.from({
|
|
129
|
+
...logicItemOptions,
|
|
130
|
+
name: options,
|
|
131
|
+
}, this, 'keys');
|
|
132
|
+
}
|
|
133
|
+
else if (options instanceof LogicItem__1.default) {
|
|
134
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
135
|
+
logicItem = options;
|
|
136
|
+
Object.assign(logicItem, relationOptions);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
logicItem = LogicItem__1.default.from({
|
|
140
|
+
...logicItemOptions,
|
|
141
|
+
...options,
|
|
142
|
+
}, this, 'keys');
|
|
143
|
+
}
|
|
144
|
+
this.keys.splice(index, 0, logicItem);
|
|
145
|
+
return logicItem;
|
|
146
|
+
}
|
|
147
|
+
insertItemInKeysAt(options, index) {
|
|
148
|
+
const node = this._insertItemInKeysAt(options, index);
|
|
149
|
+
node.create({
|
|
150
|
+
index,
|
|
151
|
+
parentNode: this,
|
|
152
|
+
parentKey: 'keys',
|
|
153
|
+
});
|
|
154
|
+
return node;
|
|
155
|
+
}
|
|
156
|
+
_addItemInKeys(options) {
|
|
157
|
+
const index = this.keys.length;
|
|
158
|
+
return this._insertItemInKeysAt(options, index);
|
|
159
|
+
}
|
|
160
|
+
addItemInKeys(options) {
|
|
161
|
+
const node = this._addItemInKeys(options);
|
|
162
|
+
const index = this.keys.indexOf(node);
|
|
163
|
+
node.create({
|
|
164
|
+
index,
|
|
165
|
+
parentNode: this,
|
|
166
|
+
parentKey: 'keys',
|
|
167
|
+
});
|
|
168
|
+
return node;
|
|
169
|
+
}
|
|
170
|
+
_insertItemInValuesAt(options, index) {
|
|
171
|
+
const logicItemOptions = {};
|
|
172
|
+
const relationOptions = { parentNode: this, parentKey: 'values' };
|
|
173
|
+
let logicItem;
|
|
174
|
+
if (!options) {
|
|
175
|
+
logicItem = LogicItem__1.default.from({
|
|
176
|
+
...logicItemOptions,
|
|
177
|
+
name: this.getItemUniqueName(),
|
|
178
|
+
}, this, 'values');
|
|
179
|
+
}
|
|
180
|
+
else if (typeof options === 'string') {
|
|
181
|
+
logicItem = LogicItem__1.default.from({
|
|
182
|
+
...logicItemOptions,
|
|
183
|
+
name: options,
|
|
184
|
+
}, this, 'values');
|
|
185
|
+
}
|
|
186
|
+
else if (options instanceof LogicItem__1.default) {
|
|
187
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
188
|
+
logicItem = options;
|
|
189
|
+
Object.assign(logicItem, relationOptions);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
logicItem = LogicItem__1.default.from({
|
|
193
|
+
...logicItemOptions,
|
|
194
|
+
...options,
|
|
195
|
+
}, this, 'values');
|
|
196
|
+
}
|
|
197
|
+
this.values.splice(index, 0, logicItem);
|
|
198
|
+
return logicItem;
|
|
199
|
+
}
|
|
200
|
+
insertItemInValuesAt(options, index) {
|
|
201
|
+
const node = this._insertItemInValuesAt(options, index);
|
|
202
|
+
node.create({
|
|
203
|
+
index,
|
|
204
|
+
parentNode: this,
|
|
205
|
+
parentKey: 'values',
|
|
206
|
+
});
|
|
207
|
+
return node;
|
|
208
|
+
}
|
|
209
|
+
_addItemInValues(options) {
|
|
210
|
+
const index = this.values.length;
|
|
211
|
+
return this._insertItemInValuesAt(options, index);
|
|
212
|
+
}
|
|
213
|
+
addItemInValues(options) {
|
|
214
|
+
const node = this._addItemInValues(options);
|
|
215
|
+
const index = this.values.indexOf(node);
|
|
216
|
+
node.create({
|
|
217
|
+
index,
|
|
218
|
+
parentNode: this,
|
|
219
|
+
parentKey: 'values',
|
|
220
|
+
});
|
|
221
|
+
return node;
|
|
222
|
+
}
|
|
223
|
+
removeTypeAnnotation(options) {
|
|
224
|
+
let typeAnnotation;
|
|
225
|
+
if (typeof options === 'string') {
|
|
226
|
+
typeAnnotation = this.typeAnnotation;
|
|
227
|
+
if (!typeAnnotation) {
|
|
228
|
+
throw new Error('找不到类型标注 ' + options);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
typeAnnotation = options;
|
|
233
|
+
}
|
|
234
|
+
return typeAnnotation.delete();
|
|
235
|
+
}
|
|
236
|
+
__removeTypeAnnotation(typeAnnotation) {
|
|
237
|
+
const parentKey = typeAnnotation.parentKey;
|
|
238
|
+
const params = {
|
|
239
|
+
parentNode: this,
|
|
240
|
+
parentKey,
|
|
241
|
+
index: -1,
|
|
242
|
+
object: null,
|
|
243
|
+
oldObject: typeAnnotation,
|
|
244
|
+
};
|
|
245
|
+
if (parentKey) {
|
|
246
|
+
params.parentKey = parentKey;
|
|
247
|
+
if (Array.isArray(this[parentKey])) {
|
|
248
|
+
const index = this[parentKey].indexOf(typeAnnotation);
|
|
249
|
+
~index && this[parentKey].splice(index, 1);
|
|
250
|
+
params.index = index;
|
|
251
|
+
}
|
|
252
|
+
else if (this[parentKey] === typeAnnotation) {
|
|
253
|
+
params.index = 0;
|
|
254
|
+
this[parentKey] = undefined;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return params;
|
|
258
|
+
}
|
|
259
|
+
removeItemInKeys(options) {
|
|
260
|
+
let logicItem;
|
|
261
|
+
if (typeof options === 'string') {
|
|
262
|
+
logicItem = this.keys.find((item) => item.name === options);
|
|
263
|
+
if (!logicItem) {
|
|
264
|
+
throw new Error('找不到逻辑项 ' + options);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
logicItem = options;
|
|
269
|
+
}
|
|
270
|
+
return logicItem.delete();
|
|
271
|
+
}
|
|
272
|
+
removeItemInValues(options) {
|
|
273
|
+
let logicItem;
|
|
274
|
+
if (typeof options === 'string') {
|
|
275
|
+
logicItem = this.values.find((item) => item.name === options);
|
|
276
|
+
if (!logicItem) {
|
|
277
|
+
throw new Error('找不到逻辑项 ' + options);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
logicItem = options;
|
|
282
|
+
}
|
|
283
|
+
return logicItem.delete();
|
|
284
|
+
}
|
|
285
|
+
__removeLogicItem(logicItem) {
|
|
286
|
+
const parentKey = logicItem.parentKey;
|
|
287
|
+
const params = {
|
|
288
|
+
parentNode: this,
|
|
289
|
+
parentKey,
|
|
290
|
+
index: -1,
|
|
291
|
+
object: null,
|
|
292
|
+
oldObject: logicItem,
|
|
293
|
+
};
|
|
294
|
+
if (parentKey) {
|
|
295
|
+
params.parentKey = parentKey;
|
|
296
|
+
if (Array.isArray(this[parentKey])) {
|
|
297
|
+
const index = this[parentKey].indexOf(logicItem);
|
|
298
|
+
~index && this[parentKey].splice(index, 1);
|
|
299
|
+
params.index = index;
|
|
300
|
+
}
|
|
301
|
+
else if (this[parentKey] === logicItem) {
|
|
302
|
+
params.index = 0;
|
|
303
|
+
this[parentKey] = undefined;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return params;
|
|
307
|
+
}
|
|
308
|
+
//================================================================================
|
|
309
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
310
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
311
|
+
//================================================================================
|
|
312
|
+
getIterator() {
|
|
313
|
+
return this.keys.map((k, idx) => ({
|
|
314
|
+
key: k,
|
|
315
|
+
value: this.values[idx],
|
|
316
|
+
uid: (0, uuid_1.v4)(),
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
addPair() {
|
|
320
|
+
this.update({
|
|
321
|
+
keys: [...this.keys, undefined],
|
|
322
|
+
values: [...this.values, undefined],
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
removePair(idx) {
|
|
326
|
+
const k = this.keys.slice();
|
|
327
|
+
k.splice(idx, 1);
|
|
328
|
+
const v = this.values.slice();
|
|
329
|
+
v.splice(idx, 1);
|
|
330
|
+
this.update({
|
|
331
|
+
keys: k,
|
|
332
|
+
values: v,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
toJS(state) {
|
|
336
|
+
let code = '';
|
|
337
|
+
code += 'await (async () => {\n';
|
|
338
|
+
code += 'const obj = {};\n';
|
|
339
|
+
code += 'let k;\n';
|
|
340
|
+
this.keys.forEach((item, index) => {
|
|
341
|
+
const key = item;
|
|
342
|
+
const value = this.values[index];
|
|
343
|
+
code += `k = `;
|
|
344
|
+
code += `${key ? key.toJS((0, translator_1.shiftState)(state, code, { inline: true })) : undefined};\n`;
|
|
345
|
+
code += 'obj[k] = ';
|
|
346
|
+
code += `${value ? value.toJS((0, translator_1.shiftState)(state, code, { inline: true })) : undefined};\n`;
|
|
347
|
+
});
|
|
348
|
+
code += `return obj;\n`;
|
|
349
|
+
code += '})()';
|
|
350
|
+
return code;
|
|
351
|
+
}
|
|
352
|
+
toEmbeddedTS(state) {
|
|
353
|
+
let code = '';
|
|
354
|
+
if (this.typeAnnotation) {
|
|
355
|
+
const newConstructor = `nasl.util.New<${this.typeAnnotation.sortedTypeKey}>()`;
|
|
356
|
+
code += '(() => { \n';
|
|
357
|
+
// 方便ts报错检查
|
|
358
|
+
code += 'function __newComposite() {\n';
|
|
359
|
+
code += '\n';
|
|
360
|
+
this.keys.forEach((item, index) => {
|
|
361
|
+
const key = item;
|
|
362
|
+
code += `nasl.util.MapPut(${newConstructor}, `;
|
|
363
|
+
code += `${key ? key.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) : null}`;
|
|
364
|
+
code += ', null)\n';
|
|
365
|
+
});
|
|
366
|
+
this.values.forEach((item, index) => {
|
|
367
|
+
const value = this.values[index];
|
|
368
|
+
code += `nasl.util.MapPut(${newConstructor}, null, `;
|
|
369
|
+
code += `${value ? value.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) : null}`;
|
|
370
|
+
code += ')';
|
|
371
|
+
code += '\n';
|
|
372
|
+
});
|
|
373
|
+
code += `return ${newConstructor};\n`;
|
|
374
|
+
code += '};\n';
|
|
375
|
+
code += 'return __newComposite();\n';
|
|
376
|
+
code += '})()';
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
if (this.keys.length) {
|
|
380
|
+
code += '(() => { \n';
|
|
381
|
+
const valueTsArr = [];
|
|
382
|
+
let keyTs = 'null';
|
|
383
|
+
let keyBol = false;
|
|
384
|
+
this.keys.forEach((key) => {
|
|
385
|
+
if (key) {
|
|
386
|
+
const ts = key.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
387
|
+
if (!keyBol && !['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
|
|
388
|
+
keyBol = true;
|
|
389
|
+
keyTs = ts;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
this.values.forEach((item, index) => {
|
|
394
|
+
const ts = item ? item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) : null;
|
|
395
|
+
valueTsArr.push(ts);
|
|
396
|
+
code += valueTsArr[index];
|
|
397
|
+
code += '; ';
|
|
398
|
+
});
|
|
399
|
+
code += '\n';
|
|
400
|
+
// 方便ts报错检查
|
|
401
|
+
code += 'function __newComposite() {\n';
|
|
402
|
+
this.keys.forEach((key) => {
|
|
403
|
+
code += `nasl.core.compare2(${keyTs}, `;
|
|
404
|
+
code += key.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
405
|
+
code += ');\n';
|
|
406
|
+
});
|
|
407
|
+
code += `return nasl.util.NewMap(${keyTs}, `;
|
|
408
|
+
valueTsArr.forEach((ts, index) => {
|
|
409
|
+
code += ['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts;
|
|
410
|
+
if (index + 1 < this.values.length)
|
|
411
|
+
code += ', ';
|
|
412
|
+
});
|
|
413
|
+
code += ');\n';
|
|
414
|
+
code += '};\n';
|
|
415
|
+
code += 'return __newComposite();\n';
|
|
416
|
+
code += '})()';
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
code += `nasl.util.NewMap(${null}, ${null})`;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return code;
|
|
423
|
+
}
|
|
424
|
+
getInitCode(state) {
|
|
425
|
+
let code = '';
|
|
426
|
+
if (this.keys.length) {
|
|
427
|
+
let keyBol = false;
|
|
428
|
+
code += `nasl.util.NewMap(`;
|
|
429
|
+
this.keys.forEach((key) => {
|
|
430
|
+
if (key && !keyBol) {
|
|
431
|
+
const ts = key.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
432
|
+
if (!['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
|
|
433
|
+
keyBol = true;
|
|
434
|
+
code += ts;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
if (!keyBol)
|
|
439
|
+
code += 'null';
|
|
440
|
+
code += `, ...[`;
|
|
441
|
+
this.values.forEach((item, index) => {
|
|
442
|
+
const ts = item ? item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) : null;
|
|
443
|
+
code += ['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts;
|
|
444
|
+
if (index + 1 < this.values.length)
|
|
445
|
+
code += ', ';
|
|
446
|
+
});
|
|
447
|
+
code += '])';
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
code += `nasl.util.NewMap(${null}, ${null})`;
|
|
451
|
+
}
|
|
452
|
+
return code;
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
__decorate([
|
|
456
|
+
(0, decorators_1.property)()
|
|
457
|
+
], NewMap.prototype, "concept", void 0);
|
|
458
|
+
__decorate([
|
|
459
|
+
(0, decorators_1.property)('TypeAnnotation')
|
|
460
|
+
], NewMap.prototype, "typeAnnotation", void 0);
|
|
461
|
+
__decorate([
|
|
462
|
+
(0, decorators_1.property)('LogicItem')
|
|
463
|
+
], NewMap.prototype, "keys", void 0);
|
|
464
|
+
__decorate([
|
|
465
|
+
(0, decorators_1.property)('LogicItem')
|
|
466
|
+
], NewMap.prototype, "values", void 0);
|
|
467
|
+
__decorate([
|
|
468
|
+
(0, translator_1.withSourceMap)()
|
|
469
|
+
], NewMap.prototype, "toEmbeddedTS", null);
|
|
470
|
+
NewMap = NewMap_1 = __decorate([
|
|
471
|
+
(0, decorators_1.concept)('map构造器')
|
|
472
|
+
], NewMap);
|
|
473
|
+
exports.NewMap = NewMap;
|
|
474
|
+
classMap_1.default.NewMap = NewMap;
|
|
475
|
+
exports.default = NewMap;
|
|
476
|
+
//================================================================================
|
|
477
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
478
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
479
|
+
//================================================================================
|
|
480
|
+
//# sourceMappingURL=NewMap__.js.map
|