@lcap/nasl 1.0.0-alpha.9 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/automate/engine/index.d.ts +3 -0
- package/out/automate/engine/index.js +414 -0
- package/out/automate/engine/index.js.map +1 -0
- package/out/automate/engine/operators.d.ts +13 -0
- package/out/automate/engine/operators.js +63 -0
- package/out/automate/engine/operators.js.map +1 -0
- package/out/automate/engine/uniqueName.d.ts +6 -0
- package/out/automate/engine/uniqueName.js +39 -0
- package/out/automate/engine/uniqueName.js.map +1 -0
- package/out/automate/engine/utils.d.ts +24 -0
- package/out/automate/engine/utils.js +379 -0
- package/out/automate/engine/utils.js.map +1 -0
- package/out/common/BaseNode.d.ts +21 -1
- package/out/common/BaseNode.js +232 -84
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +19 -1
- package/out/concepts/App__.js +88 -45
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.d.ts +5 -1
- package/out/concepts/Argument__.js +21 -3
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.d.ts +201 -0
- package/out/concepts/Assignee__.js +298 -0
- package/out/concepts/Assignee__.js.map +1 -0
- package/out/concepts/Assignment__.js +5 -0
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +8 -7
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +19 -0
- package/out/concepts/BindAttribute__.js +55 -10
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +23 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +2 -2
- package/out/concepts/BindEvent__.js +67 -34
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +2 -0
- package/out/concepts/BooleanLiteral__.js +10 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +58 -25
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +5 -0
- package/out/concepts/CallInterface__.js +238 -31
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +4 -4
- package/out/concepts/CallLogic__.js +107 -50
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +38 -3
- package/out/concepts/CallQueryComponent__.js +329 -75
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +6 -2
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/CompletionProperty__.d.ts +3 -1
- package/out/concepts/CompletionProperty__.js +2 -0
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js +3 -3
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js +3 -3
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.js +3 -3
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.d.ts +1 -0
- package/out/concepts/Constant__.js +16 -2
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +12 -0
- package/out/concepts/Destination__.js +115 -22
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +9 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.js +4 -2
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +11 -0
- package/out/concepts/EntityProperty__.js +71 -5
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +5 -4
- package/out/concepts/Entity__.js +35 -19
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +5 -0
- package/out/concepts/Enum__.js +24 -12
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +3 -3
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +1 -1
- package/out/concepts/ForEachStatement__.js +11 -15
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.js +13 -13
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +3 -0
- package/out/concepts/Identifier__.js +77 -30
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +4 -4
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.d.ts +6 -4
- package/out/concepts/InterfaceParam__.js +57 -19
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +42 -30
- package/out/concepts/Interface__.js +133 -17
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.d.ts +1 -0
- package/out/concepts/JSBlock__.js +3 -0
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +2 -1
- package/out/concepts/LogicItem__.js +14 -0
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +20 -1
- package/out/concepts/Logic__.js +194 -37
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +2 -0
- package/out/concepts/MemberExpression__.js +49 -13
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +126 -120
- package/out/concepts/Module__.js +36 -26
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +5 -1
- package/out/concepts/Namespace__.js +48 -37
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NullLiteral__.d.ts +3 -0
- package/out/concepts/NullLiteral__.js +11 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.d.ts +1 -1
- package/out/concepts/NumericLiteral__.js +17 -6
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/Param__.d.ts +7 -3
- package/out/concepts/Param__.js +64 -28
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +6 -6
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +0 -4
- package/out/concepts/ProcessElement__.js +123 -54
- 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/Process__.d.ts +7 -1
- package/out/concepts/Process__.js +81 -85
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +1 -0
- package/out/concepts/QueryFieldExpression__.js +3 -0
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +2 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +3 -0
- package/out/concepts/QueryGroupByExpression__.js +20 -0
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +5 -5
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js +2 -2
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +3 -3
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +4 -1
- package/out/concepts/Return__.js +74 -23
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.d.ts +4 -0
- package/out/concepts/Role__.js +13 -4
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.js +2 -2
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -1
- package/out/concepts/StringLiteral__.js +22 -39
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +5 -4
- package/out/concepts/StructureProperty__.js +55 -26
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +44 -30
- package/out/concepts/Structure__.js +44 -12
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +4 -4
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +2 -2
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +5 -5
- package/out/concepts/TypeAnnotation__.js +82 -20
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +10 -8
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -0
- package/out/concepts/ValidationRule__.js +48 -13
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +10 -1
- package/out/concepts/Variable__.js +77 -20
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +15 -15
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +17 -11
- package/out/concepts/ViewElement__.js +302 -204
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +13 -12
- package/out/concepts/View__.js +124 -102
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +3 -3
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +4 -1
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/{nasl.validate.d.ts → nasl.auth.d.ts} +0 -0
- package/out/concepts/basics/stdlib/nasl.auth.js +30 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.browser.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.browser.js +41 -0
- package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.configuration.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js +25 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.interface.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.interface.js +4 -4
- package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +20 -0
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +138 -18
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.validation.js +54 -20
- package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +1 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -1
- package/out/concepts/basics/types/coreTypeList.js +11 -10
- package/out/concepts/basics/types/coreTypeList.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 +1 -0
- package/out/concepts/index__.js +1 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/config.d.ts +1 -2
- package/out/config.js +1 -2
- package/out/config.js.map +1 -1
- package/out/enums/KEYWORDS.d.ts +3 -0
- package/out/enums/KEYWORDS.js +1199 -0
- package/out/enums/KEYWORDS.js.map +1 -0
- package/out/{terms → enums}/LEVEL_NAME_MAP.d.ts +0 -0
- package/out/{terms → enums}/LEVEL_NAME_MAP.js +0 -0
- package/out/{terms → enums}/LEVEL_NAME_MAP.js.map +1 -1
- package/out/eventBus.d.ts +3 -0
- package/out/eventBus.js +7 -0
- package/out/eventBus.js.map +1 -0
- package/out/generator/genBundleFiles.d.ts +7 -2
- package/out/generator/genBundleFiles.js +168 -27
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +20 -20
- package/out/generator/genMetaData.js +50 -15
- package/out/generator/genMetaData.js.map +1 -1
- package/out/index.d.ts +2 -0
- package/out/index.js +2 -0
- package/out/index.js.map +1 -1
- package/out/manager/diagnostic.d.ts +2 -2
- package/out/server/createUiTs.d.ts +1 -0
- package/out/server/createUiTs.js +49 -5
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +38 -23
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.d.ts +1 -0
- package/out/server/extendBaseNode.js +323 -0
- package/out/server/extendBaseNode.js.map +1 -0
- package/out/server/getExtensionModules.js +2 -0
- package/out/server/getExtensionModules.js.map +1 -1
- package/out/server/getFunctions.d.ts +1 -0
- package/out/server/getFunctions.js +7 -1
- package/out/server/getFunctions.js.map +1 -1
- package/out/server/getLogics.js +84 -18
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +16 -1
- package/out/server/getMemberIdentifier.js +326 -38
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +8 -1
- package/out/server/getProcesses.js +383 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/getScope.d.ts +13 -0
- package/out/server/getScope.js +61 -0
- package/out/server/getScope.js.map +1 -0
- package/out/server/index.d.ts +1 -0
- package/out/server/index.js +5 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +36 -57
- package/out/server/naslServer.js +689 -615
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.d.ts +10 -0
- package/out/server/process2LogicNamespace.js +29 -1
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.d.ts +22 -3
- package/out/server/translator.js +369 -123
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/add.configs.d.ts +1 -0
- package/out/service/creator/add.configs.js +68 -0
- package/out/service/creator/add.configs.js.map +1 -0
- package/out/service/creator/errHandles.d.ts +18 -0
- package/out/service/creator/errHandles.js +60 -0
- package/out/service/creator/errHandles.js.map +1 -0
- package/out/service/creator/index.d.ts +1 -0
- package/out/service/creator/index.js +72 -0
- package/out/service/creator/index.js.map +1 -0
- package/out/service/storage/api.d.ts +18 -0
- package/out/service/storage/api.js +17 -0
- package/out/service/storage/api.js.map +1 -0
- package/out/service/storage/init.js +221 -37
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/service.d.ts +2 -0
- package/out/service/storage/service.js +10 -0
- package/out/service/storage/service.js.map +1 -0
- package/out/service/storage/storagePoint.d.ts +1 -14
- package/out/service/storage/storagePoint.js +16 -16
- package/out/service/storage/storagePoint.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +13 -17
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +11 -11
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +5 -5
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +2 -2
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +6 -4
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.d.ts +3 -1
- package/out/templator/genGridViewBlock.js +61 -6
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.d.ts +2 -0
- package/out/templator/genQueryComponent.js +34 -18
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +5 -15
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +1 -1
- package/out/templator/genTableBlock.js +4 -5
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +10 -11
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +16 -5
- package/out/templator/utils.js +10 -5
- package/out/templator/utils.js.map +1 -1
- package/out/test/fixtures/env.js +0 -1
- package/out/test/fixtures/env.js.map +1 -1
- package/out/test/units/page/Element.spec.js +3 -3
- package/out/test/units/page/Element.spec.js.map +1 -1
- package/out/test/units/temp/temp.spec.js +1 -1
- package/out/test/units/temp/temp.spec.js.map +1 -1
- package/out/utils/index.d.ts +6 -0
- package/out/utils/index.js +25 -1
- package/out/utils/index.js.map +1 -1
- package/out/utils/string.d.ts +1 -1
- package/out/utils/string.js +38 -9
- package/out/utils/string.js.map +1 -1
- package/package.json +2 -2
- package/src/automate/engine/index.js +95 -119
- package/src/automate/engine/operators.js +63 -0
- package/src/automate/engine/uniqueName.js +36 -0
- package/src/automate/engine/utils.js +63 -19
- package/src/common/BaseNode.ts +229 -74
- package/src/concepts/App__.ts +92 -85
- package/src/concepts/Argument__.ts +23 -3
- package/src/concepts/Assignee__.ts +467 -0
- package/src/concepts/Assignment__.ts +4 -1
- package/src/concepts/BinaryExpression__.ts +9 -7
- package/src/concepts/BindAttribute__.ts +69 -9
- package/src/concepts/BindDirective__.ts +22 -3
- package/src/concepts/BindEvent__.ts +67 -23
- package/src/concepts/BooleanLiteral__.ts +8 -0
- package/src/concepts/CallFunction__.ts +55 -23
- package/src/concepts/CallInterface__.ts +236 -26
- package/src/concepts/CallLogic__.ts +111 -52
- package/src/concepts/CallQueryComponent__.ts +315 -67
- package/src/concepts/Comment__.ts +6 -2
- package/src/concepts/CompletionProperty__.ts +5 -1
- package/src/concepts/ConfigGroup__.ts +3 -3
- package/src/concepts/ConfigProperty__.ts +3 -3
- package/src/concepts/Configuration__.ts +3 -3
- package/src/concepts/Constant__.ts +14 -2
- package/src/concepts/Destination__.ts +123 -37
- package/src/concepts/End__.ts +8 -1
- package/src/concepts/EntityIndex__.ts +4 -2
- package/src/concepts/EntityProperty__.ts +56 -5
- package/src/concepts/Entity__.ts +38 -21
- package/src/concepts/Enum__.ts +23 -26
- package/src/concepts/Event__.ts +3 -3
- package/src/concepts/ForEachStatement__.ts +16 -21
- package/src/concepts/Function__.ts +13 -13
- package/src/concepts/Identifier__.ts +84 -42
- package/src/concepts/IfStatement__.ts +4 -4
- package/src/concepts/InterfaceParam__.ts +57 -16
- package/src/concepts/Interface__.ts +130 -16
- package/src/concepts/JSBlock__.ts +4 -0
- package/src/concepts/LogicItem__.ts +16 -1
- package/src/concepts/Logic__.ts +192 -39
- package/src/concepts/MemberExpression__.ts +58 -15
- package/src/concepts/Module__.ts +35 -24
- package/src/concepts/Namespace__.ts +49 -37
- package/src/concepts/NullLiteral__.ts +8 -1
- package/src/concepts/NumericLiteral__.ts +17 -6
- package/src/concepts/Param__.ts +64 -16
- package/src/concepts/ProcessComponent__.ts +6 -6
- package/src/concepts/ProcessElement__.ts +149 -44
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/Process__.ts +85 -98
- package/src/concepts/QueryAggregateExpression__.ts +1 -1
- package/src/concepts/QueryFieldExpression__.ts +4 -0
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/QueryGroupByExpression__.ts +23 -0
- package/src/concepts/QueryJoinExpression__.ts +5 -5
- package/src/concepts/QueryLimitExpression__.ts +2 -2
- package/src/concepts/QuerySelectExpression__.ts +3 -3
- package/src/concepts/Return__.ts +69 -17
- package/src/concepts/Role__.ts +5 -4
- package/src/concepts/SqlQueryComponent__.ts +2 -2
- package/src/concepts/StringLiteral__.ts +21 -39
- package/src/concepts/StructureProperty__.ts +50 -18
- package/src/concepts/Structure__.ts +32 -10
- package/src/concepts/SwitchCase__.ts +4 -4
- package/src/concepts/SwitchStatement__.ts +2 -2
- package/src/concepts/TypeAnnotation__.ts +66 -15
- package/src/concepts/UnaryExpression__.ts +10 -8
- package/src/concepts/Unparsed__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +44 -14
- package/src/concepts/Variable__.ts +70 -16
- package/src/concepts/ViewComponent__.ts +15 -15
- package/src/concepts/ViewElement__.ts +289 -166
- package/src/concepts/View__.ts +135 -69
- package/src/concepts/WhileStatement__.ts +4 -4
- package/src/concepts/basics/stdlib/index.ts +4 -2
- package/src/concepts/basics/stdlib/nasl.auth.ts +26 -0
- package/src/concepts/basics/stdlib/nasl.browser.ts +37 -0
- package/src/concepts/basics/stdlib/nasl.configuration.ts +21 -0
- package/src/concepts/basics/stdlib/nasl.interface.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.ui.ts +20 -1
- package/src/concepts/basics/stdlib/nasl.util.ts +140 -18
- package/src/concepts/basics/stdlib/nasl.validation.ts +45 -11
- package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +1 -1
- package/src/concepts/basics/types/coreTypeList.ts +11 -11
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/index__.ts +1 -0
- package/src/config.ts +1 -2
- package/src/enums/KEYWORDS.ts +1197 -0
- package/src/{terms → enums}/LEVEL_NAME_MAP.ts +0 -0
- package/src/eventBus.ts +5 -0
- package/src/generator/genBundleFiles.ts +182 -30
- package/src/generator/genMetaData.ts +72 -21
- package/src/index.ts +2 -0
- package/src/manager/diagnostic.ts +2 -2
- package/src/server/createUiTs.ts +45 -7
- package/src/server/entity2LogicNamespace.ts +41 -25
- package/src/server/extendBaseNode.ts +318 -0
- package/src/server/getExtensionModules.ts +2 -0
- package/src/server/getFunctions.ts +6 -0
- package/src/server/getLogics.ts +87 -19
- package/src/server/getMemberIdentifier.ts +282 -65
- package/src/server/getProcesses.ts +397 -4
- package/src/server/getScope.ts +67 -0
- package/src/server/index.ts +13 -1
- package/src/server/naslServer.ts +694 -632
- package/src/server/process2LogicNamespace.ts +30 -2
- package/src/server/translator.ts +425 -128
- package/src/service/config/index.js +1 -1
- package/src/service/creator/errHandles.js +5 -2
- package/src/service/creator/index.js +0 -6
- package/src/service/storage/api.js +14 -0
- package/src/service/storage/init.ts +218 -45
- package/src/service/storage/service.ts +6 -0
- package/src/service/storage/storagePoint.ts +16 -16
- package/src/templator/genCreateBlock.ts +6 -6
- package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -30
- package/src/templator/genCurdMultipleKeyBlock.ts +11 -11
- package/src/templator/genEditTableBlock.ts +5 -5
- package/src/templator/genEnumSelectBlock.ts +2 -2
- package/src/templator/genGetBlock.ts +7 -9
- package/src/templator/genGridViewBlock.ts +59 -9
- package/src/templator/genQueryComponent.ts +46 -32
- package/src/templator/genSelectBlock.ts +5 -15
- package/src/templator/genTableBlock.ts +5 -9
- package/src/templator/genUpdateBlock.ts +10 -12
- package/src/templator/utils.ts +12 -6
- package/src/test/fixtures/env.ts +0 -2
- package/src/test/units/page/Element.spec.ts +3 -3
- package/src/test/units/temp/temp.spec.ts +1 -1
- package/src/utils/index.ts +24 -0
- package/src/utils/string.ts +39 -9
- package/out/concepts/basics/stdlib/nasl.validate.js +0 -527
- package/out/concepts/basics/stdlib/nasl.validate.js.map +0 -1
- package/out/data/Module.d.ts +0 -34
- package/out/data/Module.js +0 -53
- package/out/data/Module.js.map +0 -1
- package/src/automate/engine/index.d.ts +0 -3
|
@@ -65,38 +65,62 @@ function genArgumentMemberExpression(arr) {
|
|
|
65
65
|
}
|
|
66
66
|
return expressionNode;
|
|
67
67
|
}
|
|
68
|
-
function transAstNodeToNaslNode(astNode) {
|
|
68
|
+
function transAstNodeToNaslNode(astNode, namespace) {
|
|
69
69
|
let node = null;
|
|
70
70
|
if (astNode.type === 'CallExpression' && astNode.callee.object.name === '$utils') {
|
|
71
71
|
const calleeName = astNode.callee.property.name || astNode.callee.property.value;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
name
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
if (calleeName === 'EnumList') {
|
|
73
|
+
const args = astNode.arguments;
|
|
74
|
+
let name = '';
|
|
75
|
+
let namespace = 'app.enums';
|
|
76
|
+
if (Array.isArray(args)) {
|
|
77
|
+
name = args[0]?.value;
|
|
78
|
+
namespace = args[1]?.value ? args[1]?.value : 'app.enums';
|
|
79
|
+
}
|
|
80
|
+
node = {
|
|
81
|
+
concept: 'Identifier',
|
|
82
|
+
name,
|
|
83
|
+
namespace,
|
|
84
|
+
kind: 'Expression',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
node = {
|
|
89
|
+
concept: 'CallFunction',
|
|
81
90
|
name: '',
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
label: '调用内置函数',
|
|
92
|
+
kind: 'Expression',
|
|
93
|
+
calleeNamespace: 'nasl.util',
|
|
94
|
+
calleeName,
|
|
95
|
+
arguments: astNode.arguments.map((argument) => ({
|
|
96
|
+
concept: 'Argument',
|
|
97
|
+
name: '',
|
|
98
|
+
kind: 'Statement',
|
|
99
|
+
keyword: '',
|
|
100
|
+
expression: transAstNodeToNaslNode(Object.assign({}, argument)),
|
|
101
|
+
})),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
87
104
|
}
|
|
88
105
|
else if (astNode.type === 'MemberExpression') {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
if (astNode.object?.name === '$global') {
|
|
107
|
+
// 目前只有权限相关的
|
|
108
|
+
node = transAstNodeToNaslNode(astNode.property, 'nasl.auth');
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
node = {
|
|
112
|
+
concept: 'MemberExpression',
|
|
113
|
+
name: '',
|
|
114
|
+
kind: 'Expression',
|
|
115
|
+
object: transAstNodeToNaslNode(astNode.object),
|
|
116
|
+
property: transAstNodeToNaslNode(astNode.property),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
96
119
|
}
|
|
97
120
|
else if (astNode.type === 'Identifier') {
|
|
98
121
|
node = {
|
|
99
122
|
concept: 'Identifier',
|
|
123
|
+
namespace: namespace || '',
|
|
100
124
|
name: astNode.name,
|
|
101
125
|
kind: 'Expression',
|
|
102
126
|
};
|
|
@@ -116,6 +140,19 @@ function transAstNodeToNaslNode(astNode) {
|
|
|
116
140
|
value: astNode.value,
|
|
117
141
|
};
|
|
118
142
|
}
|
|
143
|
+
else if (astNode.type === 'UnaryExpression') {
|
|
144
|
+
node = {
|
|
145
|
+
concept: 'UnaryExpression',
|
|
146
|
+
kind: 'Expression',
|
|
147
|
+
name: '',
|
|
148
|
+
operator: astNode.operator,
|
|
149
|
+
argument: transAstNodeToNaslNode(astNode.argument),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
node = astNode;
|
|
154
|
+
node.concept = astNode.type;
|
|
155
|
+
}
|
|
119
156
|
return node;
|
|
120
157
|
}
|
|
121
158
|
const decorators_1 = require("../decorators");
|
|
@@ -246,7 +283,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
246
283
|
return (this.bindAttrs || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
247
284
|
}
|
|
248
285
|
getBindAttributeUniqueName(name = 'bindAttribute1') {
|
|
249
|
-
return utils.unique(name, this.getBindAttributeExistingNames());
|
|
286
|
+
return utils.unique(name, this.getBindAttributeExistingNames(), undefined, false);
|
|
250
287
|
}
|
|
251
288
|
_insertBindAttributeAt(options, index) {
|
|
252
289
|
const bindAttributeOptions = {};
|
|
@@ -265,7 +302,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
265
302
|
}, this, 'bindAttrs');
|
|
266
303
|
}
|
|
267
304
|
else if (options instanceof BindAttribute__1.default) {
|
|
268
|
-
options.
|
|
305
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
269
306
|
bindAttribute = options;
|
|
270
307
|
Object.assign(bindAttribute, relationOptions);
|
|
271
308
|
}
|
|
@@ -293,7 +330,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
293
330
|
}
|
|
294
331
|
addBindAttribute(options) {
|
|
295
332
|
const node = this._addBindAttribute(options);
|
|
296
|
-
const index = this.bindAttrs.
|
|
333
|
+
const index = this.bindAttrs.indexOf(node);
|
|
297
334
|
node.create({
|
|
298
335
|
index,
|
|
299
336
|
parentNode: this,
|
|
@@ -306,7 +343,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
306
343
|
return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
307
344
|
}
|
|
308
345
|
getBindEventUniqueName(name = 'bindEvent1') {
|
|
309
|
-
return utils.unique(name, this.getBindEventExistingNames());
|
|
346
|
+
return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
|
|
310
347
|
}
|
|
311
348
|
_insertBindEventAt(options, index) {
|
|
312
349
|
const bindEventOptions = {};
|
|
@@ -325,7 +362,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
325
362
|
}, this, 'bindEvents');
|
|
326
363
|
}
|
|
327
364
|
else if (options instanceof BindEvent__1.default) {
|
|
328
|
-
options.
|
|
365
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
329
366
|
bindEvent = options;
|
|
330
367
|
Object.assign(bindEvent, relationOptions);
|
|
331
368
|
}
|
|
@@ -353,7 +390,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
353
390
|
}
|
|
354
391
|
addBindEvent(options) {
|
|
355
392
|
const node = this._addBindEvent(options);
|
|
356
|
-
const index = this.bindEvents.
|
|
393
|
+
const index = this.bindEvents.indexOf(node);
|
|
357
394
|
node.create({
|
|
358
395
|
index,
|
|
359
396
|
parentNode: this,
|
|
@@ -366,7 +403,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
366
403
|
return (this.bindDirectives || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
367
404
|
}
|
|
368
405
|
getBindDirectiveUniqueName(name = 'bindDirective1') {
|
|
369
|
-
return utils.unique(name, this.getBindDirectiveExistingNames());
|
|
406
|
+
return utils.unique(name, this.getBindDirectiveExistingNames(), undefined, false);
|
|
370
407
|
}
|
|
371
408
|
_insertBindDirectiveAt(options, index) {
|
|
372
409
|
const bindDirectiveOptions = {};
|
|
@@ -385,7 +422,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
385
422
|
}, this, 'bindDirectives');
|
|
386
423
|
}
|
|
387
424
|
else if (options instanceof BindDirective__1.default) {
|
|
388
|
-
options.
|
|
425
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
389
426
|
bindDirective = options;
|
|
390
427
|
Object.assign(bindDirective, relationOptions);
|
|
391
428
|
}
|
|
@@ -413,7 +450,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
413
450
|
}
|
|
414
451
|
addBindDirective(options) {
|
|
415
452
|
const node = this._addBindDirective(options);
|
|
416
|
-
const index = this.bindDirectives.
|
|
453
|
+
const index = this.bindDirectives.indexOf(node);
|
|
417
454
|
node.create({
|
|
418
455
|
index,
|
|
419
456
|
parentNode: this,
|
|
@@ -438,7 +475,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
438
475
|
}, this, 'children');
|
|
439
476
|
}
|
|
440
477
|
else if (options instanceof ViewElement_1) {
|
|
441
|
-
options.
|
|
478
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
442
479
|
viewElement = options;
|
|
443
480
|
Object.assign(viewElement, relationOptions);
|
|
444
481
|
}
|
|
@@ -466,7 +503,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
466
503
|
}
|
|
467
504
|
addViewElement(options) {
|
|
468
505
|
const node = this._addViewElement(options);
|
|
469
|
-
const index = this.children.
|
|
506
|
+
const index = this.children.indexOf(node);
|
|
470
507
|
node.create({
|
|
471
508
|
index,
|
|
472
509
|
parentNode: this,
|
|
@@ -622,6 +659,18 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
622
659
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
623
660
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
624
661
|
//================================================================================
|
|
662
|
+
/* 主页面有没有权限 */
|
|
663
|
+
get parentAuth() {
|
|
664
|
+
const _nameSpace = this.view.getNamespace();
|
|
665
|
+
const mainViewName = _nameSpace.split('.')[2];
|
|
666
|
+
return this.view.parentNode.concept === 'App' ? this.view.auth : this.app.views.find((item) => item.name === mainViewName)?.auth;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* 权限领域的资源路径
|
|
670
|
+
*/
|
|
671
|
+
get authPath() {
|
|
672
|
+
return `${this.view.path}/${this.name}`;
|
|
673
|
+
}
|
|
625
674
|
getViewElementUniqueName(name = 'viewElement1') {
|
|
626
675
|
return this.view?.getViewElementUniqueName(name);
|
|
627
676
|
}
|
|
@@ -648,43 +697,24 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
648
697
|
getBindAttribute(name) {
|
|
649
698
|
return this.bindAttrs.find((bindAttr) => bindAttr.name === name);
|
|
650
699
|
}
|
|
651
|
-
/**
|
|
652
|
-
* 角色
|
|
653
|
-
*/
|
|
654
|
-
roles = [];
|
|
655
|
-
toggleRole(role) {
|
|
656
|
-
const index = this.roles.findIndex((roleItem) => roleItem.name === role.name);
|
|
657
|
-
const roles = [...this.roles];
|
|
658
|
-
if (index !== -1) {
|
|
659
|
-
roles.splice(index, 1);
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
662
|
-
roles.push({
|
|
663
|
-
namespace: role.getNamespace(),
|
|
664
|
-
name: role.name,
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
const object = {
|
|
668
|
-
roles,
|
|
669
|
-
};
|
|
670
|
-
this.update({
|
|
671
|
-
...object,
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
700
|
toHump(name) {
|
|
675
701
|
return name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase());
|
|
676
702
|
}
|
|
677
703
|
haveScope(node) {
|
|
678
|
-
|
|
679
|
-
const
|
|
704
|
+
// uGallery 没有子集不需要scope
|
|
705
|
+
const dataSourcePcList = ['uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect', 'devopsDragTable'];
|
|
706
|
+
const dataSourceH5List = ['vanRadioGroup', 'vanCheckboxGroup', 'vanListView', 'vanGridView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
|
|
680
707
|
const dataSourceList = [...dataSourcePcList, ...dataSourceH5List];
|
|
681
708
|
return dataSourceList.includes(node.toHump(node.tag));
|
|
682
709
|
}
|
|
683
710
|
toEmbeddedTSDefinition(state) {
|
|
711
|
+
// 登录组件不翻译
|
|
712
|
+
if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form')
|
|
713
|
+
return '';
|
|
684
714
|
let code = '';
|
|
685
715
|
// formItem的单独处理
|
|
686
716
|
if (this.tag === 'u-form-item') {
|
|
687
|
-
code = (0, translator_1.indent)(state.tabSize) + `${this.name}:
|
|
717
|
+
code = (0, translator_1.indent)(state.tabSize) + `${this.name}: nasl.ui.${this.toHump(this.tag)}`;
|
|
688
718
|
if (Array.isArray(this.children) && this.children.length) {
|
|
689
719
|
const tag = this.children[0].tag;
|
|
690
720
|
if (tag === 'u-input') {
|
|
@@ -697,7 +727,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
697
727
|
code += '<nasl.core.Any>';
|
|
698
728
|
}
|
|
699
729
|
}
|
|
700
|
-
code += '
|
|
730
|
+
code += ';\n';
|
|
701
731
|
}
|
|
702
732
|
if (this.haveScope(this)) {
|
|
703
733
|
let genericType = 'any';
|
|
@@ -714,9 +744,13 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
714
744
|
let parentNode = this.parentNode;
|
|
715
745
|
let haveScopeFlag = false;
|
|
716
746
|
while (!haveScopeFlag && parentNode.concept !== 'View') {
|
|
717
|
-
if (this.haveScope(
|
|
747
|
+
if (this.haveScope(parentNode)) {
|
|
718
748
|
// type d = nasl.ui.GetItemTypeFromDataSource<typeof listStructure>['tableRelation']
|
|
719
|
-
const tsArr = expressionTs.split('.');
|
|
749
|
+
const tsArr = expressionTs.replace('scope.item.', '').split('.');
|
|
750
|
+
let itemStr = '';
|
|
751
|
+
tsArr.forEach((item) => {
|
|
752
|
+
itemStr += `['${item}']`;
|
|
753
|
+
});
|
|
720
754
|
const parentbindAttrs = parentNode.bindAttrs;
|
|
721
755
|
if (parentbindAttrs && parentbindAttrs.length) {
|
|
722
756
|
const parentAttr = parentbindAttrs.find((item) => item.name === 'data-source');
|
|
@@ -724,7 +758,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
724
758
|
let parentExpressionTs = parentAttr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code));
|
|
725
759
|
parentExpressionTs = parentExpressionTs.replaceAll(' ', '');
|
|
726
760
|
// 如果是逻辑就推导出逻辑类型
|
|
727
|
-
genericType = `nasl.ui.GetItemTypeFromDataSource<nasl.ui.GetItemTypeFromDataSource<typeof ${parentExpressionTs}
|
|
761
|
+
genericType = `nasl.ui.GetItemTypeFromDataSource<nasl.ui.GetItemTypeFromDataSource<typeof ${parentExpressionTs}>${itemStr}>`;
|
|
728
762
|
}
|
|
729
763
|
}
|
|
730
764
|
haveScopeFlag = true;
|
|
@@ -734,10 +768,10 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
734
768
|
}
|
|
735
769
|
}
|
|
736
770
|
}
|
|
737
|
-
code += (0, translator_1.indent)(state.tabSize) + `${this.name}:
|
|
771
|
+
code += (0, translator_1.indent)(state.tabSize) + `${this.name}: nasl.ui.${this.toHump(this.tag)}<${genericType}>;\n`;
|
|
738
772
|
}
|
|
739
773
|
else {
|
|
740
|
-
code = (0, translator_1.indent)(state.tabSize) + `${this.name}:
|
|
774
|
+
code = (0, translator_1.indent)(state.tabSize) + `${this.name}: nasl.ui.${this.toHump(this.tag)}<any>;\n`;
|
|
741
775
|
}
|
|
742
776
|
if (Array.isArray(this.children)) {
|
|
743
777
|
this.children.forEach((element) => {
|
|
@@ -747,13 +781,15 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
747
781
|
return code;
|
|
748
782
|
}
|
|
749
783
|
toEmbeddedTS(state, parentLevel) {
|
|
784
|
+
if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form')
|
|
785
|
+
return '';
|
|
750
786
|
function chineseTsName(name) {
|
|
751
787
|
let tsName = name;
|
|
788
|
+
// 匹配所有特殊字符都转为_
|
|
789
|
+
tsName = tsName.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '_');
|
|
752
790
|
if (/^\d/.test(tsName)) {
|
|
753
791
|
tsName = '$' + tsName;
|
|
754
792
|
}
|
|
755
|
-
// 匹配所有特殊字符都转为_
|
|
756
|
-
tsName = tsName.replace(/\W/g, '_');
|
|
757
793
|
return tsName;
|
|
758
794
|
}
|
|
759
795
|
let code = `__elements.${this.name} = new nasl.ui.${this.toHump(this.tag)}({\n`;
|
|
@@ -763,7 +799,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
763
799
|
hasAuth = !!this.bindDirectives.filter((directive) => directive.name === 'auth').length;
|
|
764
800
|
}
|
|
765
801
|
// 角色
|
|
766
|
-
if (
|
|
802
|
+
if (Array.isArray(this.bindRoles) && this.bindRoles.length) {
|
|
767
803
|
code += (0, translator_1.indent)(state.tabSize + 2);
|
|
768
804
|
code += 'roles = [\n';
|
|
769
805
|
this.bindRoles.forEach((role) => {
|
|
@@ -798,26 +834,39 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
798
834
|
// 子元素
|
|
799
835
|
if (Array.isArray(this.children)) {
|
|
800
836
|
code += (0, translator_1.indent)(state.tabSize + 1);
|
|
801
|
-
let levelIndex = parentLevel || 0;
|
|
802
|
-
if (this.haveScope(this)) {
|
|
803
|
-
code += `slotDefault: (scope${levelIndex || ''})=> [\n`;
|
|
804
|
-
levelIndex++;
|
|
805
|
-
}
|
|
806
|
-
else {
|
|
807
|
-
code += `slotDefault: ()=> [\n`;
|
|
808
|
-
}
|
|
809
837
|
if (Array.isArray(this.bindAttrs)) {
|
|
810
|
-
code +=
|
|
838
|
+
code += `bindAttr: () => [\n`;
|
|
811
839
|
this.bindAttrs.forEach((attr) => {
|
|
812
840
|
if (attr.expression) {
|
|
813
841
|
code
|
|
814
842
|
+= attr.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
815
|
-
tabSize: state.tabSize +
|
|
843
|
+
tabSize: state.tabSize + 2,
|
|
844
|
+
})) + ',\n';
|
|
845
|
+
}
|
|
846
|
+
if (Array.isArray(attr.rules) && attr.rules.length) {
|
|
847
|
+
attr.rules.forEach((item) => {
|
|
848
|
+
code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code)) + ',\n';
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
this.bindDirectives.forEach((directive) => {
|
|
853
|
+
if (directive.expression) {
|
|
854
|
+
code
|
|
855
|
+
+= directive.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
856
|
+
tabSize: state.tabSize + 2,
|
|
816
857
|
})) + ',\n';
|
|
817
858
|
}
|
|
818
859
|
});
|
|
819
860
|
code += (0, translator_1.indent)(state.tabSize + 2) + '],\n';
|
|
820
861
|
}
|
|
862
|
+
let levelIndex = parentLevel || 0;
|
|
863
|
+
if (this.haveScope(this)) {
|
|
864
|
+
code += `slotDefault: (scope)=> [\n`;
|
|
865
|
+
levelIndex++;
|
|
866
|
+
}
|
|
867
|
+
else {
|
|
868
|
+
code += `slotDefault: ()=> [\n`;
|
|
869
|
+
}
|
|
821
870
|
this.children.forEach((element) => {
|
|
822
871
|
code += element.toEmbeddedTS((0, translator_1.shiftState)(state, code, {
|
|
823
872
|
tabSize: state.tabSize + 2,
|
|
@@ -830,12 +879,9 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
830
879
|
code += (0, translator_1.indent)(state.tabSize) + '}),\n';
|
|
831
880
|
return code;
|
|
832
881
|
}
|
|
833
|
-
_duplicate(
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
view: this.view,
|
|
837
|
-
});
|
|
838
|
-
element.deepRenameElements();
|
|
882
|
+
_duplicate() {
|
|
883
|
+
const element = ViewElement_1.from(this.toTemplateJSON());
|
|
884
|
+
element.deepRenameElements(this);
|
|
839
885
|
return element;
|
|
840
886
|
}
|
|
841
887
|
// 递归遍历组件
|
|
@@ -845,10 +891,10 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
845
891
|
}, { node: this });
|
|
846
892
|
}
|
|
847
893
|
// 递归生成组件名
|
|
848
|
-
deepRenameElements() {
|
|
894
|
+
deepRenameElements(node) {
|
|
849
895
|
return this.traverseChildren((ele) => {
|
|
850
896
|
const tagName = ele.tag.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
851
|
-
ele.name =
|
|
897
|
+
ele.name = node.getViewElementUniqueName(`${tagName}1`);
|
|
852
898
|
});
|
|
853
899
|
}
|
|
854
900
|
/**
|
|
@@ -888,7 +934,6 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
888
934
|
concept: 'ValidationRule',
|
|
889
935
|
name: '',
|
|
890
936
|
label: '验证规则',
|
|
891
|
-
folded: true,
|
|
892
937
|
kind: 'Expression',
|
|
893
938
|
calleeNamespace: 'nasl.validation',
|
|
894
939
|
arguments: args,
|
|
@@ -917,8 +962,9 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
917
962
|
if (astNode.scopedSlots) {
|
|
918
963
|
astNode.children = astNode.children || [];
|
|
919
964
|
Object.keys(astNode.scopedSlots).forEach((key) => {
|
|
920
|
-
if (!astNode.children.find((child) => key === child.slotTarget))
|
|
965
|
+
if (!astNode.children.find((child) => key === child.slotTarget)) {
|
|
921
966
|
astNode.children.unshift(astNode.scopedSlots[key]);
|
|
967
|
+
}
|
|
922
968
|
});
|
|
923
969
|
delete astNode.scopedSlots;
|
|
924
970
|
}
|
|
@@ -938,6 +984,12 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
938
984
|
}
|
|
939
985
|
}
|
|
940
986
|
const tagName = astNode.tag.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
987
|
+
let newContext = {};
|
|
988
|
+
if (context) {
|
|
989
|
+
newContext = {
|
|
990
|
+
...context,
|
|
991
|
+
};
|
|
992
|
+
}
|
|
941
993
|
element = new ViewElement_1({
|
|
942
994
|
tag: astNode.tag,
|
|
943
995
|
name: astNode.attrsMap.ref || view.getViewElementUniqueName(`${tagName}1`),
|
|
@@ -945,46 +997,45 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
945
997
|
staticStyle: astNode.attrsMap.style,
|
|
946
998
|
slotTarget: astNode.slotTarget && json5.parse(astNode.slotTarget),
|
|
947
999
|
slotScope: astNode.slotScope === '_empty_' ? '' : astNode.slotScope,
|
|
948
|
-
children: astNode.children.map((item) => this._fromASTNode(item,
|
|
1000
|
+
children: astNode.children.map((item) => this._fromASTNode(item, newContext)),
|
|
949
1001
|
});
|
|
950
|
-
astNode
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1002
|
+
astNode?.attrs?.forEach((oldAttr) => {
|
|
1003
|
+
let attr;
|
|
1004
|
+
if (oldAttr.value === '""' && oldAttr.end - oldAttr.start === oldAttr.name.length) {
|
|
1005
|
+
attr = new BindAttribute__1.default({
|
|
1006
|
+
type: 'static',
|
|
1007
|
+
name: oldAttr.name,
|
|
1008
|
+
value: 'true',
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
else {
|
|
1012
|
+
try {
|
|
1013
|
+
const tmp = json5.parse(oldAttr.value);
|
|
1014
|
+
const source = {
|
|
1015
|
+
type: typeof tmp === 'string' ? 'string' : 'static',
|
|
956
1016
|
name: oldAttr.name,
|
|
957
|
-
value: '
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
try {
|
|
962
|
-
const tmp = json5.parse(oldAttr.value);
|
|
963
|
-
const source = {
|
|
964
|
-
type: typeof tmp === 'string' ? 'string' : 'static',
|
|
965
|
-
name: oldAttr.name,
|
|
966
|
-
value: typeof tmp === 'string' ? tmp : oldAttr.value,
|
|
967
|
-
};
|
|
968
|
-
if (oldAttr.name === 'rules') {
|
|
969
|
-
source.rules = tmp?.split('|').map((ruleStr) => this._parseValidationRule(ruleStr.trim()));
|
|
970
|
-
}
|
|
971
|
-
attr = BindAttribute__1.default.from(source, element);
|
|
1017
|
+
value: typeof tmp === 'string' ? tmp : oldAttr.value,
|
|
1018
|
+
};
|
|
1019
|
+
if (oldAttr.name === 'rules') {
|
|
1020
|
+
source.rules = tmp?.split('|').map((ruleStr) => this._parseValidationRule(ruleStr.trim()));
|
|
972
1021
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1022
|
+
attr = new BindAttribute__1.default(source);
|
|
1023
|
+
}
|
|
1024
|
+
catch (e) {
|
|
1025
|
+
const expression = this._parseExpression(oldAttr.value);
|
|
1026
|
+
attr = new BindAttribute__1.default({
|
|
1027
|
+
type: 'dynamic',
|
|
1028
|
+
name: oldAttr.name,
|
|
1029
|
+
value: expression ? '' : oldAttr.value,
|
|
1030
|
+
expression,
|
|
1031
|
+
});
|
|
1032
|
+
if (astNode.attrsMap[`:${attr.name}.sync`]) {
|
|
1033
|
+
attr.sync = true;
|
|
984
1034
|
}
|
|
985
1035
|
}
|
|
986
|
-
|
|
987
|
-
|
|
1036
|
+
}
|
|
1037
|
+
element.addBindAttribute(attr);
|
|
1038
|
+
});
|
|
988
1039
|
// compiler 处理:value.sync 时会加上update:value事件,需要过滤
|
|
989
1040
|
astNode.events
|
|
990
1041
|
&& Object.keys(astNode.events)
|
|
@@ -993,24 +1044,23 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
993
1044
|
const oldEvent = astNode.events[name];
|
|
994
1045
|
const str = oldEvent.value;
|
|
995
1046
|
let calleeName = str.split('(')[0];
|
|
996
|
-
const matchArr = str.match(/\(([^)]*)\)/);
|
|
1047
|
+
const matchArr = str.match(/\(([^)]*)\)/) || [];
|
|
997
1048
|
let argsStr = '';
|
|
998
|
-
if (matchArr
|
|
1049
|
+
if (matchArr?.length >= 2) {
|
|
999
1050
|
argsStr = matchArr[1];
|
|
1000
1051
|
}
|
|
1001
1052
|
let args = [];
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
let calleeNamespace = `${viewNamespace}.${viewName}.logics`;
|
|
1053
|
+
const argStrs = argsStr.split(',');
|
|
1054
|
+
args = argStrs
|
|
1055
|
+
.filter((argStr) => !!argStr && argStr !== '_empty_')
|
|
1056
|
+
.map((argStr) => {
|
|
1057
|
+
const keyword = argStr.trim().split('.');
|
|
1058
|
+
return {
|
|
1059
|
+
concept: 'Argument',
|
|
1060
|
+
expression: genArgumentMemberExpression(keyword),
|
|
1061
|
+
};
|
|
1062
|
+
});
|
|
1063
|
+
let calleeNamespace = '';
|
|
1014
1064
|
if (calleeName) {
|
|
1015
1065
|
const namespaceArr = calleeName.split('.');
|
|
1016
1066
|
const start = namespaceArr.shift();
|
|
@@ -1019,12 +1069,12 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1019
1069
|
calleeName = namespaceArr[1];
|
|
1020
1070
|
}
|
|
1021
1071
|
}
|
|
1022
|
-
element.
|
|
1072
|
+
element.addBindEvent(new BindEvent__1.default({
|
|
1023
1073
|
name,
|
|
1024
1074
|
calleeNamespace,
|
|
1025
1075
|
calleeName,
|
|
1026
1076
|
arguments: args,
|
|
1027
|
-
}
|
|
1077
|
+
}));
|
|
1028
1078
|
});
|
|
1029
1079
|
astNode.directives
|
|
1030
1080
|
&& astNode.directives.forEach((directive) => {
|
|
@@ -1032,52 +1082,48 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1032
1082
|
const valueAttr = astNode.attrs && astNode.attrs.find((attr) => attr.name === 'value');
|
|
1033
1083
|
if (!valueAttr) {
|
|
1034
1084
|
const expression = this._parseExpression(directive.value);
|
|
1035
|
-
element.
|
|
1085
|
+
element.addBindAttribute(new BindAttribute__1.default({
|
|
1036
1086
|
type: 'dynamic',
|
|
1037
1087
|
name: 'value',
|
|
1038
1088
|
value: expression ? '' : directive.value,
|
|
1039
1089
|
expression,
|
|
1040
1090
|
sync: true,
|
|
1041
|
-
}
|
|
1091
|
+
}));
|
|
1042
1092
|
}
|
|
1043
1093
|
}
|
|
1044
1094
|
else {
|
|
1045
1095
|
const expression = this._parseExpression(directive.value);
|
|
1046
|
-
element.
|
|
1096
|
+
element.addBindDirective(new BindDirective__1.default({
|
|
1047
1097
|
type: expression ? 'string' : 'dynamic',
|
|
1048
1098
|
name: directive.name,
|
|
1049
1099
|
rawName: directive.rawName,
|
|
1050
1100
|
value: expression ? '' : directive.value,
|
|
1051
1101
|
expression,
|
|
1052
1102
|
arg: directive.arg,
|
|
1053
|
-
modifiers: directive.modifiers,
|
|
1054
|
-
}
|
|
1103
|
+
// modifiers: directive.modifiers,
|
|
1104
|
+
}));
|
|
1055
1105
|
}
|
|
1056
1106
|
});
|
|
1057
1107
|
if (astNode.if) {
|
|
1058
|
-
element.
|
|
1108
|
+
element.addBindDirective(new BindDirective__1.default({
|
|
1059
1109
|
type: 'dynamic',
|
|
1060
1110
|
name: 'if',
|
|
1061
1111
|
rawName: 'v-if',
|
|
1062
1112
|
value: '',
|
|
1063
1113
|
expression: this._parseExpression(astNode.if),
|
|
1064
|
-
}
|
|
1114
|
+
}));
|
|
1065
1115
|
}
|
|
1066
1116
|
}
|
|
1067
1117
|
else if (astNode.type === 2) {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
element = new ViewElement_1({
|
|
1075
|
-
tag: 'u-text',
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1118
|
+
const tagName = __1.config.scope === 'h5' ? 'van-text' : 'u-text';
|
|
1119
|
+
const baseName = tagName.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1120
|
+
element = new ViewElement_1({
|
|
1121
|
+
tag: tagName,
|
|
1122
|
+
name: view.getViewElementUniqueName(`${baseName}1`),
|
|
1123
|
+
});
|
|
1078
1124
|
const value = astNode.text.match(/{{(.*?)}}/)[1].trim();
|
|
1079
1125
|
const expression = this._parseExpression(value);
|
|
1080
|
-
element.
|
|
1126
|
+
element.addBindAttribute(new BindAttribute__1.default({
|
|
1081
1127
|
type: 'dynamic',
|
|
1082
1128
|
name: 'text',
|
|
1083
1129
|
value: expression ? '' : value,
|
|
@@ -1085,17 +1131,13 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1085
1131
|
}));
|
|
1086
1132
|
}
|
|
1087
1133
|
else if (astNode.type === 3) {
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
tag: 'u-text',
|
|
1096
|
-
});
|
|
1097
|
-
}
|
|
1098
|
-
element.bindAttrs.push(new BindAttribute__1.default({
|
|
1134
|
+
const tagName = __1.config.scope === 'h5' ? 'van-text' : 'u-text';
|
|
1135
|
+
const baseName = tagName.replace(ViewElement_1.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
1136
|
+
element = new ViewElement_1({
|
|
1137
|
+
tag: tagName,
|
|
1138
|
+
name: view.getViewElementUniqueName(`${baseName}1`),
|
|
1139
|
+
});
|
|
1140
|
+
element.addBindAttribute(new BindAttribute__1.default({
|
|
1099
1141
|
name: 'text',
|
|
1100
1142
|
type: 'string',
|
|
1101
1143
|
value: astNode.text,
|
|
@@ -1118,22 +1160,13 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1118
1160
|
let ast = compiler.compile(html, compilerOptions).ast;
|
|
1119
1161
|
if (ast.tag === 'template' && !ast.slotTarget)
|
|
1120
1162
|
ast = ast.children[0];
|
|
1121
|
-
|
|
1122
|
-
utils.traverse((current) => {
|
|
1123
|
-
// 处理 scopedSlots;
|
|
1124
|
-
if (!current.parent)
|
|
1125
|
-
root = this._fromASTNode(current.node, context);
|
|
1126
|
-
else
|
|
1127
|
-
current.parent.children[current.index] = this._fromASTNode(current.node, context);
|
|
1128
|
-
}, { node: ast });
|
|
1129
|
-
return root;
|
|
1163
|
+
return this._fromASTNode(ast, context);
|
|
1130
1164
|
}
|
|
1131
1165
|
/**
|
|
1132
1166
|
* 从模板生成规范的 ViewElement 对象
|
|
1133
1167
|
*/
|
|
1134
1168
|
static fromHTML(html, context) {
|
|
1135
|
-
|
|
1136
|
-
return element;
|
|
1169
|
+
return this.parse(html, context);
|
|
1137
1170
|
}
|
|
1138
1171
|
/**
|
|
1139
1172
|
* 转换成设计器中使用的 Vue 文件
|
|
@@ -1161,7 +1194,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1161
1194
|
}
|
|
1162
1195
|
}
|
|
1163
1196
|
if (attr.type === 'dynamic' && !(element.tag === 'u-cascade-select' && attr.name === 'categories'))
|
|
1164
|
-
return defaultResult.replace(/:?(\w+)(?:.*?)="(.*)"/, (m, name, value) => {
|
|
1197
|
+
return defaultResult.replace(/:?([\w-]+)(?:.*?)="(.*)"/, (m, name, value) => {
|
|
1165
1198
|
try {
|
|
1166
1199
|
const tempValue = json5.parse(value);
|
|
1167
1200
|
if (typeof tempValue === 'boolean' || typeof tempValue === 'number') {
|
|
@@ -1173,7 +1206,12 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1173
1206
|
if (apiOfAttr && !apiOfAttr.type.includes('string'))
|
|
1174
1207
|
return '';
|
|
1175
1208
|
}
|
|
1176
|
-
|
|
1209
|
+
value = value
|
|
1210
|
+
.replace(/"/g, "'")
|
|
1211
|
+
.replace(/\$utils\['(.+?)'\]/g, '$1')
|
|
1212
|
+
.replace(/\$refs./g, 'elements.')
|
|
1213
|
+
.replace(/\$global./g, 'nasl.auth.');
|
|
1214
|
+
return `${name}="{{ ${value} }}"`;
|
|
1177
1215
|
});
|
|
1178
1216
|
else
|
|
1179
1217
|
return defaultResult;
|
|
@@ -1184,13 +1222,31 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1184
1222
|
const parts = [];
|
|
1185
1223
|
const api = __1.config.allNodesAPI[el.tag];
|
|
1186
1224
|
const emptySlot = api && api.slots && api.slots.find((slot) => slot.name === 'default' && slot['empty-background']);
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1225
|
+
const hasSupport = api && api.slots && api.slots.some((slot) => slot.support);
|
|
1226
|
+
if (emptySlot || hasSupport) {
|
|
1227
|
+
let childEmpty = !el.children.length;
|
|
1228
|
+
const defaultSlot = el.children.find((elem) => elem.tag === 'template' && elem.slotTarget === 'default');
|
|
1229
|
+
if (defaultSlot) {
|
|
1230
|
+
childEmpty = !defaultSlot.children.length;
|
|
1231
|
+
}
|
|
1232
|
+
if (childEmpty) {
|
|
1233
|
+
let addEmpty = true;
|
|
1234
|
+
if (el.tag === 'u-grid-view' || el.tag === 'u-list-view' || el.tag === 'van-list-view' || el.tag === 'van-grid-view') {
|
|
1235
|
+
const hasDataSource = el.bindAttrs.find((attr) => attr.name === 'data-source');
|
|
1236
|
+
addEmpty = !hasDataSource;
|
|
1237
|
+
}
|
|
1238
|
+
if (el.tag === 'u-crumb') {
|
|
1239
|
+
const attrList = el.bindAttrs;
|
|
1240
|
+
const hasAuto = attrList.some((attr) => attr.name === 'auto' && String(attr.value) === 'true');
|
|
1241
|
+
if (hasAuto)
|
|
1242
|
+
addEmpty = false;
|
|
1243
|
+
}
|
|
1244
|
+
if (['u-select', 'u-dropdown', 'u-panel'].includes(el.tag)) {
|
|
1245
|
+
addEmpty = false;
|
|
1246
|
+
}
|
|
1247
|
+
const background = (emptySlot && emptySlot['empty-background']) || (hasSupport ? 'add-sub' : '');
|
|
1248
|
+
addEmpty && parts.push(`vusion-empty-background="${background}"`);
|
|
1192
1249
|
}
|
|
1193
|
-
addEmpty && parts.push(`vusion-empty-background="${emptySlot['empty-background']}"`);
|
|
1194
1250
|
}
|
|
1195
1251
|
return parts;
|
|
1196
1252
|
},
|
|
@@ -1200,7 +1256,14 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1200
1256
|
* 转换成 Vue 的模板格式
|
|
1201
1257
|
*/
|
|
1202
1258
|
toVue(options) {
|
|
1203
|
-
|
|
1259
|
+
let scopeList = [];
|
|
1260
|
+
if (Array.isArray(options?.scopeList)) {
|
|
1261
|
+
scopeList = [...options?.scopeList];
|
|
1262
|
+
}
|
|
1263
|
+
if (this.slotScope) {
|
|
1264
|
+
scopeList.unshift(this.slotScope);
|
|
1265
|
+
}
|
|
1266
|
+
const newOptions = Object.assign({
|
|
1204
1267
|
indentStyle: 'space',
|
|
1205
1268
|
tabSize: 4,
|
|
1206
1269
|
indentLevel: 0,
|
|
@@ -1208,26 +1271,30 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1208
1271
|
nodePathAttr: false,
|
|
1209
1272
|
getExtraParts: () => [],
|
|
1210
1273
|
attrFormat: (attr, element, defaultResult) => defaultResult,
|
|
1211
|
-
}, options
|
|
1212
|
-
|
|
1213
|
-
|
|
1274
|
+
}, options, {
|
|
1275
|
+
scopeList,
|
|
1276
|
+
});
|
|
1277
|
+
const tabString = ' '.repeat(newOptions.tabSize * newOptions.indentLevel);
|
|
1278
|
+
const insideTabString = ' '.repeat(newOptions.tabSize * (newOptions.indentLevel + 1));
|
|
1214
1279
|
let shouldIndent = true;
|
|
1215
1280
|
const content = !this.children ? '' : this.children
|
|
1216
1281
|
.map((element) => {
|
|
1217
|
-
const childOptions = Object.assign({},
|
|
1282
|
+
const childOptions = Object.assign({}, newOptions);
|
|
1218
1283
|
childOptions.indentLevel++;
|
|
1219
|
-
return (shouldIndent ? '\n' + insideTabString : '') + element
|
|
1284
|
+
return (shouldIndent ? '\n' + insideTabString : '') + element?.toVue(childOptions);
|
|
1220
1285
|
})
|
|
1221
1286
|
.join('');
|
|
1222
|
-
if (!content.length)
|
|
1287
|
+
if (!content.length) {
|
|
1223
1288
|
shouldIndent = false;
|
|
1289
|
+
}
|
|
1224
1290
|
const parts = [];
|
|
1225
|
-
if (
|
|
1226
|
-
if (
|
|
1227
|
-
|
|
1228
|
-
|
|
1291
|
+
if (newOptions.aslIdAttr) {
|
|
1292
|
+
if (newOptions.aslIdAttr === true) {
|
|
1293
|
+
newOptions.aslIdAttr = 'asl-id';
|
|
1294
|
+
}
|
|
1295
|
+
parts.push(`${newOptions.aslIdAttr}="${this.id}"`);
|
|
1229
1296
|
}
|
|
1230
|
-
if (
|
|
1297
|
+
if (newOptions.nodePathAttr) {
|
|
1231
1298
|
// 注入 asl 的 node-path
|
|
1232
1299
|
parts.push(`vusion-node-path="${this.nodePath}"`);
|
|
1233
1300
|
}
|
|
@@ -1236,10 +1303,10 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1236
1303
|
this.staticClass && parts.push(`class="${this.staticClass}"`);
|
|
1237
1304
|
this.staticStyle && parts.push(`style="${this.staticStyle}"`);
|
|
1238
1305
|
[].concat(this.bindAttrs, this.bindDirectives, this.bindEvents).forEach((attr) => {
|
|
1239
|
-
const result =
|
|
1306
|
+
const result = newOptions.attrFormat(attr, this, attr?.toVue(newOptions));
|
|
1240
1307
|
result && parts.push(result);
|
|
1241
1308
|
});
|
|
1242
|
-
|
|
1309
|
+
newOptions.getExtraParts(this).forEach((part) => parts.push(part));
|
|
1243
1310
|
let partsLength = 0;
|
|
1244
1311
|
let partsString = '';
|
|
1245
1312
|
parts.forEach((part) => {
|
|
@@ -1252,6 +1319,37 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1252
1319
|
});
|
|
1253
1320
|
return `<${this.tag}${partsString.length ? partsString : ''}>` + content + (shouldIndent ? '\n' + tabString : '') + `</${this.tag}>`;
|
|
1254
1321
|
}
|
|
1322
|
+
/**
|
|
1323
|
+
* 从父级删除该节点
|
|
1324
|
+
* @internal
|
|
1325
|
+
*/
|
|
1326
|
+
delete() {
|
|
1327
|
+
super.delete();
|
|
1328
|
+
if (this.parentNode) {
|
|
1329
|
+
this.traverseChildren((ele) => {
|
|
1330
|
+
this.view?.removeExistingViewElement(ele);
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
findElementByName(name) {
|
|
1335
|
+
return utils.traverse((current) => {
|
|
1336
|
+
if (current.node.name === name)
|
|
1337
|
+
return current.node;
|
|
1338
|
+
}, { node: this });
|
|
1339
|
+
}
|
|
1340
|
+
findElementByTag(tag) {
|
|
1341
|
+
return utils.traverse((current) => {
|
|
1342
|
+
if (current.node.tag === tag)
|
|
1343
|
+
return current.node;
|
|
1344
|
+
}, { node: this });
|
|
1345
|
+
}
|
|
1346
|
+
findElementByAttr(name, value) {
|
|
1347
|
+
return utils.traverse((current) => {
|
|
1348
|
+
if (current.node.bindAttrs.some((attr) => attr.name === name && attr.value === value))
|
|
1349
|
+
return current.node;
|
|
1350
|
+
}, { node: this });
|
|
1351
|
+
}
|
|
1352
|
+
computedStyle = {};
|
|
1255
1353
|
};
|
|
1256
1354
|
__decorate([
|
|
1257
1355
|
(0, decorators_1.property)()
|
|
@@ -1292,12 +1390,12 @@ __decorate([
|
|
|
1292
1390
|
__decorate([
|
|
1293
1391
|
(0, decorators_1.property)('ViewElement')
|
|
1294
1392
|
], ViewElement.prototype, "children", void 0);
|
|
1295
|
-
__decorate([
|
|
1296
|
-
(0, decorators_1.property)()
|
|
1297
|
-
], ViewElement.prototype, "roles", void 0);
|
|
1298
1393
|
__decorate([
|
|
1299
1394
|
(0, translator_1.withSourceMap)()
|
|
1300
1395
|
], ViewElement.prototype, "toEmbeddedTS", null);
|
|
1396
|
+
__decorate([
|
|
1397
|
+
(0, decorators_1.excludedInJSON)()
|
|
1398
|
+
], ViewElement.prototype, "computedStyle", void 0);
|
|
1301
1399
|
ViewElement = ViewElement_1 = __decorate([
|
|
1302
1400
|
(0, decorators_1.concept)('页面元素')
|
|
1303
1401
|
], ViewElement);
|