@lcap/nasl 1.0.0-alpha.2 → 1.0.0-alpha.3
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/README.md +3 -3
- package/docs/assets/search.js +1 -1
- package/docs/classes/Entity.html +2832 -204
- package/docs/classes/View.html +4567 -365
- package/out/common/BaseNode.js +23 -16
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +22 -0
- package/out/concepts/App__.js +77 -15
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.d.ts +2 -1
- package/out/concepts/Argument__.js +2 -2
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignment__.d.ts +2 -1
- package/out/concepts/Assignment__.js +3 -8
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/Attribute__.js.map +1 -1
- package/out/concepts/BinaryExpression__.d.ts +2 -1
- package/out/concepts/BinaryExpression__.js +5 -5
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +2 -1
- package/out/concepts/BindAttribute__.js +9 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +2 -1
- package/out/concepts/BindDirective__.js +2 -2
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +2 -1
- package/out/concepts/BindEvent__.js +4 -3
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +2 -1
- package/out/concepts/BooleanLiteral__.js +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.d.ts +57 -1
- package/out/concepts/CallFunction__.js +119 -11
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +2 -1
- package/out/concepts/CallInterface__.js +2 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +57 -1
- package/out/concepts/CallLogic__.js +117 -10
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +1 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +120 -0
- package/out/concepts/ConfigGroup__.js +214 -0
- package/out/concepts/ConfigGroup__.js.map +1 -0
- package/out/concepts/ConfigPropertyValue__.d.ts +43 -0
- package/out/concepts/ConfigPropertyValue__.js +103 -0
- package/out/concepts/ConfigPropertyValue__.js.map +1 -0
- package/out/concepts/ConfigProperty__.d.ts +128 -0
- package/out/concepts/ConfigProperty__.js +236 -0
- package/out/concepts/ConfigProperty__.js.map +1 -0
- package/out/concepts/Configuration__.d.ts +120 -0
- package/out/concepts/Configuration__.js +210 -0
- package/out/concepts/Configuration__.js.map +1 -0
- package/out/concepts/Constant__.d.ts +2 -1
- package/out/concepts/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataElement__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +2 -1
- package/out/concepts/Destination__.js +4 -3
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +8 -0
- package/out/concepts/EntityIndex__.js +18 -0
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +5 -5
- package/out/concepts/EntityProperty__.js +10 -9
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +30 -26
- package/out/concepts/Entity__.js +44 -36
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +8 -8
- package/out/concepts/Enum__.js +10 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +35 -33
- package/out/concepts/ForEachStatement__.js +103 -36
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.js +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +2 -1
- package/out/concepts/Identifier__.js +15 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +1 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +5 -1
- package/out/concepts/Interface__.js +19 -5
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +2 -1
- package/out/concepts/LogicItem__.js +2 -2
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +9 -7
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +2 -5
- package/out/concepts/MemberExpression__.js +12 -18
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +121 -126
- package/out/concepts/Module__.js +10 -17
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js +12 -12
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NullLiteral__.d.ts +2 -1
- package/out/concepts/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.d.ts +2 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -1
- package/out/concepts/Param__.js +2 -2
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Point__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +2 -2
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +82 -81
- package/out/concepts/ProcessElement__.js +19 -6
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/Process__.d.ts +1 -0
- package/out/concepts/Process__.js +10 -4
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +1 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Rect__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -1
- package/out/concepts/Return__.js +2 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.d.ts +5 -0
- package/out/concepts/Role__.js +19 -2
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/Slot__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +2 -0
- package/out/concepts/SqlQueryComponent__.js +16 -0
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +2 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +1 -1
- package/out/concepts/StructureProperty__.js +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +1 -1
- package/out/concepts/Structure__.js +4 -4
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +3 -0
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.d.ts +2 -1
- package/out/concepts/UnaryExpression__.js +3 -3
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.d.ts +2 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/UseComponent__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +2 -1
- package/out/concepts/ValidationRule__.js +2 -2
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +6 -5
- package/out/concepts/Variable__.js +3 -3
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +5 -5
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +5 -4
- package/out/concepts/ViewElement__.js +109 -65
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +97 -90
- package/out/concepts/View__.js +153 -118
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +2 -2
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +3 -137
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +21 -5
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.validation.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.validation.js +527 -0
- package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -0
- package/out/concepts/index__.d.ts +4 -0
- package/out/concepts/index__.js +4 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/data/Module.d.ts +34 -0
- package/out/data/Module.js +53 -0
- package/out/data/Module.js.map +1 -0
- package/out/generator/compileComponent.d.ts +1 -1
- package/out/generator/genBundleFiles.d.ts +0 -1
- package/out/generator/genBundleFiles.js +1 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +35 -0
- package/out/generator/genMetaData.js +78 -0
- package/out/generator/genMetaData.js.map +1 -0
- package/out/generator/index.d.ts +1 -0
- package/out/generator/index.js +1 -0
- package/out/generator/index.js.map +1 -1
- package/out/index.d.ts +2 -2
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/server/createUiTs.d.ts +7 -0
- package/out/server/createUiTs.js +157 -0
- package/out/server/createUiTs.js.map +1 -0
- package/out/server/entity2LogicNamespace.d.ts +9 -1
- package/out/server/entity2LogicNamespace.js +11 -1
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/getExtensionModules.d.ts +3 -0
- package/out/server/getExtensionModules.js +18 -0
- package/out/server/getExtensionModules.js.map +1 -0
- package/out/server/getLogics.js +18 -15
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +3 -2
- package/out/server/getMemberIdentifier.js +47 -15
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +4 -1
- package/out/server/getProcesses.js +16 -7
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/getValidates.js +1 -1
- package/out/server/getValidates.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 +23 -5
- package/out/server/naslServer.js +199 -25
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.d.ts +15 -1
- package/out/server/process2LogicNamespace.js +30 -3
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +28 -0
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.d.ts +5 -0
- package/out/service/storage/init.js +60 -52
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCallComponentLogic.js +2 -2
- package/out/templator/genCallComponentLogic.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -8
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +3 -3
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +4 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +3 -3
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +2 -2
- 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/genUpdateBlock.js +8 -12
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +20 -20
- package/out/templator/utils.js +22 -22
- package/out/templator/utils.js.map +1 -1
- package/package.json +2 -1
- package/src/automate/engine/index.js +37 -3
- package/src/automate/engine/utils.js +68 -64
- package/src/common/BaseNode.ts +24 -17
- package/src/concepts/App__.ts +93 -17
- package/src/concepts/Argument__.ts +4 -2
- package/src/concepts/Assignment__.ts +5 -7
- package/src/concepts/Attribute__.ts +1 -0
- package/src/concepts/BinaryExpression__.ts +7 -5
- package/src/concepts/BindAttribute__.ts +9 -4
- package/src/concepts/BindDirective__.ts +4 -2
- package/src/concepts/BindEvent__.ts +6 -4
- package/src/concepts/BooleanLiteral__.ts +3 -1
- package/src/concepts/CallFunction__.ts +195 -11
- package/src/concepts/CallInterface__.ts +4 -2
- package/src/concepts/CallLogic__.ts +211 -12
- package/src/concepts/CallQueryComponent__.ts +2 -1
- package/src/concepts/Comment__.ts +1 -0
- package/src/concepts/CompletionProperty__.ts +1 -0
- package/src/concepts/ConfigGroup__.ts +290 -0
- package/src/concepts/ConfigPropertyValue__.ts +112 -0
- package/src/concepts/ConfigProperty__.ts +306 -0
- package/src/concepts/Configuration__.ts +286 -0
- package/src/concepts/Constant__.ts +3 -1
- package/src/concepts/DataElement__.ts +1 -0
- package/src/concepts/Destination__.ts +7 -5
- package/src/concepts/End__.ts +1 -0
- package/src/concepts/EntityIndex__.ts +19 -0
- package/src/concepts/EntityProperty__.ts +9 -8
- package/src/concepts/Entity__.ts +66 -59
- package/src/concepts/EnumItem__.ts +1 -0
- package/src/concepts/Enum__.ts +32 -12
- package/src/concepts/Event__.ts +2 -1
- package/src/concepts/ForEachStatement__.ts +115 -69
- package/src/concepts/Function__.ts +2 -1
- package/src/concepts/Identifier__.ts +18 -1
- package/src/concepts/IfStatement__.ts +1 -0
- package/src/concepts/InterfaceParam__.ts +2 -1
- package/src/concepts/Interface__.ts +21 -5
- package/src/concepts/JSBlock__.ts +1 -0
- package/src/concepts/LogicItem__.ts +9 -40
- package/src/concepts/Logic__.ts +48 -9
- package/src/concepts/MemberExpression__.ts +14 -17
- package/src/concepts/Module__.ts +158 -139
- package/src/concepts/Namespace__.ts +13 -12
- package/src/concepts/NullLiteral__.ts +3 -1
- package/src/concepts/NumericLiteral__.ts +3 -1
- package/src/concepts/Param__.ts +3 -2
- package/src/concepts/Point__.ts +1 -0
- package/src/concepts/ProcessComponent__.ts +3 -2
- package/src/concepts/ProcessElement__.ts +102 -107
- package/src/concepts/ProcessOutcome__.ts +1 -0
- package/src/concepts/Process__.ts +12 -4
- package/src/concepts/QueryAggregateExpression__.ts +1 -0
- package/src/concepts/QueryFieldExpression__.ts +2 -1
- package/src/concepts/QueryFromExpression__.ts +1 -0
- package/src/concepts/QueryGroupByExpression__.ts +1 -0
- package/src/concepts/QueryJoinExpression__.ts +2 -1
- package/src/concepts/QueryLimitExpression__.ts +1 -0
- package/src/concepts/QueryOrderByExpression__.ts +1 -0
- package/src/concepts/QuerySelectExpression__.ts +2 -1
- package/src/concepts/Rect__.ts +1 -0
- package/src/concepts/Return__.ts +3 -2
- package/src/concepts/Role__.ts +19 -2
- package/src/concepts/Slot__.ts +1 -0
- package/src/concepts/SqlQueryComponent__.ts +11 -1
- package/src/concepts/Start__.ts +1 -0
- package/src/concepts/StringLiteral__.ts +3 -1
- package/src/concepts/StructureProperty__.ts +2 -1
- package/src/concepts/Structure__.ts +5 -4
- package/src/concepts/SwitchCase__.ts +1 -0
- package/src/concepts/SwitchStatement__.ts +1 -0
- package/src/concepts/Theme__.ts +1 -0
- package/src/concepts/Transactional__.ts +1 -0
- package/src/concepts/TypeAnnotation__.ts +4 -0
- package/src/concepts/TypeParam__.ts +1 -0
- package/src/concepts/UnaryExpression__.ts +6 -3
- package/src/concepts/Unparsed__.ts +3 -1
- package/src/concepts/UseComponent__.ts +1 -0
- package/src/concepts/ValidationRule__.ts +5 -2
- package/src/concepts/Variable__.ts +12 -6
- package/src/concepts/ViewComponent__.ts +6 -5
- package/src/concepts/ViewElement__.ts +109 -80
- package/src/concepts/View__.ts +245 -206
- package/src/concepts/WhileStatement__.ts +1 -0
- package/src/concepts/basics/stdlib/index.ts +2 -2
- package/src/concepts/basics/stdlib/nasl.ui.ts +3 -137
- package/src/concepts/basics/stdlib/nasl.util.ts +21 -5
- package/src/concepts/basics/stdlib/{nasl.validate.ts → nasl.validation.ts} +28 -28
- package/src/concepts/index__.ts +4 -0
- package/src/generator/compileComponent.ts +1 -1
- package/src/generator/genBundleFiles.ts +1 -2
- package/src/generator/genMetaData.ts +111 -0
- package/src/generator/index.ts +1 -0
- package/src/index.ts +2 -2
- package/src/server/createUiTs.ts +153 -0
- package/src/server/entity2LogicNamespace.ts +17 -1
- package/src/server/getExtensionModules.ts +13 -0
- package/src/server/getLogics.ts +19 -18
- package/src/server/getMemberIdentifier.ts +60 -19
- package/src/server/getProcesses.ts +15 -8
- package/src/server/getValidates.ts +1 -1
- package/src/server/index.ts +2 -1
- package/src/server/naslServer.ts +204 -24
- package/src/server/process2LogicNamespace.ts +44 -3
- package/src/server/translator.ts +121 -97
- package/src/service/config/api.js +32 -0
- package/src/service/config/index.js +6 -0
- package/src/service/creator/index.js +2 -2
- package/src/service/logic/checktypeSocket.js +49 -0
- package/src/service/modules/api.js +20 -0
- package/src/service/modules/index.js +6 -0
- package/src/service/storage/init.ts +62 -54
- package/src/templator/genCallComponentLogic.ts +2 -2
- package/src/templator/genCreateBlock.ts +19 -25
- package/src/templator/genCurdEditMultipleKeyBlock.ts +3 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +4 -4
- package/src/templator/genEditTableBlock.ts +3 -3
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genListViewBlock.ts +2 -2
- package/src/templator/genSelectBlock.ts +1 -1
- package/src/templator/genUpdateBlock.ts +19 -25
- package/src/templator/utils.ts +25 -153
|
@@ -44,7 +44,7 @@ export interface ElementToVueOptions {
|
|
|
44
44
|
aslIdAttr?: string | boolean;
|
|
45
45
|
nodePathAttr?: string | boolean;
|
|
46
46
|
getExtraParts?: (element?: ViewElement) => Array<string>;
|
|
47
|
-
attrFormat?: (attr: BindAttribute | BindEvent | BindDirective, element?: ViewElement, defaultResult?: string) => string;
|
|
47
|
+
attrFormat?: (attr: BindAttribute | BindEvent | BindDirective, element?: ViewElement, defaultResult?: string) => string | false;
|
|
48
48
|
finalCode?: boolean;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -72,7 +72,7 @@ function transAstNodeToNaslNode(astNode: any): any {
|
|
|
72
72
|
concept: 'MemberExpression',
|
|
73
73
|
name: '',
|
|
74
74
|
kind: 'Expression',
|
|
75
|
-
|
|
75
|
+
object: transAstNodeToNaslNode(astNode.object),
|
|
76
76
|
property: transAstNodeToNaslNode(astNode.property),
|
|
77
77
|
};
|
|
78
78
|
} else if (astNode.type === 'Identifier') {
|
|
@@ -106,6 +106,7 @@ import { EventPayload, Params } from '../common/EventEmitter';
|
|
|
106
106
|
import { concept, excludedInJSON, property } from '../decorators';
|
|
107
107
|
|
|
108
108
|
import * as utils from '../utils';
|
|
109
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
109
110
|
import BaseNode from '../common/BaseNode';
|
|
110
111
|
import classMap from '../common/classMap';
|
|
111
112
|
import BindAttribute from './BindAttribute__';
|
|
@@ -226,8 +227,6 @@ export class ViewElement extends BaseNode {
|
|
|
226
227
|
super.subConstructor(source);
|
|
227
228
|
}
|
|
228
229
|
|
|
229
|
-
|
|
230
|
-
|
|
231
230
|
/**
|
|
232
231
|
* 从父级删除该节点
|
|
233
232
|
* @internal
|
|
@@ -264,9 +263,9 @@ export class ViewElement extends BaseNode {
|
|
|
264
263
|
});
|
|
265
264
|
}
|
|
266
265
|
|
|
267
|
-
|
|
266
|
+
getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
|
|
268
267
|
const excludedSet = new Set(excludedList);
|
|
269
|
-
return this.bindAttrs.filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
268
|
+
return (this.bindAttrs || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
270
269
|
}
|
|
271
270
|
getBindAttributeUniqueName(name = 'bindAttribute1') {
|
|
272
271
|
return utils.unique(name, this.getBindAttributeExistingNames());
|
|
@@ -405,10 +404,9 @@ export class ViewElement extends BaseNode {
|
|
|
405
404
|
return node;
|
|
406
405
|
}
|
|
407
406
|
|
|
408
|
-
|
|
409
407
|
getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
|
|
410
408
|
const excludedSet = new Set(excludedList);
|
|
411
|
-
return this.bindEvents.filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
409
|
+
return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
412
410
|
}
|
|
413
411
|
getBindEventUniqueName(name = 'bindEvent1') {
|
|
414
412
|
return utils.unique(name, this.getBindEventExistingNames());
|
|
@@ -547,10 +545,9 @@ export class ViewElement extends BaseNode {
|
|
|
547
545
|
return node;
|
|
548
546
|
}
|
|
549
547
|
|
|
550
|
-
|
|
551
548
|
getBindDirectiveExistingNames(excludedList: Array<BindDirective> = []) {
|
|
552
549
|
const excludedSet = new Set(excludedList);
|
|
553
|
-
return this.bindDirectives.filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
550
|
+
return (this.bindDirectives || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
554
551
|
}
|
|
555
552
|
getBindDirectiveUniqueName(name = 'bindDirective1') {
|
|
556
553
|
return utils.unique(name, this.getBindDirectiveExistingNames());
|
|
@@ -689,11 +686,6 @@ export class ViewElement extends BaseNode {
|
|
|
689
686
|
return node;
|
|
690
687
|
}
|
|
691
688
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
689
|
/**
|
|
698
690
|
* 插入页面元素
|
|
699
691
|
* @internal
|
|
@@ -827,9 +819,6 @@ export class ViewElement extends BaseNode {
|
|
|
827
819
|
return node;
|
|
828
820
|
}
|
|
829
821
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
822
|
/**
|
|
834
823
|
* 删除元素绑定属性
|
|
835
824
|
* @param name 元素绑定属性名称
|
|
@@ -878,8 +867,6 @@ export class ViewElement extends BaseNode {
|
|
|
878
867
|
return params;
|
|
879
868
|
}
|
|
880
869
|
|
|
881
|
-
|
|
882
|
-
|
|
883
870
|
/**
|
|
884
871
|
* 删除元素绑定事件
|
|
885
872
|
* @param name 元素绑定事件名称
|
|
@@ -928,8 +915,6 @@ export class ViewElement extends BaseNode {
|
|
|
928
915
|
return params;
|
|
929
916
|
}
|
|
930
917
|
|
|
931
|
-
|
|
932
|
-
|
|
933
918
|
/**
|
|
934
919
|
* 删除元素指令
|
|
935
920
|
* @param name 元素指令名称
|
|
@@ -978,8 +963,6 @@ export class ViewElement extends BaseNode {
|
|
|
978
963
|
return params;
|
|
979
964
|
}
|
|
980
965
|
|
|
981
|
-
|
|
982
|
-
|
|
983
966
|
/**
|
|
984
967
|
* 删除页面元素
|
|
985
968
|
* @param name 页面元素名称
|
|
@@ -1093,7 +1076,11 @@ export class ViewElement extends BaseNode {
|
|
|
1093
1076
|
toHump(name: string): string {
|
|
1094
1077
|
return name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase());
|
|
1095
1078
|
}
|
|
1096
|
-
|
|
1079
|
+
|
|
1080
|
+
get haveScope() {
|
|
1081
|
+
const dataSourceList = ['uGallery', 'uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect'];
|
|
1082
|
+
return dataSourceList.includes(this.toHump(this.tag));
|
|
1083
|
+
}
|
|
1097
1084
|
toEmbeddedTSDefinition(state?: TranslatorState): string {
|
|
1098
1085
|
let code = '';
|
|
1099
1086
|
// formItem的单独处理
|
|
@@ -1110,6 +1097,20 @@ export class ViewElement extends BaseNode {
|
|
|
1110
1097
|
}
|
|
1111
1098
|
}
|
|
1112
1099
|
code += '> null,\n';
|
|
1100
|
+
}
|
|
1101
|
+
if (this.haveScope) {
|
|
1102
|
+
let genericType = 'any';
|
|
1103
|
+
const bindAttrs = this.bindAttrs;
|
|
1104
|
+
if (bindAttrs && bindAttrs.length) {
|
|
1105
|
+
const attr = bindAttrs.find((item) => item.name === 'data-source');
|
|
1106
|
+
if (attr && attr.expression) {
|
|
1107
|
+
let expressionTs = attr.expression.toEmbeddedTS(shiftState(state, code));
|
|
1108
|
+
expressionTs = expressionTs.replaceAll(' ', '');
|
|
1109
|
+
// 如果是逻辑就推导出逻辑类型
|
|
1110
|
+
genericType = `nasl.ui.GetItemTypeFromDataSource<typeof ${expressionTs}>`;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
code += indent(state.tabSize) + `${this.name}: <nasl.ui.${this.toHump(this.tag)}<${genericType}>> null,\n`;
|
|
1113
1114
|
} else {
|
|
1114
1115
|
code = indent(state.tabSize) + `${this.name}: <nasl.ui.${this.toHump(this.tag)}<any>> null,\n`;
|
|
1115
1116
|
}
|
|
@@ -1121,8 +1122,17 @@ export class ViewElement extends BaseNode {
|
|
|
1121
1122
|
return code;
|
|
1122
1123
|
}
|
|
1123
1124
|
@withSourceMap()
|
|
1124
|
-
toEmbeddedTS(state?: TranslatorState): string {
|
|
1125
|
-
|
|
1125
|
+
toEmbeddedTS(state?: TranslatorState, parentLevel?: number): string {
|
|
1126
|
+
function chineseTsName(name: string) {
|
|
1127
|
+
let tsName = name;
|
|
1128
|
+
if (/^\d/.test(tsName)) {
|
|
1129
|
+
tsName = '$' + tsName;
|
|
1130
|
+
}
|
|
1131
|
+
// 匹配所有特殊字符都转为_
|
|
1132
|
+
tsName = tsName.replace(/\W/g, '_');
|
|
1133
|
+
return tsName;
|
|
1134
|
+
}
|
|
1135
|
+
let code = `__elements.${this.name} = new nasl.ui.${this.toHump(this.tag)}({\n`;
|
|
1126
1136
|
// 是否开启权限
|
|
1127
1137
|
let hasAuth = false;
|
|
1128
1138
|
if (Array.isArray(this.bindDirectives)) {
|
|
@@ -1134,14 +1144,12 @@ export class ViewElement extends BaseNode {
|
|
|
1134
1144
|
code += 'roles = [\n';
|
|
1135
1145
|
this.bindRoles.forEach((role) => {
|
|
1136
1146
|
code += indent(state.tabSize + 3);
|
|
1137
|
-
code += `${role},`;
|
|
1147
|
+
code += `${this.app.getNamespace()}.roles.${chineseTsName(role)}.${chineseTsName(role)},`;
|
|
1138
1148
|
code += '\n';
|
|
1139
1149
|
});
|
|
1140
1150
|
code += indent(state.tabSize + 2);
|
|
1141
|
-
code += ']
|
|
1151
|
+
code += '],\n';
|
|
1142
1152
|
}
|
|
1143
|
-
*/
|
|
1144
|
-
let code = `__elements.${this.name} = new nasl.ui.${this.toHump(this.tag)}({\n`;
|
|
1145
1153
|
// 绑定属性
|
|
1146
1154
|
if (Array.isArray(this.bindAttrs)) {
|
|
1147
1155
|
this.bindAttrs.forEach((attr) => {
|
|
@@ -1163,16 +1171,35 @@ export class ViewElement extends BaseNode {
|
|
|
1163
1171
|
}));
|
|
1164
1172
|
code += '\n';
|
|
1165
1173
|
});
|
|
1166
|
-
code += indent(state.tabSize + 1);
|
|
1167
1174
|
}
|
|
1168
1175
|
|
|
1169
1176
|
// 子元素
|
|
1170
1177
|
if (Array.isArray(this.children)) {
|
|
1171
|
-
code +=
|
|
1178
|
+
code += indent(state.tabSize + 1);
|
|
1179
|
+
|
|
1180
|
+
let levelIndex = parentLevel || 0;
|
|
1181
|
+
if (this.haveScope) {
|
|
1182
|
+
code += `slotDefault: (scope${levelIndex || ''})=> [\n`;
|
|
1183
|
+
levelIndex++;
|
|
1184
|
+
} else {
|
|
1185
|
+
code += `slotDefault: ()=> [\n`;
|
|
1186
|
+
}
|
|
1187
|
+
if (Array.isArray(this.bindAttrs)) {
|
|
1188
|
+
code += indent(state.tabSize + 2) + `() => [\n`;
|
|
1189
|
+
this.bindAttrs.forEach((attr) => {
|
|
1190
|
+
if (attr.expression) {
|
|
1191
|
+
code
|
|
1192
|
+
+= attr.expression.toEmbeddedTS(shiftState(state, code, {
|
|
1193
|
+
tabSize: state.tabSize + 3,
|
|
1194
|
+
})) + ',\n';
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
code += indent(state.tabSize + 2) + '],\n';
|
|
1198
|
+
}
|
|
1172
1199
|
this.children.forEach((element) => {
|
|
1173
1200
|
code += element.toEmbeddedTS(shiftState(state, code, {
|
|
1174
1201
|
tabSize: state.tabSize + 2,
|
|
1175
|
-
}));
|
|
1202
|
+
}), levelIndex);
|
|
1176
1203
|
code += '\n';
|
|
1177
1204
|
});
|
|
1178
1205
|
code += indent(state.tabSize + 1);
|
|
@@ -1184,8 +1211,8 @@ export class ViewElement extends BaseNode {
|
|
|
1184
1211
|
return code;
|
|
1185
1212
|
}
|
|
1186
1213
|
|
|
1187
|
-
_duplicate() {
|
|
1188
|
-
const code = this.toVue();
|
|
1214
|
+
_duplicate(options?: ElementToVueOptions) {
|
|
1215
|
+
const code = this.toVue(options);
|
|
1189
1216
|
const element = ViewElement.fromHTML(code, {
|
|
1190
1217
|
view: this.view,
|
|
1191
1218
|
});
|
|
@@ -1227,24 +1254,26 @@ export class ViewElement extends BaseNode {
|
|
|
1227
1254
|
private static _parseValidationRule(value: string) {
|
|
1228
1255
|
let calleeName = value;
|
|
1229
1256
|
let args: any[] = [];
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1257
|
+
try {
|
|
1258
|
+
const ast = babelParser.parseExpression(value) as any;
|
|
1259
|
+
if (ast.type === 'CallExpression') {
|
|
1260
|
+
calleeName = ast.callee.property.name || ast.callee.property.value;
|
|
1261
|
+
args = ast.arguments.map((argument: any) => ({
|
|
1262
|
+
concept: 'Argument',
|
|
1263
|
+
name: '',
|
|
1264
|
+
kind: 'Statement',
|
|
1265
|
+
keyword: '',
|
|
1266
|
+
expression: transAstNodeToNaslNode(Object.assign({}, argument)),
|
|
1267
|
+
}));
|
|
1268
|
+
}
|
|
1269
|
+
} catch (error) {}
|
|
1241
1270
|
return {
|
|
1242
1271
|
concept: 'ValidationRule',
|
|
1243
1272
|
name: '',
|
|
1244
1273
|
label: '验证规则',
|
|
1245
1274
|
folded: true,
|
|
1246
1275
|
kind: 'Expression',
|
|
1247
|
-
calleeNamespace: 'nasl.
|
|
1276
|
+
calleeNamespace: 'nasl.validation',
|
|
1248
1277
|
arguments: args,
|
|
1249
1278
|
calleeName,
|
|
1250
1279
|
};
|
|
@@ -1368,7 +1397,7 @@ export class ViewElement extends BaseNode {
|
|
|
1368
1397
|
});
|
|
1369
1398
|
}
|
|
1370
1399
|
const viewNamespace = view?.getNamespace();
|
|
1371
|
-
const viewName =
|
|
1400
|
+
const viewName = `${view?.name}`;
|
|
1372
1401
|
element.bindEvents.push(BindEvent.from({
|
|
1373
1402
|
name,
|
|
1374
1403
|
calleeNamespace: `${viewNamespace}.${viewName}.logics`,
|
|
@@ -1377,32 +1406,33 @@ export class ViewElement extends BaseNode {
|
|
|
1377
1406
|
}, element));
|
|
1378
1407
|
});
|
|
1379
1408
|
|
|
1380
|
-
astNode.directives
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1409
|
+
astNode.directives
|
|
1410
|
+
&& astNode.directives.forEach((directive) => {
|
|
1411
|
+
if (directive.name === 'model') {
|
|
1412
|
+
const valueAttr = astNode.attrs && astNode.attrs.find((attr) => attr.name === 'value');
|
|
1413
|
+
if (!valueAttr) {
|
|
1414
|
+
const expression = <any> this._parseExpression(directive.value);
|
|
1415
|
+
element.bindAttrs.push(BindAttribute.from({
|
|
1416
|
+
type: 'dynamic',
|
|
1417
|
+
name: 'value',
|
|
1418
|
+
value: expression ? '' : directive.value,
|
|
1419
|
+
expression,
|
|
1420
|
+
sync: true,
|
|
1421
|
+
}, element));
|
|
1422
|
+
}
|
|
1423
|
+
} else {
|
|
1384
1424
|
const expression = <any> this._parseExpression(directive.value);
|
|
1385
|
-
element.
|
|
1386
|
-
type: 'dynamic',
|
|
1387
|
-
name:
|
|
1425
|
+
element.bindDirectives.push(BindDirective.from({
|
|
1426
|
+
type: expression ? 'string' : 'dynamic',
|
|
1427
|
+
name: directive.name,
|
|
1428
|
+
rawName: directive.rawName,
|
|
1388
1429
|
value: expression ? '' : directive.value,
|
|
1389
1430
|
expression,
|
|
1390
|
-
|
|
1431
|
+
arg: directive.arg,
|
|
1432
|
+
modifiers: directive.modifiers,
|
|
1391
1433
|
}, element));
|
|
1392
1434
|
}
|
|
1393
|
-
}
|
|
1394
|
-
const expression = <any> this._parseExpression(directive.value);
|
|
1395
|
-
element.bindDirectives.push(BindDirective.from({
|
|
1396
|
-
type: expression ? 'string' : 'dynamic',
|
|
1397
|
-
name: directive.name,
|
|
1398
|
-
rawName: directive.rawName,
|
|
1399
|
-
value: expression ? '' : directive.value,
|
|
1400
|
-
expression,
|
|
1401
|
-
arg: directive.arg,
|
|
1402
|
-
modifiers: directive.modifiers,
|
|
1403
|
-
}, element));
|
|
1404
|
-
}
|
|
1405
|
-
});
|
|
1435
|
+
});
|
|
1406
1436
|
|
|
1407
1437
|
if (astNode.if) {
|
|
1408
1438
|
element.bindDirectives.push(BindDirective.from({
|
|
@@ -1493,12 +1523,13 @@ export class ViewElement extends BaseNode {
|
|
|
1493
1523
|
* 转换成设计器中使用的 Vue 文件
|
|
1494
1524
|
* @param options
|
|
1495
1525
|
*/
|
|
1496
|
-
toDesignerVue(
|
|
1497
|
-
|
|
1526
|
+
toDesignerVue() {
|
|
1527
|
+
return this.toVue({
|
|
1528
|
+
finalCode: false,
|
|
1498
1529
|
nodePathAttr: true,
|
|
1499
|
-
attrFormat: (attr: BindAttribute,
|
|
1530
|
+
attrFormat: (attr: BindAttribute | BindEvent | BindDirective, element?: ViewElement, defaultResult?: string) => {
|
|
1500
1531
|
if (attr.concept === 'BindAttribute') {
|
|
1501
|
-
const api = config.allNodesAPI[
|
|
1532
|
+
const api = config.allNodesAPI[element.tag];
|
|
1502
1533
|
const apiOfAttr = api && api.attrs && api.attrs.find((_attr) => _attr.name === attr.name);
|
|
1503
1534
|
if (apiOfAttr && apiOfAttr['designer-value'] !== undefined) {
|
|
1504
1535
|
let designerValue = apiOfAttr['designer-value'];
|
|
@@ -1512,7 +1543,7 @@ export class ViewElement extends BaseNode {
|
|
|
1512
1543
|
return `${attr.name}="${designerValue}"`;
|
|
1513
1544
|
}
|
|
1514
1545
|
}
|
|
1515
|
-
if ((attr as BindAttribute).type === 'dynamic' && !(
|
|
1546
|
+
if ((attr as BindAttribute).type === 'dynamic' && !(element.tag === 'u-cascade-select' && attr.name === 'categories'))
|
|
1516
1547
|
return defaultResult.replace(/:?(\w+)(?:.*?)="(.*)"/, (m, name, value) => {
|
|
1517
1548
|
try {
|
|
1518
1549
|
const tempValue = json5.parse(value);
|
|
@@ -1547,8 +1578,7 @@ export class ViewElement extends BaseNode {
|
|
|
1547
1578
|
|
|
1548
1579
|
return parts;
|
|
1549
1580
|
},
|
|
1550
|
-
}
|
|
1551
|
-
return this.toVue(options);
|
|
1581
|
+
});
|
|
1552
1582
|
}
|
|
1553
1583
|
|
|
1554
1584
|
/**
|
|
@@ -1593,9 +1623,8 @@ export class ViewElement extends BaseNode {
|
|
|
1593
1623
|
this.staticClass && parts.push(`class="${this.staticClass}"`);
|
|
1594
1624
|
this.staticStyle && parts.push(`style="${this.staticStyle}"`);
|
|
1595
1625
|
|
|
1596
|
-
const { finalCode } = options;
|
|
1597
1626
|
[].concat(this.bindAttrs, this.bindDirectives, this.bindEvents).forEach((attr: BindAttribute | BindDirective | BindEvent) => {
|
|
1598
|
-
const result = options.attrFormat(attr, this, attr.toVue());
|
|
1627
|
+
const result = options.attrFormat(attr, this, attr.toVue(options));
|
|
1599
1628
|
result && parts.push(result);
|
|
1600
1629
|
});
|
|
1601
1630
|
|
|
@@ -1621,7 +1650,7 @@ export class ViewElement extends BaseNode {
|
|
|
1621
1650
|
//================================================================================
|
|
1622
1651
|
}
|
|
1623
1652
|
|
|
1624
|
-
classMap
|
|
1653
|
+
classMap.ViewElement = ViewElement;
|
|
1625
1654
|
export default ViewElement;
|
|
1626
1655
|
//================================================================================
|
|
1627
1656
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|