@lcap/nasl 2.20.0-beta.3 → 2.20.0-beta.5
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 +271 -39
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +7 -0
- package/out/concepts/BindDirective__.js +215 -16
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +7 -0
- package/out/concepts/BindStyle__.js +192 -2
- 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 +63 -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 +11 -3
- 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 +22 -4
- 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 +30 -8
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +2 -2
- package/out/concepts/Match__.js +29 -13
- 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 +3 -4
- package/out/concepts/NewComposite__.js +99 -116
- 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 +13 -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 +12 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +1 -0
- package/out/concepts/ViewElement__.js +24 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -3
- package/out/concepts/View__.js +33 -12
- 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 +3 -3
- package/out/generator/genReleaseBody.js +98 -23
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.d.ts +3 -10
- package/out/generator/permission.js +43 -21
- package/out/generator/permission.js.map +1 -1
- 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 +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 +558 -62
- 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 +22 -2
- 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/translator/index.js +4 -1
- package/out/translator/index.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 +301 -38
- package/src/concepts/BindDirective__.ts +205 -30
- package/src/concepts/BindStyle__.ts +188 -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 +72 -4
- package/src/concepts/Configuration__.ts +14 -5
- package/src/concepts/DataSource__.ts +10 -3
- 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 +29 -9
- 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 +110 -89
- package/src/concepts/Match__.ts +53 -14
- package/src/concepts/MemberExpression__.ts +6 -0
- package/src/concepts/Module__.ts +57 -0
- package/src/concepts/NewComposite__.ts +104 -131
- 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 +10 -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 +102 -15
- package/src/concepts/ValidationRule__.ts +58 -9
- package/src/concepts/Variable__.ts +13 -1
- package/src/concepts/ViewElement__.ts +47 -2
- package/src/concepts/View__.ts +39 -18
- 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 +77 -31
- package/src/generator/permission.ts +47 -21
- package/src/index.ts +1 -1
- 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 +555 -63
- package/src/server/translator.ts +96 -34
- package/src/service/storage/dist/init.js +579 -0
- package/src/service/storage/init.ts +23 -3
- 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/translator/index.ts +3 -1
- 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,9 @@
|
|
|
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__';
|
|
6
|
+
import { genHash } from '../generator';
|
|
5
7
|
//================================================================================
|
|
6
8
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
7
9
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -18,7 +20,6 @@ import Identifier from './Identifier__';
|
|
|
18
20
|
import SelectMembers from './SelectMembers__';
|
|
19
21
|
import AssignmentLine from './AssignmentLine__';
|
|
20
22
|
import LogicItem from './LogicItem__';
|
|
21
|
-
import App from './App__';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* 实体/(匿名)数据结构构造器
|
|
@@ -73,8 +74,6 @@ export class NewComposite extends LogicItem {
|
|
|
73
74
|
@property()
|
|
74
75
|
autoConnection: boolean = true;
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
78
77
|
/**
|
|
79
78
|
* @param source 需要合并的部分参数
|
|
80
79
|
*/
|
|
@@ -88,7 +87,6 @@ export class NewComposite extends LogicItem {
|
|
|
88
87
|
return super.from(source, parentNode, parentKey) as NewComposite;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
|
|
92
90
|
/**
|
|
93
91
|
* 设置类型
|
|
94
92
|
*/
|
|
@@ -176,7 +174,7 @@ export class NewComposite extends LogicItem {
|
|
|
176
174
|
});
|
|
177
175
|
}
|
|
178
176
|
|
|
179
|
-
|
|
177
|
+
getIdentifierExistingNames(excludedList: Array<Identifier> = []) {
|
|
180
178
|
const excludedSet = new Set(excludedList);
|
|
181
179
|
return ((this.properties as Identifier[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
182
180
|
}
|
|
@@ -317,7 +315,6 @@ export class NewComposite extends LogicItem {
|
|
|
317
315
|
return node;
|
|
318
316
|
}
|
|
319
317
|
|
|
320
|
-
|
|
321
318
|
getSelectMembersExistingNames(excludedList: Array<SelectMembers> = []) {
|
|
322
319
|
const excludedSet = new Set(excludedList);
|
|
323
320
|
return ((this.rights as SelectMembers[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
@@ -459,7 +456,6 @@ export class NewComposite extends LogicItem {
|
|
|
459
456
|
return node;
|
|
460
457
|
}
|
|
461
458
|
|
|
462
|
-
|
|
463
459
|
getAssignmentLineExistingNames(excludedList: Array<AssignmentLine> = []) {
|
|
464
460
|
const excludedSet = new Set(excludedList);
|
|
465
461
|
return ((this.assignmentLines as AssignmentLine[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
@@ -601,9 +597,6 @@ export class NewComposite extends LogicItem {
|
|
|
601
597
|
return node;
|
|
602
598
|
}
|
|
603
599
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
600
|
/**
|
|
608
601
|
* 删除类型标注
|
|
609
602
|
* @param name 类型标注名称
|
|
@@ -652,8 +645,6 @@ export class NewComposite extends LogicItem {
|
|
|
652
645
|
return params;
|
|
653
646
|
}
|
|
654
647
|
|
|
655
|
-
|
|
656
|
-
|
|
657
648
|
/**
|
|
658
649
|
* 删除标识符
|
|
659
650
|
* @param name 标识符名称
|
|
@@ -702,8 +693,6 @@ export class NewComposite extends LogicItem {
|
|
|
702
693
|
return params;
|
|
703
694
|
}
|
|
704
695
|
|
|
705
|
-
|
|
706
|
-
|
|
707
696
|
/**
|
|
708
697
|
* 删除选择成员
|
|
709
698
|
* @param name 选择成员名称
|
|
@@ -752,8 +741,6 @@ export class NewComposite extends LogicItem {
|
|
|
752
741
|
return params;
|
|
753
742
|
}
|
|
754
743
|
|
|
755
|
-
|
|
756
|
-
|
|
757
744
|
/**
|
|
758
745
|
* 删除赋值连线
|
|
759
746
|
* @param name 赋值连线名称
|
|
@@ -813,7 +800,6 @@ export class NewComposite extends LogicItem {
|
|
|
813
800
|
async newConnection(addRightIndex?: number) {
|
|
814
801
|
const leftLineSet = new Set();
|
|
815
802
|
const lineArr: Array<AssignmentLine> = [];
|
|
816
|
-
const connectionArr: any = [];
|
|
817
803
|
// 系统属性不可自动连线
|
|
818
804
|
['id', 'createdTime', 'updatedTime', 'createdBy', 'updatedBy'].forEach((name) => leftLineSet.add(name));
|
|
819
805
|
// 左边已连线的下标
|
|
@@ -823,17 +809,13 @@ export class NewComposite extends LogicItem {
|
|
|
823
809
|
});
|
|
824
810
|
|
|
825
811
|
const autoConnection = () => {
|
|
826
|
-
let structure: any;
|
|
827
812
|
const isAnnotation = this.typeAnnotation.typeKind === 'anonymousStructure';
|
|
828
|
-
if (!isAnnotation)
|
|
829
|
-
structure = this.app.findNodeByCompleteName(this.typeAnnotation.typeNamespace + '.' + this.typeAnnotation.typeName);
|
|
830
813
|
this.app.emit('collect:start', {
|
|
831
814
|
actionMsg: '自动连线',
|
|
832
815
|
});
|
|
833
816
|
this.properties.forEach((property: Identifier, leftSecondIndex: number) => {
|
|
834
817
|
const leftName = property.name;
|
|
835
|
-
const leftTypeAnnotation = !isAnnotation &&
|
|
836
|
-
const typeStruct = isAnnotation && this.typeAnnotation.properties[leftSecondIndex]; // 获取匿名数据结构typeAnnotation的具体property
|
|
818
|
+
const leftTypeAnnotation = !isAnnotation && property.__TypeAnnotation;
|
|
837
819
|
if (leftLineSet.has(leftSecondIndex) || leftLineSet.has(leftName))
|
|
838
820
|
return;
|
|
839
821
|
|
|
@@ -858,10 +840,6 @@ export class NewComposite extends LogicItem {
|
|
|
858
840
|
rightIndex: [rightFirstIndex],
|
|
859
841
|
});
|
|
860
842
|
lineArr.push(Line);
|
|
861
|
-
connectionArr.push({
|
|
862
|
-
leftItem: typeStruct,
|
|
863
|
-
rightItem: expression,
|
|
864
|
-
});
|
|
865
843
|
leftLineSet.add(leftSecondIndex);
|
|
866
844
|
return;
|
|
867
845
|
}
|
|
@@ -878,33 +856,21 @@ export class NewComposite extends LogicItem {
|
|
|
878
856
|
const rightIndex = [rightFirstIndex, rightSecondIndex];
|
|
879
857
|
const Line: AssignmentLine = new AssignmentLine({ leftIndex, rightIndex });
|
|
880
858
|
lineArr.push(Line);
|
|
881
|
-
connectionArr.push({
|
|
882
|
-
leftItem: typeStruct,
|
|
883
|
-
rightItem: rightMember,
|
|
884
|
-
});
|
|
885
859
|
leftLineSet.add(leftSecondIndex);
|
|
886
860
|
}
|
|
887
861
|
});
|
|
888
862
|
});
|
|
889
863
|
});
|
|
890
864
|
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
865
|
this.app.emit('collect:end');
|
|
901
866
|
};
|
|
902
867
|
|
|
903
868
|
let count = 0;
|
|
904
869
|
const typeAnnotationEnd = () => {
|
|
905
|
-
const
|
|
870
|
+
const l = this.properties.every((item) => item.__isCorrectTypeAnnotation);
|
|
871
|
+
const r = this.rights.every((right) => right.members.every((item) => item.__isCorrectTypeAnnotation) && right.expression.__isCorrectTypeAnnotation);
|
|
906
872
|
count++;
|
|
907
|
-
if (r) {
|
|
873
|
+
if (r && l) {
|
|
908
874
|
autoConnection();
|
|
909
875
|
} else if (count <= 10) {
|
|
910
876
|
setTimeout(() => {
|
|
@@ -947,47 +913,17 @@ export class NewComposite extends LogicItem {
|
|
|
947
913
|
});
|
|
948
914
|
newLines.push(Line);
|
|
949
915
|
|
|
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
|
-
}
|
|
916
|
+
this.update({
|
|
917
|
+
assignmentLines: newLines,
|
|
918
|
+
properties: newProperties,
|
|
919
|
+
});
|
|
974
920
|
}
|
|
975
921
|
|
|
976
922
|
deleteAssignmentLine(assignmentLine: AssignmentLine) {
|
|
977
923
|
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
924
|
this.update({
|
|
988
925
|
assignmentLines: newLine,
|
|
989
926
|
});
|
|
990
|
-
this.app.emit('collect:end');
|
|
991
927
|
}
|
|
992
928
|
|
|
993
929
|
changeLinesLocation(selectMember: any) {
|
|
@@ -999,7 +935,6 @@ export class NewComposite extends LogicItem {
|
|
|
999
935
|
const newRights = this.rights.filter((member) => selectMember !== member);
|
|
1000
936
|
const filterLine = this.assignmentLines.filter((line) => line.rightIndex[0] !== index);
|
|
1001
937
|
const newLines: Array<AssignmentLine> = [];
|
|
1002
|
-
const oldLines: AssignmentLine[] = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] === index);
|
|
1003
938
|
filterLine.forEach((line) => {
|
|
1004
939
|
if (line.rightIndex[0] > index) {
|
|
1005
940
|
if (line.rightIndex[1] === undefined) {
|
|
@@ -1013,22 +948,10 @@ export class NewComposite extends LogicItem {
|
|
|
1013
948
|
newLines.push(line);
|
|
1014
949
|
}
|
|
1015
950
|
});
|
|
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
951
|
this.update({
|
|
1028
952
|
rights: newRights,
|
|
1029
953
|
assignmentLines: newLines,
|
|
1030
954
|
});
|
|
1031
|
-
this.app.emit('collect:end');
|
|
1032
955
|
}
|
|
1033
956
|
}
|
|
1034
957
|
|
|
@@ -1044,7 +967,7 @@ export class NewComposite extends LogicItem {
|
|
|
1044
967
|
let oldLines: AssignmentLine[] = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] === splitIndex);
|
|
1045
968
|
// 右侧变量改变后,修改连线
|
|
1046
969
|
members.forEach((item, index) => {
|
|
1047
|
-
if (keepMembers
|
|
970
|
+
if (keepMembers?.has(item.completeName)) {
|
|
1048
971
|
const lines = this.findlines(item, selectMember);
|
|
1049
972
|
lines.forEach((line) => {
|
|
1050
973
|
const newLine = Object.assign({}, line, { rightIndex: [line.rightIndex[0], index] });
|
|
@@ -1054,14 +977,6 @@ export class NewComposite extends LogicItem {
|
|
|
1054
977
|
}
|
|
1055
978
|
});
|
|
1056
979
|
|
|
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
980
|
this.update({
|
|
1066
981
|
assignmentLines: newLines,
|
|
1067
982
|
rights: [...this.rights.slice(0, splitIndex), newSelectMember, ...this.rights.slice(splitIndex + 1, this.rights.length)],
|
|
@@ -1094,11 +1009,8 @@ export class NewComposite extends LogicItem {
|
|
|
1094
1009
|
return lines;
|
|
1095
1010
|
}
|
|
1096
1011
|
|
|
1097
|
-
findMember(arrIndex: Array<number>, place: string
|
|
1012
|
+
findMember(arrIndex: Array<number>, place: string) {
|
|
1098
1013
|
const [firstIndex, secondIndex] = [arrIndex[0], arrIndex[1]];
|
|
1099
|
-
if (isAnnotation) {
|
|
1100
|
-
return this.typeAnnotation.properties[secondIndex];
|
|
1101
|
-
}
|
|
1102
1014
|
|
|
1103
1015
|
if (place === 'left') {
|
|
1104
1016
|
if (secondIndex === undefined) {
|
|
@@ -1219,34 +1131,35 @@ export class NewComposite extends LogicItem {
|
|
|
1219
1131
|
});
|
|
1220
1132
|
// 方便ts报错检查
|
|
1221
1133
|
code += 'function __newComposite() {\n';
|
|
1222
|
-
code += `let
|
|
1223
|
-
code += '\n';
|
|
1134
|
+
code += `let __obj = nasl.util.New<${this.typeAnnotation.sortedTypeKey}>();\n`;
|
|
1224
1135
|
// 是否是左边的顶层连线
|
|
1225
1136
|
const leftTopIndex = this.assignmentLines.findIndex(({ leftIndex }) => leftIndex[1] === undefined);
|
|
1226
1137
|
if (leftTopIndex !== -1) {
|
|
1227
1138
|
const rightIndex = this.assignmentLines[leftTopIndex].rightIndex;
|
|
1228
1139
|
const rightExpression = rightIndex[1] !== undefined ? this.rights[rightIndex[0]].members[rightIndex[1]] : this.rights[rightIndex[0]].expression;
|
|
1229
|
-
code += `
|
|
1140
|
+
code += `__obj = ${rightExpression.toEmbeddedTS(shiftState(state, code, { inline: true }))};`;
|
|
1230
1141
|
code += '\n';
|
|
1231
1142
|
} else {
|
|
1143
|
+
// 左侧properties的identifier的类型标注
|
|
1144
|
+
code += 'const { ';
|
|
1145
|
+
this.properties.forEach((item, index) => {
|
|
1146
|
+
code += item.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1147
|
+
if (index < this.properties.length - 1)
|
|
1148
|
+
code += ', ';
|
|
1149
|
+
});
|
|
1150
|
+
code += ' } = __obj;\n';
|
|
1232
1151
|
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
1233
1152
|
const leftSecondIndex = leftIndex[1];
|
|
1234
1153
|
const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
|
|
1235
1154
|
const leftItem = this.properties[leftSecondIndex];
|
|
1236
1155
|
const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
|
|
1237
1156
|
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';
|
|
1157
|
+
code += `nasl.core.compareNew(`;
|
|
1158
|
+
code += `${['__IDENTIFIER__', '__IDENTIFIER__()'].includes(rightTs) ? 'null' : rightMap.get(rightItem)}, `;
|
|
1159
|
+
code += `${leftItem.toEmbeddedTS(shiftState(state, code, { inline: true }))});\n`;
|
|
1247
1160
|
});
|
|
1248
1161
|
}
|
|
1249
|
-
code += 'return
|
|
1162
|
+
code += 'return __obj;\n';
|
|
1250
1163
|
code += '};\n';
|
|
1251
1164
|
|
|
1252
1165
|
code += 'return __newComposite();\n';
|
|
@@ -1280,24 +1193,35 @@ export class NewComposite extends LogicItem {
|
|
|
1280
1193
|
code += right.members.length ? '\n' : '';
|
|
1281
1194
|
});
|
|
1282
1195
|
// 方便ts报错检查
|
|
1283
|
-
code += 'function __newComposite()
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
this.properties.forEach((property) => {
|
|
1196
|
+
code += 'function __newComposite() {\n';
|
|
1197
|
+
this.properties.forEach((property, index) => {
|
|
1198
|
+
const temp = `temp${index}`;
|
|
1287
1199
|
const name = property.name;
|
|
1288
1200
|
const rightItem = nameMap.get(name);
|
|
1289
|
-
|
|
1290
|
-
|
|
1201
|
+
const ts = rightMap.get(rightItem);
|
|
1202
|
+
if (ts !== undefined) {
|
|
1203
|
+
if (['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
|
|
1204
|
+
code += `const ${temp}: any = null; `;
|
|
1205
|
+
} else {
|
|
1206
|
+
code += `const ${temp}${ts === 'null' ? ':void' : ''} = ${ts}; `;
|
|
1207
|
+
}
|
|
1208
|
+
code += 'const ';
|
|
1291
1209
|
code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1292
|
-
code += `: nasl.core.Incompatible<typeof
|
|
1293
|
-
code += '
|
|
1210
|
+
code += `: nasl.core.Incompatible<typeof ${temp}, void> = ${temp}`;
|
|
1211
|
+
code += ';\n';
|
|
1294
1212
|
} else {
|
|
1295
|
-
code += '
|
|
1213
|
+
code += 'const ';
|
|
1296
1214
|
code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1297
|
-
code += '
|
|
1215
|
+
code += ';\n';
|
|
1298
1216
|
}
|
|
1299
1217
|
});
|
|
1300
|
-
code += 'return
|
|
1218
|
+
code += 'return {\n';
|
|
1219
|
+
code += `__name: "AStructure_${genHash(JSON.stringify(this))}" as const,\n`;
|
|
1220
|
+
this.properties.forEach((property) => {
|
|
1221
|
+
code += `${property.name},\n`;
|
|
1222
|
+
});
|
|
1223
|
+
code += '}\n';
|
|
1224
|
+
|
|
1301
1225
|
code += '};\n';
|
|
1302
1226
|
|
|
1303
1227
|
code += 'return __newComposite();\n';
|
|
@@ -1306,9 +1230,58 @@ export class NewComposite extends LogicItem {
|
|
|
1306
1230
|
return code;
|
|
1307
1231
|
}
|
|
1308
1232
|
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1233
|
+
getInitCode(state?: TranslatorState): string {
|
|
1234
|
+
let code = '';
|
|
1235
|
+
const nameMap = new Map();
|
|
1236
|
+
const rightMap = new Map();
|
|
1237
|
+
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
1238
|
+
const leftSecondIndex = leftIndex[1];
|
|
1239
|
+
const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
|
|
1240
|
+
const leftItem = this.properties[leftSecondIndex];
|
|
1241
|
+
const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
|
|
1242
|
+
nameMap.set(leftItem.name, rightItem);
|
|
1243
|
+
rightMap.set(rightItem, null);
|
|
1244
|
+
});
|
|
1245
|
+
code += '(() => { ';
|
|
1246
|
+
// 提供sourcemap,获取类型标注和上下文可选变量
|
|
1247
|
+
this.rights.forEach((right) => {
|
|
1248
|
+
let ts = right.expression.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1249
|
+
if (rightMap.has(right.expression))
|
|
1250
|
+
rightMap.set(right.expression, ts);
|
|
1251
|
+
right.members.forEach((member) => {
|
|
1252
|
+
ts = member.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1253
|
+
if (rightMap.has(member))
|
|
1254
|
+
rightMap.set(member, ts);
|
|
1255
|
+
});
|
|
1256
|
+
});
|
|
1257
|
+
// 方便ts报错检查
|
|
1258
|
+
code += 'function __newComposite() { ';
|
|
1259
|
+
this.properties.forEach((property) => {
|
|
1260
|
+
const name = property.name;
|
|
1261
|
+
const rightItem = nameMap.get(name);
|
|
1262
|
+
const ts = rightMap.get(rightItem);
|
|
1263
|
+
if (ts !== undefined) {
|
|
1264
|
+
code += `const ${name} = ${['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts}; `;
|
|
1265
|
+
} else {
|
|
1266
|
+
code += `const ${name}; `;
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
code += '\nreturn {\n';
|
|
1270
|
+
code += `__name: "AStructure_${genHash(JSON.stringify(this))}" as const,\n`;
|
|
1271
|
+
this.properties.forEach((property) => {
|
|
1272
|
+
code += `${property.name},\n`;
|
|
1273
|
+
});
|
|
1274
|
+
code += '}\n';
|
|
1275
|
+
|
|
1276
|
+
code += '};\n';
|
|
1277
|
+
|
|
1278
|
+
code += 'return __newComposite();\n';
|
|
1279
|
+
code += '})()';
|
|
1280
|
+
return code;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
__addIdentifier() {
|
|
1284
|
+
this.app.emit('collect:start', {
|
|
1312
1285
|
actionMsg: '添加匿名数据结构属性',
|
|
1313
1286
|
});
|
|
1314
1287
|
const node = this.addIdentifier({ name: this.getIdentifierUniqueName('property1') });
|
|
@@ -1317,13 +1290,13 @@ export class NewComposite extends LogicItem {
|
|
|
1317
1290
|
typeAnnotation: null,
|
|
1318
1291
|
});
|
|
1319
1292
|
this.typeAnnotation.addStructureProperty(struct);
|
|
1320
|
-
app.emit('collect:end');
|
|
1293
|
+
this.app.emit('collect:end');
|
|
1321
1294
|
}
|
|
1322
1295
|
|
|
1323
1296
|
__deleteIdentifier(property: Identifier) {
|
|
1324
1297
|
const index = this.properties.findIndex((p) => p === property);
|
|
1325
1298
|
const newLines: AssignmentLine[] = [];
|
|
1326
|
-
const newProperties =
|
|
1299
|
+
const newProperties = this.typeAnnotation.properties.filter((item) => item.name !== property.name);
|
|
1327
1300
|
this.assignmentLines.forEach((line) => {
|
|
1328
1301
|
const { leftIndex } = line;
|
|
1329
1302
|
if (leftIndex[1] < index) {
|
|
@@ -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) => {
|