@lcap/nasl 2.20.0-beta.3 → 2.20.0-beta.4
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 +2 -3
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +1 -1
- package/out/automate/engine/uniqueName.js +2 -2
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.js +4 -1
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/myProcess.d.ts +1 -1
- package/out/automate/template/myProcess.js +2 -2
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/bak/translator.js +14 -22
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +4 -1
- package/out/common/BaseNode.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/App__.d.ts +4 -0
- package/out/concepts/App__.js +30 -6
- 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__.js +3 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +7 -0
- package/out/concepts/BindAttribute__.js +270 -39
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +7 -0
- package/out/concepts/BindDirective__.js +215 -17
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +7 -0
- package/out/concepts/BindStyle__.js +194 -4
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/CallFunction__.js +22 -8
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +3 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +3 -0
- package/out/concepts/CallLogic__.js +78 -89
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +20 -3
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +13 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +19 -0
- package/out/concepts/ConfigProperty__.js +61 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +13 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -0
- package/out/concepts/Destination__.js +61 -7
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +9 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +5 -5
- package/out/concepts/EnumItem__.js +6 -6
- package/out/concepts/Enum__.d.ts +20 -19
- package/out/concepts/Enum__.js +28 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ExternalDestination__.d.ts +1 -0
- package/out/concepts/ExternalDestination__.js +21 -3
- package/out/concepts/ExternalDestination__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -0
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +2 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.js +16 -5
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +9 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/JSBlock__.js +5 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +79 -79
- package/out/concepts/Logic__.js +16 -3
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +0 -3
- package/out/concepts/Match__.js +11 -66
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +9 -0
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +16 -0
- package/out/concepts/Module__.js +43 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +2 -4
- package/out/concepts/NewComposite__.js +91 -126
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.d.ts +1 -0
- package/out/concepts/NewList__.js +22 -2
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -0
- package/out/concepts/NewMap__.js +43 -11
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +40 -12
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.js +10 -2
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +2 -1
- 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__.js +1 -1
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/Process__.js +1 -0
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/Return__.js +10 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +14 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +6 -6
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +9 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +6 -3
- package/out/concepts/TypeAnnotation__.js +67 -13
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -0
- package/out/concepts/ValidationRule__.js +53 -0
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +9 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +17 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -3
- package/out/concepts/View__.js +22 -11
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.collection.js +6 -1
- package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js +3 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.core.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.core.js +34 -0
- package/out/concepts/basics/stdlib/nasl.core.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +4 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +3 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -1
- package/out/concepts/index__.js +0 -1
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +8 -0
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.js +24 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -3
- package/out/generator/genReleaseBody.js +97 -23
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.d.ts +2 -10
- package/out/generator/permission.js +26 -13
- package/out/generator/permission.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +2 -20
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +16 -5
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +40 -10
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.d.ts +2 -2
- package/out/server/getLogics.js +3 -3
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +27 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +7 -1
- package/out/server/naslServer.js +519 -46
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +109 -33
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +21 -1
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +1 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +1 -3
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +2 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +2 -2
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -1
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +1 -1
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +2 -2
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/utils/traverse.js +8 -2
- package/out/utils/traverse.js.map +1 -1
- package/package.json +2 -2
- package/sandbox/stdlib/dist/nasl.logging.js +0 -0
- package/sandbox/stdlib/dist/nasl.util.js +0 -0
- package/sandbox/stdlib/nasl.collection.ts +1 -0
- package/sandbox/stdlib/nasl.core.ts +34 -0
- package/sandbox/stdlib/nasl.oql.ts +71 -15
- package/sandbox/stdlib/nasl.util.ts +9 -3
- package/src/automate/engine/dist/index.dev.js +517 -0
- package/src/automate/engine/index.js +2 -3
- package/src/automate/engine/uniqueName.js +2 -2
- package/src/automate/engine/utils.js +4 -2
- package/src/automate/template/myProcess.js +2 -2
- package/src/bak/translator.js +16 -25
- package/src/common/BaseNode.ts +3 -1
- package/src/common/Command.ts +4 -0
- package/src/common/dist/BaseNode.js +1101 -0
- package/src/concepts/App__.ts +36 -7
- package/src/concepts/Assignee__.ts +4 -3
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/BindAttribute__.ts +299 -38
- package/src/concepts/BindDirective__.ts +204 -31
- package/src/concepts/BindStyle__.ts +187 -24
- package/src/concepts/CallFunction__.ts +55 -10
- package/src/concepts/CallInterface__.ts +3 -2
- package/src/concepts/CallLogic__.ts +110 -90
- package/src/concepts/CallQueryComponent__.ts +18 -3
- package/src/concepts/ConfigGroup__.ts +17 -4
- package/src/concepts/ConfigProperty__.ts +70 -4
- package/src/concepts/Configuration__.ts +14 -5
- package/src/concepts/DataSource__.ts +4 -1
- package/src/concepts/Destination__.ts +61 -7
- package/src/concepts/EntityProperty__.ts +7 -1
- package/src/concepts/EnumItem__.ts +6 -6
- package/src/concepts/Enum__.ts +22 -19
- package/src/concepts/ExternalDestination__.ts +28 -8
- package/src/concepts/ForEachStatement__.ts +2 -0
- package/src/concepts/Frontend__.ts +2 -1
- package/src/concepts/Identifier__.ts +16 -5
- package/src/concepts/InterfaceParam__.ts +7 -1
- package/src/concepts/JSBlock__.ts +3 -2
- package/src/concepts/Logic__.ts +95 -83
- package/src/concepts/Match__.ts +31 -67
- package/src/concepts/MemberExpression__.ts +6 -0
- package/src/concepts/Module__.ts +57 -0
- package/src/concepts/NewComposite__.ts +95 -140
- package/src/concepts/NewList__.ts +23 -2
- package/src/concepts/NewMap__.ts +48 -24
- package/src/concepts/OqlQueryComponent__.ts +40 -20
- package/src/concepts/Param__.ts +178 -176
- package/src/concepts/ProcessElement__.ts +2 -1
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/ProcessOutcomes__.ts +1 -1
- package/src/concepts/Process__.ts +1 -0
- package/src/concepts/Return__.ts +8 -2
- package/src/concepts/StringInterpolation__.ts +19 -7
- package/src/concepts/StringLiteral__.ts +7 -6
- package/src/concepts/StructureProperty__.ts +7 -1
- package/src/concepts/TypeAnnotation__.ts +101 -14
- package/src/concepts/ValidationRule__.ts +58 -9
- package/src/concepts/Variable__.ts +11 -1
- package/src/concepts/ViewElement__.ts +39 -2
- package/src/concepts/View__.ts +26 -14
- package/src/concepts/basics/stdlib/dist/nasl.util.js +1602 -0
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
- package/src/concepts/basics/stdlib/nasl.collection.ts +6 -1
- package/src/concepts/basics/stdlib/nasl.configuration.ts +3 -0
- package/src/concepts/basics/stdlib/nasl.core.ts +33 -2
- package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/dist/BindAttribute__.js +795 -0
- package/src/concepts/dist/BindEvent__.js +732 -0
- package/src/concepts/dist/CallFunction__.js +527 -0
- package/src/concepts/dist/CallLogic__.js +932 -0
- package/src/concepts/dist/Destination__.js +708 -0
- package/src/concepts/dist/ExternalDestination__.js +298 -0
- 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 +1692 -0
- package/src/concepts/dist/View__.js +1601 -0
- package/src/concepts/index__.ts +0 -1
- package/src/enums/KEYWORDS.ts +8 -0
- package/src/generator/dist/genBundleFiles.js +261 -0
- package/src/generator/dist/genMetaData.js +245 -0
- package/src/generator/dist/permission.js +405 -0
- package/src/generator/genBundleFiles.ts +24 -5
- package/src/generator/genReleaseBody.ts +75 -30
- package/src/generator/permission.ts +30 -14
- package/src/server/entity2LogicNamespace.ts +2 -20
- package/src/server/extendBaseNode.ts +15 -5
- package/src/server/formatTsUtils.ts +41 -10
- package/src/server/getLogics.ts +4 -4
- package/src/server/getMemberIdentifier.ts +27 -1
- package/src/server/index.ts +2 -0
- package/src/server/naslServer.ts +520 -48
- package/src/server/translator.ts +96 -34
- package/src/service/storage/dist/init.js +579 -0
- package/src/service/storage/init.ts +22 -2
- 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/genCreateBlock.ts +1 -3
- package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +2 -4
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +3 -4
- package/src/templator/genListViewBlock.ts +9 -3
- package/src/templator/genSelectBlock.ts +1 -1
- package/src/templator/genTableBlock.ts +3 -3
- package/src/templator/genUpdateBlock.ts +2 -3
- package/src/utils/traverse.ts +10 -2
- package/ts-worker/lib/tsserver.js +10 -2
- package/ts-worker/package.json +1 -0
- package/ts-worker/webpack.config.js +11 -2
- package/out/concepts/ConstructArgument__.d.ts +0 -40
- package/out/concepts/ConstructArgument__.js +0 -108
- 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/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
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap} from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
3
|
import MemberExpression from './MemberExpression__';
|
|
4
4
|
import StructureProperty from './StructureProperty__';
|
|
5
|
+
import App from './App__';
|
|
5
6
|
//================================================================================
|
|
6
7
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
7
8
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -18,7 +19,6 @@ import Identifier from './Identifier__';
|
|
|
18
19
|
import SelectMembers from './SelectMembers__';
|
|
19
20
|
import AssignmentLine from './AssignmentLine__';
|
|
20
21
|
import LogicItem from './LogicItem__';
|
|
21
|
-
import App from './App__';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* 实体/(匿名)数据结构构造器
|
|
@@ -73,8 +73,6 @@ export class NewComposite extends LogicItem {
|
|
|
73
73
|
@property()
|
|
74
74
|
autoConnection: boolean = true;
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
76
|
/**
|
|
79
77
|
* @param source 需要合并的部分参数
|
|
80
78
|
*/
|
|
@@ -88,7 +86,6 @@ export class NewComposite extends LogicItem {
|
|
|
88
86
|
return super.from(source, parentNode, parentKey) as NewComposite;
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
|
|
92
89
|
/**
|
|
93
90
|
* 设置类型
|
|
94
91
|
*/
|
|
@@ -176,7 +173,7 @@ export class NewComposite extends LogicItem {
|
|
|
176
173
|
});
|
|
177
174
|
}
|
|
178
175
|
|
|
179
|
-
|
|
176
|
+
getIdentifierExistingNames(excludedList: Array<Identifier> = []) {
|
|
180
177
|
const excludedSet = new Set(excludedList);
|
|
181
178
|
return ((this.properties as Identifier[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
182
179
|
}
|
|
@@ -317,7 +314,6 @@ export class NewComposite extends LogicItem {
|
|
|
317
314
|
return node;
|
|
318
315
|
}
|
|
319
316
|
|
|
320
|
-
|
|
321
317
|
getSelectMembersExistingNames(excludedList: Array<SelectMembers> = []) {
|
|
322
318
|
const excludedSet = new Set(excludedList);
|
|
323
319
|
return ((this.rights as SelectMembers[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
@@ -459,7 +455,6 @@ export class NewComposite extends LogicItem {
|
|
|
459
455
|
return node;
|
|
460
456
|
}
|
|
461
457
|
|
|
462
|
-
|
|
463
458
|
getAssignmentLineExistingNames(excludedList: Array<AssignmentLine> = []) {
|
|
464
459
|
const excludedSet = new Set(excludedList);
|
|
465
460
|
return ((this.assignmentLines as AssignmentLine[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
@@ -601,9 +596,6 @@ export class NewComposite extends LogicItem {
|
|
|
601
596
|
return node;
|
|
602
597
|
}
|
|
603
598
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
599
|
/**
|
|
608
600
|
* 删除类型标注
|
|
609
601
|
* @param name 类型标注名称
|
|
@@ -652,8 +644,6 @@ export class NewComposite extends LogicItem {
|
|
|
652
644
|
return params;
|
|
653
645
|
}
|
|
654
646
|
|
|
655
|
-
|
|
656
|
-
|
|
657
647
|
/**
|
|
658
648
|
* 删除标识符
|
|
659
649
|
* @param name 标识符名称
|
|
@@ -702,8 +692,6 @@ export class NewComposite extends LogicItem {
|
|
|
702
692
|
return params;
|
|
703
693
|
}
|
|
704
694
|
|
|
705
|
-
|
|
706
|
-
|
|
707
695
|
/**
|
|
708
696
|
* 删除选择成员
|
|
709
697
|
* @param name 选择成员名称
|
|
@@ -752,8 +740,6 @@ export class NewComposite extends LogicItem {
|
|
|
752
740
|
return params;
|
|
753
741
|
}
|
|
754
742
|
|
|
755
|
-
|
|
756
|
-
|
|
757
743
|
/**
|
|
758
744
|
* 删除赋值连线
|
|
759
745
|
* @param name 赋值连线名称
|
|
@@ -813,7 +799,6 @@ export class NewComposite extends LogicItem {
|
|
|
813
799
|
async newConnection(addRightIndex?: number) {
|
|
814
800
|
const leftLineSet = new Set();
|
|
815
801
|
const lineArr: Array<AssignmentLine> = [];
|
|
816
|
-
const connectionArr: any = [];
|
|
817
802
|
// 系统属性不可自动连线
|
|
818
803
|
['id', 'createdTime', 'updatedTime', 'createdBy', 'updatedBy'].forEach((name) => leftLineSet.add(name));
|
|
819
804
|
// 左边已连线的下标
|
|
@@ -823,17 +808,13 @@ export class NewComposite extends LogicItem {
|
|
|
823
808
|
});
|
|
824
809
|
|
|
825
810
|
const autoConnection = () => {
|
|
826
|
-
let structure: any;
|
|
827
811
|
const isAnnotation = this.typeAnnotation.typeKind === 'anonymousStructure';
|
|
828
|
-
if (!isAnnotation)
|
|
829
|
-
structure = this.app.findNodeByCompleteName(this.typeAnnotation.typeNamespace + '.' + this.typeAnnotation.typeName);
|
|
830
812
|
this.app.emit('collect:start', {
|
|
831
813
|
actionMsg: '自动连线',
|
|
832
814
|
});
|
|
833
815
|
this.properties.forEach((property: Identifier, leftSecondIndex: number) => {
|
|
834
816
|
const leftName = property.name;
|
|
835
|
-
const leftTypeAnnotation = !isAnnotation &&
|
|
836
|
-
const typeStruct = isAnnotation && this.typeAnnotation.properties[leftSecondIndex]; // 获取匿名数据结构typeAnnotation的具体property
|
|
817
|
+
const leftTypeAnnotation = !isAnnotation && property.__TypeAnnotation;
|
|
837
818
|
if (leftLineSet.has(leftSecondIndex) || leftLineSet.has(leftName))
|
|
838
819
|
return;
|
|
839
820
|
|
|
@@ -858,10 +839,6 @@ export class NewComposite extends LogicItem {
|
|
|
858
839
|
rightIndex: [rightFirstIndex],
|
|
859
840
|
});
|
|
860
841
|
lineArr.push(Line);
|
|
861
|
-
connectionArr.push({
|
|
862
|
-
leftItem: typeStruct,
|
|
863
|
-
rightItem: expression,
|
|
864
|
-
});
|
|
865
842
|
leftLineSet.add(leftSecondIndex);
|
|
866
843
|
return;
|
|
867
844
|
}
|
|
@@ -878,33 +855,21 @@ export class NewComposite extends LogicItem {
|
|
|
878
855
|
const rightIndex = [rightFirstIndex, rightSecondIndex];
|
|
879
856
|
const Line: AssignmentLine = new AssignmentLine({ leftIndex, rightIndex });
|
|
880
857
|
lineArr.push(Line);
|
|
881
|
-
connectionArr.push({
|
|
882
|
-
leftItem: typeStruct,
|
|
883
|
-
rightItem: rightMember,
|
|
884
|
-
});
|
|
885
858
|
leftLineSet.add(leftSecondIndex);
|
|
886
859
|
}
|
|
887
860
|
});
|
|
888
861
|
});
|
|
889
862
|
});
|
|
890
863
|
lineArr.length && this.setAssignmentLines([...this.assignmentLines, ...lineArr]);
|
|
891
|
-
if (this.typeAnnotation.typeKind === 'anonymousStructure') {
|
|
892
|
-
connectionArr.forEach(({ leftItem, rightItem }: any) => {
|
|
893
|
-
if (rightItem.__TypeAnnotation) {
|
|
894
|
-
leftItem.update({
|
|
895
|
-
typeAnnotation: TypeAnnotation.from({ ...rightItem.__TypeAnnotation.toJSON() }),
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
864
|
this.app.emit('collect:end');
|
|
901
865
|
};
|
|
902
866
|
|
|
903
867
|
let count = 0;
|
|
904
868
|
const typeAnnotationEnd = () => {
|
|
905
|
-
const
|
|
869
|
+
const l = this.properties.every((item) => item.__isCorrectTypeAnnotation);
|
|
870
|
+
const r = this.rights.every((right) => right.members.every((item) => item.__isCorrectTypeAnnotation) && right.expression.__isCorrectTypeAnnotation);
|
|
906
871
|
count++;
|
|
907
|
-
if (r) {
|
|
872
|
+
if (r && l) {
|
|
908
873
|
autoConnection();
|
|
909
874
|
} else if (count <= 10) {
|
|
910
875
|
setTimeout(() => {
|
|
@@ -947,47 +912,17 @@ export class NewComposite extends LogicItem {
|
|
|
947
912
|
});
|
|
948
913
|
newLines.push(Line);
|
|
949
914
|
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
});
|
|
955
|
-
} else {
|
|
956
|
-
this.app.emit('collect:start', {
|
|
957
|
-
actionMsg: '匿名数据结构连线',
|
|
958
|
-
});
|
|
959
|
-
// 匿名数据结构typeAnnotation变化
|
|
960
|
-
const structureProperty = this.typeAnnotation.properties.find(({ name }) => name === leftItem.name);
|
|
961
|
-
const exp = rightItem.concept === 'SelectMembers' ? rightItem.expression : rightItem;
|
|
962
|
-
// 场景:右侧连接是非匿名数据
|
|
963
|
-
if (exp.__TypeAnnotation && exp.__TypeAnnotation.typeKey !== 'nasl.core.Null') {
|
|
964
|
-
structureProperty.update({
|
|
965
|
-
typeAnnotation: TypeAnnotation.from({ ...exp.__TypeAnnotation.toJSON() }),
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
this.update({
|
|
969
|
-
assignmentLines: newLines,
|
|
970
|
-
properties: newProperties,
|
|
971
|
-
});
|
|
972
|
-
this.app.emit('collect:end');
|
|
973
|
-
}
|
|
915
|
+
this.update({
|
|
916
|
+
assignmentLines: newLines,
|
|
917
|
+
properties: newProperties,
|
|
918
|
+
});
|
|
974
919
|
}
|
|
975
920
|
|
|
976
921
|
deleteAssignmentLine(assignmentLine: AssignmentLine) {
|
|
977
922
|
const newLine = this.assignmentLines.filter((line) => line !== assignmentLine);
|
|
978
|
-
this.app.emit('collect:start', {
|
|
979
|
-
actionMsg: '删除连线',
|
|
980
|
-
});
|
|
981
|
-
if (this.typeAnnotation.typeKind === 'anonymousStructure') {
|
|
982
|
-
const typeStructureProperty = this.findMember(assignmentLine.leftIndex, 'left', true);
|
|
983
|
-
typeStructureProperty.update({
|
|
984
|
-
typeAnnotation: null,
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
923
|
this.update({
|
|
988
924
|
assignmentLines: newLine,
|
|
989
925
|
});
|
|
990
|
-
this.app.emit('collect:end');
|
|
991
926
|
}
|
|
992
927
|
|
|
993
928
|
changeLinesLocation(selectMember: any) {
|
|
@@ -999,7 +934,6 @@ export class NewComposite extends LogicItem {
|
|
|
999
934
|
const newRights = this.rights.filter((member) => selectMember !== member);
|
|
1000
935
|
const filterLine = this.assignmentLines.filter((line) => line.rightIndex[0] !== index);
|
|
1001
936
|
const newLines: Array<AssignmentLine> = [];
|
|
1002
|
-
const oldLines: AssignmentLine[] = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] === index);
|
|
1003
937
|
filterLine.forEach((line) => {
|
|
1004
938
|
if (line.rightIndex[0] > index) {
|
|
1005
939
|
if (line.rightIndex[1] === undefined) {
|
|
@@ -1013,22 +947,10 @@ export class NewComposite extends LogicItem {
|
|
|
1013
947
|
newLines.push(line);
|
|
1014
948
|
}
|
|
1015
949
|
});
|
|
1016
|
-
this.app.emit('collect:start', {
|
|
1017
|
-
actionMsg: '匿名数据结构删除右侧变量',
|
|
1018
|
-
});
|
|
1019
|
-
if (this.typeAnnotation.typeKind === 'anonymousStructure') {
|
|
1020
|
-
oldLines.forEach(({ leftIndex }) => {
|
|
1021
|
-
const leftItem = this.typeAnnotation.properties[leftIndex[1]];
|
|
1022
|
-
leftItem.update({
|
|
1023
|
-
typeAnnotation: null,
|
|
1024
|
-
});
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
950
|
this.update({
|
|
1028
951
|
rights: newRights,
|
|
1029
952
|
assignmentLines: newLines,
|
|
1030
953
|
});
|
|
1031
|
-
this.app.emit('collect:end');
|
|
1032
954
|
}
|
|
1033
955
|
}
|
|
1034
956
|
|
|
@@ -1044,7 +966,7 @@ export class NewComposite extends LogicItem {
|
|
|
1044
966
|
let oldLines: AssignmentLine[] = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] === splitIndex);
|
|
1045
967
|
// 右侧变量改变后,修改连线
|
|
1046
968
|
members.forEach((item, index) => {
|
|
1047
|
-
if (keepMembers
|
|
969
|
+
if (keepMembers?.has(item.completeName)) {
|
|
1048
970
|
const lines = this.findlines(item, selectMember);
|
|
1049
971
|
lines.forEach((line) => {
|
|
1050
972
|
const newLine = Object.assign({}, line, { rightIndex: [line.rightIndex[0], index] });
|
|
@@ -1054,14 +976,6 @@ export class NewComposite extends LogicItem {
|
|
|
1054
976
|
}
|
|
1055
977
|
});
|
|
1056
978
|
|
|
1057
|
-
if (this.typeAnnotation.typeKind === 'anonymousStructure') {
|
|
1058
|
-
oldLines.forEach(({ leftIndex }) => {
|
|
1059
|
-
const leftItem = this.typeAnnotation.properties[leftIndex[1]];
|
|
1060
|
-
leftItem.update({
|
|
1061
|
-
typeAnnotation: null,
|
|
1062
|
-
});
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
979
|
this.update({
|
|
1066
980
|
assignmentLines: newLines,
|
|
1067
981
|
rights: [...this.rights.slice(0, splitIndex), newSelectMember, ...this.rights.slice(splitIndex + 1, this.rights.length)],
|
|
@@ -1094,11 +1008,8 @@ export class NewComposite extends LogicItem {
|
|
|
1094
1008
|
return lines;
|
|
1095
1009
|
}
|
|
1096
1010
|
|
|
1097
|
-
findMember(arrIndex: Array<number>, place: string
|
|
1011
|
+
findMember(arrIndex: Array<number>, place: string) {
|
|
1098
1012
|
const [firstIndex, secondIndex] = [arrIndex[0], arrIndex[1]];
|
|
1099
|
-
if (isAnnotation) {
|
|
1100
|
-
return this.typeAnnotation.properties[secondIndex];
|
|
1101
|
-
}
|
|
1102
1013
|
|
|
1103
1014
|
if (place === 'left') {
|
|
1104
1015
|
if (secondIndex === undefined) {
|
|
@@ -1219,34 +1130,35 @@ export class NewComposite extends LogicItem {
|
|
|
1219
1130
|
});
|
|
1220
1131
|
// 方便ts报错检查
|
|
1221
1132
|
code += 'function __newComposite() {\n';
|
|
1222
|
-
code += `let
|
|
1223
|
-
code += '\n';
|
|
1133
|
+
code += `let __obj = nasl.util.New<${this.typeAnnotation.sortedTypeKey}>();\n`;
|
|
1224
1134
|
// 是否是左边的顶层连线
|
|
1225
1135
|
const leftTopIndex = this.assignmentLines.findIndex(({ leftIndex }) => leftIndex[1] === undefined);
|
|
1226
1136
|
if (leftTopIndex !== -1) {
|
|
1227
1137
|
const rightIndex = this.assignmentLines[leftTopIndex].rightIndex;
|
|
1228
1138
|
const rightExpression = rightIndex[1] !== undefined ? this.rights[rightIndex[0]].members[rightIndex[1]] : this.rights[rightIndex[0]].expression;
|
|
1229
|
-
code += `
|
|
1139
|
+
code += `__obj = ${rightExpression.toEmbeddedTS(shiftState(state, code, { inline: true }))};`;
|
|
1230
1140
|
code += '\n';
|
|
1231
1141
|
} else {
|
|
1142
|
+
// 左侧properties的identifier的类型标注
|
|
1143
|
+
code += 'const { ';
|
|
1144
|
+
this.properties.forEach((item, index) => {
|
|
1145
|
+
code += item.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1146
|
+
if (index < this.properties.length - 1)
|
|
1147
|
+
code += ', ';
|
|
1148
|
+
});
|
|
1149
|
+
code += ' } = __obj;\n';
|
|
1232
1150
|
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
1233
1151
|
const leftSecondIndex = leftIndex[1];
|
|
1234
1152
|
const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
|
|
1235
1153
|
const leftItem = this.properties[leftSecondIndex];
|
|
1236
1154
|
const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
|
|
1237
1155
|
const rightTs = rightMap.get(rightItem);
|
|
1238
|
-
code += `
|
|
1239
|
-
code += '
|
|
1240
|
-
|
|
1241
|
-
// 左侧properties的identifier的类型标注
|
|
1242
|
-
this.properties.forEach((item) => {
|
|
1243
|
-
code += '{ const ';
|
|
1244
|
-
const name = item.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1245
|
-
code += `${name} = obj.${name};`;
|
|
1246
|
-
code += '}\n';
|
|
1156
|
+
code += `nasl.core.compareNew(`;
|
|
1157
|
+
code += `${['__IDENTIFIER__', '__IDENTIFIER__()'].includes(rightTs) ? 'null' : rightMap.get(rightItem)}, `;
|
|
1158
|
+
code += `${leftItem.toEmbeddedTS(shiftState(state, code, { inline: true }))});\n`;
|
|
1247
1159
|
});
|
|
1248
1160
|
}
|
|
1249
|
-
code += 'return
|
|
1161
|
+
code += 'return __obj;\n';
|
|
1250
1162
|
code += '};\n';
|
|
1251
1163
|
|
|
1252
1164
|
code += 'return __newComposite();\n';
|
|
@@ -1280,24 +1192,35 @@ export class NewComposite extends LogicItem {
|
|
|
1280
1192
|
code += right.members.length ? '\n' : '';
|
|
1281
1193
|
});
|
|
1282
1194
|
// 方便ts报错检查
|
|
1283
|
-
code += 'function __newComposite()
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
this.properties.forEach((property) => {
|
|
1195
|
+
code += 'function __newComposite() {\n';
|
|
1196
|
+
this.properties.forEach((property, index) => {
|
|
1197
|
+
const temp = `temp${index}`;
|
|
1287
1198
|
const name = property.name;
|
|
1288
1199
|
const rightItem = nameMap.get(name);
|
|
1289
|
-
|
|
1290
|
-
|
|
1200
|
+
const ts = rightMap.get(rightItem);
|
|
1201
|
+
if (ts !== undefined) {
|
|
1202
|
+
if (['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
|
|
1203
|
+
code += `const ${temp}: any = null; `;
|
|
1204
|
+
} else {
|
|
1205
|
+
code += `const ${temp}${ts === 'null' ? ':void' : ''} = ${ts}; `;
|
|
1206
|
+
}
|
|
1207
|
+
code += 'const ';
|
|
1291
1208
|
code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1292
|
-
code += `: nasl.core.Incompatible<typeof
|
|
1293
|
-
code += '
|
|
1209
|
+
code += `: nasl.core.Incompatible<typeof ${temp}, void> = ${temp}`;
|
|
1210
|
+
code += ';\n';
|
|
1294
1211
|
} else {
|
|
1295
|
-
code += '
|
|
1212
|
+
code += 'const ';
|
|
1296
1213
|
code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1297
|
-
code += '
|
|
1214
|
+
code += ';\n';
|
|
1298
1215
|
}
|
|
1299
1216
|
});
|
|
1300
|
-
code += 'return
|
|
1217
|
+
code += 'return {\n';
|
|
1218
|
+
code += `__name: "AStructure_${this.typeAnnotation.hash}" as const,\n`;
|
|
1219
|
+
this.properties.forEach((property) => {
|
|
1220
|
+
code += `${property.name},\n`;
|
|
1221
|
+
});
|
|
1222
|
+
code += '}\n';
|
|
1223
|
+
|
|
1301
1224
|
code += '};\n';
|
|
1302
1225
|
|
|
1303
1226
|
code += 'return __newComposite();\n';
|
|
@@ -1306,24 +1229,59 @@ export class NewComposite extends LogicItem {
|
|
|
1306
1229
|
return code;
|
|
1307
1230
|
}
|
|
1308
1231
|
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1232
|
+
getInitCode(state?: TranslatorState): string {
|
|
1233
|
+
let code = '';
|
|
1234
|
+
const nameMap = new Map();
|
|
1235
|
+
const rightMap = new Map();
|
|
1236
|
+
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
1237
|
+
const leftSecondIndex = leftIndex[1];
|
|
1238
|
+
const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
|
|
1239
|
+
const leftItem = this.properties[leftSecondIndex];
|
|
1240
|
+
const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
|
|
1241
|
+
nameMap.set(leftItem.name, rightItem);
|
|
1242
|
+
rightMap.set(rightItem, null);
|
|
1243
|
+
});
|
|
1244
|
+
code += '(() => { ';
|
|
1245
|
+
// 提供sourcemap,获取类型标注和上下文可选变量
|
|
1246
|
+
this.rights.forEach((right) => {
|
|
1247
|
+
let ts = right.expression.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1248
|
+
if (rightMap.has(right.expression))
|
|
1249
|
+
rightMap.set(right.expression, ts);
|
|
1250
|
+
right.members.forEach((member) => {
|
|
1251
|
+
ts = member.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1252
|
+
if (rightMap.has(member))
|
|
1253
|
+
rightMap.set(member, ts);
|
|
1254
|
+
});
|
|
1313
1255
|
});
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1256
|
+
// 方便ts报错检查
|
|
1257
|
+
code += 'function __newComposite() { ';
|
|
1258
|
+
this.properties.forEach((property) => {
|
|
1259
|
+
const name = property.name;
|
|
1260
|
+
const rightItem = nameMap.get(name);
|
|
1261
|
+
const ts = rightMap.get(rightItem);
|
|
1262
|
+
if (ts !== undefined) {
|
|
1263
|
+
code += `const ${name} = ${['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts}; `;
|
|
1264
|
+
} else {
|
|
1265
|
+
code += `const ${name}; `;
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
code += '\nreturn {\n';
|
|
1269
|
+
code += `__name: "AStructure_${this.typeAnnotation.hash}" as const,\n`;
|
|
1270
|
+
this.properties.forEach((property) => {
|
|
1271
|
+
code += `${property.name},\n`;
|
|
1318
1272
|
});
|
|
1319
|
-
|
|
1320
|
-
|
|
1273
|
+
code += '}\n';
|
|
1274
|
+
|
|
1275
|
+
code += '};\n';
|
|
1276
|
+
|
|
1277
|
+
code += 'return __newComposite();\n';
|
|
1278
|
+
code += '})()';
|
|
1279
|
+
return code;
|
|
1321
1280
|
}
|
|
1322
1281
|
|
|
1323
1282
|
__deleteIdentifier(property: Identifier) {
|
|
1324
1283
|
const index = this.properties.findIndex((p) => p === property);
|
|
1325
1284
|
const newLines: AssignmentLine[] = [];
|
|
1326
|
-
const newProperties = [...this.typeAnnotation.properties.slice(0, index), ...this.typeAnnotation.properties.slice(index + 1, this.properties.length)];
|
|
1327
1285
|
this.assignmentLines.forEach((line) => {
|
|
1328
1286
|
const { leftIndex } = line;
|
|
1329
1287
|
if (leftIndex[1] < index) {
|
|
@@ -1337,9 +1295,6 @@ export class NewComposite extends LogicItem {
|
|
|
1337
1295
|
actionMsg: '删除匿名数据结属性',
|
|
1338
1296
|
});
|
|
1339
1297
|
this.setAssignmentLines(newLines);
|
|
1340
|
-
this.typeAnnotation.update({
|
|
1341
|
-
properties: newProperties,
|
|
1342
|
-
});
|
|
1343
1298
|
property.delete();
|
|
1344
1299
|
this.app.emit('collect:end');
|
|
1345
1300
|
}
|
|
@@ -326,6 +326,22 @@ export class NewList extends LogicItem {
|
|
|
326
326
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
327
327
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
328
328
|
//================================================================================
|
|
329
|
+
toBrief(): string {
|
|
330
|
+
let code = '';
|
|
331
|
+
code += '[ ';
|
|
332
|
+
this.items.forEach((value, index) => {
|
|
333
|
+
if (index >= 10)
|
|
334
|
+
return;
|
|
335
|
+
if (index)
|
|
336
|
+
code += ',';
|
|
337
|
+
code += value.toBrief();
|
|
338
|
+
});
|
|
339
|
+
if (this.items.length > 10)
|
|
340
|
+
code += ', ...';
|
|
341
|
+
code += ' ]';
|
|
342
|
+
return code;
|
|
343
|
+
}
|
|
344
|
+
|
|
329
345
|
toUI(state?: TranslatorState): string {
|
|
330
346
|
let code = '';
|
|
331
347
|
code += '[';
|
|
@@ -376,11 +392,16 @@ export class NewList extends LogicItem {
|
|
|
376
392
|
code += '(() => { \n';
|
|
377
393
|
const arr: any = [];
|
|
378
394
|
this.items.forEach((item, index) => {
|
|
395
|
+
if (item.concept === 'Unparsed')
|
|
396
|
+
return;
|
|
397
|
+
code += 'nasl.core.ensureVoid(';
|
|
379
398
|
arr.push(item.toEmbeddedTS(shiftState(state, code, { inline: true })));
|
|
380
399
|
code += arr[index];
|
|
381
|
-
code += '; ';
|
|
400
|
+
code += '); ';
|
|
382
401
|
});
|
|
383
402
|
code += '\n';
|
|
403
|
+
if (!arr.length || arr.every((item: any) => ['__IDENTIFIER__', '__IDENTIFIER__()', 'null'].includes(item)))
|
|
404
|
+
code += '__IDENTIFIER__;\n';
|
|
384
405
|
// ts报错检查
|
|
385
406
|
code += 'function __newComposite() {\n';
|
|
386
407
|
if (this.items.length === 0) {
|
|
@@ -413,7 +434,7 @@ export class NewList extends LogicItem {
|
|
|
413
434
|
code += 'let arr = [';
|
|
414
435
|
this.items.forEach((item, index) => {
|
|
415
436
|
const ts = item.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
416
|
-
code +=
|
|
437
|
+
code += ['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts;
|
|
417
438
|
if (index + 1 < this.items.length)
|
|
418
439
|
code += ', ';
|
|
419
440
|
});
|
package/src/concepts/NewMap__.ts
CHANGED
|
@@ -43,8 +43,6 @@ export class NewMap extends LogicItem {
|
|
|
43
43
|
@property('LogicItem')
|
|
44
44
|
values: Array<LogicItem> = [];
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
46
|
/**
|
|
49
47
|
* @param source 需要合并的部分参数
|
|
50
48
|
*/
|
|
@@ -58,7 +56,6 @@ export class NewMap extends LogicItem {
|
|
|
58
56
|
return super.from(source, parentNode, parentKey) as NewMap;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
|
|
62
59
|
/**
|
|
63
60
|
* 设置类型
|
|
64
61
|
*/
|
|
@@ -98,7 +95,7 @@ export class NewMap extends LogicItem {
|
|
|
98
95
|
});
|
|
99
96
|
}
|
|
100
97
|
|
|
101
|
-
|
|
98
|
+
getItemExistingNames(excludedList: Array<LogicItem> = []) {
|
|
102
99
|
const excludedSet = new Set(excludedList);
|
|
103
100
|
return ((this.keys as LogicItem[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
104
101
|
}
|
|
@@ -372,9 +369,6 @@ export class NewMap extends LogicItem {
|
|
|
372
369
|
return node;
|
|
373
370
|
}
|
|
374
371
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
372
|
/**
|
|
379
373
|
* 删除类型标注
|
|
380
374
|
* @param name 类型标注名称
|
|
@@ -423,8 +417,6 @@ export class NewMap extends LogicItem {
|
|
|
423
417
|
return params;
|
|
424
418
|
}
|
|
425
419
|
|
|
426
|
-
|
|
427
|
-
|
|
428
420
|
/**
|
|
429
421
|
* 删除逻辑项
|
|
430
422
|
* @param name 逻辑项名称
|
|
@@ -450,8 +442,6 @@ export class NewMap extends LogicItem {
|
|
|
450
442
|
return logicItem.delete();
|
|
451
443
|
}
|
|
452
444
|
|
|
453
|
-
|
|
454
|
-
|
|
455
445
|
/**
|
|
456
446
|
* 删除逻辑项
|
|
457
447
|
* @param name 逻辑项名称
|
|
@@ -516,7 +506,7 @@ export class NewMap extends LogicItem {
|
|
|
516
506
|
this.update({
|
|
517
507
|
keys: [...this.keys, undefined],
|
|
518
508
|
values: [...this.values, undefined],
|
|
519
|
-
})
|
|
509
|
+
});
|
|
520
510
|
}
|
|
521
511
|
|
|
522
512
|
removePair(idx: number) {
|
|
@@ -527,7 +517,24 @@ export class NewMap extends LogicItem {
|
|
|
527
517
|
this.update({
|
|
528
518
|
keys: k,
|
|
529
519
|
values: v,
|
|
530
|
-
})
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
toBrief(): string {
|
|
524
|
+
let code = '';
|
|
525
|
+
code += '[<br />';
|
|
526
|
+
this.keys.forEach((key, index) => {
|
|
527
|
+
if (index >= 10)
|
|
528
|
+
return;
|
|
529
|
+
const value = this.values[index];
|
|
530
|
+
code += ' ';
|
|
531
|
+
code += `${key ? key.toBrief() : 'null'} -> ${value ? value.toBrief() : 'null'}`;
|
|
532
|
+
code += '<br />';
|
|
533
|
+
});
|
|
534
|
+
if (this.keys.length > 10)
|
|
535
|
+
code += '  ...<br />';
|
|
536
|
+
code += ']';
|
|
537
|
+
return code;
|
|
531
538
|
}
|
|
532
539
|
|
|
533
540
|
toJS(state?: TranslatorState): string {
|
|
@@ -576,48 +583,65 @@ export class NewMap extends LogicItem {
|
|
|
576
583
|
code += 'return __newComposite();\n';
|
|
577
584
|
code += '})()';
|
|
578
585
|
} else {
|
|
579
|
-
if (this.keys.
|
|
586
|
+
if (this.keys.some((key) => key) || this.values.some((value) => value)) {
|
|
580
587
|
code += '(() => { \n';
|
|
581
588
|
const valueTsArr: any = [];
|
|
582
589
|
let keyTs = 'null';
|
|
583
|
-
let
|
|
584
|
-
|
|
590
|
+
let valueTs = false;
|
|
591
|
+
let keyIndex = -1;
|
|
592
|
+
this.keys.forEach((key, index) => {
|
|
585
593
|
if (key) {
|
|
586
594
|
const ts = key.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
587
|
-
if (
|
|
588
|
-
|
|
595
|
+
if (keyIndex === -1 && !['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
|
|
596
|
+
keyIndex = index;
|
|
589
597
|
keyTs = ts;
|
|
590
598
|
}
|
|
591
599
|
}
|
|
592
600
|
});
|
|
593
601
|
this.values.forEach((item, index) => {
|
|
602
|
+
if (item)
|
|
603
|
+
valueTs = true;
|
|
604
|
+
code += 'nasl.core.ensureVoid(';
|
|
594
605
|
const ts = item ? item.toEmbeddedTS(shiftState(state, code, { inline: true })) : null;
|
|
595
606
|
valueTsArr.push(ts);
|
|
596
607
|
code += valueTsArr[index];
|
|
597
|
-
code += '; ';
|
|
608
|
+
code += '); ';
|
|
598
609
|
});
|
|
599
610
|
code += '\n';
|
|
611
|
+
if (keyTs === 'null' || !valueTs) {
|
|
612
|
+
code += '__IDENTIFIER__;\n';
|
|
613
|
+
}
|
|
600
614
|
// 方便ts报错检查
|
|
601
615
|
code += 'function __newComposite() {\n';
|
|
602
616
|
this.keys.forEach((key: any) => {
|
|
603
|
-
|
|
617
|
+
if (!key)
|
|
618
|
+
return;
|
|
619
|
+
code += `nasl.core.compareNew(${keyTs}, `;
|
|
604
620
|
code += key.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
605
621
|
code += ');\n';
|
|
606
622
|
});
|
|
607
|
-
code += `return nasl.util.NewMap(
|
|
623
|
+
code += `return nasl.util.NewMap(`;
|
|
624
|
+
code += `${keyIndex === -1 ? 'null' : this.keys[keyIndex].toEmbeddedTS(shiftState(state, code, { inline: true }))}, ...[`;
|
|
608
625
|
valueTsArr.forEach((ts: any, index: number) => {
|
|
609
626
|
code += ['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts;
|
|
610
627
|
if (index + 1 < this.values.length)
|
|
611
628
|
code += ', ';
|
|
612
629
|
});
|
|
613
|
-
code += ');\n';
|
|
630
|
+
code += ']);\n';
|
|
614
631
|
|
|
615
632
|
code += '};\n';
|
|
616
633
|
|
|
617
634
|
code += 'return __newComposite();\n';
|
|
618
635
|
code += '})()';
|
|
619
636
|
} else {
|
|
620
|
-
code +=
|
|
637
|
+
code += '(() => {\n';
|
|
638
|
+
code += '__IDENTIFIER__;\n';
|
|
639
|
+
code += 'function __newComposite() {\n';
|
|
640
|
+
code += `return nasl.util.NewMap(${null}, ${null});\n`;
|
|
641
|
+
code += '};\n';
|
|
642
|
+
|
|
643
|
+
code += 'return __newComposite();\n';
|
|
644
|
+
code += '})()';
|
|
621
645
|
}
|
|
622
646
|
}
|
|
623
647
|
return code;
|
|
@@ -625,7 +649,7 @@ export class NewMap extends LogicItem {
|
|
|
625
649
|
|
|
626
650
|
getInitCode(state?: TranslatorState): string {
|
|
627
651
|
let code = '';
|
|
628
|
-
if (this.keys.
|
|
652
|
+
if (this.keys.some((key) => key) || this.values.some((value) => value)) {
|
|
629
653
|
let keyBol = false;
|
|
630
654
|
code += `nasl.util.NewMap(`;
|
|
631
655
|
this.keys.forEach((key) => {
|